rip_interface.c 50 KB

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