Lines Matching refs:s
50 struct bnep_session *s; in __bnep_get_session() local
54 list_for_each_entry(s, &bnep_session_list, list) in __bnep_get_session()
55 if (ether_addr_equal(dst, s->eh.h_source)) in __bnep_get_session()
56 return s; in __bnep_get_session()
61 static void __bnep_link_session(struct bnep_session *s) in __bnep_link_session() argument
63 list_add(&s->list, &bnep_session_list); in __bnep_link_session()
66 static void __bnep_unlink_session(struct bnep_session *s) in __bnep_unlink_session() argument
68 list_del(&s->list); in __bnep_unlink_session()
71 static int bnep_send(struct bnep_session *s, void *data, size_t len) in bnep_send() argument
73 struct socket *sock = s->sock; in bnep_send()
76 return kernel_sendmsg(sock, &s->msg, &iv, 1, len); in bnep_send()
79 static int bnep_send_rsp(struct bnep_session *s, u8 ctrl, u16 resp) in bnep_send_rsp() argument
85 return bnep_send(s, &rsp, sizeof(rsp)); in bnep_send_rsp()
89 static inline void bnep_set_default_proto_filter(struct bnep_session *s) in bnep_set_default_proto_filter() argument
92 s->proto_filter[0].start = ETH_P_IP; in bnep_set_default_proto_filter()
93 s->proto_filter[0].end = ETH_P_ARP; in bnep_set_default_proto_filter()
95 s->proto_filter[1].start = ETH_P_RARP; in bnep_set_default_proto_filter()
96 s->proto_filter[1].end = ETH_P_AARP; in bnep_set_default_proto_filter()
98 s->proto_filter[2].start = ETH_P_IPX; in bnep_set_default_proto_filter()
99 s->proto_filter[2].end = ETH_P_IPV6; in bnep_set_default_proto_filter()
103 static int bnep_ctrl_set_netfilter(struct bnep_session *s, __be16 *data, int len) in bnep_ctrl_set_netfilter() argument
122 struct bnep_proto_filter *f = s->proto_filter; in bnep_ctrl_set_netfilter()
137 bnep_set_default_proto_filter(s); in bnep_ctrl_set_netfilter()
139 bnep_send_rsp(s, BNEP_FILTER_NET_TYPE_RSP, BNEP_SUCCESS); in bnep_ctrl_set_netfilter()
141 bnep_send_rsp(s, BNEP_FILTER_NET_TYPE_RSP, BNEP_FILTER_LIMIT_REACHED); in bnep_ctrl_set_netfilter()
144 bnep_send_rsp(s, BNEP_FILTER_NET_TYPE_RSP, BNEP_FILTER_UNSUPPORTED_REQ); in bnep_ctrl_set_netfilter()
149 static int bnep_ctrl_set_mcfilter(struct bnep_session *s, u8 *data, int len) in bnep_ctrl_set_mcfilter() argument
171 s->mc_filter = 0; in bnep_ctrl_set_mcfilter()
174 set_bit(bnep_mc_hash(s->dev->broadcast), (ulong *) &s->mc_filter); in bnep_ctrl_set_mcfilter()
188 set_bit(bnep_mc_hash(a1), (ulong *) &s->mc_filter); in bnep_ctrl_set_mcfilter()
189 while (memcmp(a1, a2, 6) < 0 && s->mc_filter != ~0LL) { in bnep_ctrl_set_mcfilter()
195 set_bit(bnep_mc_hash(a1), (ulong *) &s->mc_filter); in bnep_ctrl_set_mcfilter()
200 BT_DBG("mc filter hash 0x%llx", s->mc_filter); in bnep_ctrl_set_mcfilter()
202 bnep_send_rsp(s, BNEP_FILTER_MULTI_ADDR_RSP, BNEP_SUCCESS); in bnep_ctrl_set_mcfilter()
204 bnep_send_rsp(s, BNEP_FILTER_MULTI_ADDR_RSP, BNEP_FILTER_UNSUPPORTED_REQ); in bnep_ctrl_set_mcfilter()
209 static int bnep_rx_control(struct bnep_session *s, void *data, int len) in bnep_rx_control() argument
226 err = bnep_ctrl_set_netfilter(s, data, len); in bnep_rx_control()
230 err = bnep_ctrl_set_mcfilter(s, data, len); in bnep_rx_control()
235 if (test_bit(BNEP_SETUP_RESPONSE, &s->flags) && in bnep_rx_control()
236 !test_and_set_bit(BNEP_SETUP_RSP_SENT, &s->flags)) in bnep_rx_control()
237 err = bnep_send_rsp(s, BNEP_SETUP_CONN_RSP, in bnep_rx_control()
240 err = bnep_send_rsp(s, BNEP_SETUP_CONN_RSP, in bnep_rx_control()
249 err = bnep_send(s, pkt, sizeof(pkt)); in bnep_rx_control()
257 static int bnep_rx_extension(struct bnep_session *s, struct sk_buff *skb) in bnep_rx_extension() argument
273 bnep_rx_control(s, skb->data, skb->len); in bnep_rx_extension()
298 static int bnep_rx_frame(struct bnep_session *s, struct sk_buff *skb) in bnep_rx_frame() argument
300 struct net_device *dev = s->dev; in bnep_rx_frame()
314 if (bnep_rx_control(s, skb->data, skb->len) < 0) { in bnep_rx_frame()
349 s->eh.h_proto = get_unaligned((__be16 *) (skb->data - 2)); in bnep_rx_frame()
353 if (bnep_rx_extension(s, skb) < 0) in bnep_rx_frame()
358 if (ntohs(s->eh.h_proto) == ETH_P_8021Q) { in bnep_rx_frame()
361 s->eh.h_proto = get_unaligned((__be16 *) (skb->data - 2)); in bnep_rx_frame()
377 memcpy(__skb_put(nskb, ETH_HLEN), &s->eh, ETH_HLEN); in bnep_rx_frame()
381 memcpy(__skb_put(nskb, ETH_ALEN), s->eh.h_dest, ETH_ALEN); in bnep_rx_frame()
383 put_unaligned(s->eh.h_proto, (__be16 *) __skb_put(nskb, 2)); in bnep_rx_frame()
389 memcpy(__skb_put(nskb, ETH_ALEN + 2), s->eh.h_source, in bnep_rx_frame()
396 put_unaligned(s->eh.h_proto, (__be16 *) __skb_put(nskb, 2)); in bnep_rx_frame()
422 static int bnep_tx_frame(struct bnep_session *s, struct sk_buff *skb) in bnep_tx_frame() argument
425 struct socket *sock = s->sock; in bnep_tx_frame()
440 if (compress_src && ether_addr_equal(eh->h_dest, s->eh.h_source)) in bnep_tx_frame()
443 if (compress_dst && ether_addr_equal(eh->h_source, s->eh.h_dest)) in bnep_tx_frame()
468 len = kernel_sendmsg(sock, &s->msg, iv, il, len); in bnep_tx_frame()
473 s->dev->stats.tx_bytes += len; in bnep_tx_frame()
474 s->dev->stats.tx_packets++; in bnep_tx_frame()
483 struct bnep_session *s = arg; in bnep_session() local
484 struct net_device *dev = s->dev; in bnep_session()
485 struct sock *sk = s->sock->sk; in bnep_session()
498 if (atomic_read(&s->terminate)) in bnep_session()
504 bnep_rx_frame(s, skb); in bnep_session()
514 if (bnep_tx_frame(s, skb)) in bnep_session()
529 s->sock->sk->sk_err = EUNATCH; in bnep_session()
531 wake_up_interruptible(sk_sleep(s->sock->sk)); in bnep_session()
534 fput(s->sock->file); in bnep_session()
536 __bnep_unlink_session(s); in bnep_session()
562 struct bnep_session *s, *ss; in bnep_add_connection() local
593 s = netdev_priv(dev); in bnep_add_connection()
597 memcpy(s->eh.h_dest, &src, ETH_ALEN); in bnep_add_connection()
598 memcpy(s->eh.h_source, &dst, ETH_ALEN); in bnep_add_connection()
599 memcpy(dev->dev_addr, s->eh.h_dest, ETH_ALEN); in bnep_add_connection()
601 s->dev = dev; in bnep_add_connection()
602 s->sock = sock; in bnep_add_connection()
603 s->role = req->role; in bnep_add_connection()
604 s->state = BT_CONNECTED; in bnep_add_connection()
605 s->flags = req->flags; in bnep_add_connection()
607 s->msg.msg_flags = MSG_NOSIGNAL; in bnep_add_connection()
611 set_bit(bnep_mc_hash(dev->broadcast), (ulong *) &s->mc_filter); in bnep_add_connection()
616 bnep_set_default_proto_filter(s); in bnep_add_connection()
619 SET_NETDEV_DEV(dev, bnep_get_device(s)); in bnep_add_connection()
626 __bnep_link_session(s); in bnep_add_connection()
629 s->task = kthread_run(bnep_session, s, "kbnepd %s", dev->name); in bnep_add_connection()
630 if (IS_ERR(s->task)) { in bnep_add_connection()
634 __bnep_unlink_session(s); in bnep_add_connection()
635 err = PTR_ERR(s->task); in bnep_add_connection()
652 struct bnep_session *s; in bnep_del_connection() local
662 s = __bnep_get_session(req->dst); in bnep_del_connection()
663 if (s) { in bnep_del_connection()
664 atomic_inc(&s->terminate); in bnep_del_connection()
665 wake_up_interruptible(sk_sleep(s->sock->sk)); in bnep_del_connection()
673 static void __bnep_copy_ci(struct bnep_conninfo *ci, struct bnep_session *s) in __bnep_copy_ci() argument
678 memcpy(ci->dst, s->eh.h_source, ETH_ALEN); in __bnep_copy_ci()
679 strcpy(ci->device, s->dev->name); in __bnep_copy_ci()
680 ci->flags = s->flags & valid_flags; in __bnep_copy_ci()
681 ci->state = s->state; in __bnep_copy_ci()
682 ci->role = s->role; in __bnep_copy_ci()
687 struct bnep_session *s; in bnep_get_connlist() local
692 list_for_each_entry(s, &bnep_session_list, list) { in bnep_get_connlist()
695 __bnep_copy_ci(&ci, s); in bnep_get_connlist()
715 struct bnep_session *s; in bnep_get_conninfo() local
720 s = __bnep_get_session(ci->dst); in bnep_get_conninfo()
721 if (s) in bnep_get_conninfo()
722 __bnep_copy_ci(ci, s); in bnep_get_conninfo()