Blame view

net/802/p8022.c 1.66 KB
2874c5fd2   Thomas Gleixner   treewide: Replace...
1
  // SPDX-License-Identifier: GPL-2.0-or-later
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
  /*
211ed8651   Paul Gortmaker   net: delete all i...
3
   *	NET3:	Support for 802.2 demultiplexing off Ethernet
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
4
5
6
7
8
9
10
11
12
13
14
15
16
   *
   *		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.
   *
   *		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.
   */
  #include <linux/module.h>
  #include <linux/netdevice.h>
  #include <linux/skbuff.h>
5a0e3ad6a   Tejun Heo   include cleanup: ...
17
  #include <linux/slab.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
  #include <net/datalink.h>
  #include <linux/mm.h>
  #include <linux/in.h>
  #include <linux/init.h>
  #include <net/llc.h>
  #include <net/p8022.h>
  
  static int p8022_request(struct datalink_proto *dl, struct sk_buff *skb,
  			 unsigned char *dest)
  {
  	llc_build_and_send_ui_pkt(dl->sap, skb, dest, dl->sap->laddr.lsap);
  	return 0;
  }
  
  struct datalink_proto *register_8022_client(unsigned char type,
  					    int (*func)(struct sk_buff *skb,
  							struct net_device *dev,
f2ccd8fa0   David S. Miller   [NET]: Kill skb->...
35
36
  							struct packet_type *pt,
  							struct net_device *orig_dev))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
  {
  	struct datalink_proto *proto;
  
  	proto = kmalloc(sizeof(*proto), GFP_ATOMIC);
  	if (proto) {
  		proto->type[0]		= type;
  		proto->header_length	= 3;
  		proto->request		= p8022_request;
  		proto->sap = llc_sap_open(type, func);
  		if (!proto->sap) {
  			kfree(proto);
  			proto = NULL;
  		}
  	}
  	return proto;
  }
  
  void unregister_8022_client(struct datalink_proto *proto)
  {
6e2144b76   Arnaldo Carvalho de Melo   [LLC]: Use refcou...
56
  	llc_sap_put(proto->sap);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
57
58
59
60
61
62
63
  	kfree(proto);
  }
  
  EXPORT_SYMBOL(register_8022_client);
  EXPORT_SYMBOL(unregister_8022_client);
  
  MODULE_LICENSE("GPL");