| 1 | /* | 
|---|
| 2 | * Copyright (c) 2008-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 | /*	$KAME: ip6protosw.h,v 1.22 2001/02/08 18:02:08 itojun Exp $	*/ | 
|---|
| 30 |  | 
|---|
| 31 | /* | 
|---|
| 32 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. | 
|---|
| 33 | * All rights reserved. | 
|---|
| 34 | * | 
|---|
| 35 | * Redistribution and use in source and binary forms, with or without | 
|---|
| 36 | * modification, are permitted provided that the following conditions | 
|---|
| 37 | * are met: | 
|---|
| 38 | * 1. Redistributions of source code must retain the above copyright | 
|---|
| 39 | *    notice, this list of conditions and the following disclaimer. | 
|---|
| 40 | * 2. Redistributions in binary form must reproduce the above copyright | 
|---|
| 41 | *    notice, this list of conditions and the following disclaimer in the | 
|---|
| 42 | *    documentation and/or other materials provided with the distribution. | 
|---|
| 43 | * 3. Neither the name of the project nor the names of its contributors | 
|---|
| 44 | *    may be used to endorse or promote products derived from this software | 
|---|
| 45 | *    without specific prior written permission. | 
|---|
| 46 | * | 
|---|
| 47 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND | 
|---|
| 48 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 
|---|
| 49 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 
|---|
| 50 | * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE | 
|---|
| 51 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 
|---|
| 52 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 
|---|
| 53 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 
|---|
| 54 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 
|---|
| 55 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 
|---|
| 56 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 
|---|
| 57 | * SUCH DAMAGE. | 
|---|
| 58 | * | 
|---|
| 59 | */ | 
|---|
| 60 |  | 
|---|
| 61 | /*	BSDI protosw.h,v 2.3 1996/10/11 16:02:40 pjd Exp	*/ | 
|---|
| 62 |  | 
|---|
| 63 | /*- | 
|---|
| 64 | * Copyright (c) 1982, 1986, 1993 | 
|---|
| 65 | *	The Regents of the University of California.  All rights reserved. | 
|---|
| 66 | * | 
|---|
| 67 | * Redistribution and use in source and binary forms, with or without | 
|---|
| 68 | * modification, are permitted provided that the following conditions | 
|---|
| 69 | * are met: | 
|---|
| 70 | * 1. Redistributions of source code must retain the above copyright | 
|---|
| 71 | *    notice, this list of conditions and the following disclaimer. | 
|---|
| 72 | * 2. Redistributions in binary form must reproduce the above copyright | 
|---|
| 73 | *    notice, this list of conditions and the following disclaimer in the | 
|---|
| 74 | *    documentation and/or other materials provided with the distribution. | 
|---|
| 75 | * 3. All advertising materials mentioning features or use of this software | 
|---|
| 76 | *    must display the following acknowledgement: | 
|---|
| 77 | *	This product includes software developed by the University of | 
|---|
| 78 | *	California, Berkeley and its contributors. | 
|---|
| 79 | * 4. Neither the name of the University nor the names of its contributors | 
|---|
| 80 | *    may be used to endorse or promote products derived from this software | 
|---|
| 81 | *    without specific prior written permission. | 
|---|
| 82 | * | 
|---|
| 83 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | 
|---|
| 84 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 
|---|
| 85 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 
|---|
| 86 | * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 
|---|
| 87 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 
|---|
| 88 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 
|---|
| 89 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 
|---|
| 90 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 
|---|
| 91 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 
|---|
| 92 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 
|---|
| 93 | * SUCH DAMAGE. | 
|---|
| 94 | * | 
|---|
| 95 | *	@(#)protosw.h	8.1 (Berkeley) 6/2/93 | 
|---|
| 96 | */ | 
|---|
| 97 |  | 
|---|
| 98 | #ifndef _NETINET6_IP6PROTOSW_H_ | 
|---|
| 99 | #define _NETINET6_IP6PROTOSW_H_ | 
|---|
| 100 | #include <sys/appleapiopts.h> | 
|---|
| 101 |  | 
|---|
| 102 | #ifdef BSD_KERNEL_PRIVATE | 
|---|
| 103 | #include <kern/locks.h> | 
|---|
| 104 |  | 
|---|
| 105 | /* | 
|---|
| 106 | * Protocol switch table for IPv6. | 
|---|
| 107 | * All other definitions should refer to sys/protosw.h | 
|---|
| 108 | */ | 
|---|
| 109 |  | 
|---|
| 110 | struct mbuf; | 
|---|
| 111 | struct sockaddr; | 
|---|
| 112 | struct socket; | 
|---|
| 113 | struct domain; | 
|---|
| 114 | struct ip6_hdr; | 
|---|
| 115 | struct icmp6_hdr; | 
|---|
| 116 | struct in6_addr; | 
|---|
| 117 | struct pr_usrreqs; | 
|---|
| 118 |  | 
|---|
| 119 | /* | 
|---|
| 120 | * argument type for the last arg of pr_ctlinput(). | 
|---|
| 121 | * should be consulted only with AF_INET6 family. | 
|---|
| 122 | * | 
|---|
| 123 | * IPv6 ICMP IPv6 [exthdrs] finalhdr payload | 
|---|
| 124 | * ^    ^    ^              ^ | 
|---|
| 125 | * |    |    ip6c_ip6       ip6c_off | 
|---|
| 126 | * |    ip6c_icmp6 | 
|---|
| 127 | * ip6c_m | 
|---|
| 128 | * | 
|---|
| 129 | * ip6c_finaldst usually points to ip6c_ip6->ip6_dst.  if the original | 
|---|
| 130 | * (internal) packet carries a routing header, it may point the final | 
|---|
| 131 | * dstination address in the routing header. | 
|---|
| 132 | * | 
|---|
| 133 | * ip6c_src: ip6c_ip6->ip6_src + scope info + flowlabel in ip6c_ip6 | 
|---|
| 134 | *	(beware of flowlabel, if you try to compare it against others) | 
|---|
| 135 | * ip6c_dst: ip6c_finaldst + scope info | 
|---|
| 136 | */ | 
|---|
| 137 | struct ip6ctlparam { | 
|---|
| 138 | struct mbuf *ip6c_m;            /* start of mbuf chain */ | 
|---|
| 139 | struct icmp6_hdr *ip6c_icmp6;   /* icmp6 header of target packet */ | 
|---|
| 140 | struct ip6_hdr *ip6c_ip6;       /* ip6 header of target packet */ | 
|---|
| 141 | int ip6c_off;                   /* offset of the target proto header */ | 
|---|
| 142 | struct sockaddr_in6 *ip6c_src;  /* srcaddr w/ additional info */ | 
|---|
| 143 | struct sockaddr_in6 *ip6c_dst;  /* (final) dstaddr w/ additional info */ | 
|---|
| 144 | struct in6_addr *ip6c_finaldst; /* final destination address */ | 
|---|
| 145 | void *ip6c_cmdarg;              /* control command dependent data */ | 
|---|
| 146 | u_int8_t ip6c_nxt;              /* final next header field */ | 
|---|
| 147 | }; | 
|---|
| 148 |  | 
|---|
| 149 | /* | 
|---|
| 150 | * TODO: | 
|---|
| 151 | * | 
|---|
| 152 | * This closesly resembles protosw; we should merge them one day.  Offsets | 
|---|
| 153 | * must be exactly equivalent, due to casting. | 
|---|
| 154 | */ | 
|---|
| 155 | struct ip6protosw { | 
|---|
| 156 | TAILQ_ENTRY(ip6protosw) pr_entry; /* chain for domain */ | 
|---|
| 157 | struct  domain *pr_domain;      /* domain protocol a member of */ | 
|---|
| 158 | struct protosw *pr_protosw;     /* pointer to self */ | 
|---|
| 159 | u_int16_t pr_type;              /* socket type used for */ | 
|---|
| 160 | u_int16_t pr_protocol;          /* protocol number */ | 
|---|
| 161 | u_int32_t pr_flags;             /* see below */ | 
|---|
| 162 | /* | 
|---|
| 163 | * protocol-protocol hooks | 
|---|
| 164 | */ | 
|---|
| 165 | int     (*pr_input)             /* input to protocol (from below) */ | 
|---|
| 166 | (struct mbuf **, int *, int); | 
|---|
| 167 | int     (*pr_output)            /* output to protocol (from above) */ | 
|---|
| 168 | (struct mbuf *m, struct socket *so, | 
|---|
| 169 | struct sockaddr_in6 *, struct mbuf *); | 
|---|
| 170 | void    (*pr_ctlinput)          /* control input (from below) */ | 
|---|
| 171 | (int, struct sockaddr *, void *, struct ifnet *); | 
|---|
| 172 | int     (*pr_ctloutput)         /* control output (from above) */ | 
|---|
| 173 | (struct socket *, struct sockopt *); | 
|---|
| 174 | /* | 
|---|
| 175 | * user-protocol hook | 
|---|
| 176 | */ | 
|---|
| 177 | struct  pr_usrreqs *pr_usrreqs; /* user request; see list below */ | 
|---|
| 178 | /* | 
|---|
| 179 | * utility hooks | 
|---|
| 180 | */ | 
|---|
| 181 | void    (*pr_init)              /* initialization hook */ | 
|---|
| 182 | (struct ip6protosw *, struct domain *); | 
|---|
| 183 | void    (*pr_drain)(void);      /* flush any excess space possible */ | 
|---|
| 184 | /* for compat. with IPv4 protosw */ | 
|---|
| 185 | int     (*pr_sysctl)(void);     /* sysctl for protocol */ | 
|---|
| 186 | int     (*pr_lock)              /* lock function for protocol */ | 
|---|
| 187 | (struct socket *so, int refcnt, void *debug); | 
|---|
| 188 | int     (*pr_unlock)            /* unlock for protocol */ | 
|---|
| 189 | (struct socket *so, int refcnt, void *debug); | 
|---|
| 190 | lck_mtx_t *(*pr_getlock)        /* retrieve protocol lock */ | 
|---|
| 191 | (struct socket *so, int flags); | 
|---|
| 192 | /* | 
|---|
| 193 | * misc | 
|---|
| 194 | */ | 
|---|
| 195 | TAILQ_HEAD(, socket_filter) pr_filter_head; | 
|---|
| 196 | struct protosw_old *pr_old; | 
|---|
| 197 |  | 
|---|
| 198 | void    (*pr_update_last_owner) /* update last socket owner) */ | 
|---|
| 199 | (struct socket *so, struct proc *p, struct proc *ep); | 
|---|
| 200 |  | 
|---|
| 201 | void    (*pr_copy_last_owner) /* copy last socket from listener */ | 
|---|
| 202 | (struct socket *so, struct socket *head); | 
|---|
| 203 | }; | 
|---|
| 204 | #endif /* BSD_KERNEL_PRIVATE */ | 
|---|
| 205 | #endif /* _NETINET6_IP6PROTOSW_H_ */ | 
|---|
| 206 |  | 
|---|