1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#include <linux/module.h>
18#include <linux/netdevice.h>
19#include <linux/skbuff.h>
20#include <linux/slab.h>
21#include <net/datalink.h>
22#include <linux/mm.h>
23#include <linux/in.h>
24#include <linux/init.h>
25#include <net/llc.h>
26#include <net/p8022.h>
27
28static int p8022_request(struct datalink_proto *dl, struct sk_buff *skb,
29 unsigned char *dest)
30{
31 llc_build_and_send_ui_pkt(dl->sap, skb, dest, dl->sap->laddr.lsap);
32 return 0;
33}
34
35struct datalink_proto *register_8022_client(unsigned char type,
36 int (*func)(struct sk_buff *skb,
37 struct net_device *dev,
38 struct packet_type *pt,
39 struct net_device *orig_dev))
40{
41 struct datalink_proto *proto;
42
43 proto = kmalloc(sizeof(*proto), GFP_ATOMIC);
44 if (proto) {
45 proto->type[0] = type;
46 proto->header_length = 3;
47 proto->request = p8022_request;
48 proto->sap = llc_sap_open(type, func);
49 if (!proto->sap) {
50 kfree(proto);
51 proto = NULL;
52 }
53 }
54 return proto;
55}
56
57void unregister_8022_client(struct datalink_proto *proto)
58{
59 llc_sap_put(proto->sap);
60 kfree(proto);
61}
62
63EXPORT_SYMBOL(register_8022_client);
64EXPORT_SYMBOL(unregister_8022_client);
65
66MODULE_LICENSE("GPL");
67