rip_interface.c 51 KB

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