4 * 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 $
36 * FreeBSD: src/sys/netgraph/ng_tty.c
37 * Author: Archie Cobbs <archie@freebsd.org>
41 #include <sys/param.h>
42 #include <sys/systm.h>
43 #include <sys/kernel.h>
45 #include <sys/endian.h>
46 #include <sys/errno.h>
47 #include <sys/fcntl.h>
48 #include <sys/malloc.h>
51 #include <sys/socket.h>
53 #include <sys/ttycom.h>
55 #include <net/if_var.h>
56 #include "ng_message.h"
59 #include "bluetooth/include/ng_bluetooth.h"
60 #include "bluetooth/include/ng_hci.h"
61 #include "bluetooth/include/ng_h4.h"
62 #include "bluetooth/drivers/h4/ng_h4_var.h"
63 #include "bluetooth/drivers/h4/ng_h4_prse.h"
65 /*****************************************************************************
66 *****************************************************************************
67 ** This node implements a Bluetooth HCI UART transport layer as per chapter
68 ** H4 of the Bluetooth Specification Book v1.1. It is a terminal line
69 ** discipline that is also a netgraph node. Installing this line discipline
70 ** on a terminal device instantiates a new netgraph node of this type, which
71 ** allows access to the device via the "hook" hook of the node.
73 ** Once the line discipline is installed, you can find out the name of the
74 ** corresponding netgraph node via a NGIOCGINFO ioctl().
75 *****************************************************************************
76 *****************************************************************************/
79 #ifndef NG_SEPARATE_MALLOC
80 MALLOC_DEFINE(M_NETGRAPH_H4, "netgraph_h4", "Netgraph Bluetooth H4 node");
82 #define M_NETGRAPH_H4 M_NETGRAPH
83 #endif /* NG_SEPARATE_MALLOC */
85 /* Line discipline methods */
86 static int ng_h4_open (struct cdev *, struct tty *);
87 static int ng_h4_close (struct tty *, int);
88 static int ng_h4_read (struct tty *, struct uio *, int);
89 static int ng_h4_write (struct tty *, struct uio *, int);
90 static int ng_h4_input (int, struct tty *);
91 static int ng_h4_start (struct tty *);
92 static int ng_h4_ioctl (struct tty *, u_long, caddr_t,
93 int, struct thread *);
95 /* Line discipline descriptor */
96 static struct linesw ng_h4_disc = {
97 ng_h4_open, /* open */
98 ng_h4_close, /* close */
99 ng_h4_read, /* read */
100 ng_h4_write, /* write */
101 ng_h4_ioctl, /* ioctl */
102 ng_h4_input, /* input */
103 ng_h4_start, /* start */
107 /* Netgraph methods */
108 static ng_constructor_t ng_h4_constructor;
109 static ng_rcvmsg_t ng_h4_rcvmsg;
110 static ng_shutdown_t ng_h4_shutdown;
111 static ng_newhook_t ng_h4_newhook;
112 static ng_connect_t ng_h4_connect;
113 static ng_rcvdata_t ng_h4_rcvdata;
114 static ng_disconnect_t ng_h4_disconnect;
117 static void ng_h4_process_timeout (node_p, hook_p, void *, int);
118 static int ng_h4_mod_event (module_t, int, void *);
120 /* Netgraph node type descriptor */
121 static struct ng_type typestruct = {
122 .version = NG_ABI_VERSION,
123 .name = NG_H4_NODE_TYPE,
124 .mod_event = ng_h4_mod_event,
125 .constructor = ng_h4_constructor,
126 .rcvmsg = ng_h4_rcvmsg,
127 .shutdown = ng_h4_shutdown,
128 .newhook = ng_h4_newhook,
129 .connect = ng_h4_connect,
130 .rcvdata = ng_h4_rcvdata,
131 .disconnect = ng_h4_disconnect,
132 .cmdlist = ng_h4_cmdlist
134 NETGRAPH_INIT(h4, &typestruct);
135 MODULE_VERSION(ng_h4, NG_BLUETOOTH_VERSION);
137 static int ng_h4_node = 0;
139 /*****************************************************************************
140 *****************************************************************************
141 ** Line discipline methods
142 *****************************************************************************
143 *****************************************************************************/
146 * Set our line discipline on the tty.
150 ng_h4_open(struct cdev *dev, struct tty *tp)
152 struct thread *td = curthread;
153 char name[NG_NODESIZ];
154 ng_h4_info_p sc = NULL;
157 /* Super-user only */
158 error = priv_check(td, PRIV_NETGRAPH_TTY); /* XXX */
162 /* Initialize private struct */
163 sc = kmalloc(sizeof(*sc), M_NETGRAPH_H4, M_WAITOK | M_NULLOK | M_ZERO);
167 lwkt_gettoken(&tty_token);
169 sc->debug = NG_H4_WARN_LEVEL;
171 sc->state = NG_H4_W4_PKT_IND;
175 mtx_init(&sc->outq.ifq_mtx, "ng_h4 node+queue", NULL, MTX_DEF);
176 IFQ_SET_MAXLEN(&sc->outq, NG_H4_DEFAULTQLEN);
177 ng_callout_init(&sc->timo);
181 /* Setup netgraph node */
182 error = ng_make_node_common(&typestruct, &sc->node);
186 kprintf("%s: Unable to create new node!\n", __func__);
188 mtx_destroy(&sc->outq.ifq_mtx);
189 bzero(sc, sizeof(*sc));
190 kfree(sc, M_NETGRAPH_H4);
192 lwkt_reltoken(&tty_token);
196 /* Assign node its name */
197 ksnprintf(name, sizeof(name), "%s%d", typestruct.name, ng_h4_node ++);
199 error = ng_name_node(sc->node, name);
203 kprintf("%s: %s - node name exists?\n", __func__, name);
205 NG_NODE_UNREF(sc->node);
206 mtx_destroy(&sc->outq.ifq_mtx);
207 bzero(sc, sizeof(*sc));
208 kfree(sc, M_NETGRAPH_H4);
210 lwkt_reltoken(&tty_token);
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);
234 lwkt_reltoken(&tty_token);
239 * Line specific close routine, called from device close routine
240 * and from ttioctl. This causes the node to be destroyed as well.
244 ng_h4_close(struct tty *tp, int flag)
246 ng_h4_info_p sc = (ng_h4_info_p) tp->t_lsc;
248 lwkt_gettoken(&tty_token);
249 ttyflush(tp, FREAD | FWRITE);
250 clist_free_cblocks(&tp->t_outq);
255 if (callout_pending(&sc->timo))
256 ng_uncallout(&sc->timo, sc->node);
263 ng_rmnode_self(sc->node);
266 lwkt_reltoken(&tty_token);
271 * Once the device has been turned into a node, we don't allow reading.
275 ng_h4_read(struct tty *tp, struct uio *uio, int flag)
281 * Once the device has been turned into a node, we don't allow writing.
285 ng_h4_write(struct tty *tp, struct uio *uio, int flag)
291 * We implement the NGIOCGINFO ioctl() defined in ng_message.h.
295 ng_h4_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag,
298 ng_h4_info_p sc = (ng_h4_info_p) tp->t_lsc;
304 lwkt_gettoken(&tty_token);
310 #define NI(x) ((struct nodeinfo *)(x))
312 bzero(data, sizeof(*NI(data)));
314 if (NG_NODE_HAS_NAME(sc->node))
315 strncpy(NI(data)->name, NG_NODE_NAME(sc->node),
316 sizeof(NI(data)->name) - 1);
318 strncpy(NI(data)->type, sc->node->nd_type->name,
319 sizeof(NI(data)->type) - 1);
321 NI(data)->id = (u_int32_t) ng_node2ID(sc->node);
322 NI(data)->hooks = NG_NODE_NUMHOOKS(sc->node);
332 lwkt_reltoken(&tty_token);
337 * Receive data coming from the device. We get one character at a time, which
342 ng_h4_input(int c, struct tty *tp)
344 ng_h4_info_p sc = (ng_h4_info_p) tp->t_lsc;
346 lwkt_gettoken(&tty_token);
347 if (sc == NULL || tp != sc->tp ||
348 sc->node == NULL || NG_NODE_NOT_VALID(sc->node)) {
349 lwkt_reltoken(&tty_token);
355 /* Check for error conditions */
356 if ((tp->t_state & TS_CONNECTED) == 0) {
357 NG_H4_INFO("%s: %s - no carrier\n", __func__,
358 NG_NODE_NAME(sc->node));
360 sc->state = NG_H4_W4_PKT_IND;
366 lwkt_reltoken(&tty_token);
367 return (0); /* XXX Loss of synchronization here! */
370 /* Check for framing error or overrun on this char */
371 if (c & TTY_ERRORMASK) {
372 NG_H4_ERR("%s: %s - line error %#x, c=%#x\n", __func__,
373 NG_NODE_NAME(sc->node), c & TTY_ERRORMASK,
376 NG_H4_STAT_IERROR(sc->stat);
378 sc->state = NG_H4_W4_PKT_IND;
384 lwkt_reltoken(&tty_token);
385 return (0); /* XXX Loss of synchronization here! */
388 NG_H4_STAT_BYTES_RECV(sc->stat, 1);
390 /* Append char to mbuf */
391 if (sc->got >= sizeof(sc->ibuf)) {
392 NG_H4_ALERT("%s: %s - input buffer overflow, c=%#x, got=%d\n",
393 __func__, NG_NODE_NAME(sc->node), c & TTY_CHARMASK,
396 NG_H4_STAT_IERROR(sc->stat);
398 sc->state = NG_H4_W4_PKT_IND;
404 lwkt_reltoken(&tty_token);
405 return (0); /* XXX Loss of synchronization here! */
408 sc->ibuf[sc->got ++] = (c & TTY_CHARMASK);
410 NG_H4_INFO("%s: %s - got char %#x, want=%d, got=%d\n", __func__,
411 NG_NODE_NAME(sc->node), c, sc->want, sc->got);
413 if (sc->got < sc->want) {
416 lwkt_reltoken(&tty_token);
417 return (0); /* Wait for more */
421 /* Got packet indicator */
422 case NG_H4_W4_PKT_IND:
423 NG_H4_INFO("%s: %s - got packet indicator %#x\n", __func__,
424 NG_NODE_NAME(sc->node), sc->ibuf[0]);
426 sc->state = NG_H4_W4_PKT_HDR;
429 * Since packet indicator included in the packet header
430 * just set sc->want to sizeof(packet header).
433 switch (sc->ibuf[0]) {
434 case NG_HCI_ACL_DATA_PKT:
435 sc->want = sizeof(ng_hci_acldata_pkt_t);
438 case NG_HCI_SCO_DATA_PKT:
439 sc->want = sizeof(ng_hci_scodata_pkt_t);
442 case NG_HCI_EVENT_PKT:
443 sc->want = sizeof(ng_hci_event_pkt_t);
447 NG_H4_WARN("%s: %s - ignoring unknown packet " \
448 "type=%#x\n", __func__, NG_NODE_NAME(sc->node),
451 NG_H4_STAT_IERROR(sc->stat);
453 sc->state = NG_H4_W4_PKT_IND;
460 /* Got packet header */
461 case NG_H4_W4_PKT_HDR:
462 sc->state = NG_H4_W4_PKT_DATA;
464 switch (sc->ibuf[0]) {
465 case NG_HCI_ACL_DATA_PKT:
466 c = le16toh(((ng_hci_acldata_pkt_t *)
467 (sc->ibuf))->length);
470 case NG_HCI_SCO_DATA_PKT:
471 c = ((ng_hci_scodata_pkt_t *)(sc->ibuf))->length;
474 case NG_HCI_EVENT_PKT:
475 c = ((ng_hci_event_pkt_t *)(sc->ibuf))->length;
479 KASSERT((0), ("Invalid packet type=%#x",
484 NG_H4_INFO("%s: %s - got packet header, packet type=%#x, " \
485 "packet size=%d, payload size=%d\n", __func__,
486 NG_NODE_NAME(sc->node), sc->ibuf[0], sc->got, c);
492 * Try to prevent possible buffer overrun
494 * XXX I'm *really* confused here. It turns out
495 * that Xircom card sends us packets with length
496 * greater then 512 bytes! This is greater then
497 * our old receive buffer (ibuf) size. In the same
498 * time the card demands from us *not* to send
499 * packets greater then 192 bytes. Weird! How the
500 * hell i should know how big *receive* buffer
501 * should be? For now increase receiving buffer
502 * size to 1K and add the following check.
505 if (sc->want >= sizeof(sc->ibuf)) {
508 NG_H4_ALERT("%s: %s - packet too big for " \
509 "buffer, type=%#x, got=%d, want=%d, " \
510 "length=%d\n", __func__,
511 NG_NODE_NAME(sc->node), sc->ibuf[0],
512 sc->got, sc->want, c);
514 NG_H4_ALERT("Packet header:\n");
515 for (b = 0; b < sc->got; b++)
516 NG_H4_ALERT("%#x ", sc->ibuf[b]);
520 NG_H4_STAT_IERROR(sc->stat);
522 sc->state = NG_H4_W4_PKT_IND;
530 /* else FALLTHROUGH and deliver frame */
531 /* XXX Is this true? Should we deliver empty frame? */
533 /* Got packet data */
534 case NG_H4_W4_PKT_DATA:
535 NG_H4_INFO("%s: %s - got full packet, packet type=%#x, " \
536 "packet size=%d\n", __func__,
537 NG_NODE_NAME(sc->node), sc->ibuf[0], sc->got);
539 if (sc->hook != NULL && NG_HOOK_IS_VALID(sc->hook)) {
540 struct mbuf *m = NULL;
542 MGETHDR(m, MB_DONTWAIT, MT_DATA);
546 /* XXX m_copyback() is stupid */
547 m->m_len = min(MHLEN, sc->got);
549 m_copyback(m, 0, sc->got, sc->ibuf);
550 NG_SEND_DATA_ONLY(c, sc->hook, m);
552 NG_H4_ERR("%s: %s - could not get mbuf\n",
553 __func__, NG_NODE_NAME(sc->node));
555 NG_H4_STAT_IERROR(sc->stat);
559 sc->state = NG_H4_W4_PKT_IND;
563 NG_H4_STAT_PCKTS_RECV(sc->stat);
567 KASSERT((0), ("Invalid H4 node state=%d", sc->state));
573 lwkt_reltoken(&tty_token);
578 * This is called when the device driver is ready for more output. Called from
583 ng_h4_start(struct tty *tp)
585 ng_h4_info_p sc = (ng_h4_info_p) tp->t_lsc;
586 struct mbuf *m = NULL;
589 lwkt_gettoken(&tty_token);
590 if (sc == NULL || tp != sc->tp ||
591 sc->node == NULL || NG_NODE_NOT_VALID(sc->node)) {
592 lwkt_reltoken(&tty_token);
597 while (tp->t_outq.c_cc < NG_H4_HIWATER) { /* XXX 2.2 specific ? */
601 /* Remove first mbuf from queue */
602 IF_DEQUEUE(&sc->outq, m);
606 /* Send as much of it as possible */
608 size = m->m_len - b_to_q(mtod(m, u_char *),
609 m->m_len, &tp->t_outq);
612 NG_H4_STAT_BYTES_SENT(sc->stat, size);
618 break; /* device can't take no more */
623 /* Put remainder of mbuf chain (if any) back on queue */
625 IF_PREPEND(&sc->outq, m);
629 /* Full packet has been sent */
631 NG_H4_STAT_PCKTS_SENT(sc->stat);
636 * Call output process whether or not there is any output. We are
637 * being called in lieu of ttstart and must do what it would.
643 * This timeout is needed for operation on a pseudo-tty, because the
644 * pty code doesn't call pppstart after it has drained the t_outq.
649 if (!IFQ_IS_EMPTY(&sc->outq) && !callout_pending(&sc->timo))
650 ng_callout(&sc->timo, sc->node, NULL, 1,
651 ng_h4_process_timeout, NULL, 0);
655 lwkt_reltoken(&tty_token);
659 /*****************************************************************************
660 *****************************************************************************
661 ** Netgraph node methods
662 *****************************************************************************
663 *****************************************************************************/
666 * Initialize a new node of this type. We only allow nodes to be created as
667 * a result of setting the line discipline on a tty, so always return an error
672 ng_h4_constructor(node_p node)
675 } /* ng_h4_constructor */
678 * Add a new hook. There can only be one.
682 ng_h4_newhook(node_p node, hook_p hook, const char *name)
684 ng_h4_info_p sc = (ng_h4_info_p) NG_NODE_PRIVATE(node);
686 if (strcmp(name, NG_H4_HOOK) != 0)
691 if (sc->hook != NULL) {
700 } /* ng_h4_newhook */
703 * Connect hook. Just say yes.
707 ng_h4_connect(hook_p hook)
709 ng_h4_info_p sc = (ng_h4_info_p) NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
711 if (hook != sc->hook)
712 panic("%s: hook != sc->hook", __func__);
714 NG_HOOK_FORCE_QUEUE(NG_HOOK_PEER(hook));
715 NG_HOOK_FORCE_QUEUE(hook);
718 } /* ng_h4_connect */
721 * Disconnect the hook
725 ng_h4_disconnect(hook_p hook)
727 ng_h4_info_p sc = (ng_h4_info_p) NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
730 * We need to check for sc != NULL because we can be called from
731 * ng_h4_close() via ng_rmnode_self()
735 if (hook != sc->hook)
736 panic("%s: hook != sc->hook", __func__);
740 /* XXX do we have to untimeout and drain out queue? */
741 if (callout_pending(&sc->timo))
742 ng_uncallout(&sc->timo, sc->node);
744 _IF_DRAIN(&sc->outq);
746 sc->state = NG_H4_W4_PKT_IND;
756 } /* ng_h4_disconnect */
759 * Remove this node. The does the netgraph portion of the shutdown.
760 * This should only be called indirectly from ng_h4_close().
764 ng_h4_shutdown(node_p node)
766 ng_h4_info_p sc = (ng_h4_info_p) NG_NODE_PRIVATE(node);
773 NG_NODE_REVIVE(node); /* we will persist */
780 NG_NODE_SET_PRIVATE(node, NULL);
782 _IF_DRAIN(&sc->outq);
785 mtx_destroy(&sc->outq.ifq_mtx);
786 bzero(sc, sizeof(*sc));
787 kfree(sc, M_NETGRAPH_H4);
790 } /* ng_h4_shutdown */
793 * Receive incoming data from Netgraph system. Put it on our
794 * output queue and start output if necessary.
798 ng_h4_rcvdata(hook_p hook, item_p item)
800 ng_h4_info_p sc = (ng_h4_info_p)NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
801 struct mbuf *m = NULL;
807 if (hook != sc->hook)
808 panic("%s: hook != sc->hook", __func__);
815 if (_IF_QFULL(&sc->outq)) {
816 NG_H4_ERR("%s: %s - dropping mbuf, len=%d\n", __func__,
817 NG_NODE_NAME(sc->node), m->m_pkthdr.len);
819 NG_H4_STAT_OERROR(sc->stat);
829 NG_H4_INFO("%s: %s - queue mbuf, len=%d\n", __func__,
830 NG_NODE_NAME(sc->node), m->m_pkthdr.len);
832 _IF_ENQUEUE(&sc->outq, m);
833 qlen = _IF_QLEN(&sc->outq);
838 * If qlen > 1, then we should already have a scheduled callout
848 } /* ng_h4_rcvdata */
851 * Receive control message
855 ng_h4_rcvmsg(node_p node, item_p item, hook_p lasthook)
857 ng_h4_info_p sc = (ng_h4_info_p) NG_NODE_PRIVATE(node);
858 struct ng_mesg *msg = NULL, *resp = NULL;
864 NGI_GET_MSG(item, msg);
867 switch (msg->header.typecookie) {
868 case NGM_GENERIC_COOKIE:
869 switch (msg->header.cmd) {
870 case NGM_TEXT_STATUS:
871 NG_MKRESPONSE(resp, msg, NG_TEXTRESPONSE, M_WAITOK | M_NULLOK);
875 ksnprintf(resp->data, NG_TEXTRESPONSE,
879 "Queue: [have:%d,max:%d]\n" \
880 "Input: [got:%d,want:%d]",
881 (sc->hook != NULL)? NG_H4_HOOK : "",
897 switch (msg->header.cmd) {
898 case NGM_H4_NODE_RESET:
899 _IF_DRAIN(&sc->outq);
900 sc->state = NG_H4_W4_PKT_IND;
905 case NGM_H4_NODE_GET_STATE:
906 NG_MKRESPONSE(resp, msg, sizeof(ng_h4_node_state_ep),
907 M_WAITOK | M_NULLOK);
911 *((ng_h4_node_state_ep *)(resp->data)) =
915 case NGM_H4_NODE_GET_DEBUG:
916 NG_MKRESPONSE(resp, msg, sizeof(ng_h4_node_debug_ep),
917 M_WAITOK | M_NULLOK);
921 *((ng_h4_node_debug_ep *)(resp->data)) =
925 case NGM_H4_NODE_SET_DEBUG:
926 if (msg->header.arglen != sizeof(ng_h4_node_debug_ep))
930 *((ng_h4_node_debug_ep *)(msg->data));
933 case NGM_H4_NODE_GET_QLEN:
934 NG_MKRESPONSE(resp, msg, sizeof(ng_h4_node_qlen_ep),
935 M_WAITOK | M_NULLOK);
939 *((ng_h4_node_qlen_ep *)(resp->data)) =
943 case NGM_H4_NODE_SET_QLEN:
944 if (msg->header.arglen != sizeof(ng_h4_node_qlen_ep))
946 else if (*((ng_h4_node_qlen_ep *)(msg->data)) <= 0)
949 IFQ_SET_MAXLEN(&sc->outq,
950 *((ng_h4_node_qlen_ep *)(msg->data)));
953 case NGM_H4_NODE_GET_STAT:
954 NG_MKRESPONSE(resp, msg, sizeof(ng_h4_node_stat_ep),
955 M_WAITOK | M_NULLOK);
959 bcopy(&sc->stat, resp->data,
960 sizeof(ng_h4_node_stat_ep));
963 case NGM_H4_NODE_RESET_STAT:
964 NG_H4_STAT_RESET(sc->stat);
980 NG_RESPOND_MSG(error, node, item, resp);
987 * Timeout processing function.
988 * We still have data to output to the device, so try sending more.
992 ng_h4_process_timeout(node_p node, hook_p hook, void *arg1, int arg2)
994 ng_h4_info_p sc = (ng_h4_info_p) NG_NODE_PRIVATE(node);
999 } /* ng_h4_process_timeout */
1002 * Handle loading and unloading for this node type
1006 ng_h4_mod_event(module_t mod, int event, void *data)
1008 static int ng_h4_ldisc;
1013 /* Register line discipline */
1015 ng_h4_ldisc = ldisc_register(H4DISC, &ng_h4_disc);
1018 if (ng_h4_ldisc < 0) {
1019 kprintf("%s: can't register H4 line discipline\n",
1026 /* Unregister line discipline */
1028 ldisc_deregister(ng_h4_ldisc);
1038 } /* ng_h4_mod_event */