br_private_stp.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Linux ethernet bridge
  3. *
  4. * Authors:
  5. * Lennert Buytenhek <buytenh@gnu.org>
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version
  10. * 2 of the License, or (at your option) any later version.
  11. */
  12. #ifndef _BR_PRIVATE_STP_H
  13. #define _BR_PRIVATE_STP_H
  14. #define BPDU_TYPE_CONFIG 0
  15. #define BPDU_TYPE_TCN 0x80
  16. /* IEEE 802.1D-1998 timer values */
  17. #define BR_MIN_HELLO_TIME (1*HZ)
  18. #define BR_MAX_HELLO_TIME (10*HZ)
  19. #define BR_MIN_FORWARD_DELAY (2*HZ)
  20. #define BR_MAX_FORWARD_DELAY (30*HZ)
  21. #define BR_MIN_MAX_AGE (6*HZ)
  22. #define BR_MAX_MAX_AGE (40*HZ)
  23. #define BR_MIN_PATH_COST 1
  24. #define BR_MAX_PATH_COST 65535
  25. struct br_config_bpdu {
  26. unsigned int topology_change:1;
  27. unsigned int topology_change_ack:1;
  28. bridge_id root;
  29. int root_path_cost;
  30. bridge_id bridge_id;
  31. port_id port_id;
  32. int message_age;
  33. int max_age;
  34. int hello_time;
  35. int forward_delay;
  36. };
  37. /* called under bridge lock */
  38. static inline int br_is_designated_port(const struct net_bridge_port *p)
  39. {
  40. return !memcmp(&p->designated_bridge, &p->br->bridge_id, 8) &&
  41. (p->designated_port == p->port_id);
  42. }
  43. /* br_stp.c */
  44. void br_become_root_bridge(struct net_bridge *br);
  45. void br_config_bpdu_generation(struct net_bridge *);
  46. void br_configuration_update(struct net_bridge *);
  47. void br_port_state_selection(struct net_bridge *);
  48. void br_received_config_bpdu(struct net_bridge_port *p,
  49. const struct br_config_bpdu *bpdu);
  50. void br_received_tcn_bpdu(struct net_bridge_port *p);
  51. void br_transmit_config(struct net_bridge_port *p);
  52. void br_transmit_tcn(struct net_bridge *br);
  53. void br_topology_change_detection(struct net_bridge *br);
  54. /* br_stp_bpdu.c */
  55. void br_send_config_bpdu(struct net_bridge_port *, struct br_config_bpdu *);
  56. void br_send_tcn_bpdu(struct net_bridge_port *);
  57. #endif