| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #ifndef _ZEBRA_RIP_H |
| #define _ZEBRA_RIP_H |
| |
| #include "hook.h" |
| #include "nexthop.h" |
| #include "distribute.h" |
| #include "rip_memory.h" |
| |
| |
| #define RIPv1 1 |
| #define RIPv2 2 |
| |
| |
| |
| |
| |
| #define RIP_REQUEST 1 |
| #define RIP_RESPONSE 2 |
| #define RIP_TRACEON 3 |
| #define RIP_TRACEOFF 4 |
| #define RIP_POLL 5 |
| #define RIP_POLL_ENTRY 6 |
| #define RIP_COMMAND_MAX 7 |
| |
| |
| #define RIP_METRIC_INFINITY 16 |
| |
| |
| #define RIP_PACKET_MINSIZ 4 |
| #define RIP_PACKET_MAXSIZ 512 |
| |
| #define RIP_HEADER_SIZE 4 |
| #define RIP_RTE_SIZE 20 |
| |
| |
| #define RIP_MAX_RTE ((RIP_PACKET_MAXSIZ - RIP_HEADER_SIZE) / RIP_RTE_SIZE) |
| |
| |
| #ifndef INADDR_RIP_GROUP |
| #define INADDR_RIP_GROUP 0xe0000009 |
| #endif |
| |
| |
| #define RIP_PEER_TIMER_DEFAULT 180 |
| |
| |
| #define RIP_PORT_DEFAULT 520 |
| #define RIP_VTY_PORT 2602 |
| |
| |
| #define RIPD_DEFAULT_CONFIG "ripd.conf" |
| |
| |
| #define RIP_ROUTE_RTE 0 |
| #define RIP_ROUTE_STATIC 1 |
| #define RIP_ROUTE_DEFAULT 2 |
| #define RIP_ROUTE_REDISTRIBUTE 3 |
| #define RIP_ROUTE_INTERFACE 4 |
| |
| |
| #define RIP_FAMILY_AUTH 0xffff |
| |
| |
| #define RIP_NO_AUTH 0 |
| #define RIP_AUTH_DATA 1 |
| #define RIP_AUTH_SIMPLE_PASSWORD 2 |
| #define RIP_AUTH_MD5 3 |
| |
| |
| #define RIP_AUTH_SIMPLE_SIZE 16 |
| |
| |
| #define RIP_AUTH_MD5_SIZE 16 |
| #define RIP_AUTH_MD5_COMPAT_SIZE RIP_RTE_SIZE |
| |
| |
| #define RIP_INSTANCE "/frr-ripd:ripd/instance" |
| #define RIP_IFACE "/frr-interface:lib/interface/frr-ripd:rip" |
| |
| |
| struct rip { |
| |
| int sock; |
| |
| |
| int version_send; |
| int version_recv; |
| |
| |
| struct stream *obuf; |
| |
| |
| struct route_table *table; |
| |
| |
| struct route_table *neighbor; |
| |
| |
| struct thread *t_read; |
| |
| |
| struct thread *t_update; |
| |
| |
| int trigger; |
| struct thread *t_triggered_update; |
| struct thread *t_triggered_interval; |
| |
| |
| uint32_t update_time; |
| uint32_t timeout_time; |
| uint32_t garbage_time; |
| |
| |
| uint8_t default_metric; |
| |
| |
| uint8_t distance; |
| struct route_table *distance_table; |
| |
| |
| bool ecmp; |
| |
| |
| bool passive_default; |
| |
| |
| struct { |
| char *name; |
| struct route_map *map; |
| bool metric_config; |
| uint8_t metric; |
| } route_map[ZEBRA_ROUTE_MAX]; |
| |
| |
| struct distribute_ctx *distribute_ctx; |
| }; |
| |
| |
| struct rte { |
| uint16_t family; |
| uint16_t tag; |
| struct in_addr prefix; |
| struct in_addr mask; |
| struct in_addr nexthop; |
| uint32_t metric; |
| }; |
| |
| |
| struct rip_packet { |
| unsigned char command; |
| unsigned char version; |
| unsigned char pad1; |
| unsigned char pad2; |
| struct rte rte[1]; |
| }; |
| |
| |
| union rip_buf { |
| struct rip_packet rip_packet; |
| char buf[RIP_PACKET_MAXSIZ]; |
| }; |
| |
| |
| struct rip_info { |
| |
| int type; |
| |
| |
| int sub_type; |
| |
| |
| struct nexthop nh; |
| struct in_addr from; |
| |
| |
| uint32_t metric; |
| |
| |
| |
| uint32_t external_metric; |
| |
| |
| uint16_t tag; |
| |
| |
| #define RIP_RTF_FIB 1 |
| #define RIP_RTF_CHANGED 2 |
| uint8_t flags; |
| |
| |
| struct thread *t_timeout; |
| struct thread *t_garbage_collect; |
| |
| |
| struct in_addr nexthop_out; |
| uint8_t metric_set; |
| uint32_t metric_out; |
| uint16_t tag_out; |
| ifindex_t ifindex_out; |
| |
| struct route_node *rp; |
| |
| uint8_t distance; |
| |
| #ifdef NEW_RIP_TABLE |
| struct rip_info *next; |
| struct rip_info *prev; |
| #endif |
| }; |
| |
| typedef enum { |
| RIP_NO_SPLIT_HORIZON = 0, |
| RIP_SPLIT_HORIZON, |
| RIP_SPLIT_HORIZON_POISONED_REVERSE |
| } split_horizon_policy_t; |
| |
| |
| struct rip_interface { |
| |
| int enable_network; |
| int enable_interface; |
| |
| |
| int running; |
| |
| |
| int ri_send; |
| int ri_receive; |
| |
| |
| bool v2_broadcast; |
| |
| |
| int auth_type; |
| |
| |
| char *auth_str; |
| |
| |
| char *key_chain; |
| |
| |
| int md5_auth_len; |
| |
| |
| split_horizon_policy_t split_horizon; |
| |
| |
| #define RIP_FILTER_IN 0 |
| #define RIP_FILTER_OUT 1 |
| #define RIP_FILTER_MAX 2 |
| |
| |
| struct access_list *list[RIP_FILTER_MAX]; |
| |
| |
| struct prefix_list *prefix[RIP_FILTER_MAX]; |
| |
| |
| struct route_map *routemap[RIP_FILTER_MAX]; |
| |
| |
| struct thread *t_wakeup; |
| |
| |
| int recv_badpackets; |
| int recv_badroutes; |
| int sent_updates; |
| |
| |
| int passive; |
| }; |
| |
| |
| struct rip_peer { |
| |
| struct in_addr addr; |
| |
| |
| int domain; |
| |
| |
| time_t uptime; |
| |
| |
| uint8_t version; |
| |
| |
| int recv_badpackets; |
| int recv_badroutes; |
| |
| |
| struct thread *t_timeout; |
| }; |
| |
| struct rip_distance { |
| |
| uint8_t distance; |
| |
| |
| char *access_list; |
| }; |
| |
| struct rip_md5_info { |
| uint16_t family; |
| uint16_t type; |
| uint16_t packet_len; |
| uint8_t keyid; |
| uint8_t auth_len; |
| uint32_t sequence; |
| uint32_t reserv1; |
| uint32_t reserv2; |
| }; |
| |
| struct rip_md5_data { |
| uint16_t family; |
| uint16_t type; |
| uint8_t digest[16]; |
| }; |
| |
| |
| #define RI_RIP_UNSPEC 0 |
| #define RI_RIP_VERSION_1 1 |
| #define RI_RIP_VERSION_2 2 |
| #define RI_RIP_VERSION_1_AND_2 3 |
| #define RI_RIP_VERSION_NONE 4 |
| |
| |
| |
| |
| enum rip_event { |
| RIP_READ, |
| RIP_UPDATE_EVENT, |
| RIP_TRIGGERED_UPDATE, |
| }; |
| |
| |
| #define RIP_TIMER_ON(T,F,V) thread_add_timer (master, (F), rinfo, (V), &(T)) |
| |
| |
| #define RIP_TIMER_OFF(X) THREAD_TIMER_OFF(X) |
| |
| #define RIP_OFFSET_LIST_IN 0 |
| #define RIP_OFFSET_LIST_OUT 1 |
| #define RIP_OFFSET_LIST_MAX 2 |
| |
| struct rip_offset_list { |
| char *ifname; |
| |
| struct { |
| char *alist_name; |
| |
| uint8_t metric; |
| } direct[RIP_OFFSET_LIST_MAX]; |
| }; |
| |
| |
| extern void rip_init(void); |
| extern void rip_clean(void); |
| extern void rip_clean_network(void); |
| extern void rip_interfaces_clean(void); |
| extern int rip_passive_nondefault_set(const char *ifname); |
| extern int rip_passive_nondefault_unset(const char *ifname); |
| extern void rip_passive_nondefault_clean(void); |
| extern void rip_if_init(void); |
| extern void rip_if_down_all(void); |
| extern void rip_route_map_init(void); |
| extern void rip_zclient_init(struct thread_master *); |
| extern void rip_zclient_stop(void); |
| extern int if_check_address(struct in_addr addr); |
| extern int rip_create(int socket); |
| |
| extern int rip_request_send(struct sockaddr_in *, struct interface *, uint8_t, |
| struct connected *); |
| extern int rip_neighbor_lookup(struct sockaddr_in *); |
| extern int rip_neighbor_add(struct prefix_ipv4 *p); |
| extern int rip_neighbor_delete(struct prefix_ipv4 *p); |
| |
| extern int rip_enable_network_add(struct prefix *p); |
| extern int rip_enable_network_delete(struct prefix *p); |
| extern int rip_enable_if_add(const char *ifname); |
| extern int rip_enable_if_delete(const char *ifname); |
| |
| extern void rip_event(enum rip_event, int); |
| extern void rip_ecmp_disable(void); |
| |
| extern int rip_create_socket(void); |
| |
| extern int rip_redistribute_check(int); |
| extern void rip_redistribute_conf_update(int type); |
| extern void rip_redistribute_conf_delete(int type); |
| extern void rip_redistribute_add(int type, int sub_type, struct prefix_ipv4 *p, |
| struct nexthop *nh, unsigned int metric, |
| unsigned char distance, route_tag_t tag); |
| extern void rip_redistribute_delete(int, int, struct prefix_ipv4 *, ifindex_t); |
| extern void rip_redistribute_withdraw(int); |
| extern void rip_zebra_ipv4_add(struct route_node *); |
| extern void rip_zebra_ipv4_delete(struct route_node *); |
| extern void rip_interface_multicast_set(int, struct connected *); |
| extern void rip_distribute_update_interface(struct interface *); |
| extern void rip_if_rmap_update_interface(struct interface *); |
| |
| extern int rip_show_network_config(struct vty *); |
| extern void rip_show_redistribute_config(struct vty *); |
| |
| extern void rip_peer_init(void); |
| extern void rip_peer_update(struct sockaddr_in *, uint8_t); |
| extern void rip_peer_bad_route(struct sockaddr_in *); |
| extern void rip_peer_bad_packet(struct sockaddr_in *); |
| extern void rip_peer_display(struct vty *); |
| extern struct rip_peer *rip_peer_lookup(struct in_addr *); |
| extern struct rip_peer *rip_peer_lookup_next(struct in_addr *); |
| |
| extern void rip_info_free(struct rip_info *); |
| extern struct rip_distance *rip_distance_new(void); |
| extern void rip_distance_free(struct rip_distance *rdistance); |
| extern uint8_t rip_distance_apply(struct rip_info *); |
| extern void rip_redistribute_clean(void); |
| |
| extern int rip_route_rte(struct rip_info *rinfo); |
| extern struct rip_info *rip_ecmp_add(struct rip_info *); |
| extern struct rip_info *rip_ecmp_replace(struct rip_info *); |
| extern struct rip_info *rip_ecmp_delete(struct rip_info *); |
| |
| extern struct rip_offset_list *rip_offset_list_new(const char *ifname); |
| extern void offset_list_del(struct rip_offset_list *offset); |
| extern struct rip_offset_list *rip_offset_list_lookup(const char *ifname); |
| extern int rip_offset_list_apply_in(struct prefix_ipv4 *, struct interface *, |
| uint32_t *); |
| extern int rip_offset_list_apply_out(struct prefix_ipv4 *, struct interface *, |
| uint32_t *); |
| extern void rip_offset_init(void); |
| extern void rip_offset_clean(void); |
| |
| |
| extern void ripd_notif_send_auth_type_failure(const char *ifname); |
| extern void ripd_notif_send_auth_failure(const char *ifname); |
| |
| |
| extern struct rip *rip; |
| |
| extern struct zebra_privs_t ripd_privs; |
| |
| |
| extern struct thread_master *master; |
| |
| |
| extern long rip_global_route_changes; |
| extern long rip_global_queries; |
| |
| DECLARE_HOOK(rip_ifaddr_add, (struct connected * ifc), (ifc)) |
| DECLARE_HOOK(rip_ifaddr_del, (struct connected * ifc), (ifc)) |
| |
| extern struct list *peer_list; |
| extern struct route_table *rip_distance_table; |
| extern vector Vrip_passive_nondefault; |
| |
| |
| extern void rip_cli_init(void); |
| extern const struct frr_yang_module_info frr_ripd_info; |
| |
| #endif |