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