summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authoremax <emax@FreeBSD.org>2008-07-10 00:15:29 +0000
committeremax <emax@FreeBSD.org>2008-07-10 00:15:29 +0000
commitb07b40d7feb6ae8e188fa82622c29d6a0daeb94e (patch)
treec9a252ce0ab32de4ddfe23980c92a68052f6f4c0 /sys
parentf158d7c96d50027875a88283d7830455c9ebaa7e (diff)
downloadFreeBSD-src-b07b40d7feb6ae8e188fa82622c29d6a0daeb94e.zip
FreeBSD-src-b07b40d7feb6ae8e188fa82622c29d6a0daeb94e.tar.gz
Get in some basic infrastructure for Bluetooth SCO support.
MFC after: 3 months
Diffstat (limited to 'sys')
-rw-r--r--sys/netgraph/bluetooth/common/ng_bluetooth.c38
-rw-r--r--sys/netgraph/bluetooth/include/ng_bluetooth.h2
-rw-r--r--sys/netgraph/bluetooth/include/ng_btsocket.h19
3 files changed, 59 insertions, 0 deletions
diff --git a/sys/netgraph/bluetooth/common/ng_bluetooth.c b/sys/netgraph/bluetooth/common/ng_bluetooth.c
index 6f6a46e..1cf17d7 100644
--- a/sys/netgraph/bluetooth/common/ng_bluetooth.c
+++ b/sys/netgraph/bluetooth/common/ng_bluetooth.c
@@ -49,6 +49,7 @@ static u_int32_t bluetooth_hci_connect_timeout_value = 60; /* sec */
static u_int32_t bluetooth_hci_max_neighbor_age_value = 600; /* sec */
static u_int32_t bluetooth_l2cap_rtx_timeout_value = 60; /* sec */
static u_int32_t bluetooth_l2cap_ertx_timeout_value = 300; /* sec */
+static u_int32_t bluetooth_sco_rtx_timeout_value = 60; /* sec */
/*
* Define sysctl tree that shared by other parts of Bluetooth stack
@@ -207,6 +208,12 @@ bluetooth_l2cap_ertx_timeout(void)
return (bluetooth_l2cap_ertx_timeout_value * hz);
} /* bluetooth_l2cap_ertx_timeout */
+u_int32_t
+bluetooth_sco_rtx_timeout(void)
+{
+ return (bluetooth_sco_rtx_timeout_value * hz);
+} /* bluetooth_sco_rtx_timeout */
+
/*
* RFCOMM
*/
@@ -214,6 +221,37 @@ bluetooth_l2cap_ertx_timeout(void)
SYSCTL_NODE(_net_bluetooth, OID_AUTO, rfcomm, CTLFLAG_RW,
0, "Bluetooth RFCOMM family");
+/*
+ * SCO
+ */
+
+SYSCTL_NODE(_net_bluetooth, OID_AUTO, sco, CTLFLAG_RW,
+ 0, "Bluetooth SCO family");
+
+static int
+bluetooth_set_sco_rtx_timeout_value(SYSCTL_HANDLER_ARGS)
+{
+ u_int32_t value;
+ int error;
+
+ value = bluetooth_sco_rtx_timeout_value;
+ error = sysctl_handle_int(oidp, &value, 0, req);
+ if (error == 0 && req->newptr != NULL) {
+ if (bluetooth_hci_connect_timeout_value <= value)
+ bluetooth_sco_rtx_timeout_value = value;
+ else
+ error = EINVAL;
+ }
+
+ return (error);
+} /* bluetooth_set_sco_rtx_timeout_value */
+
+SYSCTL_PROC(_net_bluetooth_sco, OID_AUTO, rtx_timeout,
+ CTLTYPE_INT | CTLFLAG_RW,
+ &bluetooth_sco_rtx_timeout_value, 60,
+ bluetooth_set_sco_rtx_timeout_value,
+ "I", "SCO RTX timeout (sec)");
+
/*
* Handle loading and unloading for this code.
*/
diff --git a/sys/netgraph/bluetooth/include/ng_bluetooth.h b/sys/netgraph/bluetooth/include/ng_bluetooth.h
index fbfbea7..2b85fac 100644
--- a/sys/netgraph/bluetooth/include/ng_bluetooth.h
+++ b/sys/netgraph/bluetooth/include/ng_bluetooth.h
@@ -52,6 +52,7 @@ SYSCTL_DECL(_net_bluetooth);
SYSCTL_DECL(_net_bluetooth_hci);
SYSCTL_DECL(_net_bluetooth_l2cap);
SYSCTL_DECL(_net_bluetooth_rfcomm);
+SYSCTL_DECL(_net_bluetooth_sco);
#endif /* SYSCTL_DECL */
/*
@@ -221,6 +222,7 @@ u_int32_t bluetooth_hci_connect_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);
+u_int32_t bluetooth_sco_rtx_timeout (void);
#endif /* _NETGRAPH_BLUETOOTH_H_ */
diff --git a/sys/netgraph/bluetooth/include/ng_btsocket.h b/sys/netgraph/bluetooth/include/ng_btsocket.h
index 7dc309a..6c3ce8d 100644
--- a/sys/netgraph/bluetooth/include/ng_btsocket.h
+++ b/sys/netgraph/bluetooth/include/ng_btsocket.h
@@ -41,6 +41,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 */
+#define BLUETOOTH_PROTO_SCO 137 /* SCO protocol number */
/*
* Bluetooth version of struct sockaddr for raw HCI sockets
@@ -200,6 +201,23 @@ struct ng_btsocket_hci_raw_node_list_names {
/*
* XXX FIXME: probably does not belong here
+ * Bluetooth version of struct sockaddr for SCO sockets (SEQPACKET)
+ */
+
+struct sockaddr_sco {
+ u_char sco_len; /* total length */
+ u_char sco_family; /* address family */
+ bdaddr_t sco_bdaddr; /* address */
+};
+
+/* SCO socket options */
+#define SOL_SCO 0x0209 /* socket options level */
+
+#define SO_SCO_MTU 1 /* get sockets mtu */
+#define SO_SCO_CONNINFO 2 /* get HCI connection handle */
+
+/*
+ * XXX FIXME: probably does not belong here
* Bluetooth version of struct sockaddr for L2CAP sockets (RAW and SEQPACKET)
*/
@@ -328,6 +346,7 @@ struct ng_btsocket_rfcomm_fc_info {
#define NG_BTSOCKET_HCI_RAW_NODE_TYPE "btsock_hci_raw"
#define NG_BTSOCKET_L2CAP_RAW_NODE_TYPE "btsock_l2c_raw"
#define NG_BTSOCKET_L2CAP_NODE_TYPE "btsock_l2c"
+#define NG_BTSOCKET_SCO_NODE_TYPE "btsock_sco"
/*
* Debug levels
OpenPOWER on IntegriCloud