2 * Copyright (c) 2001-2002
3 * Fraunhofer Institute for Open Communication Systems (FhG Fokus).
5 * Copyright (c) 2003-2004
9 * Author: Harti Brandt <harti@freebsd.org>
11 * Redistribution of this software and documentation and use in source and
12 * binary forms, with or without modification, are permitted provided that
13 * the following conditions are met:
15 * 1. Redistributions of source code or documentation must retain the above
16 * copyright notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
21 * THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY THE AUTHOR
22 * AND ITS CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
23 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
24 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
25 * THE AUTHOR OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
28 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
31 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 * $FreeBSD: src/sys/netgraph/atm/ccatm/ng_ccatm.c,v 1.3 2006/09/30 12:37:43 netchild Exp $
35 * ATM call control and API
38 #include <sys/param.h>
39 #include <sys/systm.h>
40 #include <sys/kernel.h>
41 #include <sys/malloc.h>
43 #include <sys/errno.h>
44 #include <sys/socket.h>
45 #include <sys/socketvar.h>
47 #include <machine/stdarg.h>
49 #include "ng_message.h"
52 #include <netnatm/unimsg.h>
53 #include <netnatm/msg/unistruct.h>
54 #include <netnatm/api/unisap.h>
55 #include <netnatm/sig/unidef.h>
56 #include "atm/ngatmbase.h"
57 #include "atm/ng_uni.h"
58 #include <netnatm/api/atmapi.h>
59 #include "atm/ng_ccatm.h"
60 #include <netnatm/api/ccatm.h>
62 MODULE_DEPEND(ng_ccatm, ngatmbase, 1, 1, 1);
64 MALLOC_DEFINE(M_NG_CCATM, "ng_ccatm", "netgraph uni api node");
67 * Command structure parsing
71 static const struct ng_parse_fixedarray_info ng_ccatm_esi_type_info =
73 static const struct ng_parse_type ng_ccatm_esi_type = {
74 &ng_parse_fixedarray_type,
75 &ng_ccatm_esi_type_info
79 static const struct ng_parse_struct_field ng_ccatm_atm_port_type_info[] =
80 NGM_CCATM_ATM_PORT_INFO;
81 static const struct ng_parse_type ng_ccatm_atm_port_type = {
82 &ng_parse_struct_type,
83 ng_ccatm_atm_port_type_info
87 static const struct ng_parse_struct_field ng_ccatm_port_type_info[] =
89 static const struct ng_parse_type ng_ccatm_port_type = {
90 &ng_parse_struct_type,
91 ng_ccatm_port_type_info
94 /* the ADDRESS array itself */
95 static const struct ng_parse_fixedarray_info ng_ccatm_addr_array_type_info =
96 NGM_CCATM_ADDR_ARRAY_INFO;
97 static const struct ng_parse_type ng_ccatm_addr_array_type = {
98 &ng_parse_fixedarray_type,
99 &ng_ccatm_addr_array_type_info
103 static const struct ng_parse_struct_field ng_ccatm_uni_addr_type_info[] =
104 NGM_CCATM_UNI_ADDR_INFO;
105 static const struct ng_parse_type ng_ccatm_uni_addr_type = {
106 &ng_parse_struct_type,
107 ng_ccatm_uni_addr_type_info
110 /* ADDRESS request */
111 static const struct ng_parse_struct_field ng_ccatm_addr_req_type_info[] =
112 NGM_CCATM_ADDR_REQ_INFO;
113 static const struct ng_parse_type ng_ccatm_addr_req_type = {
114 &ng_parse_struct_type,
115 ng_ccatm_addr_req_type_info
118 /* ADDRESS var-array */
120 ng_ccatm_addr_req_array_getlen(const struct ng_parse_type *type,
121 const u_char *start, const u_char *buf)
123 const struct ngm_ccatm_get_addresses *p;
125 p = (const struct ngm_ccatm_get_addresses *)
126 (buf - offsetof(struct ngm_ccatm_get_addresses, addr));
129 static const struct ng_parse_array_info ng_ccatm_addr_req_array_type_info =
130 NGM_CCATM_ADDR_REQ_ARRAY_INFO;
131 static const struct ng_parse_type ng_ccatm_addr_req_array_type = {
132 &ng_parse_array_type,
133 &ng_ccatm_addr_req_array_type_info
136 /* Outer get_ADDRESSes structure */
137 static const struct ng_parse_struct_field ng_ccatm_get_addresses_type_info[] =
138 NGM_CCATM_GET_ADDRESSES_INFO;
139 static const struct ng_parse_type ng_ccatm_get_addresses_type = {
140 &ng_parse_struct_type,
141 ng_ccatm_get_addresses_type_info
146 ng_ccatm_port_array_getlen(const struct ng_parse_type *type,
147 const u_char *start, const u_char *buf)
149 const struct ngm_ccatm_portlist *p;
151 p = (const struct ngm_ccatm_portlist *)
152 (buf - offsetof(struct ngm_ccatm_portlist, ports));
155 static const struct ng_parse_array_info ng_ccatm_port_array_type_info =
156 NGM_CCATM_PORT_ARRAY_INFO;
157 static const struct ng_parse_type ng_ccatm_port_array_type = {
158 &ng_parse_array_type,
159 &ng_ccatm_port_array_type_info
162 /* Portlist structure */
163 static const struct ng_parse_struct_field ng_ccatm_portlist_type_info[] =
164 NGM_CCATM_PORTLIST_INFO;
165 static const struct ng_parse_type ng_ccatm_portlist_type = {
166 &ng_parse_struct_type,
167 ng_ccatm_portlist_type_info
173 static const struct ng_cmdlist ng_ccatm_cmdlist[] = {
200 &ng_parse_uint32_type
204 NGM_CCATM_GET_ADDRESSES,
207 &ng_ccatm_get_addresses_type
218 NGM_CCATM_ADDRESS_REGISTERED,
220 &ng_ccatm_addr_req_type,
225 NGM_CCATM_ADDRESS_UNREGISTERED,
227 &ng_ccatm_addr_req_type,
232 NGM_CCATM_SET_PORT_PARAM,
234 &ng_ccatm_atm_port_type,
239 NGM_CCATM_GET_PORT_PARAM,
242 &ng_ccatm_atm_port_type,
246 NGM_CCATM_GET_PORTLIST,
249 &ng_ccatm_portlist_type,
255 &ng_parse_hint32_type,
256 &ng_parse_hint32_type,
271 static ng_constructor_t ng_ccatm_constructor;
272 static ng_rcvmsg_t ng_ccatm_rcvmsg;
273 static ng_shutdown_t ng_ccatm_shutdown;
274 static ng_newhook_t ng_ccatm_newhook;
275 static ng_rcvdata_t ng_ccatm_rcvdata;
276 static ng_disconnect_t ng_ccatm_disconnect;
277 static int ng_ccatm_mod_event(module_t, int, void *);
279 static struct ng_type ng_ccatm_typestruct = {
280 .version = NG_ABI_VERSION,
281 .name = NG_CCATM_NODE_TYPE,
282 .mod_event = ng_ccatm_mod_event,
283 .constructor = ng_ccatm_constructor, /* Node constructor */
284 .rcvmsg = ng_ccatm_rcvmsg, /* Control messages */
285 .shutdown = ng_ccatm_shutdown, /* Node destructor */
286 .newhook = ng_ccatm_newhook, /* Arrival of new hook */
287 .rcvdata = ng_ccatm_rcvdata, /* receive data */
288 .disconnect = ng_ccatm_disconnect, /* disconnect a hook */
289 .cmdlist = ng_ccatm_cmdlist,
291 NETGRAPH_INIT(ccatm, &ng_ccatm_typestruct);
293 static ng_rcvdata_t ng_ccatm_rcvuni;
294 static ng_rcvdata_t ng_ccatm_rcvdump;
295 static ng_rcvdata_t ng_ccatm_rcvmanage;
301 node_p node; /* the owning node */
302 hook_p dump; /* dump hook */
303 hook_p manage; /* hook to ILMI */
306 struct mbuf *dump_first;
307 struct mbuf *dump_last; /* first and last mbuf when dumping */
309 u_int hook_cnt; /* count user and port hooks */
313 * Private UNI hook data
316 int is_uni; /* true if uni hook, user otherwise */
317 struct ccnode *node; /* the owning node */
319 void *inst; /* port or user */
322 static void ng_ccatm_send_user(struct ccuser *, void *, u_int, void *, size_t);
323 static void ng_ccatm_respond_user(struct ccuser *, void *, int, u_int,
325 static void ng_ccatm_send_uni(struct ccconn *, void *, u_int, u_int,
327 static void ng_ccatm_send_uni_glob(struct ccport *, void *, u_int, u_int,
329 static void ng_ccatm_log(const char *, ...) __printflike(1, 2);
331 static const struct cc_funcs cc_funcs = {
332 .send_user = ng_ccatm_send_user,
333 .respond_user = ng_ccatm_respond_user,
334 .send_uni = ng_ccatm_send_uni,
335 .send_uni_glob = ng_ccatm_send_uni_glob,
339 /************************************************************
344 ng_ccatm_constructor(node_p node)
348 priv = kmalloc(sizeof(*priv), M_NG_CCATM, M_WAITOK | M_NULLOK | M_ZERO);
353 priv->data = cc_create(&cc_funcs);
354 if (priv->data == NULL) {
355 kfree(priv, M_NG_CCATM);
359 NG_NODE_SET_PRIVATE(node, priv);
365 * Destroy a node. The user list is empty here, because all hooks are
366 * previously disconnected. The connection lists may not be empty, because
367 * connections may be waiting for responses from the stack. This also means,
368 * that no orphaned connections will be made by the port_destroy routine.
371 ng_ccatm_shutdown(node_p node)
373 struct ccnode *priv = NG_NODE_PRIVATE(node);
375 cc_destroy(priv->data);
377 kfree(priv, M_NG_CCATM);
378 NG_NODE_SET_PRIVATE(node, NULL);
386 * Retrieve the registered addresses for one port or all ports.
387 * Returns an error code or 0 on success.
390 ng_ccatm_get_addresses(node_p node, uint32_t portno, struct ng_mesg *msg,
391 struct ng_mesg **resp)
393 struct ccnode *priv = NG_NODE_PRIVATE(node);
394 struct uni_addr *addrs;
396 struct ngm_ccatm_get_addresses *list;
401 err = cc_get_addrs(priv->data, portno, &addrs, &ports, &count);
405 len = sizeof(*list) + count * sizeof(list->addr[0]);
406 NG_MKRESPONSE(*resp, msg, len, M_WAITOK | M_NULLOK);
408 kfree(addrs, M_NG_CCATM);
409 kfree(ports, M_NG_CCATM);
412 list = (struct ngm_ccatm_get_addresses *)(*resp)->data;
415 for (i = 0; i < count; i++) {
416 list->addr[i].port = ports[i];
417 list->addr[i].addr = addrs[i];
420 kfree(addrs, M_NG_CCATM);
421 kfree(ports, M_NG_CCATM);
427 * Dumper function. Pack the data into an mbuf chain.
430 send_dump(struct ccdata *data, void *uarg, const char *buf)
433 struct ccnode *priv = uarg;
435 if (priv->dump == NULL) {
436 m = m_getcl(MB_DONTWAIT, MT_DATA, M_PKTHDR);
439 priv->dump_first = priv->dump_last = m;
442 m = m_getcl(MB_DONTWAIT, MT_DATA, 0);
444 m_freem(priv->dump_first);
447 priv->dump_last->m_next = m;
451 strcpy(m->m_data, buf);
452 priv->dump_first->m_pkthdr.len += (m->m_len = strlen(buf));
458 * Dump current status to dump hook
461 ng_ccatm_dump(node_p node)
463 struct ccnode *priv = NG_NODE_PRIVATE(node);
467 priv->dump_first = priv->dump_last = NULL;
468 error = cc_dump(priv->data, MCLBYTES, send_dump, priv);
472 if ((m = priv->dump_first) != NULL) {
473 priv->dump_first = priv->dump_last = NULL;
474 NG_SEND_DATA_ONLY(error, priv->dump, m);
484 ng_ccatm_rcvmsg(node_p node, item_p item, hook_p lasthook)
486 struct ng_mesg *resp = NULL;
488 struct ccnode *priv = NG_NODE_PRIVATE(node);
491 NGI_GET_MSG(item, msg);
493 switch (msg->header.typecookie) {
495 case NGM_CCATM_COOKIE:
496 switch (msg->header.cmd) {
500 error = ng_ccatm_dump(node);
507 struct ngm_ccatm_port *arg;
509 if (msg->header.arglen != sizeof(*arg)) {
513 arg = (struct ngm_ccatm_port *)msg->data;
514 error = cc_port_stop(priv->data, arg->port);
518 case NGM_CCATM_START:
520 struct ngm_ccatm_port *arg;
522 if (msg->header.arglen != sizeof(*arg)) {
526 arg = (struct ngm_ccatm_port *)msg->data;
527 error = cc_port_start(priv->data, arg->port);
531 case NGM_CCATM_GETSTATE:
533 struct ngm_ccatm_port *arg;
536 if (msg->header.arglen != sizeof(*arg)) {
540 arg = (struct ngm_ccatm_port *)msg->data;
541 error = cc_port_isrunning(priv->data, arg->port,
544 NG_MKRESPONSE(resp, msg, sizeof(uint32_t),
545 M_WAITOK | M_NULLOK);
550 *(uint32_t *)resp->data = state;
555 case NGM_CCATM_GET_ADDRESSES:
557 struct ngm_ccatm_port *arg;
559 if (msg->header.arglen != sizeof(*arg)) {
563 arg = (struct ngm_ccatm_port *)msg->data;
564 error = ng_ccatm_get_addresses(node, arg->port, msg,
569 case NGM_CCATM_CLEAR:
571 struct ngm_ccatm_port *arg;
573 if (msg->header.arglen != sizeof(*arg)) {
577 arg = (struct ngm_ccatm_port *)msg->data;
578 error = cc_port_clear(priv->data, arg->port);
582 case NGM_CCATM_ADDRESS_REGISTERED:
584 struct ngm_ccatm_addr_req *arg;
586 if (msg->header.arglen != sizeof(*arg)) {
590 arg = (struct ngm_ccatm_addr_req *)msg->data;
591 error = cc_addr_register(priv->data, arg->port,
596 case NGM_CCATM_ADDRESS_UNREGISTERED:
598 struct ngm_ccatm_addr_req *arg;
600 if (msg->header.arglen != sizeof(*arg)) {
604 arg = (struct ngm_ccatm_addr_req *)msg->data;
605 error = cc_addr_unregister(priv->data, arg->port,
610 case NGM_CCATM_GET_PORT_PARAM:
612 struct ngm_ccatm_port *arg;
614 if (msg->header.arglen != sizeof(*arg)) {
618 arg = (struct ngm_ccatm_port *)msg->data;
619 NG_MKRESPONSE(resp, msg, sizeof(struct atm_port_info),
620 M_WAITOK | M_NULLOK);
625 error = cc_port_get_param(priv->data, arg->port,
626 (struct atm_port_info *)resp->data);
628 kfree(resp, M_NETGRAPH_MSG);
634 case NGM_CCATM_SET_PORT_PARAM:
636 struct atm_port_info *arg;
638 if (msg->header.arglen != sizeof(*arg)) {
642 arg = (struct atm_port_info *)msg->data;
643 error = cc_port_set_param(priv->data, arg);
647 case NGM_CCATM_GET_PORTLIST:
649 struct ngm_ccatm_portlist *arg;
652 if (msg->header.arglen != 0) {
656 error = cc_port_getlist(priv->data, &n, &ports);
660 NG_MKRESPONSE(resp, msg, sizeof(*arg) +
661 n * sizeof(arg->ports[0]), M_WAITOK | M_NULLOK);
663 kfree(ports, M_NG_CCATM);
667 arg = (struct ngm_ccatm_portlist *)resp->data;
670 for (arg->nports = 0; arg->nports < n; arg->nports++)
671 arg->ports[arg->nports] = ports[arg->nports];
672 kfree(ports, M_NG_CCATM);
676 case NGM_CCATM_SETLOG:
680 log_level = cc_get_log(priv->data);
681 if (msg->header.arglen != 0) {
682 if (msg->header.arglen != sizeof(log_level)) {
686 cc_set_log(priv->data, *(uint32_t *)msg->data);
689 NG_MKRESPONSE(resp, msg, sizeof(uint32_t), M_WAITOK | M_NULLOK);
692 if (msg->header.arglen != 0)
693 cc_set_log(priv->data, log_level);
696 *(uint32_t *)resp->data = log_level;
700 case NGM_CCATM_RESET:
701 if (msg->header.arglen != 0) {
706 if (priv->hook_cnt != 0) {
710 cc_reset(priv->data);
713 case NGM_CCATM_GET_EXSTAT:
715 struct atm_exstatus s;
716 struct atm_exstatus_ep *eps;
717 struct atm_exstatus_port *ports;
718 struct atm_exstatus_conn *conns;
719 struct atm_exstatus_party *parties;
722 if (msg->header.arglen != 0) {
726 error = cc_get_extended_status(priv->data,
727 &s, &eps, &ports, &conns, &parties);
731 offs = sizeof(s) + s.neps * sizeof(*eps) +
732 s.nports * sizeof(*ports) +
733 s.nconns * sizeof(*conns) +
734 s.nparties * sizeof(*parties);
736 NG_MKRESPONSE(resp, msg, offs, M_WAITOK | M_NULLOK);
742 memcpy(resp->data, &s, sizeof(s));
745 memcpy(resp->data + offs, eps,
746 sizeof(*eps) * s.neps);
747 offs += sizeof(*eps) * s.neps;
749 memcpy(resp->data + offs, ports,
750 sizeof(*ports) * s.nports);
751 offs += sizeof(*ports) * s.nports;
753 memcpy(resp->data + offs, conns,
754 sizeof(*conns) * s.nconns);
755 offs += sizeof(*conns) * s.nconns;
757 memcpy(resp->data + offs, parties,
758 sizeof(*parties) * s.nparties);
759 offs += sizeof(*parties) * s.nparties;
761 kfree(eps, M_NG_CCATM);
762 kfree(ports, M_NG_CCATM);
763 kfree(conns, M_NG_CCATM);
764 kfree(parties, M_NG_CCATM);
781 NG_RESPOND_MSG(error, node, item, resp);
786 /************************************************************
791 ng_ccatm_newhook(node_p node, hook_p hook, const char *name)
793 struct ccnode *priv = NG_NODE_PRIVATE(node);
800 if (strncmp(name, "uni", 3) == 0) {
802 * This is a UNI hook. Should be a new port.
806 lport = strtoul(name + 3, &end, 10);
807 if (*end != '\0' || lport == 0 || lport > 0xffffffff)
810 hd = kmalloc(sizeof(*hd), M_NG_CCATM, M_WAITOK | M_NULLOK);
817 port = cc_port_create(priv->data, hd, (u_int)lport);
819 kfree(hd, M_NG_CCATM);
824 NG_HOOK_SET_PRIVATE(hook, hd);
825 NG_HOOK_SET_RCVDATA(hook, ng_ccatm_rcvuni);
826 NG_HOOK_FORCE_QUEUE(hook);
833 if (strcmp(name, "dump") == 0) {
835 NG_HOOK_SET_RCVDATA(hook, ng_ccatm_rcvdump);
839 if (strcmp(name, "manage") == 0) {
841 NG_HOOK_SET_RCVDATA(hook, ng_ccatm_rcvmanage);
848 hd = kmalloc(sizeof(*hd), M_NG_CCATM, M_WAITOK | M_NULLOK);
855 user = cc_user_create(priv->data, hd, NG_HOOK_NAME(hook));
857 kfree(hd, M_NG_CCATM);
862 NG_HOOK_SET_PRIVATE(hook, hd);
863 NG_HOOK_FORCE_QUEUE(hook);
874 ng_ccatm_disconnect(hook_p hook)
876 node_p node = NG_HOOK_NODE(hook);
877 struct ccnode *priv = NG_NODE_PRIVATE(node);
878 struct cchook *hd = NG_HOOK_PRIVATE(hook);
881 if (hook == priv->dump) {
884 } else if (hook == priv->manage) {
886 cc_unmanage(priv->data);
890 cc_port_destroy(hd->inst, 0);
892 cc_user_destroy(hd->inst);
896 kfree(hd, M_NG_CCATM);
897 NG_HOOK_SET_PRIVATE(hook, NULL);
905 * When the number of hooks drops to zero, delete the node.
907 if (NG_NODE_NUMHOOKS(node) == 0 && NG_NODE_IS_VALID(node))
908 ng_rmnode_self(node);
913 /************************************************************
915 * Receive data from user hook
918 ng_ccatm_rcvdata(hook_p hook, item_p item)
920 struct cchook *hd = NG_HOOK_PRIVATE(hook);
929 if ((err = uni_msg_unpack_mbuf(m, &msg)) != 0) {
935 if (uni_msg_len(msg) < sizeof(op)) {
936 printf("%s: packet too short\n", __func__);
937 uni_msg_destroy(msg);
941 bcopy(msg->b_rptr, &op, sizeof(op));
942 msg->b_rptr += sizeof(op);
944 err = cc_user_signal(hd->inst, op.op, msg);
945 cc_work(hd->node->data);
950 * Pack a header and a data area into an mbuf chain
953 pack_buf(void *h, size_t hlen, void *t, size_t tlen)
955 struct mbuf *m, *m0, *last;
956 u_char *buf = (u_char *)t;
959 /* header should fit into a normal mbuf */
960 MGETHDR(m0, MB_DONTWAIT, MT_DATA);
964 KASSERT(hlen <= MHLEN, ("hlen > MHLEN"));
966 bcopy(h, m0->m_data, hlen);
968 m0->m_pkthdr.len = hlen;
971 while ((n = tlen) != 0) {
973 m = m_getcl(MB_DONTWAIT, MT_DATA, 0);
977 MGET(m, MB_DONTWAIT, MT_DATA);
985 bcopy(buf, m->m_data, n);
989 m0->m_pkthdr.len += n;
1000 * Send an indication to the user.
1003 ng_ccatm_send_user(struct ccuser *user, void *uarg, u_int op,
1004 void *val, size_t len)
1006 struct cchook *hd = uarg;
1012 m = pack_buf(&h, sizeof(h), val, len);
1016 NG_SEND_DATA_ONLY(error, hd->hook, m);
1018 printf("%s: error=%d\n", __func__, error);
1022 * Send a response to the user.
1025 ng_ccatm_respond_user(struct ccuser *user, void *uarg, int err, u_int data,
1026 void *val, size_t len)
1028 struct cchook *hd = uarg;
1032 struct atm_resp resp;
1036 resp.op.op = ATMOP_RESP;
1037 resp.resp.resp = err;
1038 resp.resp.data = data;
1039 m = pack_buf(&resp, sizeof(resp), val, len);
1043 NG_SEND_DATA_ONLY(error, hd->hook, m);
1045 printf("%s: error=%d\n", __func__, error);
1049 * Receive data from UNI.
1052 ng_ccatm_rcvuni(hook_p hook, item_p item)
1054 struct cchook *hd = NG_HOOK_PRIVATE(hook);
1055 struct uni_msg *msg;
1063 if ((err = uni_msg_unpack_mbuf(m, &msg)) != 0) {
1069 if (uni_msg_len(msg) < sizeof(arg)) {
1070 printf("%s: packet too short\n", __func__);
1071 uni_msg_destroy(msg);
1075 bcopy(msg->b_rptr, &arg, sizeof(arg));
1076 msg->b_rptr += sizeof(arg);
1078 if (arg.sig == UNIAPI_ERROR) {
1079 if (uni_msg_len(msg) != sizeof(struct uniapi_error)) {
1080 printf("%s: bad UNIAPI_ERROR size %zu\n", __func__,
1082 uni_msg_destroy(msg);
1085 err = cc_uni_response(hd->inst, arg.cookie,
1086 ((struct uniapi_error *)msg->b_rptr)->reason,
1087 ((struct uniapi_error *)msg->b_rptr)->state);
1088 uni_msg_destroy(msg);
1090 err = cc_uni_signal(hd->inst, arg.cookie, arg.sig, msg);
1092 cc_work(hd->node->data);
1097 * Uarg is the port's uarg.
1100 ng_ccatm_send_uni(struct ccconn *conn, void *uarg, u_int op, u_int cookie,
1101 struct uni_msg *msg)
1103 struct cchook *hd = uarg;
1109 arg.cookie = cookie;
1111 m = uni_msg_pack_mbuf(msg, &arg, sizeof(arg));
1112 uni_msg_destroy(msg);
1116 NG_SEND_DATA_ONLY(error, hd->hook, m);
1118 printf("%s: error=%d\n", __func__, error);
1122 * Send a global message to the UNI
1125 ng_ccatm_send_uni_glob(struct ccport *port, void *uarg, u_int op, u_int cookie,
1126 struct uni_msg *msg)
1128 struct cchook *hd = uarg;
1134 arg.cookie = cookie;
1136 m = uni_msg_pack_mbuf(msg, &arg, sizeof(arg));
1138 uni_msg_destroy(msg);
1142 NG_SEND_DATA_ONLY(error, hd->hook, m);
1144 printf("%s: error=%d\n", __func__, error);
1147 * Receive from ILMID
1150 ng_ccatm_rcvmanage(hook_p hook, item_p item)
1157 ng_ccatm_rcvdump(hook_p hook, item_p item)
1164 ng_ccatm_log(const char *fmt, ...)
1175 * Loading and unloading of node type
1178 ng_ccatm_mod_event(module_t mod, int event, void *data)