xref: /illumos-gate/usr/src/uts/common/inet/rawip_impl.h (revision f4b3ec61df05330d25f55a36b975b4d7519fdeb1)
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 	uint_t		icmp_state;	/* TPI state */
72 	in6_addr_t	icmp_v6src;	/* Source address of this stream */
73 	in6_addr_t	icmp_bound_v6src; /* Explicitely bound to address */
74 	in6_addr_t 	icmp_v6dst;	/* Connected destination */
75 	uint32_t	icmp_flowinfo;	/* Connected flow id and tclass */
76 	uint32_t 	icmp_max_hdr_len; /* For write offset in stream head */
77 	sa_family_t	icmp_family;	/* Family from socket() call */
78 	/*
79 	 * IP format that packets transmitted from this struct should use.
80 	 * Value can be IP4_VERSION or IPV6_VERSION.
81 	 */
82 	uchar_t	icmp_ipversion;
83 
84 	uint_t		icmp_proto;
85 	uint_t		icmp_ip_snd_options_len; /* Len of IPv4 options */
86 	uint8_t		*icmp_ip_snd_options;	/* Ptr to IPv4 options */
87 	uint8_t		icmp_multicast_ttl;	/* IP*_MULTICAST_TTL/HOPS */
88 	ipaddr_t	icmp_multicast_if_addr; /* IP_MULTICAST_IF option */
89 	uint_t		icmp_multicast_if_index; /* IPV6_MULTICAST_IF option */
90 	int		icmp_bound_if;		/* IP*_BOUND_IF option */
91 	int		icmp_xmit_if;		/* IP_XMIT_IF option */
92 
93 	uint_t
94 	    icmp_debug : 1,		/* SO_DEBUG "socket" option. */
95 	    icmp_dontroute : 1,		/* SO_DONTROUTE "socket" option. */
96 	    icmp_broadcast : 1,		/* SO_BROADCAST "socket" option. */
97 	    icmp_reuseaddr : 1,		/* SO_REUSEADDR "socket" option. */
98 
99 	    icmp_useloopback : 1,	/* SO_USELOOPBACK "socket" option. */
100 	    icmp_multicast_loop : 1,	/* IP_MULTICAST_LOOP option */
101 	    icmp_hdrincl : 1,		/* IP_HDRINCL option + RAW and IGMP */
102 	    icmp_dgram_errind : 1,	/* SO_DGRAM_ERRIND option */
103 
104 	    icmp_discon_pending : 1,	/* T_DISCON_REQ in progress */
105 	    icmp_unspec_source : 1,	/* IP*_UNSPEC_SRC option */
106 	    icmp_raw_checksum : 1,	/* raw checksum per IPV6_CHECKSUM */
107 	    icmp_no_tp_cksum : 1,	/* icmp_proto is UDP or TCP */
108 
109 	    icmp_ip_recvpktinfo : 1,	/* IPV[4,6]_RECVPKTINFO option  */
110 	    icmp_ipv6_recvhoplimit : 1,	/* IPV6_RECVHOPLIMIT option */
111 	    icmp_ipv6_recvhopopts : 1,	/* IPV6_RECVHOPOPTS option */
112 	    icmp_ipv6_recvdstopts : 1,	/* IPV6_RECVDSTOPTS option */
113 
114 	    icmp_ipv6_recvrthdr : 1,	/* IPV6_RECVRTHDR option */
115 	    icmp_ipv6_recvpathmtu : 1,	/* IPV6_RECVPATHMTU option */
116 	    icmp_recvif:1,		/* IP_RECVIF for raw sockets option */
117 	    icmp_ipv6_recvtclass : 1,	/* IPV6_RECVTCLASS option */
118 
119 	    icmp_restricted : 1,	/* opened by non-privileged user */
120 	    icmp_ipv6_recvrtdstopts : 1, /* Obsolete IPV6_RECVRTHDRDSTOPTS */
121 	    icmp_old_ipv6_recvdstopts : 1, /* Old ver of IPV6_RECVDSTOPTS */
122 	    icmp_timestamp : 1,  	/* SO_TIMESTAMP "socket" option */
123 	    icmp_mac_exempt : 1,	/* SO_MAC_EXEMPT option */
124 
125 	    icmp_pad_to_bit_31: 7;
126 
127 	uint8_t		icmp_type_of_service;
128 	uint8_t		icmp_ttl;		/* TTL or hoplimit */
129 	uint32_t	icmp_checksum_off; /* user supplied checksum offset */
130 	icmp6_filter_t	*icmp_filter;		/* ICMP6_FILTER option */
131 	cred_t		*icmp_credp;		/* Opener's credentials */
132 
133 	ip6_pkt_t	icmp_sticky_ipp;	/* Sticky options */
134 	uint8_t		*icmp_sticky_hdrs;	/* Prebuilt IPv6 hdrs */
135 	uint_t		icmp_sticky_hdrs_len;	/* Incl. ip6h and any ip6i */
136 	zoneid_t	icmp_zoneid;		/* ID of owning zone */
137 	uint_t		icmp_label_len;		/* length of security label */
138 	uint_t		icmp_label_len_v6;	/* sec. part of sticky opt */
139 	in6_addr_t 	icmp_v6lastdst;		/* most recent destination */
140 	mblk_t		*icmp_delabel;		/* send this on close */
141 	icmp_stack_t	*icmp_is;		/* Stack instance */
142 } icmp_t;
143 #define	icmp_rawip_mib	icmp_is->is_rawip_mib
144 
145 #endif	/* _KERNEL */
146 
147 #ifdef	__cplusplus
148 }
149 #endif
150 
151 #endif	/* _RAWIP_IMPL_H */
152