summaryrefslogtreecommitdiffstats
path: root/sys/dev/musycc
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>2000-12-18 20:03:32 +0000
committerjulian <julian@FreeBSD.org>2000-12-18 20:03:32 +0000
commit0c949560a12dd18943b66fe09bd06d3c34e5cf7a (patch)
tree5466b04ac515e8d01f9b135b6c119744a1138d82 /sys/dev/musycc
parente6bd476191c5b338634a02b0a6de56aa7f23cf37 (diff)
downloadFreeBSD-src-0c949560a12dd18943b66fe09bd06d3c34e5cf7a.zip
FreeBSD-src-0c949560a12dd18943b66fe09bd06d3c34e5cf7a.tar.gz
Divorce the kernel binary ABI version number from the message
format version number. (userland programs should not need to be recompiled when the netgraph kernel internal ABI is changed. Also fix modules that don;t handle the fact that a caller may not supply a return message pointer. (benign at the moment because the calling code checks, but that will change)
Diffstat (limited to 'sys/dev/musycc')
-rw-r--r--sys/dev/musycc/musycc.c58
1 files changed, 36 insertions, 22 deletions
diff --git a/sys/dev/musycc/musycc.c b/sys/dev/musycc/musycc.c
index c8f35ff..85ec6e0 100644
--- a/sys/dev/musycc/musycc.c
+++ b/sys/dev/musycc/musycc.c
@@ -265,7 +265,7 @@ static ng_rcvdata_t musycc_rcvdata;
static ng_disconnect_t musycc_disconnect;
static struct ng_type ngtypestruct = {
- NG_VERSION,
+ NG_ABI_VERSION,
NG_NODETYPE,
NULL,
musycc_constructor,
@@ -926,56 +926,70 @@ barf:
return;
}
+/*
+ * Handle status and config enquiries.
+ * Respond with a synchronous response.
+ * [JRE] -this would be easier to read with the usual 'switch' structure-
+ */
static int
-musycc_rcvmsg(node_p node, struct ng_mesg *msg, const char *retaddr, struct ng_mesg **resp, hook_p lasthook)
+musycc_rcvmsg(node_p node, struct ng_mesg *msg, const char *retaddr,
+ struct ng_mesg **rptr, hook_p lasthook)
{
struct softc *sc;
+ struct ng_mesg *resp = NULL;
char *s, *r;
+ int error = 0;
sc = node->private;
+ if (rptr)
+ *rptr = NULL; /* default answer in case of errors */
if (msg->header.typecookie != NGM_GENERIC_COOKIE)
goto out;
if (msg->header.cmd == NGM_TEXT_STATUS) {
- NG_MKRESPONSE(*resp, msg,
+ NG_MKRESPONSE(resp, msg,
sizeof(struct ng_mesg) + NG_TEXTRESPONSE, M_NOWAIT);
- if (*resp == NULL) {
- FREE(msg, M_NETGRAPH);
- return (ENOMEM);
+ if (resp == NULL) {
+ error = ENOMEM;
+ goto out;
}
- s = (char *)(*resp)->data;
+ s = (char *)resp->data;
status_8370(sc, s);
- (*resp)->header.arglen = strlen(s) + 1;
+ resp->header.arglen = strlen(s) + 1;
FREE(msg, M_NETGRAPH);
- return (0);
- }
- if (msg->header.cmd == NGM_TEXT_CONFIG) {
+
+ } else if (msg->header.cmd == NGM_TEXT_CONFIG) {
if (msg->header.arglen) {
s = (char *)msg->data;
} else {
s = NULL;
}
- NG_MKRESPONSE(*resp, msg,
+ NG_MKRESPONSE(resp, msg,
sizeof(struct ng_mesg) + NG_TEXTRESPONSE, M_NOWAIT);
- if (*resp == NULL) {
- FREE(msg, M_NETGRAPH);
- return (ENOMEM);
+ if (resp == NULL) {
+ error = ENOMEM;
+ goto out;
}
- r = (char *)(*resp)->data;
+ r = (char *)resp->data;
*r = '\0';
musycc_config(node, s, r);
- (*resp)->header.arglen = strlen(r) + 1;
+ resp->header.arglen = strlen(r) + 1;
FREE(msg, M_NETGRAPH);
- return (0);
- }
+ } else {
+ error = EINVAL;
+ }
out:
- if (resp)
- *resp = NULL;
+ /* Take care of synchronous response, if any */
+ if (rptr)
+ *rptr = resp;
+ else if (resp)
+ FREE(resp, M_NETGRAPH); /* eventually 'send' the response */
+
FREE(msg, M_NETGRAPH);
- return (EINVAL);
+ return (error);
}
static int
OpenPOWER on IntegriCloud