⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bgpd.h

📁 大名鼎鼎的路由器源码。程序分ZEBRA、OSPFRIP等3个包。程序框架采用一个路由协议一个进程的方式
💻 H
📖 第 1 页 / 共 2 页
字号:
/* BGP message definition header.   Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro IshiguroThis file is part of GNU Zebra.GNU Zebra is free software; you can redistribute it and/or modify itunder the terms of the GNU General Public License as published by theFree Software Foundation; either version 2, or (at your option) anylater version.GNU Zebra is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Zebra; see the file COPYING.  If not, write to the FreeSoftware Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA02111-1307, USA.  *//* For union sockunion.  */#include "sockunion.h"/* Typedef BGP specific types.  */typedef u_int16_t as_t;typedef u_int16_t bgp_size_t;/* BGP master for system wide configurations and variables.  */struct bgp_master{  /* BGP instance list.  */  struct list *bgp;  /* BGP thread master.  */  struct thread_master *master;  /* BGP port number.  */  u_int16_t port;  /* BGP start time.  */  time_t start_time;  /* Various BGP global configuration.  */  u_char options;#define BGP_OPT_NO_FIB                   (1 << 0)#define BGP_OPT_MULTIPLE_INSTANCE        (1 << 1)#define BGP_OPT_CONFIG_CISCO             (1 << 2)};/* BGP instance structure.  */struct bgp {  /* AS number of this BGP instance.  */  as_t as;  /* Name of this BGP instance.  */  char *name;  /* Self peer.  */  struct peer *peer_self;  /* BGP peer. */  struct list *peer;  /* BGP peer group.  */  struct list *group;  /* BGP configuration.  */  u_int16_t config;#define BGP_CONFIG_ROUTER_ID              (1 << 0)#define BGP_CONFIG_CLUSTER_ID             (1 << 1)#define BGP_CONFIG_CONFEDERATION          (1 << 2)#define BGP_CONFIG_DEFAULT_LOCAL_PREF     (1 << 3)  /* BGP router identifier.  */  struct in_addr router_id;  /* BGP route reflector cluster ID.  */  struct in_addr cluster_id;  /* BGP confederation information.  */  as_t confed_id;  as_t *confed_peers;  int confed_peers_cnt;  /* BGP flags. */  u_int16_t flags;#define BGP_FLAG_ALWAYS_COMPARE_MED       (1 << 0)#define BGP_FLAG_DETERMINISTIC_MED        (1 << 1)#define BGP_FLAG_MED_MISSING_AS_WORST     (1 << 2)#define BGP_FLAG_MED_CONFED               (1 << 3)#define BGP_FLAG_NO_DEFAULT_IPV4          (1 << 4)#define BGP_FLAG_NO_CLIENT_TO_CLIENT      (1 << 5)#define BGP_FLAG_ENFORCE_FIRST_AS         (1 << 6)#define BGP_FLAG_COMPARE_ROUTER_ID        (1 << 7)#define BGP_FLAG_ASPATH_IGNORE            (1 << 8)#define BGP_FLAG_IMPORT_CHECK             (1 << 9)#define BGP_FLAG_NO_FAST_EXT_FAILOVER     (1 << 10)#define BGP_FLAG_LOG_NEIGHBOR_CHANGES     (1 << 11)  /* BGP Per AF flags */  u_int16_t af_flags[AFI_MAX][SAFI_MAX];#define BGP_CONFIG_DAMPENING              (1 << 0)  /* Static route configuration.  */  struct bgp_table *route[AFI_MAX][SAFI_MAX];  /* Aggregate address configuration.  */  struct bgp_table *aggregate[AFI_MAX][SAFI_MAX];  /* BGP routing information base.  */  struct bgp_table *rib[AFI_MAX][SAFI_MAX];  /* BGP redistribute configuration. */  u_char redist[AFI_MAX][ZEBRA_ROUTE_MAX];  /* BGP redistribute metric configuration. */  u_char redist_metric_flag[AFI_MAX][ZEBRA_ROUTE_MAX];  u_int32_t redist_metric[AFI_MAX][ZEBRA_ROUTE_MAX];  /* BGP redistribute route-map.  */  struct  {    char *name;    struct route_map *map;  } rmap[AFI_MAX][ZEBRA_ROUTE_MAX];  /* BGP distance configuration.  */  u_char distance_ebgp;  u_char distance_ibgp;  u_char distance_local;    /* BGP default local-preference.  */  u_int32_t default_local_pref;  /* BGP default timer.  */  u_int32_t default_holdtime;  u_int32_t default_keepalive;};/* BGP peer-group support. */struct peer_group{  /* Name of the peer-group. */  char *name;  /* Pointer to BGP.  */  struct bgp *bgp;    /* Peer-group client list. */  struct list *peer;  /* Peer-group config */  struct peer *conf;};/* BGP Notify message format. */struct bgp_notify {  u_char code;  u_char subcode;  char *data;  bgp_size_t length;};/* Next hop self address. */struct bgp_nexthop{  struct interface *ifp;  struct in_addr v4;#ifdef HAVE_IPV6  struct in6_addr v6_global;  struct in6_addr v6_local;#endif /* HAVE_IPV6 */  };/* BGP router distinguisher value.  */#define BGP_RD_SIZE                8struct bgp_rd{  u_char val[BGP_RD_SIZE];};/* BGP filter structure. */struct bgp_filter{  /* Distribute-list.  */  struct   {    char *name;    struct access_list *alist;  } dlist[FILTER_MAX];  /* Prefix-list.  */  struct  {    char *name;    struct prefix_list *plist;  } plist[FILTER_MAX];  /* Filter-list.  */  struct  {    char *name;    struct as_list *aslist;  } aslist[FILTER_MAX];  /* Route-map.  */  struct  {    char *name;    struct route_map *map;  } map[FILTER_MAX];  /* Unsuppress-map.  */  struct  {    char *name;    struct route_map *map;  } usmap;};/* BGP neighbor structure. */struct peer{  /* BGP structure.  */  struct bgp *bgp;  /* BGP peer group.  */  struct peer_group *group;  u_char af_group[AFI_MAX][SAFI_MAX];  /* Peer's remote AS number. */  as_t as;			  /* Peer's local AS number. */  as_t local_as;  /* Peer's Change local AS number. */  as_t change_local_as;  /* Remote router ID. */  struct in_addr remote_id;  /* Local router ID. */  struct in_addr local_id;  /* Packet receive and send buffer. */  struct stream *ibuf;  struct stream_fifo *obuf;  struct stream *work;  /* Status of the peer. */  int status;  int ostatus;  /* Peer information */  int fd;			/* File descriptor */  int ttl;			/* TTL of TCP connection to the peer. */  char *desc;			/* Description of the peer. */  unsigned short port;          /* Destination port for peer */  char *host;			/* Printable address of the peer. */  union sockunion su;		/* Sockunion address of the peer. */  time_t uptime;		/* Last Up/Down time */  time_t readtime;		/* Last read time */  time_t resettime;		/* Last reset time */    unsigned int ifindex;		/* ifindex of the BGP connection. */  char *ifname;			/* bind interface name. */  char *update_if;  union sockunion *update_source;  struct zlog *log;  u_char version;		/* Peer BGP version. */  union sockunion *su_local;	/* Sockunion of local address.  */  union sockunion *su_remote;	/* Sockunion of remote address.  */  int shared_network;		/* Is this peer shared same network. */  struct bgp_nexthop nexthop;	/* Nexthop */  /* Peer address family configuration. */  u_char afc[AFI_MAX][SAFI_MAX];  u_char afc_nego[AFI_MAX][SAFI_MAX];  u_char afc_adv[AFI_MAX][SAFI_MAX];  u_char afc_recv[AFI_MAX][SAFI_MAX];  /* Capability Flags.*/  u_char cap;#define PEER_CAP_REFRESH_ADV                (1 << 0) /* refresh advertised */#define PEER_CAP_REFRESH_OLD_RCV            (1 << 1) /* refresh old received */#define PEER_CAP_REFRESH_NEW_RCV            (1 << 2) /* refresh rfc received */#define PEER_CAP_DYNAMIC_ADV                (1 << 3) /* dynamic advertised */#define PEER_CAP_DYNAMIC_RCV                (1 << 4) /* dynamic received */  /* Capability Flags.*/  u_int16_t af_cap[AFI_MAX][SAFI_MAX];#define PEER_CAP_ORF_PREFIX_SM_ADV          (1 << 0) /* send-mode advertised */#define PEER_CAP_ORF_PREFIX_RM_ADV          (1 << 1) /* receive-mode advertised */#define PEER_CAP_ORF_PREFIX_SM_RCV          (1 << 2) /* send-mode received */#define PEER_CAP_ORF_PREFIX_RM_RCV          (1 << 3) /* receive-mode received */#define PEER_CAP_ORF_PREFIX_SM_OLD_RCV      (1 << 4) /* send-mode received */#define PEER_CAP_ORF_PREFIX_RM_OLD_RCV      (1 << 5) /* receive-mode received */  /* Global configuration flags. */  u_int32_t flags;#define PEER_FLAG_PASSIVE                   (1 << 0) /* passive mode */#define PEER_FLAG_SHUTDOWN                  (1 << 1) /* shutdown */#define PEER_FLAG_DONT_CAPABILITY           (1 << 2) /* dont-capability */#define PEER_FLAG_OVERRIDE_CAPABILITY       (1 << 3) /* override-capability */#define PEER_FLAG_STRICT_CAP_MATCH          (1 << 4) /* strict-match */#define PEER_FLAG_NO_ROUTE_REFRESH_CAP      (1 << 5) /* route-refresh */#define PEER_FLAG_DYNAMIC_CAPABILITY        (1 << 6) /* dynamic capability */#define PEER_FLAG_ENFORCE_MULTIHOP          (1 << 7) /* enforce-multihop */#define PEER_FLAG_LOCAL_AS_NO_PREPEND       (1 << 8) /* local-as no-prepend */  /* Per AF configuration flags. */  u_int32_t af_flags[AFI_MAX][SAFI_MAX];#define PEER_FLAG_SEND_COMMUNITY            (1 << 0) /* send-community */#define PEER_FLAG_SEND_EXT_COMMUNITY        (1 << 1) /* send-community ext. */#define PEER_FLAG_NEXTHOP_SELF              (1 << 2) /* next-hop-self */#define PEER_FLAG_REFLECTOR_CLIENT          (1 << 3) /* reflector-client */#define PEER_FLAG_RSERVER_CLIENT            (1 << 4) /* route-server-client */#define PEER_FLAG_SOFT_RECONFIG             (1 << 5) /* soft-reconfiguration */#define PEER_FLAG_AS_PATH_UNCHANGED         (1 << 6) /* transparent-as */#define PEER_FLAG_NEXTHOP_UNCHANGED         (1 << 7) /* transparent-next-hop */#define PEER_FLAG_MED_UNCHANGED             (1 << 8) /* transparent-next-hop */#define PEER_FLAG_DEFAULT_ORIGINATE         (1 << 9) /* default-originate */#define PEER_FLAG_REMOVE_PRIVATE_AS         (1 << 10) /* remove-private-as */#define PEER_FLAG_ALLOWAS_IN                (1 << 11) /* set allowas-in */#define PEER_FLAG_ORF_PREFIX_SM             (1 << 12) /* orf capability send-mode */#define PEER_FLAG_ORF_PREFIX_RM             (1 << 13) /* orf capability receive-mode */#define PEER_FLAG_MAX_PREFIX                (1 << 14) /* maximum prefix */#define PEER_FLAG_MAX_PREFIX_WARNING        (1 << 15) /* maximum prefix warning-only */  /* default-originate route-map.  */  struct  {    char *name;    struct route_map *map;  } default_rmap[AFI_MAX][SAFI_MAX];  /* Peer status flags. */  u_int16_t sflags;#define PEER_STATUS_ACCEPT_PEER	      (1 << 0) /* accept peer */#define PEER_STATUS_PREFIX_OVERFLOW   (1 << 1) /* prefix-overflow */#define PEER_STATUS_CAPABILITY_OPEN   (1 << 2) /* capability open send */#define PEER_STATUS_HAVE_ACCEPT       (1 << 3) /* accept peer's parent */#define PEER_STATUS_GROUP             (1 << 4) /* peer-group conf */  /* Peer status af flags. */  u_int16_t af_sflags[AFI_MAX][SAFI_MAX];#define PEER_STATUS_ORF_PREFIX_SEND   (1 << 0) /* prefix-list send peer */#define PEER_STATUS_ORF_WAIT_REFRESH  (1 << 1) /* wait refresh received peer */#define PEER_STATUS_DEFAULT_ORIGINATE (1 << 2) /* default-originate peer */#define PEER_STATUS_PREFIX_THRESHOLD  (1 << 3) /* exceed prefix-threshold */#define PEER_STATUS_PREFIX_LIMIT      (1 << 4) /* exceed prefix-limit */  /* Default attribute value for the peer. */  u_int32_t config;#define PEER_CONFIG_WEIGHT            (1 << 0) /* Default weight. */#define PEER_CONFIG_TIMER             (1 << 1) /* keepalive & holdtime */#define PEER_CONFIG_CONNECT           (1 << 2) /* connect */#define PEER_CONFIG_ROUTEADV          (1 << 3) /* route advertise */  u_int32_t weight;  u_int32_t holdtime;  u_int32_t keepalive;  u_int32_t connect;  u_int32_t routeadv;  /* Timer values. */  u_int32_t v_start;  u_int32_t v_connect;  u_int32_t v_holdtime;  u_int32_t v_keepalive;  u_int32_t v_asorig;  u_int32_t v_routeadv;  /* Threads. */  struct thread *t_read;  struct thread *t_write;  struct thread *t_start;  struct thread *t_connect;  struct thread *t_holdtime;  struct thread *t_keepalive;  struct thread *t_asorig;  struct thread *t_routeadv;  /* Statistics field */  u_int32_t open_in;		/* Open message input count */  u_int32_t open_out;		/* Open message output count */  u_int32_t update_in;		/* Update message input count */  u_int32_t update_out;		/* Update message ouput count */  time_t update_time;		/* Update message received time. */  u_int32_t keepalive_in;	/* Keepalive input count */  u_int32_t keepalive_out;	/* Keepalive output count */  u_int32_t notify_in;		/* Notify input count */  u_int32_t notify_out;		/* Notify output count */  u_int32_t refresh_in;		/* Route Refresh input count */  u_int32_t refresh_out;	/* Route Refresh output count */  u_int32_t dynamic_cap_in;	/* Dynamic Capability input count.  */  u_int32_t dynamic_cap_out;	/* Dynamic Capability output count.  */  /* BGP state count */  u_int32_t established;	/* Established */  u_int32_t dropped;		/* Dropped */  /* Syncronization list and time.  */  struct bgp_synchronize *sync[AFI_MAX][SAFI_MAX];  time_t synctime;  /* Send prefix count. */  unsigned long scount[AFI_MAX][SAFI_MAX];  /* Announcement attribute hash.  */  struct hash *hash[AFI_MAX][SAFI_MAX];  /* Notify data. */  struct bgp_notify notify;  /* Whole packet size to be read. */  unsigned long packet_size;  /* Filter structure. */  struct bgp_filter filter[AFI_MAX][SAFI_MAX];  /* ORF Prefix-list */  struct prefix_list *orf_plist[AFI_MAX][SAFI_MAX];  /* Prefix count. */  unsigned long pcount[AFI_MAX][SAFI_MAX];  /* Max prefix count. */  unsigned long pmax[AFI_MAX][SAFI_MAX];

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -