Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F140970286
D30657.id90473.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D30657.id90473.diff
View Options
Index: tests/sys/netgraph/util.h
===================================================================
--- tests/sys/netgraph/util.h
+++ tests/sys/netgraph/util.h
@@ -46,6 +46,8 @@
void ng_register_data(char const *hook, ng_data_handler_t proc);
void ng_send_data(char const *hook, void const *, size_t);
+typedef void (*ng_msg_handler_t)(char const *, struct ng_mesg *, void *);
+void ng_register_msg(ng_msg_handler_t proc);
int ng_send_msg(char const *path, char const *msg);
int ng_handle_event (unsigned int ms, void *ctx);
Index: tests/sys/netgraph/util.c
===================================================================
--- tests/sys/netgraph/util.c
+++ tests/sys/netgraph/util.c
@@ -34,7 +34,6 @@
#include <atf-c.h>
#include <errno.h>
#include <stdlib.h>
-#include <stdio.h>
#include <string.h>
#include <sys/select.h>
@@ -59,9 +58,10 @@
SLIST_ENTRY(data_handler) next;
};
static SLIST_HEAD(, data_handler) data_head = SLIST_HEAD_INITIALIZER(data_head);
+static ng_msg_handler_t msg_handler = NULL;
static void handle_data(void *ctx);
-static void handle_msg(void);
+static void handle_msg(void *ctx);
void
ng_connect(char const *path1, char const *hook1,
@@ -143,14 +143,21 @@
CHECK(, -1 != NgSendData(ds, hook, data, len));
}
+void
+ng_register_msg(ng_msg_handler_t proc) {
+ msg_handler = proc;
+}
+
static void
-handle_msg(void) {
+handle_msg(void *ctx) {
struct ng_mesg *m;
char path[NG_PATHSIZ];
ATF_REQUIRE(-1 != NgAllocRecvMsg(cs, &m, path));
- printf("Got message from %s\n", path);
+ if(msg_handler != NULL)
+ (*msg_handler)(path, m, ctx);
+
free(m);
}
@@ -191,7 +198,7 @@
return 0;
default: /* something to do */
if (FD_ISSET(cs, &fds))
- handle_msg();
+ handle_msg(context);
if (FD_ISSET(ds, &fds))
handle_data(context);
return 1;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 31, 6:08 AM (2 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27404050
Default Alt Text
D30657.id90473.diff (1 KB)
Attached To
Mode
D30657: tests/netgraph: Allow receiving answers to messages
Attached
Detach File
Event Timeline
Log In to Comment