aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/rfcomm/core.c
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@pobox.com>2005-09-01 18:02:27 -0400
committerJeff Garzik <jgarzik@pobox.com>2005-09-01 18:02:27 -0400
commitceeec3dc375e3b0618f16b34efc56fe093918f8b (patch)
tree2293d02721ee05131aaf1c60e4fba7e281585eec /net/bluetooth/rfcomm/core.c
parentfbff868db3a4cc6a89d51da9a6d49b26c29d04fb (diff)
parente3ee3b78f83688a0ae4315e8be71b2eac559904a (diff)
/spare/repo/netdev-2.6 branch 'ieee80211'
Diffstat (limited to 'net/bluetooth/rfcomm/core.c')
-rw-r--r--net/bluetooth/rfcomm/core.c73
1 files changed, 37 insertions, 36 deletions
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index 27bf5047cd3..173f46e8cda 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -21,10 +21,6 @@
21 SOFTWARE IS DISCLAIMED. 21 SOFTWARE IS DISCLAIMED.
22*/ 22*/
23 23
24/*
25 RPN support - Dirk Husemann <hud@zurich.ibm.com>
26*/
27
28/* 24/*
29 * Bluetooth RFCOMM core. 25 * Bluetooth RFCOMM core.
30 * 26 *
@@ -115,10 +111,10 @@ static void rfcomm_session_del(struct rfcomm_session *s);
115#define __get_mcc_len(b) ((b & 0xfe) >> 1) 111#define __get_mcc_len(b) ((b & 0xfe) >> 1)
116 112
117/* RPN macros */ 113/* RPN macros */
118#define __rpn_line_settings(data, stop, parity) ((data & 0x3) | ((stop & 0x1) << 2) | ((parity & 0x3) << 3)) 114#define __rpn_line_settings(data, stop, parity) ((data & 0x3) | ((stop & 0x1) << 2) | ((parity & 0x7) << 3))
119#define __get_rpn_data_bits(line) ((line) & 0x3) 115#define __get_rpn_data_bits(line) ((line) & 0x3)
120#define __get_rpn_stop_bits(line) (((line) >> 2) & 0x1) 116#define __get_rpn_stop_bits(line) (((line) >> 2) & 0x1)
121#define __get_rpn_parity(line) (((line) >> 3) & 0x3) 117#define __get_rpn_parity(line) (((line) >> 3) & 0x7)
122 118
123static inline void rfcomm_schedule(uint event) 119static inline void rfcomm_schedule(uint event)
124{ 120{
@@ -233,7 +229,7 @@ static void rfcomm_dlc_clear_state(struct rfcomm_dlc *d)
233 d->rx_credits = RFCOMM_DEFAULT_CREDITS; 229 d->rx_credits = RFCOMM_DEFAULT_CREDITS;
234} 230}
235 231
236struct rfcomm_dlc *rfcomm_dlc_alloc(int prio) 232struct rfcomm_dlc *rfcomm_dlc_alloc(unsigned int __nocast prio)
237{ 233{
238 struct rfcomm_dlc *d = kmalloc(sizeof(*d), prio); 234 struct rfcomm_dlc *d = kmalloc(sizeof(*d), prio);
239 if (!d) 235 if (!d)
@@ -780,10 +776,10 @@ static int rfcomm_send_pn(struct rfcomm_session *s, int cr, struct rfcomm_dlc *d
780 return rfcomm_send_frame(s, buf, ptr - buf); 776 return rfcomm_send_frame(s, buf, ptr - buf);
781} 777}
782 778
783static int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci, 779int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci,
784 u8 bit_rate, u8 data_bits, u8 stop_bits, 780 u8 bit_rate, u8 data_bits, u8 stop_bits,
785 u8 parity, u8 flow_ctrl_settings, 781 u8 parity, u8 flow_ctrl_settings,
786 u8 xon_char, u8 xoff_char, u16 param_mask) 782 u8 xon_char, u8 xoff_char, u16 param_mask)
787{ 783{
788 struct rfcomm_hdr *hdr; 784 struct rfcomm_hdr *hdr;
789 struct rfcomm_mcc *mcc; 785 struct rfcomm_mcc *mcc;
@@ -791,9 +787,9 @@ static int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci,
791 u8 buf[16], *ptr = buf; 787 u8 buf[16], *ptr = buf;
792 788
793 BT_DBG("%p cr %d dlci %d bit_r 0x%x data_b 0x%x stop_b 0x%x parity 0x%x" 789 BT_DBG("%p cr %d dlci %d bit_r 0x%x data_b 0x%x stop_b 0x%x parity 0x%x"
794 "flwc_s 0x%x xon_c 0x%x xoff_c 0x%x p_mask 0x%x", 790 " flwc_s 0x%x xon_c 0x%x xoff_c 0x%x p_mask 0x%x",
795 s, cr, dlci, bit_rate, data_bits, stop_bits, parity, 791 s, cr, dlci, bit_rate, data_bits, stop_bits, parity,
796 flow_ctrl_settings, xon_char, xoff_char, param_mask); 792 flow_ctrl_settings, xon_char, xoff_char, param_mask);
797 793
798 hdr = (void *) ptr; ptr += sizeof(*hdr); 794 hdr = (void *) ptr; ptr += sizeof(*hdr);
799 hdr->addr = __addr(s->initiator, 0); 795 hdr->addr = __addr(s->initiator, 0);
@@ -1265,16 +1261,16 @@ static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_
1265 u8 xon_char = 0; 1261 u8 xon_char = 0;
1266 u8 xoff_char = 0; 1262 u8 xoff_char = 0;
1267 u16 rpn_mask = RFCOMM_RPN_PM_ALL; 1263 u16 rpn_mask = RFCOMM_RPN_PM_ALL;
1268 1264
1269 BT_DBG("dlci %d cr %d len 0x%x bitr 0x%x line 0x%x flow 0x%x xonc 0x%x xoffc 0x%x pm 0x%x", 1265 BT_DBG("dlci %d cr %d len 0x%x bitr 0x%x line 0x%x flow 0x%x xonc 0x%x xoffc 0x%x pm 0x%x",
1270 dlci, cr, len, rpn->bit_rate, rpn->line_settings, rpn->flow_ctrl, 1266 dlci, cr, len, rpn->bit_rate, rpn->line_settings, rpn->flow_ctrl,
1271 rpn->xon_char, rpn->xoff_char, rpn->param_mask); 1267 rpn->xon_char, rpn->xoff_char, rpn->param_mask);
1272 1268
1273 if (!cr) 1269 if (!cr)
1274 return 0; 1270 return 0;
1275 1271
1276 if (len == 1) { 1272 if (len == 1) {
1277 /* request: return default setting */ 1273 /* This is a request, return default settings */
1278 bit_rate = RFCOMM_RPN_BR_115200; 1274 bit_rate = RFCOMM_RPN_BR_115200;
1279 data_bits = RFCOMM_RPN_DATA_8; 1275 data_bits = RFCOMM_RPN_DATA_8;
1280 stop_bits = RFCOMM_RPN_STOP_1; 1276 stop_bits = RFCOMM_RPN_STOP_1;
@@ -1282,11 +1278,12 @@ static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_
1282 flow_ctrl = RFCOMM_RPN_FLOW_NONE; 1278 flow_ctrl = RFCOMM_RPN_FLOW_NONE;
1283 xon_char = RFCOMM_RPN_XON_CHAR; 1279 xon_char = RFCOMM_RPN_XON_CHAR;
1284 xoff_char = RFCOMM_RPN_XOFF_CHAR; 1280 xoff_char = RFCOMM_RPN_XOFF_CHAR;
1285
1286 goto rpn_out; 1281 goto rpn_out;
1287 } 1282 }
1288 /* check for sane values: ignore/accept bit_rate, 8 bits, 1 stop bit, no parity, 1283
1289 no flow control lines, normal XON/XOFF chars */ 1284 /* Check for sane values, ignore/accept bit_rate, 8 bits, 1 stop bit,
1285 * no parity, no flow control lines, normal XON/XOFF chars */
1286
1290 if (rpn->param_mask & RFCOMM_RPN_PM_BITRATE) { 1287 if (rpn->param_mask & RFCOMM_RPN_PM_BITRATE) {
1291 bit_rate = rpn->bit_rate; 1288 bit_rate = rpn->bit_rate;
1292 if (bit_rate != RFCOMM_RPN_BR_115200) { 1289 if (bit_rate != RFCOMM_RPN_BR_115200) {
@@ -1295,6 +1292,7 @@ static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_
1295 rpn_mask ^= RFCOMM_RPN_PM_BITRATE; 1292 rpn_mask ^= RFCOMM_RPN_PM_BITRATE;
1296 } 1293 }
1297 } 1294 }
1295
1298 if (rpn->param_mask & RFCOMM_RPN_PM_DATA) { 1296 if (rpn->param_mask & RFCOMM_RPN_PM_DATA) {
1299 data_bits = __get_rpn_data_bits(rpn->line_settings); 1297 data_bits = __get_rpn_data_bits(rpn->line_settings);
1300 if (data_bits != RFCOMM_RPN_DATA_8) { 1298 if (data_bits != RFCOMM_RPN_DATA_8) {
@@ -1303,6 +1301,7 @@ static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_
1303 rpn_mask ^= RFCOMM_RPN_PM_DATA; 1301 rpn_mask ^= RFCOMM_RPN_PM_DATA;
1304 } 1302 }
1305 } 1303 }
1304
1306 if (rpn->param_mask & RFCOMM_RPN_PM_STOP) { 1305 if (rpn->param_mask & RFCOMM_RPN_PM_STOP) {
1307 stop_bits = __get_rpn_stop_bits(rpn->line_settings); 1306 stop_bits = __get_rpn_stop_bits(rpn->line_settings);
1308 if (stop_bits != RFCOMM_RPN_STOP_1) { 1307 if (stop_bits != RFCOMM_RPN_STOP_1) {
@@ -1311,6 +1310,7 @@ static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_
1311 rpn_mask ^= RFCOMM_RPN_PM_STOP; 1310 rpn_mask ^= RFCOMM_RPN_PM_STOP;
1312 } 1311 }
1313 } 1312 }
1313
1314 if (rpn->param_mask & RFCOMM_RPN_PM_PARITY) { 1314 if (rpn->param_mask & RFCOMM_RPN_PM_PARITY) {
1315 parity = __get_rpn_parity(rpn->line_settings); 1315 parity = __get_rpn_parity(rpn->line_settings);
1316 if (parity != RFCOMM_RPN_PARITY_NONE) { 1316 if (parity != RFCOMM_RPN_PARITY_NONE) {
@@ -1319,6 +1319,7 @@ static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_
1319 rpn_mask ^= RFCOMM_RPN_PM_PARITY; 1319 rpn_mask ^= RFCOMM_RPN_PM_PARITY;
1320 } 1320 }
1321 } 1321 }
1322
1322 if (rpn->param_mask & RFCOMM_RPN_PM_FLOW) { 1323 if (rpn->param_mask & RFCOMM_RPN_PM_FLOW) {
1323 flow_ctrl = rpn->flow_ctrl; 1324 flow_ctrl = rpn->flow_ctrl;
1324 if (flow_ctrl != RFCOMM_RPN_FLOW_NONE) { 1325 if (flow_ctrl != RFCOMM_RPN_FLOW_NONE) {
@@ -1327,6 +1328,7 @@ static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_
1327 rpn_mask ^= RFCOMM_RPN_PM_FLOW; 1328 rpn_mask ^= RFCOMM_RPN_PM_FLOW;
1328 } 1329 }
1329 } 1330 }
1331
1330 if (rpn->param_mask & RFCOMM_RPN_PM_XON) { 1332 if (rpn->param_mask & RFCOMM_RPN_PM_XON) {
1331 xon_char = rpn->xon_char; 1333 xon_char = rpn->xon_char;
1332 if (xon_char != RFCOMM_RPN_XON_CHAR) { 1334 if (xon_char != RFCOMM_RPN_XON_CHAR) {
@@ -1335,6 +1337,7 @@ static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_
1335 rpn_mask ^= RFCOMM_RPN_PM_XON; 1337 rpn_mask ^= RFCOMM_RPN_PM_XON;
1336 } 1338 }
1337 } 1339 }
1340
1338 if (rpn->param_mask & RFCOMM_RPN_PM_XOFF) { 1341 if (rpn->param_mask & RFCOMM_RPN_PM_XOFF) {
1339 xoff_char = rpn->xoff_char; 1342 xoff_char = rpn->xoff_char;
1340 if (xoff_char != RFCOMM_RPN_XOFF_CHAR) { 1343 if (xoff_char != RFCOMM_RPN_XOFF_CHAR) {
@@ -1345,9 +1348,8 @@ static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_
1345 } 1348 }
1346 1349
1347rpn_out: 1350rpn_out:
1348 rfcomm_send_rpn(s, 0, dlci, 1351 rfcomm_send_rpn(s, 0, dlci, bit_rate, data_bits, stop_bits,
1349 bit_rate, data_bits, stop_bits, parity, flow_ctrl, 1352 parity, flow_ctrl, xon_char, xoff_char, rpn_mask);
1350 xon_char, xoff_char, rpn_mask);
1351 1353
1352 return 0; 1354 return 0;
1353} 1355}
@@ -1358,14 +1360,13 @@ static int rfcomm_recv_rls(struct rfcomm_session *s, int cr, struct sk_buff *skb
1358 u8 dlci = __get_dlci(rls->dlci); 1360 u8 dlci = __get_dlci(rls->dlci);
1359 1361
1360 BT_DBG("dlci %d cr %d status 0x%x", dlci, cr, rls->status); 1362 BT_DBG("dlci %d cr %d status 0x%x", dlci, cr, rls->status);
1361 1363
1362 if (!cr) 1364 if (!cr)
1363 return 0; 1365 return 0;
1364 1366
1365 /* FIXME: We should probably do something with this 1367 /* We should probably do something with this information here. But
1366 information here. But for now it's sufficient just 1368 * for now it's sufficient just to reply -- Bluetooth 1.1 says it's
1367 to reply -- Bluetooth 1.1 says it's mandatory to 1369 * mandatory to recognise and respond to RLS */
1368 recognise and respond to RLS */
1369 1370
1370 rfcomm_send_rls(s, 0, dlci, rls->status); 1371 rfcomm_send_rls(s, 0, dlci, rls->status);
1371 1372
@@ -1381,7 +1382,7 @@ static int rfcomm_recv_msc(struct rfcomm_session *s, int cr, struct sk_buff *skb
1381 BT_DBG("dlci %d cr %d v24 0x%x", dlci, cr, msc->v24_sig); 1382 BT_DBG("dlci %d cr %d v24 0x%x", dlci, cr, msc->v24_sig);
1382 1383
1383 d = rfcomm_dlc_get(s, dlci); 1384 d = rfcomm_dlc_get(s, dlci);
1384 if (!d) 1385 if (!d)
1385 return 0; 1386 return 0;
1386 1387
1387 if (cr) { 1388 if (cr) {
@@ -1389,7 +1390,7 @@ static int rfcomm_recv_msc(struct rfcomm_session *s, int cr, struct sk_buff *skb
1389 set_bit(RFCOMM_TX_THROTTLED, &d->flags); 1390 set_bit(RFCOMM_TX_THROTTLED, &d->flags);
1390 else 1391 else
1391 clear_bit(RFCOMM_TX_THROTTLED, &d->flags); 1392 clear_bit(RFCOMM_TX_THROTTLED, &d->flags);
1392 1393
1393 rfcomm_dlc_lock(d); 1394 rfcomm_dlc_lock(d);
1394 if (d->modem_status) 1395 if (d->modem_status)
1395 d->modem_status(d, msc->v24_sig); 1396 d->modem_status(d, msc->v24_sig);
@@ -1398,7 +1399,7 @@ static int rfcomm_recv_msc(struct rfcomm_session *s, int cr, struct sk_buff *skb
1398 rfcomm_send_msc(s, 0, dlci, msc->v24_sig); 1399 rfcomm_send_msc(s, 0, dlci, msc->v24_sig);
1399 1400
1400 d->mscex |= RFCOMM_MSCEX_RX; 1401 d->mscex |= RFCOMM_MSCEX_RX;
1401 } else 1402 } else
1402 d->mscex |= RFCOMM_MSCEX_TX; 1403 d->mscex |= RFCOMM_MSCEX_TX;
1403 1404
1404 return 0; 1405 return 0;