]>
git.saurik.com Git - apple/xnu.git/blob - bsd/net/kext_net.h
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
25 /* Copyright (C) 1999 Apple Computer, Inc. */
27 * Support for network filter kernel extensions
28 * Justin C. Walker, 990319
30 #ifndef NET_KEXT_NET_H
31 #define NET_KEXT_NET_H
32 #include <sys/appleapiopts.h>
34 #include <sys/queue.h>
35 #include <sys/socketvar.h>
48 #ifdef __APPLE_API_UNSTABLE
51 * This structure gives access to the functionality of the filter.
52 * The kextcb provides the link from the socket structure.
55 { TAILQ_ENTRY(NFDescriptor
) nf_next
; /* protosw chain */
56 TAILQ_ENTRY(NFDescriptor
) nf_list
; /* descriptor list */
57 unsigned int nf_handle
; /* Identifier */
59 /* Dispatch for PF_FILTER control */
60 int (*nf_connect
)(); /* Make contact */
61 void (*nf_disconnect
)(); /* Break contact */
62 int (*nf_read
)(); /* Get data from filter */
63 int (*nf_write
)(); /* Send data to filter */
64 int (*nf_get
)(); /* Get filter config */
65 int (*nf_set
)(); /* Set filter config */
67 * Socket function dispatch vectors - copied to kextcb
70 struct sockif
*nf_soif
; /* Socket functions */
71 struct sockutil
*nf_soutil
; /* Sockbuf utility functions */
72 u_long reserved
[4]; /* for future use if needed */
75 #define NFD_GLOBAL 0x01
77 #define NFD_VISIBLE 0x80000000
79 #define NFF_BEFORE 0x01
80 #define NFF_AFTER 0x02
83 /* How to register: filter, insert location, target protosw, flags */
84 extern int register_sockfilter(struct NFDescriptor
*,
85 struct NFDescriptor
*,
86 struct protosw
*, int);
87 /* How to unregister: filter, original protosw, flags */
88 extern int unregister_sockfilter(struct NFDescriptor
*, struct protosw
*, int);
90 #ifdef __APPLE_API_PRIVATE
91 TAILQ_HEAD(nf_list
, NFDescriptor
);
93 extern struct nf_list nf_list
;
94 #endif /* __APPLE_API_PRIVATE */
101 * Interface structure for inserting an installed socket NKE into an
103 * 'handle' is the NKE to be inserted, 'where' is an insertion point,
104 * and flags dictate the position of the to-be-inserted NKE relative to
105 * the 'where' NKE. If the latter is NULL, the flags indicate "first"
109 { unsigned int nke_handle
;
110 unsigned int nke_where
;
111 int nke_flags
; /* NFF_BEFORE, NFF_AFTER: net/kext_net.h */
112 unsigned long reserved
[4]; /* for future use */
117 * Contains socket interface:
118 * dispatch vector abstracting the interface between protocols and
120 * TODO: add sf_sosense()
123 { int (*sf_soabort
)(struct socket
*, struct kextcb
*);
124 int (*sf_soaccept
)(struct socket
*, struct sockaddr
**,
126 int (*sf_sobind
)(struct socket
*, struct sockaddr
*, struct kextcb
*);
127 int (*sf_soclose
)(struct socket
*, struct kextcb
*);
128 int (*sf_soconnect
)(struct socket
*, struct sockaddr
*,
130 int (*sf_soconnect2
)(struct socket
*, struct socket
*,
132 int (*sf_socontrol
)(struct socket
*, struct sockopt
*,
134 int (*sf_socreate
)(struct socket
*, struct protosw
*, struct kextcb
*);
135 int (*sf_sodisconnect
)(struct socket
*, struct kextcb
*);
136 int (*sf_sofree
)(struct socket
*, struct kextcb
*);
137 int (*sf_sogetopt
)(struct socket
*, int, int, struct mbuf
**,
139 int (*sf_sohasoutofband
)(struct socket
*, struct kextcb
*);
140 int (*sf_solisten
)(struct socket
*, struct kextcb
*);
141 int (*sf_soreceive
)(struct socket
*, struct sockaddr
**, struct uio
**,
142 struct mbuf
**, struct mbuf
**, int *,
144 int (*sf_sorflush
)(struct socket
*, struct kextcb
*);
145 int (*sf_sosend
)(struct socket
*, struct sockaddr
**, struct uio
**,
146 struct mbuf
**, struct mbuf
**, int *,
148 int (*sf_sosetopt
)(struct socket
*, int, int, struct mbuf
*,
150 int (*sf_soshutdown
)(struct socket
*, int, struct kextcb
*);
151 /* Calls sorwakeup() */
152 int (*sf_socantrcvmore
)(struct socket
*, struct kextcb
*);
153 /* Calls sowwakeup() */
154 int (*sf_socantsendmore
)(struct socket
*, struct kextcb
*);
155 /* Calls soqinsque(), sorwakeup(), sowwakeup() */
156 int (*sf_soisconnected
)(struct socket
*, struct kextcb
*);
157 int (*sf_soisconnecting
)(struct socket
*, struct kextcb
*);
158 /* Calls sowwakeup(), sorwakeup() */
159 int (*sf_soisdisconnected
)(struct socket
*, struct kextcb
*);
160 /* Calls sowwakeup(), sorwakeup() */
161 int (*sf_soisdisconnecting
)(struct socket
*, struct kextcb
*);
162 /* Calls soreserve(), soqinsque(), soqremque(), sorwakeup() */
163 int (*sf_sonewconn
)(struct socket
*, int, struct kextcb
*);
164 int (*sf_soqinsque
)(struct socket
*, struct socket
*, int,
166 int (*sf_soqremque
)(struct socket
*, int, struct kextcb
*);
167 int (*sf_soreserve
)(struct socket
*, u_long
, u_long
, struct kextcb
*);
168 int (*sf_sowakeup
)(struct socket
*, struct sockbuf
*,
176 * Contains the utility functions for socket layer access
179 { /* Sleeps if locked */
180 int (*su_sb_lock
)(struct sockbuf
*, struct kextcb
*);
181 /* Conditionally calls sbappendrecord, Calls sbcompress */
182 int (*su_sbappend
)(struct sockbuf
*, struct mbuf
*, struct kextcb
*);
183 /* Calls sbspace(), sballoc() */
184 int (*su_sbappendaddr
)(struct sockbuf
*, struct sockaddr
*,
185 struct mbuf
*, struct mbuf
*, struct kextcb
*);
186 /* Calls sbspace(), sballoc() */
187 int (*su_sbappendcontrol
)(struct sockbuf
*, struct mbuf
*,
188 struct mbuf
*, struct kextcb
*);
189 /* Calls sballoc(), sbcompress() */
190 int (*su_sbappendrecord
)(struct sockbuf
*, struct mbuf
*,
192 /* Calls sballoc() */
193 int (*su_sbcompress
)(struct sockbuf
*, struct mbuf
*, struct mbuf
*,
196 int (*su_sbdrop
)(struct sockbuf
*, int, struct kextcb
*);
198 int (*su_sbdroprecord
)(struct sockbuf
*, struct kextcb
*);
200 int (*su_sbflush
)(struct sockbuf
*, struct kextcb
*);
201 /* Calls sballoc(), sbcompress() */
202 int (*su_sbinsertoob
)(struct sockbuf
*, struct mbuf
*,
204 /* Calls sbflush() */
205 int (*su_sbrelease
)(struct sockbuf
*, struct kextcb
*);
206 int (*su_sbreserve
)(struct sockbuf
*, u_long
, struct kextcb
*);
208 int (*su_sbwait
)(struct sockbuf
*, struct kextcb
*);
211 #endif /* __APPLE_API_UNSTABLE */