Release 4.7 net/bluetooth/bnep/netdev.c
/*
BNEP implementation for Linux Bluetooth stack (BlueZ).
Copyright (C) 2001-2002 Inventel Systemes
Written 2001-2002 by
Clément Moreau <clement.moreau@inventel.fr>
David Libault <david.libault@inventel.fr>
Copyright (C) 2002 Maxim Krasnyansky <maxk@qualcomm.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation;
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
SOFTWARE IS DISCLAIMED.
*/
#include <linux/etherdevice.h>
#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>
#include <net/bluetooth/l2cap.h>
#include "bnep.h"
#define BNEP_TX_QUEUE_LEN 20
static int bnep_net_open(struct net_device *dev)
{
netif_start_queue(dev);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| maksim krasnyanskiy | maksim krasnyanskiy | 19 | 100.00% | 1 | 100.00% |
| Total | 19 | 100.00% | 1 | 100.00% |
static int bnep_net_close(struct net_device *dev)
{
netif_stop_queue(dev);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| maksim krasnyanskiy | maksim krasnyanskiy | 19 | 100.00% | 1 | 100.00% |
| Total | 19 | 100.00% | 1 | 100.00% |
static void bnep_net_set_mc_list(struct net_device *dev)
{
#ifdef CONFIG_BT_BNEP_MC_FILTER
struct bnep_session *s = netdev_priv(dev);
struct sock *sk = s->sock->sk;
struct bnep_set_filter_req *r;
struct sk_buff *skb;
int size;
BT_DBG("%s mc_count %d", dev->name, netdev_mc_count(dev));
size = sizeof(*r) + (BNEP_MAX_MULTICAST_FILTERS + 1) * ETH_ALEN * 2;
skb = alloc_skb(size, GFP_ATOMIC);
if (!skb) {
BT_ERR("%s Multicast list allocation failed", dev->name);
return;
}
r = (void *) skb->data;
__skb_put(skb, sizeof(*r));
r->type = BNEP_CONTROL;
r->ctrl = BNEP_FILTER_MULTI_ADDR_SET;
if (dev->flags & (IFF_PROMISC | IFF_ALLMULTI)) {
u8 start[ETH_ALEN] = { 0x01 };
/* Request all addresses */
memcpy(__skb_put(skb, ETH_ALEN), start, ETH_ALEN);
memcpy(__skb_put(skb, ETH_ALEN), dev->broadcast, ETH_ALEN);
r->len = htons(ETH_ALEN * 2);
} else {
struct netdev_hw_addr *ha;
int i, len = skb->len;
if (dev->flags & IFF_BROADCAST) {
memcpy(__skb_put(skb, ETH_ALEN), dev->broadcast, ETH_ALEN);
memcpy(__skb_put(skb, ETH_ALEN), dev->broadcast, ETH_ALEN);
}
/* FIXME: We should group addresses here. */
i = 0;
netdev_for_each_mc_addr(ha, dev) {
if (i == BNEP_MAX_MULTICAST_FILTERS)
break;
memcpy(__skb_put(skb, ETH_ALEN), ha->addr, ETH_ALEN);
memcpy(__skb_put(skb, ETH_ALEN), ha->addr, ETH_ALEN);
i++;
}
r->len = htons(skb->len - len);
}
skb_queue_tail(&sk->sk_write_queue, skb);
wake_up_interruptible(sk_sleep(sk));
#endif
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| maksim krasnyanskiy | maksim krasnyanskiy | 319 | 90.62% | 2 | 22.22% |
| jiri pirko | jiri pirko | 22 | 6.25% | 3 | 33.33% |
| eric dumazet | eric dumazet | 3 | 0.85% | 1 | 11.11% |
| wang chen | wang chen | 3 | 0.85% | 1 | 11.11% |
| gustavo f. padovan | gustavo f. padovan | 3 | 0.85% | 1 | 11.11% |
| arnaldo carvalho de melo | arnaldo carvalho de melo | 2 | 0.57% | 1 | 11.11% |
| Total | 352 | 100.00% | 9 | 100.00% |
static int bnep_net_set_mac_addr(struct net_device *dev, void *arg)
{
BT_DBG("%s", dev->name);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| maksim krasnyanskiy | maksim krasnyanskiy | 27 | 100.00% | 1 | 100.00% |
| Total | 27 | 100.00% | 1 | 100.00% |
static void bnep_net_timeout(struct net_device *dev)
{
BT_DBG("net_timeout");
netif_wake_queue(dev);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| maksim krasnyanskiy | maksim krasnyanskiy | 21 | 100.00% | 1 | 100.00% |
| Total | 21 | 100.00% | 1 | 100.00% |
#ifdef CONFIG_BT_BNEP_MC_FILTER
static int bnep_net_mc_filter(struct sk_buff *skb, struct bnep_session *s)
{
struct ethhdr *eh = (void *) skb->data;
if ((eh->h_dest[0] & 1) && !test_bit(bnep_mc_hash(eh->h_dest), (ulong *) &s->mc_filter))
return 1;
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| maksim krasnyanskiy | maksim krasnyanskiy | 68 | 100.00% | 1 | 100.00% |
| Total | 68 | 100.00% | 1 | 100.00% |
#endif
#ifdef CONFIG_BT_BNEP_PROTO_FILTER
/* Determine ether protocol. Based on eth_type_trans. */
static u16 bnep_net_eth_proto(struct sk_buff *skb)
{
struct ethhdr *eh = (void *) skb->data;
u16 proto = ntohs(eh->h_proto);
if (proto >= ETH_P_802_3_MIN)
return proto;
if (get_unaligned((__be16 *) skb->data) == htons(0xFFFF))
return ETH_P_802_3;
return ETH_P_802_2;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| maksim krasnyanskiy | maksim krasnyanskiy | 54 | 80.60% | 1 | 33.33% |
| al viro | al viro | 12 | 17.91% | 1 | 33.33% |
| simon horman | simon horman | 1 | 1.49% | 1 | 33.33% |
| Total | 67 | 100.00% | 3 | 100.00% |
static int bnep_net_proto_filter(struct sk_buff *skb, struct bnep_session *s)
{
u16 proto = bnep_net_eth_proto(skb);
struct bnep_proto_filter *f = s->proto_filter;
int i;
for (i = 0; i < BNEP_MAX_PROTO_FILTERS && f[i].end; i++) {
if (proto >= f[i].start && proto <= f[i].end)
return 0;
}
BT_DBG("BNEP: filtered skb %p, proto 0x%.4x", skb, proto);
return 1;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| maksim krasnyanskiy | maksim krasnyanskiy | 93 | 100.00% | 1 | 100.00% |
| Total | 93 | 100.00% | 1 | 100.00% |
#endif
static netdev_tx_t bnep_net_xmit(struct sk_buff *skb,
struct net_device *dev)
{
struct bnep_session *s = netdev_priv(dev);
struct sock *sk = s->sock->sk;
BT_DBG("skb %p, dev %p", skb, dev);
#ifdef CONFIG_BT_BNEP_MC_FILTER
if (bnep_net_mc_filter(skb, s)) {
kfree_skb(skb);
return NETDEV_TX_OK;
}
#endif
#ifdef CONFIG_BT_BNEP_PROTO_FILTER
if (bnep_net_proto_filter(skb, s)) {
kfree_skb(skb);
return NETDEV_TX_OK;
}
#endif
/*
* We cannot send L2CAP packets from here as we are potentially in a bh.
* So we have to queue them and wake up session thread which is sleeping
* on the sk_sleep(sk).
*/
netif_trans_update(dev);
skb_queue_tail(&sk->sk_write_queue, skb);
wake_up_interruptible(sk_sleep(sk));
if (skb_queue_len(&sk->sk_write_queue) >= BNEP_TX_QUEUE_LEN) {
BT_DBG("tx queue is full");
/* Stop queuing.
* Session thread will do netif_wake_queue() */
netif_stop_queue(dev);
}
return NETDEV_TX_OK;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| maksim krasnyanskiy | maksim krasnyanskiy | 129 | 88.36% | 2 | 25.00% |
| eric dumazet | eric dumazet | 4 | 2.74% | 1 | 12.50% |
| florian westphal | florian westphal | 3 | 2.05% | 1 | 12.50% |
| patrick mchardy | patrick mchardy | 3 | 2.05% | 1 | 12.50% |
| arnaldo carvalho de melo | arnaldo carvalho de melo | 3 | 2.05% | 1 | 12.50% |
| wang chen | wang chen | 3 | 2.05% | 1 | 12.50% |
| stephen hemminger | stephen hemminger | 1 | 0.68% | 1 | 12.50% |
| Total | 146 | 100.00% | 8 | 100.00% |
static const struct net_device_ops bnep_netdev_ops = {
.ndo_open = bnep_net_open,
.ndo_stop = bnep_net_close,
.ndo_start_xmit = bnep_net_xmit,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_rx_mode = bnep_net_set_mc_list,
.ndo_set_mac_address = bnep_net_set_mac_addr,
.ndo_tx_timeout = bnep_net_timeout,
.ndo_change_mtu = eth_change_mtu,
};
void bnep_net_setup(struct net_device *dev)
{
eth_broadcast_addr(dev->broadcast);
dev->addr_len = ETH_ALEN;
ether_setup(dev);
dev->priv_flags &= ~IFF_TX_SKB_SHARING;
dev->netdev_ops = &bnep_netdev_ops;
dev->watchdog_timeo = HZ * 2;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| maksim krasnyanskiy | maksim krasnyanskiy | 39 | 78.00% | 2 | 40.00% |
| neil horman | neil horman | 7 | 14.00% | 1 | 20.00% |
| stephen hemminger | stephen hemminger | 3 | 6.00% | 1 | 20.00% |
| joe perches | joe perches | 1 | 2.00% | 1 | 20.00% |
| Total | 50 | 100.00% | 5 | 100.00% |
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| maksim krasnyanskiy | maksim krasnyanskiy | 818 | 86.93% | 3 | 15.00% |
| stephen hemminger | stephen hemminger | 51 | 5.42% | 2 | 10.00% |
| jiri pirko | jiri pirko | 23 | 2.44% | 4 | 20.00% |
| al viro | al viro | 12 | 1.28% | 1 | 5.00% |
| neil horman | neil horman | 7 | 0.74% | 1 | 5.00% |
| eric dumazet | eric dumazet | 7 | 0.74% | 1 | 5.00% |
| wang chen | wang chen | 6 | 0.64% | 1 | 5.00% |
| arnaldo carvalho de melo | arnaldo carvalho de melo | 5 | 0.53% | 1 | 5.00% |
| florian westphal | florian westphal | 3 | 0.32% | 1 | 5.00% |
| gustavo f. padovan | gustavo f. padovan | 3 | 0.32% | 1 | 5.00% |
| patrick mchardy | patrick mchardy | 3 | 0.32% | 1 | 5.00% |
| jan engelhardt | jan engelhardt | 1 | 0.11% | 1 | 5.00% |
| joe perches | joe perches | 1 | 0.11% | 1 | 5.00% |
| simon horman | simon horman | 1 | 0.11% | 1 | 5.00% |
| Total | 941 | 100.00% | 20 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.