Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  *  NET3:   Support for 802.2 demultiplexing off Ethernet
0004  *
0005  *      Demultiplex 802.2 encoded protocols. We match the entry by the
0006  *      SSAP/DSAP pair and then deliver to the registered datalink that
0007  *      matches. The control byte is ignored and handling of such items
0008  *      is up to the routine passed the frame.
0009  *
0010  *      Unlike the 802.3 datalink we have a list of 802.2 entries as
0011  *      there are multiple protocols to demux. The list is currently
0012  *      short (3 or 4 entries at most). The current demux assumes this.
0013  */
0014 #include <linux/module.h>
0015 #include <linux/netdevice.h>
0016 #include <linux/skbuff.h>
0017 #include <linux/slab.h>
0018 #include <net/datalink.h>
0019 #include <linux/mm.h>
0020 #include <linux/in.h>
0021 #include <linux/init.h>
0022 #include <net/llc.h>
0023 #include <net/p8022.h>
0024 
0025 static int p8022_request(struct datalink_proto *dl, struct sk_buff *skb,
0026              const unsigned char *dest)
0027 {
0028     llc_build_and_send_ui_pkt(dl->sap, skb, dest, dl->sap->laddr.lsap);
0029     return 0;
0030 }
0031 
0032 struct datalink_proto *register_8022_client(unsigned char type,
0033                         int (*func)(struct sk_buff *skb,
0034                             struct net_device *dev,
0035                             struct packet_type *pt,
0036                             struct net_device *orig_dev))
0037 {
0038     struct datalink_proto *proto;
0039 
0040     proto = kmalloc(sizeof(*proto), GFP_ATOMIC);
0041     if (proto) {
0042         proto->type[0]      = type;
0043         proto->header_length    = 3;
0044         proto->request      = p8022_request;
0045         proto->sap = llc_sap_open(type, func);
0046         if (!proto->sap) {
0047             kfree(proto);
0048             proto = NULL;
0049         }
0050     }
0051     return proto;
0052 }
0053 
0054 void unregister_8022_client(struct datalink_proto *proto)
0055 {
0056     llc_sap_put(proto->sap);
0057     kfree(proto);
0058 }
0059 
0060 EXPORT_SYMBOL(register_8022_client);
0061 EXPORT_SYMBOL(unregister_8022_client);
0062 
0063 MODULE_LICENSE("GPL");