6 * Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * $Id: ng_h4.c,v 1.10 2005/10/31 17:57:43 max Exp $
31 * $FreeBSD: src/sys/netgraph/bluetooth/drivers/h4/ng_h4.c,v 1.17 2007/08/13 17:19:28 emax Exp $
32 * $DragonFly: src/sys/netgraph7/bluetooth/drivers/h4/ng_h4.c,v 1.2 2008/06/26 23:05:40 dillon Exp $
33 * $DragonFly: src/sys/netgraph7/bluetooth/drivers/h4/ng_h4.c,v 1.2 2008/06/26 23:05:40 dillon Exp $
38 * FreeBSD: src/sys/netgraph/ng_tty.c
39 * Author: Archie Cobbs <archie@freebsd.org>
43 #include <sys/param.h>
44 #include <sys/systm.h>
45 #include <sys/kernel.h>
47 #include <sys/endian.h>
48 #include <sys/errno.h>
49 #include <sys/fcntl.h>
50 #include <sys/ioccom.h>
51 #include <sys/malloc.h>
54 #include <sys/socket.h>
56 #include <sys/ttycom.h>
58 #include <net/if_var.h>
59 #include "ng_message.h"
62 #include "bluetooth/include/ng_bluetooth.h"
63 #include "bluetooth/include/ng_hci.h"
64 #include "bluetooth/include/ng_h4.h"
65 #include "bluetooth/drivers/h4/ng_h4_var.h"
66 #include "bluetooth/drivers/h4/ng_h4_prse.h"
68 /*****************************************************************************
69 *****************************************************************************
70 ** This node implements a Bluetooth HCI UART transport layer as per chapter
71 ** H4 of the Bluetooth Specification Book v1.1. It is a terminal line
72 ** discipline that is also a netgraph node. Installing this line discipline
73 ** on a terminal device instantiates a new netgraph node of this type, which
74 ** allows access to the device via the "hook" hook of the node.
76 ** Once the line discipline is installed, you can find out the name of the
77 ** corresponding netgraph node via a NGIOCGINFO ioctl().
78 *****************************************************************************
79 *****************************************************************************/
82 #ifndef NG_SEPARATE_MALLOC
83 MALLOC_DEFINE(M_NETGRAPH_H4, "netgraph_h4", "Netgraph Bluetooth H4 node");
85 #define M_NETGRAPH_H4 M_NETGRAPH
86 #endif /* NG_SEPARATE_MALLOC */
88 /* Line discipline methods */
89 static int ng_h4_open (struct cdev *, struct tty *);
90 static int ng_h4_close (struct tty *, int);
91 static int ng_h4_read (struct tty *, struct uio *, int);
92 static int ng_h4_write (struct tty *, struct uio *, int);
93 static int ng_h4_input (int, struct tty *);
94 static int ng_h4_start (struct tty *);
95 static int ng_h4_ioctl (struct tty *, u_long, caddr_t,
96 int, struct thread *);
98 /* Line discipline descriptor */
99 static struct linesw ng_h4_disc = {
100 ng_h4_open, /* open */
101 ng_h4_close, /* close */
102 ng_h4_read, /* read */
103 ng_h4_write, /* write */
104 ng_h4_ioctl, /* ioctl */
105 ng_h4_input, /* input */
106 ng_h4_start, /* start */
110 /* Netgraph methods */
111 static ng_constructor_t ng_h4_constructor;
112 static ng_rcvmsg_t ng_h4_rcvmsg;
113 static ng_shutdown_t ng_h4_shutdown;
114 static ng_newhook_t ng_h4_newhook;
115 static ng_connect_t ng_h4_connect;
116 static ng_rcvdata_t ng_h4_rcvdata;
117 static ng_disconnect_t ng_h4_disconnect;
120 static void ng_h4_process_timeout (node_p, hook_p, void *, int);
121 static int ng_h4_mod_event (module_t, int, void *);
123 /* Netgraph node type descriptor */
124 static struct ng_type typestruct = {
125 .version = NG_ABI_VERSION,
126 .name = NG_H4_NODE_TYPE,
127 .mod_event = ng_h4_mod_event,
128 .constructor = ng_h4_constructor,
129 .rcvmsg = ng_h4_rcvmsg,
130 .shutdown = ng_h4_shutdown,
131 .newhook = ng_h4_newhook,
132 .connect = ng_h4_connect,
133 .rcvdata = ng_h4_rcvdata,
134 .disconnect = ng_h4_disconnect,
135 .cmdlist = ng_h4_cmdlist
137 NETGRAPH_INIT(h4, &typestruct);
138 MODULE_VERSION(ng_h4, NG_BLUETOOTH_VERSION);
140 static int ng_h4_node = 0;
142 /*****************************************************************************
143 *****************************************************************************
144 ** Line discipline methods
145 *****************************************************************************
146 *****************************************************************************/
149 * Set our line discipline on the tty.
153 ng_h4_open(struct cdev *dev, struct tty *tp)
155 struct thread *td = curthread;
156 char name[NG_NODESIZ];
157 ng_h4_info_p sc = NULL;
160 /* Super-user only */
161 error = priv_check(td, PRIV_NETGRAPH_TTY); /* XXX */
165 /* Initialize private struct */
166 MALLOC(sc, ng_h4_info_p, sizeof(*sc), M_NETGRAPH_H4, M_WAITOK | M_NULLOK | M_ZERO);
171 sc->debug = NG_H4_WARN_LEVEL;
173 sc->state = NG_H4_W4_PKT_IND;
177 mtx_init(&sc->outq.ifq_mtx, "ng_h4 node+queue", NULL, MTX_DEF);
178 IFQ_SET_MAXLEN(&sc->outq, NG_H4_DEFAULTQLEN);
179 ng_callout_init(&sc->timo);
183 /* Setup netgraph node */
184 error = ng_make_node_common(&typestruct, &sc->node);
188 printf("%s: Unable to create new node!\n", __func__);
190 mtx_destroy(&sc->outq.ifq_mtx);
191 bzero(sc, sizeof(*sc));
192 FREE(sc, M_NETGRAPH_H4);
197 /* Assign node its name */
198 snprintf(name, sizeof(name), "%s%d", typestruct.name, ng_h4_node ++);
200 error = ng_name_node(sc->node, name);
204 printf("%s: %s - node name exists?\n", __func__, name);
206 NG_NODE_UNREF(sc->node);
207 mtx_destroy(&sc->outq.ifq_mtx);
208 bzero(sc, sizeof(*sc));
209 FREE(sc, M_NETGRAPH_H4);
214 /* Set back pointers */
215 NG_NODE_SET_PRIVATE(sc->node, sc);
216 tp->t_lsc = (caddr_t) sc;
218 /* The node has to be a WRITER because data can change node status */
219 NG_NODE_FORCE_WRITER(sc->node);
222 * Pre-allocate cblocks to the an appropriate amount.
223 * I'm not sure what is appropriate.
226 ttyflush(tp, FREAD | FWRITE);
227 clist_alloc_cblocks(&tp->t_canq, 0, 0);
228 clist_alloc_cblocks(&tp->t_rawq, 0, 0);
229 clist_alloc_cblocks(&tp->t_outq,
230 MLEN + NG_H4_HIWATER, MLEN + NG_H4_HIWATER);
238 * Line specific close routine, called from device close routine
239 * and from ttioctl. This causes the node to be destroyed as well.
243 ng_h4_close(struct tty *tp, int flag)
245 ng_h4_info_p sc = (ng_h4_info_p) tp->t_lsc;
247 ttyflush(tp, FREAD | FWRITE);
248 clist_free_cblocks(&tp->t_outq);
253 if (callout_pending(&sc->timo))
254 ng_uncallout(&sc->timo, sc->node);
261 ng_rmnode_self(sc->node);
268 * Once the device has been turned into a node, we don't allow reading.
272 ng_h4_read(struct tty *tp, struct uio *uio, int flag)
278 * Once the device has been turned into a node, we don't allow writing.
282 ng_h4_write(struct tty *tp, struct uio *uio, int flag)
288 * We implement the NGIOCGINFO ioctl() defined in ng_message.h.
292 ng_h4_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag,
295 ng_h4_info_p sc = (ng_h4_info_p) tp->t_lsc;
306 #define NI(x) ((struct nodeinfo *)(x))
308 bzero(data, sizeof(*NI(data)));
310 if (NG_NODE_HAS_NAME(sc->node))
311 strncpy(NI(data)->name, NG_NODE_NAME(sc->node),
312 sizeof(NI(data)->name) - 1);
314 strncpy(NI(data)->type, sc->node->nd_type->name,
315 sizeof(NI(data)->type) - 1);
317 NI(data)->id = (u_int32_t) ng_node2ID(sc->node);
318 NI(data)->hooks = NG_NODE_NUMHOOKS(sc->node);
332 * Receive data coming from the device. We get one character at a time, which
337 ng_h4_input(int c, struct tty *tp)
339 ng_h4_info_p sc = (ng_h4_info_p) tp->t_lsc;
341 if (sc == NULL || tp != sc->tp ||
342 sc->node == NULL || NG_NODE_NOT_VALID(sc->node))
347 /* Check for error conditions */
348 if ((tp->t_state & TS_CONNECTED) == 0) {
349 NG_H4_INFO("%s: %s - no carrier\n", __func__,
350 NG_NODE_NAME(sc->node));
352 sc->state = NG_H4_W4_PKT_IND;
358 return (0); /* XXX Loss of synchronization here! */
361 /* Check for framing error or overrun on this char */
362 if (c & TTY_ERRORMASK) {
363 NG_H4_ERR("%s: %s - line error %#x, c=%#x\n", __func__,
364 NG_NODE_NAME(sc->node), c & TTY_ERRORMASK,
367 NG_H4_STAT_IERROR(sc->stat);
369 sc->state = NG_H4_W4_PKT_IND;
375 return (0); /* XXX Loss of synchronization here! */
378 NG_H4_STAT_BYTES_RECV(sc->stat, 1);
380 /* Append char to mbuf */
381 if (sc->got >= sizeof(sc->ibuf)) {
382 NG_H4_ALERT("%s: %s - input buffer overflow, c=%#x, got=%d\n",
383 __func__, NG_NODE_NAME(sc->node), c & TTY_CHARMASK,
386 NG_H4_STAT_IERROR(sc->stat);
388 sc->state = NG_H4_W4_PKT_IND;
394 return (0); /* XXX Loss of synchronization here! */
397 sc->ibuf[sc->got ++] = (c & TTY_CHARMASK);
399 NG_H4_INFO("%s: %s - got char %#x, want=%d, got=%d\n", __func__,
400 NG_NODE_NAME(sc->node), c, sc->want, sc->got);
402 if (sc->got < sc->want) {
405 return (0); /* Wait for more */
409 /* Got packet indicator */
410 case NG_H4_W4_PKT_IND:
411 NG_H4_INFO("%s: %s - got packet indicator %#x\n", __func__,
412 NG_NODE_NAME(sc->node), sc->ibuf[0]);
414 sc->state = NG_H4_W4_PKT_HDR;
417 * Since packet indicator included in the packet header
418 * just set sc->want to sizeof(packet header).
421 switch (sc->ibuf[0]) {
422 case NG_HCI_ACL_DATA_PKT:
423 sc->want = sizeof(ng_hci_acldata_pkt_t);
426 case NG_HCI_SCO_DATA_PKT:
427 sc->want = sizeof(ng_hci_scodata_pkt_t);
430 case NG_HCI_EVENT_PKT:
431 sc->want = sizeof(ng_hci_event_pkt_t);
435 NG_H4_WARN("%s: %s - ignoring unknown packet " \
436 "type=%#x\n", __func__, NG_NODE_NAME(sc->node),
439 NG_H4_STAT_IERROR(sc->stat);
441 sc->state = NG_H4_W4_PKT_IND;
448 /* Got packet header */
449 case NG_H4_W4_PKT_HDR:
450 sc->state = NG_H4_W4_PKT_DATA;
452 switch (sc->ibuf[0]) {
453 case NG_HCI_ACL_DATA_PKT:
454 c = le16toh(((ng_hci_acldata_pkt_t *)
455 (sc->ibuf))->length);
458 case NG_HCI_SCO_DATA_PKT:
459 c = ((ng_hci_scodata_pkt_t *)(sc->ibuf))->length;
462 case NG_HCI_EVENT_PKT:
463 c = ((ng_hci_event_pkt_t *)(sc->ibuf))->length;
467 KASSERT((0), ("Invalid packet type=%#x\n",
472 NG_H4_INFO("%s: %s - got packet header, packet type=%#x, " \
473 "packet size=%d, payload size=%d\n", __func__,
474 NG_NODE_NAME(sc->node), sc->ibuf[0], sc->got, c);
480 * Try to prevent possible buffer overrun
482 * XXX I'm *really* confused here. It turns out
483 * that Xircom card sends us packets with length
484 * greater then 512 bytes! This is greater then
485 * our old receive buffer (ibuf) size. In the same
486 * time the card demands from us *not* to send
487 * packets greater then 192 bytes. Weird! How the
488 * hell i should know how big *receive* buffer
489 * should be? For now increase receiving buffer
490 * size to 1K and add the following check.
493 if (sc->want >= sizeof(sc->ibuf)) {
496 NG_H4_ALERT("%s: %s - packet too big for " \
497 "buffer, type=%#x, got=%d, want=%d, " \
498 "length=%d\n", __func__,
499 NG_NODE_NAME(sc->node), sc->ibuf[0],
500 sc->got, sc->want, c);
502 NG_H4_ALERT("Packet header:\n");
503 for (b = 0; b < sc->got; b++)
504 NG_H4_ALERT("%#x ", sc->ibuf[b]);
508 NG_H4_STAT_IERROR(sc->stat);
510 sc->state = NG_H4_W4_PKT_IND;
518 /* else FALLTHROUGH and deliver frame */
519 /* XXX Is this true? Should we deliver empty frame? */
521 /* Got packet data */
522 case NG_H4_W4_PKT_DATA:
523 NG_H4_INFO("%s: %s - got full packet, packet type=%#x, " \
524 "packet size=%d\n", __func__,
525 NG_NODE_NAME(sc->node), sc->ibuf[0], sc->got);
527 if (sc->hook != NULL && NG_HOOK_IS_VALID(sc->hook)) {
528 struct mbuf *m = NULL;
530 MGETHDR(m, MB_DONTWAIT, MT_DATA);
534 /* XXX m_copyback() is stupid */
535 m->m_len = min(MHLEN, sc->got);
537 m_copyback(m, 0, sc->got, sc->ibuf);
538 NG_SEND_DATA_ONLY(c, sc->hook, m);
540 NG_H4_ERR("%s: %s - could not get mbuf\n",
541 __func__, NG_NODE_NAME(sc->node));
543 NG_H4_STAT_IERROR(sc->stat);
547 sc->state = NG_H4_W4_PKT_IND;
551 NG_H4_STAT_PCKTS_RECV(sc->stat);
555 KASSERT((0), ("Invalid H4 node state=%d", sc->state));
565 * This is called when the device driver is ready for more output. Called from
570 ng_h4_start(struct tty *tp)
572 ng_h4_info_p sc = (ng_h4_info_p) tp->t_lsc;
573 struct mbuf *m = NULL;
576 if (sc == NULL || tp != sc->tp ||
577 sc->node == NULL || NG_NODE_NOT_VALID(sc->node))
581 while (tp->t_outq.c_cc < NG_H4_HIWATER) { /* XXX 2.2 specific ? */
585 /* Remove first mbuf from queue */
586 IF_DEQUEUE(&sc->outq, m);
590 /* Send as much of it as possible */
592 size = m->m_len - b_to_q(mtod(m, u_char *),
593 m->m_len, &tp->t_outq);
596 NG_H4_STAT_BYTES_SENT(sc->stat, size);
602 break; /* device can't take no more */
607 /* Put remainder of mbuf chain (if any) back on queue */
609 IF_PREPEND(&sc->outq, m);
613 /* Full packet has been sent */
615 NG_H4_STAT_PCKTS_SENT(sc->stat);
620 * Call output process whether or not there is any output. We are
621 * being called in lieu of ttstart and must do what it would.
627 * This timeout is needed for operation on a pseudo-tty, because the
628 * pty code doesn't call pppstart after it has drained the t_outq.
633 if (!IFQ_IS_EMPTY(&sc->outq) && !callout_pending(&sc->timo))
634 ng_callout(&sc->timo, sc->node, NULL, 1,
635 ng_h4_process_timeout, NULL, 0);
642 /*****************************************************************************
643 *****************************************************************************
644 ** Netgraph node methods
645 *****************************************************************************
646 *****************************************************************************/
649 * Initialize a new node of this type. We only allow nodes to be created as
650 * a result of setting the line discipline on a tty, so always return an error
655 ng_h4_constructor(node_p node)
658 } /* ng_h4_constructor */
661 * Add a new hook. There can only be one.
665 ng_h4_newhook(node_p node, hook_p hook, const char *name)
667 ng_h4_info_p sc = (ng_h4_info_p) NG_NODE_PRIVATE(node);
669 if (strcmp(name, NG_H4_HOOK) != 0)
674 if (sc->hook != NULL) {
683 } /* ng_h4_newhook */
686 * Connect hook. Just say yes.
690 ng_h4_connect(hook_p hook)
692 ng_h4_info_p sc = (ng_h4_info_p) NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
694 if (hook != sc->hook)
695 panic("%s: hook != sc->hook\n", __func__);
697 NG_HOOK_FORCE_QUEUE(NG_HOOK_PEER(hook));
698 NG_HOOK_FORCE_QUEUE(hook);
701 } /* ng_h4_connect */
704 * Disconnect the hook
708 ng_h4_disconnect(hook_p hook)
710 ng_h4_info_p sc = (ng_h4_info_p) NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
713 * We need to check for sc != NULL because we can be called from
714 * ng_h4_close() via ng_rmnode_self()
718 if (hook != sc->hook)
719 panic("%s: hook != sc->hook\n", __func__);
723 /* XXX do we have to untimeout and drain out queue? */
724 if (callout_pending(&sc->timo))
725 ng_uncallout(&sc->timo, sc->node);
727 _IF_DRAIN(&sc->outq);
729 sc->state = NG_H4_W4_PKT_IND;
739 } /* ng_h4_disconnect */
742 * Remove this node. The does the netgraph portion of the shutdown.
743 * This should only be called indirectly from ng_h4_close().
747 ng_h4_shutdown(node_p node)
749 ng_h4_info_p sc = (ng_h4_info_p) NG_NODE_PRIVATE(node);
756 NG_NODE_REVIVE(node); /* we will persist */
763 NG_NODE_SET_PRIVATE(node, NULL);
765 _IF_DRAIN(&sc->outq);
768 mtx_destroy(&sc->outq.ifq_mtx);
769 bzero(sc, sizeof(*sc));
770 FREE(sc, M_NETGRAPH_H4);
773 } /* ng_h4_shutdown */
776 * Receive incoming data from Netgraph system. Put it on our
777 * output queue and start output if necessary.
781 ng_h4_rcvdata(hook_p hook, item_p item)
783 ng_h4_info_p sc = (ng_h4_info_p)NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
784 struct mbuf *m = NULL;
790 if (hook != sc->hook)
791 panic("%s: hook != sc->hook\n", __func__);
798 if (_IF_QFULL(&sc->outq)) {
799 NG_H4_ERR("%s: %s - dropping mbuf, len=%d\n", __func__,
800 NG_NODE_NAME(sc->node), m->m_pkthdr.len);
802 NG_H4_STAT_OERROR(sc->stat);
812 NG_H4_INFO("%s: %s - queue mbuf, len=%d\n", __func__,
813 NG_NODE_NAME(sc->node), m->m_pkthdr.len);
815 _IF_ENQUEUE(&sc->outq, m);
816 qlen = _IF_QLEN(&sc->outq);
821 * If qlen > 1, then we should already have a scheduled callout
831 } /* ng_h4_rcvdata */
834 * Receive control message
838 ng_h4_rcvmsg(node_p node, item_p item, hook_p lasthook)
840 ng_h4_info_p sc = (ng_h4_info_p) NG_NODE_PRIVATE(node);
841 struct ng_mesg *msg = NULL, *resp = NULL;
847 NGI_GET_MSG(item, msg);
850 switch (msg->header.typecookie) {
851 case NGM_GENERIC_COOKIE:
852 switch (msg->header.cmd) {
853 case NGM_TEXT_STATUS:
854 NG_MKRESPONSE(resp, msg, NG_TEXTRESPONSE, M_WAITOK | M_NULLOK);
858 snprintf(resp->data, NG_TEXTRESPONSE,
862 "Queue: [have:%d,max:%d]\n" \
863 "Input: [got:%d,want:%d]",
864 (sc->hook != NULL)? NG_H4_HOOK : "",
880 switch (msg->header.cmd) {
881 case NGM_H4_NODE_RESET:
882 _IF_DRAIN(&sc->outq);
883 sc->state = NG_H4_W4_PKT_IND;
888 case NGM_H4_NODE_GET_STATE:
889 NG_MKRESPONSE(resp, msg, sizeof(ng_h4_node_state_ep),
890 M_WAITOK | M_NULLOK);
894 *((ng_h4_node_state_ep *)(resp->data)) =
898 case NGM_H4_NODE_GET_DEBUG:
899 NG_MKRESPONSE(resp, msg, sizeof(ng_h4_node_debug_ep),
900 M_WAITOK | M_NULLOK);
904 *((ng_h4_node_debug_ep *)(resp->data)) =
908 case NGM_H4_NODE_SET_DEBUG:
909 if (msg->header.arglen != sizeof(ng_h4_node_debug_ep))
913 *((ng_h4_node_debug_ep *)(msg->data));
916 case NGM_H4_NODE_GET_QLEN:
917 NG_MKRESPONSE(resp, msg, sizeof(ng_h4_node_qlen_ep),
918 M_WAITOK | M_NULLOK);
922 *((ng_h4_node_qlen_ep *)(resp->data)) =
926 case NGM_H4_NODE_SET_QLEN:
927 if (msg->header.arglen != sizeof(ng_h4_node_qlen_ep))
929 else if (*((ng_h4_node_qlen_ep *)(msg->data)) <= 0)
932 IFQ_SET_MAXLEN(&sc->outq,
933 *((ng_h4_node_qlen_ep *)(msg->data)));
936 case NGM_H4_NODE_GET_STAT:
937 NG_MKRESPONSE(resp, msg, sizeof(ng_h4_node_stat_ep),
938 M_WAITOK | M_NULLOK);
942 bcopy(&sc->stat, resp->data,
943 sizeof(ng_h4_node_stat_ep));
946 case NGM_H4_NODE_RESET_STAT:
947 NG_H4_STAT_RESET(sc->stat);
963 NG_RESPOND_MSG(error, node, item, resp);
970 * Timeout processing function.
971 * We still have data to output to the device, so try sending more.
975 ng_h4_process_timeout(node_p node, hook_p hook, void *arg1, int arg2)
977 ng_h4_info_p sc = (ng_h4_info_p) NG_NODE_PRIVATE(node);
982 } /* ng_h4_process_timeout */
985 * Handle loading and unloading for this node type
989 ng_h4_mod_event(module_t mod, int event, void *data)
991 static int ng_h4_ldisc;
996 /* Register line discipline */
998 ng_h4_ldisc = ldisc_register(H4DISC, &ng_h4_disc);
1001 if (ng_h4_ldisc < 0) {
1002 printf("%s: can't register H4 line discipline\n",
1009 /* Unregister line discipline */
1011 ldisc_deregister(ng_h4_ldisc);
1021 } /* ng_h4_mod_event */