Linux Audio

Check our new training course

Buildroot integration, development and maintenance

Need a Buildroot system for your embedded project?
Loading...
v3.1
 
 1/*
 2 *	NET3:	Support for 802.2 demultiplexing off Ethernet (Token ring
 3 *		is kept separate see p8022tr.c)
 4 *		This program is free software; you can redistribute it and/or
 5 *		modify it under the terms of the GNU General Public License
 6 *		as published by the Free Software Foundation; either version
 7 *		2 of the License, or (at your option) any later version.
 8 *
 9 *		Demultiplex 802.2 encoded protocols. We match the entry by the
10 *		SSAP/DSAP pair and then deliver to the registered datalink that
11 *		matches. The control byte is ignored and handling of such items
12 *		is up to the routine passed the frame.
13 *
14 *		Unlike the 802.3 datalink we have a list of 802.2 entries as
15 *		there are multiple protocols to demux. The list is currently
16 *		short (3 or 4 entries at most). The current demux assumes this.
17 */
18#include <linux/module.h>
19#include <linux/netdevice.h>
20#include <linux/skbuff.h>
21#include <linux/slab.h>
22#include <net/datalink.h>
23#include <linux/mm.h>
24#include <linux/in.h>
25#include <linux/init.h>
26#include <net/llc.h>
27#include <net/p8022.h>
28
29static int p8022_request(struct datalink_proto *dl, struct sk_buff *skb,
30			 unsigned char *dest)
31{
32	llc_build_and_send_ui_pkt(dl->sap, skb, dest, dl->sap->laddr.lsap);
33	return 0;
34}
35
36struct datalink_proto *register_8022_client(unsigned char type,
37					    int (*func)(struct sk_buff *skb,
38							struct net_device *dev,
39							struct packet_type *pt,
40							struct net_device *orig_dev))
41{
42	struct datalink_proto *proto;
43
44	proto = kmalloc(sizeof(*proto), GFP_ATOMIC);
45	if (proto) {
46		proto->type[0]		= type;
47		proto->header_length	= 3;
48		proto->request		= p8022_request;
49		proto->sap = llc_sap_open(type, func);
50		if (!proto->sap) {
51			kfree(proto);
52			proto = NULL;
53		}
54	}
55	return proto;
56}
57
58void unregister_8022_client(struct datalink_proto *proto)
59{
60	llc_sap_put(proto->sap);
61	kfree(proto);
62}
63
64EXPORT_SYMBOL(register_8022_client);
65EXPORT_SYMBOL(unregister_8022_client);
66
 
67MODULE_LICENSE("GPL");
v6.9.4
 1// SPDX-License-Identifier: GPL-2.0-or-later
 2/*
 3 *	NET3:	Support for 802.2 demultiplexing off Ethernet
 
 
 
 
 
 4 *
 5 *		Demultiplex 802.2 encoded protocols. We match the entry by the
 6 *		SSAP/DSAP pair and then deliver to the registered datalink that
 7 *		matches. The control byte is ignored and handling of such items
 8 *		is up to the routine passed the frame.
 9 *
10 *		Unlike the 802.3 datalink we have a list of 802.2 entries as
11 *		there are multiple protocols to demux. The list is currently
12 *		short (3 or 4 entries at most). The current demux assumes this.
13 */
14#include <linux/module.h>
15#include <linux/netdevice.h>
16#include <linux/skbuff.h>
17#include <linux/slab.h>
18#include <net/datalink.h>
19#include <linux/mm.h>
20#include <linux/in.h>
21#include <linux/init.h>
22#include <net/llc.h>
23#include <net/p8022.h>
24
25static int p8022_request(struct datalink_proto *dl, struct sk_buff *skb,
26			 const unsigned char *dest)
27{
28	llc_build_and_send_ui_pkt(dl->sap, skb, dest, dl->sap->laddr.lsap);
29	return 0;
30}
31
32struct datalink_proto *register_8022_client(unsigned char type,
33					    int (*func)(struct sk_buff *skb,
34							struct net_device *dev,
35							struct packet_type *pt,
36							struct net_device *orig_dev))
37{
38	struct datalink_proto *proto;
39
40	proto = kmalloc(sizeof(*proto), GFP_ATOMIC);
41	if (proto) {
42		proto->type[0]		= type;
43		proto->header_length	= 3;
44		proto->request		= p8022_request;
45		proto->sap = llc_sap_open(type, func);
46		if (!proto->sap) {
47			kfree(proto);
48			proto = NULL;
49		}
50	}
51	return proto;
52}
53
54void unregister_8022_client(struct datalink_proto *proto)
55{
56	llc_sap_put(proto->sap);
57	kfree(proto);
58}
59
60EXPORT_SYMBOL(register_8022_client);
61EXPORT_SYMBOL(unregister_8022_client);
62
63MODULE_DESCRIPTION("Support for 802.2 demultiplexing off Ethernet");
64MODULE_LICENSE("GPL");