]> git.saurik.com Git - apple/xnu.git/blob - bsd/netinet/ip_flowid.h
xnu-4903.270.47.tar.gz
[apple/xnu.git] / bsd / netinet / ip_flowid.h
1 /*
2 * Copyright (c) 2011-2012 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28
29 /*
30 * Copyright (c) 2002 Luigi Rizzo, Universita` di Pisa
31 *
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions
34 * are met:
35 * 1. Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 * 2. Redistributions in binary form must reproduce the above copyright
38 * notice, this list of conditions and the following disclaimer in the
39 * documentation and/or other materials provided with the distribution.
40 *
41 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 */
54
55 #ifndef __IP_FLOWID_H__
56 #define __IP_FLOWID_H__
57
58 #include <sys/types.h>
59 #include <netinet/in.h>
60
61 /*
62 * This structure is used as a flow mask and a flow id for various
63 * parts of the code.
64 */
65 struct ip_flow_id {
66 u_int32_t dst_ip;
67 u_int32_t src_ip;
68 u_int16_t dst_port;
69 u_int16_t src_port;
70 u_int8_t proto;
71 u_int8_t flags; /* protocol-specific flags */
72 u_int8_t addr_type; /* 4 = ipv4, 6 = ipv6, 1=ether ? */
73 struct in6_addr dst_ip6; /* could also store MAC addr! */
74 struct in6_addr src_ip6;
75 u_int32_t flow_id6;
76 u_int32_t frag_id6;
77 };
78
79 #define IS_IP6_FLOW_ID(id) ((id)->addr_type == 6)
80
81 #ifdef BSD_KERNEL_PRIVATE
82 struct route_in6;
83 struct sockaddr_in6;
84 struct pf_rule;
85 struct ip_fw;
86
87 /*
88 * Arguments for calling ipfw_chk() and dummynet_io(). We put them
89 * all into a structure because this way it is easier and more
90 * efficient to pass variables around and extend the interface.
91 */
92 struct ip_fw_args {
93 struct mbuf *fwa_m; /* the mbuf chain */
94 struct ifnet *fwa_oif; /* output interface */
95 struct sockaddr_in *fwa_next_hop; /* forward address */
96 struct ip_fw *fwa_ipfw_rule; /* matching IPFW rule */
97 struct pf_rule *fwa_pf_rule; /* matching PF rule */
98 struct ether_header *fwa_eh; /* for bridged packets */
99 int fwa_flags; /* for dummynet */
100 int fwa_oflags; /* for dummynet */
101 union {
102 struct ip_out_args *_fwa_ipoa; /* for dummynet */
103 struct ip6_out_args *_fwa_ip6oa; /* for dummynet */
104 } fwa_ipoa_;
105 union {
106 struct route *_fwa_ro; /* for dummynet */
107 struct route_in6 *_fwa_ro6; /* for dummynet */
108 } fwa_ro_;
109 union {
110 struct sockaddr_in *_fwa_dst; /* for dummynet */
111 struct sockaddr_in6 *_fwa_dst6; /* for IPv6 dummynet */
112 } fwa_dst_;
113 struct route_in6 *fwa_ro6_pmtu; /* for IPv6 output */
114 struct ifnet *fwa_origifp; /* for IPv6 output */
115 u_int32_t fwa_mtu; /* for IPv6 output */
116 int fwa_alwaysfrag; /* for IPv6 output */
117 u_int32_t fwa_unfragpartlen; /* for IPv6 output */
118 struct ip6_exthdrs *fwa_exthdrs; /* for IPv6 output */
119 struct ip_flow_id fwa_id; /* grabbed from IP header */
120 u_int16_t fwa_divert_rule;/* divert cookie */
121 u_int32_t fwa_cookie;
122 };
123 #define fwa_ipoa fwa_ipoa_._fwa_ipoa
124 #define fwa_ip6oa fwa_ipoa_._fwa_ip6oa
125 #define fwa_ro fwa_ro_._fwa_ro
126 #define fwa_ro6 fwa_ro_._fwa_ro6
127 #define fwa_dst fwa_dst_._fwa_dst
128 #define fwa_dst6 fwa_dst_._fwa_dst6
129
130 /* Allocate a separate structure for inputs args to save space and bzero time */
131 struct ip_fw_in_args {
132 struct sockaddr_in *fwai_next_hop; /* forward address */
133 struct ip_fw *fwai_ipfw_rule;/* matching IPFW rule */
134 struct pf_rule *fwai_pf_rule; /* matching PF rule */
135 u_int16_t fwai_divert_rule;/* divert cookie */
136 };
137
138 #endif /* BSD_KERNEL_PRIVATE */
139
140 #endif /* __IP_FLOWID_H__ */