garp.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #ifndef _NET_GARP_H
  2. #define _NET_GARP_H
  3. #include <net/stp.h>
  4. #define GARP_PROTOCOL_ID 0x1
  5. #define GARP_END_MARK 0x0
  6. struct garp_pdu_hdr {
  7. __be16 protocol;
  8. };
  9. struct garp_msg_hdr {
  10. u8 attrtype;
  11. };
  12. enum garp_attr_event {
  13. GARP_LEAVE_ALL,
  14. GARP_JOIN_EMPTY,
  15. GARP_JOIN_IN,
  16. GARP_LEAVE_EMPTY,
  17. GARP_LEAVE_IN,
  18. GARP_EMPTY,
  19. };
  20. struct garp_attr_hdr {
  21. u8 len;
  22. u8 event;
  23. u8 data[];
  24. };
  25. struct garp_skb_cb {
  26. u8 cur_type;
  27. };
  28. static inline struct garp_skb_cb *garp_cb(struct sk_buff *skb)
  29. {
  30. BUILD_BUG_ON(sizeof(struct garp_skb_cb) >
  31. FIELD_SIZEOF(struct sk_buff, cb));
  32. return (struct garp_skb_cb *)skb->cb;
  33. }
  34. enum garp_applicant_state {
  35. GARP_APPLICANT_INVALID,
  36. GARP_APPLICANT_VA,
  37. GARP_APPLICANT_AA,
  38. GARP_APPLICANT_QA,
  39. GARP_APPLICANT_LA,
  40. GARP_APPLICANT_VP,
  41. GARP_APPLICANT_AP,
  42. GARP_APPLICANT_QP,
  43. GARP_APPLICANT_VO,
  44. GARP_APPLICANT_AO,
  45. GARP_APPLICANT_QO,
  46. __GARP_APPLICANT_MAX
  47. };
  48. #define GARP_APPLICANT_MAX (__GARP_APPLICANT_MAX - 1)
  49. enum garp_event {
  50. GARP_EVENT_REQ_JOIN,
  51. GARP_EVENT_REQ_LEAVE,
  52. GARP_EVENT_R_JOIN_IN,
  53. GARP_EVENT_R_JOIN_EMPTY,
  54. GARP_EVENT_R_EMPTY,
  55. GARP_EVENT_R_LEAVE_IN,
  56. GARP_EVENT_R_LEAVE_EMPTY,
  57. GARP_EVENT_TRANSMIT_PDU,
  58. __GARP_EVENT_MAX
  59. };
  60. #define GARP_EVENT_MAX (__GARP_EVENT_MAX - 1)
  61. enum garp_action {
  62. GARP_ACTION_NONE,
  63. GARP_ACTION_S_JOIN_IN,
  64. GARP_ACTION_S_LEAVE_EMPTY,
  65. };
  66. struct garp_attr {
  67. struct rb_node node;
  68. enum garp_applicant_state state;
  69. u8 type;
  70. u8 dlen;
  71. unsigned char data[];
  72. };
  73. enum garp_applications {
  74. GARP_APPLICATION_GVRP,
  75. __GARP_APPLICATION_MAX
  76. };
  77. #define GARP_APPLICATION_MAX (__GARP_APPLICATION_MAX - 1)
  78. struct garp_application {
  79. enum garp_applications type;
  80. unsigned int maxattr;
  81. struct stp_proto proto;
  82. };
  83. struct garp_applicant {
  84. struct garp_application *app;
  85. struct net_device *dev;
  86. struct timer_list join_timer;
  87. spinlock_t lock;
  88. struct sk_buff_head queue;
  89. struct sk_buff *pdu;
  90. struct rb_root gid;
  91. struct rcu_head rcu;
  92. };
  93. struct garp_port {
  94. struct garp_applicant __rcu *applicants[GARP_APPLICATION_MAX + 1];
  95. struct rcu_head rcu;
  96. };
  97. extern int garp_register_application(struct garp_application *app);
  98. extern void garp_unregister_application(struct garp_application *app);
  99. extern int garp_init_applicant(struct net_device *dev,
  100. struct garp_application *app);
  101. extern void garp_uninit_applicant(struct net_device *dev,
  102. struct garp_application *app);
  103. extern int garp_request_join(const struct net_device *dev,
  104. const struct garp_application *app,
  105. const void *data, u8 len, u8 type);
  106. extern void garp_request_leave(const struct net_device *dev,
  107. const struct garp_application *app,
  108. const void *data, u8 len, u8 type);
  109. #endif /* _NET_GARP_H */