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.
35 * ATM call control and API
38 #include <sys/cdefs.h>
39 __FBSDID("$FreeBSD$");
41 #include <sys/param.h>
42 #include <sys/systm.h>
43 #include <sys/kernel.h>
44 #include <sys/malloc.h>
46 #include <sys/errno.h>
47 #include <sys/socket.h>
48 #include <sys/socketvar.h>
50 #include <machine/stdarg.h>
52 #include <netgraph/ng_message.h>
53 #include <netgraph/netgraph.h>
54 #include <netgraph/ng_parse.h>
55 #include <netnatm/unimsg.h>
56 #include <netnatm/msg/unistruct.h>
57 #include <netnatm/api/unisap.h>
58 #include <netnatm/sig/unidef.h>
59 #include <netgraph/atm/ngatmbase.h>
60 #include <netgraph/atm/ng_uni.h>
61 #include <netnatm/api/atmapi.h>
62 #include <netgraph/atm/ng_ccatm.h>
63 #include <netnatm/api/ccatm.h>
65 MODULE_DEPEND(ng_ccatm, ngatmbase, 1, 1, 1);
67 MALLOC_DEFINE(M_NG_CCATM, "ng_ccatm", "netgraph uni api node");
70 * Command structure parsing
74 static const struct ng_parse_fixedarray_info ng_ccatm_esi_type_info =
76 static const struct ng_parse_type ng_ccatm_esi_type = {
77 &ng_parse_fixedarray_type,
78 &ng_ccatm_esi_type_info
82 static const struct ng_parse_struct_field ng_ccatm_atm_port_type_info[] =
83 NGM_CCATM_ATM_PORT_INFO;
84 static const struct ng_parse_type ng_ccatm_atm_port_type = {
85 &ng_parse_struct_type,
86 ng_ccatm_atm_port_type_info
90 static const struct ng_parse_struct_field ng_ccatm_port_type_info[] =
92 static const struct ng_parse_type ng_ccatm_port_type = {
93 &ng_parse_struct_type,
94 ng_ccatm_port_type_info
97 /* the ADDRESS array itself */
98 static const struct ng_parse_fixedarray_info ng_ccatm_addr_array_type_info =
99 NGM_CCATM_ADDR_ARRAY_INFO;
100 static const struct ng_parse_type ng_ccatm_addr_array_type = {
101 &ng_parse_fixedarray_type,
102 &ng_ccatm_addr_array_type_info
106 static const struct ng_parse_struct_field ng_ccatm_uni_addr_type_info[] =
107 NGM_CCATM_UNI_ADDR_INFO;
108 static const struct ng_parse_type ng_ccatm_uni_addr_type = {
109 &ng_parse_struct_type,
110 ng_ccatm_uni_addr_type_info
113 /* ADDRESS request */
114 static const struct ng_parse_struct_field ng_ccatm_addr_req_type_info[] =
115 NGM_CCATM_ADDR_REQ_INFO;
116 static const struct ng_parse_type ng_ccatm_addr_req_type = {
117 &ng_parse_struct_type,
118 ng_ccatm_addr_req_type_info
121 /* ADDRESS var-array */
123 ng_ccatm_addr_req_array_getlen(const struct ng_parse_type *type,
124 const u_char *start, const u_char *buf)
126 const struct ngm_ccatm_get_addresses *p;
128 p = (const struct ngm_ccatm_get_addresses *)
129 (buf - offsetof(struct ngm_ccatm_get_addresses, addr));
132 static const struct ng_parse_array_info ng_ccatm_addr_req_array_type_info =
133 NGM_CCATM_ADDR_REQ_ARRAY_INFO;
134 static const struct ng_parse_type ng_ccatm_addr_req_array_type = {
135 &ng_parse_array_type,
136 &ng_ccatm_addr_req_array_type_info
139 /* Outer get_ADDRESSes structure */
140 static const struct ng_parse_struct_field ng_ccatm_get_addresses_type_info[] =
141 NGM_CCATM_GET_ADDRESSES_INFO;
142 static const struct ng_parse_type ng_ccatm_get_addresses_type = {
143 &ng_parse_struct_type,
144 ng_ccatm_get_addresses_type_info
149 ng_ccatm_port_array_getlen(const struct ng_parse_type *type,
150 const u_char *start, const u_char *buf)
152 const struct ngm_ccatm_portlist *p;
154 p = (const struct ngm_ccatm_portlist *)
155 (buf - offsetof(struct ngm_ccatm_portlist, ports));
158 static const struct ng_parse_array_info ng_ccatm_port_array_type_info =
159 NGM_CCATM_PORT_ARRAY_INFO;
160 static const struct ng_parse_type ng_ccatm_port_array_type = {
161 &ng_parse_array_type,
162 &ng_ccatm_port_array_type_info
165 /* Portlist structure */
166 static const struct ng_parse_struct_field ng_ccatm_portlist_type_info[] =
167 NGM_CCATM_PORTLIST_INFO;
168 static const struct ng_parse_type ng_ccatm_portlist_type = {
169 &ng_parse_struct_type,
170 ng_ccatm_portlist_type_info
176 static const struct ng_cmdlist ng_ccatm_cmdlist[] = {
203 &ng_parse_uint32_type
207 NGM_CCATM_GET_ADDRESSES,
210 &ng_ccatm_get_addresses_type
221 NGM_CCATM_ADDRESS_REGISTERED,
223 &ng_ccatm_addr_req_type,
228 NGM_CCATM_ADDRESS_UNREGISTERED,
230 &ng_ccatm_addr_req_type,
235 NGM_CCATM_SET_PORT_PARAM,
237 &ng_ccatm_atm_port_type,
242 NGM_CCATM_GET_PORT_PARAM,
245 &ng_ccatm_atm_port_type,
249 NGM_CCATM_GET_PORTLIST,
252 &ng_ccatm_portlist_type,
258 &ng_parse_hint32_type,
259 &ng_parse_hint32_type,
274 static ng_constructor_t ng_ccatm_constructor;
275 static ng_rcvmsg_t ng_ccatm_rcvmsg;
276 static ng_shutdown_t ng_ccatm_shutdown;
277 static ng_newhook_t ng_ccatm_newhook;
278 static ng_rcvdata_t ng_ccatm_rcvdata;
279 static ng_disconnect_t ng_ccatm_disconnect;
280 static int ng_ccatm_mod_event(module_t, int, void *);
282 static struct ng_type ng_ccatm_typestruct = {
283 .version = NG_ABI_VERSION,
284 .name = NG_CCATM_NODE_TYPE,
285 .mod_event = ng_ccatm_mod_event,
286 .constructor = ng_ccatm_constructor, /* Node constructor */
287 .rcvmsg = ng_ccatm_rcvmsg, /* Control messages */
288 .shutdown = ng_ccatm_shutdown, /* Node destructor */
289 .newhook = ng_ccatm_newhook, /* Arrival of new hook */
290 .rcvdata = ng_ccatm_rcvdata, /* receive data */
291 .disconnect = ng_ccatm_disconnect, /* disconnect a hook */
292 .cmdlist = ng_ccatm_cmdlist,
294 NETGRAPH_INIT(ccatm, &ng_ccatm_typestruct);
296 static ng_rcvdata_t ng_ccatm_rcvuni;
297 static ng_rcvdata_t ng_ccatm_rcvdump;
298 static ng_rcvdata_t ng_ccatm_rcvmanage;
304 node_p node; /* the owning node */
305 hook_p dump; /* dump hook */
306 hook_p manage; /* hook to ILMI */
309 struct mbuf *dump_first;
310 struct mbuf *dump_last; /* first and last mbuf when dumping */
312 u_int hook_cnt; /* count user and port hooks */
316 * Private UNI hook data
319 int is_uni; /* true if uni hook, user otherwise */
320 struct ccnode *node; /* the owning node */
322 void *inst; /* port or user */
325 static void ng_ccatm_send_user(struct ccuser *, void *, u_int, void *, size_t);
326 static void ng_ccatm_respond_user(struct ccuser *, void *, int, u_int,
328 static void ng_ccatm_send_uni(struct ccconn *, void *, u_int, u_int,
330 static void ng_ccatm_send_uni_glob(struct ccport *, void *, u_int, u_int,
332 static void ng_ccatm_log(const char *, ...) __printflike(1, 2);
334 static const struct cc_funcs cc_funcs = {
335 .send_user = ng_ccatm_send_user,
336 .respond_user = ng_ccatm_respond_user,
337 .send_uni = ng_ccatm_send_uni,
338 .send_uni_glob = ng_ccatm_send_uni_glob,
342 /************************************************************
347 ng_ccatm_constructor(node_p node)
351 priv = malloc(sizeof(*priv), M_NG_CCATM, M_WAITOK | M_ZERO);
354 priv->data = cc_create(&cc_funcs);
355 if (priv->data == NULL) {
356 free(priv, M_NG_CCATM);
360 NG_NODE_SET_PRIVATE(node, priv);
366 * Destroy a node. The user list is empty here, because all hooks are
367 * previously disconnected. The connection lists may not be empty, because
368 * connections may be waiting for responses from the stack. This also means,
369 * that no orphaned connections will be made by the port_destroy routine.
372 ng_ccatm_shutdown(node_p node)
374 struct ccnode *priv = NG_NODE_PRIVATE(node);
376 cc_destroy(priv->data);
378 free(priv, M_NG_CCATM);
379 NG_NODE_SET_PRIVATE(node, NULL);
387 * Retrieve the registered addresses for one port or all ports.
388 * Returns an error code or 0 on success.
391 ng_ccatm_get_addresses(node_p node, uint32_t portno, struct ng_mesg *msg,
392 struct ng_mesg **resp)
394 struct ccnode *priv = NG_NODE_PRIVATE(node);
395 struct uni_addr *addrs;
397 struct ngm_ccatm_get_addresses *list;
402 err = cc_get_addrs(priv->data, portno, &addrs, &ports, &count);
406 len = sizeof(*list) + count * sizeof(list->addr[0]);
407 NG_MKRESPONSE(*resp, msg, len, M_NOWAIT);
409 free(addrs, M_NG_CCATM);
410 free(ports, M_NG_CCATM);
413 list = (struct ngm_ccatm_get_addresses *)(*resp)->data;
416 for (i = 0; i < count; i++) {
417 list->addr[i].port = ports[i];
418 list->addr[i].addr = addrs[i];
421 free(addrs, M_NG_CCATM);
422 free(ports, M_NG_CCATM);
428 * Dumper function. Pack the data into an mbuf chain.
431 send_dump(struct ccdata *data, void *uarg, const char *buf)
434 struct ccnode *priv = uarg;
436 if (priv->dump == NULL) {
437 m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
440 priv->dump_first = priv->dump_last = m;
443 m = m_getcl(M_NOWAIT, MT_DATA, 0);
445 m_freem(priv->dump_first);
448 priv->dump_last->m_next = m;
452 strcpy(m->m_data, buf);
453 priv->dump_first->m_pkthdr.len += (m->m_len = strlen(buf));
459 * Dump current status to dump hook
462 ng_ccatm_dump(node_p node)
464 struct ccnode *priv = NG_NODE_PRIVATE(node);
468 priv->dump_first = priv->dump_last = NULL;
469 error = cc_dump(priv->data, MCLBYTES, send_dump, priv);
473 if ((m = priv->dump_first) != NULL) {
474 priv->dump_first = priv->dump_last = NULL;
475 NG_SEND_DATA_ONLY(error, priv->dump, m);
485 ng_ccatm_rcvmsg(node_p node, item_p item, hook_p lasthook)
487 struct ng_mesg *resp = NULL;
489 struct ccnode *priv = NG_NODE_PRIVATE(node);
492 NGI_GET_MSG(item, msg);
494 switch (msg->header.typecookie) {
496 case NGM_CCATM_COOKIE:
497 switch (msg->header.cmd) {
501 error = ng_ccatm_dump(node);
508 struct ngm_ccatm_port *arg;
510 if (msg->header.arglen != sizeof(*arg)) {
514 arg = (struct ngm_ccatm_port *)msg->data;
515 error = cc_port_stop(priv->data, arg->port);
519 case NGM_CCATM_START:
521 struct ngm_ccatm_port *arg;
523 if (msg->header.arglen != sizeof(*arg)) {
527 arg = (struct ngm_ccatm_port *)msg->data;
528 error = cc_port_start(priv->data, arg->port);
532 case NGM_CCATM_GETSTATE:
534 struct ngm_ccatm_port *arg;
537 if (msg->header.arglen != sizeof(*arg)) {
541 arg = (struct ngm_ccatm_port *)msg->data;
542 error = cc_port_isrunning(priv->data, arg->port,
545 NG_MKRESPONSE(resp, msg, sizeof(uint32_t),
551 *(uint32_t *)resp->data = state;
556 case NGM_CCATM_GET_ADDRESSES:
558 struct ngm_ccatm_port *arg;
560 if (msg->header.arglen != sizeof(*arg)) {
564 arg = (struct ngm_ccatm_port *)msg->data;
565 error = ng_ccatm_get_addresses(node, arg->port, msg,
570 case NGM_CCATM_CLEAR:
572 struct ngm_ccatm_port *arg;
574 if (msg->header.arglen != sizeof(*arg)) {
578 arg = (struct ngm_ccatm_port *)msg->data;
579 error = cc_port_clear(priv->data, arg->port);
583 case NGM_CCATM_ADDRESS_REGISTERED:
585 struct ngm_ccatm_addr_req *arg;
587 if (msg->header.arglen != sizeof(*arg)) {
591 arg = (struct ngm_ccatm_addr_req *)msg->data;
592 error = cc_addr_register(priv->data, arg->port,
597 case NGM_CCATM_ADDRESS_UNREGISTERED:
599 struct ngm_ccatm_addr_req *arg;
601 if (msg->header.arglen != sizeof(*arg)) {
605 arg = (struct ngm_ccatm_addr_req *)msg->data;
606 error = cc_addr_unregister(priv->data, arg->port,
611 case NGM_CCATM_GET_PORT_PARAM:
613 struct ngm_ccatm_port *arg;
615 if (msg->header.arglen != sizeof(*arg)) {
619 arg = (struct ngm_ccatm_port *)msg->data;
620 NG_MKRESPONSE(resp, msg, sizeof(struct atm_port_info),
626 error = cc_port_get_param(priv->data, arg->port,
627 (struct atm_port_info *)resp->data);
629 free(resp, M_NETGRAPH_MSG);
635 case NGM_CCATM_SET_PORT_PARAM:
637 struct atm_port_info *arg;
639 if (msg->header.arglen != sizeof(*arg)) {
643 arg = (struct atm_port_info *)msg->data;
644 error = cc_port_set_param(priv->data, arg);
648 case NGM_CCATM_GET_PORTLIST:
650 struct ngm_ccatm_portlist *arg;
653 if (msg->header.arglen != 0) {
657 error = cc_port_getlist(priv->data, &n, &ports);
661 NG_MKRESPONSE(resp, msg, sizeof(*arg) +
662 n * sizeof(arg->ports[0]), M_NOWAIT);
664 free(ports, M_NG_CCATM);
668 arg = (struct ngm_ccatm_portlist *)resp->data;
671 for (arg->nports = 0; arg->nports < n; arg->nports++)
672 arg->ports[arg->nports] = ports[arg->nports];
673 free(ports, M_NG_CCATM);
677 case NGM_CCATM_SETLOG:
681 log_level = cc_get_log(priv->data);
682 if (msg->header.arglen != 0) {
683 if (msg->header.arglen != sizeof(log_level)) {
687 cc_set_log(priv->data, *(uint32_t *)msg->data);
690 NG_MKRESPONSE(resp, msg, sizeof(uint32_t), M_NOWAIT);
693 if (msg->header.arglen != 0)
694 cc_set_log(priv->data, log_level);
697 *(uint32_t *)resp->data = log_level;
701 case NGM_CCATM_RESET:
702 if (msg->header.arglen != 0) {
707 if (priv->hook_cnt != 0) {
711 cc_reset(priv->data);
714 case NGM_CCATM_GET_EXSTAT:
716 struct atm_exstatus s;
717 struct atm_exstatus_ep *eps;
718 struct atm_exstatus_port *ports;
719 struct atm_exstatus_conn *conns;
720 struct atm_exstatus_party *parties;
723 if (msg->header.arglen != 0) {
727 error = cc_get_extended_status(priv->data,
728 &s, &eps, &ports, &conns, &parties);
732 offs = sizeof(s) + s.neps * sizeof(*eps) +
733 s.nports * sizeof(*ports) +
734 s.nconns * sizeof(*conns) +
735 s.nparties * sizeof(*parties);
737 NG_MKRESPONSE(resp, msg, offs, M_NOWAIT);
743 memcpy(resp->data, &s, sizeof(s));
746 memcpy(resp->data + offs, eps,
747 sizeof(*eps) * s.neps);
748 offs += sizeof(*eps) * s.neps;
750 memcpy(resp->data + offs, ports,
751 sizeof(*ports) * s.nports);
752 offs += sizeof(*ports) * s.nports;
754 memcpy(resp->data + offs, conns,
755 sizeof(*conns) * s.nconns);
756 offs += sizeof(*conns) * s.nconns;
758 memcpy(resp->data + offs, parties,
759 sizeof(*parties) * s.nparties);
760 offs += sizeof(*parties) * s.nparties;
762 free(eps, M_NG_CCATM);
763 free(ports, M_NG_CCATM);
764 free(conns, M_NG_CCATM);
765 free(parties, M_NG_CCATM);
782 NG_RESPOND_MSG(error, node, item, resp);
787 /************************************************************
792 ng_ccatm_newhook(node_p node, hook_p hook, const char *name)
794 struct ccnode *priv = NG_NODE_PRIVATE(node);
801 if (strncmp(name, "uni", 3) == 0) {
803 * This is a UNI hook. Should be a new port.
807 lport = strtoul(name + 3, &end, 10);
808 if (*end != '\0' || lport == 0 || lport > 0xffffffff)
811 hd = malloc(sizeof(*hd), M_NG_CCATM, M_NOWAIT);
818 port = cc_port_create(priv->data, hd, (u_int)lport);
820 free(hd, M_NG_CCATM);
825 NG_HOOK_SET_PRIVATE(hook, hd);
826 NG_HOOK_SET_RCVDATA(hook, ng_ccatm_rcvuni);
827 NG_HOOK_FORCE_QUEUE(hook);
834 if (strcmp(name, "dump") == 0) {
836 NG_HOOK_SET_RCVDATA(hook, ng_ccatm_rcvdump);
840 if (strcmp(name, "manage") == 0) {
842 NG_HOOK_SET_RCVDATA(hook, ng_ccatm_rcvmanage);
849 hd = malloc(sizeof(*hd), M_NG_CCATM, M_NOWAIT);
856 user = cc_user_create(priv->data, hd, NG_HOOK_NAME(hook));
858 free(hd, M_NG_CCATM);
863 NG_HOOK_SET_PRIVATE(hook, hd);
864 NG_HOOK_FORCE_QUEUE(hook);
875 ng_ccatm_disconnect(hook_p hook)
877 node_p node = NG_HOOK_NODE(hook);
878 struct ccnode *priv = NG_NODE_PRIVATE(node);
879 struct cchook *hd = NG_HOOK_PRIVATE(hook);
882 if (hook == priv->dump) {
885 } else if (hook == priv->manage) {
887 cc_unmanage(priv->data);
891 cc_port_destroy(hd->inst, 0);
893 cc_user_destroy(hd->inst);
897 free(hd, M_NG_CCATM);
898 NG_HOOK_SET_PRIVATE(hook, NULL);
906 * When the number of hooks drops to zero, delete the node.
908 if (NG_NODE_NUMHOOKS(node) == 0 && NG_NODE_IS_VALID(node))
909 ng_rmnode_self(node);
914 /************************************************************
916 * Receive data from user hook
919 ng_ccatm_rcvdata(hook_p hook, item_p item)
921 struct cchook *hd = NG_HOOK_PRIVATE(hook);
930 if ((err = uni_msg_unpack_mbuf(m, &msg)) != 0) {
936 if (uni_msg_len(msg) < sizeof(op)) {
937 printf("%s: packet too short\n", __func__);
938 uni_msg_destroy(msg);
942 bcopy(msg->b_rptr, &op, sizeof(op));
943 msg->b_rptr += sizeof(op);
945 err = cc_user_signal(hd->inst, op.op, msg);
946 cc_work(hd->node->data);
951 * Pack a header and a data area into an mbuf chain
954 pack_buf(void *h, size_t hlen, void *t, size_t tlen)
956 struct mbuf *m, *m0, *last;
957 u_char *buf = (u_char *)t;
960 /* header should fit into a normal mbuf */
961 MGETHDR(m0, M_NOWAIT, MT_DATA);
965 KASSERT(hlen <= MHLEN, ("hlen > MHLEN"));
967 bcopy(h, m0->m_data, hlen);
969 m0->m_pkthdr.len = hlen;
972 while ((n = tlen) != 0) {
974 m = m_getcl(M_NOWAIT, MT_DATA, 0);
978 MGET(m, M_NOWAIT, MT_DATA);
986 bcopy(buf, m->m_data, n);
990 m0->m_pkthdr.len += n;
1001 * Send an indication to the user.
1004 ng_ccatm_send_user(struct ccuser *user, void *uarg, u_int op,
1005 void *val, size_t len)
1007 struct cchook *hd = uarg;
1013 m = pack_buf(&h, sizeof(h), val, len);
1017 NG_SEND_DATA_ONLY(error, hd->hook, m);
1019 printf("%s: error=%d\n", __func__, error);
1023 * Send a response to the user.
1026 ng_ccatm_respond_user(struct ccuser *user, void *uarg, int err, u_int data,
1027 void *val, size_t len)
1029 struct cchook *hd = uarg;
1033 struct atm_resp resp;
1037 resp.op.op = ATMOP_RESP;
1038 resp.resp.resp = err;
1039 resp.resp.data = data;
1040 m = pack_buf(&resp, sizeof(resp), val, len);
1044 NG_SEND_DATA_ONLY(error, hd->hook, m);
1046 printf("%s: error=%d\n", __func__, error);
1050 * Receive data from UNI.
1053 ng_ccatm_rcvuni(hook_p hook, item_p item)
1055 struct cchook *hd = NG_HOOK_PRIVATE(hook);
1056 struct uni_msg *msg;
1064 if ((err = uni_msg_unpack_mbuf(m, &msg)) != 0) {
1070 if (uni_msg_len(msg) < sizeof(arg)) {
1071 printf("%s: packet too short\n", __func__);
1072 uni_msg_destroy(msg);
1076 bcopy(msg->b_rptr, &arg, sizeof(arg));
1077 msg->b_rptr += sizeof(arg);
1079 if (arg.sig == UNIAPI_ERROR) {
1080 if (uni_msg_len(msg) != sizeof(struct uniapi_error)) {
1081 printf("%s: bad UNIAPI_ERROR size %zu\n", __func__,
1083 uni_msg_destroy(msg);
1086 err = cc_uni_response(hd->inst, arg.cookie,
1087 ((struct uniapi_error *)msg->b_rptr)->reason,
1088 ((struct uniapi_error *)msg->b_rptr)->state);
1089 uni_msg_destroy(msg);
1091 err = cc_uni_signal(hd->inst, arg.cookie, arg.sig, msg);
1093 cc_work(hd->node->data);
1098 * Uarg is the port's uarg.
1101 ng_ccatm_send_uni(struct ccconn *conn, void *uarg, u_int op, u_int cookie,
1102 struct uni_msg *msg)
1104 struct cchook *hd = uarg;
1110 arg.cookie = cookie;
1112 m = uni_msg_pack_mbuf(msg, &arg, sizeof(arg));
1113 uni_msg_destroy(msg);
1117 NG_SEND_DATA_ONLY(error, hd->hook, m);
1119 printf("%s: error=%d\n", __func__, error);
1123 * Send a global message to the UNI
1126 ng_ccatm_send_uni_glob(struct ccport *port, void *uarg, u_int op, u_int cookie,
1127 struct uni_msg *msg)
1129 struct cchook *hd = uarg;
1135 arg.cookie = cookie;
1137 m = uni_msg_pack_mbuf(msg, &arg, sizeof(arg));
1139 uni_msg_destroy(msg);
1143 NG_SEND_DATA_ONLY(error, hd->hook, m);
1145 printf("%s: error=%d\n", __func__, error);
1148 * Receive from ILMID
1151 ng_ccatm_rcvmanage(hook_p hook, item_p item)
1158 ng_ccatm_rcvdump(hook_p hook, item_p item)
1165 ng_ccatm_log(const char *fmt, ...)
1176 * Loading and unloading of node type
1179 ng_ccatm_mod_event(module_t mod, int event, void *data)