rip_interface.c 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118
  1. /* Interface related function for RIP.
  2. * Copyright (C) 1997, 98 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. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with GNU Zebra; see the file COPYING. If not, write to the Free
  18. * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  19. * 02111-1307, USA.
  20. */
  21. #include <zebra.h>
  22. #include "command.h"
  23. #include "if.h"
  24. #include "sockunion.h"
  25. #include "prefix.h"
  26. #include "memory.h"
  27. #include "network.h"
  28. #include "table.h"
  29. #include "log.h"
  30. #include "stream.h"
  31. #include "thread.h"
  32. #include "zclient.h"
  33. #include "filter.h"
  34. #include "sockopt.h"
  35. #include "privs.h"
  36. #include "zebra/connected.h"
  37. #include "ripd/ripd.h"
  38. #include "ripd/rip_debug.h"
  39. #include "ripd/rip_interface.h"
  40. /* static prototypes */
  41. static void rip_enable_apply (struct interface *);
  42. static void rip_passive_interface_apply (struct interface *);
  43. static int rip_if_down(struct interface *ifp);
  44. static int rip_enable_if_lookup (const char *ifname);
  45. static int rip_enable_network_lookup2 (struct connected *connected);
  46. static void rip_enable_apply_all (void);
  47. const struct message ri_version_msg[] =
  48. {
  49. {RI_RIP_VERSION_1, "1"},
  50. {RI_RIP_VERSION_2, "2"},
  51. {RI_RIP_VERSION_1_AND_2, "1 2"},
  52. };
  53. extern struct zebra_privs_t ripd_privs;
  54. /* RIP enabled network vector. */
  55. vector rip_enable_interface;
  56. /* RIP enabled interface table. */
  57. struct route_table *rip_enable_network;
  58. /* Vector to store passive-interface name. */
  59. static int passive_default; /* are we in passive-interface default mode? */
  60. vector Vrip_passive_nondefault;
  61. /* Join to the RIP version 2 multicast group. */
  62. static int
  63. ipv4_multicast_join (int sock,
  64. struct in_addr group,
  65. struct in_addr ifa,
  66. unsigned int ifindex)
  67. {
  68. int ret;
  69. ret = setsockopt_ipv4_multicast (sock,
  70. IP_ADD_MEMBERSHIP,
  71. group.s_addr,
  72. ifindex);
  73. if (ret < 0)
  74. zlog (NULL, LOG_INFO, "can't setsockopt IP_ADD_MEMBERSHIP %s",
  75. safe_strerror (errno));
  76. return ret;
  77. }
  78. /* Leave from the RIP version 2 multicast group. */
  79. static int
  80. ipv4_multicast_leave (int sock,
  81. struct in_addr group,
  82. struct in_addr ifa,
  83. unsigned int ifindex)
  84. {
  85. int ret;
  86. ret = setsockopt_ipv4_multicast (sock,
  87. IP_DROP_MEMBERSHIP,
  88. group.s_addr,
  89. ifindex);
  90. if (ret < 0)
  91. zlog (NULL, LOG_INFO, "can't setsockopt IP_DROP_MEMBERSHIP");
  92. return ret;
  93. }
  94. /* Allocate new RIP's interface configuration. */
  95. static struct rip_interface *
  96. rip_interface_new (void)
  97. {
  98. struct rip_interface *ri;
  99. ri = XCALLOC (MTYPE_RIP_INTERFACE, sizeof (struct rip_interface));
  100. /* Default authentication type is simple password for Cisco
  101. compatibility. */
  102. ri->auth_type = RIP_NO_AUTH;
  103. ri->md5_auth_len = RIP_AUTH_MD5_COMPAT_SIZE;
  104. /* Set default split-horizon behavior. If the interface is Frame
  105. Relay or SMDS is enabled, the default value for split-horizon is
  106. off. But currently Zebra does detect Frame Relay or SMDS
  107. interface. So all interface is set to split horizon. */
  108. ri->split_horizon_default = RIP_SPLIT_HORIZON;
  109. ri->split_horizon = ri->split_horizon_default;
  110. return ri;
  111. }
  112. void
  113. rip_interface_multicast_set (int sock, struct connected *connected)
  114. {
  115. assert (connected != NULL);
  116. if (setsockopt_ipv4_multicast_if (sock, connected->ifp->ifindex) < 0)
  117. {
  118. zlog_warn ("Can't setsockopt IP_MULTICAST_IF on fd %d to "
  119. "ifindex %d for interface %s",
  120. sock, connected->ifp->ifindex,
  121. connected->ifp->name);
  122. }
  123. return;
  124. }
  125. /* Send RIP request packet to specified interface. */
  126. static void
  127. rip_request_interface_send (struct interface *ifp, u_char version)
  128. {
  129. struct sockaddr_in to;
  130. /* RIPv2 support multicast. */
  131. if (version == RIPv2 && if_is_multicast (ifp))
  132. {
  133. if (IS_RIP_DEBUG_EVENT)
  134. zlog_debug ("multicast request on %s", ifp->name);
  135. rip_request_send (NULL, ifp, version, NULL);
  136. return;
  137. }
  138. /* RIPv1 and non multicast interface. */
  139. if (if_is_pointopoint (ifp) || if_is_broadcast (ifp))
  140. {
  141. struct listnode *cnode, *cnnode;
  142. struct connected *connected;
  143. if (IS_RIP_DEBUG_EVENT)
  144. zlog_debug ("broadcast request to %s", ifp->name);
  145. for (ALL_LIST_ELEMENTS (ifp->connected, cnode, cnnode, connected))
  146. {
  147. if (connected->address->family == AF_INET)
  148. {
  149. memset (&to, 0, sizeof (struct sockaddr_in));
  150. to.sin_port = htons (RIP_PORT_DEFAULT);
  151. if (connected->destination)
  152. /* use specified broadcast or peer destination addr */
  153. to.sin_addr = connected->destination->u.prefix4;
  154. else if (connected->address->prefixlen < IPV4_MAX_PREFIXLEN)
  155. /* calculate the appropriate broadcast address */
  156. to.sin_addr.s_addr =
  157. ipv4_broadcast_addr(connected->address->u.prefix4.s_addr,
  158. connected->address->prefixlen);
  159. else
  160. /* do not know where to send the packet */
  161. continue;
  162. if (IS_RIP_DEBUG_EVENT)
  163. zlog_debug ("SEND request to %s", inet_ntoa (to.sin_addr));
  164. rip_request_send (&to, ifp, version, connected);
  165. }
  166. }
  167. }
  168. }
  169. /* This will be executed when interface goes up. */
  170. static void
  171. rip_request_interface (struct interface *ifp)
  172. {
  173. struct rip_interface *ri;
  174. /* In default ripd doesn't send RIP_REQUEST to the loopback interface. */
  175. if (if_is_loopback (ifp))
  176. return;
  177. /* If interface is down, don't send RIP packet. */
  178. if (! if_is_operative (ifp))
  179. return;
  180. /* Fetch RIP interface information. */
  181. ri = ifp->info;
  182. /* If there is no version configuration in the interface,
  183. use rip's version setting. */
  184. {
  185. int vsend = ((ri->ri_send == RI_RIP_UNSPEC) ?
  186. rip->version_send : ri->ri_send);
  187. if (vsend & RIPv1)
  188. rip_request_interface_send (ifp, RIPv1);
  189. if (vsend & RIPv2)
  190. rip_request_interface_send (ifp, RIPv2);
  191. }
  192. }
  193. #if 0
  194. /* Send RIP request to the neighbor. */
  195. static void
  196. rip_request_neighbor (struct in_addr addr)
  197. {
  198. struct sockaddr_in to;
  199. memset (&to, 0, sizeof (struct sockaddr_in));
  200. to.sin_port = htons (RIP_PORT_DEFAULT);
  201. to.sin_addr = addr;
  202. rip_request_send (&to, NULL, rip->version_send, NULL);
  203. }
  204. /* Request routes at all interfaces. */
  205. static void
  206. rip_request_neighbor_all (void)
  207. {
  208. struct route_node *rp;
  209. if (! rip)
  210. return;
  211. if (IS_RIP_DEBUG_EVENT)
  212. zlog_debug ("request to the all neighbor");
  213. /* Send request to all neighbor. */
  214. for (rp = route_top (rip->neighbor); rp; rp = route_next (rp))
  215. if (rp->info)
  216. rip_request_neighbor (rp->p.u.prefix4);
  217. }
  218. #endif
  219. /* Multicast packet receive socket. */
  220. static int
  221. rip_multicast_join (struct interface *ifp, int sock)
  222. {
  223. struct listnode *cnode;
  224. struct connected *ifc;
  225. if (if_is_operative (ifp) && if_is_multicast (ifp))
  226. {
  227. if (IS_RIP_DEBUG_EVENT)
  228. zlog_debug ("multicast join at %s", ifp->name);
  229. for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, ifc))
  230. {
  231. struct prefix_ipv4 *p;
  232. struct in_addr group;
  233. p = (struct prefix_ipv4 *) ifc->address;
  234. if (p->family != AF_INET)
  235. continue;
  236. group.s_addr = htonl (INADDR_RIP_GROUP);
  237. if (ipv4_multicast_join (sock, group, p->prefix, ifp->ifindex) < 0)
  238. return -1;
  239. else
  240. return 0;
  241. }
  242. }
  243. return 0;
  244. }
  245. /* Leave from multicast group. */
  246. static void
  247. rip_multicast_leave (struct interface *ifp, int sock)
  248. {
  249. struct listnode *cnode;
  250. struct connected *connected;
  251. if (if_is_up (ifp) && if_is_multicast (ifp))
  252. {
  253. if (IS_RIP_DEBUG_EVENT)
  254. zlog_debug ("multicast leave from %s", ifp->name);
  255. for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, connected))
  256. {
  257. struct prefix_ipv4 *p;
  258. struct in_addr group;
  259. p = (struct prefix_ipv4 *) connected->address;
  260. if (p->family != AF_INET)
  261. continue;
  262. group.s_addr = htonl (INADDR_RIP_GROUP);
  263. if (ipv4_multicast_leave (sock, group, p->prefix, ifp->ifindex) == 0)
  264. return;
  265. }
  266. }
  267. }
  268. /* Is there and address on interface that I could use ? */
  269. static int
  270. rip_if_ipv4_address_check (struct interface *ifp)
  271. {
  272. struct listnode *nn;
  273. struct connected *connected;
  274. int count = 0;
  275. for (ALL_LIST_ELEMENTS_RO (ifp->connected, nn, connected))
  276. {
  277. struct prefix *p;
  278. p = connected->address;
  279. if (p->family == AF_INET)
  280. count++;
  281. }
  282. return count;
  283. }
  284. /* Does this address belongs to me ? */
  285. int
  286. if_check_address (struct in_addr addr)
  287. {
  288. struct listnode *node;
  289. struct interface *ifp;
  290. for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
  291. {
  292. struct listnode *cnode;
  293. struct connected *connected;
  294. for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, connected))
  295. {
  296. struct prefix_ipv4 *p;
  297. p = (struct prefix_ipv4 *) connected->address;
  298. if (p->family != AF_INET)
  299. continue;
  300. if (IPV4_ADDR_CMP (&p->prefix, &addr) == 0)
  301. return 1;
  302. }
  303. }
  304. return 0;
  305. }
  306. /* Inteface link down message processing. */
  307. int
  308. rip_interface_down (int command, struct zclient *zclient, zebra_size_t length,
  309. vrf_id_t vrf_id)
  310. {
  311. struct interface *ifp;
  312. struct stream *s;
  313. s = zclient->ibuf;
  314. /* zebra_interface_state_read() updates interface structure in
  315. iflist. */
  316. ifp = zebra_interface_state_read (s, vrf_id);
  317. if (ifp == NULL)
  318. return 0;
  319. rip_if_down(ifp);
  320. if (IS_RIP_DEBUG_ZEBRA)
  321. zlog_debug ("interface %s index %d flags %llx metric %d mtu %d is down",
  322. ifp->name, ifp->ifindex, (unsigned long long)ifp->flags,
  323. ifp->metric, ifp->mtu);
  324. return 0;
  325. }
  326. /* Inteface link up message processing */
  327. int
  328. rip_interface_up (int command, struct zclient *zclient, zebra_size_t length,
  329. vrf_id_t vrf_id)
  330. {
  331. struct interface *ifp;
  332. /* zebra_interface_state_read () updates interface structure in
  333. iflist. */
  334. ifp = zebra_interface_state_read (zclient->ibuf, vrf_id);
  335. if (ifp == NULL)
  336. return 0;
  337. if (IS_RIP_DEBUG_ZEBRA)
  338. zlog_debug ("interface %s index %d flags %#llx metric %d mtu %d is up",
  339. ifp->name, ifp->ifindex, (unsigned long long) ifp->flags,
  340. ifp->metric, ifp->mtu);
  341. /* Check if this interface is RIP enabled or not.*/
  342. rip_enable_apply (ifp);
  343. /* Check for a passive interface */
  344. rip_passive_interface_apply (ifp);
  345. /* Apply distribute list to the all interface. */
  346. rip_distribute_update_interface (ifp);
  347. return 0;
  348. }
  349. /* Inteface addition message from zebra. */
  350. int
  351. rip_interface_add (int command, struct zclient *zclient, zebra_size_t length,
  352. vrf_id_t vrf_id)
  353. {
  354. struct interface *ifp;
  355. ifp = zebra_interface_add_read (zclient->ibuf, vrf_id);
  356. if (IS_RIP_DEBUG_ZEBRA)
  357. zlog_debug ("interface add %s index %d flags %#llx metric %d mtu %d",
  358. ifp->name, ifp->ifindex, (unsigned long long) ifp->flags,
  359. ifp->metric, ifp->mtu);
  360. /* Check if this interface is RIP enabled or not.*/
  361. rip_enable_apply (ifp);
  362. /* Check for a passive interface */
  363. rip_passive_interface_apply (ifp);
  364. /* Apply distribute list to the all interface. */
  365. rip_distribute_update_interface (ifp);
  366. /* rip_request_neighbor_all (); */
  367. /* Check interface routemap. */
  368. rip_if_rmap_update_interface (ifp);
  369. return 0;
  370. }
  371. int
  372. rip_interface_delete (int command, struct zclient *zclient,
  373. zebra_size_t length, vrf_id_t vrf_id)
  374. {
  375. struct interface *ifp;
  376. struct stream *s;
  377. s = zclient->ibuf;
  378. /* zebra_interface_state_read() updates interface structure in iflist */
  379. ifp = zebra_interface_state_read (s, vrf_id);
  380. if (ifp == NULL)
  381. return 0;
  382. if (if_is_up (ifp)) {
  383. rip_if_down(ifp);
  384. }
  385. zlog_info("interface delete %s index %d flags %#llx metric %d mtu %d",
  386. ifp->name, ifp->ifindex, (unsigned long long) ifp->flags,
  387. ifp->metric, ifp->mtu);
  388. /* To support pseudo interface do not free interface structure. */
  389. /* if_delete(ifp); */
  390. ifp->ifindex = IFINDEX_INTERNAL;
  391. return 0;
  392. }
  393. void
  394. rip_interface_clean (void)
  395. {
  396. struct listnode *node;
  397. struct interface *ifp;
  398. struct rip_interface *ri;
  399. for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
  400. {
  401. ri = ifp->info;
  402. ri->enable_network = 0;
  403. ri->enable_interface = 0;
  404. ri->running = 0;
  405. if (ri->t_wakeup)
  406. {
  407. thread_cancel (ri->t_wakeup);
  408. ri->t_wakeup = NULL;
  409. }
  410. }
  411. }
  412. void
  413. rip_interface_reset (void)
  414. {
  415. struct listnode *node;
  416. struct interface *ifp;
  417. struct rip_interface *ri;
  418. for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
  419. {
  420. ri = ifp->info;
  421. ri->enable_network = 0;
  422. ri->enable_interface = 0;
  423. ri->running = 0;
  424. ri->ri_send = RI_RIP_UNSPEC;
  425. ri->ri_receive = RI_RIP_UNSPEC;
  426. ri->auth_type = RIP_NO_AUTH;
  427. if (ri->auth_str)
  428. {
  429. free (ri->auth_str);
  430. ri->auth_str = NULL;
  431. }
  432. if (ri->key_chain)
  433. {
  434. free (ri->key_chain);
  435. ri->key_chain = NULL;
  436. }
  437. ri->split_horizon = RIP_NO_SPLIT_HORIZON;
  438. ri->split_horizon_default = RIP_NO_SPLIT_HORIZON;
  439. ri->list[RIP_FILTER_IN] = NULL;
  440. ri->list[RIP_FILTER_OUT] = NULL;
  441. ri->prefix[RIP_FILTER_IN] = NULL;
  442. ri->prefix[RIP_FILTER_OUT] = NULL;
  443. if (ri->t_wakeup)
  444. {
  445. thread_cancel (ri->t_wakeup);
  446. ri->t_wakeup = NULL;
  447. }
  448. ri->recv_badpackets = 0;
  449. ri->recv_badroutes = 0;
  450. ri->sent_updates = 0;
  451. ri->passive = 0;
  452. }
  453. }
  454. int
  455. rip_if_down(struct interface *ifp)
  456. {
  457. struct route_node *rp;
  458. struct rip_info *rinfo;
  459. struct rip_interface *ri = NULL;
  460. struct list *list = NULL;
  461. struct listnode *listnode = NULL, *nextnode = NULL;
  462. if (rip)
  463. for (rp = route_top (rip->table); rp; rp = route_next (rp))
  464. if ((list = rp->info) != NULL)
  465. for (ALL_LIST_ELEMENTS (list, listnode, nextnode, rinfo))
  466. if (rinfo->ifindex == ifp->ifindex)
  467. rip_ecmp_delete (rinfo);
  468. ri = ifp->info;
  469. if (ri->running)
  470. {
  471. if (IS_RIP_DEBUG_EVENT)
  472. zlog_debug ("turn off %s", ifp->name);
  473. /* Leave from multicast group. */
  474. rip_multicast_leave (ifp, rip->sock);
  475. ri->running = 0;
  476. }
  477. return 0;
  478. }
  479. /* Needed for stop RIP process. */
  480. void
  481. rip_if_down_all ()
  482. {
  483. struct interface *ifp;
  484. struct listnode *node, *nnode;
  485. for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp))
  486. rip_if_down (ifp);
  487. }
  488. static void
  489. rip_apply_address_add (struct connected *ifc)
  490. {
  491. struct prefix_ipv4 address;
  492. struct prefix *p;
  493. if (!rip)
  494. return;
  495. if (! if_is_up(ifc->ifp))
  496. return;
  497. p = ifc->address;
  498. memset (&address, 0, sizeof (address));
  499. address.family = p->family;
  500. address.prefix = p->u.prefix4;
  501. address.prefixlen = p->prefixlen;
  502. apply_mask_ipv4(&address);
  503. /* Check if this interface is RIP enabled or not
  504. or Check if this address's prefix is RIP enabled */
  505. if ((rip_enable_if_lookup(ifc->ifp->name) >= 0) ||
  506. (rip_enable_network_lookup2(ifc) >= 0))
  507. rip_redistribute_add(ZEBRA_ROUTE_CONNECT, RIP_ROUTE_INTERFACE,
  508. &address, ifc->ifp->ifindex, NULL, 0, 0);
  509. }
  510. int
  511. rip_interface_address_add (int command, struct zclient *zclient,
  512. zebra_size_t length, vrf_id_t vrf_id)
  513. {
  514. struct connected *ifc;
  515. struct prefix *p;
  516. ifc = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD,
  517. zclient->ibuf, vrf_id);
  518. if (ifc == NULL)
  519. return 0;
  520. p = ifc->address;
  521. if (p->family == AF_INET)
  522. {
  523. if (IS_RIP_DEBUG_ZEBRA)
  524. zlog_debug ("connected address %s/%d is added",
  525. inet_ntoa (p->u.prefix4), p->prefixlen);
  526. rip_enable_apply(ifc->ifp);
  527. /* Check if this prefix needs to be redistributed */
  528. rip_apply_address_add(ifc);
  529. #ifdef HAVE_SNMP
  530. rip_ifaddr_add (ifc->ifp, ifc);
  531. #endif /* HAVE_SNMP */
  532. }
  533. return 0;
  534. }
  535. static void
  536. rip_apply_address_del (struct connected *ifc) {
  537. struct prefix_ipv4 address;
  538. struct prefix *p;
  539. if (!rip)
  540. return;
  541. if (! if_is_up(ifc->ifp))
  542. return;
  543. p = ifc->address;
  544. memset (&address, 0, sizeof (address));
  545. address.family = p->family;
  546. address.prefix = p->u.prefix4;
  547. address.prefixlen = p->prefixlen;
  548. apply_mask_ipv4(&address);
  549. rip_redistribute_delete(ZEBRA_ROUTE_CONNECT, RIP_ROUTE_INTERFACE,
  550. &address, ifc->ifp->ifindex);
  551. }
  552. int
  553. rip_interface_address_delete (int command, struct zclient *zclient,
  554. zebra_size_t length, vrf_id_t vrf_id)
  555. {
  556. struct connected *ifc;
  557. struct prefix *p;
  558. ifc = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE,
  559. zclient->ibuf, vrf_id);
  560. if (ifc)
  561. {
  562. p = ifc->address;
  563. if (p->family == AF_INET)
  564. {
  565. if (IS_RIP_DEBUG_ZEBRA)
  566. zlog_debug ("connected address %s/%d is deleted",
  567. inet_ntoa (p->u.prefix4), p->prefixlen);
  568. #ifdef HAVE_SNMP
  569. rip_ifaddr_delete (ifc->ifp, ifc);
  570. #endif /* HAVE_SNMP */
  571. /* Chech wether this prefix needs to be removed */
  572. rip_apply_address_del(ifc);
  573. }
  574. connected_free (ifc);
  575. }
  576. return 0;
  577. }
  578. /* Check interface is enabled by network statement. */
  579. /* Check wether the interface has at least a connected prefix that
  580. * is within the ripng_enable_network table. */
  581. static int
  582. rip_enable_network_lookup_if (struct interface *ifp)
  583. {
  584. struct listnode *node, *nnode;
  585. struct connected *connected;
  586. struct prefix_ipv4 address;
  587. for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, connected))
  588. {
  589. struct prefix *p;
  590. struct route_node *node;
  591. p = connected->address;
  592. if (p->family == AF_INET)
  593. {
  594. address.family = AF_INET;
  595. address.prefix = p->u.prefix4;
  596. address.prefixlen = IPV4_MAX_BITLEN;
  597. node = route_node_match (rip_enable_network,
  598. (struct prefix *)&address);
  599. if (node)
  600. {
  601. route_unlock_node (node);
  602. return 1;
  603. }
  604. }
  605. }
  606. return -1;
  607. }
  608. /* Check wether connected is within the ripng_enable_network table. */
  609. int
  610. rip_enable_network_lookup2 (struct connected *connected)
  611. {
  612. struct prefix_ipv4 address;
  613. struct prefix *p;
  614. p = connected->address;
  615. if (p->family == AF_INET) {
  616. struct route_node *node;
  617. address.family = p->family;
  618. address.prefix = p->u.prefix4;
  619. address.prefixlen = IPV4_MAX_BITLEN;
  620. /* LPM on p->family, p->u.prefix4/IPV4_MAX_BITLEN within rip_enable_network */
  621. node = route_node_match (rip_enable_network,
  622. (struct prefix *)&address);
  623. if (node) {
  624. route_unlock_node (node);
  625. return 1;
  626. }
  627. }
  628. return -1;
  629. }
  630. /* Add RIP enable network. */
  631. static int
  632. rip_enable_network_add (struct prefix *p)
  633. {
  634. struct route_node *node;
  635. node = route_node_get (rip_enable_network, p);
  636. if (node->info)
  637. {
  638. route_unlock_node (node);
  639. return -1;
  640. }
  641. else
  642. node->info = (char *) "enabled";
  643. /* XXX: One should find a better solution than a generic one */
  644. rip_enable_apply_all();
  645. return 1;
  646. }
  647. /* Delete RIP enable network. */
  648. static int
  649. rip_enable_network_delete (struct prefix *p)
  650. {
  651. struct route_node *node;
  652. node = route_node_lookup (rip_enable_network, p);
  653. if (node)
  654. {
  655. node->info = NULL;
  656. /* Unlock info lock. */
  657. route_unlock_node (node);
  658. /* Unlock lookup lock. */
  659. route_unlock_node (node);
  660. /* XXX: One should find a better solution than a generic one */
  661. rip_enable_apply_all ();
  662. return 1;
  663. }
  664. return -1;
  665. }
  666. /* Check interface is enabled by ifname statement. */
  667. static int
  668. rip_enable_if_lookup (const char *ifname)
  669. {
  670. unsigned int i;
  671. char *str;
  672. for (i = 0; i < vector_active (rip_enable_interface); i++)
  673. if ((str = vector_slot (rip_enable_interface, i)) != NULL)
  674. if (strcmp (str, ifname) == 0)
  675. return i;
  676. return -1;
  677. }
  678. /* Add interface to rip_enable_if. */
  679. static int
  680. rip_enable_if_add (const char *ifname)
  681. {
  682. int ret;
  683. ret = rip_enable_if_lookup (ifname);
  684. if (ret >= 0)
  685. return -1;
  686. vector_set (rip_enable_interface, strdup (ifname));
  687. rip_enable_apply_all(); /* TODOVJ */
  688. return 1;
  689. }
  690. /* Delete interface from rip_enable_if. */
  691. static int
  692. rip_enable_if_delete (const char *ifname)
  693. {
  694. int index;
  695. char *str;
  696. index = rip_enable_if_lookup (ifname);
  697. if (index < 0)
  698. return -1;
  699. str = vector_slot (rip_enable_interface, index);
  700. free (str);
  701. vector_unset (rip_enable_interface, index);
  702. rip_enable_apply_all(); /* TODOVJ */
  703. return 1;
  704. }
  705. /* Join to multicast group and send request to the interface. */
  706. static int
  707. rip_interface_wakeup (struct thread *t)
  708. {
  709. struct interface *ifp;
  710. struct rip_interface *ri;
  711. /* Get interface. */
  712. ifp = THREAD_ARG (t);
  713. ri = ifp->info;
  714. ri->t_wakeup = NULL;
  715. /* Join to multicast group. */
  716. if (rip_multicast_join (ifp, rip->sock) < 0)
  717. {
  718. zlog_err ("multicast join failed, interface %s not running", ifp->name);
  719. return 0;
  720. }
  721. /* Set running flag. */
  722. ri->running = 1;
  723. /* Send RIP request to the interface. */
  724. rip_request_interface (ifp);
  725. return 0;
  726. }
  727. static void
  728. rip_connect_set (struct interface *ifp, int set)
  729. {
  730. struct listnode *node, *nnode;
  731. struct connected *connected;
  732. struct prefix_ipv4 address;
  733. for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, connected))
  734. {
  735. struct prefix *p;
  736. p = connected->address;
  737. if (p->family != AF_INET)
  738. continue;
  739. address.family = AF_INET;
  740. address.prefix = p->u.prefix4;
  741. address.prefixlen = p->prefixlen;
  742. apply_mask_ipv4 (&address);
  743. if (set) {
  744. /* Check once more wether this prefix is within a "network IF_OR_PREF" one */
  745. if ((rip_enable_if_lookup(connected->ifp->name) >= 0) ||
  746. (rip_enable_network_lookup2(connected) >= 0))
  747. rip_redistribute_add (ZEBRA_ROUTE_CONNECT, RIP_ROUTE_INTERFACE,
  748. &address, connected->ifp->ifindex,
  749. NULL, 0, 0);
  750. } else
  751. {
  752. rip_redistribute_delete (ZEBRA_ROUTE_CONNECT, RIP_ROUTE_INTERFACE,
  753. &address, connected->ifp->ifindex);
  754. if (rip_redistribute_check (ZEBRA_ROUTE_CONNECT))
  755. rip_redistribute_add (ZEBRA_ROUTE_CONNECT, RIP_ROUTE_REDISTRIBUTE,
  756. &address, connected->ifp->ifindex,
  757. NULL, 0, 0);
  758. }
  759. }
  760. }
  761. /* Update interface status. */
  762. void
  763. rip_enable_apply (struct interface *ifp)
  764. {
  765. int ret;
  766. struct rip_interface *ri = NULL;
  767. /* Check interface. */
  768. if (! if_is_operative (ifp))
  769. return;
  770. ri = ifp->info;
  771. /* Check network configuration. */
  772. ret = rip_enable_network_lookup_if (ifp);
  773. /* If the interface is matched. */
  774. if (ret > 0)
  775. ri->enable_network = 1;
  776. else
  777. ri->enable_network = 0;
  778. /* Check interface name configuration. */
  779. ret = rip_enable_if_lookup (ifp->name);
  780. if (ret >= 0)
  781. ri->enable_interface = 1;
  782. else
  783. ri->enable_interface = 0;
  784. /* any interface MUST have an IPv4 address */
  785. if ( ! rip_if_ipv4_address_check (ifp) )
  786. {
  787. ri->enable_network = 0;
  788. ri->enable_interface = 0;
  789. }
  790. /* Update running status of the interface. */
  791. if (ri->enable_network || ri->enable_interface)
  792. {
  793. {
  794. if (IS_RIP_DEBUG_EVENT)
  795. zlog_debug ("turn on %s", ifp->name);
  796. /* Add interface wake up thread. */
  797. if (! ri->t_wakeup)
  798. ri->t_wakeup = thread_add_timer (master, rip_interface_wakeup,
  799. ifp, 1);
  800. rip_connect_set (ifp, 1);
  801. }
  802. }
  803. else
  804. {
  805. if (ri->running)
  806. {
  807. /* Might as well clean up the route table as well
  808. * rip_if_down sets to 0 ri->running, and displays "turn off %s"
  809. **/
  810. rip_if_down(ifp);
  811. rip_connect_set (ifp, 0);
  812. }
  813. }
  814. }
  815. /* Apply network configuration to all interface. */
  816. void
  817. rip_enable_apply_all ()
  818. {
  819. struct interface *ifp;
  820. struct listnode *node, *nnode;
  821. /* Check each interface. */
  822. for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp))
  823. rip_enable_apply (ifp);
  824. }
  825. int
  826. rip_neighbor_lookup (struct sockaddr_in *from)
  827. {
  828. struct prefix_ipv4 p;
  829. struct route_node *node;
  830. memset (&p, 0, sizeof (struct prefix_ipv4));
  831. p.family = AF_INET;
  832. p.prefix = from->sin_addr;
  833. p.prefixlen = IPV4_MAX_BITLEN;
  834. node = route_node_lookup (rip->neighbor, (struct prefix *) &p);
  835. if (node)
  836. {
  837. route_unlock_node (node);
  838. return 1;
  839. }
  840. return 0;
  841. }
  842. /* Add new RIP neighbor to the neighbor tree. */
  843. static int
  844. rip_neighbor_add (struct prefix_ipv4 *p)
  845. {
  846. struct route_node *node;
  847. node = route_node_get (rip->neighbor, (struct prefix *) p);
  848. if (node->info)
  849. return -1;
  850. node->info = rip->neighbor;
  851. return 0;
  852. }
  853. /* Delete RIP neighbor from the neighbor tree. */
  854. static int
  855. rip_neighbor_delete (struct prefix_ipv4 *p)
  856. {
  857. struct route_node *node;
  858. /* Lock for look up. */
  859. node = route_node_lookup (rip->neighbor, (struct prefix *) p);
  860. if (! node)
  861. return -1;
  862. node->info = NULL;
  863. /* Unlock lookup lock. */
  864. route_unlock_node (node);
  865. /* Unlock real neighbor information lock. */
  866. route_unlock_node (node);
  867. return 0;
  868. }
  869. /* Clear all network and neighbor configuration. */
  870. void
  871. rip_clean_network ()
  872. {
  873. unsigned int i;
  874. char *str;
  875. struct route_node *rn;
  876. /* rip_enable_network. */
  877. for (rn = route_top (rip_enable_network); rn; rn = route_next (rn))
  878. if (rn->info)
  879. {
  880. rn->info = NULL;
  881. route_unlock_node (rn);
  882. }
  883. /* rip_enable_interface. */
  884. for (i = 0; i < vector_active (rip_enable_interface); i++)
  885. if ((str = vector_slot (rip_enable_interface, i)) != NULL)
  886. {
  887. free (str);
  888. vector_slot (rip_enable_interface, i) = NULL;
  889. }
  890. }
  891. /* Utility function for looking up passive interface settings. */
  892. static int
  893. rip_passive_nondefault_lookup (const char *ifname)
  894. {
  895. unsigned int i;
  896. char *str;
  897. for (i = 0; i < vector_active (Vrip_passive_nondefault); i++)
  898. if ((str = vector_slot (Vrip_passive_nondefault, i)) != NULL)
  899. if (strcmp (str, ifname) == 0)
  900. return i;
  901. return -1;
  902. }
  903. void
  904. rip_passive_interface_apply (struct interface *ifp)
  905. {
  906. struct rip_interface *ri;
  907. ri = ifp->info;
  908. ri->passive = ((rip_passive_nondefault_lookup (ifp->name) < 0) ?
  909. passive_default : !passive_default);
  910. if (IS_RIP_DEBUG_ZEBRA)
  911. zlog_debug ("interface %s: passive = %d",ifp->name,ri->passive);
  912. }
  913. static void
  914. rip_passive_interface_apply_all (void)
  915. {
  916. struct interface *ifp;
  917. struct listnode *node, *nnode;
  918. for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp))
  919. rip_passive_interface_apply (ifp);
  920. }
  921. /* Passive interface. */
  922. static int
  923. rip_passive_nondefault_set (struct vty *vty, const char *ifname)
  924. {
  925. if (rip_passive_nondefault_lookup (ifname) >= 0)
  926. return CMD_WARNING;
  927. vector_set (Vrip_passive_nondefault, strdup (ifname));
  928. rip_passive_interface_apply_all ();
  929. return CMD_SUCCESS;
  930. }
  931. static int
  932. rip_passive_nondefault_unset (struct vty *vty, const char *ifname)
  933. {
  934. int i;
  935. char *str;
  936. i = rip_passive_nondefault_lookup (ifname);
  937. if (i < 0)
  938. return CMD_WARNING;
  939. str = vector_slot (Vrip_passive_nondefault, i);
  940. free (str);
  941. vector_unset (Vrip_passive_nondefault, i);
  942. rip_passive_interface_apply_all ();
  943. return CMD_SUCCESS;
  944. }
  945. /* Free all configured RIP passive-interface settings. */
  946. void
  947. rip_passive_nondefault_clean (void)
  948. {
  949. unsigned int i;
  950. char *str;
  951. for (i = 0; i < vector_active (Vrip_passive_nondefault); i++)
  952. if ((str = vector_slot (Vrip_passive_nondefault, i)) != NULL)
  953. {
  954. free (str);
  955. vector_slot (Vrip_passive_nondefault, i) = NULL;
  956. }
  957. rip_passive_interface_apply_all ();
  958. }
  959. /* RIP enable network or interface configuration. */
  960. DEFUN (rip_network,
  961. rip_network_cmd,
  962. "network (A.B.C.D/M|WORD)",
  963. "Enable routing on an IP network\n"
  964. "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
  965. "Interface name\n")
  966. {
  967. int ret;
  968. struct prefix_ipv4 p;
  969. ret = str2prefix_ipv4 (argv[0], &p);
  970. if (ret)
  971. ret = rip_enable_network_add ((struct prefix *) &p);
  972. else
  973. ret = rip_enable_if_add (argv[0]);
  974. if (ret < 0)
  975. {
  976. vty_out (vty, "There is a same network configuration %s%s", argv[0],
  977. VTY_NEWLINE);
  978. return CMD_WARNING;
  979. }
  980. return CMD_SUCCESS;
  981. }
  982. /* RIP enable network or interface configuration. */
  983. DEFUN (no_rip_network,
  984. no_rip_network_cmd,
  985. "no network (A.B.C.D/M|WORD)",
  986. NO_STR
  987. "Enable routing on an IP network\n"
  988. "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
  989. "Interface name\n")
  990. {
  991. int ret;
  992. struct prefix_ipv4 p;
  993. ret = str2prefix_ipv4 (argv[0], &p);
  994. if (ret)
  995. ret = rip_enable_network_delete ((struct prefix *) &p);
  996. else
  997. ret = rip_enable_if_delete (argv[0]);
  998. if (ret < 0)
  999. {
  1000. vty_out (vty, "Can't find network configuration %s%s", argv[0],
  1001. VTY_NEWLINE);
  1002. return CMD_WARNING;
  1003. }
  1004. return CMD_SUCCESS;
  1005. }
  1006. /* RIP neighbor configuration set. */
  1007. DEFUN (rip_neighbor,
  1008. rip_neighbor_cmd,
  1009. "neighbor A.B.C.D",
  1010. "Specify a neighbor router\n"
  1011. "Neighbor address\n")
  1012. {
  1013. int ret;
  1014. struct prefix_ipv4 p;
  1015. ret = str2prefix_ipv4 (argv[0], &p);
  1016. if (ret <= 0)
  1017. {
  1018. vty_out (vty, "Please specify address by A.B.C.D%s", VTY_NEWLINE);
  1019. return CMD_WARNING;
  1020. }
  1021. rip_neighbor_add (&p);
  1022. return CMD_SUCCESS;
  1023. }
  1024. /* RIP neighbor configuration unset. */
  1025. DEFUN (no_rip_neighbor,
  1026. no_rip_neighbor_cmd,
  1027. "no neighbor A.B.C.D",
  1028. NO_STR
  1029. "Specify a neighbor router\n"
  1030. "Neighbor address\n")
  1031. {
  1032. int ret;
  1033. struct prefix_ipv4 p;
  1034. ret = str2prefix_ipv4 (argv[0], &p);
  1035. if (ret <= 0)
  1036. {
  1037. vty_out (vty, "Please specify address by A.B.C.D%s", VTY_NEWLINE);
  1038. return CMD_WARNING;
  1039. }
  1040. rip_neighbor_delete (&p);
  1041. return CMD_SUCCESS;
  1042. }
  1043. DEFUN (ip_rip_receive_version,
  1044. ip_rip_receive_version_cmd,
  1045. "ip rip receive version (1|2)",
  1046. IP_STR
  1047. "Routing Information Protocol\n"
  1048. "Advertisement reception\n"
  1049. "Version control\n"
  1050. "RIP version 1\n"
  1051. "RIP version 2\n")
  1052. {
  1053. struct interface *ifp;
  1054. struct rip_interface *ri;
  1055. ifp = (struct interface *)vty->index;
  1056. ri = ifp->info;
  1057. /* Version 1. */
  1058. if (atoi (argv[0]) == 1)
  1059. {
  1060. ri->ri_receive = RI_RIP_VERSION_1;
  1061. return CMD_SUCCESS;
  1062. }
  1063. if (atoi (argv[0]) == 2)
  1064. {
  1065. ri->ri_receive = RI_RIP_VERSION_2;
  1066. return CMD_SUCCESS;
  1067. }
  1068. return CMD_WARNING;
  1069. }
  1070. DEFUN (ip_rip_receive_version_1,
  1071. ip_rip_receive_version_1_cmd,
  1072. "ip rip receive version 1 2",
  1073. IP_STR
  1074. "Routing Information Protocol\n"
  1075. "Advertisement reception\n"
  1076. "Version control\n"
  1077. "RIP version 1\n"
  1078. "RIP version 2\n")
  1079. {
  1080. struct interface *ifp;
  1081. struct rip_interface *ri;
  1082. ifp = (struct interface *)vty->index;
  1083. ri = ifp->info;
  1084. /* Version 1 and 2. */
  1085. ri->ri_receive = RI_RIP_VERSION_1_AND_2;
  1086. return CMD_SUCCESS;
  1087. }
  1088. DEFUN (ip_rip_receive_version_2,
  1089. ip_rip_receive_version_2_cmd,
  1090. "ip rip receive version 2 1",
  1091. IP_STR
  1092. "Routing Information Protocol\n"
  1093. "Advertisement reception\n"
  1094. "Version control\n"
  1095. "RIP version 2\n"
  1096. "RIP version 1\n")
  1097. {
  1098. struct interface *ifp;
  1099. struct rip_interface *ri;
  1100. ifp = (struct interface *)vty->index;
  1101. ri = ifp->info;
  1102. /* Version 1 and 2. */
  1103. ri->ri_receive = RI_RIP_VERSION_1_AND_2;
  1104. return CMD_SUCCESS;
  1105. }
  1106. DEFUN (no_ip_rip_receive_version,
  1107. no_ip_rip_receive_version_cmd,
  1108. "no ip rip receive version",
  1109. NO_STR
  1110. IP_STR
  1111. "Routing Information Protocol\n"
  1112. "Advertisement reception\n"
  1113. "Version control\n")
  1114. {
  1115. struct interface *ifp;
  1116. struct rip_interface *ri;
  1117. ifp = (struct interface *)vty->index;
  1118. ri = ifp->info;
  1119. ri->ri_receive = RI_RIP_UNSPEC;
  1120. return CMD_SUCCESS;
  1121. }
  1122. ALIAS (no_ip_rip_receive_version,
  1123. no_ip_rip_receive_version_num_cmd,
  1124. "no ip rip receive version (1|2)",
  1125. NO_STR
  1126. IP_STR
  1127. "Routing Information Protocol\n"
  1128. "Advertisement reception\n"
  1129. "Version control\n"
  1130. "Version 1\n"
  1131. "Version 2\n")
  1132. DEFUN (ip_rip_send_version,
  1133. ip_rip_send_version_cmd,
  1134. "ip rip send version (1|2)",
  1135. IP_STR
  1136. "Routing Information Protocol\n"
  1137. "Advertisement transmission\n"
  1138. "Version control\n"
  1139. "RIP version 1\n"
  1140. "RIP version 2\n")
  1141. {
  1142. struct interface *ifp;
  1143. struct rip_interface *ri;
  1144. ifp = (struct interface *)vty->index;
  1145. ri = ifp->info;
  1146. /* Version 1. */
  1147. if (atoi (argv[0]) == 1)
  1148. {
  1149. ri->ri_send = RI_RIP_VERSION_1;
  1150. return CMD_SUCCESS;
  1151. }
  1152. if (atoi (argv[0]) == 2)
  1153. {
  1154. ri->ri_send = RI_RIP_VERSION_2;
  1155. return CMD_SUCCESS;
  1156. }
  1157. return CMD_WARNING;
  1158. }
  1159. DEFUN (ip_rip_send_version_1,
  1160. ip_rip_send_version_1_cmd,
  1161. "ip rip send version 1 2",
  1162. IP_STR
  1163. "Routing Information Protocol\n"
  1164. "Advertisement transmission\n"
  1165. "Version control\n"
  1166. "RIP version 1\n"
  1167. "RIP version 2\n")
  1168. {
  1169. struct interface *ifp;
  1170. struct rip_interface *ri;
  1171. ifp = (struct interface *)vty->index;
  1172. ri = ifp->info;
  1173. /* Version 1 and 2. */
  1174. ri->ri_send = RI_RIP_VERSION_1_AND_2;
  1175. return CMD_SUCCESS;
  1176. }
  1177. DEFUN (ip_rip_send_version_2,
  1178. ip_rip_send_version_2_cmd,
  1179. "ip rip send version 2 1",
  1180. IP_STR
  1181. "Routing Information Protocol\n"
  1182. "Advertisement transmission\n"
  1183. "Version control\n"
  1184. "RIP version 2\n"
  1185. "RIP version 1\n")
  1186. {
  1187. struct interface *ifp;
  1188. struct rip_interface *ri;
  1189. ifp = (struct interface *)vty->index;
  1190. ri = ifp->info;
  1191. /* Version 1 and 2. */
  1192. ri->ri_send = RI_RIP_VERSION_1_AND_2;
  1193. return CMD_SUCCESS;
  1194. }
  1195. DEFUN (no_ip_rip_send_version,
  1196. no_ip_rip_send_version_cmd,
  1197. "no ip rip send version",
  1198. NO_STR
  1199. IP_STR
  1200. "Routing Information Protocol\n"
  1201. "Advertisement transmission\n"
  1202. "Version control\n")
  1203. {
  1204. struct interface *ifp;
  1205. struct rip_interface *ri;
  1206. ifp = (struct interface *)vty->index;
  1207. ri = ifp->info;
  1208. ri->ri_send = RI_RIP_UNSPEC;
  1209. return CMD_SUCCESS;
  1210. }
  1211. ALIAS (no_ip_rip_send_version,
  1212. no_ip_rip_send_version_num_cmd,
  1213. "no ip rip send version (1|2)",
  1214. NO_STR
  1215. IP_STR
  1216. "Routing Information Protocol\n"
  1217. "Advertisement transmission\n"
  1218. "Version control\n"
  1219. "Version 1\n"
  1220. "Version 2\n")
  1221. DEFUN (ip_rip_authentication_mode,
  1222. ip_rip_authentication_mode_cmd,
  1223. "ip rip authentication mode (md5|text)",
  1224. IP_STR
  1225. "Routing Information Protocol\n"
  1226. "Authentication control\n"
  1227. "Authentication mode\n"
  1228. "Keyed message digest\n"
  1229. "Clear text authentication\n")
  1230. {
  1231. struct interface *ifp;
  1232. struct rip_interface *ri;
  1233. int auth_type;
  1234. ifp = (struct interface *)vty->index;
  1235. ri = ifp->info;
  1236. if ( (argc < 1) || (argc > 2) )
  1237. {
  1238. vty_out (vty, "incorrect argument count%s", VTY_NEWLINE);
  1239. return CMD_WARNING;
  1240. }
  1241. if (strncmp ("md5", argv[0], strlen (argv[0])) == 0)
  1242. auth_type = RIP_AUTH_MD5;
  1243. else if (strncmp ("text", argv[0], strlen (argv[0])) == 0)
  1244. auth_type = RIP_AUTH_SIMPLE_PASSWORD;
  1245. else
  1246. {
  1247. vty_out (vty, "mode should be md5 or text%s", VTY_NEWLINE);
  1248. return CMD_WARNING;
  1249. }
  1250. if (argc == 1)
  1251. {
  1252. ri->auth_type = auth_type;
  1253. return CMD_SUCCESS;
  1254. }
  1255. if ( (argc == 2) && (auth_type != RIP_AUTH_MD5) )
  1256. {
  1257. vty_out (vty, "auth length argument only valid for md5%s", VTY_NEWLINE);
  1258. return CMD_WARNING;
  1259. }
  1260. if (strncmp ("r", argv[1], 1) == 0)
  1261. ri->md5_auth_len = RIP_AUTH_MD5_SIZE;
  1262. else if (strncmp ("o", argv[1], 1) == 0)
  1263. ri->md5_auth_len = RIP_AUTH_MD5_COMPAT_SIZE;
  1264. else
  1265. return CMD_WARNING;
  1266. ri->auth_type = auth_type;
  1267. return CMD_SUCCESS;
  1268. }
  1269. ALIAS (ip_rip_authentication_mode,
  1270. ip_rip_authentication_mode_authlen_cmd,
  1271. "ip rip authentication mode (md5|text) auth-length (rfc|old-ripd)",
  1272. IP_STR
  1273. "Routing Information Protocol\n"
  1274. "Authentication control\n"
  1275. "Authentication mode\n"
  1276. "Keyed message digest\n"
  1277. "Clear text authentication\n"
  1278. "MD5 authentication data length\n"
  1279. "RFC compatible\n"
  1280. "Old ripd compatible\n")
  1281. DEFUN (no_ip_rip_authentication_mode,
  1282. no_ip_rip_authentication_mode_cmd,
  1283. "no ip rip authentication mode",
  1284. NO_STR
  1285. IP_STR
  1286. "Routing Information Protocol\n"
  1287. "Authentication control\n"
  1288. "Authentication mode\n")
  1289. {
  1290. struct interface *ifp;
  1291. struct rip_interface *ri;
  1292. ifp = (struct interface *)vty->index;
  1293. ri = ifp->info;
  1294. ri->auth_type = RIP_NO_AUTH;
  1295. ri->md5_auth_len = RIP_AUTH_MD5_COMPAT_SIZE;
  1296. return CMD_SUCCESS;
  1297. }
  1298. ALIAS (no_ip_rip_authentication_mode,
  1299. no_ip_rip_authentication_mode_type_cmd,
  1300. "no ip rip authentication mode (md5|text)",
  1301. NO_STR
  1302. IP_STR
  1303. "Routing Information Protocol\n"
  1304. "Authentication control\n"
  1305. "Authentication mode\n"
  1306. "Keyed message digest\n"
  1307. "Clear text authentication\n")
  1308. ALIAS (no_ip_rip_authentication_mode,
  1309. no_ip_rip_authentication_mode_type_authlen_cmd,
  1310. "no ip rip authentication mode (md5|text) auth-length (rfc|old-ripd)",
  1311. NO_STR
  1312. IP_STR
  1313. "Routing Information Protocol\n"
  1314. "Authentication control\n"
  1315. "Authentication mode\n"
  1316. "Keyed message digest\n"
  1317. "Clear text authentication\n"
  1318. "MD5 authentication data length\n"
  1319. "RFC compatible\n"
  1320. "Old ripd compatible\n")
  1321. DEFUN (ip_rip_authentication_string,
  1322. ip_rip_authentication_string_cmd,
  1323. "ip rip authentication string LINE",
  1324. IP_STR
  1325. "Routing Information Protocol\n"
  1326. "Authentication control\n"
  1327. "Authentication string\n"
  1328. "Authentication string\n")
  1329. {
  1330. struct interface *ifp;
  1331. struct rip_interface *ri;
  1332. ifp = (struct interface *)vty->index;
  1333. ri = ifp->info;
  1334. if (strlen (argv[0]) > 16)
  1335. {
  1336. vty_out (vty, "%% RIPv2 authentication string must be shorter than 16%s",
  1337. VTY_NEWLINE);
  1338. return CMD_WARNING;
  1339. }
  1340. if (ri->key_chain)
  1341. {
  1342. vty_out (vty, "%% key-chain configuration exists%s", VTY_NEWLINE);
  1343. return CMD_WARNING;
  1344. }
  1345. if (ri->auth_str)
  1346. free (ri->auth_str);
  1347. ri->auth_str = strdup (argv[0]);
  1348. return CMD_SUCCESS;
  1349. }
  1350. DEFUN (no_ip_rip_authentication_string,
  1351. no_ip_rip_authentication_string_cmd,
  1352. "no ip rip authentication string",
  1353. NO_STR
  1354. IP_STR
  1355. "Routing Information Protocol\n"
  1356. "Authentication control\n"
  1357. "Authentication string\n")
  1358. {
  1359. struct interface *ifp;
  1360. struct rip_interface *ri;
  1361. ifp = (struct interface *)vty->index;
  1362. ri = ifp->info;
  1363. if (ri->auth_str)
  1364. free (ri->auth_str);
  1365. ri->auth_str = NULL;
  1366. return CMD_SUCCESS;
  1367. }
  1368. ALIAS (no_ip_rip_authentication_string,
  1369. no_ip_rip_authentication_string2_cmd,
  1370. "no ip rip authentication string LINE",
  1371. NO_STR
  1372. IP_STR
  1373. "Routing Information Protocol\n"
  1374. "Authentication control\n"
  1375. "Authentication string\n"
  1376. "Authentication string\n")
  1377. DEFUN (ip_rip_authentication_key_chain,
  1378. ip_rip_authentication_key_chain_cmd,
  1379. "ip rip authentication key-chain LINE",
  1380. IP_STR
  1381. "Routing Information Protocol\n"
  1382. "Authentication control\n"
  1383. "Authentication key-chain\n"
  1384. "name of key-chain\n")
  1385. {
  1386. struct interface *ifp;
  1387. struct rip_interface *ri;
  1388. ifp = (struct interface *) vty->index;
  1389. ri = ifp->info;
  1390. if (ri->auth_str)
  1391. {
  1392. vty_out (vty, "%% authentication string configuration exists%s",
  1393. VTY_NEWLINE);
  1394. return CMD_WARNING;
  1395. }
  1396. if (ri->key_chain)
  1397. free (ri->key_chain);
  1398. ri->key_chain = strdup (argv[0]);
  1399. return CMD_SUCCESS;
  1400. }
  1401. DEFUN (no_ip_rip_authentication_key_chain,
  1402. no_ip_rip_authentication_key_chain_cmd,
  1403. "no ip rip authentication key-chain",
  1404. NO_STR
  1405. IP_STR
  1406. "Routing Information Protocol\n"
  1407. "Authentication control\n"
  1408. "Authentication key-chain\n")
  1409. {
  1410. struct interface *ifp;
  1411. struct rip_interface *ri;
  1412. ifp = (struct interface *) vty->index;
  1413. ri = ifp->info;
  1414. if (ri->key_chain)
  1415. free (ri->key_chain);
  1416. ri->key_chain = NULL;
  1417. return CMD_SUCCESS;
  1418. }
  1419. ALIAS (no_ip_rip_authentication_key_chain,
  1420. no_ip_rip_authentication_key_chain2_cmd,
  1421. "no ip rip authentication key-chain LINE",
  1422. NO_STR
  1423. IP_STR
  1424. "Routing Information Protocol\n"
  1425. "Authentication control\n"
  1426. "Authentication key-chain\n"
  1427. "name of key-chain\n")
  1428. /* CHANGED: ip rip split-horizon
  1429. Cisco and Zebra's command is
  1430. ip split-horizon
  1431. */
  1432. DEFUN (ip_rip_split_horizon,
  1433. ip_rip_split_horizon_cmd,
  1434. "ip rip split-horizon",
  1435. IP_STR
  1436. "Routing Information Protocol\n"
  1437. "Perform split horizon\n")
  1438. {
  1439. struct interface *ifp;
  1440. struct rip_interface *ri;
  1441. ifp = vty->index;
  1442. ri = ifp->info;
  1443. ri->split_horizon = RIP_SPLIT_HORIZON;
  1444. return CMD_SUCCESS;
  1445. }
  1446. DEFUN (ip_rip_split_horizon_poisoned_reverse,
  1447. ip_rip_split_horizon_poisoned_reverse_cmd,
  1448. "ip rip split-horizon poisoned-reverse",
  1449. IP_STR
  1450. "Routing Information Protocol\n"
  1451. "Perform split horizon\n"
  1452. "With poisoned-reverse\n")
  1453. {
  1454. struct interface *ifp;
  1455. struct rip_interface *ri;
  1456. ifp = vty->index;
  1457. ri = ifp->info;
  1458. ri->split_horizon = RIP_SPLIT_HORIZON_POISONED_REVERSE;
  1459. return CMD_SUCCESS;
  1460. }
  1461. /* CHANGED: no ip rip split-horizon
  1462. Cisco and Zebra's command is
  1463. no ip split-horizon
  1464. */
  1465. DEFUN (no_ip_rip_split_horizon,
  1466. no_ip_rip_split_horizon_cmd,
  1467. "no ip rip split-horizon",
  1468. NO_STR
  1469. IP_STR
  1470. "Routing Information Protocol\n"
  1471. "Perform split horizon\n")
  1472. {
  1473. struct interface *ifp;
  1474. struct rip_interface *ri;
  1475. ifp = vty->index;
  1476. ri = ifp->info;
  1477. ri->split_horizon = RIP_NO_SPLIT_HORIZON;
  1478. return CMD_SUCCESS;
  1479. }
  1480. DEFUN (no_ip_rip_split_horizon_poisoned_reverse,
  1481. no_ip_rip_split_horizon_poisoned_reverse_cmd,
  1482. "no ip rip split-horizon poisoned-reverse",
  1483. NO_STR
  1484. IP_STR
  1485. "Routing Information Protocol\n"
  1486. "Perform split horizon\n"
  1487. "With poisoned-reverse\n")
  1488. {
  1489. struct interface *ifp;
  1490. struct rip_interface *ri;
  1491. ifp = vty->index;
  1492. ri = ifp->info;
  1493. switch( ri->split_horizon )
  1494. {
  1495. case RIP_SPLIT_HORIZON_POISONED_REVERSE:
  1496. ri->split_horizon = RIP_SPLIT_HORIZON;
  1497. default:
  1498. break;
  1499. }
  1500. return CMD_SUCCESS;
  1501. }
  1502. DEFUN (rip_passive_interface,
  1503. rip_passive_interface_cmd,
  1504. "passive-interface (IFNAME|default)",
  1505. "Suppress routing updates on an interface\n"
  1506. "Interface name\n"
  1507. "default for all interfaces\n")
  1508. {
  1509. const char *ifname = argv[0];
  1510. if (!strcmp(ifname,"default")) {
  1511. passive_default = 1;
  1512. rip_passive_nondefault_clean();
  1513. return CMD_SUCCESS;
  1514. }
  1515. if (passive_default)
  1516. return rip_passive_nondefault_unset (vty, ifname);
  1517. else
  1518. return rip_passive_nondefault_set (vty, ifname);
  1519. }
  1520. DEFUN (no_rip_passive_interface,
  1521. no_rip_passive_interface_cmd,
  1522. "no passive-interface (IFNAME|default)",
  1523. NO_STR
  1524. "Suppress routing updates on an interface\n"
  1525. "Interface name\n"
  1526. "default for all interfaces\n")
  1527. {
  1528. const char *ifname = argv[0];
  1529. if (!strcmp(ifname,"default")) {
  1530. passive_default = 0;
  1531. rip_passive_nondefault_clean();
  1532. return CMD_SUCCESS;
  1533. }
  1534. if (passive_default)
  1535. return rip_passive_nondefault_set (vty, ifname);
  1536. else
  1537. return rip_passive_nondefault_unset (vty, ifname);
  1538. }
  1539. /* Write rip configuration of each interface. */
  1540. static int
  1541. rip_interface_config_write (struct vty *vty)
  1542. {
  1543. struct listnode *node;
  1544. struct interface *ifp;
  1545. for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
  1546. {
  1547. struct rip_interface *ri;
  1548. ri = ifp->info;
  1549. /* Do not display the interface if there is no
  1550. * configuration about it.
  1551. **/
  1552. if ((!ifp->desc) &&
  1553. (ri->split_horizon == ri->split_horizon_default) &&
  1554. (ri->ri_send == RI_RIP_UNSPEC) &&
  1555. (ri->ri_receive == RI_RIP_UNSPEC) &&
  1556. (ri->auth_type != RIP_AUTH_MD5) &&
  1557. (ri->md5_auth_len != RIP_AUTH_MD5_SIZE) &&
  1558. (!ri->auth_str) &&
  1559. (!ri->key_chain) )
  1560. continue;
  1561. vty_out (vty, "interface %s%s", ifp->name,
  1562. VTY_NEWLINE);
  1563. if (ifp->desc)
  1564. vty_out (vty, " description %s%s", ifp->desc,
  1565. VTY_NEWLINE);
  1566. /* Split horizon. */
  1567. if (ri->split_horizon != ri->split_horizon_default)
  1568. {
  1569. switch (ri->split_horizon) {
  1570. case RIP_SPLIT_HORIZON:
  1571. vty_out (vty, " ip rip split-horizon%s", VTY_NEWLINE);
  1572. break;
  1573. case RIP_SPLIT_HORIZON_POISONED_REVERSE:
  1574. vty_out (vty, " ip rip split-horizon poisoned-reverse%s",
  1575. VTY_NEWLINE);
  1576. break;
  1577. case RIP_NO_SPLIT_HORIZON:
  1578. default:
  1579. vty_out (vty, " no ip rip split-horizon%s", VTY_NEWLINE);
  1580. break;
  1581. }
  1582. }
  1583. /* RIP version setting. */
  1584. if (ri->ri_send != RI_RIP_UNSPEC)
  1585. vty_out (vty, " ip rip send version %s%s",
  1586. lookup (ri_version_msg, ri->ri_send),
  1587. VTY_NEWLINE);
  1588. if (ri->ri_receive != RI_RIP_UNSPEC)
  1589. vty_out (vty, " ip rip receive version %s%s",
  1590. lookup (ri_version_msg, ri->ri_receive),
  1591. VTY_NEWLINE);
  1592. /* RIP authentication. */
  1593. if (ri->auth_type == RIP_AUTH_SIMPLE_PASSWORD)
  1594. vty_out (vty, " ip rip authentication mode text%s", VTY_NEWLINE);
  1595. if (ri->auth_type == RIP_AUTH_MD5)
  1596. {
  1597. vty_out (vty, " ip rip authentication mode md5");
  1598. if (ri->md5_auth_len == RIP_AUTH_MD5_COMPAT_SIZE)
  1599. vty_out (vty, " auth-length old-ripd");
  1600. else
  1601. vty_out (vty, " auth-length rfc");
  1602. vty_out (vty, "%s", VTY_NEWLINE);
  1603. }
  1604. if (ri->auth_str)
  1605. vty_out (vty, " ip rip authentication string %s%s",
  1606. ri->auth_str, VTY_NEWLINE);
  1607. if (ri->key_chain)
  1608. vty_out (vty, " ip rip authentication key-chain %s%s",
  1609. ri->key_chain, VTY_NEWLINE);
  1610. vty_out (vty, "!%s", VTY_NEWLINE);
  1611. }
  1612. return 0;
  1613. }
  1614. int
  1615. config_write_rip_network (struct vty *vty, int config_mode)
  1616. {
  1617. unsigned int i;
  1618. char *ifname;
  1619. struct route_node *node;
  1620. /* Network type RIP enable interface statement. */
  1621. for (node = route_top (rip_enable_network); node; node = route_next (node))
  1622. if (node->info)
  1623. vty_out (vty, "%s%s/%d%s",
  1624. config_mode ? " network " : " ",
  1625. inet_ntoa (node->p.u.prefix4),
  1626. node->p.prefixlen,
  1627. VTY_NEWLINE);
  1628. /* Interface name RIP enable statement. */
  1629. for (i = 0; i < vector_active (rip_enable_interface); i++)
  1630. if ((ifname = vector_slot (rip_enable_interface, i)) != NULL)
  1631. vty_out (vty, "%s%s%s",
  1632. config_mode ? " network " : " ",
  1633. ifname,
  1634. VTY_NEWLINE);
  1635. /* RIP neighbors listing. */
  1636. for (node = route_top (rip->neighbor); node; node = route_next (node))
  1637. if (node->info)
  1638. vty_out (vty, "%s%s%s",
  1639. config_mode ? " neighbor " : " ",
  1640. inet_ntoa (node->p.u.prefix4),
  1641. VTY_NEWLINE);
  1642. /* RIP passive interface listing. */
  1643. if (config_mode) {
  1644. if (passive_default)
  1645. vty_out (vty, " passive-interface default%s", VTY_NEWLINE);
  1646. for (i = 0; i < vector_active (Vrip_passive_nondefault); i++)
  1647. if ((ifname = vector_slot (Vrip_passive_nondefault, i)) != NULL)
  1648. vty_out (vty, " %spassive-interface %s%s",
  1649. (passive_default ? "no " : ""), ifname, VTY_NEWLINE);
  1650. }
  1651. return 0;
  1652. }
  1653. static struct cmd_node interface_node =
  1654. {
  1655. INTERFACE_NODE,
  1656. "%s(config-if)# ",
  1657. 1,
  1658. };
  1659. /* Called when interface structure allocated. */
  1660. static int
  1661. rip_interface_new_hook (struct interface *ifp)
  1662. {
  1663. ifp->info = rip_interface_new ();
  1664. return 0;
  1665. }
  1666. /* Called when interface structure deleted. */
  1667. static int
  1668. rip_interface_delete_hook (struct interface *ifp)
  1669. {
  1670. XFREE (MTYPE_RIP_INTERFACE, ifp->info);
  1671. ifp->info = NULL;
  1672. return 0;
  1673. }
  1674. /* Allocate and initialize interface vector. */
  1675. void
  1676. rip_if_init (void)
  1677. {
  1678. /* Default initial size of interface vector. */
  1679. if_add_hook (IF_NEW_HOOK, rip_interface_new_hook);
  1680. if_add_hook (IF_DELETE_HOOK, rip_interface_delete_hook);
  1681. /* RIP network init. */
  1682. rip_enable_interface = vector_init (1);
  1683. rip_enable_network = route_table_init ();
  1684. /* RIP passive interface. */
  1685. Vrip_passive_nondefault = vector_init (1);
  1686. /* Install interface node. */
  1687. install_node (&interface_node, rip_interface_config_write);
  1688. /* Install commands. */
  1689. install_element (CONFIG_NODE, &interface_cmd);
  1690. install_element (CONFIG_NODE, &no_interface_cmd);
  1691. install_default (INTERFACE_NODE);
  1692. install_element (INTERFACE_NODE, &interface_desc_cmd);
  1693. install_element (INTERFACE_NODE, &no_interface_desc_cmd);
  1694. install_element (RIP_NODE, &rip_network_cmd);
  1695. install_element (RIP_NODE, &no_rip_network_cmd);
  1696. install_element (RIP_NODE, &rip_neighbor_cmd);
  1697. install_element (RIP_NODE, &no_rip_neighbor_cmd);
  1698. install_element (RIP_NODE, &rip_passive_interface_cmd);
  1699. install_element (RIP_NODE, &no_rip_passive_interface_cmd);
  1700. install_element (INTERFACE_NODE, &ip_rip_send_version_cmd);
  1701. install_element (INTERFACE_NODE, &ip_rip_send_version_1_cmd);
  1702. install_element (INTERFACE_NODE, &ip_rip_send_version_2_cmd);
  1703. install_element (INTERFACE_NODE, &no_ip_rip_send_version_cmd);
  1704. install_element (INTERFACE_NODE, &no_ip_rip_send_version_num_cmd);
  1705. install_element (INTERFACE_NODE, &ip_rip_receive_version_cmd);
  1706. install_element (INTERFACE_NODE, &ip_rip_receive_version_1_cmd);
  1707. install_element (INTERFACE_NODE, &ip_rip_receive_version_2_cmd);
  1708. install_element (INTERFACE_NODE, &no_ip_rip_receive_version_cmd);
  1709. install_element (INTERFACE_NODE, &no_ip_rip_receive_version_num_cmd);
  1710. install_element (INTERFACE_NODE, &ip_rip_authentication_mode_cmd);
  1711. install_element (INTERFACE_NODE, &ip_rip_authentication_mode_authlen_cmd);
  1712. install_element (INTERFACE_NODE, &no_ip_rip_authentication_mode_cmd);
  1713. install_element (INTERFACE_NODE, &no_ip_rip_authentication_mode_type_cmd);
  1714. install_element (INTERFACE_NODE, &no_ip_rip_authentication_mode_type_authlen_cmd);
  1715. install_element (INTERFACE_NODE, &ip_rip_authentication_key_chain_cmd);
  1716. install_element (INTERFACE_NODE, &no_ip_rip_authentication_key_chain_cmd);
  1717. install_element (INTERFACE_NODE, &no_ip_rip_authentication_key_chain2_cmd);
  1718. install_element (INTERFACE_NODE, &ip_rip_authentication_string_cmd);
  1719. install_element (INTERFACE_NODE, &no_ip_rip_authentication_string_cmd);
  1720. install_element (INTERFACE_NODE, &no_ip_rip_authentication_string2_cmd);
  1721. install_element (INTERFACE_NODE, &ip_rip_split_horizon_cmd);
  1722. install_element (INTERFACE_NODE, &ip_rip_split_horizon_poisoned_reverse_cmd);
  1723. install_element (INTERFACE_NODE, &no_ip_rip_split_horizon_cmd);
  1724. install_element (INTERFACE_NODE, &no_ip_rip_split_horizon_poisoned_reverse_cmd);
  1725. }