xref: /illumos-gate/usr/src/uts/common/inet/nd.h (revision 88f8b78a88cbdc6d8c1af5c3e54bc49d25095c98)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 1992, 1997-2001, 2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 /* Copyright (c) 1990 Mentat Inc. */
27 
28 #ifndef _INET_ND_H
29 #define	_INET_ND_H
30 
31 #pragma ident	"%Z%%M%	%I%	%E% SMI"
32 
33 #include <sys/types.h>
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 #define	ND_BASE		('N' << 8)	/* base */
40 #define	ND_GET		(ND_BASE + 0)	/* Get a value */
41 #define	ND_SET		(ND_BASE + 1)	/* Set a value */
42 
43 #ifdef	_KERNEL
44 /* ND callback function prototypes */
45 typedef	int (*ndgetf_t)(queue_t *, MBLKP, caddr_t, cred_t *);
46 typedef	int (*ndsetf_t)(queue_t *, MBLKP, char *, caddr_t, cred_t *);
47 
48 /* Named dispatch table entry */
49 typedef struct  nde_s {
50 	char    *nde_name;
51 	pfi_t	nde_get_pfi;
52 	pfi_t	nde_set_pfi;
53 	caddr_t nde_data;
54 } NDE;
55 
56 /* Name dispatch table */
57 typedef struct  nd_s {
58 	int	nd_free_count;	/* number of unused nd table entries */
59 	int	nd_size;	/* size (in bytes) of current table */
60 	NDE	*nd_tbl;	/* pointer to table in heap */
61 } ND;
62 
63 #define	NDE_ALLOC_COUNT 32
64 #define	NDE_ALLOC_SIZE  (sizeof (NDE) * NDE_ALLOC_COUNT)
65 
66 /* 64K STREAM limit - the max ndd info header. */
67 #define	ND_MAX_BUF_LEN	65303
68 
69 /*
70  * See uts/common/inet/nd.c for comments on how to use these routines.
71  */
72 extern boolean_t	nd_load(caddr_t *, char *, ndgetf_t, ndsetf_t, caddr_t);
73 extern void		nd_unload(caddr_t *, char *);
74 extern void		nd_free(caddr_t *);
75 extern int		nd_getset(queue_t *, caddr_t, MBLKP);
76 
77 /*
78  * Canned nd_get and nd_set routines for use with nd_load().
79  */
80 extern int	nd_get_default(queue_t *, MBLKP, caddr_t, cred_t *);
81 extern int	nd_get_long(queue_t *, MBLKP, caddr_t, cred_t *);
82 extern int	nd_get_names(queue_t *, MBLKP, caddr_t, cred_t *);
83 extern int	nd_set_default(queue_t *, MBLKP, char *, caddr_t, cred_t *);
84 extern int	nd_set_long(queue_t *, MBLKP, char *, caddr_t, cred_t *);
85 
86 #endif	/* _KERNEL */
87 
88 #ifdef	__cplusplus
89 }
90 #endif
91 
92 #endif	/* _INET_ND_H */
93