rip_interface.c 50 KB

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