diff options
author | Patrick McHardy <kaber@trash.net> | 2008-07-06 00:26:13 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-07-06 00:26:13 -0400 |
commit | eca9ebac651f774d8b10fce7c5d173c3c3d3394f (patch) | |
tree | 58b4117a0820dff43d4faa7fdcae5cd7723674c7 /include/net/garp.h | |
parent | 7c85fbf0657f216557b0c9c4a2e4e07f37d8bb8c (diff) |
net: Add GARP applicant-only participant
Add an implementation of the GARP (Generic Attribute Registration Protocol)
applicant-only participant. This will be used by the following patch to
add GVRP support to the VLAN code.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/garp.h')
-rw-r--r-- | include/net/garp.h | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/include/net/garp.h b/include/net/garp.h new file mode 100644 index 000000000000..73c772395f5b --- /dev/null +++ b/include/net/garp.h | |||
@@ -0,0 +1,127 @@ | |||
1 | #ifndef _NET_GARP_H | ||
2 | #define _NET_GARP_H | ||
3 | |||
4 | #include <net/stp.h> | ||
5 | |||
6 | #define GARP_PROTOCOL_ID 0x1 | ||
7 | #define GARP_END_MARK 0x0 | ||
8 | |||
9 | struct garp_pdu_hdr { | ||
10 | __be16 protocol; | ||
11 | }; | ||
12 | |||
13 | struct garp_msg_hdr { | ||
14 | u8 attrtype; | ||
15 | }; | ||
16 | |||
17 | enum garp_attr_event { | ||
18 | GARP_LEAVE_ALL, | ||
19 | GARP_JOIN_EMPTY, | ||
20 | GARP_JOIN_IN, | ||
21 | GARP_LEAVE_EMPTY, | ||
22 | GARP_LEAVE_IN, | ||
23 | GARP_EMPTY, | ||
24 | }; | ||
25 | |||
26 | struct garp_attr_hdr { | ||
27 | u8 len; | ||
28 | u8 event; | ||
29 | u8 data[]; | ||
30 | }; | ||
31 | |||
32 | struct garp_skb_cb { | ||
33 | u8 cur_type; | ||
34 | }; | ||
35 | |||
36 | static inline struct garp_skb_cb *garp_cb(struct sk_buff *skb) | ||
37 | { | ||
38 | BUILD_BUG_ON(sizeof(struct garp_skb_cb) > | ||
39 | FIELD_SIZEOF(struct sk_buff, cb)); | ||
40 | return (struct garp_skb_cb *)skb->cb; | ||
41 | } | ||
42 | |||
43 | enum garp_applicant_state { | ||
44 | GARP_APPLICANT_INVALID, | ||
45 | GARP_APPLICANT_VA, | ||
46 | GARP_APPLICANT_AA, | ||
47 | GARP_APPLICANT_QA, | ||
48 | GARP_APPLICANT_LA, | ||
49 | GARP_APPLICANT_VP, | ||
50 | GARP_APPLICANT_AP, | ||
51 | GARP_APPLICANT_QP, | ||
52 | GARP_APPLICANT_VO, | ||
53 | GARP_APPLICANT_AO, | ||
54 | GARP_APPLICANT_QO, | ||
55 | __GARP_APPLICANT_MAX | ||
56 | }; | ||
57 | #define GARP_APPLICANT_MAX (__GARP_APPLICANT_MAX - 1) | ||
58 | |||
59 | enum garp_event { | ||
60 | GARP_EVENT_REQ_JOIN, | ||
61 | GARP_EVENT_REQ_LEAVE, | ||
62 | GARP_EVENT_R_JOIN_IN, | ||
63 | GARP_EVENT_R_JOIN_EMPTY, | ||
64 | GARP_EVENT_R_EMPTY, | ||
65 | GARP_EVENT_R_LEAVE_IN, | ||
66 | GARP_EVENT_R_LEAVE_EMPTY, | ||
67 | GARP_EVENT_TRANSMIT_PDU, | ||
68 | __GARP_EVENT_MAX | ||
69 | }; | ||
70 | #define GARP_EVENT_MAX (__GARP_EVENT_MAX - 1) | ||
71 | |||
72 | enum garp_action { | ||
73 | GARP_ACTION_NONE, | ||
74 | GARP_ACTION_S_JOIN_IN, | ||
75 | GARP_ACTION_S_LEAVE_EMPTY, | ||
76 | }; | ||
77 | |||
78 | struct garp_attr { | ||
79 | struct rb_node node; | ||
80 | enum garp_applicant_state state; | ||
81 | u8 type; | ||
82 | u8 dlen; | ||
83 | unsigned char data[]; | ||
84 | }; | ||
85 | |||
86 | enum garp_applications { | ||
87 | __GARP_APPLICATION_MAX | ||
88 | }; | ||
89 | #define GARP_APPLICATION_MAX (__GARP_APPLICATION_MAX - 1) | ||
90 | |||
91 | struct garp_application { | ||
92 | enum garp_applications type; | ||
93 | unsigned int maxattr; | ||
94 | struct stp_proto proto; | ||
95 | }; | ||
96 | |||
97 | struct garp_applicant { | ||
98 | struct garp_application *app; | ||
99 | struct net_device *dev; | ||
100 | struct timer_list join_timer; | ||
101 | |||
102 | spinlock_t lock; | ||
103 | struct sk_buff_head queue; | ||
104 | struct sk_buff *pdu; | ||
105 | struct rb_root gid; | ||
106 | }; | ||
107 | |||
108 | struct garp_port { | ||
109 | struct garp_applicant *applicants[GARP_APPLICATION_MAX + 1]; | ||
110 | }; | ||
111 | |||
112 | extern int garp_register_application(struct garp_application *app); | ||
113 | extern void garp_unregister_application(struct garp_application *app); | ||
114 | |||
115 | extern int garp_init_applicant(struct net_device *dev, | ||
116 | struct garp_application *app); | ||
117 | extern void garp_uninit_applicant(struct net_device *dev, | ||
118 | struct garp_application *app); | ||
119 | |||
120 | extern int garp_request_join(const struct net_device *dev, | ||
121 | const struct garp_application *app, | ||
122 | const void *data, u8 len, u8 type); | ||
123 | extern void garp_request_leave(const struct net_device *dev, | ||
124 | const struct garp_application *app, | ||
125 | const void *data, u8 len, u8 type); | ||
126 | |||
127 | #endif /* _NET_GARP_H */ | ||