diff options
author | julian <julian@FreeBSD.org> | 2003-05-10 21:44:42 +0000 |
---|---|---|
committer | julian <julian@FreeBSD.org> | 2003-05-10 21:44:42 +0000 |
commit | dc5734d94b071df224b65d45b95d9ae7c5d563ab (patch) | |
tree | ed7d8caf163274b56933e0b801c52beb10b3260d /sys/netgraph/bluetooth/include | |
parent | 9e09746efa5431d5af0baf849575917d37cfdb76 (diff) | |
download | FreeBSD-src-dc5734d94b071df224b65d45b95d9ae7c5d563ab.zip FreeBSD-src-dc5734d94b071df224b65d45b95d9ae7c5d563ab.tar.gz |
Part one of undating the bluetooth code to the newest version
Submitted by: Maksim Yevmenkin <m_evmenkin@yahoo.com>
Approved by: re@
Diffstat (limited to 'sys/netgraph/bluetooth/include')
-rw-r--r-- | sys/netgraph/bluetooth/include/ng_bluetooth.h | 6 | ||||
-rw-r--r-- | sys/netgraph/bluetooth/include/ng_bt3c.h | 2 | ||||
-rw-r--r-- | sys/netgraph/bluetooth/include/ng_btsocket.h | 92 | ||||
-rw-r--r-- | sys/netgraph/bluetooth/include/ng_btsocket_hci_raw.h | 6 | ||||
-rw-r--r-- | sys/netgraph/bluetooth/include/ng_btsocket_l2cap.h | 10 | ||||
-rw-r--r-- | sys/netgraph/bluetooth/include/ng_btsocket_rfcomm.h | 337 | ||||
-rw-r--r-- | sys/netgraph/bluetooth/include/ng_h4.h | 2 | ||||
-rw-r--r-- | sys/netgraph/bluetooth/include/ng_hci.h | 6 | ||||
-rw-r--r-- | sys/netgraph/bluetooth/include/ng_l2cap.h | 17 | ||||
-rw-r--r-- | sys/netgraph/bluetooth/include/ng_ubt.h | 28 |
10 files changed, 434 insertions, 72 deletions
diff --git a/sys/netgraph/bluetooth/include/ng_bluetooth.h b/sys/netgraph/bluetooth/include/ng_bluetooth.h index 238da42..e4b4846 100644 --- a/sys/netgraph/bluetooth/include/ng_bluetooth.h +++ b/sys/netgraph/bluetooth/include/ng_bluetooth.h @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ng_bluetooth.h,v 1.1.1.1 2002/09/04 21:47:41 max Exp $ + * $Id: ng_bluetooth.h,v 1.4 2003/04/26 22:32:34 max Exp $ * $FreeBSD$ */ @@ -47,6 +47,7 @@ SYSCTL_DECL(_net_bluetooth); SYSCTL_DECL(_net_bluetooth_hci); SYSCTL_DECL(_net_bluetooth_l2cap); +SYSCTL_DECL(_net_bluetooth_rfcomm); #endif /* SYSCTL_DECL */ /* @@ -84,7 +85,7 @@ typedef struct ng_bt_mbufq * ng_bt_mbufq_p; #define NG_BT_MBUFQ_LEN(q) (q)->len -#define NG_BT_MBUFQ_FULL(q) (q)->len >= (q)->maxlen +#define NG_BT_MBUFQ_FULL(q) ((q)->len >= (q)->maxlen) #define NG_BT_MBUFQ_DROP(q) (q)->drops ++ @@ -223,7 +224,6 @@ typedef struct ng_bt_itemq * ng_bt_itemq_p; u_int32_t bluetooth_hci_command_timeout (void); u_int32_t bluetooth_hci_connect_timeout (void); -u_int32_t bluetooth_hci_watchdog_timeout (void); u_int32_t bluetooth_hci_max_neighbor_age (void); u_int32_t bluetooth_l2cap_rtx_timeout (void); u_int32_t bluetooth_l2cap_ertx_timeout (void); diff --git a/sys/netgraph/bluetooth/include/ng_bt3c.h b/sys/netgraph/bluetooth/include/ng_bt3c.h index 6030b81..88084a2 100644 --- a/sys/netgraph/bluetooth/include/ng_bt3c.h +++ b/sys/netgraph/bluetooth/include/ng_bt3c.h @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ng_bt3c.h,v 1.2 2002/11/12 00:51:45 max Exp $ + * $Id: ng_bt3c.h,v 1.1 2002/11/24 19:47:05 max Exp $ * $FreeBSD$ * * XXX XXX XX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX diff --git a/sys/netgraph/bluetooth/include/ng_btsocket.h b/sys/netgraph/bluetooth/include/ng_btsocket.h index 5ace3fa..2a133a3 100644 --- a/sys/netgraph/bluetooth/include/ng_btsocket.h +++ b/sys/netgraph/bluetooth/include/ng_btsocket.h @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ng_btsocket.h,v 1.7 2002/11/12 22:31:39 max Exp $ + * $Id: ng_btsocket.h,v 1.8 2003/04/26 22:32:10 max Exp $ * $FreeBSD$ */ @@ -45,6 +45,7 @@ #define BLUETOOTH_PROTO_HCI 134 /* HCI protocol number */ #define BLUETOOTH_PROTO_L2CAP 135 /* L2CAP protocol number */ +#define BLUETOOTH_PROTO_RFCOMM 136 /* RFCOMM protocol number */ /* * XXX FIXME: probably does not belong here @@ -82,7 +83,6 @@ struct ng_btsocket_hci_raw_filter { /* Get state */ struct ng_btsocket_hci_raw_node_state { - char hci_node[16]; ng_hci_node_state_ep state; }; #define SIOC_HCI_RAW_NODE_GET_STATE \ @@ -90,16 +90,11 @@ struct ng_btsocket_hci_raw_node_state { struct ng_btsocket_hci_raw_node_state) /* Initialize */ -struct ng_btsocket_hci_raw_node_init { - char hci_node[16]; -}; #define SIOC_HCI_RAW_NODE_INIT \ - _IOWR('b', NGM_HCI_NODE_INIT, \ - struct ng_btsocket_hci_raw_node_init) + _IO('b', NGM_HCI_NODE_INIT) /* Get/Set debug level */ struct ng_btsocket_hci_raw_node_debug { - char hci_node[16]; ng_hci_node_debug_ep debug; }; #define SIOC_HCI_RAW_NODE_GET_DEBUG \ @@ -111,7 +106,6 @@ struct ng_btsocket_hci_raw_node_debug { /* Get buffer info */ struct ng_btsocket_hci_raw_node_buffer { - char hci_node[16]; ng_hci_node_buffer_ep buffer; }; #define SIOC_HCI_RAW_NODE_GET_BUFFER \ @@ -120,7 +114,6 @@ struct ng_btsocket_hci_raw_node_buffer { /* Get BD_ADDR */ struct ng_btsocket_hci_raw_node_bdaddr { - char hci_node[16]; bdaddr_t bdaddr; }; #define SIOC_HCI_RAW_NODE_GET_BDADDR \ @@ -129,7 +122,6 @@ struct ng_btsocket_hci_raw_node_bdaddr { /* Get features */ struct ng_btsocket_hci_raw_node_features { - char hci_node [16]; u_int8_t features[NG_HCI_FEATURES_SIZE]; }; #define SIOC_HCI_RAW_NODE_GET_FEATURES \ @@ -138,7 +130,6 @@ struct ng_btsocket_hci_raw_node_features { /* Get stat */ struct ng_btsocket_hci_raw_node_stat { - char hci_node[16]; ng_hci_node_stat_ep stat; }; #define SIOC_HCI_RAW_NODE_GET_STAT \ @@ -146,24 +137,15 @@ struct ng_btsocket_hci_raw_node_stat { struct ng_btsocket_hci_raw_node_stat) /* Reset stat */ -struct ng_btsocket_hci_raw_node_reset_stat { - char hci_node[16]; -}; #define SIOC_HCI_RAW_NODE_RESET_STAT \ - _IOWR('b', NGM_HCI_NODE_RESET_STAT, \ - struct ng_btsocket_hci_raw_node_reset_stat) + _IO('b', NGM_HCI_NODE_RESET_STAT) /* Flush neighbor cache */ -struct ng_btsocket_hci_raw_node_flush_neighbor_cache { - char hci_node[16]; -}; #define SIOC_HCI_RAW_NODE_FLUSH_NEIGHBOR_CACHE \ - _IOWR('b', NGM_HCI_NODE_FLUSH_NEIGHBOR_CACHE, \ - struct ng_btsocket_hci_raw_node_flush_neighbor_cache) + _IO('b', NGM_HCI_NODE_FLUSH_NEIGHBOR_CACHE) /* Get neighbor cache */ struct ng_btsocket_hci_raw_node_neighbor_cache { - char hci_node[16]; u_int32_t num_entries; ng_hci_node_neighbor_cache_entry_ep *entries; }; @@ -173,7 +155,6 @@ struct ng_btsocket_hci_raw_node_neighbor_cache { /* Get connection list */ struct ng_btsocket_hci_raw_con_list { - char hci_node[16]; u_int32_t num_connections; ng_hci_node_con_ep *connections; }; @@ -183,7 +164,6 @@ struct ng_btsocket_hci_raw_con_list { /* Get/Set link policy settings mask */ struct ng_btsocket_hci_raw_node_link_policy_mask { - char hci_node[16]; ng_hci_node_link_policy_mask_ep policy_mask; }; #define SIOC_HCI_RAW_NODE_GET_LINK_POLICY_MASK \ @@ -195,7 +175,6 @@ struct ng_btsocket_hci_raw_node_link_policy_mask { /* Get/Set packet mask */ struct ng_btsocket_hci_raw_node_packet_mask { - char hci_node[16]; ng_hci_node_packet_mask_ep packet_mask; }; #define SIOC_HCI_RAW_NODE_GET_PACKET_MASK \ @@ -205,6 +184,17 @@ struct ng_btsocket_hci_raw_node_packet_mask { _IOWR('b', NGM_HCI_NODE_SET_PACKET_MASK, \ struct ng_btsocket_hci_raw_node_packet_mask) +/* Get/Set role switch */ +struct ng_btsocket_hci_raw_node_role_switch { + ng_hci_node_role_switch_ep role_switch; +}; +#define SIOC_HCI_RAW_NODE_GET_ROLE_SWITCH \ + _IOWR('b', NGM_HCI_NODE_GET_ROLE_SWITCH, \ + struct ng_btsocket_hci_raw_node_role_switch) +#define SIOC_HCI_RAW_NODE_SET_ROLE_SWITCH \ + _IOWR('b', NGM_HCI_NODE_SET_ROLE_SWITCH, \ + struct ng_btsocket_hci_raw_node_role_switch) + /* * XXX FIXME: probably does not belong here * Bluetooth version of struct sockaddr for L2CAP sockets (RAW and SEQPACKET) @@ -232,9 +222,6 @@ struct sockaddr_l2cap { /* Ping */ struct ng_btsocket_l2cap_raw_ping { - bdaddr_t bdaddr[2]; -#define echo_src bdaddr[0] -#define echo_dst bdaddr[1] u_int32_t result; u_int32_t echo_size; u_int8_t *echo_data; @@ -245,9 +232,6 @@ struct ng_btsocket_l2cap_raw_ping { /* Get info */ struct ng_btsocket_l2cap_raw_get_info { - bdaddr_t bdaddr[2]; -#define info_src bdaddr[0] -#define info_dst bdaddr[1] u_int32_t result; u_int32_t info_type; u_int32_t info_size; @@ -259,7 +243,6 @@ struct ng_btsocket_l2cap_raw_get_info { /* Get flags */ struct ng_btsocket_l2cap_raw_node_flags { - bdaddr_t src; ng_l2cap_node_flags_ep flags; }; #define SIOC_L2CAP_NODE_GET_FLAGS \ @@ -268,7 +251,6 @@ struct ng_btsocket_l2cap_raw_node_flags { /* Get/Set debug level */ struct ng_btsocket_l2cap_raw_node_debug { - bdaddr_t src; ng_l2cap_node_debug_ep debug; }; #define SIOC_L2CAP_NODE_GET_DEBUG \ @@ -280,7 +262,6 @@ struct ng_btsocket_l2cap_raw_node_debug { /* Get connection list */ struct ng_btsocket_l2cap_raw_con_list { - bdaddr_t src; u_int32_t num_connections; ng_l2cap_node_con_ep *connections; }; @@ -290,7 +271,6 @@ struct ng_btsocket_l2cap_raw_con_list { /* Get channel list */ struct ng_btsocket_l2cap_raw_chan_list { - bdaddr_t src; u_int32_t num_channels; ng_l2cap_node_chan_ep *channels; }; @@ -298,6 +278,46 @@ struct ng_btsocket_l2cap_raw_chan_list { _IOWR('b', NGM_L2CAP_NODE_GET_CHAN_LIST, \ struct ng_btsocket_l2cap_raw_chan_list) +/* Get/Set auto disconnect timeout */ +struct ng_btsocket_l2cap_raw_auto_discon_timo +{ + ng_l2cap_node_auto_discon_ep timeout; +}; +#define SIOC_L2CAP_NODE_GET_AUTO_DISCON_TIMO \ + _IOWR('b', NGM_L2CAP_NODE_GET_AUTO_DISCON_TIMO, \ + struct ng_btsocket_l2cap_raw_auto_discon_timo) +#define SIOC_L2CAP_NODE_SET_AUTO_DISCON_TIMO \ + _IOWR('b', NGM_L2CAP_NODE_SET_AUTO_DISCON_TIMO, \ + struct ng_btsocket_l2cap_raw_auto_discon_timo) + +/* + * XXX FIXME: probably does not belong here + * Bluetooth version of struct sockaddr for RFCOMM sockets (STREAM) + */ + +struct sockaddr_rfcomm { + u_char rfcomm_len; /* total length */ + u_char rfcomm_family; /* address family */ + bdaddr_t rfcomm_bdaddr; /* address */ + u_int8_t rfcomm_channel; /* channel */ +}; + +/* Flow control information */ +struct ng_btsocket_rfcomm_fc_info { + u_int8_t lmodem; /* modem signals (local) */ + u_int8_t rmodem; /* modem signals (remote) */ + u_int8_t tx_cred; /* TX credits */ + u_int8_t rx_cred; /* RX credits */ + u_int8_t cfc; /* credit flow control */ + u_int8_t reserved; +}; + +/* STREAM RFCOMM socket options */ +#define SOL_RFCOMM 0x0816 /* socket options level */ + +#define SO_RFCOMM_MTU 1 /* get channel MTU */ +#define SO_RFCOMM_FC_INFO 2 /* get flow control information */ + /* * Netgraph node type name and cookie */ diff --git a/sys/netgraph/bluetooth/include/ng_btsocket_hci_raw.h b/sys/netgraph/bluetooth/include/ng_btsocket_hci_raw.h index 399e8ac..c3af9e9 100644 --- a/sys/netgraph/bluetooth/include/ng_btsocket_hci_raw.h +++ b/sys/netgraph/bluetooth/include/ng_btsocket_hci_raw.h @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ng_btsocket_hci_raw.h,v 1.2 2002/09/16 19:46:02 max Exp $ + * $Id: ng_btsocket_hci_raw.h,v 1.3 2003/03/25 23:53:32 max Exp $ * $FreeBSD$ */ @@ -41,13 +41,15 @@ struct ng_btsocket_hci_raw_pcb { struct socket *so; /* socket */ - int flags; /* flags */ + u_int32_t flags; /* flags */ #define NG_BTSOCKET_HCI_RAW_DIRECTION (1 << 0) +#define NG_BTSOCKET_HCI_RAW_PRIVILEGED (1 << 1) struct sockaddr_hci addr; /* local address */ struct ng_btsocket_hci_raw_filter filter; /* filter */ u_int32_t token; /* message token */ struct ng_mesg *msg; /* message */ LIST_ENTRY(ng_btsocket_hci_raw_pcb) next; /* link to next */ + struct mtx pcb_mtx; /* pcb mutex */ }; typedef struct ng_btsocket_hci_raw_pcb ng_btsocket_hci_raw_pcb_t; typedef struct ng_btsocket_hci_raw_pcb * ng_btsocket_hci_raw_pcb_p; diff --git a/sys/netgraph/bluetooth/include/ng_btsocket_l2cap.h b/sys/netgraph/bluetooth/include/ng_btsocket_l2cap.h index cfae52e..093b22a 100644 --- a/sys/netgraph/bluetooth/include/ng_btsocket_l2cap.h +++ b/sys/netgraph/bluetooth/include/ng_btsocket_l2cap.h @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ng_btsocket_l2cap.h,v 1.3 2002/09/22 18:23:31 max Exp $ + * $Id: ng_btsocket_l2cap.h,v 1.4 2003/03/25 23:53:33 max Exp $ * $FreeBSD$ */ @@ -42,7 +42,7 @@ struct ng_message; struct ng_btsocket_l2cap_rtentry { bdaddr_t src; /* source BD_ADDR */ struct ng_hook *hook; /* downstream hook */ - LIST_ENTRY(ng_btsocket_l2cap_rtentry) next; /* linkt to next */ + LIST_ENTRY(ng_btsocket_l2cap_rtentry) next; /* link to next */ }; typedef struct ng_btsocket_l2cap_rtentry ng_btsocket_l2cap_rtentry_t; typedef struct ng_btsocket_l2cap_rtentry * ng_btsocket_l2cap_rtentry_p; @@ -63,12 +63,18 @@ typedef struct ng_btsocket_l2cap_rtentry * ng_btsocket_l2cap_rtentry_p; struct ng_btsocket_l2cap_raw_pcb { struct socket *so; /* socket */ + u_int32_t flags; /* flags */ +#define NG_BTSOCKET_L2CAP_RAW_PRIVILEGED (1 << 0) + bdaddr_t src; /* source address */ + bdaddr_t dst; /* dest address */ ng_btsocket_l2cap_rtentry_p rt; /* routing info */ u_int32_t token; /* message token */ struct ng_mesg *msg; /* message */ + struct mtx pcb_mtx; /* pcb mutex */ + LIST_ENTRY(ng_btsocket_l2cap_raw_pcb) next; /* link to next PCB */ }; typedef struct ng_btsocket_l2cap_raw_pcb ng_btsocket_l2cap_raw_pcb_t; diff --git a/sys/netgraph/bluetooth/include/ng_btsocket_rfcomm.h b/sys/netgraph/bluetooth/include/ng_btsocket_rfcomm.h new file mode 100644 index 0000000..21bfb3e --- /dev/null +++ b/sys/netgraph/bluetooth/include/ng_btsocket_rfcomm.h @@ -0,0 +1,337 @@ +/* + * ng_btsocket_rfcomm.h + * + * Copyright (c) 2001-2003 Maksim Yevmenkin <m_evmenkin@yahoo.com> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id: ng_btsocket_rfcomm.h,v 1.10 2003/03/29 22:27:42 max Exp $ + * $FreeBSD$ + */ + +#ifndef _NETGRAPH_BTSOCKET_RFCOMM_H_ +#define _NETGRAPH_BTSOCKET_RFCOMM_H_ 1 + +/***************************************************************************** + ***************************************************************************** + ** RFCOMM ** + ***************************************************************************** + *****************************************************************************/ + +/* XXX FIXME this does not belong here */ + +#define RFCOMM_DEFAULT_MTU 127 +#define RFCOMM_MAX_MTU 1024 + +#define RFCOMM_DEFAULT_CREDITS 7 +#define RFCOMM_MAX_CREDITS 40 + +/* RFCOMM frame types */ +#define RFCOMM_FRAME_SABM 0x2f +#define RFCOMM_FRAME_DISC 0x43 +#define RFCOMM_FRAME_UA 0x63 +#define RFCOMM_FRAME_DM 0x0f +#define RFCOMM_FRAME_UIH 0xef + +/* RFCOMM MCC commands */ +#define RFCOMM_MCC_TEST 0x08 /* Test */ +#define RFCOMM_MCC_FCON 0x28 /* Flow Control on */ +#define RFCOMM_MCC_FCOFF 0x18 /* Flow Control off */ +#define RFCOMM_MCC_MSC 0x38 /* Modem Status Command */ +#define RFCOMM_MCC_RPN 0x24 /* Remote Port Negotiation */ +#define RFCOMM_MCC_RLS 0x14 /* Remote Line Status */ +#define RFCOMM_MCC_PN 0x20 /* Port Negotiation */ +#define RFCOMM_MCC_NSC 0x04 /* Non Supported Command */ + +/* RFCOMM modem signals */ +#define RFCOMM_MODEM_FC 0x02 /* Flow Control asserted */ +#define RFCOMM_MODEM_RTC 0x04 /* Ready To Communicate */ +#define RFCOMM_MODEM_RTR 0x08 /* Ready To Receive */ +#define RFCOMM_MODEM_IC 0x40 /* Incomming Call */ +#define RFCOMM_MODEM_DV 0x80 /* Data Valid */ + +/* RPN parameters - baud rate */ +#define RFCOMM_RPN_BR_2400 0x0 +#define RFCOMM_RPN_BR_4800 0x1 +#define RFCOMM_RPN_BR_7200 0x2 +#define RFCOMM_RPN_BR_9600 0x3 +#define RFCOMM_RPN_BR_19200 0x4 +#define RFCOMM_RPN_BR_38400 0x5 +#define RFCOMM_RPN_BR_57600 0x6 +#define RFCOMM_RPN_BR_115200 0x7 +#define RFCOMM_RPN_BR_230400 0x8 + +/* RPN parameters - data bits */ +#define RFCOMM_RPN_DATA_5 0x0 +#define RFCOMM_RPN_DATA_6 0x1 +#define RFCOMM_RPN_DATA_7 0x2 +#define RFCOMM_RPN_DATA_8 0x3 + +/* RPN parameters - stop bit */ +#define RFCOMM_RPN_STOP_1 0 +#define RFCOMM_RPN_STOP_15 1 + +/* RPN parameters - parity */ +#define RFCOMM_RPN_PARITY_NONE 0x0 +#define RFCOMM_RPN_PARITY_ODD 0x4 +#define RFCOMM_RPN_PARITY_EVEN 0x5 +#define RFCOMM_RPN_PARITY_MARK 0x6 +#define RFCOMM_RPN_PARITY_SPACE 0x7 + +/* RPN parameters - flow control */ +#define RFCOMM_RPN_FLOW_NONE 0x00 +#define RFCOMM_RPN_XON_CHAR 0x11 +#define RFCOMM_RPN_XOFF_CHAR 0x13 + +/* RPN parameters - mask */ +#define RFCOMM_RPN_PM_BITRATE 0x0001 +#define RFCOMM_RPN_PM_DATA 0x0002 +#define RFCOMM_RPN_PM_STOP 0x0004 +#define RFCOMM_RPN_PM_PARITY 0x0008 +#define RFCOMM_RPN_PM_PARITY_TYPE 0x0010 +#define RFCOMM_RPN_PM_XON 0x0020 +#define RFCOMM_RPN_PM_XOFF 0x0040 +#define RFCOMM_RPN_PM_FLOW 0x3F00 +#define RFCOMM_RPN_PM_ALL 0x3F7F + +/* RFCOMM frame header */ +struct rfcomm_frame_hdr +{ + u_int8_t address; + u_int8_t control; + u_int8_t length; /* Actual size could be 2 bytes */ +} __attribute__ ((packed)); + +/* RFCOMM command frame header */ +struct rfcomm_cmd_hdr +{ + u_int8_t address; + u_int8_t control; + u_int8_t length; + u_int8_t fcs; +} __attribute__ ((packed)); + +/* RFCOMM MCC command header */ +struct rfcomm_mcc_hdr +{ + u_int8_t type; + u_int8_t length; /* XXX FIXME Can actual size be 2 bytes?? */ +} __attribute__ ((packed)); + +/* RFCOMM MSC command */ +struct rfcomm_mcc_msc +{ + u_int8_t address; + u_int8_t modem; +} __attribute__ ((packed)); + +/* RFCOMM RPN command */ +struct rfcomm_mcc_rpn +{ + u_int8_t dlci; + u_int8_t bit_rate; + u_int8_t line_settings; + u_int8_t flow_control; + u_int8_t xon_char; + u_int8_t xoff_char; + u_int16_t param_mask; +} __attribute__ ((packed)); + +/* RFCOMM RLS command */ +struct rfcomm_mcc_rls +{ + u_int8_t address; + u_int8_t status; +} __attribute__ ((packed)); + +/* RFCOMM PN command */ +struct rfcomm_mcc_pn +{ + u_int8_t dlci; + u_int8_t flow_control; + u_int8_t priority; + u_int8_t ack_timer; + u_int16_t mtu; + u_int8_t max_retrans; + u_int8_t credits; +} __attribute__ ((packed)); + +/* RFCOMM frame parsing macros */ +#define RFCOMM_DLCI(b) (((b) & 0xfc) >> 2) +#define RFCOMM_CHANNEL(b) (((b) & 0xf8) >> 3) +#define RFCOMM_DIRECTION(b) (((b) & 0x04) >> 2) +#define RFCOMM_TYPE(b) (((b) & 0xef)) + +#define RFCOMM_EA(b) (((b) & 0x01)) +#define RFCOMM_CR(b) (((b) & 0x02) >> 1) +#define RFCOMM_PF(b) (((b) & 0x10) >> 4) + +#define RFCOMM_SRVCHANNEL(dlci) ((dlci) >> 1) + +#define RFCOMM_MKADDRESS(cr, dlci) \ + ((((dlci) & 0x3f) << 2) | ((cr) << 1) | 0x01) + +#define RFCOMM_MKCONTROL(type, pf) ((((type) & 0xef) | ((pf) << 4))) +#define RFCOMM_MKDLCI(dir, channel) ((((channel) & 0x1f) << 1) | (dir)) + +#define RFCOMM_MKLEN8(len) (((len) << 1) | 1) +#define RFCOMM_MKLEN16(len) ((len) << 1) + +/* RFCOMM MCC macros */ +#define RFCOMM_MCC_TYPE(b) (((b) & 0xfc) >> 2) +#define RFCOMM_MCC_LENGTH(b) (((b) & 0xfe) >> 1) +#define RFCOMM_MKMCC_TYPE(cr, type) ((((type) << 2) | ((cr) << 1) | 0x01)) + +/* RPN macros */ +#define RFCOMM_RPN_DATA_BITS(line) ((line) & 0x3) +#define RFCOMM_RPN_STOP_BITS(line) (((line) >> 2) & 0x1) +#define RFCOMM_RPN_PARITY(line) (((line) >> 3) & 0x3) +#define RFCOMM_MKRPN_LINE_SETTINGS(data, stop, parity) \ + (((data) & 0x3) | (((stop) & 0x1) << 2) | (((parity) & 0x3) << 3)) + +/***************************************************************************** + ***************************************************************************** + ** SOCK_STREAM RFCOMM sockets ** + ***************************************************************************** + *****************************************************************************/ + +#define NG_BTSOCKET_RFCOMM_SENDSPACE \ + (RFCOMM_MAX_CREDITS * RFCOMM_DEFAULT_MTU * 10) +#define NG_BTSOCKET_RFCOMM_RECVSPACE \ + (RFCOMM_MAX_CREDITS * RFCOMM_DEFAULT_MTU * 10) + +/* + * Bluetooth RFCOMM session. One L2CAP connection == one RFCOMM session + */ + +struct ng_btsocket_rfcomm_pcb; +struct ng_btsocket_rfcomm_session; + +struct ng_btsocket_rfcomm_session { + struct socket *l2so; /* L2CAP socket */ + + u_int16_t state; /* session state */ +#define NG_BTSOCKET_RFCOMM_SESSION_CLOSED 0 +#define NG_BTSOCKET_RFCOMM_SESSION_LISTENING 1 +#define NG_BTSOCKET_RFCOMM_SESSION_CONNECTING 2 +#define NG_BTSOCKET_RFCOMM_SESSION_CONNECTED 3 +#define NG_BTSOCKET_RFCOMM_SESSION_OPEN 4 +#define NG_BTSOCKET_RFCOMM_SESSION_DISCONNECTING 5 + + u_int16_t flags; /* session flags */ +#define NG_BTSOCKET_RFCOMM_SESSION_INITIATOR (1 << 0) /* initiator */ +#define NG_BTSOCKET_RFCOMM_SESSION_LFC (1 << 1) /* local flow */ +#define NG_BTSOCKET_RFCOMM_SESSION_RFC (1 << 2) /* remote flow */ + +#define INITIATOR(s) \ + (((s)->flags & NG_BTSOCKET_RFCOMM_SESSION_INITIATOR)? 1 : 0) + + u_int16_t mtu; /* default MTU */ + struct ng_bt_mbufq outq; /* outgoing queue */ + + struct mtx session_mtx; /* session lock */ + LIST_HEAD(, ng_btsocket_rfcomm_pcb) dlcs; /* active DLC */ + + LIST_ENTRY(ng_btsocket_rfcomm_session) next; /* link to next */ +}; +typedef struct ng_btsocket_rfcomm_session ng_btsocket_rfcomm_session_t; +typedef struct ng_btsocket_rfcomm_session * ng_btsocket_rfcomm_session_p; + +/* + * Bluetooth RFCOMM socket PCB (DLC) + */ + +struct ng_btsocket_rfcomm_pcb { + struct socket *so; /* RFCOMM socket */ + struct ng_btsocket_rfcomm_session *session; /* RFCOMM session */ + + u_int16_t flags; /* DLC flags */ +#define NG_BTSOCKET_RFCOMM_DLC_TIMO (1 << 0) /* timeout pending */ +#define NG_BTSOCKET_RFCOMM_DLC_CFC (1 << 1) /* credit flow ctrl */ +#define NG_BTSOCKET_RFCOMM_DLC_TIMEDOUT (1 << 2) /* timeout happend */ +#define NG_BTSOCKET_RFCOMM_DLC_DETACHED (1 << 3) /* DLC detached */ +#define NG_BTSOCKET_RFCOMM_DLC_SENDING (1 << 4) /* send pending */ + + u_int16_t state; /* DLC state */ +#define NG_BTSOCKET_RFCOMM_DLC_CLOSED 0 +#define NG_BTSOCKET_RFCOMM_DLC_W4_CONNECT 1 +#define NG_BTSOCKET_RFCOMM_DLC_CONFIGURING 2 +#define NG_BTSOCKET_RFCOMM_DLC_CONNECTING 3 +#define NG_BTSOCKET_RFCOMM_DLC_CONNECTED 4 +#define NG_BTSOCKET_RFCOMM_DLC_DISCONNECTING 5 + + bdaddr_t src; /* source address */ + bdaddr_t dst; /* dest. address */ + + u_int8_t channel; /* RFCOMM channel */ + u_int8_t dlci; /* RFCOMM DLCI */ + + u_int8_t lmodem; /* local mdm signls */ + u_int8_t rmodem; /* remote -/- */ + + u_int16_t mtu; /* MTU */ + int16_t rx_cred; /* RX credits */ + int16_t tx_cred; /* TX credits */ + + struct mtx pcb_mtx; /* PCB lock */ + struct callout_handle timo; /* timeout */ + + LIST_ENTRY(ng_btsocket_rfcomm_pcb) session_next;/* link to next */ + LIST_ENTRY(ng_btsocket_rfcomm_pcb) next; /* link to next */ +}; +typedef struct ng_btsocket_rfcomm_pcb ng_btsocket_rfcomm_pcb_t; +typedef struct ng_btsocket_rfcomm_pcb * ng_btsocket_rfcomm_pcb_p; + +#define so2rfcomm_pcb(so) \ + ((struct ng_btsocket_rfcomm_pcb *)((so)->so_pcb)) + +/* + * Bluetooth RFCOMM socket methods + */ + +#ifdef _KERNEL + +void ng_btsocket_rfcomm_init (void); +int ng_btsocket_rfcomm_abort (struct socket *); +int ng_btsocket_rfcomm_accept (struct socket *, struct sockaddr **); +int ng_btsocket_rfcomm_attach (struct socket *, int, struct thread *); +int ng_btsocket_rfcomm_bind (struct socket *, struct sockaddr *, + struct thread *); +int ng_btsocket_rfcomm_connect (struct socket *, struct sockaddr *, + struct thread *); +int ng_btsocket_rfcomm_control (struct socket *, u_long, caddr_t, + struct ifnet *, struct thread *); +int ng_btsocket_rfcomm_ctloutput (struct socket *, struct sockopt *); +int ng_btsocket_rfcomm_detach (struct socket *); +int ng_btsocket_rfcomm_disconnect (struct socket *); +int ng_btsocket_rfcomm_listen (struct socket *, struct thread *); +int ng_btsocket_rfcomm_peeraddr (struct socket *, struct sockaddr **); +int ng_btsocket_rfcomm_send (struct socket *, int, struct mbuf *, + struct sockaddr *, struct mbuf *, + struct thread *); +int ng_btsocket_rfcomm_sockaddr (struct socket *, struct sockaddr **); + +#endif /* _KERNEL */ + +#endif /* _NETGRAPH_BTSOCKET_RFCOMM_H_ */ + diff --git a/sys/netgraph/bluetooth/include/ng_h4.h b/sys/netgraph/bluetooth/include/ng_h4.h index 8f6f849..f590277 100644 --- a/sys/netgraph/bluetooth/include/ng_h4.h +++ b/sys/netgraph/bluetooth/include/ng_h4.h @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ng_h4.h,v 1.5 2002/06/27 09:50:18 max Exp $ + * $Id: ng_h4.h,v 1.1 2002/11/24 19:47:05 max Exp $ * $FreeBSD$ * * Based on: diff --git a/sys/netgraph/bluetooth/include/ng_hci.h b/sys/netgraph/bluetooth/include/ng_hci.h index c4b1aba..3bea725 100644 --- a/sys/netgraph/bluetooth/include/ng_hci.h +++ b/sys/netgraph/bluetooth/include/ng_hci.h @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ng_hci.h,v 1.13 2002/11/12 22:35:39 max Exp $ + * $Id: ng_hci.h,v 1.2 2003/03/18 00:09:37 max Exp $ * $FreeBSD$ */ @@ -598,6 +598,10 @@ typedef u_int16_t ng_hci_node_link_policy_mask_ep; #define NGM_HCI_NODE_SET_PACKET_MASK 117 /* User -> HCI */ typedef u_int16_t ng_hci_node_packet_mask_ep; +#define NGM_HCI_NODE_GET_ROLE_SWITCH 118 /* HCI -> User */ +#define NGM_HCI_NODE_SET_ROLE_SWITCH 119 /* User -> HCI */ +typedef u_int16_t ng_hci_node_role_switch_ep; + /************************************************************************** ************************************************************************** ** Link control commands and return parameters diff --git a/sys/netgraph/bluetooth/include/ng_l2cap.h b/sys/netgraph/bluetooth/include/ng_l2cap.h index e277c21..5759389 100644 --- a/sys/netgraph/bluetooth/include/ng_l2cap.h +++ b/sys/netgraph/bluetooth/include/ng_l2cap.h @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ng_l2cap.h,v 1.13 2002/09/08 23:35:51 max Exp $ + * $Id: ng_l2cap.h,v 1.2 2003/04/27 00:52:26 max Exp $ * $FreeBSD$ */ @@ -610,14 +610,17 @@ typedef u_int16_t ng_l2cap_node_debug_ep; #define NGM_L2CAP_NODE_HOOK_INFO 0x409 /* L2CAP -> Upper */ /* bdaddr_t bdaddr; -- local (source BDADDR) */ -#define NGM_L2CAP_NODE_GET_CON_LIST 0x40a /* User -> L2CAP */ +#define NGM_L2CAP_NODE_GET_CON_LIST 0x40a /* L2CAP -> User */ typedef struct { u_int32_t num_connections; /* number of connections */ } ng_l2cap_node_con_list_ep; /* Connection flags */ -#define NG_L2CAP_CON_TX (1 << 0) /* sending data */ -#define NG_L2CAP_CON_RX (1 << 1) /* receiving data */ +#define NG_L2CAP_CON_TX (1 << 0) /* sending data */ +#define NG_L2CAP_CON_RX (1 << 1) /* receiving data */ +#define NG_L2CAP_CON_OUTGOING (1 << 2) /* outgoing connection */ +#define NG_L2CAP_CON_LP_TIMO (1 << 3) /* LP timeout */ +#define NG_L2CAP_CON_AUTO_DISCON_TIMO (1 << 4) /* auto discon. timeout */ typedef struct { u_int8_t state; /* connection state */ @@ -630,7 +633,7 @@ typedef struct { #define NG_L2CAP_MAX_CON_NUM \ ((0xffff - sizeof(ng_l2cap_node_con_list_ep))/sizeof(ng_l2cap_node_con_ep)) -#define NGM_L2CAP_NODE_GET_CHAN_LIST 0x40b /* User -> L2CAP */ +#define NGM_L2CAP_NODE_GET_CHAN_LIST 0x40b /* L2CAP -> User */ typedef struct { u_int32_t num_channels; /* number of channels */ } ng_l2cap_node_chan_list_ep; @@ -651,5 +654,9 @@ typedef struct { #define NG_L2CAP_MAX_CHAN_NUM \ ((0xffff - sizeof(ng_l2cap_node_chan_list_ep))/sizeof(ng_l2cap_node_chan_ep)) +#define NGM_L2CAP_NODE_GET_AUTO_DISCON_TIMO 0x40c /* L2CAP -> User */ +#define NGM_L2CAP_NODE_SET_AUTO_DISCON_TIMO 0x40d /* User -> L2CAP */ +typedef u_int16_t ng_l2cap_node_auto_discon_ep; + #endif /* ndef _NETGRAPH_L2CAP_H_ */ diff --git a/sys/netgraph/bluetooth/include/ng_ubt.h b/sys/netgraph/bluetooth/include/ng_ubt.h index 1c55ad4..bdfc47a 100644 --- a/sys/netgraph/bluetooth/include/ng_ubt.h +++ b/sys/netgraph/bluetooth/include/ng_ubt.h @@ -25,29 +25,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ng_ubt.h,v 1.1 2002/11/09 19:09:02 max Exp $ + * $Id: ng_ubt.h,v 1.6 2003/04/13 21:34:42 max Exp $ * $FreeBSD$ */ #ifndef _NG_UBT_H_ #define _NG_UBT_H_ -/* XXX FIXME Does not belong here. Move to usbdevs.h later */ -#define USB_VENDOR_MSI 0x0db0 /* MSI www.msi.com.tw */ -#define USB_VENDOR_EPOX 0x0a12 /* EPoX www.epox.com */ - -#define USB_PRODUCT_3COM_3CREB96 0x00a0 /* 3Com Bluetooth USB dongle */ -#define USB_PRODUCT_MITSUMI_BT_DONGLE 0x641f /* Mitsumi Bluetooth USB dongle*/ -#define USB_PRODUCT_TDK_BT_DONGLE 0x0309 /* TDK Bluetooth USB dongle */ -#define USB_PRODUCT_MSI_BT_DONGLE 0x1967 /* MSI Bluetooth USB dongle */ -#define USB_PRODUCT_DBW_120M_BT_DONGLE 0x2033 /* D-Link DBW-120M */ -#define USB_PRODUCT_BT_DG02_DONGLE 0x0001 /* EPoX BT-DG02 USB dongle */ - -/* XXX FIXME Does not belong here. Move to usb.h later */ -#define UICLASS_WIRELESS_CONTROLLER 0xe0 /* Wireless Controller */ -#define UISUBCLASS_RF_CONTROLLER 0x01 /* RF Controller */ -#define UIPROTO_BLUETOOTH 0x01 /* Bluetooth programming */ - /************************************************************************** ************************************************************************** ** Netgraph node hook name, type name and type cookie and commands @@ -79,10 +63,9 @@ typedef u_int16_t ng_ubt_node_debug_ep; #define NGM_UBT_NODE_GET_QLEN 4 /* get queue length */ typedef struct { int32_t queue; /* queue index */ -#define NGM_UBT_NODE_QUEUE_IN 1 /* incoming queue */ -#define NGM_UBT_NODE_QUEUE_CMD 2 /* commands */ -#define NGM_UBT_NODE_QUEUE_ACL 3 /* ACL data */ -#define NGM_UBT_NODE_QUEUE_SCO 4 /* SCO data */ +#define NGM_UBT_NODE_QUEUE_CMD 1 /* commands */ +#define NGM_UBT_NODE_QUEUE_ACL 2 /* ACL data */ +#define NGM_UBT_NODE_QUEUE_SCO 3 /* SCO data */ int32_t qlen; /* queue length */ } ng_ubt_node_qlen_ep; @@ -99,5 +82,8 @@ typedef struct { #define NGM_UBT_NODE_RESET_STAT 6 /* reset statistic */ +#define NGM_UBT_NODE_DEV_NODES 7 /* on/off device interface */ +typedef u_int16_t ng_ubt_node_dev_nodes_ep; + #endif /* ndef _NG_UBT_H_ */ |