bgp_route.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /* BGP routing information base
  2. Copyright (C) 1996, 97, 98, 2000 Kunihiro Ishiguro
  3. This file is part of GNU Zebra.
  4. GNU Zebra is free software; you can redistribute it and/or modify it
  5. under the terms of the GNU General Public License as published by the
  6. Free Software Foundation; either version 2, or (at your option) any
  7. later version.
  8. GNU Zebra is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Zebra; see the file COPYING. If not, write to the Free
  14. Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  15. 02111-1307, USA. */
  16. #ifndef _QUAGGA_BGP_ROUTE_H
  17. #define _QUAGGA_BGP_ROUTE_H
  18. #include "bgp_table.h"
  19. struct bgp_info
  20. {
  21. /* For linked list. */
  22. struct bgp_info *next;
  23. struct bgp_info *prev;
  24. /* reference count */
  25. unsigned int lock;
  26. /* BGP route type. This can be static, RIP, OSPF, BGP etc. */
  27. u_char type;
  28. /* When above type is BGP. This sub type specify BGP sub type
  29. information. */
  30. u_char sub_type;
  31. #define BGP_ROUTE_NORMAL 0
  32. #define BGP_ROUTE_STATIC 1
  33. #define BGP_ROUTE_AGGREGATE 2
  34. #define BGP_ROUTE_REDISTRIBUTE 3
  35. /* BGP information status. */
  36. u_int16_t flags;
  37. #define BGP_INFO_IGP_CHANGED (1 << 0)
  38. #define BGP_INFO_DAMPED (1 << 1)
  39. #define BGP_INFO_HISTORY (1 << 2)
  40. #define BGP_INFO_SELECTED (1 << 3)
  41. #define BGP_INFO_VALID (1 << 4)
  42. #define BGP_INFO_ATTR_CHANGED (1 << 5)
  43. #define BGP_INFO_DMED_CHECK (1 << 6)
  44. #define BGP_INFO_DMED_SELECTED (1 << 7)
  45. #define BGP_INFO_STALE (1 << 8)
  46. /* Peer structure. */
  47. struct peer *peer;
  48. /* Attribute structure. */
  49. struct attr *attr;
  50. /* This route is suppressed with aggregation. */
  51. int suppress;
  52. /* Nexthop reachability check. */
  53. u_int32_t igpmetric;
  54. /* Uptime. */
  55. time_t uptime;
  56. /* Pointer to dampening structure. */
  57. struct bgp_damp_info *damp_info;
  58. /* MPLS label. */
  59. u_char tag[3];
  60. };
  61. /* BGP static route configuration. */
  62. struct bgp_static
  63. {
  64. /* Backdoor configuration. */
  65. int backdoor;
  66. /* Import check status. */
  67. u_char valid;
  68. /* IGP metric. */
  69. u_int32_t igpmetric;
  70. /* IGP nexthop. */
  71. struct in_addr igpnexthop;
  72. /* BGP redistribute route-map. */
  73. struct
  74. {
  75. char *name;
  76. struct route_map *map;
  77. } rmap;
  78. /* MPLS label. */
  79. u_char tag[3];
  80. };
  81. #define DISTRIBUTE_IN_NAME(F) ((F)->dlist[FILTER_IN].name)
  82. #define DISTRIBUTE_IN(F) ((F)->dlist[FILTER_IN].alist)
  83. #define DISTRIBUTE_OUT_NAME(F) ((F)->dlist[FILTER_OUT].name)
  84. #define DISTRIBUTE_OUT(F) ((F)->dlist[FILTER_OUT].alist)
  85. #define PREFIX_LIST_IN_NAME(F) ((F)->plist[FILTER_IN].name)
  86. #define PREFIX_LIST_IN(F) ((F)->plist[FILTER_IN].plist)
  87. #define PREFIX_LIST_OUT_NAME(F) ((F)->plist[FILTER_OUT].name)
  88. #define PREFIX_LIST_OUT(F) ((F)->plist[FILTER_OUT].plist)
  89. #define FILTER_LIST_IN_NAME(F) ((F)->aslist[FILTER_IN].name)
  90. #define FILTER_LIST_IN(F) ((F)->aslist[FILTER_IN].aslist)
  91. #define FILTER_LIST_OUT_NAME(F) ((F)->aslist[FILTER_OUT].name)
  92. #define FILTER_LIST_OUT(F) ((F)->aslist[FILTER_OUT].aslist)
  93. #define ROUTE_MAP_IN_NAME(F) ((F)->map[RMAP_IN].name)
  94. #define ROUTE_MAP_IN(F) ((F)->map[RMAP_IN].map)
  95. #define ROUTE_MAP_OUT_NAME(F) ((F)->map[RMAP_OUT].name)
  96. #define ROUTE_MAP_OUT(F) ((F)->map[RMAP_OUT].map)
  97. #define ROUTE_MAP_IMPORT_NAME(F) ((F)->map[RMAP_IMPORT].name)
  98. #define ROUTE_MAP_IMPORT(F) ((F)->map[RMAP_IMPORT].map)
  99. #define ROUTE_MAP_EXPORT_NAME(F) ((F)->map[RMAP_EXPORT].name)
  100. #define ROUTE_MAP_EXPORT(F) ((F)->map[RMAP_EXPORT].map)
  101. #define UNSUPPRESS_MAP_NAME(F) ((F)->usmap.name)
  102. #define UNSUPPRESS_MAP(F) ((F)->usmap.map)
  103. /* Prototypes. */
  104. extern void bgp_route_init (void);
  105. extern void bgp_cleanup_routes (void);
  106. extern void bgp_announce_route (struct peer *, afi_t, safi_t);
  107. extern void bgp_announce_route_all (struct peer *);
  108. extern void bgp_default_originate (struct peer *, afi_t, safi_t, int);
  109. extern void bgp_soft_reconfig_in (struct peer *, afi_t, safi_t);
  110. extern void bgp_soft_reconfig_rsclient (struct peer *, afi_t, safi_t);
  111. extern void bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi);
  112. extern void bgp_clear_route (struct peer *, afi_t, safi_t);
  113. extern void bgp_clear_route_all (struct peer *);
  114. extern void bgp_clear_adj_in (struct peer *, afi_t, safi_t);
  115. extern void bgp_clear_stale_route (struct peer *, afi_t, safi_t);
  116. extern struct bgp_info *bgp_info_lock (struct bgp_info *);
  117. extern struct bgp_info *bgp_info_unlock (struct bgp_info *);
  118. extern void bgp_info_add (struct bgp_node *rn, struct bgp_info *ri);
  119. extern void bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri);
  120. extern int bgp_nlri_sanity_check (struct peer *, int, u_char *, bgp_size_t);
  121. extern int bgp_nlri_parse (struct peer *, struct attr *, struct bgp_nlri *);
  122. extern int bgp_maximum_prefix_overflow (struct peer *, afi_t, safi_t, int);
  123. extern void bgp_redistribute_add (struct prefix *, struct in_addr *, u_int32_t, u_char);
  124. extern void bgp_redistribute_delete (struct prefix *, u_char);
  125. extern void bgp_redistribute_withdraw (struct bgp *, afi_t, int);
  126. extern void bgp_static_delete (struct bgp *);
  127. extern void bgp_static_update (struct bgp *, struct prefix *, struct bgp_static *,
  128. afi_t, safi_t);
  129. extern void bgp_static_withdraw (struct bgp *, struct prefix *, afi_t, safi_t);
  130. extern int bgp_static_set_vpnv4 (struct vty *vty, const char *,
  131. const char *, const char *);
  132. extern int bgp_static_unset_vpnv4 (struct vty *, const char *,
  133. const char *, const char *);
  134. /* this is primarily for MPLS-VPN */
  135. extern int bgp_update (struct peer *, struct prefix *, struct attr *,
  136. afi_t, safi_t, int, int, struct prefix_rd *,
  137. u_char *, int);
  138. extern int bgp_withdraw (struct peer *, struct prefix *, struct attr *,
  139. afi_t, safi_t, int, int, struct prefix_rd *, u_char *);
  140. /* for bgp_nexthop and bgp_damp */
  141. extern void bgp_process (struct bgp *, struct bgp_node *, afi_t, safi_t);
  142. extern int bgp_config_write_network (struct vty *, struct bgp *, afi_t, safi_t, int *);
  143. extern int bgp_config_write_distance (struct vty *, struct bgp *);
  144. extern void bgp_aggregate_increment (struct bgp *, struct prefix *, struct bgp_info *,
  145. afi_t, safi_t);
  146. extern void bgp_aggregate_decrement (struct bgp *, struct prefix *, struct bgp_info *,
  147. afi_t, safi_t);
  148. extern u_char bgp_distance_apply (struct prefix *, struct bgp_info *, struct bgp *);
  149. extern afi_t bgp_node_afi (struct vty *);
  150. extern safi_t bgp_node_safi (struct vty *);
  151. extern void route_vty_out (struct vty *, struct prefix *, struct bgp_info *, int, safi_t);
  152. extern void route_vty_out_tag (struct vty *, struct prefix *, struct bgp_info *, int, safi_t);
  153. extern void route_vty_out_tmp (struct vty *, struct prefix *, struct attr *, safi_t);
  154. #endif /* _QUAGGA_BGP_ROUTE_H */