| 1 | /* |
| 2 | * Copyright (c) 2011-2019 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 | |
| 86 | /* |
| 87 | * Arguments for calling ipfw_chk() and dummynet_io(). We put them |
| 88 | * all into a structure because this way it is easier and more |
| 89 | * efficient to pass variables around and extend the interface. |
| 90 | */ |
| 91 | struct ip_fw_args { |
| 92 | struct mbuf *fwa_m; /* the mbuf chain */ |
| 93 | struct ifnet *fwa_oif; /* output interface */ |
| 94 | struct pf_rule *fwa_pf_rule; /* matching PF rule */ |
| 95 | struct ether_header *fwa_eh; /* for bridged packets */ |
| 96 | int fwa_flags; /* for dummynet */ |
| 97 | int fwa_oflags; /* for dummynet */ |
| 98 | union { |
| 99 | struct ip_out_args *_fwa_ipoa; /* for dummynet */ |
| 100 | struct ip6_out_args *_fwa_ip6oa; /* for dummynet */ |
| 101 | } fwa_ipoa_; |
| 102 | union { |
| 103 | struct route *_fwa_ro; /* for dummynet */ |
| 104 | struct route_in6 *_fwa_ro6; /* for dummynet */ |
| 105 | } fwa_ro_; |
| 106 | union { |
| 107 | struct sockaddr_in *_fwa_dst; /* for dummynet */ |
| 108 | struct sockaddr_in6 *_fwa_dst6; /* for IPv6 dummynet */ |
| 109 | } fwa_dst_; |
| 110 | struct route_in6 *fwa_ro6_pmtu; /* for IPv6 output */ |
| 111 | struct ifnet *fwa_origifp; /* for IPv6 output */ |
| 112 | u_int32_t fwa_mtu; /* for IPv6 output */ |
| 113 | u_int32_t fwa_unfragpartlen; /* for IPv6 output */ |
| 114 | struct ip6_exthdrs *fwa_exthdrs; /* for IPv6 output */ |
| 115 | struct ip_flow_id fwa_id; /* grabbed from IP header */ |
| 116 | u_int32_t fwa_cookie; |
| 117 | }; |
| 118 | #define fwa_ipoa fwa_ipoa_._fwa_ipoa |
| 119 | #define fwa_ip6oa fwa_ipoa_._fwa_ip6oa |
| 120 | #define fwa_ro fwa_ro_._fwa_ro |
| 121 | #define fwa_ro6 fwa_ro_._fwa_ro6 |
| 122 | #define fwa_dst fwa_dst_._fwa_dst |
| 123 | #define fwa_dst6 fwa_dst_._fwa_dst6 |
| 124 | |
| 125 | /* Allocate a separate structure for inputs args to save space and bzero time */ |
| 126 | struct ip_fw_in_args { |
| 127 | struct pf_rule *fwai_pf_rule; /* matching PF rule */ |
| 128 | }; |
| 129 | |
| 130 | #endif /* BSD_KERNEL_PRIVATE */ |
| 131 | |
| 132 | #endif /* __IP_FLOWID_H__ */ |
| 133 | |