xref: /titanic_44/usr/src/uts/common/inet/rawip_impl.h (revision a776e90690d98f629ab57f6493ff5949af9d65bd)
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_bound_if;		/* IP*_BOUND_IF option */
99 
100 	/* Written to only once at the time of opening the endpoint */
101 	conn_t		*icmp_connp;
102 
103 	/* Following protected by icmp_rwlock */
104 	uint_t
105 	    icmp_debug : 1,		/* SO_DEBUG "socket" option. */
106 	    icmp_dontroute : 1,		/* SO_DONTROUTE "socket" option. */
107 	    icmp_broadcast : 1,		/* SO_BROADCAST "socket" option. */
108 	    icmp_reuseaddr : 1,		/* SO_REUSEADDR "socket" option. */
109 
110 	    icmp_useloopback : 1,	/* SO_USELOOPBACK "socket" option. */
111 	    icmp_hdrincl : 1,		/* IP_HDRINCL option + RAW and IGMP */
112 	    icmp_dgram_errind : 1,	/* SO_DGRAM_ERRIND option */
113 	    icmp_unspec_source : 1,	/* IP*_UNSPEC_SRC option */
114 
115 	    icmp_raw_checksum : 1,	/* raw checksum per IPV6_CHECKSUM */
116 	    icmp_no_tp_cksum : 1,	/* icmp_proto is UDP or TCP */
117 	    icmp_ip_recvpktinfo : 1,	/* IPV[4,6]_RECVPKTINFO option  */
118 	    icmp_ipv6_recvhoplimit : 1,	/* IPV6_RECVHOPLIMIT option */
119 
120 	    icmp_ipv6_recvhopopts : 1,	/* IPV6_RECVHOPOPTS option */
121 	    icmp_ipv6_recvdstopts : 1,	/* IPV6_RECVDSTOPTS option */
122 	    icmp_ipv6_recvrthdr : 1,	/* IPV6_RECVRTHDR option */
123 	    icmp_ipv6_recvpathmtu : 1,	/* IPV6_RECVPATHMTU option */
124 
125 	    icmp_recvif:1,		/* IP_RECVIF for raw sockets option */
126 	    icmp_ipv6_recvtclass : 1,	/* IPV6_RECVTCLASS option */
127 	    icmp_ipv6_recvrtdstopts : 1, /* Obsolete IPV6_RECVRTHDRDSTOPTS */
128 	    icmp_old_ipv6_recvdstopts : 1, /* Old ver of IPV6_RECVDSTOPTS */
129 
130 	    icmp_timestamp : 1,  	/* SO_TIMESTAMP "socket" option */
131 	    icmp_mac_exempt : 1,	/* SO_MAC_EXEMPT option */
132 
133 	    icmp_pad_to_bit_31: 10;
134 
135 	uint8_t		icmp_type_of_service;
136 	uint8_t		icmp_ttl;		/* TTL or hoplimit */
137 	uint32_t	icmp_checksum_off; /* user supplied checksum offset */
138 	icmp6_filter_t	*icmp_filter;		/* ICMP6_FILTER option */
139 
140 	ip6_pkt_t	icmp_sticky_ipp;	/* Sticky options */
141 	uint8_t		*icmp_sticky_hdrs;	/* Prebuilt IPv6 hdrs */
142 	uint_t		icmp_sticky_hdrs_len;	/* Incl. ip6h and any ip6i */
143 	zoneid_t	icmp_zoneid;		/* ID of owning zone */
144 	uint_t		icmp_label_len;		/* length of security label */
145 	uint_t		icmp_label_len_v6;	/* sec. part of sticky opt */
146 	in6_addr_t 	icmp_v6lastdst;		/* most recent destination */
147 	icmp_stack_t	*icmp_is;		/* Stack instance */
148 } icmp_t;
149 
150 /*
151  * Object to represent database of options to search passed to
152  * {sock,tpi}optcom_req() interface routine to take care of option
153  * management and associated methods.
154  */
155 extern optdb_obj_t	icmp_opt_obj;
156 extern uint_t		icmp_max_optsize;
157 
158 extern mblk_t	*icmp_snmp_get(queue_t *q, mblk_t *mpctl);
159 extern void	rawip_resume_bind(conn_t *, mblk_t *);
160 
161 extern void	icmp_ddi_init(void);
162 extern void	icmp_ddi_destroy(void);
163 
164 #endif	/* _KERNEL */
165 
166 #ifdef	__cplusplus
167 }
168 #endif
169 
170 #endif	/* _RAWIP_IMPL_H */
171