FreeBSD kernel netgraph code
ng_l2cap_misc.c
Go to the documentation of this file.
1/*
2 * ng_l2cap_misc.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_misc.c,v 1.5 2003/09/08 19:11:45 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>
53
54static u_int16_t ng_l2cap_get_cid (ng_l2cap_p, int);
55
56/******************************************************************************
57 ******************************************************************************
58 ** Utility routines
59 ******************************************************************************
60 ******************************************************************************/
61
62/*
63 * Send hook information to the upper layer
64 */
65
66void
67ng_l2cap_send_hook_info(node_p node, hook_p hook, void *arg1, int arg2)
68{
69 ng_l2cap_p l2cap = NULL;
70 struct ng_mesg *msg = NULL;
71 int error = 0;
73
74 if (node == NULL || NG_NODE_NOT_VALID(node) ||
75 hook == NULL || NG_HOOK_NOT_VALID(hook))
76 return;
77
78 l2cap = (ng_l2cap_p) NG_NODE_PRIVATE(node);
79 if (l2cap->hci == NULL || NG_HOOK_NOT_VALID(l2cap->hci) ||
80 bcmp(&l2cap->bdaddr, NG_HCI_BDADDR_ANY, sizeof(l2cap->bdaddr)) == 0)
81 return;
82
84 sizeof(*ep), M_NOWAIT);
85
86 if (msg != NULL) {
87 ep = (ng_l2cap_node_hook_info_ep *) &msg->data;
88 bcopy(&l2cap->bdaddr, &ep->addr, sizeof(bdaddr_t));
89 NG_SEND_MSG_HOOK(error, node, msg, hook, 0);
90 } else
91 error = ENOMEM;
92
93 if (error != 0)
95"%s: %s - failed to send HOOK_INFO message to hook \"%s\", error=%d\n",
96 __func__, NG_NODE_NAME(l2cap->node), NG_HOOK_NAME(hook),
97 error);
98} /* ng_l2cap_send_hook_info */
99
100/*
101 * Create new connection descriptor for the "remote" unit.
102 * Will link connection descriptor to the l2cap node.
103 */
104
107{
108 static int fake_con_handle = 0x0f00;
109 ng_l2cap_con_p con = NULL;
110
111 /* Create new connection descriptor */
112 con = malloc(sizeof(*con), M_NETGRAPH_L2CAP,
113 M_NOWAIT|M_ZERO);
114 if (con == NULL)
115 return (NULL);
116
117 con->l2cap = l2cap;
119 con->encryption = 0;
120 /*
121 * XXX
122 *
123 * Assign fake connection handle to the connection descriptor.
124 * Bluetooth specification marks 0x0f00 - 0x0fff connection
125 * handles as reserved. We need this fake connection handles
126 * for timeouts. Connection handle will be passed as argument
127 * to timeout so when timeout happens we can find the right
128 * connection descriptor. We can not pass pointers, because
129 * timeouts are external (to Netgraph) events and there might
130 * be a race when node/hook goes down and timeout event already
131 * went into node's queue
132 */
133
134 con->con_handle = fake_con_handle ++;
135 if (fake_con_handle > 0x0fff)
136 fake_con_handle = 0x0f00;
137
138 bcopy(bdaddr, &con->remote, sizeof(con->remote));
139 con->linktype = type;
141
142 con->ident = NG_L2CAP_FIRST_IDENT - 1;
143 TAILQ_INIT(&con->cmd_list);
144
145 /* Link connection */
146 LIST_INSERT_HEAD(&l2cap->con_list, con, next);
147
148 return (con);
149} /* ng_l2cap_new_con */
150
151/*
152 * Add reference to the connection descriptor
153 */
154
155void
157{
158 con->refcnt ++;
159
161 if ((con->state != NG_L2CAP_CON_OPEN) ||
162 (con->flags & NG_L2CAP_CON_OUTGOING) == 0)
163 panic(
164"%s: %s - bad auto disconnect timeout, state=%d, flags=%#x\n",
165 __func__, NG_NODE_NAME(con->l2cap->node),
166 con->state, con->flags);
167
169 }
170} /* ng_l2cap_con_ref */
171
172/*
173 * Remove reference from the connection descriptor
174 */
175
176void
178{
179 con->refcnt --;
180
181 if (con->refcnt < 0)
182 panic(
183"%s: %s - con->refcnt < 0\n", __func__, NG_NODE_NAME(con->l2cap->node));
184
185 /*
186 * Set auto disconnect timer only if the following conditions are met:
187 * 1) we have no reference on the connection
188 * 2) connection is in OPEN state
189 * 3) it is an outgoing connection
190 * 4) disconnect timeout > 0
191 * 5) connection is not dying
192 */
193
194 if ((con->refcnt == 0) &&
195 (con->state == NG_L2CAP_CON_OPEN) &&
196 (con->flags & NG_L2CAP_CON_OUTGOING) &&
197 (con->l2cap->discon_timo > 0) &&
198 ((con->flags & NG_L2CAP_CON_DYING) == 0))
200} /* ng_l2cap_con_unref */
201
202/*
203 * Set auto disconnect timeout
204 * XXX FIXME: check return code from ng_callout
205 */
206
207int
209{
211 panic(
212"%s: %s - invalid timeout, state=%d, flags=%#x\n",
213 __func__, NG_NODE_NAME(con->l2cap->node),
214 con->state, con->flags);
215
217 ng_callout(&con->con_timo, con->l2cap->node, NULL,
218 con->l2cap->discon_timo * hz,
220 con->con_handle);
221
222 return (0);
223} /* ng_l2cap_discon_timeout */
224
225/*
226 * Unset auto disconnect timeout
227 */
228
229int
231{
233 panic(
234"%s: %s - no disconnect timeout, state=%d, flags=%#x\n",
235 __func__, NG_NODE_NAME(con->l2cap->node),
236 con->state, con->flags);
237
238 if (ng_uncallout(&con->con_timo, con->l2cap->node) < 1)
239 return (ETIMEDOUT);
240
241 con->flags &= ~NG_L2CAP_CON_AUTO_DISCON_TIMO;
242
243 return (0);
244} /* ng_l2cap_discon_untimeout */
245
246/*
247 * Free connection descriptor. Will unlink connection and free everything.
248 */
249
250void
252{
253 ng_l2cap_chan_p f = NULL, n = NULL;
254
256
257 while (con->tx_pkt != NULL) {
258 struct mbuf *m = con->tx_pkt->m_nextpkt;
259
260 m_freem(con->tx_pkt);
261 con->tx_pkt = m;
262 }
263
264 NG_FREE_M(con->rx_pkt);
265
266 for (f = LIST_FIRST(&con->l2cap->chan_list); f != NULL; ) {
267 n = LIST_NEXT(f, next);
268
269 if (f->con == con)
271
272 f = n;
273 }
274
275 while (!TAILQ_EMPTY(&con->cmd_list)) {
276 ng_l2cap_cmd_p cmd = TAILQ_FIRST(&con->cmd_list);
277
279 if (cmd->flags & NG_L2CAP_CMD_PENDING)
282 }
283
285 panic(
286"%s: %s - timeout pending! state=%d, flags=%#x\n",
287 __func__, NG_NODE_NAME(con->l2cap->node),
288 con->state, con->flags);
289
290 LIST_REMOVE(con, next);
291
292 bzero(con, sizeof(*con));
293 free(con, M_NETGRAPH_L2CAP);
294} /* ng_l2cap_free_con */
295
296/*
297 * Get connection by "remote" address
298 */
299
301ng_l2cap_con_by_addr(ng_l2cap_p l2cap, bdaddr_p bdaddr, unsigned int type)
302{
303 ng_l2cap_con_p con = NULL;
304
305 LIST_FOREACH(con, &l2cap->con_list, next)
306 if ((bcmp(bdaddr, &con->remote, sizeof(con->remote)) == 0)&&
307 (con->linktype == type))
308 break;
309
310 return (con);
311} /* ng_l2cap_con_by_addr */
312
313/*
314 * Get connection by "handle"
315 */
316
318ng_l2cap_con_by_handle(ng_l2cap_p l2cap, u_int16_t con_handle)
319{
320 ng_l2cap_con_p con = NULL;
321
322 LIST_FOREACH(con, &l2cap->con_list, next)
323 if (con->con_handle == con_handle)
324 break;
325
326 return (con);
327} /* ng_l2cap_con_by_handle */
328
329/*
330 * Allocate new L2CAP channel descriptor on "con" connection with "psm".
331 * Will link the channel to the l2cap node
332 */
333
335ng_l2cap_new_chan(ng_l2cap_p l2cap, ng_l2cap_con_p con, u_int16_t psm, int idtype)
336{
337 ng_l2cap_chan_p ch = NULL;
338
339 ch = malloc(sizeof(*ch), M_NETGRAPH_L2CAP,
340 M_NOWAIT|M_ZERO);
341 if (ch == NULL)
342 return (NULL);
343 if(idtype == NG_L2CAP_L2CA_IDTYPE_ATT){
344 ch->scid = ch->dcid = NG_L2CAP_ATT_CID;
345 }else if(idtype == NG_L2CAP_L2CA_IDTYPE_SMP){
346 ch->scid = ch->dcid = NG_L2CAP_SMP_CID;
347 }else{
348 ch->scid = ng_l2cap_get_cid(l2cap,
349 (con->linktype!= NG_HCI_LINK_ACL));
350 }
351
352 ch->idtype = idtype;
353 if (ch->scid != NG_L2CAP_NULL_CID) {
354 /* Initialize channel */
355 ch->psm = psm;
356 ch->con = con;
358
359 /* Set MTU and flow control settings to defaults */
361 bcopy(ng_l2cap_default_flow(), &ch->iflow, sizeof(ch->iflow));
362
364 bcopy(ng_l2cap_default_flow(), &ch->oflow, sizeof(ch->oflow));
365
368
369 LIST_INSERT_HEAD(&l2cap->chan_list, ch, next);
370
371 ng_l2cap_con_ref(con);
372 } else {
373 bzero(ch, sizeof(*ch));
374 free(ch, M_NETGRAPH_L2CAP);
375 ch = NULL;
376 }
377
378 return (ch);
379} /* ng_l2cap_new_chan */
380
382ng_l2cap_chan_by_scid(ng_l2cap_p l2cap, u_int16_t scid, int idtype)
383{
384 ng_l2cap_chan_p ch = NULL;
385
386 if((idtype == NG_L2CAP_L2CA_IDTYPE_ATT)||
387 (idtype == NG_L2CAP_L2CA_IDTYPE_SMP)){
388 return NULL;
389 }
390
391 LIST_FOREACH(ch, &l2cap->chan_list, next){
392 if((idtype != NG_L2CAP_L2CA_IDTYPE_BREDR)&&
393 (ch->con->linktype == NG_HCI_LINK_ACL ))
394 continue;
395 if((idtype != NG_L2CAP_L2CA_IDTYPE_LE)&&
396 (ch->con->linktype != NG_HCI_LINK_ACL ))
397 continue;
398 if (ch->scid == scid)
399 break;
400 }
401 return (ch);
402} /* ng_l2cap_chan_by_scid */
403
406 u_int16_t con_handle)
407{
408 ng_l2cap_chan_p ch = NULL;
409
410 LIST_FOREACH(ch, &l2cap->chan_list, next){
411 if ((ch->scid == scid) &&
412 (ch->con->con_handle == con_handle))
413 break;
414 }
415 return (ch);
416} /* ng_l2cap_chan_by_scid */
417
418/*
419 * Free channel descriptor.
420 */
421
422void
424{
425 ng_l2cap_cmd_p f = NULL, n = NULL;
426
427 f = TAILQ_FIRST(&ch->con->cmd_list);
428
429 while (f != NULL) {
430 n = TAILQ_NEXT(f, next);
431
432 if (f->ch == ch) {
437 }
438
439 f = n;
440 }
441
442 LIST_REMOVE(ch, next);
443
445
446 bzero(ch, sizeof(*ch));
447 free(ch, M_NETGRAPH_L2CAP);
448} /* ng_l2cap_free_chan */
449
450/*
451 * Create new L2CAP command descriptor. WILL NOT add command to the queue.
452 */
453
456 u_int8_t code, u_int32_t token)
457{
458 ng_l2cap_cmd_p cmd = NULL;
459
460 KASSERT((ch == NULL || ch->con == con),
461("%s: %s - invalid channel pointer!\n",
462 __func__, NG_NODE_NAME(con->l2cap->node)));
463
464 cmd = malloc(sizeof(*cmd), M_NETGRAPH_L2CAP,
465 M_NOWAIT|M_ZERO);
466 if (cmd == NULL)
467 return (NULL);
468
469 cmd->con = con;
470 cmd->ch = ch;
471 cmd->ident = ident;
472 cmd->code = code;
473 cmd->token = token;
474 ng_callout_init(&cmd->timo);
475
476 return (cmd);
477} /* ng_l2cap_new_cmd */
478
479/*
480 * Get pending (i.e. initiated by local side) L2CAP command descriptor by ident
481 */
482
485{
486 ng_l2cap_cmd_p cmd = NULL;
487
488 TAILQ_FOREACH(cmd, &con->cmd_list, next) {
489 if ((cmd->flags & NG_L2CAP_CMD_PENDING) && cmd->ident == ident) {
490 KASSERT((cmd->con == con),
491("%s: %s - invalid connection pointer!\n",
492 __func__, NG_NODE_NAME(con->l2cap->node)));
493
494 break;
495 }
496 }
497
498 return (cmd);
499} /* ng_l2cap_cmd_by_ident */
500
501/*
502 * Set LP timeout
503 * XXX FIXME: check return code from ng_callout
504 */
505
506int
508{
510 panic(
511"%s: %s - invalid timeout, state=%d, flags=%#x\n",
512 __func__, NG_NODE_NAME(con->l2cap->node),
513 con->state, con->flags);
514
516 ng_callout(&con->con_timo, con->l2cap->node, NULL,
519 con->con_handle);
520
521 return (0);
522} /* ng_l2cap_lp_timeout */
523
524/*
525 * Unset LP timeout
526 */
527
528int
530{
531 if (!(con->flags & NG_L2CAP_CON_LP_TIMO))
532 panic(
533"%s: %s - no LP connection timeout, state=%d, flags=%#x\n",
534 __func__, NG_NODE_NAME(con->l2cap->node),
535 con->state, con->flags);
536
537 if (ng_uncallout(&con->con_timo, con->l2cap->node) < 1)
538 return (ETIMEDOUT);
539
540 con->flags &= ~NG_L2CAP_CON_LP_TIMO;
541
542 return (0);
543} /* ng_l2cap_lp_untimeout */
544
545/*
546 * Set L2CAP command timeout
547 * XXX FIXME: check return code from ng_callout
548 */
549
550int
552{
553 int arg;
554
555 if (cmd->flags & NG_L2CAP_CMD_PENDING)
556 panic(
557"%s: %s - duplicated command timeout, code=%#x, flags=%#x\n",
558 __func__, NG_NODE_NAME(cmd->con->l2cap->node),
559 cmd->code, cmd->flags);
560
561 arg = ((cmd->ident << 16) | cmd->con->con_handle);
562 cmd->flags |= NG_L2CAP_CMD_PENDING;
563 ng_callout(&cmd->timo, cmd->con->l2cap->node, NULL, timo,
565
566 return (0);
567} /* ng_l2cap_command_timeout */
568
569/*
570 * Unset L2CAP command timeout
571 */
572
573int
575{
576 if (!(cmd->flags & NG_L2CAP_CMD_PENDING))
577 panic(
578"%s: %s - no command timeout, code=%#x, flags=%#x\n",
579 __func__, NG_NODE_NAME(cmd->con->l2cap->node),
580 cmd->code, cmd->flags);
581
582 if (ng_uncallout(&cmd->timo, cmd->con->l2cap->node) < 1)
583 return (ETIMEDOUT);
584
585 cmd->flags &= ~NG_L2CAP_CMD_PENDING;
586
587 return (0);
588} /* ng_l2cap_command_untimeout */
589
590/*
591 * Prepend "m"buf with "size" bytes
592 */
593
594struct mbuf *
595ng_l2cap_prepend(struct mbuf *m, int size)
596{
597 M_PREPEND(m, size, M_NOWAIT);
598 if (m == NULL || (m->m_len < size && (m = m_pullup(m, size)) == NULL))
599 return (NULL);
600
601 return (m);
602} /* ng_l2cap_prepend */
603
604/*
605 * Default flow settings
606 */
607
610{
611 static ng_l2cap_flow_t default_flow = {
612 /* flags */ 0x0,
613 /* service_type */ NG_HCI_SERVICE_TYPE_BEST_EFFORT,
614 /* token_rate */ 0xffffffff, /* maximum */
615 /* token_bucket_size */ 0xffffffff, /* maximum */
616 /* peak_bandwidth */ 0x00000000, /* maximum */
617 /* latency */ 0xffffffff, /* don't care */
618 /* delay_variation */ 0xffffffff /* don't care */
619 };
620
621 return (&default_flow);
622} /* ng_l2cap_default_flow */
623
624/*
625 * Get next available channel ID
626 * XXX FIXME this is *UGLY* but will do for now
627 */
628
629static u_int16_t
631{
632 u_int16_t cid ;
633 u_int16_t endcid;
634 uint16_t mask;
635 int idtype;
636 if(isle){
637 endcid = l2cap->lecid;
638 /*Assume Last CID is 2^n-1 */
639 mask = NG_L2CAP_LELAST_CID;
641 }else{
642 endcid = l2cap->cid;
643 /*Assume Last CID is 2^n-1 */
644 mask = NG_L2CAP_LAST_CID;
646 }
647 cid = (endcid+1) & mask;
648
649 if (cid < NG_L2CAP_FIRST_CID)
650 cid = NG_L2CAP_FIRST_CID;
651
652 while (cid != endcid) {
653 if (ng_l2cap_chan_by_scid(l2cap, cid, idtype) == NULL) {
654 if(!isle){
655 l2cap->cid = cid;
656 }else{
657 l2cap->lecid = cid;
658 }
659 return (cid);
660 }
661
662 cid ++;
663 cid &= mask;
664 if (cid < NG_L2CAP_FIRST_CID)
665 cid = NG_L2CAP_FIRST_CID;
666 }
667
668 return (NG_L2CAP_NULL_CID);
669} /* ng_l2cap_get_cid */
670
671/*
672 * Get next available command ident
673 * XXX FIXME this is *UGLY* but will do for now
674 */
675
676u_int8_t
678{
679 u_int8_t ident = con->ident + 1;
680
681 if (ident < NG_L2CAP_FIRST_IDENT)
682 ident = NG_L2CAP_FIRST_IDENT;
683
684 while (ident != con->ident) {
685 if (ng_l2cap_cmd_by_ident(con, ident) == NULL) {
686 con->ident = ident;
687
688 return (ident);
689 }
690
691 ident ++;
692 if (ident < NG_L2CAP_FIRST_IDENT)
693 ident = NG_L2CAP_FIRST_IDENT;
694 }
695
696 return (NG_L2CAP_NULL_IDENT);
697} /* ng_l2cap_get_ident */
#define NG_FREE_M(m)
Definition: netgraph.h:946
#define NG_HOOK_NOT_VALID(hook)
Definition: netgraph.h:337
#define NG_NODE_NOT_VALID(node)
Definition: netgraph.h:611
#define NG_NODE_NAME(node)
Definition: netgraph.h:603
#define ng_callout_init(c)
Definition: netgraph.h:1168
int ng_uncallout(struct callout *c, node_p node)
Definition: ng_base.c:3840
#define NG_HOOK_NAME(hook)
Definition: netgraph.h:331
#define NG_NODE_PRIVATE(node)
Definition: netgraph.h:609
#define NG_SEND_MSG_HOOK(error, here, msg, hook, retaddr)
Definition: netgraph.h:958
int ng_callout(struct callout *c, node_p node, hook_p hook, int ticks, ng_item_fn *fn, void *arg1, int arg2)
Definition: ng_base.c:3789
u_int32_t bluetooth_hci_connect_timeout(void)
Definition: ng_bluetooth.c:191
u_int8_t type
#define NG_HCI_BDADDR_ANY
Definition: ng_hci.h:450
bdaddr_t * bdaddr_p
Definition: ng_hci.h:447
#define NG_HCI_LINK_ACL
Definition: ng_hci.h:121
#define NG_HCI_SERVICE_TYPE_BEST_EFFORT
Definition: ng_hci.h:215
#define NG_L2CAP_CLOSED
Definition: ng_l2cap.h:624
ng_l2cap_flow_t * ng_l2cap_flow_p
Definition: ng_l2cap.h:164
#define NG_L2CAP_CON_LP_TIMO
Definition: ng_l2cap.h:666
#define NG_L2CAP_SMP_CID
Definition: ng_l2cap.h:81
#define NG_L2CAP_L2CA_IDTYPE_LE
Definition: ng_l2cap.h:361
#define NG_L2CAP_L2CA_IDTYPE_BREDR
Definition: ng_l2cap.h:359
#define NG_L2CAP_L2CA_IDTYPE_SMP
Definition: ng_l2cap.h:362
#define NG_L2CAP_NULL_CID
Definition: ng_l2cap.h:75
#define NG_L2CAP_FLUSH_TIMO_DEFAULT
Definition: ng_l2cap.h:94
#define NG_L2CAP_ATT_CID
Definition: ng_l2cap.h:79
#define NG_L2CAP_LELAST_CID
Definition: ng_l2cap.h:85
#define NG_L2CAP_CON_AUTO_DISCON_TIMO
Definition: ng_l2cap.h:667
#define NGM_L2CAP_COOKIE
Definition: ng_l2cap.h:60
#define NG_L2CAP_CON_OUTGOING
Definition: ng_l2cap.h:665
#define NG_L2CAP_CON_OPEN
Definition: ng_l2cap.h:621
#define NG_L2CAP_CON_DYING
Definition: ng_l2cap.h:668
#define NG_L2CAP_MTU_DEFAULT
Definition: ng_l2cap.h:90
#define NG_L2CAP_L2CA_IDTYPE_ATT
Definition: ng_l2cap.h:360
#define NG_L2CAP_CON_CLOSED
Definition: ng_l2cap.h:619
#define NG_L2CAP_LAST_CID
Definition: ng_l2cap.h:84
u_int16_t scid
Definition: ng_l2cap.h:0
#define NG_L2CAP_LINK_TIMO_DEFAULT
Definition: ng_l2cap.h:95
#define NGM_L2CAP_NODE_HOOK_INFO
Definition: ng_l2cap.h:652
#define NG_L2CAP_FIRST_CID
Definition: ng_l2cap.h:83
void ng_l2cap_process_command_timeout(node_p node, hook_p hook, void *arg1, int arg2)
void ng_l2cap_process_discon_timeout(node_p node, hook_p hook, void *arg1, int con_handle)
void ng_l2cap_process_lp_timeout(node_p node, hook_p hook, void *arg1, int con_handle)
#define M_NETGRAPH_L2CAP
Definition: ng_l2cap_main.c:67
void ng_l2cap_free_con(ng_l2cap_con_p con)
int ng_l2cap_discon_timeout(ng_l2cap_con_p con)
ng_l2cap_cmd_p ng_l2cap_cmd_by_ident(ng_l2cap_con_p con, u_int8_t ident)
void ng_l2cap_free_chan(ng_l2cap_chan_p ch)
u_int8_t ng_l2cap_get_ident(ng_l2cap_con_p con)
void ng_l2cap_con_ref(ng_l2cap_con_p con)
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
ng_l2cap_con_p ng_l2cap_con_by_addr(ng_l2cap_p l2cap, bdaddr_p bdaddr, unsigned int type)
int ng_l2cap_discon_untimeout(ng_l2cap_con_p con)
int ng_l2cap_lp_timeout(ng_l2cap_con_p con)
ng_l2cap_con_p ng_l2cap_new_con(ng_l2cap_p l2cap, bdaddr_p bdaddr, int type)
int ng_l2cap_command_untimeout(ng_l2cap_cmd_p cmd)
void ng_l2cap_con_unref(ng_l2cap_con_p con)
int ng_l2cap_lp_untimeout(ng_l2cap_con_p con)
int ng_l2cap_command_timeout(ng_l2cap_cmd_p cmd, int timo)
static u_int16_t ng_l2cap_get_cid(ng_l2cap_p, int)
struct mbuf * ng_l2cap_prepend(struct mbuf *m, int size)
ng_l2cap_flow_p ng_l2cap_default_flow(void)
ng_l2cap_cmd_p ng_l2cap_new_cmd(ng_l2cap_con_p con, ng_l2cap_chan_p ch, u_int8_t ident, u_int8_t code, u_int32_t token)
ng_l2cap_chan_p ng_l2cap_chan_by_conhandle(ng_l2cap_p l2cap, uint16_t scid, u_int16_t con_handle)
ng_l2cap_chan_p ng_l2cap_new_chan(ng_l2cap_p l2cap, ng_l2cap_con_p con, u_int16_t psm, int idtype)
ng_l2cap_chan_p ng_l2cap_chan_by_scid(ng_l2cap_p l2cap, u_int16_t scid, int idtype)
#define ng_l2cap_unlink_cmd(cmd)
Definition: ng_l2cap_misc.h:72
#define ng_l2cap_free_cmd(cmd)
Definition: ng_l2cap_misc.h:78
ng_l2cap_t * ng_l2cap_p
Definition: ng_l2cap_var.h:102
#define NG_L2CAP_INFO
Definition: ng_l2cap_var.h:50
#define NG_L2CAP_FIRST_IDENT
Definition: ng_l2cap_var.h:70
#define NG_L2CAP_NULL_IDENT
Definition: ng_l2cap_var.h:69
#define NG_L2CAP_CMD_PENDING
Definition: ng_l2cap_var.h:181
#define NG_MKMESSAGE(msg, cookie, cmdid, len, how)
Definition: ng_message.h:378
cmd
Definition: ng_pppoe.h:74
u_int16_t dcid
Definition: ng_l2cap_var.h:156
u_int16_t link_timo
Definition: ng_l2cap_var.h:166
u_int16_t flush_timo
Definition: ng_l2cap_var.h:165
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
uint16_t idtype
Definition: ng_l2cap_var.h:158
ng_l2cap_con_p con
Definition: ng_l2cap_var.h:143
ng_l2cap_flow_t oflow
Definition: ng_l2cap_var.h:163
ng_l2cap_flow_t iflow
Definition: ng_l2cap_var.h:160
u_int16_t omtu
Definition: ng_l2cap_var.h:162
u_int8_t ident
Definition: ng_l2cap_var.h:152
ng_l2cap_chan_p ch
Definition: ng_l2cap_var.h:178
u_int16_t flags
Definition: ng_l2cap_var.h:180
uint8_t linktype
Definition: ng_l2cap_var.h:123
struct callout con_timo
Definition: ng_l2cap_var.h:120
struct mbuf * rx_pkt
Definition: ng_l2cap_var.h:131
bdaddr_t remote
Definition: ng_l2cap_var.h:118
u_int8_t ident
Definition: ng_l2cap_var.h:122
ng_l2cap_p l2cap
Definition: ng_l2cap_var.h:111
u_int16_t con_handle
Definition: ng_l2cap_var.h:119
u_int16_t state
Definition: ng_l2cap_var.h:113
int32_t refcnt
Definition: ng_l2cap_var.h:116
struct mbuf * tx_pkt
Definition: ng_l2cap_var.h:128
uint8_t encryption
Definition: ng_l2cap_var.h:124
u_int16_t flags
Definition: ng_l2cap_var.h:114
hook_p hci
Definition: ng_l2cap_var.h:91
node_p node
Definition: ng_l2cap_var.h:81
u_int16_t lecid
Definition: ng_l2cap_var.h:98
bdaddr_t bdaddr
Definition: ng_l2cap_var.h:89
u_int16_t cid
Definition: ng_l2cap_var.h:97
ng_l2cap_node_auto_discon_ep discon_timo
Definition: ng_l2cap_var.h:85
char data[]
Definition: ng_message.h:69