diff options
| author | Arnaldo Carvalho de Melo <acme@conectiva.com.br> | 2002-05-30 18:36:32 -0300 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@conectiva.com.br> | 2002-05-30 18:36:32 -0300 |
| commit | 34beb106cde7da233d4df35dd3d6cf4fee937caa (patch) | |
| tree | 2f6047513722259104cccc8fcb3aded043af4ce3 /net/core | |
| parent | d0f0cde199764cb083b3617c3739f45b1a73052d (diff) | |
net/llc/*.c
Forward port of LLC from 2.4 to 2.5. This is the forward port of the LLC stack
released by Procom Inc. for Linux 2.0.30, I have heavily modified it to make
it similar to other Linux network stacks, using of struct sk_buff to represent
in-transit packets and doing massive code cleanups.
Jay Schullist contributed support for BSD Sockets, as the original code had
only a simple in kernel API for use by upper layer protocols, such as the
NetBEUI stack also provided by Procom for 2.0.30.
This code is basically what I had previously submitted to Alan Cox for his
2.4-ac series and that is even shipped in source form, in the Red Hat 7.3
kernel package, plus cleanups wrt standard syntax for labeled elements and
further use of this C construct to make the code more resilient to editing
mistakes, using the compiler to further check the source code.
TODO:
Make it completely SMP safe, as the reports of successful usage up to now and
the testing is done on UP.
Completely remove the old LLC code in the kernel, that is still there for things
like Appletalk, IPX, etc to use, also check that all these protocols work
correctly with this new LLC stack.
This code is already being used in the linux-sna project and Jay Schullist
has been developing support for things like DLSw and other protocols that works
on top of 802.2.
I'll be releasing patches with the NetBEUI stack and updated samba-2.0.6 patches
for use with NetBEUI and this LLC stack in the future. But the NetBEUI code
is available already in my kernel.org ftp area at:
ftp://ftp.kernel.org/pub/linux/kernel/people/acme.
Please report problems to me or the linux-sna mailing list, instructions on how
to subscribe are available at http://www.linux-sna.org website.
Diffstat (limited to 'net/core')
| -rw-r--r-- | net/core/Makefile | 6 | ||||
| -rw-r--r-- | net/core/ext8022.c | 76 |
2 files changed, 81 insertions, 1 deletions
diff --git a/net/core/Makefile b/net/core/Makefile index 5dacce00c212..a87f6eb0a921 100644 --- a/net/core/Makefile +++ b/net/core/Makefile @@ -9,7 +9,7 @@ O_TARGET := core.o -export-objs := netfilter.o profile.o +export-objs := ext8022.o netfilter.o profile.o obj-y := sock.o skbuff.o iovec.o datagram.o scm.o @@ -23,6 +23,10 @@ obj-$(CONFIG_FILTER) += filter.o obj-$(CONFIG_NET) += dev.o dev_mcast.o dst.o neighbour.o rtnetlink.o utils.o +ifneq ($(CONFIG_LLC),n) +obj-y += ext8022.o +endif + obj-$(CONFIG_NETFILTER) += netfilter.o obj-$(CONFIG_NET_DIVERT) += dv.o obj-$(CONFIG_NET_PROFILE) += profile.o diff --git a/net/core/ext8022.c b/net/core/ext8022.c new file mode 100644 index 000000000000..e6415d51accb --- /dev/null +++ b/net/core/ext8022.c @@ -0,0 +1,76 @@ +/* + * (ext8022.c) + * + * Copyright (c) 1997 by Procom Technology, Inc. + * 2001 by Arnaldo Carvalho de Melo <acme@conectiva.com.br> + * + * This program can be redistributed or modified under the terms of the + * GNU General Public License as published by the Free Software Foundation. + * This program is distributed without any warranty or implied warranty + * of merchantability or fitness for a particular purpose. + * + * See the GNU General Public License for more details. + */ +#include <linux/config.h> +#include <linux/module.h> +#include <linux/netdevice.h> +#include <linux/brlock.h> + +typedef int (*func_type)(struct sk_buff *skb, struct net_device *dev, + struct packet_type *pt); +static int llc_rcv(struct sk_buff *skb, struct net_device *dev, + struct packet_type *); + +static func_type llc_sap_table[128]; +static int llc_users; + +static struct packet_type llc_packet_type = { + type: __constant_htons(ETH_P_802_2), + func: llc_rcv, +}; +static struct packet_type llc_tr_packet_type = { + type: __constant_htons(ETH_P_TR_802_2), + func: llc_rcv, +}; + +static int llc_rcv(struct sk_buff *skb, struct net_device *dev, + struct packet_type *pt) +{ + unsigned char n = (*(skb->h.raw)) >> 1; + + br_read_lock(BR_LLC_LOCK); + if (llc_sap_table[n]) + llc_sap_table[n](skb, dev, pt); + else + kfree_skb(skb); + br_read_unlock(BR_LLC_LOCK); + return 0; +} + +void llc_register_sap(unsigned char sap, func_type rcvfunc) +{ + sap >>= 1; + br_write_lock_bh(BR_LLC_LOCK); + llc_sap_table[sap] = rcvfunc; + if (!llc_users) { + dev_add_pack(&llc_packet_type); + dev_add_pack(&llc_tr_packet_type); + } + llc_users++; + br_write_unlock_bh(BR_LLC_LOCK); +} + +void llc_unregister_sap(unsigned char sap) +{ + sap >>= 1; + br_write_lock_bh(BR_LLC_LOCK); + llc_sap_table[sap] = NULL; + if (!--llc_users) { + dev_remove_pack(&llc_packet_type); + dev_remove_pack(&llc_tr_packet_type); + } + br_write_unlock_bh(BR_LLC_LOCK); +} + +EXPORT_SYMBOL(llc_register_sap); +EXPORT_SYMBOL(llc_unregister_sap); |
