xref: /titanic_41/usr/src/uts/common/inet/rawip_impl.h (revision edafac1f8203a7de1490688213c118b03215c89d)
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 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 /* Copyright (c) 1990 Mentat Inc. */
26 
27 #ifndef	_RAWIP_IMPL_H
28 #define	_RAWIP_IMPL_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 #ifdef _KERNEL
35 
36 #include <sys/types.h>
37 #include <sys/netstack.h>
38 
39 #include <netinet/in.h>
40 #include <netinet/icmp6.h>
41 #include <netinet/ip6.h>
42 
43 #include <inet/common.h>
44 #include <inet/ip.h>
45 #include <inet/optcom.h>
46 
47 /* Named Dispatch Parameter Management Structure */
48 typedef struct icmpparam_s {
49 	uint_t	icmp_param_min;
50 	uint_t	icmp_param_max;
51 	uint_t	icmp_param_value;
52 	char	*icmp_param_name;
53 } icmpparam_t;
54 
55 /*
56  * ICMP stack instances
57  */
58 struct icmp_stack {
59 	netstack_t	*is_netstack;	/* Common netstack */
60 	void		*is_head;	/* Head for list of open icmps */
61 	IDP		is_nd;	/* Points to table of ICMP ND variables. */
62 	icmpparam_t	*is_param_arr; 	/* ndd variable table */
63 	kstat_t		*is_ksp;	/* kstats */
64 	mib2_rawip_t	is_rawip_mib;	/* SNMP fixed size info */
65 	ldi_ident_t	is_ldi_ident;
66 };
67 
68 typedef struct icmp_stack icmp_stack_t;
69 
70 /* Internal icmp control structure, one per open stream */
71 typedef	struct icmp_s {
72 	/*
73 	 * The addresses and ports in the conn_t and icmp_state are protected by
74 	 * conn_lock. conn_lock also protects the content of icmp_t.
75 	 */
76 	uint_t		icmp_state;	/* TPI state */
77 
78 	/* Written to only once at the time of opening the endpoint */
79 	conn_t		*icmp_connp;
80 
81 	uint_t
82 	    icmp_hdrincl : 1,		/* IP_HDRINCL option + RAW and IGMP */
83 
84 	    icmp_pad_to_bit_31: 31;
85 
86 	icmp6_filter_t	*icmp_filter;		/* ICMP6_FILTER option */
87 
88 	/* Set at open time and never changed */
89 	icmp_stack_t	*icmp_is;		/* Stack instance */
90 
91 	int		icmp_delayed_error;
92 	kmutex_t	icmp_recv_lock;
93 	mblk_t		*icmp_fallback_queue_head;
94 	mblk_t		*icmp_fallback_queue_tail;
95 	struct sockaddr_storage	icmp_delayed_addr;
96 } icmp_t;
97 
98 /*
99  * Object to represent database of options to search passed to
100  * {sock,tpi}optcom_req() interface routine to take care of option
101  * management and associated methods.
102  */
103 extern optdb_obj_t	icmp_opt_obj;
104 extern uint_t		icmp_max_optsize;
105 
106 extern int	icmp_opt_default(queue_t *, t_scalar_t, t_scalar_t, uchar_t *);
107 extern int	icmp_tpi_opt_get(queue_t *, t_scalar_t, t_scalar_t, uchar_t *);
108 extern int	icmp_tpi_opt_set(queue_t *, uint_t, int, int, uint_t, uchar_t *,
109 		    uint_t *, uchar_t *, void *, cred_t *);
110 extern mblk_t	*icmp_snmp_get(queue_t *q, mblk_t *mpctl);
111 
112 extern void	icmp_ddi_g_init(void);
113 extern void	icmp_ddi_g_destroy(void);
114 
115 extern sock_lower_handle_t rawip_create(int, int, int, sock_downcalls_t **,
116     uint_t *, int *, int, cred_t *);
117 extern int rawip_fallback(sock_lower_handle_t, queue_t *, boolean_t,
118     so_proto_quiesced_cb_t);
119 
120 extern sock_downcalls_t sock_rawip_downcalls;
121 
122 #endif	/* _KERNEL */
123 
124 #ifdef	__cplusplus
125 }
126 #endif
127 
128 #endif	/* _RAWIP_IMPL_H */
129