Deleted Added
full compact
ng_hci_misc.c (137163) ng_hci_misc.c (138268)
1/*
2 * ng_hci_misc.c
3 *
4 * Copyright (c) Maksim Yevmenkin <m_evmenkin@yahoo.com>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 12 unchanged lines hidden (view full) ---

21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 * $Id: ng_hci_misc.c,v 1.5 2003/09/08 18:57:51 max Exp $
1/*
2 * ng_hci_misc.c
3 *
4 * Copyright (c) Maksim Yevmenkin <m_evmenkin@yahoo.com>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 12 unchanged lines hidden (view full) ---

21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 * $Id: ng_hci_misc.c,v 1.5 2003/09/08 18:57:51 max Exp $
29 * $FreeBSD: head/sys/netgraph/bluetooth/hci/ng_hci_misc.c 137163 2004-11-03 18:00:49Z emax $
29 * $FreeBSD: head/sys/netgraph/bluetooth/hci/ng_hci_misc.c 138268 2004-12-01 11:56:32Z glebius $
30 */
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/kernel.h>
35#include <sys/malloc.h>
36#include <sys/mbuf.h>
37#include <sys/queue.h>

--- 314 unchanged lines hidden (view full) ---

352 bcmp(&con->bdaddr, bdaddr, sizeof(bdaddr_t)) == 0)
353 break;
354
355 return (con);
356} /* ng_hci_con_by_bdaddr */
357
358/*
359 * Set HCI command timeout
30 */
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/kernel.h>
35#include <sys/malloc.h>
36#include <sys/mbuf.h>
37#include <sys/queue.h>

--- 314 unchanged lines hidden (view full) ---

352 bcmp(&con->bdaddr, bdaddr, sizeof(bdaddr_t)) == 0)
353 break;
354
355 return (con);
356} /* ng_hci_con_by_bdaddr */
357
358/*
359 * Set HCI command timeout
360 * XXX FIXME: check return code from ng_timeout
360 * XXX FIXME: check return code from ng_callout
361 */
362
363int
364ng_hci_command_timeout(ng_hci_unit_p unit)
365{
366 if (unit->state & NG_HCI_UNIT_COMMAND_PENDING)
367 panic(
368"%s: %s - Duplicated command timeout!\n", __func__, NG_NODE_NAME(unit->node));
369
370 unit->state |= NG_HCI_UNIT_COMMAND_PENDING;
361 */
362
363int
364ng_hci_command_timeout(ng_hci_unit_p unit)
365{
366 if (unit->state & NG_HCI_UNIT_COMMAND_PENDING)
367 panic(
368"%s: %s - Duplicated command timeout!\n", __func__, NG_NODE_NAME(unit->node));
369
370 unit->state |= NG_HCI_UNIT_COMMAND_PENDING;
371 ng_timeout(&unit->cmd_timo, unit->node, NULL,
371 ng_callout(&unit->cmd_timo, unit->node, NULL,
372 bluetooth_hci_command_timeout(),
373 ng_hci_process_command_timeout, NULL, 0);
374
375 return (0);
376} /* ng_hci_command_timeout */
377
378/*
379 * Unset HCI command timeout
380 */
381
382int
383ng_hci_command_untimeout(ng_hci_unit_p unit)
384{
385 if (!(unit->state & NG_HCI_UNIT_COMMAND_PENDING))
386 panic(
387"%s: %s - No command timeout!\n", __func__, NG_NODE_NAME(unit->node));
388
372 bluetooth_hci_command_timeout(),
373 ng_hci_process_command_timeout, NULL, 0);
374
375 return (0);
376} /* ng_hci_command_timeout */
377
378/*
379 * Unset HCI command timeout
380 */
381
382int
383ng_hci_command_untimeout(ng_hci_unit_p unit)
384{
385 if (!(unit->state & NG_HCI_UNIT_COMMAND_PENDING))
386 panic(
387"%s: %s - No command timeout!\n", __func__, NG_NODE_NAME(unit->node));
388
389 if (ng_untimeout(&unit->cmd_timo, unit->node) == 0)
389 if (ng_uncallout(&unit->cmd_timo, unit->node) == 0)
390 return (ETIMEDOUT);
391
392 unit->state &= ~NG_HCI_UNIT_COMMAND_PENDING;
393
394 return (0);
395} /* ng_hci_command_untimeout */
396
397/*
398 * Set HCI connection timeout
390 return (ETIMEDOUT);
391
392 unit->state &= ~NG_HCI_UNIT_COMMAND_PENDING;
393
394 return (0);
395} /* ng_hci_command_untimeout */
396
397/*
398 * Set HCI connection timeout
399 * XXX FIXME: check return code from ng_timeout
399 * XXX FIXME: check return code from ng_callout
400 */
401
402int
403ng_hci_con_timeout(ng_hci_unit_con_p con)
404{
405 if (con->flags & NG_HCI_CON_TIMEOUT_PENDING)
406 panic(
407"%s: %s - Duplicated connection timeout!\n",
408 __func__, NG_NODE_NAME(con->unit->node));
409
410 con->flags |= NG_HCI_CON_TIMEOUT_PENDING;
400 */
401
402int
403ng_hci_con_timeout(ng_hci_unit_con_p con)
404{
405 if (con->flags & NG_HCI_CON_TIMEOUT_PENDING)
406 panic(
407"%s: %s - Duplicated connection timeout!\n",
408 __func__, NG_NODE_NAME(con->unit->node));
409
410 con->flags |= NG_HCI_CON_TIMEOUT_PENDING;
411 ng_timeout(&con->con_timo, con->unit->node, NULL,
411 ng_callout(&con->con_timo, con->unit->node, NULL,
412 bluetooth_hci_connect_timeout(),
413 ng_hci_process_con_timeout, NULL,
414 con->con_handle);
415
416 return (0);
417} /* ng_hci_con_timeout */
418
419/*
420 * Unset HCI connection timeout
421 */
422
423int
424ng_hci_con_untimeout(ng_hci_unit_con_p con)
425{
426 if (!(con->flags & NG_HCI_CON_TIMEOUT_PENDING))
427 panic(
428"%s: %s - No connection timeout!\n", __func__, NG_NODE_NAME(con->unit->node));
429
412 bluetooth_hci_connect_timeout(),
413 ng_hci_process_con_timeout, NULL,
414 con->con_handle);
415
416 return (0);
417} /* ng_hci_con_timeout */
418
419/*
420 * Unset HCI connection timeout
421 */
422
423int
424ng_hci_con_untimeout(ng_hci_unit_con_p con)
425{
426 if (!(con->flags & NG_HCI_CON_TIMEOUT_PENDING))
427 panic(
428"%s: %s - No connection timeout!\n", __func__, NG_NODE_NAME(con->unit->node));
429
430 if (ng_untimeout(&con->con_timo, con->unit->node) == 0)
430 if (ng_uncallout(&con->con_timo, con->unit->node) == 0)
431 return (ETIMEDOUT);
432
433 con->flags &= ~NG_HCI_CON_TIMEOUT_PENDING;
434
435 return (0);
436} /* ng_hci_con_untimeout */
437
438#if 0

--- 58 unchanged lines hidden ---
431 return (ETIMEDOUT);
432
433 con->flags &= ~NG_HCI_CON_TIMEOUT_PENDING;
434
435 return (0);
436} /* ng_hci_con_untimeout */
437
438#if 0

--- 58 unchanged lines hidden ---