p8022.c 1.86 KB
Newer Older
Linus Torvalds's avatar
Linus Torvalds committed
1 2 3 4 5 6 7 8 9 10 11 12 13
/*
 *	NET3:	Support for 802.2 demultiplexing off Ethernet (Token ring
 *		is kept separate see p8022tr.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.
 *
 *		Demultiplex 802.2 encoded protocols. We match the entry by the
 *		SSAP/DSAP pair and then deliver to the registered datalink that
 *		matches. The control byte is ignored and handling of such items
 *		is up to the routine passed the frame.
 *
Arnaldo Carvalho de Melo's avatar
Arnaldo Carvalho de Melo committed
14 15 16
 *		Unlike the 802.3 datalink we have a list of 802.2 entries as
 *		there are multiple protocols to demux. The list is currently
 *		short (3 or 4 entries at most). The current demux assumes this.
Linus Torvalds's avatar
Linus Torvalds committed
17 18 19 20 21 22 23 24 25
 */
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <net/datalink.h>
#include <linux/mm.h>
#include <linux/in.h>
#include <linux/init.h>
#include <net/p8022.h>
26
#include <net/llc_sap.h>
Linus Torvalds's avatar
Linus Torvalds committed
27

28 29
static int p8022_request(struct datalink_proto *dl, struct sk_buff *skb,
			 unsigned char *dest)
Linus Torvalds's avatar
Linus Torvalds committed
30
{
31 32
	llc_build_and_send_ui_pkt(dl->sap, skb, dest, dl->sap->laddr.lsap);
	return 0;
Linus Torvalds's avatar
Linus Torvalds committed
33 34
}

Arnaldo Carvalho de Melo's avatar
Arnaldo Carvalho de Melo committed
35
struct datalink_proto *register_8022_client(unsigned char type,
36 37 38
					    int (*func)(struct sk_buff *skb,
							struct net_device *dev,
							struct packet_type *pt))
Linus Torvalds's avatar
Linus Torvalds committed
39
{
40
	struct datalink_proto *proto;
Arnaldo Carvalho de Melo's avatar
Arnaldo Carvalho de Melo committed
41 42 43 44 45

	proto = kmalloc(sizeof(*proto), GFP_ATOMIC);
	if (proto) {
		proto->type[0]		= type;
		proto->header_length	= 3;
46
		proto->request		= p8022_request;
47
		proto->sap = llc_sap_open(type, func);
48 49 50 51
		if (!proto->sap) {
			kfree(proto);
			proto = NULL;
		}
Linus Torvalds's avatar
Linus Torvalds committed
52
	}
53
	return proto;
Linus Torvalds's avatar
Linus Torvalds committed
54 55
}

56
void unregister_8022_client(struct datalink_proto *proto)
Linus Torvalds's avatar
Linus Torvalds committed
57
{
58 59
	llc_sap_close(proto->sap);
	kfree(proto);
Linus Torvalds's avatar
Linus Torvalds committed
60
}
Arnaldo Carvalho de Melo's avatar
Arnaldo Carvalho de Melo committed
61 62 63

EXPORT_SYMBOL(register_8022_client);
EXPORT_SYMBOL(unregister_8022_client);
64 65

MODULE_LICENSE("GPL");