Lines Matching refs:session
55 struct cmtp_session *session; in __cmtp_get_session() local
59 list_for_each_entry(session, &cmtp_session_list, list) in __cmtp_get_session()
60 if (!bacmp(bdaddr, &session->bdaddr)) in __cmtp_get_session()
61 return session; in __cmtp_get_session()
66 static void __cmtp_link_session(struct cmtp_session *session) in __cmtp_link_session() argument
68 list_add(&session->list, &cmtp_session_list); in __cmtp_link_session()
71 static void __cmtp_unlink_session(struct cmtp_session *session) in __cmtp_unlink_session() argument
73 list_del(&session->list); in __cmtp_unlink_session()
76 static void __cmtp_copy_session(struct cmtp_session *session, struct cmtp_conninfo *ci) in __cmtp_copy_session() argument
80 bacpy(&ci->bdaddr, &session->bdaddr); in __cmtp_copy_session()
82 ci->flags = session->flags & valid_flags; in __cmtp_copy_session()
83 ci->state = session->state; in __cmtp_copy_session()
85 ci->num = session->num; in __cmtp_copy_session()
89 static inline int cmtp_alloc_block_id(struct cmtp_session *session) in cmtp_alloc_block_id() argument
94 if (!test_and_set_bit(i, &session->blockids)) { in cmtp_alloc_block_id()
102 static inline void cmtp_free_block_id(struct cmtp_session *session, int id) in cmtp_free_block_id() argument
104 clear_bit(id, &session->blockids); in cmtp_free_block_id()
107 static inline void cmtp_add_msgpart(struct cmtp_session *session, int id, const unsigned char *buf,… in cmtp_add_msgpart() argument
109 struct sk_buff *skb = session->reassembly[id], *nskb; in cmtp_add_msgpart()
112 BT_DBG("session %p buf %p count %d", session, buf, count); in cmtp_add_msgpart()
127 session->reassembly[id] = nskb; in cmtp_add_msgpart()
132 static inline int cmtp_recv_frame(struct cmtp_session *session, struct sk_buff *skb) in cmtp_recv_frame() argument
137 BT_DBG("session %p skb %p len %d", session, skb, skb->len); in cmtp_recv_frame()
173 cmtp_add_msgpart(session, id, skb->data + hdrlen, len); in cmtp_recv_frame()
174 cmtp_recv_capimsg(session, session->reassembly[id]); in cmtp_recv_frame()
175 session->reassembly[id] = NULL; in cmtp_recv_frame()
178 cmtp_add_msgpart(session, id, skb->data + hdrlen, len); in cmtp_recv_frame()
181 kfree_skb(session->reassembly[id]); in cmtp_recv_frame()
182 session->reassembly[id] = NULL; in cmtp_recv_frame()
193 static int cmtp_send_frame(struct cmtp_session *session, unsigned char *data, int len) in cmtp_send_frame() argument
195 struct socket *sock = session->sock; in cmtp_send_frame()
199 BT_DBG("session %p data %p len %d", session, data, len); in cmtp_send_frame()
209 static void cmtp_process_transmit(struct cmtp_session *session) in cmtp_process_transmit() argument
215 BT_DBG("session %p", session); in cmtp_process_transmit()
217 nskb = alloc_skb(session->mtu, GFP_ATOMIC); in cmtp_process_transmit()
223 while ((skb = skb_dequeue(&session->transmit))) { in cmtp_process_transmit()
226 tail = session->mtu - nskb->len; in cmtp_process_transmit()
228 cmtp_send_frame(session, nskb->data, nskb->len); in cmtp_process_transmit()
230 tail = session->mtu; in cmtp_process_transmit()
236 scb->id = cmtp_alloc_block_id(session); in cmtp_process_transmit()
238 skb_queue_head(&session->transmit, skb); in cmtp_process_transmit()
262 skb_queue_head(&session->transmit, skb); in cmtp_process_transmit()
264 cmtp_free_block_id(session, scb->id); in cmtp_process_transmit()
266 cmtp_send_frame(session, nskb->data, nskb->len); in cmtp_process_transmit()
273 cmtp_send_frame(session, nskb->data, nskb->len); in cmtp_process_transmit()
280 struct cmtp_session *session = arg; in cmtp_session() local
281 struct sock *sk = session->sock->sk; in cmtp_session()
285 BT_DBG("session %p", session); in cmtp_session()
291 if (atomic_read(&session->terminate)) in cmtp_session()
299 cmtp_recv_frame(session, skb); in cmtp_session()
304 cmtp_process_transmit(session); in cmtp_session()
316 if (!(session->flags & BIT(CMTP_LOOPBACK))) in cmtp_session()
317 cmtp_detach_device(session); in cmtp_session()
319 fput(session->sock->file); in cmtp_session()
321 __cmtp_unlink_session(session); in cmtp_session()
325 kfree(session); in cmtp_session()
333 struct cmtp_session *session, *s; in cmtp_add_connection() local
344 session = kzalloc(sizeof(struct cmtp_session), GFP_KERNEL); in cmtp_add_connection()
345 if (!session) in cmtp_add_connection()
356 bacpy(&session->bdaddr, &l2cap_pi(sock->sk)->chan->dst); in cmtp_add_connection()
358 session->mtu = min_t(uint, l2cap_pi(sock->sk)->chan->omtu, in cmtp_add_connection()
361 BT_DBG("mtu %d", session->mtu); in cmtp_add_connection()
363 sprintf(session->name, "%pMR", &session->bdaddr); in cmtp_add_connection()
365 session->sock = sock; in cmtp_add_connection()
366 session->state = BT_CONFIG; in cmtp_add_connection()
368 init_waitqueue_head(&session->wait); in cmtp_add_connection()
370 session->msgnum = CMTP_INITIAL_MSGNUM; in cmtp_add_connection()
372 INIT_LIST_HEAD(&session->applications); in cmtp_add_connection()
374 skb_queue_head_init(&session->transmit); in cmtp_add_connection()
377 session->reassembly[i] = NULL; in cmtp_add_connection()
379 session->flags = req->flags; in cmtp_add_connection()
381 __cmtp_link_session(session); in cmtp_add_connection()
384 session->task = kthread_run(cmtp_session, session, "kcmtpd_ctr_%d", in cmtp_add_connection()
385 session->num); in cmtp_add_connection()
386 if (IS_ERR(session->task)) { in cmtp_add_connection()
388 err = PTR_ERR(session->task); in cmtp_add_connection()
392 if (!(session->flags & BIT(CMTP_LOOPBACK))) { in cmtp_add_connection()
393 err = cmtp_attach_device(session); in cmtp_add_connection()
398 get_file(session->sock->file); in cmtp_add_connection()
400 atomic_inc(&session->terminate); in cmtp_add_connection()
401 wake_up_interruptible(sk_sleep(session->sock->sk)); in cmtp_add_connection()
411 __cmtp_unlink_session(session); in cmtp_add_connection()
415 kfree(session); in cmtp_add_connection()
422 struct cmtp_session *session; in cmtp_del_connection() local
432 session = __cmtp_get_session(&req->bdaddr); in cmtp_del_connection()
433 if (session) { in cmtp_del_connection()
435 skb_queue_purge(&session->transmit); in cmtp_del_connection()
438 atomic_inc(&session->terminate); in cmtp_del_connection()
444 wake_up_interruptible(sk_sleep(session->sock->sk)); in cmtp_del_connection()
454 struct cmtp_session *session; in cmtp_get_connlist() local
461 list_for_each_entry(session, &cmtp_session_list, list) { in cmtp_get_connlist()
464 __cmtp_copy_session(session, &ci); in cmtp_get_connlist()
484 struct cmtp_session *session; in cmtp_get_conninfo() local
489 session = __cmtp_get_session(&ci->bdaddr); in cmtp_get_conninfo()
490 if (session) in cmtp_get_conninfo()
491 __cmtp_copy_session(session, ci); in cmtp_get_conninfo()