1193323Sed// SPDX-License-Identifier: GPL-2.0-or-later 2193323Sed/* 3193323Sed * NET3: Support for 802.2 demultiplexing off Ethernet 4193323Sed * 5193323Sed * Demultiplex 802.2 encoded protocols. We match the entry by the 6193323Sed * SSAP/DSAP pair and then deliver to the registered datalink that 7193323Sed * matches. The control byte is ignored and handling of such items 8193323Sed * is up to the routine passed the frame. 9193323Sed * 10193323Sed * Unlike the 802.3 datalink we have a list of 802.2 entries as 11193323Sed * there are multiple protocols to demux. The list is currently 12193323Sed * short (3 or 4 entries at most). The current demux assumes this. 13193323Sed */ 14193323Sed#include <linux/module.h> 15193323Sed#include <linux/netdevice.h> 16193323Sed#include <linux/skbuff.h> 17193323Sed#include <linux/slab.h> 18193323Sed#include <net/datalink.h> 19193323Sed#include <linux/mm.h> 20193323Sed#include <linux/in.h> 21193323Sed#include <linux/init.h> 22193323Sed#include <net/llc.h> 23193323Sed#include <net/p8022.h> 24193323Sed 25193323Sedstatic int p8022_request(struct datalink_proto *dl, struct sk_buff *skb, 26193323Sed const unsigned char *dest) 27193323Sed{ 28193323Sed llc_build_and_send_ui_pkt(dl->sap, skb, dest, dl->sap->laddr.lsap); 29193323Sed return 0; 30193323Sed} 31193323Sed 32252723Sdimstruct datalink_proto *register_8022_client(unsigned char type, 33252723Sdim int (*func)(struct sk_buff *skb, 34252723Sdim struct net_device *dev, 35252723Sdim struct packet_type *pt, 36252723Sdim struct net_device *orig_dev)) 37252723Sdim{ 38245431Sdim struct datalink_proto *proto; 39193323Sed 40193323Sed proto = kmalloc(sizeof(*proto), GFP_ATOMIC); 41193323Sed if (proto) { 42210299Sed proto->type[0] = type; 43193323Sed proto->header_length = 3; 44252723Sdim proto->request = p8022_request; 45235633Sdim proto->sap = llc_sap_open(type, func); 46252723Sdim if (!proto->sap) { 47252723Sdim kfree(proto); 48252723Sdim proto = NULL; 49193323Sed } 50193323Sed } 51252723Sdim return proto; 52193323Sed} 53193323Sed 54193323Sedvoid unregister_8022_client(struct datalink_proto *proto) 55193323Sed{ 56193323Sed llc_sap_put(proto->sap); 57193323Sed kfree(proto); 58193323Sed} 59235633Sdim 60235633SdimEXPORT_SYMBOL(register_8022_client); 61193323SedEXPORT_SYMBOL(unregister_8022_client); 62252723Sdim 63252723SdimMODULE_DESCRIPTION("Support for 802.2 demultiplexing off Ethernet"); 64252723SdimMODULE_LICENSE("GPL"); 65252723Sdim