Deleted Added
full compact
netgraph.h (151973) netgraph.h (152451)
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 151973 2005-11-02 14:27:24Z glebius $
40 * $FreeBSD: head/sys/netgraph/netgraph.h 152451 2005-11-15 10:54:20Z glebius $
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"

--- 137 unchanged lines hidden (view full) ---

186 hook->lastfile = file;
187}
188
189static __inline void
190_ng_hook_ref(hook_p hook, char * file, int line)
191{
192 _chkhook(hook, file, line);
193 _NG_HOOK_REF(hook);
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"

--- 137 unchanged lines hidden (view full) ---

186 hook->lastfile = file;
187}
188
189static __inline void
190_ng_hook_ref(hook_p hook, char * file, int line)
191{
192 _chkhook(hook, file, line);
193 _NG_HOOK_REF(hook);
194}
194}
195
196static __inline char *
197_ng_hook_name(hook_p hook, char * file, int line)
198{
199 _chkhook(hook, file, line);
200 return (_NG_HOOK_NAME(hook));
195
196static __inline char *
197_ng_hook_name(hook_p hook, char * file, int line)
198{
199 _chkhook(hook, file, line);
200 return (_NG_HOOK_NAME(hook));
201}
201}
202
203static __inline void
204_ng_hook_unref(hook_p hook, char * file, int line)
205{
206 _chkhook(hook, file, line);
207 _NG_HOOK_UNREF(hook);
202
203static __inline void
204_ng_hook_unref(hook_p hook, char * file, int line)
205{
206 _chkhook(hook, file, line);
207 _NG_HOOK_UNREF(hook);
208}
208}
209
210static __inline void
211_ng_hook_set_private(hook_p hook, void *val, char * file, int line)
212{
213 _chkhook(hook, file, line);
214 _NG_HOOK_SET_PRIVATE(hook, val);
209
210static __inline void
211_ng_hook_set_private(hook_p hook, void *val, char * file, int line)
212{
213 _chkhook(hook, file, line);
214 _NG_HOOK_SET_PRIVATE(hook, val);
215}
215}
216
217static __inline void
218_ng_hook_set_rcvmsg(hook_p hook, ng_rcvmsg_t *val, char * file, int line)
219{
220 _chkhook(hook, file, line);
221 _NG_HOOK_SET_RCVMSG(hook, val);
216
217static __inline void
218_ng_hook_set_rcvmsg(hook_p hook, ng_rcvmsg_t *val, char * file, int line)
219{
220 _chkhook(hook, file, line);
221 _NG_HOOK_SET_RCVMSG(hook, val);
222}
222}
223
224static __inline void
225_ng_hook_set_rcvdata(hook_p hook, ng_rcvdata_t *val, char * file, int line)
226{
227 _chkhook(hook, file, line);
228 _NG_HOOK_SET_RCVDATA(hook, val);
223
224static __inline void
225_ng_hook_set_rcvdata(hook_p hook, ng_rcvdata_t *val, char * file, int line)
226{
227 _chkhook(hook, file, line);
228 _NG_HOOK_SET_RCVDATA(hook, val);
229}
229}
230
231static __inline void *
232_ng_hook_private(hook_p hook, char * file, int line)
233{
234 _chkhook(hook, file, line);
235 return (_NG_HOOK_PRIVATE(hook));
230
231static __inline void *
232_ng_hook_private(hook_p hook, char * file, int line)
233{
234 _chkhook(hook, file, line);
235 return (_NG_HOOK_PRIVATE(hook));
236}
236}
237
238static __inline int
239_ng_hook_not_valid(hook_p hook, char * file, int line)
240{
241 _chkhook(hook, file, line);
242 return (_NG_HOOK_NOT_VALID(hook));
237
238static __inline int
239_ng_hook_not_valid(hook_p hook, char * file, int line)
240{
241 _chkhook(hook, file, line);
242 return (_NG_HOOK_NOT_VALID(hook));
243}
243}
244
245static __inline int
246_ng_hook_is_valid(hook_p hook, char * file, int line)
247{
248 _chkhook(hook, file, line);
249 return (_NG_HOOK_IS_VALID(hook));
244
245static __inline int
246_ng_hook_is_valid(hook_p hook, char * file, int line)
247{
248 _chkhook(hook, file, line);
249 return (_NG_HOOK_IS_VALID(hook));
250}
250}
251
252static __inline node_p
253_ng_hook_node(hook_p hook, char * file, int line)
254{
255 _chkhook(hook, file, line);
256 return (_NG_HOOK_NODE(hook));
251
252static __inline node_p
253_ng_hook_node(hook_p hook, char * file, int line)
254{
255 _chkhook(hook, file, line);
256 return (_NG_HOOK_NODE(hook));
257}
257}
258
259static __inline hook_p
260_ng_hook_peer(hook_p hook, char * file, int line)
261{
262 _chkhook(hook, file, line);
263 return (_NG_HOOK_PEER(hook));
258
259static __inline hook_p
260_ng_hook_peer(hook_p hook, char * file, int line)
261{
262 _chkhook(hook, file, line);
263 return (_NG_HOOK_PEER(hook));
264}
264}
265
266static __inline void
267_ng_hook_force_writer(hook_p hook, char * file, int line)
268{
269 _chkhook(hook, file, line);
270 _NG_HOOK_FORCE_WRITER(hook);
265
266static __inline void
267_ng_hook_force_writer(hook_p hook, char * file, int line)
268{
269 _chkhook(hook, file, line);
270 _NG_HOOK_FORCE_WRITER(hook);
271}
271}
272
273static __inline void
274_ng_hook_force_queue(hook_p hook, char * file, int line)
275{
276 _chkhook(hook, file, line);
277 _NG_HOOK_FORCE_QUEUE(hook);
272
273static __inline void
274_ng_hook_force_queue(hook_p hook, char * file, int line)
275{
276 _chkhook(hook, file, line);
277 _NG_HOOK_FORCE_QUEUE(hook);
278}
278}
279
280
281#define NG_HOOK_REF(hook) _ng_hook_ref(hook, _NN_)
282#define NG_HOOK_NAME(hook) _ng_hook_name(hook, _NN_)
283#define NG_HOOK_UNREF(hook) _ng_hook_unref(hook, _NN_)
284#define NG_HOOK_SET_PRIVATE(hook, val) _ng_hook_set_private(hook, val, _NN_)
285#define NG_HOOK_SET_RCVMSG(hook, val) _ng_hook_set_rcvmsg(hook, val, _NN_)
286#define NG_HOOK_SET_RCVDATA(hook, val) _ng_hook_set_rcvdata(hook, val, _NN_)

--- 24 unchanged lines hidden (view full) ---

311#endif /* NETGRAPH_DEBUG */ /*----------------------------------------------*/
312
313/***********************************************************************
314 ***************** Node Structure and Methods **************************
315 ***********************************************************************
316 * Structure of a node
317 * including the eembedded queue structure.
318 *
279
280
281#define NG_HOOK_REF(hook) _ng_hook_ref(hook, _NN_)
282#define NG_HOOK_NAME(hook) _ng_hook_name(hook, _NN_)
283#define NG_HOOK_UNREF(hook) _ng_hook_unref(hook, _NN_)
284#define NG_HOOK_SET_PRIVATE(hook, val) _ng_hook_set_private(hook, val, _NN_)
285#define NG_HOOK_SET_RCVMSG(hook, val) _ng_hook_set_rcvmsg(hook, val, _NN_)
286#define NG_HOOK_SET_RCVDATA(hook, val) _ng_hook_set_rcvdata(hook, val, _NN_)

--- 24 unchanged lines hidden (view full) ---

311#endif /* NETGRAPH_DEBUG */ /*----------------------------------------------*/
312
313/***********************************************************************
314 ***************** Node Structure and Methods **************************
315 ***********************************************************************
316 * Structure of a node
317 * including the eembedded queue structure.
318 *
319 * The structure for queueing Netgraph request items
319 * The structure for queueing Netgraph request items
320 * embedded in the node structure
321 */
322struct ng_queue {
320 * embedded in the node structure
321 */
322struct ng_queue {
323 u_long q_flags;
324 struct mtx q_mtx;
323 u_long q_flags;
324 struct mtx q_mtx;
325 item_p queue;
326 item_p *last;
327 struct ng_node *q_node; /* find the front of the node.. */
328};
329
330struct ng_node {
331 char nd_name[NG_NODESIZ]; /* optional globally unique name */
332 struct ng_type *nd_type; /* the installed 'type' */

--- 87 unchanged lines hidden (view full) ---

420static __inline int _ng_node_is_valid(node_p node, char *file, int line);
421static __inline int _ng_node_not_valid(node_p node, char *file, int line);
422static __inline int _ng_node_numhooks(node_p node, char *file, int line);
423static __inline void _ng_node_force_writer(node_p node, char *file, int line);
424static __inline hook_p _ng_node_foreach_hook(node_p node,
425 ng_fn_eachhook *fn, void *arg, char *file, int line);
426static __inline void _ng_node_revive(node_p node, char *file, int line);
427
325 item_p queue;
326 item_p *last;
327 struct ng_node *q_node; /* find the front of the node.. */
328};
329
330struct ng_node {
331 char nd_name[NG_NODESIZ]; /* optional globally unique name */
332 struct ng_type *nd_type; /* the installed 'type' */

--- 87 unchanged lines hidden (view full) ---

420static __inline int _ng_node_is_valid(node_p node, char *file, int line);
421static __inline int _ng_node_not_valid(node_p node, char *file, int line);
422static __inline int _ng_node_numhooks(node_p node, char *file, int line);
423static __inline void _ng_node_force_writer(node_p node, char *file, int line);
424static __inline hook_p _ng_node_foreach_hook(node_p node,
425 ng_fn_eachhook *fn, void *arg, char *file, int line);
426static __inline void _ng_node_revive(node_p node, char *file, int line);
427
428static __inline void
428static __inline void
429_chknode(node_p node, char *file, int line)
430{
431 if (node->nd_magic != ND_MAGIC) {
432 printf("Accessing freed node ");
433 dumpnode(node, file, line);
434 }
435 node->lastline = line;
436 node->lastfile = file;
437}
438
439static __inline char *
440_ng_node_name(node_p node, char *file, int line)
441{
442 _chknode(node, file, line);
443 return(_NG_NODE_NAME(node));
444}
445
429_chknode(node_p node, char *file, int line)
430{
431 if (node->nd_magic != ND_MAGIC) {
432 printf("Accessing freed node ");
433 dumpnode(node, file, line);
434 }
435 node->lastline = line;
436 node->lastfile = file;
437}
438
439static __inline char *
440_ng_node_name(node_p node, char *file, int line)
441{
442 _chknode(node, file, line);
443 return(_NG_NODE_NAME(node));
444}
445
446static __inline int
446static __inline int
447_ng_node_has_name(node_p node, char *file, int line)
448{
449 _chknode(node, file, line);
450 return(_NG_NODE_HAS_NAME(node));
451}
452
453static __inline ng_ID_t
454_ng_node_id(node_p node, char *file, int line)
455{
456 _chknode(node, file, line);
457 return(_NG_NODE_ID(node));
458}
459
447_ng_node_has_name(node_p node, char *file, int line)
448{
449 _chknode(node, file, line);
450 return(_NG_NODE_HAS_NAME(node));
451}
452
453static __inline ng_ID_t
454_ng_node_id(node_p node, char *file, int line)
455{
456 _chknode(node, file, line);
457 return(_NG_NODE_ID(node));
458}
459
460static __inline void
460static __inline void
461_ng_node_ref(node_p node, char *file, int line)
462{
463 _chknode(node, file, line);
464 /*_NG_NODE_REF(node);*/
465 ng_ref_node(node);
466}
467
468static __inline int

--- 200 unchanged lines hidden (view full) ---

669static __inline struct ng_mesg ** _ngi_msg(item_p item, char *file, int line) ;
670static __inline ng_item_fn ** _ngi_fn(item_p item, char *file, int line) ;
671static __inline void ** _ngi_arg1(item_p item, char *file, int line) ;
672static __inline int * _ngi_arg2(item_p item, char *file, int line) ;
673static __inline node_p _ngi_node(item_p item, char *file, int line);
674static __inline hook_p _ngi_hook(item_p item, char *file, int line);
675
676static __inline void
461_ng_node_ref(node_p node, char *file, int line)
462{
463 _chknode(node, file, line);
464 /*_NG_NODE_REF(node);*/
465 ng_ref_node(node);
466}
467
468static __inline int

--- 200 unchanged lines hidden (view full) ---

669static __inline struct ng_mesg ** _ngi_msg(item_p item, char *file, int line) ;
670static __inline ng_item_fn ** _ngi_fn(item_p item, char *file, int line) ;
671static __inline void ** _ngi_arg1(item_p item, char *file, int line) ;
672static __inline int * _ngi_arg2(item_p item, char *file, int line) ;
673static __inline node_p _ngi_node(item_p item, char *file, int line);
674static __inline hook_p _ngi_hook(item_p item, char *file, int line);
675
676static __inline void
677_ngi_check(item_p item, char *file, int line)
677_ngi_check(item_p item, char *file, int line)
678{
679 (item)->lastline = line;
680 (item)->lastfile = file;
681}
682
683static __inline struct mbuf **
678{
679 (item)->lastline = line;
680 (item)->lastfile = file;
681}
682
683static __inline struct mbuf **
684_ngi_m(item_p item, char *file, int line)
684_ngi_m(item_p item, char *file, int line)
685{
686 _ngi_check(item, file, line);
687 return (&_NGI_M(item));
688}
689
690static __inline struct ng_mesg **
685{
686 _ngi_check(item, file, line);
687 return (&_NGI_M(item));
688}
689
690static __inline struct ng_mesg **
691_ngi_msg(item_p item, char *file, int line)
691_ngi_msg(item_p item, char *file, int line)
692{
693 _ngi_check(item, file, line);
694 return (&_NGI_MSG(item));
695}
696
697static __inline ng_ID_t *
692{
693 _ngi_check(item, file, line);
694 return (&_NGI_MSG(item));
695}
696
697static __inline ng_ID_t *
698_ngi_retaddr(item_p item, char *file, int line)
698_ngi_retaddr(item_p item, char *file, int line)
699{
700 _ngi_check(item, file, line);
701 return (&_NGI_RETADDR(item));
702}
703
704static __inline ng_item_fn **
699{
700 _ngi_check(item, file, line);
701 return (&_NGI_RETADDR(item));
702}
703
704static __inline ng_item_fn **
705_ngi_fn(item_p item, char *file, int line)
705_ngi_fn(item_p item, char *file, int line)
706{
707 _ngi_check(item, file, line);
708 return (&_NGI_FN(item));
709}
710
711static __inline void **
706{
707 _ngi_check(item, file, line);
708 return (&_NGI_FN(item));
709}
710
711static __inline void **
712_ngi_arg1(item_p item, char *file, int line)
712_ngi_arg1(item_p item, char *file, int line)
713{
714 _ngi_check(item, file, line);
715 return (&_NGI_ARG1(item));
716}
717
718static __inline int *
713{
714 _ngi_check(item, file, line);
715 return (&_NGI_ARG1(item));
716}
717
718static __inline int *
719_ngi_arg2(item_p item, char *file, int line)
719_ngi_arg2(item_p item, char *file, int line)
720{
721 _ngi_check(item, file, line);
722 return (&_NGI_ARG2(item));
723}
724
725static __inline node_p
726_ngi_node(item_p item, char *file, int line)
727{

--- 241 unchanged lines hidden (view full) ---

969 } \
970 (item) = NULL; \
971 } while (0)
972
973
974/***********************************************************************
975 ******** Structures Definitions and Macros for defining a node *******
976 ***********************************************************************
720{
721 _ngi_check(item, file, line);
722 return (&_NGI_ARG2(item));
723}
724
725static __inline node_p
726_ngi_node(item_p item, char *file, int line)
727{

--- 241 unchanged lines hidden (view full) ---

969 } \
970 (item) = NULL; \
971 } while (0)
972
973
974/***********************************************************************
975 ******** Structures Definitions and Macros for defining a node *******
976 ***********************************************************************
977 *
977 *
978 * Here we define the structures needed to actually define a new node
979 * type.
980 */
981
982/*
983 * Command list -- each node type specifies the command that it knows
984 * how to convert between ASCII and binary using an array of these.
985 * The last element in the array must be a terminator with cookie=0.

--- 64 unchanged lines hidden (view full) ---

1050MODULE_DEPEND(ng_##typename, netgraph, NG_ABI_VERSION, \
1051 NG_ABI_VERSION, \
1052 NG_ABI_VERSION)
1053
1054#define NETGRAPH_INIT(tn, tp) \
1055 NETGRAPH_INIT_ORDERED(tn, tp, SI_SUB_PSEUDO, SI_ORDER_ANY)
1056
1057/* Special malloc() type for netgraph structs and ctrl messages */
978 * Here we define the structures needed to actually define a new node
979 * type.
980 */
981
982/*
983 * Command list -- each node type specifies the command that it knows
984 * how to convert between ASCII and binary using an array of these.
985 * The last element in the array must be a terminator with cookie=0.

--- 64 unchanged lines hidden (view full) ---

1050MODULE_DEPEND(ng_##typename, netgraph, NG_ABI_VERSION, \
1051 NG_ABI_VERSION, \
1052 NG_ABI_VERSION)
1053
1054#define NETGRAPH_INIT(tn, tp) \
1055 NETGRAPH_INIT_ORDERED(tn, tp, SI_SUB_PSEUDO, SI_ORDER_ANY)
1056
1057/* Special malloc() type for netgraph structs and ctrl messages */
1058/* Only these two types should be visible to nodes */
1058/* Only these two types should be visible to nodes */
1059MALLOC_DECLARE(M_NETGRAPH);
1060MALLOC_DECLARE(M_NETGRAPH_MSG);
1061
1062/* declare the base of the netgraph sysclt hierarchy */
1063/* but only if this file cares about sysctls */
1064#ifdef SYSCTL_DECL
1065SYSCTL_DECL(_net_graph);
1066#endif
1067
1068/*
1069 * Methods that the nodes can use.
1059MALLOC_DECLARE(M_NETGRAPH);
1060MALLOC_DECLARE(M_NETGRAPH_MSG);
1061
1062/* declare the base of the netgraph sysclt hierarchy */
1063/* but only if this file cares about sysctls */
1064#ifdef SYSCTL_DECL
1065SYSCTL_DECL(_net_graph);
1066#endif
1067
1068/*
1069 * Methods that the nodes can use.
1070 * Many of these methods should usually NOT be used directly but via
1070 * Many of these methods should usually NOT be used directly but via
1071 * Macros above.
1072 */
1073int ng_address_ID(node_p here, item_p item, ng_ID_t ID, ng_ID_t retaddr);
1074int ng_address_hook(node_p here, item_p item, hook_p hook, ng_ID_t retaddr);
1075int ng_address_path(node_p here, item_p item, char *address, ng_ID_t raddr);
1076int ng_bypass(hook_p hook1, hook_p hook2);
1077hook_p ng_findhook(node_p node, const char *name);
1078struct ng_type *ng_findtype(const char *type);

--- 59 unchanged lines hidden ---
1071 * Macros above.
1072 */
1073int ng_address_ID(node_p here, item_p item, ng_ID_t ID, ng_ID_t retaddr);
1074int ng_address_hook(node_p here, item_p item, hook_p hook, ng_ID_t retaddr);
1075int ng_address_path(node_p here, item_p item, char *address, ng_ID_t raddr);
1076int ng_bypass(hook_p hook1, hook_p hook2);
1077hook_p ng_findhook(node_p node, const char *name);
1078struct ng_type *ng_findtype(const char *type);

--- 59 unchanged lines hidden ---