/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* bos720 src/bos/kernel/sys/ipc_info.h 1.1                               */
/*                                                                        */
/* Licensed Materials - Property of IBM                                   */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2009                   */
/* All Rights Reserved                                                    */
/*                                                                        */
/* US Government Users Restricted Rights - Use, duplication or            */
/* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.      */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
/* @(#)45	1.1  src/bos/kernel/sys/ipc_info.h, sysipc, bos720 2/16/09 14:24:45 */

/*
 * COMPONENT_NAME: (SYSIPC) IPC Facility 
 */

#ifndef _H_IPC_INFO
#define _H_IPC_INFO

#include <sys/types.h>
#include <sys/msg.h>
#include <sys/corralid.h>
#include <mqueue.h>

#ifdef __cplusplus
extern "C" {
#endif

int get_ipc_info(cid_t cid, 
                 int cmd, 
                 int version, 
                 caddr_t buffer, 
                 int * size);

/* 
 *  The list of valid commands for get_ipc_info()
 */
#define GET_IPCINFO_SHM		1    /* return specific ipc */
#define GET_IPCINFO_SEM		2 
#define GET_IPCINFO_MSG		3
#define GET_IPCINFO_SHM_ALL	4    /* return all shm viewable in WPAR */
#define GET_IPCINFO_SEM_ALL	5    /* return all sem viewable in WPAR */
#define GET_IPCINFO_MSG_ALL	6    /* return all msg viewable in WPAR */

#define GET_IPCINFO_RTSHM	17
#define GET_IPCINFO_RTSEM	18
#define GET_IPCINFO_RTMSG	19


/* 
 * The POSIX version of the structures ipcinfo_rt*_t
 * contain the non POSIX structure and the ipcinfo_rtipc_t
 * structure.  A version request for the POSIX structures
 * will map to a version of the POSIX and non POSIX sections.
 */

/* 
 * Supported versions of the IPCINFO_ structures
 */
        /* the POSIX portion of the POSIX structures. */
#define IPCINFO_RTIPC_VERSION_0		0

#define IPCINFO_SHM_VERSION_1 		1
#define IPCINFO_SEM_VERSION_0 		0
#define IPCINFO_MSG_VERSION_0 		0

	/* this maps to a ver=1 of SHM and ver=0 of RTIPC */
#define IPCINFO_RTSHM_VERSION_1 	1
	/* this maps to a ver=0 of SEM and ver=0 of RTIPC */
#define IPCINFO_RTSEM_VERSION_0 	0
	/* this maps to a ver=0 of MSG and ver=0 of RTIPC */
#define IPCINFO_RTMSG_VERSION_0 	0

/*
 * Currently latest versions of the IPCINFO_ structures
 */
#define IPCINFO_SHM_VERSION 	IPCINFO_SHM_VERSION_1
#define IPCINFO_SEM_VERSION 	IPCINFO_SEM_VERSION_0
#define IPCINFO_MSG_VERSION 	IPCINFO_MSG_VERSION_0

#define IPCINFO_RTSHM_VERSION 	IPCINFO_RTSHM_VERSION_1
#define IPCINFO_RTSEM_VERSION 	IPCINFO_RTSEM_VERSION_0
#define IPCINFO_RTMSG_VERSION 	IPCINFO_RTMSG_VERSION_0

/* Currently latest versions of the RTIPC protion of POSIX structures */
#define IPCINFO_RTIPC_VERSION	IPCINFO_RTIPC_VERSION_0


#define IPCINFO_IPC_INUSE     0x01 /* ipc currently used */
#define IPCINFO_IPC_UNLINKED  0x02 /* ipc successfully unlinked */
#define IPCINFO_IPC_UNNAMED   0x04 /* unnamed ipc */
#define IPCINFO_IPC_SHARED    0x08 /* semaphore shared between processes */
#define IPCINFO_IPC_DESTROY   0x10 /* semaphore being removed */

typedef unsigned long long	shmatt64_t;
typedef	unsigned long long	key64_t;
typedef uint32_t 		msgqnum32_t;

typedef struct ipc_perm_inv {
	uid_t		uid;		/* owner's user id	*/
	gid_t		gid;		/* owner's group id	*/
	uid_t		cuid;		/* creator's user id	*/
	gid_t		cgid;		/* creator's group id	*/
	mode_t		mode;		/* access modes		*/
	unsigned short  _unused;	/* unused		*/
	unsigned short	seq;		/* slot sequence number */
	key64_t		key;		/* key			*/	
} ipc_perm_inv_t;

typedef struct ipcinfo_msg_struct {
	uint32_t        msg_version;    /* in case we want to change */
	ipc_perm_inv_t	msg_perm;
        uint32_t        msg_cbytes;     /* current # bytes on q */
        msgqnum32_t     msg_qnum;       /* # of messages on q */
        uint32_t        msg_qbytes;     /* max # of bytes on q */
        pid64_t         msg_lspid;      /* pid of last msgsnd */
        pid64_t         msg_lrpid;      /* pid of last msgrcv */
        time64_t        msg_stime;      /* last msgsnd time */
        time64_t        msg_rtime;      /* last msgrcv time */
        time64_t        msg_ctime;      /* last change time */
	int		msg_id;		/* msg id */
	int	        rt_ipcx;
	uint_t          maxmsg;         /* max # of messages on q */
	pid64_t		v_msg_lspid;    /* virtual pid of last msgsnd */
	pid64_t		v_msg_lrpid;    /* virtual pid of last msgrcv */
	cid_t		msg_cid;	/* WPAR identifier */
} ipcinfo_msg_t;

typedef struct ipcinfo_shm_struct {
	uint32_t        shm_version;    /* in case we want to change */
	ipc_perm_inv_t	shm_perm;
	size64_t	shm_segsz;	/* segment size */
	pid64_t		shm_lpid;	/* pid of last shmop */
	pid64_t		shm_cpid;	/* pid of creator */
	shmatt64_t	shm_nattch;	/* current # attached */
	shmatt64_t	shm_cnattch;	/* in memory # attached */
	time64_t	shm_atime;	/* last shmat time */
	time64_t	shm_dtime;	/* last shmdt time */
	time64_t	shm_ctime;	/* last change time */
	int		shm_id;		/* shm id */
	int	        rt_ipcx;
	pid64_t		v_shm_lpid;	/* virtual pid of last shmop */
	pid64_t		v_shm_cpid;	/* virtual pid of creator */
	cid_t		shm_cid;	/* WPAR identifier */
	int             shm_flags;	/* Flags*/
	psize_t         shm_pagesize;   /* page size of shm region */
} ipcinfo_shm_t;

typedef struct ipcinfo_sem_struct {
	uint32_t        sem_version;    /* in case we want to change 	*/
	ipc_perm_inv_t	sem_perm;
	unsigned short  _unused;	/* unused 			*/
        unsigned short  sem_nsems;      /* # of semaphores in set       */
        time64_t        sem_otime;      /* last semop time              */
        time64_t        sem_ctime;      /* last change time             */
	int		sem_id;		/* sem id */
	int	        rt_ipcx;
	cid_t		sem_cid;	/* WPAR identifier */
} ipcinfo_sem_t;

/* structure representing  real time ipc */
typedef struct ipcinfo_rtipc_struct {
	uint32_t	rtipc_version;
	uint32_t        rtipc_sysVid; 	/* sysV IPC id  */
	int           	rtipc_flags;
	cid_t		rtipc_cid;	/* WPAR identifier */
	char 		rtipc_name[PATH_MAX]; /* pathname */
} ipcinfo_rtipc_t;

typedef struct ipcinfo_rtsem_struct {
	ipcinfo_rtipc_t rtipc;
	int 		semval; 	/* sysV semaphore value   */
	pid64_t 	crpid;		/* virtual PID of creator */
	ipcinfo_sem_t 	sysVinfo;
} ipcinfo_rtsem_t;

typedef struct ipcinfo_rtmq_struct {
	ipcinfo_rtipc_t rtipc;
        uint_t        	msgsize;	/* max message size */
	ipcinfo_msg_t 	sysVinfo;
} ipcinfo_rtmq_t;

typedef struct ipcinfo_rtshm_struct {
	ipcinfo_rtipc_t rtipc;
	int           	vmecount; 	/* # of posix vm_map_entry */
	ipcinfo_shm_t 	sysVinfo;
} ipcinfo_rtshm_t;

#ifdef __cplusplus
}
#endif

#endif /* _H_IPCINFO */

