Lines Matching refs:session
54 struct cmtp_session *session; in __cmtp_get_session() local
60 session = list_entry(p, struct cmtp_session, list); in __cmtp_get_session()
61 if (!bacmp(bdaddr, &session->bdaddr)) in __cmtp_get_session()
62 return session; in __cmtp_get_session()
67 static void __cmtp_link_session(struct cmtp_session *session) in __cmtp_link_session() argument
70 list_add(&session->list, &cmtp_session_list); in __cmtp_link_session()
73 static void __cmtp_unlink_session(struct cmtp_session *session) in __cmtp_unlink_session() argument
75 list_del(&session->list); in __cmtp_unlink_session()
79 static void __cmtp_copy_session(struct cmtp_session *session, struct cmtp_conninfo *ci) in __cmtp_copy_session() argument
81 bacpy(&ci->bdaddr, &session->bdaddr); in __cmtp_copy_session()
83 ci->flags = session->flags; in __cmtp_copy_session()
84 ci->state = session->state; in __cmtp_copy_session()
86 ci->num = session->num; in __cmtp_copy_session()
90 static inline int cmtp_alloc_block_id(struct cmtp_session *session) in cmtp_alloc_block_id() argument
95 if (!test_and_set_bit(i, &session->blockids)) { in cmtp_alloc_block_id()
103 static inline void cmtp_free_block_id(struct cmtp_session *session, int id) in cmtp_free_block_id() argument
105 clear_bit(id, &session->blockids); in cmtp_free_block_id()
108 static inline void cmtp_add_msgpart(struct cmtp_session *session, int id, const unsigned char *buf,… in cmtp_add_msgpart() argument
110 struct sk_buff *skb = session->reassembly[id], *nskb; in cmtp_add_msgpart()
113 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 if (session->reassembly[id] != NULL) in cmtp_recv_frame()
182 kfree_skb(session->reassembly[id]); in cmtp_recv_frame()
183 session->reassembly[id] = NULL; in cmtp_recv_frame()
194 static int cmtp_send_frame(struct cmtp_session *session, unsigned char *data, int len) in cmtp_send_frame() argument
196 struct socket *sock = session->sock; in cmtp_send_frame()
200 BT_DBG("session %p data %p len %d", session, data, len); in cmtp_send_frame()
210 static void cmtp_process_transmit(struct cmtp_session *session) in cmtp_process_transmit() argument
216 BT_DBG("session %p", session); in cmtp_process_transmit()
218 if (!(nskb = alloc_skb(session->mtu, GFP_ATOMIC))) { in cmtp_process_transmit()
223 while ((skb = skb_dequeue(&session->transmit))) { in cmtp_process_transmit()
226 if ((tail = (session->mtu - nskb->len)) < 5) { in cmtp_process_transmit()
227 cmtp_send_frame(session, nskb->data, nskb->len); in cmtp_process_transmit()
229 tail = session->mtu; in cmtp_process_transmit()
234 if ((scb->id < 0) && ((scb->id = cmtp_alloc_block_id(session)) < 0)) { in cmtp_process_transmit()
235 skb_queue_head(&session->transmit, skb); in cmtp_process_transmit()
258 skb_queue_head(&session->transmit, skb); in cmtp_process_transmit()
260 cmtp_free_block_id(session, scb->id); in cmtp_process_transmit()
262 cmtp_send_frame(session, nskb->data, nskb->len); in cmtp_process_transmit()
269 cmtp_send_frame(session, nskb->data, nskb->len); in cmtp_process_transmit()
276 struct cmtp_session *session = arg; in cmtp_session() local
277 struct sock *sk = session->sock->sk; in cmtp_session()
281 BT_DBG("session %p", session); in cmtp_session()
283 daemonize("kcmtpd_ctr_%d", session->num); in cmtp_session()
288 while (!atomic_read(&session->terminate)) { in cmtp_session()
296 cmtp_recv_frame(session, skb); in cmtp_session()
299 cmtp_process_transmit(session); in cmtp_session()
308 if (!(session->flags & (1 << CMTP_LOOPBACK))) in cmtp_session()
309 cmtp_detach_device(session); in cmtp_session()
311 fput(session->sock->file); in cmtp_session()
313 __cmtp_unlink_session(session); in cmtp_session()
317 kfree(session); in cmtp_session()
323 struct cmtp_session *session, *s; in cmtp_add_connection() local
332 session = kzalloc(sizeof(struct cmtp_session), GFP_KERNEL); in cmtp_add_connection()
333 if (!session) in cmtp_add_connection()
344 bacpy(&session->bdaddr, &bt_sk(sock->sk)->dst); in cmtp_add_connection()
346 session->mtu = min_t(uint, l2cap_pi(sock->sk)->omtu, l2cap_pi(sock->sk)->imtu); in cmtp_add_connection()
348 BT_DBG("mtu %d", session->mtu); in cmtp_add_connection()
350 sprintf(session->name, "%s", batostr(&dst)); in cmtp_add_connection()
352 session->sock = sock; in cmtp_add_connection()
353 session->state = BT_CONFIG; in cmtp_add_connection()
355 init_waitqueue_head(&session->wait); in cmtp_add_connection()
357 session->msgnum = CMTP_INITIAL_MSGNUM; in cmtp_add_connection()
359 INIT_LIST_HEAD(&session->applications); in cmtp_add_connection()
361 skb_queue_head_init(&session->transmit); in cmtp_add_connection()
364 session->reassembly[i] = NULL; in cmtp_add_connection()
366 session->flags = req->flags; in cmtp_add_connection()
368 __cmtp_link_session(session); in cmtp_add_connection()
370 err = kernel_thread(cmtp_session, session, CLONE_KERNEL); in cmtp_add_connection()
374 if (!(session->flags & (1 << CMTP_LOOPBACK))) { in cmtp_add_connection()
375 err = cmtp_attach_device(session); in cmtp_add_connection()
384 cmtp_detach_device(session); in cmtp_add_connection()
387 __cmtp_unlink_session(session); in cmtp_add_connection()
391 kfree(session); in cmtp_add_connection()
397 struct cmtp_session *session; in cmtp_del_connection() local
404 session = __cmtp_get_session(&req->bdaddr); in cmtp_del_connection()
405 if (session) { in cmtp_del_connection()
407 skb_queue_purge(&session->transmit); in cmtp_del_connection()
410 atomic_inc(&session->terminate); in cmtp_del_connection()
411 cmtp_schedule(session); in cmtp_del_connection()
429 struct cmtp_session *session; in cmtp_get_connlist() local
432 session = list_entry(p, struct cmtp_session, list); in cmtp_get_connlist()
434 __cmtp_copy_session(session, &ci); in cmtp_get_connlist()
454 struct cmtp_session *session; in cmtp_get_conninfo() local
459 session = __cmtp_get_session(&ci->bdaddr); in cmtp_get_conninfo()
460 if (session) in cmtp_get_conninfo()
461 __cmtp_copy_session(session, ci); in cmtp_get_conninfo()