diff options
Diffstat (limited to 'include/net/bluetooth/l2cap.h')
-rw-r--r-- | include/net/bluetooth/l2cap.h | 182 |
1 files changed, 90 insertions, 92 deletions
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 4f4bff1eaed..d09c9b1118e 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h | |||
@@ -276,63 +276,17 @@ struct l2cap_conn_param_update_rsp { | |||
276 | #define L2CAP_CONN_PARAM_ACCEPTED 0x0000 | 276 | #define L2CAP_CONN_PARAM_ACCEPTED 0x0000 |
277 | #define L2CAP_CONN_PARAM_REJECTED 0x0001 | 277 | #define L2CAP_CONN_PARAM_REJECTED 0x0001 |
278 | 278 | ||
279 | /* ----- L2CAP connections ----- */ | 279 | /* ----- L2CAP channels and connections ----- */ |
280 | struct l2cap_chan_list { | ||
281 | struct sock *head; | ||
282 | rwlock_t lock; | ||
283 | long num; | ||
284 | }; | ||
285 | |||
286 | struct l2cap_conn { | ||
287 | struct hci_conn *hcon; | ||
288 | |||
289 | bdaddr_t *dst; | ||
290 | bdaddr_t *src; | ||
291 | |||
292 | unsigned int mtu; | ||
293 | |||
294 | __u32 feat_mask; | ||
295 | |||
296 | __u8 info_state; | ||
297 | __u8 info_ident; | ||
298 | |||
299 | struct timer_list info_timer; | ||
300 | |||
301 | spinlock_t lock; | ||
302 | |||
303 | struct sk_buff *rx_skb; | ||
304 | __u32 rx_len; | ||
305 | __u8 rx_ident; | ||
306 | __u8 tx_ident; | ||
307 | |||
308 | __u8 disc_reason; | ||
309 | |||
310 | struct l2cap_chan_list chan_list; | ||
311 | }; | ||
312 | |||
313 | struct sock_del_list { | ||
314 | struct sock *sk; | ||
315 | struct list_head list; | ||
316 | }; | ||
317 | |||
318 | #define L2CAP_INFO_CL_MTU_REQ_SENT 0x01 | ||
319 | #define L2CAP_INFO_FEAT_MASK_REQ_SENT 0x04 | ||
320 | #define L2CAP_INFO_FEAT_MASK_REQ_DONE 0x08 | ||
321 | |||
322 | /* ----- L2CAP channel and socket info ----- */ | ||
323 | #define l2cap_pi(sk) ((struct l2cap_pinfo *) sk) | ||
324 | #define TX_QUEUE(sk) (&l2cap_pi(sk)->tx_queue) | ||
325 | #define SREJ_QUEUE(sk) (&l2cap_pi(sk)->srej_queue) | ||
326 | #define BUSY_QUEUE(sk) (&l2cap_pi(sk)->busy_queue) | ||
327 | #define SREJ_LIST(sk) (&l2cap_pi(sk)->srej_l.list) | ||
328 | |||
329 | struct srej_list { | 280 | struct srej_list { |
330 | __u8 tx_seq; | 281 | __u8 tx_seq; |
331 | struct list_head list; | 282 | struct list_head list; |
332 | }; | 283 | }; |
333 | 284 | ||
334 | struct l2cap_pinfo { | 285 | struct l2cap_chan { |
335 | struct bt_sock bt; | 286 | struct sock *sk; |
287 | |||
288 | struct l2cap_conn *conn; | ||
289 | |||
336 | __le16 psm; | 290 | __le16 psm; |
337 | __u16 dcid; | 291 | __u16 dcid; |
338 | __u16 scid; | 292 | __u16 scid; |
@@ -341,17 +295,29 @@ struct l2cap_pinfo { | |||
341 | __u16 omtu; | 295 | __u16 omtu; |
342 | __u16 flush_to; | 296 | __u16 flush_to; |
343 | __u8 mode; | 297 | __u8 mode; |
344 | __u8 num_conf_req; | ||
345 | __u8 num_conf_rsp; | ||
346 | 298 | ||
347 | __u8 fcs; | 299 | __le16 sport; |
300 | |||
348 | __u8 sec_level; | 301 | __u8 sec_level; |
349 | __u8 role_switch; | 302 | __u8 role_switch; |
350 | __u8 force_reliable; | 303 | __u8 force_reliable; |
351 | __u8 flushable; | 304 | __u8 flushable; |
352 | 305 | ||
306 | __u8 ident; | ||
307 | |||
353 | __u8 conf_req[64]; | 308 | __u8 conf_req[64]; |
354 | __u8 conf_len; | 309 | __u8 conf_len; |
310 | __u8 num_conf_req; | ||
311 | __u8 num_conf_rsp; | ||
312 | |||
313 | __u8 fcs; | ||
314 | |||
315 | __u8 tx_win; | ||
316 | __u8 max_tx; | ||
317 | __u16 retrans_timeout; | ||
318 | __u16 monitor_timeout; | ||
319 | __u16 mps; | ||
320 | |||
355 | __u8 conf_state; | 321 | __u8 conf_state; |
356 | __u16 conn_state; | 322 | __u16 conn_state; |
357 | 323 | ||
@@ -369,30 +335,61 @@ struct l2cap_pinfo { | |||
369 | __u16 partial_sdu_len; | 335 | __u16 partial_sdu_len; |
370 | struct sk_buff *sdu; | 336 | struct sk_buff *sdu; |
371 | 337 | ||
372 | __u8 ident; | ||
373 | |||
374 | __u8 tx_win; | ||
375 | __u8 max_tx; | ||
376 | __u8 remote_tx_win; | 338 | __u8 remote_tx_win; |
377 | __u8 remote_max_tx; | 339 | __u8 remote_max_tx; |
378 | __u16 retrans_timeout; | ||
379 | __u16 monitor_timeout; | ||
380 | __u16 remote_mps; | 340 | __u16 remote_mps; |
381 | __u16 mps; | ||
382 | |||
383 | __le16 sport; | ||
384 | 341 | ||
385 | struct timer_list retrans_timer; | 342 | struct timer_list retrans_timer; |
386 | struct timer_list monitor_timer; | 343 | struct timer_list monitor_timer; |
387 | struct timer_list ack_timer; | 344 | struct timer_list ack_timer; |
388 | struct sk_buff_head tx_queue; | 345 | struct sk_buff *tx_send_head; |
389 | struct sk_buff_head srej_queue; | 346 | struct sk_buff_head tx_q; |
390 | struct sk_buff_head busy_queue; | 347 | struct sk_buff_head srej_q; |
348 | struct sk_buff_head busy_q; | ||
391 | struct work_struct busy_work; | 349 | struct work_struct busy_work; |
392 | struct srej_list srej_l; | 350 | struct list_head srej_l; |
393 | struct l2cap_conn *conn; | 351 | |
394 | struct sock *next_c; | 352 | struct list_head list; |
395 | struct sock *prev_c; | 353 | struct list_head global_l; |
354 | }; | ||
355 | |||
356 | struct l2cap_conn { | ||
357 | struct hci_conn *hcon; | ||
358 | |||
359 | bdaddr_t *dst; | ||
360 | bdaddr_t *src; | ||
361 | |||
362 | unsigned int mtu; | ||
363 | |||
364 | __u32 feat_mask; | ||
365 | |||
366 | __u8 info_state; | ||
367 | __u8 info_ident; | ||
368 | |||
369 | struct timer_list info_timer; | ||
370 | |||
371 | spinlock_t lock; | ||
372 | |||
373 | struct sk_buff *rx_skb; | ||
374 | __u32 rx_len; | ||
375 | __u8 tx_ident; | ||
376 | |||
377 | __u8 disc_reason; | ||
378 | |||
379 | struct list_head chan_l; | ||
380 | rwlock_t chan_lock; | ||
381 | }; | ||
382 | |||
383 | #define L2CAP_INFO_CL_MTU_REQ_SENT 0x01 | ||
384 | #define L2CAP_INFO_FEAT_MASK_REQ_SENT 0x04 | ||
385 | #define L2CAP_INFO_FEAT_MASK_REQ_DONE 0x08 | ||
386 | |||
387 | /* ----- L2CAP socket info ----- */ | ||
388 | #define l2cap_pi(sk) ((struct l2cap_pinfo *) sk) | ||
389 | |||
390 | struct l2cap_pinfo { | ||
391 | struct bt_sock bt; | ||
392 | struct l2cap_chan *chan; | ||
396 | }; | 393 | }; |
397 | 394 | ||
398 | #define L2CAP_CONF_REQ_SENT 0x01 | 395 | #define L2CAP_CONF_REQ_SENT 0x01 |
@@ -419,24 +416,23 @@ struct l2cap_pinfo { | |||
419 | #define L2CAP_CONN_RNR_SENT 0x0200 | 416 | #define L2CAP_CONN_RNR_SENT 0x0200 |
420 | #define L2CAP_CONN_SAR_RETRY 0x0400 | 417 | #define L2CAP_CONN_SAR_RETRY 0x0400 |
421 | 418 | ||
422 | #define __mod_retrans_timer() mod_timer(&l2cap_pi(sk)->retrans_timer, \ | 419 | #define __mod_retrans_timer() mod_timer(&chan->retrans_timer, \ |
423 | jiffies + msecs_to_jiffies(L2CAP_DEFAULT_RETRANS_TO)); | 420 | jiffies + msecs_to_jiffies(L2CAP_DEFAULT_RETRANS_TO)); |
424 | #define __mod_monitor_timer() mod_timer(&l2cap_pi(sk)->monitor_timer, \ | 421 | #define __mod_monitor_timer() mod_timer(&chan->monitor_timer, \ |
425 | jiffies + msecs_to_jiffies(L2CAP_DEFAULT_MONITOR_TO)); | 422 | jiffies + msecs_to_jiffies(L2CAP_DEFAULT_MONITOR_TO)); |
426 | #define __mod_ack_timer() mod_timer(&l2cap_pi(sk)->ack_timer, \ | 423 | #define __mod_ack_timer() mod_timer(&chan->ack_timer, \ |
427 | jiffies + msecs_to_jiffies(L2CAP_DEFAULT_ACK_TO)); | 424 | jiffies + msecs_to_jiffies(L2CAP_DEFAULT_ACK_TO)); |
428 | 425 | ||
429 | static inline int l2cap_tx_window_full(struct sock *sk) | 426 | static inline int l2cap_tx_window_full(struct l2cap_chan *ch) |
430 | { | 427 | { |
431 | struct l2cap_pinfo *pi = l2cap_pi(sk); | ||
432 | int sub; | 428 | int sub; |
433 | 429 | ||
434 | sub = (pi->next_tx_seq - pi->expected_ack_seq) % 64; | 430 | sub = (ch->next_tx_seq - ch->expected_ack_seq) % 64; |
435 | 431 | ||
436 | if (sub < 0) | 432 | if (sub < 0) |
437 | sub += 64; | 433 | sub += 64; |
438 | 434 | ||
439 | return sub == pi->remote_tx_win; | 435 | return sub == ch->remote_tx_win; |
440 | } | 436 | } |
441 | 437 | ||
442 | #define __get_txseq(ctrl) (((ctrl) & L2CAP_CTRL_TXSEQ) >> 1) | 438 | #define __get_txseq(ctrl) (((ctrl) & L2CAP_CTRL_TXSEQ) >> 1) |
@@ -446,24 +442,24 @@ static inline int l2cap_tx_window_full(struct sock *sk) | |||
446 | #define __is_sar_start(ctrl) (((ctrl) & L2CAP_CTRL_SAR) == L2CAP_SDU_START) | 442 | #define __is_sar_start(ctrl) (((ctrl) & L2CAP_CTRL_SAR) == L2CAP_SDU_START) |
447 | 443 | ||
448 | extern int disable_ertm; | 444 | extern int disable_ertm; |
449 | extern const struct proto_ops l2cap_sock_ops; | ||
450 | extern struct bt_sock_list l2cap_sk_list; | ||
451 | 445 | ||
452 | int l2cap_init_sockets(void); | 446 | int l2cap_init_sockets(void); |
453 | void l2cap_cleanup_sockets(void); | 447 | void l2cap_cleanup_sockets(void); |
454 | 448 | ||
455 | u8 l2cap_get_ident(struct l2cap_conn *conn); | ||
456 | void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data); | 449 | void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data); |
457 | int l2cap_build_conf_req(struct sock *sk, void *data); | 450 | void __l2cap_connect_rsp_defer(struct l2cap_chan *chan); |
458 | int __l2cap_wait_ack(struct sock *sk); | 451 | int __l2cap_wait_ack(struct sock *sk); |
459 | 452 | ||
460 | struct sk_buff *l2cap_create_connless_pdu(struct sock *sk, struct msghdr *msg, size_t len); | 453 | struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len); |
461 | struct sk_buff *l2cap_create_basic_pdu(struct sock *sk, struct msghdr *msg, size_t len); | 454 | struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len); |
462 | struct sk_buff *l2cap_create_iframe_pdu(struct sock *sk, struct msghdr *msg, size_t len, u16 control, u16 sdulen); | 455 | struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len, u16 control, u16 sdulen); |
463 | int l2cap_sar_segment_sdu(struct sock *sk, struct msghdr *msg, size_t len); | 456 | int l2cap_sar_segment_sdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len); |
464 | void l2cap_do_send(struct sock *sk, struct sk_buff *skb); | 457 | void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb); |
465 | void l2cap_streaming_send(struct sock *sk); | 458 | void l2cap_streaming_send(struct l2cap_chan *chan); |
466 | int l2cap_ertm_send(struct sock *sk); | 459 | int l2cap_ertm_send(struct l2cap_chan *chan); |
460 | |||
461 | int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm); | ||
462 | int l2cap_add_scid(struct l2cap_chan *chan, __u16 scid); | ||
467 | 463 | ||
468 | void l2cap_sock_set_timer(struct sock *sk, long timeout); | 464 | void l2cap_sock_set_timer(struct sock *sk, long timeout); |
469 | void l2cap_sock_clear_timer(struct sock *sk); | 465 | void l2cap_sock_clear_timer(struct sock *sk); |
@@ -472,8 +468,10 @@ void l2cap_sock_kill(struct sock *sk); | |||
472 | void l2cap_sock_init(struct sock *sk, struct sock *parent); | 468 | void l2cap_sock_init(struct sock *sk, struct sock *parent); |
473 | struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, | 469 | struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, |
474 | int proto, gfp_t prio); | 470 | int proto, gfp_t prio); |
475 | void l2cap_send_disconn_req(struct l2cap_conn *conn, struct sock *sk, int err); | 471 | void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *chan, int err); |
476 | void l2cap_chan_del(struct sock *sk, int err); | 472 | struct l2cap_chan *l2cap_chan_create(struct sock *sk); |
477 | int l2cap_do_connect(struct sock *sk); | 473 | void l2cap_chan_del(struct l2cap_chan *chan, int err); |
474 | void l2cap_chan_destroy(struct l2cap_chan *chan); | ||
475 | int l2cap_chan_connect(struct l2cap_chan *chan); | ||
478 | 476 | ||
479 | #endif /* __L2CAP_H */ | 477 | #endif /* __L2CAP_H */ |