xref: /titanic_50/usr/src/uts/common/inet/rawip_impl.h (revision ab4a9beb2e4d596be0b3288c7d92919e27781b57)
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 2007 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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #ifdef _KERNEL
37 
38 #include <sys/types.h>
39 #include <sys/netstack.h>
40 
41 #include <netinet/in.h>
42 #include <netinet/icmp6.h>
43 #include <netinet/ip6.h>
44 
45 #include <inet/common.h>
46 #include <inet/ip.h>
47 
48 /* Named Dispatch Parameter Management Structure */
49 typedef struct icmpparam_s {
50 	uint_t	icmp_param_min;
51 	uint_t	icmp_param_max;
52 	uint_t	icmp_param_value;
53 	char	*icmp_param_name;
54 } icmpparam_t;
55 
56 /*
57  * ICMP stack instances
58  */
59 struct icmp_stack {
60 	netstack_t	*is_netstack;	/* Common netstack */
61 	void		*is_head;	/* Head for list of open icmps */
62 	IDP		is_nd;	/* Points to table of ICMP ND variables. */
63 	icmpparam_t	*is_param_arr; 	/* ndd variable table */
64 	kstat_t		*is_ksp;	/* kstats */
65 	mib2_rawip_t	is_rawip_mib;	/* SNMP fixed size info */
66 };
67 typedef struct icmp_stack icmp_stack_t;
68 
69 /* Internal icmp control structure, one per open stream */
70 typedef	struct icmp_s {
71 	krwlock_t	icmp_rwlock;	/* Protects most of icmp_t */
72 	t_scalar_t	icmp_pending_op;	/* The current TPI operation */
73 	/*
74 	 * Following fields up to icmp_ipversion protected by conn_lock.
75 	 */
76 	uint_t		icmp_state;	/* TPI state */
77 	in6_addr_t	icmp_v6src;	/* Source address of this stream */
78 	in6_addr_t	icmp_bound_v6src; /* Explicitely bound to address */
79 	in6_addr_t 	icmp_v6dst;	/* Connected destination */
80 	/*
81 	 * IP format that packets transmitted from this struct should use.
82 	 * Value can be IP4_VERSION or IPV6_VERSION.
83 	 */
84 	uchar_t		icmp_ipversion;
85 
86 	/* Written to only once at the time of opening the endpoint */
87 	sa_family_t	icmp_family;	/* Family from socket() call */
88 
89 	/* Following protected by icmp_rwlock */
90 	uint32_t	icmp_flowinfo;	/* Connected flow id and tclass */
91 	uint32_t 	icmp_max_hdr_len; /* For write offset in stream head */
92 	uint_t		icmp_proto;
93 	uint_t		icmp_ip_snd_options_len; /* Len of IPv4 options */
94 	uint8_t		*icmp_ip_snd_options;	/* Ptr to IPv4 options */
95 	uint8_t		icmp_multicast_ttl;	/* IP*_MULTICAST_TTL/HOPS */
96 	ipaddr_t	icmp_multicast_if_addr; /* IP_MULTICAST_IF option */
97 	uint_t		icmp_multicast_if_index; /* IPV6_MULTICAST_IF option */
98 	int		icmp_xmit_if;		/* IP_XMIT_IF option */
99 	int		icmp_bound_if;		/* IP*_BOUND_IF option */
100 
101 	/* Written to only once at the time of opening the endpoint */
102 	conn_t		*icmp_connp;
103 
104 	/* Following protected by icmp_rwlock */
105 	uint_t
106 	    icmp_debug : 1,		/* SO_DEBUG "socket" option. */
107 	    icmp_dontroute : 1,		/* SO_DONTROUTE "socket" option. */
108 	    icmp_broadcast : 1,		/* SO_BROADCAST "socket" option. */
109 	    icmp_reuseaddr : 1,		/* SO_REUSEADDR "socket" option. */
110 
111 	    icmp_useloopback : 1,	/* SO_USELOOPBACK "socket" option. */
112 	    icmp_hdrincl : 1,		/* IP_HDRINCL option + RAW and IGMP */
113 	    icmp_dgram_errind : 1,	/* SO_DGRAM_ERRIND option */
114 	    icmp_unspec_source : 1,	/* IP*_UNSPEC_SRC option */
115 
116 	    icmp_raw_checksum : 1,	/* raw checksum per IPV6_CHECKSUM */
117 	    icmp_no_tp_cksum : 1,	/* icmp_proto is UDP or TCP */
118 	    icmp_ip_recvpktinfo : 1,	/* IPV[4,6]_RECVPKTINFO option  */
119 	    icmp_ipv6_recvhoplimit : 1,	/* IPV6_RECVHOPLIMIT option */
120 
121 	    icmp_ipv6_recvhopopts : 1,	/* IPV6_RECVHOPOPTS option */
122 	    icmp_ipv6_recvdstopts : 1,	/* IPV6_RECVDSTOPTS option */
123 	    icmp_ipv6_recvrthdr : 1,	/* IPV6_RECVRTHDR option */
124 	    icmp_ipv6_recvpathmtu : 1,	/* IPV6_RECVPATHMTU option */
125 
126 	    icmp_recvif:1,		/* IP_RECVIF for raw sockets option */
127 	    icmp_ipv6_recvtclass : 1,	/* IPV6_RECVTCLASS option */
128 	    icmp_ipv6_recvrtdstopts : 1, /* Obsolete IPV6_RECVRTHDRDSTOPTS */
129 	    icmp_old_ipv6_recvdstopts : 1, /* Old ver of IPV6_RECVDSTOPTS */
130 
131 	    icmp_timestamp : 1,  	/* SO_TIMESTAMP "socket" option */
132 	    icmp_mac_exempt : 1,	/* SO_MAC_EXEMPT option */
133 
134 	    icmp_pad_to_bit_31: 10;
135 
136 	uint8_t		icmp_type_of_service;
137 	uint8_t		icmp_ttl;		/* TTL or hoplimit */
138 	uint32_t	icmp_checksum_off; /* user supplied checksum offset */
139 	icmp6_filter_t	*icmp_filter;		/* ICMP6_FILTER option */
140 
141 	ip6_pkt_t	icmp_sticky_ipp;	/* Sticky options */
142 	uint8_t		*icmp_sticky_hdrs;	/* Prebuilt IPv6 hdrs */
143 	uint_t		icmp_sticky_hdrs_len;	/* Incl. ip6h and any ip6i */
144 	zoneid_t	icmp_zoneid;		/* ID of owning zone */
145 	uint_t		icmp_label_len;		/* length of security label */
146 	uint_t		icmp_label_len_v6;	/* sec. part of sticky opt */
147 	in6_addr_t 	icmp_v6lastdst;		/* most recent destination */
148 	icmp_stack_t	*icmp_is;		/* Stack instance */
149 } icmp_t;
150 
151 /*
152  * Object to represent database of options to search passed to
153  * {sock,tpi}optcom_req() interface routine to take care of option
154  * management and associated methods.
155  */
156 extern optdb_obj_t	icmp_opt_obj;
157 extern uint_t		icmp_max_optsize;
158 
159 extern mblk_t	*icmp_snmp_get(queue_t *q, mblk_t *mpctl);
160 extern void	rawip_resume_bind(conn_t *, mblk_t *);
161 
162 extern void	icmp_ddi_init(void);
163 extern void	icmp_ddi_destroy(void);
164 
165 #endif	/* _KERNEL */
166 
167 #ifdef	__cplusplus
168 }
169 #endif
170 
171 #endif	/* _RAWIP_IMPL_H */
172