xref: /titanic_50/usr/src/uts/common/inet/nd.h (revision c77a61a72b5ecdc507d6cf104142edd371a16c84)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/types.h>
33 #include <inet/common.h>
34 #include <inet/led.h>
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 #define	ND_BASE		('N' << 8)	/* base */
41 #define	ND_GET		(ND_BASE + 0)	/* Get a value */
42 #define	ND_SET		(ND_BASE + 1)	/* Set a value */
43 
44 #ifdef	_KERNEL
45 /* ND callback function prototypes */
46 typedef	int (*ndgetf_t)(queue_t *, MBLKP, caddr_t, cred_t *);
47 typedef	int (*ndsetf_t)(queue_t *, MBLKP, char *, caddr_t, cred_t *);
48 
49 /* Named dispatch table entry */
50 typedef struct  nde_s {
51 	char    *nde_name;
52 	pfi_t	nde_get_pfi;
53 	pfi_t	nde_set_pfi;
54 	caddr_t nde_data;
55 } NDE;
56 
57 /* Name dispatch table */
58 typedef struct  nd_s {
59 	int	nd_free_count;	/* number of unused nd table entries */
60 	int	nd_size;	/* size (in bytes) of current table */
61 	NDE	*nd_tbl;	/* pointer to table in heap */
62 } ND;
63 
64 #define	NDE_ALLOC_COUNT 32
65 #define	NDE_ALLOC_SIZE  (sizeof (NDE) * NDE_ALLOC_COUNT)
66 
67 /* 64K STREAM limit - the max ndd info header. */
68 #define	ND_MAX_BUF_LEN	65303
69 
70 /*
71  * See uts/common/inet/nd.c for comments on how to use these routines.
72  */
73 extern boolean_t	nd_load(caddr_t *, char *, ndgetf_t, ndsetf_t, caddr_t);
74 extern void		nd_unload(caddr_t *, char *);
75 extern void		nd_free(caddr_t *);
76 extern int		nd_getset(queue_t *, caddr_t, MBLKP);
77 
78 /*
79  * Canned nd_get and nd_set routines for use with nd_load().
80  */
81 extern int	nd_get_default(queue_t *, MBLKP, caddr_t, cred_t *);
82 extern int	nd_get_long(queue_t *, MBLKP, caddr_t, cred_t *);
83 extern int	nd_get_names(queue_t *, MBLKP, caddr_t, cred_t *);
84 extern int	nd_set_default(queue_t *, MBLKP, char *, caddr_t, cred_t *);
85 extern int	nd_set_long(queue_t *, MBLKP, char *, caddr_t, cred_t *);
86 
87 #endif	/* _KERNEL */
88 
89 #ifdef	__cplusplus
90 }
91 #endif
92 
93 #endif	/* _INET_ND_H */
94