Release 4.11 net/802/psnap.c
/*
* SNAP data link layer. Derived from 802.2
*
* Alan Cox <alan@lxorguk.ukuu.org.uk>,
* from the 802.2 layer by Greg Page.
* Merged in additions from Greg Page's psnap.c.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <linux/slab.h>
#include <net/datalink.h>
#include <net/llc.h>
#include <net/psnap.h>
#include <linux/mm.h>
#include <linux/in.h>
#include <linux/init.h>
#include <linux/rculist.h>
static LIST_HEAD(snap_list);
static DEFINE_SPINLOCK(snap_lock);
static struct llc_sap *snap_sap;
/*
* Find a snap client by matching the 5 bytes.
*/
static struct datalink_proto *find_snap_client(const unsigned char *desc)
{
struct datalink_proto *proto = NULL, *p;
list_for_each_entry_rcu(p, &snap_list, node) {
if (!memcmp(p->type, desc, 5)) {
proto = p;
break;
}
}
return proto;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 32 | 55.17% | 1 | 20.00% |
Arnaldo Carvalho de Melo | 21 | 36.21% | 2 | 40.00% |
Paul E. McKenney | 4 | 6.90% | 1 | 20.00% |
Stephen Hemminger | 1 | 1.72% | 1 | 20.00% |
Total | 58 | 100.00% | 5 | 100.00% |
/*
* A SNAP packet has arrived
*/
static int snap_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt, struct net_device *orig_dev)
{
int rc = 1;
struct datalink_proto *proto;
static struct packet_type snap_packet_type = {
.type = cpu_to_be16(ETH_P_SNAP),
};
if (unlikely(!pskb_may_pull(skb, 5)))
goto drop;
rcu_read_lock();
proto = find_snap_client(skb_transport_header(skb));
if (proto) {
/* Pass the frame on. */
skb->transport_header += 5;
skb_pull_rcsum(skb, 5);
rc = proto->rcvfunc(skb, dev, &snap_packet_type, orig_dev);
}
rcu_read_unlock();
if (unlikely(!proto))
goto drop;
out:
return rc;
drop:
kfree_skb(skb);
goto out;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Arnaldo Carvalho de Melo | 47 | 32.41% | 6 | 42.86% |
Herbert Xu | 40 | 27.59% | 2 | 14.29% |
Linus Torvalds (pre-git) | 37 | 25.52% | 3 | 21.43% |
Stephen Hemminger | 13 | 8.97% | 1 | 7.14% |
David S. Miller | 7 | 4.83% | 1 | 7.14% |
Harvey Harrison | 1 | 0.69% | 1 | 7.14% |
Total | 145 | 100.00% | 14 | 100.00% |
/*
* Put a SNAP header on a frame and pass to 802.2
*/
static int snap_request(struct datalink_proto *dl,
struct sk_buff *skb, u8 *dest)
{
memcpy(skb_push(skb, 5), dl->type, 5);
llc_build_and_send_ui_pkt(snap_sap, skb, dest, snap_sap->laddr.lsap);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 32 | 59.26% | 3 | 60.00% |
Arnaldo Carvalho de Melo | 22 | 40.74% | 2 | 40.00% |
Total | 54 | 100.00% | 5 | 100.00% |
/*
* Set up the SNAP layer
*/
EXPORT_SYMBOL(register_snap_client);
EXPORT_SYMBOL(unregister_snap_client);
static const char snap_err_msg[] __initconst =
KERN_CRIT "SNAP - unable to register with 802.2\n";
static int __init snap_init(void)
{
snap_sap = llc_sap_open(0xAA, snap_rcv);
if (!snap_sap) {
printk(snap_err_msg);
return -EBUSY;
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 23 | 62.16% | 3 | 37.50% |
Arnaldo Carvalho de Melo | 8 | 21.62% | 4 | 50.00% |
Stephen Hemminger | 6 | 16.22% | 1 | 12.50% |
Total | 37 | 100.00% | 8 | 100.00% |
module_init(snap_init);
static void __exit snap_exit(void)
{
llc_sap_put(snap_sap);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Arnaldo Carvalho de Melo | 14 | 100.00% | 2 | 100.00% |
Total | 14 | 100.00% | 2 | 100.00% |
module_exit(snap_exit);
/*
* Register SNAP clients. We don't yet use this for IP.
*/
struct datalink_proto *register_snap_client(const unsigned char *desc,
int (*rcvfunc)(struct sk_buff *,
struct net_device *,
struct packet_type *,
struct net_device *))
{
struct datalink_proto *proto = NULL;
spin_lock_bh(&snap_lock);
if (find_snap_client(desc))
goto out;
proto = kmalloc(sizeof(*proto), GFP_ATOMIC);
if (proto) {
memcpy(proto->type, desc, 5);
proto->rcvfunc = rcvfunc;
proto->header_length = 5 + 3; /* snap + 802.2 */
proto->request = snap_request;
list_add_rcu(&proto->node, &snap_list);
}
out:
spin_unlock_bh(&snap_lock);
return proto;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 97 | 73.48% | 2 | 28.57% |
Arnaldo Carvalho de Melo | 23 | 17.42% | 2 | 28.57% |
Stephen Hemminger | 8 | 6.06% | 2 | 28.57% |
David S. Miller | 4 | 3.03% | 1 | 14.29% |
Total | 132 | 100.00% | 7 | 100.00% |
/*
* Unregister SNAP clients. Protocols no longer want to play with us ...
*/
void unregister_snap_client(struct datalink_proto *proto)
{
spin_lock_bh(&snap_lock);
list_del_rcu(&proto->node);
spin_unlock_bh(&snap_lock);
synchronize_net();
kfree(proto);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 20 | 52.63% | 1 | 33.33% |
Stephen Hemminger | 12 | 31.58% | 1 | 33.33% |
Arnaldo Carvalho de Melo | 6 | 15.79% | 1 | 33.33% |
Total | 38 | 100.00% | 3 | 100.00% |
MODULE_LICENSE("GPL");
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 292 | 51.14% | 12 | 35.29% |
Arnaldo Carvalho de Melo | 167 | 29.25% | 10 | 29.41% |
Stephen Hemminger | 45 | 7.88% | 3 | 8.82% |
Herbert Xu | 40 | 7.01% | 2 | 5.88% |
David S. Miller | 11 | 1.93% | 1 | 2.94% |
Thomas Gleixner | 4 | 0.70% | 1 | 2.94% |
Paul E. McKenney | 4 | 0.70% | 1 | 2.94% |
Tejun Heo | 3 | 0.53% | 1 | 2.94% |
Franck Bui-Huu | 3 | 0.53% | 1 | 2.94% |
Harvey Harrison | 1 | 0.18% | 1 | 2.94% |
Alan Cox | 1 | 0.18% | 1 | 2.94% |
Total | 571 | 100.00% | 34 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.