FreeBSD kernel netgraph code
ng_l2cap_main.c
Go to the documentation of this file.
1/*
2 * ng_l2cap_main.c
3 */
4
5/*-
6 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
7 *
8 * Copyright (c) Maksim Yevmenkin <m_evmenkin@yahoo.com>
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * $Id: ng_l2cap_main.c,v 1.2 2003/04/28 21:44:59 max Exp $
33 * $FreeBSD$
34 */
35
36#include <sys/param.h>
37#include <sys/systm.h>
38#include <sys/kernel.h>
39#include <sys/malloc.h>
40#include <sys/mbuf.h>
41#include <sys/queue.h>
42#include <netgraph/ng_message.h>
43#include <netgraph/netgraph.h>
44#include <netgraph/ng_parse.h>
55
56/******************************************************************************
57 ******************************************************************************
58 ** This node implements Link Layer Control and Adaptation Protocol (L2CAP)
59 ******************************************************************************
60 ******************************************************************************/
61
62/* MALLOC define */
63#ifdef NG_SEPARATE_MALLOC
64MALLOC_DEFINE(M_NETGRAPH_L2CAP, "netgraph_l2cap",
65 "Netgraph Bluetooth L2CAP node");
66#else
67#define M_NETGRAPH_L2CAP M_NETGRAPH
68#endif /* NG_SEPARATE_MALLOC */
69
70/* Netgraph node methods */
80
81/* Netgraph node type descriptor */
82static struct ng_type typestruct = {
84 .name = NG_L2CAP_NODE_TYPE,
85 .constructor = ng_l2cap_constructor,
87 .shutdown = ng_l2cap_shutdown,
88 .newhook = ng_l2cap_newhook,
89 .connect = ng_l2cap_connect,
90 .rcvdata = ng_l2cap_rcvdata,
91 .disconnect = ng_l2cap_disconnect,
92 .cmdlist = ng_l2cap_cmdlist,
93};
98
99/*****************************************************************************
100 *****************************************************************************
101 ** Netgraph methods implementation
102 *****************************************************************************
103 *****************************************************************************/
104
105static void ng_l2cap_cleanup (ng_l2cap_p);
107
108/*
109 * Create new instance of L2CAP node
110 */
111
112static int
114{
115 ng_l2cap_p l2cap = NULL;
116
117 /* Create new L2CAP node */
118 l2cap = malloc(sizeof(*l2cap), M_NETGRAPH_L2CAP, M_WAITOK | M_ZERO);
119
120 l2cap->node = node;
121 l2cap->debug = NG_L2CAP_WARN_LEVEL;
122 l2cap->discon_timo = 5; /* sec */
123
124 LIST_INIT(&l2cap->con_list);
125 LIST_INIT(&l2cap->chan_list);
126
127 NG_NODE_SET_PRIVATE(node, l2cap);
129
130 return (0);
131} /* ng_l2cap_constructor */
132
133/*
134 * Shutdown L2CAP node
135 */
136
137static int
139{
140 ng_l2cap_p l2cap = (ng_l2cap_p) NG_NODE_PRIVATE(node);
141
142 NG_NODE_SET_PRIVATE(node, NULL);
143 NG_NODE_UNREF(node);
144
145 /* Clean up L2CAP node. Delete all connection, channels and commands */
146 l2cap->node = NULL;
147 ng_l2cap_cleanup(l2cap);
148
149 bzero(l2cap, sizeof(*l2cap));
150 free(l2cap, M_NETGRAPH_L2CAP);
151
152 return (0);
153} /* ng_l2cap_shutdown */
154
155/*
156 * Give our OK for a hook to be added. HCI layer is connected to the HCI
157 * (NG_L2CAP_HOOK_HCI) hook. As per specification L2CAP layer MUST provide
158 * Procol/Service Multiplexing, so the L2CAP node provides separate hooks
159 * for SDP (NG_L2CAP_HOOK_SDP), RFCOMM (NG_L2CAP_HOOK_RFCOMM) and TCP
160 * (NG_L2CAP_HOOK_TCP) protcols. Unknown PSM will be forwarded to
161 * NG_L2CAP_HOOK_ORPHAN hook. Control node/application is connected to
162 * control (NG_L2CAP_HOOK_CTL) hook.
163 */
164
165static int
166ng_l2cap_newhook(node_p node, hook_p hook, char const *name)
167{
168 ng_l2cap_p l2cap = (ng_l2cap_p) NG_NODE_PRIVATE(node);
169 hook_p *h = NULL;
170
171 if (strcmp(name, NG_L2CAP_HOOK_HCI) == 0)
172 h = &l2cap->hci;
173 else if (strcmp(name, NG_L2CAP_HOOK_L2C) == 0)
174 h = &l2cap->l2c;
175 else if (strcmp(name, NG_L2CAP_HOOK_CTL) == 0)
176 h = &l2cap->ctl;
177 else
178 return (EINVAL);
179
180 if (*h != NULL)
181 return (EISCONN);
182
183 *h = hook;
184
185 return (0);
186} /* ng_l2cap_newhook */
187
188/*
189 * Give our final OK to connect hook. Nothing to do here.
190 */
191
192static int
194{
196 int error = 0;
197
198 if (hook == l2cap->hci)
200 else
201 if (hook == l2cap->l2c || hook == l2cap->ctl) {
203
204 /* Send delayed notification to the upper layer */
205 error = ng_send_fn(l2cap->node, hook, ng_l2cap_send_hook_info,
206 NULL, 0);
207 } else
208 error = EINVAL;
209
210 return (error);
211} /* ng_l2cap_connect */
212
213/*
214 * Disconnect the hook. For downstream hook we must notify upper layers.
215 *
216 * XXX For upstream hooks this is really ugly :( Hook was disconnected and it
217 * XXX is now too late to do anything. For now we just clean up our own mess
218 * XXX and remove all channels that use disconnected upstream hook. If we don't
219 * XXX do that then L2CAP node can get out of sync with upper layers.
220 * XXX No notification will be sent to remote peer.
221 */
222
223static int
225{
227 hook_p *h = NULL;
228
229 if (hook == l2cap->hci) {
230 ng_l2cap_cleanup(l2cap);
231 h = &l2cap->hci;
232 } else
233 if (hook == l2cap->l2c) {
235 h = &l2cap->l2c;
236 } else
237 if (hook == l2cap->ctl)
238 h = &l2cap->ctl;
239 else
240 return (EINVAL);
241
242 *h = NULL;
243
244 /* Shutdown when all hooks are disconnected */
245 if (NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0 &&
248
249 return (0);
250} /* ng_l2cap_disconnect */
251
252/*
253 * Process control message from lower layer
254 */
255
256static int
258{
259 ng_l2cap_p l2cap = (ng_l2cap_p) NG_NODE_PRIVATE(node);
260 struct ng_mesg *msg = NGI_MSG(item); /* item still has message */
261 int error = 0;
262
263 switch (msg->header.typecookie) {
264 case NGM_HCI_COOKIE:
265 switch (msg->header.cmd) {
266 /* HCI node is ready */
267 case NGM_HCI_NODE_UP: {
268 ng_hci_node_up_ep *ep = NULL;
269
270 if (msg->header.arglen != sizeof(*ep))
271 error = EMSGSIZE;
272 else {
273 ep = (ng_hci_node_up_ep *)(msg->data);
274
276"%s: %s - HCI node is up, bdaddr: %x:%x:%x:%x:%x:%x, " \
277"pkt_size=%d bytes, num_pkts=%d\n", __func__, NG_NODE_NAME(l2cap->node),
278 ep->bdaddr.b[5], ep->bdaddr.b[4],
279 ep->bdaddr.b[3], ep->bdaddr.b[2],
280 ep->bdaddr.b[1], ep->bdaddr.b[0],
281 ep->pkt_size, ep->num_pkts);
282
283 bcopy(&ep->bdaddr, &l2cap->bdaddr,
284 sizeof(l2cap->bdaddr));
285 l2cap->pkt_size = ep->pkt_size;
286 l2cap->num_pkts = ep->num_pkts;
287
288 /* Notify upper layers */
290 l2cap->l2c, NULL, 0);
292 l2cap->ctl, NULL, 0);
293 }
294 } break;
295
297 ng_hci_sync_con_queue_ep *ep = NULL;
298 ng_l2cap_con_p con = NULL;
299
300 if (msg->header.arglen != sizeof(*ep))
301 error = EMSGSIZE;
302 else {
303 ep = (ng_hci_sync_con_queue_ep *)(msg->data);
304 con = ng_l2cap_con_by_handle(l2cap,
305 ep->con_handle);
306 if (con == NULL)
307 break;
308
310"%s: %s - sync HCI connection queue, con_handle=%d, pending=%d, completed=%d\n",
311 __func__, NG_NODE_NAME(l2cap->node),
312 ep->con_handle, con->pending,
313 ep->completed);
314
315 con->pending -= ep->completed;
316 if (con->pending < 0) {
318"%s: %s - pending packet counter is out of sync! " \
319"con_handle=%d, pending=%d, completed=%d\n", __func__,
320 NG_NODE_NAME(l2cap->node),
321 con->con_handle, con->pending,
322 ep->completed);
323
324 con->pending = 0;
325 }
326
328 }
329 } break;
330
331 /* LP_ConnectCfm[Neg] */
333 error = ng_l2cap_lp_con_cfm(l2cap, msg);
334 break;
335
336 /* LP_ConnectInd */
338 error = ng_l2cap_lp_con_ind(l2cap, msg);
339 break;
340
341 /* LP_DisconnectInd */
343 error = ng_l2cap_lp_discon_ind(l2cap, msg);
344 break;
345
346 /* LP_QoSSetupCfm[Neg] */
348 error = ng_l2cap_lp_qos_cfm(l2cap, msg);
349 break;
350
351 /* LP_OoSViolationInd */
353 error = ng_l2cap_lp_qos_ind(l2cap, msg);
354 break;
356 error = ng_l2cap_lp_enc_change(l2cap, msg);
357 break;
358 default:
359 error = EINVAL;
360 break;
361 }
362 break;
363
364 default:
365 return (ng_l2cap_default_rcvmsg(node, item, lasthook));
366 /* NOT REACHED */
367 }
368
369 NG_FREE_ITEM(item);
370
371 return (error);
372} /* ng_l2cap_lower_rcvmsg */
373
374/*
375 * Process control message from upper layer
376 */
377
378static int
380{
381 ng_l2cap_p l2cap = (ng_l2cap_p) NG_NODE_PRIVATE(node);
382 struct ng_mesg *msg = NGI_MSG(item); /* item still has message */
383 int error = 0;
384
385 switch (msg->header.typecookie) {
386 case NGM_L2CAP_COOKIE:
387 switch (msg->header.cmd) {
388 /* L2CA_Connect */
390 error = ng_l2cap_l2ca_con_req(l2cap, msg);
391 break;
392
393 /* L2CA_ConnectRsp */
395 error = ng_l2cap_l2ca_con_rsp_req(l2cap, msg);
396 break;
397
398 /* L2CA_Config */
400 error = ng_l2cap_l2ca_cfg_req(l2cap, msg);
401 break;
402
403 /* L2CA_ConfigRsp */
405 error = ng_l2cap_l2ca_cfg_rsp_req(l2cap, msg);
406 break;
407
408 /* L2CA_Disconnect */
410 error = ng_l2cap_l2ca_discon_req(l2cap, msg);
411 break;
412
413 /* L2CA_GroupCreate */
415 error = ng_l2cap_l2ca_grp_create(l2cap, msg);
416 break;
417
418 /* L2CA_GroupClose */
420 error = ng_l2cap_l2ca_grp_close(l2cap, msg);
421 break;
422
423 /* L2CA_GroupAddMember */
425 error = ng_l2cap_l2ca_grp_add_member_req(l2cap, msg);
426 break;
427
428 /* L2CA_GroupDeleteMember */
430 error = ng_l2cap_l2ca_grp_rem_member(l2cap, msg);
431 break;
432
433 /* L2CA_GroupMembership */
435 error = ng_l2cap_l2ca_grp_get_members(l2cap, msg);
436 break;
437
438 /* L2CA_Ping */
440 error = ng_l2cap_l2ca_ping_req(l2cap, msg);
441 break;
442
443 /* L2CA_GetInfo */
445 error = ng_l2cap_l2ca_get_info_req(l2cap, msg);
446 break;
447
448 /* L2CA_EnableCLT */
450 error = ng_l2cap_l2ca_enable_clt(l2cap, msg);
451 break;
452
453 default:
454 return (ng_l2cap_default_rcvmsg(node, item, lasthook));
455 /* NOT REACHED */
456 }
457 break;
458
459 default:
460 return (ng_l2cap_default_rcvmsg(node, item, lasthook));
461 /* NOT REACHED */
462 }
463
464 NG_FREE_ITEM(item);
465
466 return (error);
467} /* ng_l2cap_upper_rcvmsg */
468
469/*
470 * Default control message processing routine
471 */
472
473static int
475{
476 ng_l2cap_p l2cap = (ng_l2cap_p) NG_NODE_PRIVATE(node);
477 struct ng_mesg *msg = NULL, *rsp = NULL;
478 int error = 0;
479
480 /* Detach and process message */
481 NGI_GET_MSG(item, msg);
482
483 switch (msg->header.typecookie) {
485 switch (msg->header.cmd) {
486 case NGM_TEXT_STATUS:
487 NG_MKRESPONSE(rsp, msg, NG_TEXTRESPONSE, M_NOWAIT);
488 if (rsp == NULL)
489 error = ENOMEM;
490 else
491 snprintf(rsp->data, NG_TEXTRESPONSE,
492 "bdaddr %x:%x:%x:%x:%x:%x, " \
493 "pkt_size %d\n" \
494 "Hooks %s %s %s\n" \
495 "Flags %#x\n",
496 l2cap->bdaddr.b[5], l2cap->bdaddr.b[4],
497 l2cap->bdaddr.b[3], l2cap->bdaddr.b[2],
498 l2cap->bdaddr.b[1], l2cap->bdaddr.b[0],
499 l2cap->pkt_size,
500 (l2cap->hci != NULL)?
502 (l2cap->l2c != NULL)?
503 NG_L2CAP_HOOK_L2C : "",
504 (l2cap->ctl != NULL)?
505 NG_L2CAP_HOOK_CTL : "",
506 l2cap->flags);
507 break;
508
509 default:
510 error = EINVAL;
511 break;
512 }
513 break;
514
515 /* Messages from the upper layer or directed to the local node */
516 case NGM_L2CAP_COOKIE:
517 switch (msg->header.cmd) {
518 /* Get node flags */
520 NG_MKRESPONSE(rsp, msg, sizeof(ng_l2cap_node_flags_ep),
521 M_NOWAIT);
522 if (rsp == NULL)
523 error = ENOMEM;
524 else
525 *((ng_l2cap_node_flags_ep *)(rsp->data)) =
526 l2cap->flags;
527 break;
528
529 /* Get node debug */
531 NG_MKRESPONSE(rsp, msg, sizeof(ng_l2cap_node_debug_ep),
532 M_NOWAIT);
533 if (rsp == NULL)
534 error = ENOMEM;
535 else
536 *((ng_l2cap_node_debug_ep *)(rsp->data)) =
537 l2cap->debug;
538 break;
539
540 /* Set node debug */
542 if (msg->header.arglen !=
544 error = EMSGSIZE;
545 else
546 l2cap->debug =
547 *((ng_l2cap_node_debug_ep *)(msg->data));
548 break;
549
550 /* Get connection list */
552 ng_l2cap_con_p con = NULL;
553 ng_l2cap_node_con_list_ep *e1 = NULL;
554 ng_l2cap_node_con_ep *e2 = NULL;
555 int n = 0;
556
557 /* Count number of connections */
558 LIST_FOREACH(con, &l2cap->con_list, next)
559 n++;
560 if (n > NG_L2CAP_MAX_CON_NUM)
562
563 /* Prepare response */
564 NG_MKRESPONSE(rsp, msg,
565 sizeof(*e1) + n * sizeof(*e2), M_NOWAIT);
566 if (rsp == NULL) {
567 error = ENOMEM;
568 break;
569 }
570
571 e1 = (ng_l2cap_node_con_list_ep *)(rsp->data);
572 e2 = (ng_l2cap_node_con_ep *)(e1 + 1);
573
574 e1->num_connections = n;
575
576 LIST_FOREACH(con, &l2cap->con_list, next) {
577 e2->state = con->state;
578
579 e2->flags = con->flags;
580 if (con->tx_pkt != NULL)
581 e2->flags |= NG_L2CAP_CON_TX;
582 if (con->rx_pkt != NULL)
583 e2->flags |= NG_L2CAP_CON_RX;
584
585 e2->pending = con->pending;
586
587 e2->con_handle = con->con_handle;
588 bcopy(&con->remote, &e2->remote,
589 sizeof(e2->remote));
590
591 e2 ++;
592 if (--n <= 0)
593 break;
594 }
595 } break;
596
597 /* Get channel list */
599 ng_l2cap_chan_p ch = NULL;
601 ng_l2cap_node_chan_ep *e2 = NULL;
602 int n = 0;
603
604 /* Count number of channels */
605 LIST_FOREACH(ch, &l2cap->chan_list, next)
606 n ++;
607 if (n > NG_L2CAP_MAX_CHAN_NUM)
609
610 /* Prepare response */
611 NG_MKRESPONSE(rsp, msg,
613 n * sizeof(ng_l2cap_node_chan_ep), M_NOWAIT);
614 if (rsp == NULL) {
615 error = ENOMEM;
616 break;
617 }
618
619 e1 = (ng_l2cap_node_chan_list_ep *)(rsp->data);
620 e2 = (ng_l2cap_node_chan_ep *)(e1 + 1);
621
622 e1->num_channels = n;
623
624 LIST_FOREACH(ch, &l2cap->chan_list, next) {
625 e2->state = ch->state;
626
627 e2->scid = ch->scid;
628 e2->dcid = ch->dcid;
629
630 e2->imtu = ch->imtu;
631 e2->omtu = ch->omtu;
632
633 e2->psm = ch->psm;
634 bcopy(&ch->con->remote, &e2->remote,
635 sizeof(e2->remote));
636
637 e2 ++;
638 if (--n <= 0)
639 break;
640 }
641 } break;
642
644 NG_MKRESPONSE(rsp, msg,
645 sizeof(ng_l2cap_node_auto_discon_ep), M_NOWAIT);
646 if (rsp == NULL)
647 error = ENOMEM;
648 else
649 *((ng_l2cap_node_auto_discon_ep *)(rsp->data)) =
650 l2cap->discon_timo;
651 break;
652
654 if (msg->header.arglen !=
656 error = EMSGSIZE;
657 else
658 l2cap->discon_timo =
660 (msg->data));
661 break;
662
663 default:
664 error = EINVAL;
665 break;
666 }
667 break;
668
669 default:
670 error = EINVAL;
671 break;
672 }
673
674 NG_RESPOND_MSG(error, node, item, rsp);
675 NG_FREE_MSG(msg);
676
677 return (error);
678} /* ng_l2cap_rcvmsg */
679
680/*
681 * Process data packet from one of our hooks.
682 *
683 * From the HCI hook we expect to receive ACL data packets. ACL data packets
684 * gets re-assembled into one L2CAP packet (according to length) and then gets
685 * processed.
686 *
687 * NOTE: We expect to receive L2CAP packet header in the first fragment.
688 * Otherwise we WILL NOT be able to get length of the L2CAP packet.
689 *
690 * Signaling L2CAP packets (destination channel ID == 0x1) are processed within
691 * the node. Connectionless data packets (destination channel ID == 0x2) will
692 * be forwarded to appropriate upstream hook unless it is not connected or
693 * connectionless traffic for the specified PSM was disabled.
694 *
695 * From the upstream hooks we expect to receive data packets. These data
696 * packets will be converted into L2CAP data packets. The length of each
697 * L2CAP packet must not exceed channel's omtu (our peer's imtu). Then
698 * these L2CAP packets will be converted to ACL data packets (according to
699 * HCI layer MTU) and sent to lower layer.
700 *
701 * No data is expected from the control hook.
702 */
703
704static int
706{
708 struct mbuf *m = NULL;
709 int error = 0;
710
711 /* Detach mbuf, discard item and process data */
712 NGI_GET_M(item, m);
713 NG_FREE_ITEM(item);
714
715 if (hook == l2cap->hci)
716 error = ng_l2cap_lp_receive(l2cap, m);
717 else if (hook == l2cap->l2c)
718 error = ng_l2cap_l2ca_write_req(l2cap, m);
719 else {
720 NG_FREE_M(m);
721 error = EINVAL;
722 }
723
724 return (error);
725} /* ng_l2cap_rcvdata */
726
727/*
728 * Clean all connections, channels and commands for the L2CAP node
729 */
730
731static void
733{
734 ng_l2cap_con_p con = NULL;
735
736 /* Clean up connection and channels */
737 while (!LIST_EMPTY(&l2cap->con_list)) {
738 con = LIST_FIRST(&l2cap->con_list);
739
740 if (con->flags & NG_L2CAP_CON_LP_TIMO)
742 else if (con->flags & NG_L2CAP_CON_AUTO_DISCON_TIMO)
744
745 /* Connection terminated by local host */
746 ng_l2cap_con_fail(con, 0x16);
747 }
748} /* ng_l2cap_cleanup */
749
750/*
751 * Destroy all channels that use specified upstream hook
752 */
753
754static void
756{
757 while (!LIST_EMPTY(&l2cap->chan_list))
758 ng_l2cap_free_chan(LIST_FIRST(&l2cap->chan_list));
759} /* ng_l2cap_destroy_channels_by_hook */
int ng_connect_t(hook_p hook)
Definition: netgraph.h:104
#define NGI_MSG(i)
Definition: netgraph.h:834
#define NG_HOOK_NODE(hook)
Definition: netgraph.h:339
#define NG_FREE_M(m)
Definition: netgraph.h:946
int ng_rcvmsg_t(node_p node, item_p item, hook_p lasthook)
Definition: netgraph.h:105
int ng_disconnect_t(hook_p hook)
Definition: netgraph.h:107
#define NG_NODE_SET_PRIVATE(node, val)
Definition: netgraph.h:608
#define NG_RESPOND_MSG(error, here, item, resp)
Definition: netgraph.h:1025
#define NG_NODE_IS_VALID(node)
Definition: netgraph.h:610
#define NG_NODE_FORCE_WRITER(node)
Definition: netgraph.h:612
#define NG_HOOK_SET_RCVMSG(hook, val)
Definition: netgraph.h:334
#define NG_NODE_UNREF(node)
Definition: netgraph.h:607
#define NG_NODE_NAME(node)
Definition: netgraph.h:603
int ng_rmnode_self(node_p here)
Definition: ng_base.c:1609
int ng_rcvdata_t(hook_p hook, item_p item)
Definition: netgraph.h:106
int ng_shutdown_t(node_p node)
Definition: netgraph.h:101
#define NG_FREE_ITEM(item)
Definition: netgraph.h:847
int ng_constructor_t(node_p node)
Definition: netgraph.h:99
#define NGI_GET_M(i, m)
Definition: netgraph.h:852
int ng_send_fn(node_p node, hook_p hook, ng_item_fn *fn, void *arg1, int arg2)
Definition: ng_base.c:3700
#define NG_FREE_MSG(msg)
Definition: netgraph.h:938
#define NG_ABI_VERSION
Definition: netgraph.h:77
#define NG_NODE_NUMHOOKS(node)
Definition: netgraph.h:615
#define NGI_GET_MSG(i, m)
Definition: netgraph.h:858
#define NG_NODE_PRIVATE(node)
Definition: netgraph.h:609
int ng_newhook_t(node_p node, hook_p hook, const char *name)
Definition: netgraph.h:102
#define NG_BLUETOOTH_VERSION
Definition: ng_bluetooth.h:45
MALLOC_DEFINE(M_NG_CCATM, "ng_ccatm", "netgraph uni api node")
#define NGM_HCI_LP_QOS_IND
Definition: ng_hci.h:535
#define NGM_HCI_LP_CON_IND
Definition: ng_hci.h:492
#define NGM_HCI_SYNC_CON_QUEUE
Definition: ng_hci.h:668
#define NGM_HCI_COOKIE
Definition: ng_hci.h:60
#define NGM_HCI_LP_CON_CFM
Definition: ng_hci.h:483
#define NGM_HCI_LP_ENC_CHG
Definition: ng_hci.h:540
#define NGM_HCI_LP_DISCON_IND
Definition: ng_hci.h:508
#define NGM_HCI_LP_QOS_CFM
Definition: ng_hci.h:528
#define NGM_HCI_NODE_UP
Definition: ng_hci.h:660
#define NGM_L2CAP_L2CA_DISCON
Definition: ng_l2cap.h:464
#define NGM_L2CAP_L2CA_GRP_CLOSE
Definition: ng_l2cap.h:507
#define NG_L2CAP_CON_LP_TIMO
Definition: ng_l2cap.h:666
#define NGM_L2CAP_L2CA_ENABLE_CLT
Definition: ng_l2cap.h:592
#define NGM_L2CAP_L2CA_CFG_RSP
Definition: ng_l2cap.h:431
#define NG_L2CAP_CON_TX
Definition: ng_l2cap.h:663
#define NGM_L2CAP_NODE_GET_CHAN_LIST
Definition: ng_l2cap.h:681
u_int16_t ng_l2cap_node_auto_discon_ep
Definition: ng_l2cap.h:704
#define NGM_L2CAP_NODE_GET_AUTO_DISCON_TIMO
Definition: ng_l2cap.h:702
u_int16_t ng_l2cap_node_flags_ep
Definition: ng_l2cap.h:645
#define NGM_L2CAP_NODE_SET_DEBUG
Definition: ng_l2cap.h:649
#define NGM_L2CAP_L2CA_PING
Definition: ng_l2cap.h:558
#define NGM_L2CAP_L2CA_GRP_CREATE
Definition: ng_l2cap.h:495
u_int16_t ng_l2cap_node_debug_ep
Definition: ng_l2cap.h:650
#define NG_L2CAP_CON_AUTO_DISCON_TIMO
Definition: ng_l2cap.h:667
#define NGM_L2CAP_COOKIE
Definition: ng_l2cap.h:60
#define NGM_L2CAP_L2CA_CFG
Definition: ng_l2cap.h:412
#define NGM_L2CAP_L2CA_GRP_MEMBERSHIP
Definition: ng_l2cap.h:544
#define NGM_L2CAP_NODE_GET_CON_LIST
Definition: ng_l2cap.h:657
#define NGM_L2CAP_NODE_GET_FLAGS
Definition: ng_l2cap.h:644
#define NGM_L2CAP_NODE_GET_DEBUG
Definition: ng_l2cap.h:648
#define NG_L2CAP_NODE_TYPE
Definition: ng_l2cap.h:59
#define NGM_L2CAP_L2CA_GET_INFO
Definition: ng_l2cap.h:575
#define NG_L2CAP_HOOK_HCI
Definition: ng_l2cap.h:54
#define NG_L2CAP_MAX_CON_NUM
Definition: ng_l2cap.h:678
#define NG_L2CAP_CON_RX
Definition: ng_l2cap.h:664
#define NGM_L2CAP_L2CA_CON_RSP
Definition: ng_l2cap.h:395
#define NG_L2CAP_WARN_LEVEL
Definition: ng_l2cap.h:640
#define NGM_L2CAP_L2CA_GRP_ADD_MEMBER
Definition: ng_l2cap.h:521
#define NGM_L2CAP_NODE_SET_AUTO_DISCON_TIMO
Definition: ng_l2cap.h:703
#define NGM_L2CAP_L2CA_CON
Definition: ng_l2cap.h:364
#define NG_L2CAP_MAX_CHAN_NUM
Definition: ng_l2cap.h:699
#define NG_L2CAP_HOOK_CTL
Definition: ng_l2cap.h:56
#define NGM_L2CAP_L2CA_GRP_REM_MEMBER
Definition: ng_l2cap.h:534
#define NG_L2CAP_HOOK_L2C
Definition: ng_l2cap.h:55
void ng_l2cap_con_fail(ng_l2cap_con_p con, u_int16_t result)
int ng_l2cap_lp_qos_ind(ng_l2cap_p l2cap, struct ng_mesg *msg)
int ng_l2cap_lp_enc_change(ng_l2cap_p l2cap, struct ng_mesg *msg)
void ng_l2cap_lp_deliver(ng_l2cap_con_p con)
int ng_l2cap_lp_receive(ng_l2cap_p l2cap, struct mbuf *m)
int ng_l2cap_lp_discon_ind(ng_l2cap_p l2cap, struct ng_mesg *msg)
int ng_l2cap_lp_qos_cfm(ng_l2cap_p l2cap, struct ng_mesg *msg)
int ng_l2cap_lp_con_cfm(ng_l2cap_p l2cap, struct ng_mesg *msg)
int ng_l2cap_lp_con_ind(ng_l2cap_p l2cap, struct ng_mesg *msg)
static ng_rcvmsg_t ng_l2cap_lower_rcvmsg
Definition: ng_l2cap_main.c:76
#define M_NETGRAPH_L2CAP
Definition: ng_l2cap_main.c:67
static ng_shutdown_t ng_l2cap_shutdown
Definition: ng_l2cap_main.c:72
static ng_constructor_t ng_l2cap_constructor
Definition: ng_l2cap_main.c:71
MODULE_DEPEND(ng_l2cap, ng_bluetooth, NG_BLUETOOTH_VERSION, NG_BLUETOOTH_VERSION, NG_BLUETOOTH_VERSION)
MODULE_VERSION(ng_l2cap, NG_BLUETOOTH_VERSION)
static ng_rcvmsg_t ng_l2cap_default_rcvmsg
Definition: ng_l2cap_main.c:78
static struct ng_type typestruct
Definition: ng_l2cap_main.c:82
static void ng_l2cap_destroy_channels(ng_l2cap_p)
static void ng_l2cap_cleanup(ng_l2cap_p)
static ng_newhook_t ng_l2cap_newhook
Definition: ng_l2cap_main.c:73
static ng_disconnect_t ng_l2cap_disconnect
Definition: ng_l2cap_main.c:75
static ng_rcvmsg_t ng_l2cap_upper_rcvmsg
Definition: ng_l2cap_main.c:77
static ng_rcvdata_t ng_l2cap_rcvdata
Definition: ng_l2cap_main.c:79
NETGRAPH_INIT(l2cap, &typestruct)
static ng_connect_t ng_l2cap_connect
Definition: ng_l2cap_main.c:74
void ng_l2cap_free_chan(ng_l2cap_chan_p ch)
ng_l2cap_con_p ng_l2cap_con_by_handle(ng_l2cap_p l2cap, u_int16_t con_handle)
void ng_l2cap_send_hook_info(node_p node, hook_p hook, void *arg1, int arg2)
Definition: ng_l2cap_misc.c:67
int ng_l2cap_discon_untimeout(ng_l2cap_con_p con)
int ng_l2cap_lp_untimeout(ng_l2cap_con_p con)
static const struct ng_cmdlist ng_l2cap_cmdlist[]
Definition: ng_l2cap_prse.h:49
int ng_l2cap_l2ca_ping_req(ng_l2cap_p l2cap, struct ng_mesg *msg)
int ng_l2cap_l2ca_grp_add_member_req(ng_l2cap_p l2cap, struct ng_mesg *msg)
int ng_l2cap_l2ca_cfg_req(ng_l2cap_p l2cap, struct ng_mesg *msg)
int ng_l2cap_l2ca_enable_clt(ng_l2cap_p l2cap, struct ng_mesg *msg)
int ng_l2cap_l2ca_cfg_rsp_req(ng_l2cap_p l2cap, struct ng_mesg *msg)
int ng_l2cap_l2ca_con_req(ng_l2cap_p l2cap, struct ng_mesg *msg)
Definition: ng_l2cap_ulpi.c:65
int ng_l2cap_l2ca_get_info_req(ng_l2cap_p l2cap, struct ng_mesg *msg)
int ng_l2cap_l2ca_write_req(ng_l2cap_p l2cap, struct mbuf *m)
int ng_l2cap_l2ca_grp_rem_member(ng_l2cap_p l2cap, struct ng_mesg *msg)
int ng_l2cap_l2ca_con_rsp_req(ng_l2cap_p l2cap, struct ng_mesg *msg)
int ng_l2cap_l2ca_grp_close(ng_l2cap_p l2cap, struct ng_mesg *msg)
int ng_l2cap_l2ca_discon_req(ng_l2cap_p l2cap, struct ng_mesg *msg)
int ng_l2cap_l2ca_grp_get_members(ng_l2cap_p l2cap, struct ng_mesg *msg)
int ng_l2cap_l2ca_grp_create(ng_l2cap_p l2cap, struct ng_mesg *msg)
ng_l2cap_t * ng_l2cap_p
Definition: ng_l2cap_var.h:102
#define NG_L2CAP_WARN
Definition: ng_l2cap_var.h:49
#define NG_L2CAP_INFO
Definition: ng_l2cap_var.h:50
#define NG_MKRESPONSE(rsp, msg, len, how)
Definition: ng_message.h:396
#define NG_TEXTRESPONSE
Definition: ng_message.h:54
#define NGM_GENERIC_COOKIE
Definition: ng_message.h:113
@ NGM_TEXT_STATUS
Definition: ng_message.h:134
char *const name
Definition: ng_ppp.c:261
u_int16_t num_pkts
Definition: ng_hci.h:663
u_int16_t pkt_size
Definition: ng_hci.h:662
bdaddr_t bdaddr
Definition: ng_hci.h:665
u_int16_t con_handle
Definition: ng_hci.h:670
u_int16_t dcid
Definition: ng_l2cap_var.h:156
u_int16_t imtu
Definition: ng_l2cap_var.h:159
u_int16_t psm
Definition: ng_l2cap_var.h:154
u_int16_t state
Definition: ng_l2cap_var.h:145
u_int16_t scid
Definition: ng_l2cap_var.h:155
ng_l2cap_con_p con
Definition: ng_l2cap_var.h:143
u_int16_t omtu
Definition: ng_l2cap_var.h:162
struct mbuf * rx_pkt
Definition: ng_l2cap_var.h:131
bdaddr_t remote
Definition: ng_l2cap_var.h:118
u_int16_t con_handle
Definition: ng_l2cap_var.h:119
u_int16_t state
Definition: ng_l2cap_var.h:113
struct mbuf * tx_pkt
Definition: ng_l2cap_var.h:128
u_int16_t flags
Definition: ng_l2cap_var.h:114
u_int16_t con_handle
Definition: ng_l2cap.h:674
ng_l2cap_node_debug_ep debug
Definition: ng_l2cap_var.h:83
hook_p hci
Definition: ng_l2cap_var.h:91
ng_l2cap_node_flags_ep flags
Definition: ng_l2cap_var.h:84
u_int16_t pkt_size
Definition: ng_l2cap_var.h:87
node_p node
Definition: ng_l2cap_var.h:81
u_int16_t num_pkts
Definition: ng_l2cap_var.h:88
bdaddr_t bdaddr
Definition: ng_l2cap_var.h:89
hook_p l2c
Definition: ng_l2cap_var.h:92
hook_p ctl
Definition: ng_l2cap_var.h:93
ng_l2cap_node_auto_discon_ep discon_timo
Definition: ng_l2cap_var.h:85
u_int32_t arglen
Definition: ng_message.h:62
u_int32_t typecookie
Definition: ng_message.h:66
struct ng_mesg::ng_msghdr header
char data[]
Definition: ng_message.h:69
u_int32_t version
Definition: netgraph.h:1077