xref: /freebsd/usr.bin/ipcs/ipc.h (revision b3e7694832e81d7a904a10f525f8797b753bf0d3)
11de7b4b8SPedro F. Giffuni /*-
21de7b4b8SPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
31de7b4b8SPedro F. Giffuni  *
455e2cb41SEdwin Groothuis  * Copyright (c) 1994 SigmaSoft, Th. Lockert <tholo@sigmasoft.com>
555e2cb41SEdwin Groothuis  * All rights reserved.
655e2cb41SEdwin Groothuis  *
755e2cb41SEdwin Groothuis  * Redistribution and use in source and binary forms, with or without
855e2cb41SEdwin Groothuis  * modification, are permitted provided that the following conditions
955e2cb41SEdwin Groothuis  * are met:
1055e2cb41SEdwin Groothuis  * 1. Redistributions of source code must retain the above copyright
1155e2cb41SEdwin Groothuis  *    notice, this list of conditions and the following disclaimer.
1255e2cb41SEdwin Groothuis  * 2. Redistributions in binary form must reproduce the above copyright
1355e2cb41SEdwin Groothuis  *    notice, this list of conditions and the following disclaimer in the
1455e2cb41SEdwin Groothuis  *    documentation and/or other materials provided with the distribution.
1555e2cb41SEdwin Groothuis  * 3. The name of the author may not be used to endorse or promote products
1655e2cb41SEdwin Groothuis  *    derived from this software without specific prior written permission.
1755e2cb41SEdwin Groothuis  *
1855e2cb41SEdwin Groothuis  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
1955e2cb41SEdwin Groothuis  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
2055e2cb41SEdwin Groothuis  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
2155e2cb41SEdwin Groothuis  * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
2255e2cb41SEdwin Groothuis  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
2355e2cb41SEdwin Groothuis  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
2455e2cb41SEdwin Groothuis  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
2555e2cb41SEdwin Groothuis  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
2655e2cb41SEdwin Groothuis  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
2755e2cb41SEdwin Groothuis  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2855e2cb41SEdwin Groothuis  *
29487ac9acSUlrich Spörlein  * The split of ipcs.c into ipcs.c and ipc.c to accommodate the
3055e2cb41SEdwin Groothuis  * changes in ipcrm.c was done by Edwin Groothuis <edwin@FreeBSD.org>
3155e2cb41SEdwin Groothuis  */
3255e2cb41SEdwin Groothuis 
3355e2cb41SEdwin Groothuis /* Part of struct nlist symbols[] */
3455e2cb41SEdwin Groothuis #define X_SEMA		0
3555e2cb41SEdwin Groothuis #define X_SEMINFO	1
3655e2cb41SEdwin Groothuis #define X_MSGINFO	2
3755e2cb41SEdwin Groothuis #define X_MSQIDS	3
3855e2cb41SEdwin Groothuis #define X_SHMINFO	4
3955e2cb41SEdwin Groothuis #define X_SHMSEGS	5
4055e2cb41SEdwin Groothuis 
4155e2cb41SEdwin Groothuis #define	SHMINFO		1
4255e2cb41SEdwin Groothuis #define	SHMTOTAL	2
4355e2cb41SEdwin Groothuis #define	MSGINFO		4
4455e2cb41SEdwin Groothuis #define	MSGTOTAL	8
4555e2cb41SEdwin Groothuis #define	SEMINFO		16
4655e2cb41SEdwin Groothuis #define	SEMTOTAL	32
4755e2cb41SEdwin Groothuis 
4855e2cb41SEdwin Groothuis #define IPC_TO_STR(x) (x == 'Q' ? "msq" : (x == 'M' ? "shm" : "sem"))
4955e2cb41SEdwin Groothuis #define IPC_TO_STRING(x) (x == 'Q' ? "message queue" : \
5055e2cb41SEdwin Groothuis 	    (x == 'M' ? "shared memory segment" : "semaphore"))
5155e2cb41SEdwin Groothuis 
5255e2cb41SEdwin Groothuis /* SysCtlGatherStruct structure. */
5355e2cb41SEdwin Groothuis struct scgs_vector {
5455e2cb41SEdwin Groothuis 	const char *sysctl;
5511f4012fSEitan Adler 	size_t offset;
5655e2cb41SEdwin Groothuis 	size_t size;
5755e2cb41SEdwin Groothuis };
5855e2cb41SEdwin Groothuis 
5955e2cb41SEdwin Groothuis void	kget(int idx, void *addr, size_t size);
6055e2cb41SEdwin Groothuis void	sysctlgatherstruct(void *addr, size_t size, struct scgs_vector *vec);
6155e2cb41SEdwin Groothuis 
6255e2cb41SEdwin Groothuis extern int use_sysctl;
6355e2cb41SEdwin Groothuis extern struct nlist symbols[];
6455e2cb41SEdwin Groothuis extern kvm_t *kd;
6555e2cb41SEdwin Groothuis 
6655e2cb41SEdwin Groothuis extern struct semid_kernel	*sema;
6755e2cb41SEdwin Groothuis extern struct msqid_kernel	*msqids;
6855e2cb41SEdwin Groothuis extern struct shmid_kernel	*shmsegs;
69*27b95863SBrooks Davis extern struct seminfo		 seminfo;
70*27b95863SBrooks Davis extern struct msginfo		 msginfo;
71*27b95863SBrooks Davis extern struct shminfo		 shminfo;
72