1 /* SPDX-License-Identifier: GPL-2.0 */ 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _NET_GARP_H 2 #ifndef _NET_GARP_H 3 #define _NET_GARP_H 3 #define _NET_GARP_H 4 4 5 #include <linux/if_ether.h> 5 #include <linux/if_ether.h> 6 #include <linux/types.h> 6 #include <linux/types.h> 7 #include <net/stp.h> 7 #include <net/stp.h> 8 8 9 #define GARP_PROTOCOL_ID 0x1 9 #define GARP_PROTOCOL_ID 0x1 10 #define GARP_END_MARK 0x0 10 #define GARP_END_MARK 0x0 11 11 12 struct garp_pdu_hdr { 12 struct garp_pdu_hdr { 13 __be16 protocol; 13 __be16 protocol; 14 }; 14 }; 15 15 16 struct garp_msg_hdr { 16 struct garp_msg_hdr { 17 u8 attrtype; 17 u8 attrtype; 18 }; 18 }; 19 19 20 enum garp_attr_event { 20 enum garp_attr_event { 21 GARP_LEAVE_ALL, 21 GARP_LEAVE_ALL, 22 GARP_JOIN_EMPTY, 22 GARP_JOIN_EMPTY, 23 GARP_JOIN_IN, 23 GARP_JOIN_IN, 24 GARP_LEAVE_EMPTY, 24 GARP_LEAVE_EMPTY, 25 GARP_LEAVE_IN, 25 GARP_LEAVE_IN, 26 GARP_EMPTY, 26 GARP_EMPTY, 27 }; 27 }; 28 28 29 struct garp_attr_hdr { 29 struct garp_attr_hdr { 30 u8 len; 30 u8 len; 31 u8 event; 31 u8 event; 32 u8 data[]; 32 u8 data[]; 33 }; 33 }; 34 34 35 struct garp_skb_cb { 35 struct garp_skb_cb { 36 u8 cur_type; 36 u8 cur_type; 37 }; 37 }; 38 38 39 static inline struct garp_skb_cb *garp_cb(stru 39 static inline struct garp_skb_cb *garp_cb(struct sk_buff *skb) 40 { 40 { 41 BUILD_BUG_ON(sizeof(struct garp_skb_cb 41 BUILD_BUG_ON(sizeof(struct garp_skb_cb) > 42 sizeof_field(struct sk_bu 42 sizeof_field(struct sk_buff, cb)); 43 return (struct garp_skb_cb *)skb->cb; 43 return (struct garp_skb_cb *)skb->cb; 44 } 44 } 45 45 46 enum garp_applicant_state { 46 enum garp_applicant_state { 47 GARP_APPLICANT_INVALID, 47 GARP_APPLICANT_INVALID, 48 GARP_APPLICANT_VA, 48 GARP_APPLICANT_VA, 49 GARP_APPLICANT_AA, 49 GARP_APPLICANT_AA, 50 GARP_APPLICANT_QA, 50 GARP_APPLICANT_QA, 51 GARP_APPLICANT_LA, 51 GARP_APPLICANT_LA, 52 GARP_APPLICANT_VP, 52 GARP_APPLICANT_VP, 53 GARP_APPLICANT_AP, 53 GARP_APPLICANT_AP, 54 GARP_APPLICANT_QP, 54 GARP_APPLICANT_QP, 55 GARP_APPLICANT_VO, 55 GARP_APPLICANT_VO, 56 GARP_APPLICANT_AO, 56 GARP_APPLICANT_AO, 57 GARP_APPLICANT_QO, 57 GARP_APPLICANT_QO, 58 __GARP_APPLICANT_MAX 58 __GARP_APPLICANT_MAX 59 }; 59 }; 60 #define GARP_APPLICANT_MAX (__GARP_APPLIC 60 #define GARP_APPLICANT_MAX (__GARP_APPLICANT_MAX - 1) 61 61 62 enum garp_event { 62 enum garp_event { 63 GARP_EVENT_REQ_JOIN, 63 GARP_EVENT_REQ_JOIN, 64 GARP_EVENT_REQ_LEAVE, 64 GARP_EVENT_REQ_LEAVE, 65 GARP_EVENT_R_JOIN_IN, 65 GARP_EVENT_R_JOIN_IN, 66 GARP_EVENT_R_JOIN_EMPTY, 66 GARP_EVENT_R_JOIN_EMPTY, 67 GARP_EVENT_R_EMPTY, 67 GARP_EVENT_R_EMPTY, 68 GARP_EVENT_R_LEAVE_IN, 68 GARP_EVENT_R_LEAVE_IN, 69 GARP_EVENT_R_LEAVE_EMPTY, 69 GARP_EVENT_R_LEAVE_EMPTY, 70 GARP_EVENT_TRANSMIT_PDU, 70 GARP_EVENT_TRANSMIT_PDU, 71 __GARP_EVENT_MAX 71 __GARP_EVENT_MAX 72 }; 72 }; 73 #define GARP_EVENT_MAX (__GARP_EVENT_ 73 #define GARP_EVENT_MAX (__GARP_EVENT_MAX - 1) 74 74 75 enum garp_action { 75 enum garp_action { 76 GARP_ACTION_NONE, 76 GARP_ACTION_NONE, 77 GARP_ACTION_S_JOIN_IN, 77 GARP_ACTION_S_JOIN_IN, 78 GARP_ACTION_S_LEAVE_EMPTY, 78 GARP_ACTION_S_LEAVE_EMPTY, 79 }; 79 }; 80 80 81 struct garp_attr { 81 struct garp_attr { 82 struct rb_node node; 82 struct rb_node node; 83 enum garp_applicant_state state; 83 enum garp_applicant_state state; 84 u8 type; 84 u8 type; 85 u8 dlen; 85 u8 dlen; 86 unsigned char data[] 86 unsigned char data[]; 87 }; 87 }; 88 88 89 enum garp_applications { 89 enum garp_applications { 90 GARP_APPLICATION_GVRP, 90 GARP_APPLICATION_GVRP, 91 __GARP_APPLICATION_MAX 91 __GARP_APPLICATION_MAX 92 }; 92 }; 93 #define GARP_APPLICATION_MAX (__GARP_APPLIC 93 #define GARP_APPLICATION_MAX (__GARP_APPLICATION_MAX - 1) 94 94 95 struct garp_application { 95 struct garp_application { 96 enum garp_applications type; 96 enum garp_applications type; 97 unsigned int maxattr; 97 unsigned int maxattr; 98 struct stp_proto proto; 98 struct stp_proto proto; 99 }; 99 }; 100 100 101 struct garp_applicant { 101 struct garp_applicant { 102 struct garp_application *app; 102 struct garp_application *app; 103 struct net_device *dev; 103 struct net_device *dev; 104 struct timer_list join_timer; 104 struct timer_list join_timer; 105 105 106 spinlock_t lock; 106 spinlock_t lock; 107 struct sk_buff_head queue; 107 struct sk_buff_head queue; 108 struct sk_buff *pdu; 108 struct sk_buff *pdu; 109 struct rb_root gid; 109 struct rb_root gid; 110 struct rcu_head rcu; 110 struct rcu_head rcu; 111 }; 111 }; 112 112 113 struct garp_port { 113 struct garp_port { 114 struct garp_applicant __rcu *appli 114 struct garp_applicant __rcu *applicants[GARP_APPLICATION_MAX + 1]; 115 struct rcu_head rcu; 115 struct rcu_head rcu; 116 }; 116 }; 117 117 118 int garp_register_application(struct garp_appl 118 int garp_register_application(struct garp_application *app); 119 void garp_unregister_application(struct garp_a 119 void garp_unregister_application(struct garp_application *app); 120 120 121 int garp_init_applicant(struct net_device *dev 121 int garp_init_applicant(struct net_device *dev, struct garp_application *app); 122 void garp_uninit_applicant(struct net_device * 122 void garp_uninit_applicant(struct net_device *dev, 123 struct garp_applica 123 struct garp_application *app); 124 124 125 int garp_request_join(const struct net_device 125 int garp_request_join(const struct net_device *dev, 126 const struct garp_applic 126 const struct garp_application *app, const void *data, 127 u8 len, u8 type); 127 u8 len, u8 type); 128 void garp_request_leave(const struct net_devic 128 void garp_request_leave(const struct net_device *dev, 129 const struct garp_appl 129 const struct garp_application *app, 130 const void *data, u8 l 130 const void *data, u8 len, u8 type); 131 131 132 #endif /* _NET_GARP_H */ 132 #endif /* _NET_GARP_H */ 133 133
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.