netgraph.h (191816) | netgraph.h (194012) |
---|---|
1/* 2 * netgraph.h 3 */ 4 5/*- 6 * Copyright (c) 1996-1999 Whistle Communications, Inc. 7 * All rights reserved. 8 * --- 23 unchanged lines hidden (view full) --- 32 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY 33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 35 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY 36 * OF SUCH DAMAGE. 37 * 38 * Author: Julian Elischer <julian@freebsd.org> 39 * | 1/* 2 * netgraph.h 3 */ 4 5/*- 6 * Copyright (c) 1996-1999 Whistle Communications, Inc. 7 * All rights reserved. 8 * --- 23 unchanged lines hidden (view full) --- 32 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY 33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 35 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY 36 * OF SUCH DAMAGE. 37 * 38 * Author: Julian Elischer <julian@freebsd.org> 39 * |
40 * $FreeBSD: head/sys/netgraph/netgraph.h 191816 2009-05-05 10:56:12Z zec $ | 40 * $FreeBSD: head/sys/netgraph/netgraph.h 194012 2009-06-11 16:50:49Z zec $ |
41 * $Whistle: netgraph.h,v 1.29 1999/11/01 07:56:13 julian Exp $ 42 */ 43 44#ifndef _NETGRAPH_NETGRAPH_H_ 45#define _NETGRAPH_NETGRAPH_H_ 46 47#ifndef _KERNEL 48#error "This file should not be included in user level programs" --- 76 unchanged lines hidden (view full) --- 125#endif /* NETGRAPH_DEBUG */ /*----------------------------------------------*/ 126}; 127/* Flags for a hook */ 128#define HK_INVALID 0x0001 /* don't trust it! */ 129#define HK_QUEUE 0x0002 /* queue for later delivery */ 130#define HK_FORCE_WRITER 0x0004 /* Incoming data queued as a writer */ 131#define HK_DEAD 0x0008 /* This is the dead hook.. don't free */ 132#define HK_HI_STACK 0x0010 /* Hook has hi stack usage */ | 41 * $Whistle: netgraph.h,v 1.29 1999/11/01 07:56:13 julian Exp $ 42 */ 43 44#ifndef _NETGRAPH_NETGRAPH_H_ 45#define _NETGRAPH_NETGRAPH_H_ 46 47#ifndef _KERNEL 48#error "This file should not be included in user level programs" --- 76 unchanged lines hidden (view full) --- 125#endif /* NETGRAPH_DEBUG */ /*----------------------------------------------*/ 126}; 127/* Flags for a hook */ 128#define HK_INVALID 0x0001 /* don't trust it! */ 129#define HK_QUEUE 0x0002 /* queue for later delivery */ 130#define HK_FORCE_WRITER 0x0004 /* Incoming data queued as a writer */ 131#define HK_DEAD 0x0008 /* This is the dead hook.. don't free */ 132#define HK_HI_STACK 0x0010 /* Hook has hi stack usage */ |
133#define HK_TO_INBOUND 0x0020 /* Hook on ntw. stack inbound path. */ |
|
133 134/* 135 * Public Methods for hook 136 * If you can't do it with these you probably shouldn;t be doing it. 137 */ 138void ng_unref_hook(hook_p hook); /* don't move this */ 139#define _NG_HOOK_REF(hook) atomic_add_int(&(hook)->hk_refs, 1) 140#define _NG_HOOK_NAME(hook) ((hook)->hk_name) --- 4 unchanged lines hidden (view full) --- 145#define _NG_HOOK_PRIVATE(hook) ((hook)->hk_private) 146#define _NG_HOOK_NOT_VALID(hook) ((hook)->hk_flags & HK_INVALID) 147#define _NG_HOOK_IS_VALID(hook) (!((hook)->hk_flags & HK_INVALID)) 148#define _NG_HOOK_NODE(hook) ((hook)->hk_node) /* only rvalue! */ 149#define _NG_HOOK_PEER(hook) ((hook)->hk_peer) /* only rvalue! */ 150#define _NG_HOOK_FORCE_WRITER(hook) \ 151 do { hook->hk_flags |= HK_FORCE_WRITER; } while (0) 152#define _NG_HOOK_FORCE_QUEUE(hook) do { hook->hk_flags |= HK_QUEUE; } while (0) | 134 135/* 136 * Public Methods for hook 137 * If you can't do it with these you probably shouldn;t be doing it. 138 */ 139void ng_unref_hook(hook_p hook); /* don't move this */ 140#define _NG_HOOK_REF(hook) atomic_add_int(&(hook)->hk_refs, 1) 141#define _NG_HOOK_NAME(hook) ((hook)->hk_name) --- 4 unchanged lines hidden (view full) --- 146#define _NG_HOOK_PRIVATE(hook) ((hook)->hk_private) 147#define _NG_HOOK_NOT_VALID(hook) ((hook)->hk_flags & HK_INVALID) 148#define _NG_HOOK_IS_VALID(hook) (!((hook)->hk_flags & HK_INVALID)) 149#define _NG_HOOK_NODE(hook) ((hook)->hk_node) /* only rvalue! */ 150#define _NG_HOOK_PEER(hook) ((hook)->hk_peer) /* only rvalue! */ 151#define _NG_HOOK_FORCE_WRITER(hook) \ 152 do { hook->hk_flags |= HK_FORCE_WRITER; } while (0) 153#define _NG_HOOK_FORCE_QUEUE(hook) do { hook->hk_flags |= HK_QUEUE; } while (0) |
154#define _NG_HOOK_SET_TO_INBOUND(hook) \ 155 do { hook->hk_flags |= HK_TO_INBOUND; } while (0) |
|
153#define _NG_HOOK_HI_STACK(hook) do { hook->hk_flags |= HK_HI_STACK; } while (0) 154 155/* Some shortcuts */ 156#define NG_PEER_NODE(hook) NG_HOOK_NODE(NG_HOOK_PEER(hook)) 157#define NG_PEER_HOOK_NAME(hook) NG_HOOK_NAME(NG_HOOK_PEER(hook)) 158#define NG_PEER_NODE_NAME(hook) NG_NODE_NAME(NG_PEER_NODE(hook)) 159 160#ifdef NETGRAPH_DEBUG /*----------------------------------------------*/ --- 10 unchanged lines hidden (view full) --- 171static __inline void _ng_hook_set_rcvdata(hook_p hook, 172 ng_rcvdata_t *val, char * file, int line); 173static __inline void * _ng_hook_private(hook_p hook, char * file, int line); 174static __inline int _ng_hook_not_valid(hook_p hook, char * file, int line); 175static __inline int _ng_hook_is_valid(hook_p hook, char * file, int line); 176static __inline node_p _ng_hook_node(hook_p hook, char * file, int line); 177static __inline hook_p _ng_hook_peer(hook_p hook, char * file, int line); 178static __inline void _ng_hook_force_writer(hook_p hook, char * file, | 156#define _NG_HOOK_HI_STACK(hook) do { hook->hk_flags |= HK_HI_STACK; } while (0) 157 158/* Some shortcuts */ 159#define NG_PEER_NODE(hook) NG_HOOK_NODE(NG_HOOK_PEER(hook)) 160#define NG_PEER_HOOK_NAME(hook) NG_HOOK_NAME(NG_HOOK_PEER(hook)) 161#define NG_PEER_NODE_NAME(hook) NG_NODE_NAME(NG_PEER_NODE(hook)) 162 163#ifdef NETGRAPH_DEBUG /*----------------------------------------------*/ --- 10 unchanged lines hidden (view full) --- 174static __inline void _ng_hook_set_rcvdata(hook_p hook, 175 ng_rcvdata_t *val, char * file, int line); 176static __inline void * _ng_hook_private(hook_p hook, char * file, int line); 177static __inline int _ng_hook_not_valid(hook_p hook, char * file, int line); 178static __inline int _ng_hook_is_valid(hook_p hook, char * file, int line); 179static __inline node_p _ng_hook_node(hook_p hook, char * file, int line); 180static __inline hook_p _ng_hook_peer(hook_p hook, char * file, int line); 181static __inline void _ng_hook_force_writer(hook_p hook, char * file, |
179 int line); 180static __inline void _ng_hook_force_queue(hook_p hook, char * file, int line); | 182 int line); 183static __inline void _ng_hook_force_queue(hook_p hook, char * file, 184 int line); 185static __inline void _ng_hook_set_to_inbound(hook_p hook, char * file, 186 int line); |
181 182static __inline void 183_chkhook(hook_p hook, char *file, int line) 184{ 185 if (hook->hk_magic != HK_MAGIC) { 186 printf("Accessing freed hook "); 187 dumphook(hook, file, line); 188 } --- 88 unchanged lines hidden (view full) --- 277static __inline void 278_ng_hook_force_queue(hook_p hook, char * file, int line) 279{ 280 _chkhook(hook, file, line); 281 _NG_HOOK_FORCE_QUEUE(hook); 282} 283 284static __inline void | 187 188static __inline void 189_chkhook(hook_p hook, char *file, int line) 190{ 191 if (hook->hk_magic != HK_MAGIC) { 192 printf("Accessing freed hook "); 193 dumphook(hook, file, line); 194 } --- 88 unchanged lines hidden (view full) --- 283static __inline void 284_ng_hook_force_queue(hook_p hook, char * file, int line) 285{ 286 _chkhook(hook, file, line); 287 _NG_HOOK_FORCE_QUEUE(hook); 288} 289 290static __inline void |
291_ng_hook_set_to_inbound(hook_p hook, char * file, int line) 292{ 293 _chkhook(hook, file, line); 294 _NG_HOOK_SET_TO_INBOUND(hook); 295} 296 297static __inline void |
|
285_ng_hook_hi_stack(hook_p hook, char * file, int line) 286{ 287 _chkhook(hook, file, line); 288 _NG_HOOK_HI_STACK(hook); 289} 290 291 292#define NG_HOOK_REF(hook) _ng_hook_ref(hook, _NN_) --- 4 unchanged lines hidden (view full) --- 297#define NG_HOOK_SET_RCVDATA(hook, val) _ng_hook_set_rcvdata(hook, val, _NN_) 298#define NG_HOOK_PRIVATE(hook) _ng_hook_private(hook, _NN_) 299#define NG_HOOK_NOT_VALID(hook) _ng_hook_not_valid(hook, _NN_) 300#define NG_HOOK_IS_VALID(hook) _ng_hook_is_valid(hook, _NN_) 301#define NG_HOOK_NODE(hook) _ng_hook_node(hook, _NN_) 302#define NG_HOOK_PEER(hook) _ng_hook_peer(hook, _NN_) 303#define NG_HOOK_FORCE_WRITER(hook) _ng_hook_force_writer(hook, _NN_) 304#define NG_HOOK_FORCE_QUEUE(hook) _ng_hook_force_queue(hook, _NN_) | 298_ng_hook_hi_stack(hook_p hook, char * file, int line) 299{ 300 _chkhook(hook, file, line); 301 _NG_HOOK_HI_STACK(hook); 302} 303 304 305#define NG_HOOK_REF(hook) _ng_hook_ref(hook, _NN_) --- 4 unchanged lines hidden (view full) --- 310#define NG_HOOK_SET_RCVDATA(hook, val) _ng_hook_set_rcvdata(hook, val, _NN_) 311#define NG_HOOK_PRIVATE(hook) _ng_hook_private(hook, _NN_) 312#define NG_HOOK_NOT_VALID(hook) _ng_hook_not_valid(hook, _NN_) 313#define NG_HOOK_IS_VALID(hook) _ng_hook_is_valid(hook, _NN_) 314#define NG_HOOK_NODE(hook) _ng_hook_node(hook, _NN_) 315#define NG_HOOK_PEER(hook) _ng_hook_peer(hook, _NN_) 316#define NG_HOOK_FORCE_WRITER(hook) _ng_hook_force_writer(hook, _NN_) 317#define NG_HOOK_FORCE_QUEUE(hook) _ng_hook_force_queue(hook, _NN_) |
318#define NG_HOOK_SET_TO_INBOUND(hook) _ng_hook_set_to_inbound(hook, _NN_) |
|
305#define NG_HOOK_HI_STACK(hook) _ng_hook_hi_stack(hook, _NN_) 306 307#else /* NETGRAPH_DEBUG */ /*----------------------------------------------*/ 308 309#define NG_HOOK_REF(hook) _NG_HOOK_REF(hook) 310#define NG_HOOK_NAME(hook) _NG_HOOK_NAME(hook) 311#define NG_HOOK_UNREF(hook) _NG_HOOK_UNREF(hook) 312#define NG_HOOK_SET_PRIVATE(hook, val) _NG_HOOK_SET_PRIVATE(hook, val) 313#define NG_HOOK_SET_RCVMSG(hook, val) _NG_HOOK_SET_RCVMSG(hook, val) 314#define NG_HOOK_SET_RCVDATA(hook, val) _NG_HOOK_SET_RCVDATA(hook, val) 315#define NG_HOOK_PRIVATE(hook) _NG_HOOK_PRIVATE(hook) 316#define NG_HOOK_NOT_VALID(hook) _NG_HOOK_NOT_VALID(hook) 317#define NG_HOOK_IS_VALID(hook) _NG_HOOK_IS_VALID(hook) 318#define NG_HOOK_NODE(hook) _NG_HOOK_NODE(hook) 319#define NG_HOOK_PEER(hook) _NG_HOOK_PEER(hook) 320#define NG_HOOK_FORCE_WRITER(hook) _NG_HOOK_FORCE_WRITER(hook) 321#define NG_HOOK_FORCE_QUEUE(hook) _NG_HOOK_FORCE_QUEUE(hook) | 319#define NG_HOOK_HI_STACK(hook) _ng_hook_hi_stack(hook, _NN_) 320 321#else /* NETGRAPH_DEBUG */ /*----------------------------------------------*/ 322 323#define NG_HOOK_REF(hook) _NG_HOOK_REF(hook) 324#define NG_HOOK_NAME(hook) _NG_HOOK_NAME(hook) 325#define NG_HOOK_UNREF(hook) _NG_HOOK_UNREF(hook) 326#define NG_HOOK_SET_PRIVATE(hook, val) _NG_HOOK_SET_PRIVATE(hook, val) 327#define NG_HOOK_SET_RCVMSG(hook, val) _NG_HOOK_SET_RCVMSG(hook, val) 328#define NG_HOOK_SET_RCVDATA(hook, val) _NG_HOOK_SET_RCVDATA(hook, val) 329#define NG_HOOK_PRIVATE(hook) _NG_HOOK_PRIVATE(hook) 330#define NG_HOOK_NOT_VALID(hook) _NG_HOOK_NOT_VALID(hook) 331#define NG_HOOK_IS_VALID(hook) _NG_HOOK_IS_VALID(hook) 332#define NG_HOOK_NODE(hook) _NG_HOOK_NODE(hook) 333#define NG_HOOK_PEER(hook) _NG_HOOK_PEER(hook) 334#define NG_HOOK_FORCE_WRITER(hook) _NG_HOOK_FORCE_WRITER(hook) 335#define NG_HOOK_FORCE_QUEUE(hook) _NG_HOOK_FORCE_QUEUE(hook) |
336#define NG_HOOK_SET_TO_INBOUND(hook) _NG_HOOK_SET_TO_INBOUND(hook) |
|
322#define NG_HOOK_HI_STACK(hook) _NG_HOOK_HI_STACK(hook) 323 324#endif /* NETGRAPH_DEBUG */ /*----------------------------------------------*/ 325 326/*********************************************************************** 327 ***************** Node Structure and Methods ************************** 328 *********************************************************************** 329 * Structure of a node --- 854 unchanged lines hidden (view full) --- 1184#define NG_FREE_META(meta) 1185#define NGI_GET_META(i,m) 1186#define ng_copy_meta(meta) NULL 1187 1188/* Hash related definitions */ 1189#define NG_ID_HASH_SIZE 128 /* most systems wont need even this many */ 1190#define NG_NAME_HASH_SIZE 128 /* most systems wont need even this many */ 1191 | 337#define NG_HOOK_HI_STACK(hook) _NG_HOOK_HI_STACK(hook) 338 339#endif /* NETGRAPH_DEBUG */ /*----------------------------------------------*/ 340 341/*********************************************************************** 342 ***************** Node Structure and Methods ************************** 343 *********************************************************************** 344 * Structure of a node --- 854 unchanged lines hidden (view full) --- 1199#define NG_FREE_META(meta) 1200#define NGI_GET_META(i,m) 1201#define ng_copy_meta(meta) NULL 1202 1203/* Hash related definitions */ 1204#define NG_ID_HASH_SIZE 128 /* most systems wont need even this many */ 1205#define NG_NAME_HASH_SIZE 128 /* most systems wont need even this many */ 1206 |
1207/* 1208 * Mark the current thread when called from the outbound path of the 1209 * network stack, in order to enforce queuing on ng nodes calling into 1210 * the inbound network stack path. 1211 */ 1212#define NG_OUTBOUND_THREAD_REF() \ 1213 curthread->td_ng_outbound++ 1214#define NG_OUTBOUND_THREAD_UNREF() \ 1215 do { \ 1216 curthread->td_ng_outbound--; \ 1217 KASSERT(curthread->td_ng_outbound >= 0, \ 1218 ("%s: negative td_ng_outbound", __func__)); \ 1219 } while (0) 1220 |
|
1192/* Virtualization macros */ 1193#define INIT_VNET_NETGRAPH(vnet) \ 1194 INIT_FROM_VNET(vnet, VNET_MOD_NETGRAPH, \ 1195 struct vnet_netgraph, vnet_netgraph) 1196 1197#define VNET_NETGRAPH(sym) VSYM(vnet_netgraph, sym) 1198 1199struct vnet_netgraph { --- 25 unchanged lines hidden --- | 1221/* Virtualization macros */ 1222#define INIT_VNET_NETGRAPH(vnet) \ 1223 INIT_FROM_VNET(vnet, VNET_MOD_NETGRAPH, \ 1224 struct vnet_netgraph, vnet_netgraph) 1225 1226#define VNET_NETGRAPH(sym) VSYM(vnet_netgraph, sym) 1227 1228struct vnet_netgraph { --- 25 unchanged lines hidden --- |