summaryrefslogtreecommitdiffstats
path: root/sys/netgraph/netgraph.h
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>2001-01-14 23:25:54 +0000
committerjulian <julian@FreeBSD.org>2001-01-14 23:25:54 +0000
commit95d27233f38767ebb529d8f37869c188f7ac5722 (patch)
tree3e91d2b62966c877341fa2d16238069642bc6640 /sys/netgraph/netgraph.h
parent89aa26ba0b79e4d72bb2779417aed0d4e8c0dcc1 (diff)
downloadFreeBSD-src-95d27233f38767ebb529d8f37869c188f7ac5722.zip
FreeBSD-src-95d27233f38767ebb529d8f37869c188f7ac5722.tar.gz
Add a generic "queued function callin" mechanism
Use it to implement (hopefully) SMP safe node/hook addition and removal. Fix some debug stuff.
Diffstat (limited to 'sys/netgraph/netgraph.h')
-rw-r--r--sys/netgraph/netgraph.h58
1 files changed, 49 insertions, 9 deletions
diff --git a/sys/netgraph/netgraph.h b/sys/netgraph/netgraph.h
index 396bef3..dc41880 100644
--- a/sys/netgraph/netgraph.h
+++ b/sys/netgraph/netgraph.h
@@ -540,6 +540,7 @@ typedef struct ng_meta *meta_p;
***********************************************************************
*
*/
+typedef int ng_item_fn(node_p node, hook_p hook, void *arg1, int arg2);
struct ng_item {
u_long el_flags;
item_p el_next;
@@ -554,6 +555,11 @@ struct ng_item {
struct ng_mesg *msg_msg;
ng_ID_t msg_retaddr;
} msg;
+ struct {
+ ng_item_fn *fn_fn;
+ void *fn_arg1;
+ int fn_arg2;
+ } fn;
} body;
#ifdef NETGRAPH_DEBUG /*----------------------------------------------*/
char *lastfile;
@@ -561,13 +567,18 @@ struct ng_item {
TAILQ_ENTRY(ng_item) all; /* all existing items */
#endif /* NETGRAPH_DEBUG */ /*----------------------------------------------*/
};
-#define NGQF_D_M 0x01 /* MASK of data/message */
-#define NGQF_DATA 0x01 /* the queue element is data */
+
+#define NGQF_TYPE 0x03 /* MASK of content definition */
#define NGQF_MESG 0x00 /* the queue element is a message */
-#define NGQF_TYPE 0x02 /* MASK for queue entry type */
-#define NGQF_READER 0x02 /* queued as a reader */
+#define NGQF_DATA 0x01 /* the queue element is data */
+#define NGQF_FN 0x02 /* the queue element is a function */
+#define NGQF_UNDEF 0x03 /* UNDEFINED */
+
+#define NGQF_RW 0x04 /* MASK for queue entry read/write */
+#define NGQF_READER 0x04 /* queued as a reader */
#define NGQF_WRITER 0x00 /* queued as a writer */
-#define NGQF_FREE 0x04
+
+#define NGQF_FREE 0x08
/*
* Get the mbuf (etc) out of an item.
@@ -583,6 +594,9 @@ struct ng_item {
#define _NGI_META(i) ((i)->body.data.da_meta)
#define _NGI_MSG(i) ((i)->body.msg.msg_msg)
#define _NGI_RETADDR(i) ((i)->body.msg.msg_retaddr)
+#define _NGI_FN(i) ((i)->body.fn.fn_fn)
+#define _NGI_ARG1(i) ((i)->body.fn.fn_arg1)
+#define _NGI_ARG2(i) ((i)->body.fn.fn_arg2)
#ifdef NETGRAPH_DEBUG /*----------------------------------------------*/
void dumpitem(item_p item, char *file, int line);
@@ -633,13 +647,34 @@ _ngi_retaddr(item_p item, char *file, int line)
return (&_NGI_RETADDR(item));
}
-#define NGI_M(i) (*_ngi_m(i, _NN_))
+static __inline ng_item_fn **
+_ngi_fn(item_p item, char *file, int line)
+{
+ _ngi_check(item, file, line);
+ return (&_NGI_FN(item));
+}
-#define NGI_META(i) (*_ngi_meta(i, _NN_))
+static __inline void **
+_ngi_arg1(item_p item, char *file, int line)
+{
+ _ngi_check(item, file, line);
+ return (&_NGI_ARG1(item));
+}
-#define NGI_MSG(i) (*_ngi_msg(i, _NN_))
+static __inline int *
+_ngi_arg2(item_p item, char *file, int line)
+{
+ _ngi_check(item, file, line);
+ return (&_NGI_ARG2(item));
+}
-#define NGI_RETADDR(i) (*_ngi_retaddr(i, _NN_))
+#define NGI_M(i) (*_ngi_m(i, _NN_))
+#define NGI_META(i) (*_ngi_meta(i, _NN_))
+#define NGI_MSG(i) (*_ngi_msg(i, _NN_))
+#define NGI_RETADDR(i) (*_ngi_retaddr(i, _NN_))
+#define NGI_FN(i) (*_ngi_fn(i, _NN_))
+#define NGI_ARG1(i) (*_ngi_arg1(i, _NN_))
+#define NGI_ARG2(i) (*_ngi_arg2(i, _NN_))
#define NGI_GET_M(i,m) \
do { \
@@ -677,6 +712,9 @@ _ngi_retaddr(item_p item, char *file, int line)
#define NGI_META(i) _NGI_META(i)
#define NGI_MSG(i) _NGI_MSG(i)
#define NGI_RETADDR(i) _NGI_RETADDR(i)
+#define NGI_FN(i) _NGI_FN(i)
+#define NGI_ARG1(i) _NGI_ARG1(i)
+#define NGI_ARG2(i) _NGI_ARG2(i)
#define NGI_GET_M(i,m) do {m = NGI_M(i); NGI_M(i) = NULL; } while (0)
#define NGI_GET_META(i,m) do {m = NGI_META(i); NGI_META(i) = NULL;} while (0)
@@ -1013,6 +1051,8 @@ void ng_replace_retaddr(node_p here, item_p item, ng_ID_t retaddr);
int ng_rmhook_self(hook_p hook); /* if a node wants to kill a hook */
int ng_rmnode_self(node_p here); /* if a node wants to suicide */
int ng_snd_item(item_p item, int queue);
+int ng_send_fn(node_p node, hook_p hook, ng_item_fn *fn,
+ void *arg1, int arg2);
/*
* prototypes the user should DEFINITLY not use directly
OpenPOWER on IntegriCloud