Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _NET_GARP_H
0003 #define _NET_GARP_H
0004 
0005 #include <linux/if_ether.h>
0006 #include <linux/types.h>
0007 #include <net/stp.h>
0008 
0009 #define GARP_PROTOCOL_ID    0x1
0010 #define GARP_END_MARK       0x0
0011 
0012 struct garp_pdu_hdr {
0013     __be16  protocol;
0014 };
0015 
0016 struct garp_msg_hdr {
0017     u8  attrtype;
0018 };
0019 
0020 enum garp_attr_event {
0021     GARP_LEAVE_ALL,
0022     GARP_JOIN_EMPTY,
0023     GARP_JOIN_IN,
0024     GARP_LEAVE_EMPTY,
0025     GARP_LEAVE_IN,
0026     GARP_EMPTY,
0027 };
0028 
0029 struct garp_attr_hdr {
0030     u8  len;
0031     u8  event;
0032     u8  data[];
0033 };
0034 
0035 struct garp_skb_cb {
0036     u8  cur_type;
0037 };
0038 
0039 static inline struct garp_skb_cb *garp_cb(struct sk_buff *skb)
0040 {
0041     BUILD_BUG_ON(sizeof(struct garp_skb_cb) >
0042              sizeof_field(struct sk_buff, cb));
0043     return (struct garp_skb_cb *)skb->cb;
0044 }
0045 
0046 enum garp_applicant_state {
0047     GARP_APPLICANT_INVALID,
0048     GARP_APPLICANT_VA,
0049     GARP_APPLICANT_AA,
0050     GARP_APPLICANT_QA,
0051     GARP_APPLICANT_LA,
0052     GARP_APPLICANT_VP,
0053     GARP_APPLICANT_AP,
0054     GARP_APPLICANT_QP,
0055     GARP_APPLICANT_VO,
0056     GARP_APPLICANT_AO,
0057     GARP_APPLICANT_QO,
0058     __GARP_APPLICANT_MAX
0059 };
0060 #define GARP_APPLICANT_MAX  (__GARP_APPLICANT_MAX - 1)
0061 
0062 enum garp_event {
0063     GARP_EVENT_REQ_JOIN,
0064     GARP_EVENT_REQ_LEAVE,
0065     GARP_EVENT_R_JOIN_IN,
0066     GARP_EVENT_R_JOIN_EMPTY,
0067     GARP_EVENT_R_EMPTY,
0068     GARP_EVENT_R_LEAVE_IN,
0069     GARP_EVENT_R_LEAVE_EMPTY,
0070     GARP_EVENT_TRANSMIT_PDU,
0071     __GARP_EVENT_MAX
0072 };
0073 #define GARP_EVENT_MAX      (__GARP_EVENT_MAX - 1)
0074 
0075 enum garp_action {
0076     GARP_ACTION_NONE,
0077     GARP_ACTION_S_JOIN_IN,
0078     GARP_ACTION_S_LEAVE_EMPTY,
0079 };
0080 
0081 struct garp_attr {
0082     struct rb_node          node;
0083     enum garp_applicant_state   state;
0084     u8              type;
0085     u8              dlen;
0086     unsigned char           data[];
0087 };
0088 
0089 enum garp_applications {
0090     GARP_APPLICATION_GVRP,
0091     __GARP_APPLICATION_MAX
0092 };
0093 #define GARP_APPLICATION_MAX    (__GARP_APPLICATION_MAX - 1)
0094 
0095 struct garp_application {
0096     enum garp_applications  type;
0097     unsigned int        maxattr;
0098     struct stp_proto    proto;
0099 };
0100 
0101 struct garp_applicant {
0102     struct garp_application *app;
0103     struct net_device   *dev;
0104     struct timer_list   join_timer;
0105 
0106     spinlock_t      lock;
0107     struct sk_buff_head queue;
0108     struct sk_buff      *pdu;
0109     struct rb_root      gid;
0110     struct rcu_head     rcu;
0111 };
0112 
0113 struct garp_port {
0114     struct garp_applicant __rcu *applicants[GARP_APPLICATION_MAX + 1];
0115     struct rcu_head         rcu;
0116 };
0117 
0118 int garp_register_application(struct garp_application *app);
0119 void garp_unregister_application(struct garp_application *app);
0120 
0121 int garp_init_applicant(struct net_device *dev, struct garp_application *app);
0122 void garp_uninit_applicant(struct net_device *dev,
0123                struct garp_application *app);
0124 
0125 int garp_request_join(const struct net_device *dev,
0126               const struct garp_application *app, const void *data,
0127               u8 len, u8 type);
0128 void garp_request_leave(const struct net_device *dev,
0129             const struct garp_application *app,
0130             const void *data, u8 len, u8 type);
0131 
0132 #endif /* _NET_GARP_H */