1b06ebda0SMatthew Dillon /* 2b06ebda0SMatthew Dillon * ng_l2cap_misc.h 3b06ebda0SMatthew Dillon */ 4b06ebda0SMatthew Dillon 5b06ebda0SMatthew Dillon /*- 6b06ebda0SMatthew Dillon * Copyright (c) Maksim Yevmenkin <m_evmenkin@yahoo.com> 7b06ebda0SMatthew Dillon * All rights reserved. 8b06ebda0SMatthew Dillon * 9b06ebda0SMatthew Dillon * Redistribution and use in source and binary forms, with or without 10b06ebda0SMatthew Dillon * modification, are permitted provided that the following conditions 11b06ebda0SMatthew Dillon * are met: 12b06ebda0SMatthew Dillon * 1. Redistributions of source code must retain the above copyright 13b06ebda0SMatthew Dillon * notice, this list of conditions and the following disclaimer. 14b06ebda0SMatthew Dillon * 2. Redistributions in binary form must reproduce the above copyright 15b06ebda0SMatthew Dillon * notice, this list of conditions and the following disclaimer in the 16b06ebda0SMatthew Dillon * documentation and/or other materials provided with the distribution. 17b06ebda0SMatthew Dillon * 18b06ebda0SMatthew Dillon * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19b06ebda0SMatthew Dillon * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20b06ebda0SMatthew Dillon * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21b06ebda0SMatthew Dillon * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22b06ebda0SMatthew Dillon * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23b06ebda0SMatthew Dillon * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24b06ebda0SMatthew Dillon * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25b06ebda0SMatthew Dillon * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26b06ebda0SMatthew Dillon * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27b06ebda0SMatthew Dillon * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28b06ebda0SMatthew Dillon * SUCH DAMAGE. 29b06ebda0SMatthew Dillon * 30b06ebda0SMatthew Dillon * $Id: ng_l2cap_misc.h,v 1.3 2003/09/08 19:11:45 max Exp $ 31b06ebda0SMatthew Dillon * $FreeBSD: src/sys/netgraph/bluetooth/l2cap/ng_l2cap_misc.h,v 1.6 2005/08/21 19:15:14 pjd Exp $ 32b06ebda0SMatthew Dillon */ 33b06ebda0SMatthew Dillon 34b06ebda0SMatthew Dillon #ifndef _NETGRAPH_L2CAP_MISC_H_ 35b06ebda0SMatthew Dillon #define _NETGRAPH_L2CAP_MISC_H_ 36b06ebda0SMatthew Dillon 37b06ebda0SMatthew Dillon void ng_l2cap_send_hook_info (node_p, hook_p, void *, int); 38b06ebda0SMatthew Dillon 39b06ebda0SMatthew Dillon /* 40b06ebda0SMatthew Dillon * ACL Connections 41b06ebda0SMatthew Dillon */ 42b06ebda0SMatthew Dillon 43b06ebda0SMatthew Dillon ng_l2cap_con_p ng_l2cap_new_con (ng_l2cap_p, bdaddr_p); 44b06ebda0SMatthew Dillon void ng_l2cap_con_ref (ng_l2cap_con_p); 45b06ebda0SMatthew Dillon void ng_l2cap_con_unref (ng_l2cap_con_p); 46b06ebda0SMatthew Dillon ng_l2cap_con_p ng_l2cap_con_by_addr (ng_l2cap_p, bdaddr_p); 47b06ebda0SMatthew Dillon ng_l2cap_con_p ng_l2cap_con_by_handle (ng_l2cap_p, u_int16_t); 48b06ebda0SMatthew Dillon void ng_l2cap_free_con (ng_l2cap_con_p); 49b06ebda0SMatthew Dillon 50b06ebda0SMatthew Dillon /* 51b06ebda0SMatthew Dillon * L2CAP channels 52b06ebda0SMatthew Dillon */ 53b06ebda0SMatthew Dillon 54b06ebda0SMatthew Dillon ng_l2cap_chan_p ng_l2cap_new_chan (ng_l2cap_p, ng_l2cap_con_p, u_int16_t); 55b06ebda0SMatthew Dillon ng_l2cap_chan_p ng_l2cap_chan_by_scid (ng_l2cap_p, u_int16_t); 56b06ebda0SMatthew Dillon void ng_l2cap_free_chan (ng_l2cap_chan_p); 57b06ebda0SMatthew Dillon 58b06ebda0SMatthew Dillon /* 59b06ebda0SMatthew Dillon * L2CAP command descriptors 60b06ebda0SMatthew Dillon */ 61b06ebda0SMatthew Dillon 62b06ebda0SMatthew Dillon #define ng_l2cap_link_cmd(con, cmd) \ 63b06ebda0SMatthew Dillon do { \ 64b06ebda0SMatthew Dillon TAILQ_INSERT_TAIL(&(con)->cmd_list, (cmd), next); \ 65b06ebda0SMatthew Dillon ng_l2cap_con_ref((con)); \ 66b06ebda0SMatthew Dillon } while (0) 67b06ebda0SMatthew Dillon 68b06ebda0SMatthew Dillon #define ng_l2cap_unlink_cmd(cmd) \ 69b06ebda0SMatthew Dillon do { \ 70b06ebda0SMatthew Dillon TAILQ_REMOVE(&((cmd)->con->cmd_list), (cmd), next); \ 71b06ebda0SMatthew Dillon ng_l2cap_con_unref((cmd)->con); \ 72b06ebda0SMatthew Dillon } while (0) 73b06ebda0SMatthew Dillon 74b06ebda0SMatthew Dillon #define ng_l2cap_free_cmd(cmd) \ 75b06ebda0SMatthew Dillon do { \ 76b06ebda0SMatthew Dillon KASSERT(!callout_pending(&(cmd)->timo), ("Pending callout!")); \ 77b06ebda0SMatthew Dillon NG_FREE_M((cmd)->aux); \ 78b06ebda0SMatthew Dillon bzero((cmd), sizeof(*(cmd))); \ 79*fc025606SSascha Wildner kfree((cmd), M_NETGRAPH_L2CAP); \ 80b06ebda0SMatthew Dillon } while (0) 81b06ebda0SMatthew Dillon 82b06ebda0SMatthew Dillon ng_l2cap_cmd_p ng_l2cap_new_cmd (ng_l2cap_con_p, ng_l2cap_chan_p, 83b06ebda0SMatthew Dillon u_int8_t, u_int8_t, u_int32_t); 84b06ebda0SMatthew Dillon ng_l2cap_cmd_p ng_l2cap_cmd_by_ident (ng_l2cap_con_p, u_int8_t); 85b06ebda0SMatthew Dillon u_int8_t ng_l2cap_get_ident (ng_l2cap_con_p); 86b06ebda0SMatthew Dillon 87b06ebda0SMatthew Dillon /* 88b06ebda0SMatthew Dillon * Timeout 89b06ebda0SMatthew Dillon */ 90b06ebda0SMatthew Dillon 91b06ebda0SMatthew Dillon int ng_l2cap_discon_timeout (ng_l2cap_con_p); 92b06ebda0SMatthew Dillon int ng_l2cap_discon_untimeout (ng_l2cap_con_p); 93b06ebda0SMatthew Dillon int ng_l2cap_lp_timeout (ng_l2cap_con_p); 94b06ebda0SMatthew Dillon int ng_l2cap_lp_untimeout (ng_l2cap_con_p); 95b06ebda0SMatthew Dillon int ng_l2cap_command_timeout (ng_l2cap_cmd_p, int); 96b06ebda0SMatthew Dillon int ng_l2cap_command_untimeout (ng_l2cap_cmd_p); 97b06ebda0SMatthew Dillon 98b06ebda0SMatthew Dillon /* 99b06ebda0SMatthew Dillon * Other stuff 100b06ebda0SMatthew Dillon */ 101b06ebda0SMatthew Dillon 102b06ebda0SMatthew Dillon struct mbuf * ng_l2cap_prepend (struct mbuf *, int); 103b06ebda0SMatthew Dillon ng_l2cap_flow_p ng_l2cap_default_flow (void); 104b06ebda0SMatthew Dillon 105b06ebda0SMatthew Dillon #endif /* ndef _NETGRAPH_L2CAP_MISC_H_ */ 106b06ebda0SMatthew Dillon 107