This source file includes following definitions.
- find_8022_client
- p8022_rcv
- p8022_datalink_header
- p8022_proto_init
- register_8022_client
1 #include <linux/netdevice.h>
2 #include <linux/skbuff.h>
3 #include "datalink.h"
4 #include <linux/mm.h>
5 #include <linux/in.h>
6
7 static struct datalink_proto *p8022_list = NULL;
8
9 static struct datalink_proto *
10 find_8022_client(unsigned char type)
11 {
12 struct datalink_proto *proto;
13
14 for (proto = p8022_list;
15 ((proto != NULL) && (*(proto->type) != type));
16 proto = proto->next)
17 ;
18
19 return proto;
20 }
21
22 int
23 p8022_rcv(struct sk_buff *skb, struct device *dev, struct packet_type *pt)
24 {
25 struct datalink_proto *proto;
26
27 proto = find_8022_client(*(skb->h.raw));
28 if (proto != NULL) {
29 skb->h.raw += 3;
30 skb->len -= 3;
31 return proto->rcvfunc(skb, dev, pt);
32 }
33
34 skb->sk = NULL;
35 kfree_skb(skb, FREE_READ);
36 return 0;
37 }
38
39 static void
40 p8022_datalink_header(struct datalink_proto *dl,
41 struct sk_buff *skb, unsigned char *dest_node)
42 {
43 struct device *dev = skb->dev;
44 unsigned long len = skb->len;
45 unsigned long hard_len = dev->hard_header_len;
46 unsigned char *rawp;
47
48 dev->hard_header(skb->data, dev, len - hard_len,
49 dest_node, NULL, len - hard_len, skb);
50 rawp = skb->data + hard_len;
51 *rawp = dl->type[0];
52 rawp++;
53 *rawp = dl->type[0];
54 rawp++;
55 *rawp = 0x03;
56 rawp++;
57 skb->h.raw = rawp;
58 }
59
60 static struct packet_type p8022_packet_type =
61 {
62 0,
63 NULL,
64 p8022_rcv,
65 NULL,
66 NULL,
67 };
68
69
70 void p8022_proto_init(struct net_proto *pro)
71 {
72 p8022_packet_type.type=htons(ETH_P_802_2);
73 dev_add_pack(&p8022_packet_type);
74 }
75
76 struct datalink_proto *
77 register_8022_client(unsigned char type, int (*rcvfunc)(struct sk_buff *, struct device *, struct packet_type *))
78 {
79 struct datalink_proto *proto;
80
81 if (find_8022_client(type) != NULL)
82 return NULL;
83
84 proto = (struct datalink_proto *) kmalloc(sizeof(*proto), GFP_ATOMIC);
85 if (proto != NULL) {
86 proto->type[0] = type;
87 proto->type_len = 1;
88 proto->rcvfunc = rcvfunc;
89 proto->header_length = 3;
90 proto->datalink_header = p8022_datalink_header;
91 proto->string_name = "802.2";
92 proto->next = p8022_list;
93 p8022_list = proto;
94 }
95
96 return proto;
97 }
98