]> git.proxmox.com Git - mirror_frr.git/blame - ripd/ripd.h
ripd: fix unsetting of authentication password
[mirror_frr.git] / ripd / ripd.h
CommitLineData
718e3744 1/* RIP related values and structures.
2 * Copyright (C) 1997, 1998, 1999 Kunihiro Ishiguro <kunihiro@zebra.org>
3 *
4 * This file is part of GNU Zebra.
5 *
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
896014f4
DL
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
718e3744 19 */
20
21#ifndef _ZEBRA_RIP_H
22#define _ZEBRA_RIP_H
23
3012671f 24#include "hook.h"
dd127197 25#include "nexthop.h"
03a38493 26#include "distribute.h"
4a1ab8e4
DL
27#include "rip_memory.h"
28
718e3744 29/* RIP version number. */
30#define RIPv1 1
31#define RIPv2 2
f38a471c 32/* N.B. stuff will break if
33 (RIPv1 != RI_RIP_VERSION_1) || (RIPv2 != RI_RIP_VERSION_2) */
34
718e3744 35
36/* RIP command list. */
37#define RIP_REQUEST 1
38#define RIP_RESPONSE 2
39#define RIP_TRACEON 3 /* Obsolete */
40#define RIP_TRACEOFF 4 /* Obsolete */
41#define RIP_POLL 5
42#define RIP_POLL_ENTRY 6
43#define RIP_COMMAND_MAX 7
44
45/* RIP metric infinity value.*/
46#define RIP_METRIC_INFINITY 16
47
48/* Normal RIP packet min and max size. */
49#define RIP_PACKET_MINSIZ 4
50#define RIP_PACKET_MAXSIZ 512
51
52#define RIP_HEADER_SIZE 4
53#define RIP_RTE_SIZE 20
54
55/* Max count of routing table entry in one rip packet. */
6a7cff75 56#define RIP_MAX_RTE ((RIP_PACKET_MAXSIZ - RIP_HEADER_SIZE) / RIP_RTE_SIZE)
718e3744 57
58/* RIP version 2 multicast address. */
59#ifndef INADDR_RIP_GROUP
60#define INADDR_RIP_GROUP 0xe0000009 /* 224.0.0.9 */
61#endif
62
718e3744 63/* RIP peer timeout value. */
64#define RIP_PEER_TIMER_DEFAULT 180
65
66/* RIP port number. */
67#define RIP_PORT_DEFAULT 520
68#define RIP_VTY_PORT 2602
718e3744 69
70/* Default configuration file name. */
71#define RIPD_DEFAULT_CONFIG "ripd.conf"
72
73/* RIP route types. */
74#define RIP_ROUTE_RTE 0
75#define RIP_ROUTE_STATIC 1
76#define RIP_ROUTE_DEFAULT 2
77#define RIP_ROUTE_REDISTRIBUTE 3
78#define RIP_ROUTE_INTERFACE 4
79
ca5e516c 80/* RIPv2 special RTE family types */
81#define RIP_FAMILY_AUTH 0xffff
82
83/* RIPv2 authentication types, for RIP_FAMILY_AUTH RTE's */
84#define RIP_NO_AUTH 0
85#define RIP_AUTH_DATA 1
86#define RIP_AUTH_SIMPLE_PASSWORD 2
87#define RIP_AUTH_MD5 3
88
b14ee00b 89/* RIPv2 Simple authentication */
90#define RIP_AUTH_SIMPLE_SIZE 16
91
ca5e516c 92/* RIPv2 MD5 authentication. */
718e3744 93#define RIP_AUTH_MD5_SIZE 16
ca5e516c 94#define RIP_AUTH_MD5_COMPAT_SIZE RIP_RTE_SIZE
718e3744 95
707656ec
RW
96/* YANG paths */
97#define RIP_INSTANCE "/frr-ripd:ripd/instance"
98#define RIP_IFACE "/frr-interface:lib/interface/frr-ripd:rip"
99
718e3744 100/* RIP structure. */
d62a17ae 101struct rip {
ae7b826a
RW
102 RB_ENTRY(rip) entry;
103
104 /* VRF this routing instance is associated with. */
105 char *vrf_name;
106
107 /* VRF backpointer (might be NULL if the VRF doesn't exist). */
108 struct vrf *vrf;
109
110 /* Status of the routing instance. */
111 bool enabled;
045c5389 112
d62a17ae 113 /* RIP socket. */
114 int sock;
115
116 /* Default version of rip instance. */
117 int version_send; /* version 1 or 2 (but not both) */
118 int version_recv; /* version 1 or 2 or both */
119
120 /* Output buffer of RIP. */
121 struct stream *obuf;
122
123 /* RIP routing information base. */
124 struct route_table *table;
125
29e897ad 126 /* RIP static neighbors. */
d62a17ae 127 struct route_table *neighbor;
128
29e897ad
RW
129 /* Linked list of RIP peers. */
130 struct list *peer_list;
131
d62a17ae 132 /* RIP threads. */
133 struct thread *t_read;
134
135 /* Update and garbage timer. */
136 struct thread *t_update;
137
138 /* Triggered update hack. */
139 int trigger;
140 struct thread *t_triggered_update;
141 struct thread *t_triggered_interval;
142
143 /* RIP timer values. */
b745780b
RW
144 uint32_t update_time;
145 uint32_t timeout_time;
146 uint32_t garbage_time;
d62a17ae 147
148 /* RIP default metric. */
282ae30c 149 uint8_t default_metric;
d62a17ae 150
d62a17ae 151 /* RIP default distance. */
d7c0a89a 152 uint8_t distance;
d62a17ae 153 struct route_table *distance_table;
154
155 /* RIP ECMP flag */
edbf59d2 156 bool ecmp;
d62a17ae 157
44f2f852
RW
158 /* Are we in passive-interface default mode? */
159 bool passive_default;
160
ca046902
RW
161 /* RIP enabled interfaces. */
162 vector enable_interface;
163
1205fdc4
RW
164 /* RIP enabled networks. */
165 struct route_table *enable_network;
166
5a29c0d5
RW
167 /* Vector to store passive-interface name. */
168 vector passive_nondefault;
169
3f21c8c4
RW
170 /* RIP offset-lists. */
171 struct list *offset_list_master;
172
d62a17ae 173 /* For redistribute route map. */
174 struct {
175 char *name;
176 struct route_map *map;
908f0020
RW
177 bool metric_config;
178 uint8_t metric;
d62a17ae 179 } route_map[ZEBRA_ROUTE_MAX];
03a38493
PG
180
181 /* For distribute-list container */
182 struct distribute_ctx *distribute_ctx;
c08a2107
RW
183
184 /* Counters for SNMP. */
185 struct {
186 /* RIP route changes. */
187 long route_changes;
188
189 /* RIP queries. */
190 long queries;
191 } counters;
718e3744 192};
ae7b826a
RW
193RB_HEAD(rip_instance_head, rip);
194RB_PROTOTYPE(rip_instance_head, rip, entry, rip_instance_compare)
718e3744 195
196/* RIP routing table entry which belong to rip_packet. */
d62a17ae 197struct rte {
d7c0a89a
QY
198 uint16_t family; /* Address family of this route. */
199 uint16_t tag; /* Route Tag which included in RIP2 packet. */
d62a17ae 200 struct in_addr prefix; /* Prefix of rip route. */
201 struct in_addr mask; /* Netmask of rip route. */
202 struct in_addr nexthop; /* Next hop of rip route. */
d7c0a89a 203 uint32_t metric; /* Metric value of rip route. */
718e3744 204};
205
206/* RIP packet structure. */
d62a17ae 207struct rip_packet {
208 unsigned char command; /* Command type of RIP packet. */
209 unsigned char version; /* RIP version which coming from peer. */
210 unsigned char pad1; /* Padding of RIP packet header. */
211 unsigned char pad2; /* Same as above. */
212 struct rte rte[1]; /* Address structure. */
718e3744 213};
214
215/* Buffer to read RIP packet. */
d62a17ae 216union rip_buf {
217 struct rip_packet rip_packet;
218 char buf[RIP_PACKET_MAXSIZ];
718e3744 219};
220
221/* RIP route information. */
d62a17ae 222struct rip_info {
223 /* This route's type. */
224 int type;
718e3744 225
d62a17ae 226 /* Sub type. */
227 int sub_type;
718e3744 228
d62a17ae 229 /* RIP nexthop. */
dd127197 230 struct nexthop nh;
d62a17ae 231 struct in_addr from;
718e3744 232
d62a17ae 233 /* Metric of this route. */
d7c0a89a 234 uint32_t metric;
718e3744 235
d62a17ae 236 /* External metric of this route.
237 if learnt from an externalm proto */
d7c0a89a 238 uint32_t external_metric;
fbf5d033 239
d62a17ae 240 /* Tag information of this route. */
d7c0a89a 241 uint16_t tag;
718e3744 242
d62a17ae 243/* Flags of RIP route. */
718e3744 244#define RIP_RTF_FIB 1
245#define RIP_RTF_CHANGED 2
d7c0a89a 246 uint8_t flags;
718e3744 247
d62a17ae 248 /* Garbage collect timer. */
249 struct thread *t_timeout;
250 struct thread *t_garbage_collect;
718e3744 251
d62a17ae 252 /* Route-map futures - this variables can be changed. */
253 struct in_addr nexthop_out;
d7c0a89a
QY
254 uint8_t metric_set;
255 uint32_t metric_out;
256 uint16_t tag_out;
d62a17ae 257 ifindex_t ifindex_out;
718e3744 258
d62a17ae 259 struct route_node *rp;
718e3744 260
d7c0a89a 261 uint8_t distance;
718e3744 262};
263
16705130 264typedef enum {
d62a17ae 265 RIP_NO_SPLIT_HORIZON = 0,
266 RIP_SPLIT_HORIZON,
267 RIP_SPLIT_HORIZON_POISONED_REVERSE
16705130 268} split_horizon_policy_t;
269
718e3744 270/* RIP specific interface configuration. */
d62a17ae 271struct rip_interface {
045c5389
RW
272 /* Parent routing instance. */
273 struct rip *rip;
274
d62a17ae 275 /* RIP is enabled on this interface. */
276 int enable_network;
277 int enable_interface;
718e3744 278
d62a17ae 279 /* RIP is running on this interface. */
280 int running;
718e3744 281
d62a17ae 282 /* RIP version control. */
283 int ri_send;
284 int ri_receive;
718e3744 285
d62a17ae 286 /* RIPv2 broadcast mode */
94b117b2 287 bool v2_broadcast;
f90310cf 288
d62a17ae 289 /* RIPv2 authentication type. */
290 int auth_type;
718e3744 291
d62a17ae 292 /* RIPv2 authentication string. */
293 char *auth_str;
718e3744 294
d62a17ae 295 /* RIPv2 authentication key chain. */
296 char *key_chain;
718e3744 297
d62a17ae 298 /* value to use for md5->auth_len */
94b117b2 299 int md5_auth_len;
ca5e516c 300
d62a17ae 301 /* Split horizon flag. */
302 split_horizon_policy_t split_horizon;
718e3744 303
d62a17ae 304/* For filter type slot. */
718e3744 305#define RIP_FILTER_IN 0
306#define RIP_FILTER_OUT 1
307#define RIP_FILTER_MAX 2
308
d62a17ae 309 /* Access-list. */
310 struct access_list *list[RIP_FILTER_MAX];
718e3744 311
d62a17ae 312 /* Prefix-list. */
313 struct prefix_list *prefix[RIP_FILTER_MAX];
718e3744 314
d62a17ae 315 /* Route-map. */
316 struct route_map *routemap[RIP_FILTER_MAX];
16705130 317
d62a17ae 318 /* Wake up thread. */
319 struct thread *t_wakeup;
718e3744 320
d62a17ae 321 /* Interface statistics. */
322 int recv_badpackets;
323 int recv_badroutes;
324 int sent_updates;
718e3744 325
d62a17ae 326 /* Passive interface. */
327 int passive;
718e3744 328};
329
330/* RIP peer information. */
d62a17ae 331struct rip_peer {
045c5389
RW
332 /* Parent routing instance. */
333 struct rip *rip;
334
d62a17ae 335 /* Peer address. */
336 struct in_addr addr;
718e3744 337
d62a17ae 338 /* Peer RIP tag value. */
339 int domain;
718e3744 340
d62a17ae 341 /* Last update time. */
342 time_t uptime;
718e3744 343
d62a17ae 344 /* Peer RIP version. */
d7c0a89a 345 uint8_t version;
718e3744 346
d62a17ae 347 /* Statistics. */
348 int recv_badpackets;
349 int recv_badroutes;
718e3744 350
d62a17ae 351 /* Timeout thread. */
352 struct thread *t_timeout;
718e3744 353};
354
23b23d8c
RW
355struct rip_distance {
356 /* Distance value for the IP source prefix. */
357 uint8_t distance;
358
359 /* Name of the access-list to be matched. */
360 char *access_list;
361};
362
d62a17ae 363struct rip_md5_info {
d7c0a89a
QY
364 uint16_t family;
365 uint16_t type;
366 uint16_t packet_len;
367 uint8_t keyid;
368 uint8_t auth_len;
369 uint32_t sequence;
370 uint32_t reserv1;
371 uint32_t reserv2;
718e3744 372};
373
d62a17ae 374struct rip_md5_data {
d7c0a89a
QY
375 uint16_t family;
376 uint16_t type;
377 uint8_t digest[16];
718e3744 378};
379
380/* RIP accepet/announce methods. */
381#define RI_RIP_UNSPEC 0
382#define RI_RIP_VERSION_1 1
383#define RI_RIP_VERSION_2 2
384#define RI_RIP_VERSION_1_AND_2 3
6aec4b41 385#define RI_RIP_VERSION_NONE 4
f38a471c 386/* N.B. stuff will break if
387 (RIPv1 != RI_RIP_VERSION_1) || (RIPv2 != RI_RIP_VERSION_2) */
718e3744 388
718e3744 389/* RIP event. */
d62a17ae 390enum rip_event {
391 RIP_READ,
392 RIP_UPDATE_EVENT,
393 RIP_TRIGGERED_UPDATE,
718e3744 394};
395
396/* Macro for timer turn on. */
ffa2c898 397#define RIP_TIMER_ON(T,F,V) thread_add_timer (master, (F), rinfo, (V), &(T))
718e3744 398
399/* Macro for timer turn off. */
8578874d 400#define RIP_TIMER_OFF(X) THREAD_TIMER_OFF(X)
718e3744 401
8c942f65
RW
402#define RIP_OFFSET_LIST_IN 0
403#define RIP_OFFSET_LIST_OUT 1
404#define RIP_OFFSET_LIST_MAX 2
405
406struct rip_offset_list {
045c5389
RW
407 /* Parent routing instance. */
408 struct rip *rip;
409
8c942f65
RW
410 char *ifname;
411
412 struct {
413 char *alist_name;
414 /* struct access_list *alist; */
415 uint8_t metric;
416 } direct[RIP_OFFSET_LIST_MAX];
417};
418
718e3744 419/* Prototypes. */
d62a17ae 420extern void rip_init(void);
045c5389
RW
421extern void rip_clean(struct rip *rip);
422extern void rip_clean_network(struct rip *rip);
423extern void rip_interfaces_clean(struct rip *rip);
424extern int rip_passive_nondefault_set(struct rip *rip, const char *ifname);
425extern int rip_passive_nondefault_unset(struct rip *rip, const char *ifname);
426extern void rip_passive_nondefault_clean(struct rip *rip);
d62a17ae 427extern void rip_if_init(void);
d62a17ae 428extern void rip_route_map_init(void);
ae7b826a
RW
429extern void rip_zebra_vrf_register(struct vrf *vrf);
430extern void rip_zebra_vrf_deregister(struct vrf *vrf);
4140ca4d 431extern void rip_zclient_init(struct thread_master *);
a2f9eb82 432extern void rip_zclient_stop(void);
045c5389
RW
433extern int if_check_address(struct rip *rip, struct in_addr addr);
434extern struct rip *rip_lookup_by_vrf_id(vrf_id_t vrf_id);
ae7b826a
RW
435extern struct rip *rip_lookup_by_vrf_name(const char *vrf_name);
436extern struct rip *rip_create(const char *vrf_name, struct vrf *vrf,
437 int socket);
d62a17ae 438
d7c0a89a 439extern int rip_request_send(struct sockaddr_in *, struct interface *, uint8_t,
d62a17ae 440 struct connected *);
045c5389
RW
441extern int rip_neighbor_lookup(struct rip *rip, struct sockaddr_in *from);
442extern int rip_neighbor_add(struct rip *rip, struct prefix_ipv4 *p);
443extern int rip_neighbor_delete(struct rip *rip, struct prefix_ipv4 *p);
d62a17ae 444
045c5389
RW
445extern int rip_enable_network_add(struct rip *rip, struct prefix *p);
446extern int rip_enable_network_delete(struct rip *rip, struct prefix *p);
447extern int rip_enable_if_add(struct rip *rip, const char *ifname);
448extern int rip_enable_if_delete(struct rip *rip, const char *ifname);
3d7a1be8 449
045c5389
RW
450extern void rip_event(struct rip *rip, enum rip_event event, int sock);
451extern void rip_ecmp_disable(struct rip *rip);
edbf59d2 452
ae7b826a 453extern int rip_create_socket(struct vrf *vrf);
8c9226c2 454
045c5389
RW
455extern int rip_redistribute_check(struct rip *rip, int type);
456extern void rip_redistribute_conf_update(struct rip *rip, int type);
457extern void rip_redistribute_conf_delete(struct rip *rip, int type);
458extern void rip_redistribute_add(struct rip *rip, int type, int sub_type,
459 struct prefix_ipv4 *p, struct nexthop *nh,
460 unsigned int metric, unsigned char distance,
461 route_tag_t tag);
462extern void rip_redistribute_delete(struct rip *rip, int type, int sub_type,
463 struct prefix_ipv4 *p, ifindex_t ifindex);
464extern void rip_redistribute_withdraw(struct rip *rip, int type);
465extern void rip_zebra_ipv4_add(struct rip *rip, struct route_node *rp);
466extern void rip_zebra_ipv4_delete(struct rip *rip, struct route_node *rp);
d62a17ae 467extern void rip_interface_multicast_set(int, struct connected *);
468extern void rip_distribute_update_interface(struct interface *);
469extern void rip_if_rmap_update_interface(struct interface *);
470
045c5389
RW
471extern int rip_show_network_config(struct vty *vty, struct rip *rip);
472extern void rip_show_redistribute_config(struct vty *vty, struct rip *rip);
473
474extern void rip_peer_update(struct rip *rip, struct sockaddr_in *from,
475 uint8_t version);
476extern void rip_peer_bad_route(struct rip *rip, struct sockaddr_in *from);
477extern void rip_peer_bad_packet(struct rip *rip, struct sockaddr_in *from);
478extern void rip_peer_display(struct vty *vty, struct rip *rip);
479extern struct rip_peer *rip_peer_lookup(struct rip *rip, struct in_addr *addr);
480extern struct rip_peer *rip_peer_lookup_next(struct rip *rip,
481 struct in_addr *addr);
29e897ad 482extern int rip_peer_list_cmp(struct rip_peer *p1, struct rip_peer *p2);
711915d2 483extern void rip_peer_list_del(void *arg);
d62a17ae 484
d62a17ae 485extern void rip_info_free(struct rip_info *);
045c5389 486extern struct rip *rip_info_get_instance(const struct rip_info *rinfo);
23b23d8c
RW
487extern struct rip_distance *rip_distance_new(void);
488extern void rip_distance_free(struct rip_distance *rdistance);
045c5389
RW
489extern uint8_t rip_distance_apply(struct rip *rip, struct rip_info *rinfo);
490extern void rip_redistribute_clean(struct rip *rip);
d62a17ae 491
1137aef4 492extern int rip_route_rte(struct rip_info *rinfo);
045c5389
RW
493extern struct rip_info *rip_ecmp_add(struct rip *rip,
494 struct rip_info *rinfo_new);
495extern struct rip_info *rip_ecmp_replace(struct rip *rip,
496 struct rip_info *rinfo_new);
497extern struct rip_info *rip_ecmp_delete(struct rip *rip,
498 struct rip_info *rinfo);
499
500extern struct rip_offset_list *rip_offset_list_new(struct rip *rip,
501 const char *ifname);
8c942f65 502extern void offset_list_del(struct rip_offset_list *offset);
045c5389
RW
503extern struct rip_offset_list *rip_offset_list_lookup(struct rip *rip,
504 const char *ifname);
8c942f65
RW
505extern int rip_offset_list_apply_in(struct prefix_ipv4 *, struct interface *,
506 uint32_t *);
507extern int rip_offset_list_apply_out(struct prefix_ipv4 *, struct interface *,
508 uint32_t *);
3f21c8c4
RW
509extern int offset_list_cmp(struct rip_offset_list *o1,
510 struct rip_offset_list *o2);
8c942f65 511
ae7b826a
RW
512extern void rip_vrf_init(void);
513extern void rip_vrf_terminate(void);
514
fe339c95
RW
515/* YANG notifications */
516extern void ripd_notif_send_auth_type_failure(const char *ifname);
517extern void ripd_notif_send_auth_failure(const char *ifname);
518
32b5a493 519extern struct zebra_privs_t ripd_privs;
32600a98 520extern struct rip_instance_head rip_instances;
32b5a493 521
718e3744 522/* Master thread strucutre. */
523extern struct thread_master *master;
524
d62a17ae 525DECLARE_HOOK(rip_ifaddr_add, (struct connected * ifc), (ifc))
526DECLARE_HOOK(rip_ifaddr_del, (struct connected * ifc), (ifc))
3012671f 527
707656ec
RW
528/* Northbound. */
529extern void rip_cli_init(void);
530extern const struct frr_yang_module_info frr_ripd_info;
531
718e3744 532#endif /* _ZEBRA_RIP_H */