ospf6_interface.c 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952
  1. /*
  2. * Copyright (C) 2003 Yasuhiro Ohara
  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
  18. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. * Boston, MA 02111-1307, USA.
  20. */
  21. #include <zebra.h>
  22. #include "memory.h"
  23. #include "if.h"
  24. #include "log.h"
  25. #include "command.h"
  26. #include "thread.h"
  27. #include "prefix.h"
  28. #include "plist.h"
  29. #include "ospf6_lsa.h"
  30. #include "ospf6_lsdb.h"
  31. #include "ospf6_network.h"
  32. #include "ospf6_message.h"
  33. #include "ospf6_route.h"
  34. #include "ospf6_top.h"
  35. #include "ospf6_area.h"
  36. #include "ospf6_interface.h"
  37. #include "ospf6_neighbor.h"
  38. #include "ospf6_intra.h"
  39. #include "ospf6_spf.h"
  40. #include "ospf6_snmp.h"
  41. #include "ospf6d.h"
  42. unsigned char conf_debug_ospf6_interface = 0;
  43. const char *ospf6_interface_state_str[] =
  44. {
  45. "None",
  46. "Down",
  47. "Loopback",
  48. "Waiting",
  49. "PointToPoint",
  50. "DROther",
  51. "BDR",
  52. "DR",
  53. NULL
  54. };
  55. struct ospf6_interface *
  56. ospf6_interface_lookup_by_ifindex (ifindex_t ifindex)
  57. {
  58. struct ospf6_interface *oi;
  59. struct interface *ifp;
  60. ifp = if_lookup_by_index (ifindex);
  61. if (ifp == NULL)
  62. return (struct ospf6_interface *) NULL;
  63. oi = (struct ospf6_interface *) ifp->info;
  64. return oi;
  65. }
  66. /* schedule routing table recalculation */
  67. static void
  68. ospf6_interface_lsdb_hook (struct ospf6_lsa *lsa, unsigned int reason)
  69. {
  70. struct ospf6_interface *oi;
  71. if (lsa == NULL)
  72. return;
  73. oi = lsa->lsdb->data;
  74. switch (ntohs (lsa->header->type))
  75. {
  76. case OSPF6_LSTYPE_LINK:
  77. if (oi->state == OSPF6_INTERFACE_DR)
  78. OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
  79. ospf6_spf_schedule (oi->area->ospf6, reason);
  80. break;
  81. default:
  82. break;
  83. }
  84. }
  85. static void
  86. ospf6_interface_lsdb_hook_add (struct ospf6_lsa *lsa)
  87. {
  88. ospf6_interface_lsdb_hook(lsa, ospf6_lsadd_to_spf_reason(lsa));
  89. }
  90. static void
  91. ospf6_interface_lsdb_hook_remove (struct ospf6_lsa *lsa)
  92. {
  93. ospf6_interface_lsdb_hook(lsa, ospf6_lsremove_to_spf_reason(lsa));
  94. }
  95. static u_char
  96. ospf6_default_iftype(struct interface *ifp)
  97. {
  98. if (if_is_pointopoint (ifp))
  99. return OSPF_IFTYPE_POINTOPOINT;
  100. else if (if_is_loopback (ifp))
  101. return OSPF_IFTYPE_LOOPBACK;
  102. else
  103. return OSPF_IFTYPE_BROADCAST;
  104. }
  105. static u_int32_t
  106. ospf6_interface_get_cost (struct ospf6_interface *oi)
  107. {
  108. /* If all else fails, use default OSPF cost */
  109. u_int32_t cost;
  110. u_int32_t bw, refbw;
  111. bw = oi->interface->bandwidth ? oi->interface->bandwidth : OSPF6_INTERFACE_BANDWIDTH;
  112. refbw = ospf6 ? ospf6->ref_bandwidth : OSPF6_REFERENCE_BANDWIDTH;
  113. /* A specifed ip ospf cost overrides a calculated one. */
  114. if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST))
  115. cost = oi->cost;
  116. else
  117. {
  118. cost = (u_int32_t) ((double)refbw / (double)bw + (double)0.5);
  119. if (cost < 1) cost = 1;
  120. else if (cost > UINT32_MAX) cost = UINT32_MAX;
  121. }
  122. return cost;
  123. }
  124. static void
  125. ospf6_interface_recalculate_cost (struct ospf6_interface *oi)
  126. {
  127. u_int32_t newcost;
  128. newcost = ospf6_interface_get_cost (oi);
  129. if (newcost == oi->cost) return;
  130. oi->cost = newcost;
  131. /* update cost held in route_connected list in ospf6_interface */
  132. ospf6_interface_connected_route_update (oi->interface);
  133. /* execute LSA hooks */
  134. if (oi->area)
  135. {
  136. OSPF6_LINK_LSA_SCHEDULE (oi);
  137. OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
  138. OSPF6_NETWORK_LSA_SCHEDULE (oi);
  139. OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
  140. OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
  141. }
  142. }
  143. /* Create new ospf6 interface structure */
  144. struct ospf6_interface *
  145. ospf6_interface_create (struct interface *ifp)
  146. {
  147. struct ospf6_interface *oi;
  148. unsigned int iobuflen;
  149. oi = (struct ospf6_interface *)
  150. XCALLOC (MTYPE_OSPF6_IF, sizeof (struct ospf6_interface));
  151. if (!oi)
  152. {
  153. zlog_err ("Can't malloc ospf6_interface for ifindex %d", ifp->ifindex);
  154. return (struct ospf6_interface *) NULL;
  155. }
  156. oi->area = (struct ospf6_area *) NULL;
  157. oi->neighbor_list = list_new ();
  158. oi->neighbor_list->cmp = ospf6_neighbor_cmp;
  159. oi->linklocal_addr = (struct in6_addr *) NULL;
  160. oi->instance_id = OSPF6_INTERFACE_INSTANCE_ID;
  161. oi->transdelay = OSPF6_INTERFACE_TRANSDELAY;
  162. oi->priority = OSPF6_INTERFACE_PRIORITY;
  163. oi->hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
  164. oi->dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
  165. oi->rxmt_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
  166. oi->type = ospf6_default_iftype (ifp);
  167. oi->state = OSPF6_INTERFACE_DOWN;
  168. oi->flag = 0;
  169. oi->mtu_ignore = 0;
  170. /* Try to adjust I/O buffer size with IfMtu */
  171. oi->ifmtu = ifp->mtu6;
  172. iobuflen = ospf6_iobuf_size (ifp->mtu6);
  173. if (oi->ifmtu > iobuflen)
  174. {
  175. if (IS_OSPF6_DEBUG_INTERFACE)
  176. zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
  177. ifp->name, iobuflen);
  178. oi->ifmtu = iobuflen;
  179. }
  180. oi->lsupdate_list = ospf6_lsdb_create (oi);
  181. oi->lsack_list = ospf6_lsdb_create (oi);
  182. oi->lsdb = ospf6_lsdb_create (oi);
  183. oi->lsdb->hook_add = ospf6_interface_lsdb_hook_add;
  184. oi->lsdb->hook_remove = ospf6_interface_lsdb_hook_remove;
  185. oi->lsdb_self = ospf6_lsdb_create (oi);
  186. oi->route_connected = OSPF6_ROUTE_TABLE_CREATE (INTERFACE, CONNECTED_ROUTES);
  187. oi->route_connected->scope = oi;
  188. /* link both */
  189. oi->interface = ifp;
  190. ifp->info = oi;
  191. /* Compute cost. */
  192. oi->cost = ospf6_interface_get_cost(oi);
  193. return oi;
  194. }
  195. void
  196. ospf6_interface_delete (struct ospf6_interface *oi)
  197. {
  198. struct listnode *node, *nnode;
  199. struct ospf6_neighbor *on;
  200. for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
  201. ospf6_neighbor_delete (on);
  202. list_delete (oi->neighbor_list);
  203. THREAD_OFF (oi->thread_send_hello);
  204. THREAD_OFF (oi->thread_send_lsupdate);
  205. THREAD_OFF (oi->thread_send_lsack);
  206. ospf6_lsdb_remove_all (oi->lsdb);
  207. ospf6_lsdb_remove_all (oi->lsupdate_list);
  208. ospf6_lsdb_remove_all (oi->lsack_list);
  209. ospf6_lsdb_delete (oi->lsdb);
  210. ospf6_lsdb_delete (oi->lsdb_self);
  211. ospf6_lsdb_delete (oi->lsupdate_list);
  212. ospf6_lsdb_delete (oi->lsack_list);
  213. ospf6_route_table_delete (oi->route_connected);
  214. /* cut link */
  215. oi->interface->info = NULL;
  216. /* plist_name */
  217. if (oi->plist_name)
  218. XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
  219. XFREE (MTYPE_OSPF6_IF, oi);
  220. }
  221. void
  222. ospf6_interface_enable (struct ospf6_interface *oi)
  223. {
  224. UNSET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
  225. ospf6_interface_state_update (oi->interface);
  226. }
  227. void
  228. ospf6_interface_disable (struct ospf6_interface *oi)
  229. {
  230. SET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
  231. thread_execute (master, interface_down, oi, 0);
  232. ospf6_lsdb_remove_all (oi->lsdb);
  233. ospf6_lsdb_remove_all (oi->lsdb_self);
  234. ospf6_lsdb_remove_all (oi->lsupdate_list);
  235. ospf6_lsdb_remove_all (oi->lsack_list);
  236. THREAD_OFF (oi->thread_send_hello);
  237. THREAD_OFF (oi->thread_send_lsupdate);
  238. THREAD_OFF (oi->thread_send_lsack);
  239. THREAD_OFF (oi->thread_network_lsa);
  240. THREAD_OFF (oi->thread_link_lsa);
  241. THREAD_OFF (oi->thread_intra_prefix_lsa);
  242. }
  243. static struct in6_addr *
  244. ospf6_interface_get_linklocal_address (struct interface *ifp)
  245. {
  246. struct listnode *n;
  247. struct connected *c;
  248. struct in6_addr *l = (struct in6_addr *) NULL;
  249. /* for each connected address */
  250. for (ALL_LIST_ELEMENTS_RO (ifp->connected, n, c))
  251. {
  252. /* if family not AF_INET6, ignore */
  253. if (c->address->family != AF_INET6)
  254. continue;
  255. /* linklocal scope check */
  256. if (IN6_IS_ADDR_LINKLOCAL (&c->address->u.prefix6))
  257. l = &c->address->u.prefix6;
  258. }
  259. return l;
  260. }
  261. void
  262. ospf6_interface_if_add (struct interface *ifp)
  263. {
  264. struct ospf6_interface *oi;
  265. unsigned int iobuflen;
  266. oi = (struct ospf6_interface *) ifp->info;
  267. if (oi == NULL)
  268. return;
  269. /* Try to adjust I/O buffer size with IfMtu */
  270. if (oi->ifmtu == 0)
  271. oi->ifmtu = ifp->mtu6;
  272. iobuflen = ospf6_iobuf_size (ifp->mtu6);
  273. if (oi->ifmtu > iobuflen)
  274. {
  275. if (IS_OSPF6_DEBUG_INTERFACE)
  276. zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
  277. ifp->name, iobuflen);
  278. oi->ifmtu = iobuflen;
  279. }
  280. /* interface start */
  281. ospf6_interface_state_update(oi->interface);
  282. }
  283. void
  284. ospf6_interface_if_del (struct interface *ifp)
  285. {
  286. struct ospf6_interface *oi;
  287. oi = (struct ospf6_interface *) ifp->info;
  288. if (oi == NULL)
  289. return;
  290. /* interface stop */
  291. if (oi->area)
  292. thread_execute (master, interface_down, oi, 0);
  293. listnode_delete (oi->area->if_list, oi);
  294. oi->area = (struct ospf6_area *) NULL;
  295. /* cut link */
  296. oi->interface = NULL;
  297. ifp->info = NULL;
  298. ospf6_interface_delete (oi);
  299. }
  300. void
  301. ospf6_interface_state_update (struct interface *ifp)
  302. {
  303. struct ospf6_interface *oi;
  304. oi = (struct ospf6_interface *) ifp->info;
  305. if (oi == NULL)
  306. return;
  307. if (oi->area == NULL)
  308. return;
  309. if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE))
  310. return;
  311. if (if_is_operative (ifp)
  312. && (ospf6_interface_get_linklocal_address(oi->interface)
  313. || if_is_loopback(oi->interface)))
  314. thread_add_event (master, interface_up, oi, 0);
  315. else
  316. thread_add_event (master, interface_down, oi, 0);
  317. return;
  318. }
  319. void
  320. ospf6_interface_connected_route_update (struct interface *ifp)
  321. {
  322. struct ospf6_interface *oi;
  323. struct ospf6_route *route;
  324. struct connected *c;
  325. struct listnode *node, *nnode;
  326. oi = (struct ospf6_interface *) ifp->info;
  327. if (oi == NULL)
  328. return;
  329. /* reset linklocal pointer */
  330. oi->linklocal_addr = ospf6_interface_get_linklocal_address (ifp);
  331. /* if area is null, do not make connected-route list */
  332. if (oi->area == NULL)
  333. return;
  334. if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE))
  335. return;
  336. /* update "route to advertise" interface route table */
  337. ospf6_route_remove_all (oi->route_connected);
  338. for (ALL_LIST_ELEMENTS (oi->interface->connected, node, nnode, c))
  339. {
  340. if (c->address->family != AF_INET6)
  341. continue;
  342. CONTINUE_IF_ADDRESS_LINKLOCAL (IS_OSPF6_DEBUG_INTERFACE, c->address);
  343. CONTINUE_IF_ADDRESS_UNSPECIFIED (IS_OSPF6_DEBUG_INTERFACE, c->address);
  344. CONTINUE_IF_ADDRESS_LOOPBACK (IS_OSPF6_DEBUG_INTERFACE, c->address);
  345. CONTINUE_IF_ADDRESS_V4COMPAT (IS_OSPF6_DEBUG_INTERFACE, c->address);
  346. CONTINUE_IF_ADDRESS_V4MAPPED (IS_OSPF6_DEBUG_INTERFACE, c->address);
  347. /* apply filter */
  348. if (oi->plist_name)
  349. {
  350. struct prefix_list *plist;
  351. enum prefix_list_type ret;
  352. char buf[128];
  353. prefix2str (c->address, buf, sizeof (buf));
  354. plist = prefix_list_lookup (AFI_IP6, oi->plist_name);
  355. ret = prefix_list_apply (plist, (void *) c->address);
  356. if (ret == PREFIX_DENY)
  357. {
  358. if (IS_OSPF6_DEBUG_INTERFACE)
  359. zlog_debug ("%s on %s filtered by prefix-list %s ",
  360. buf, oi->interface->name, oi->plist_name);
  361. continue;
  362. }
  363. }
  364. route = ospf6_route_create ();
  365. memcpy (&route->prefix, c->address, sizeof (struct prefix));
  366. apply_mask (&route->prefix);
  367. route->type = OSPF6_DEST_TYPE_NETWORK;
  368. route->path.area_id = oi->area->area_id;
  369. route->path.type = OSPF6_PATH_TYPE_INTRA;
  370. route->path.cost = oi->cost;
  371. route->nexthop[0].ifindex = oi->interface->ifindex;
  372. inet_pton (AF_INET6, "::1", &route->nexthop[0].address);
  373. ospf6_route_add (route, oi->route_connected);
  374. }
  375. /* create new Link-LSA */
  376. OSPF6_LINK_LSA_SCHEDULE (oi);
  377. OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
  378. OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
  379. }
  380. static void
  381. ospf6_interface_state_change (u_char next_state, struct ospf6_interface *oi)
  382. {
  383. u_char prev_state;
  384. prev_state = oi->state;
  385. oi->state = next_state;
  386. if (prev_state == next_state)
  387. return;
  388. /* log */
  389. if (IS_OSPF6_DEBUG_INTERFACE)
  390. {
  391. zlog_debug ("Interface state change %s: %s -> %s", oi->interface->name,
  392. ospf6_interface_state_str[prev_state],
  393. ospf6_interface_state_str[next_state]);
  394. }
  395. oi->state_change++;
  396. if ((prev_state == OSPF6_INTERFACE_DR ||
  397. prev_state == OSPF6_INTERFACE_BDR) &&
  398. (next_state != OSPF6_INTERFACE_DR &&
  399. next_state != OSPF6_INTERFACE_BDR))
  400. ospf6_sso (oi->interface->ifindex, &alldrouters6, IPV6_LEAVE_GROUP);
  401. if ((prev_state != OSPF6_INTERFACE_DR &&
  402. prev_state != OSPF6_INTERFACE_BDR) &&
  403. (next_state == OSPF6_INTERFACE_DR ||
  404. next_state == OSPF6_INTERFACE_BDR))
  405. ospf6_sso (oi->interface->ifindex, &alldrouters6, IPV6_JOIN_GROUP);
  406. OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
  407. if (next_state == OSPF6_INTERFACE_DOWN)
  408. {
  409. OSPF6_NETWORK_LSA_EXECUTE (oi);
  410. OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT (oi);
  411. OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
  412. }
  413. else if (prev_state == OSPF6_INTERFACE_DR ||
  414. next_state == OSPF6_INTERFACE_DR)
  415. {
  416. OSPF6_NETWORK_LSA_SCHEDULE (oi);
  417. OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
  418. OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
  419. }
  420. #ifdef HAVE_SNMP
  421. /* Terminal state or regression */
  422. if ((next_state == OSPF6_INTERFACE_POINTTOPOINT) ||
  423. (next_state == OSPF6_INTERFACE_DROTHER) ||
  424. (next_state == OSPF6_INTERFACE_BDR) ||
  425. (next_state == OSPF6_INTERFACE_DR) ||
  426. (next_state < prev_state))
  427. ospf6TrapIfStateChange (oi);
  428. #endif
  429. }
  430. /* DR Election, RFC2328 section 9.4 */
  431. #define IS_ELIGIBLE(n) \
  432. ((n)->state >= OSPF6_NEIGHBOR_TWOWAY && (n)->priority != 0)
  433. static struct ospf6_neighbor *
  434. better_bdrouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
  435. {
  436. if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id) &&
  437. (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id))
  438. return NULL;
  439. else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id)
  440. return b;
  441. else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id)
  442. return a;
  443. if (a->bdrouter == a->router_id && b->bdrouter != b->router_id)
  444. return a;
  445. if (a->bdrouter != a->router_id && b->bdrouter == b->router_id)
  446. return b;
  447. if (a->priority > b->priority)
  448. return a;
  449. if (a->priority < b->priority)
  450. return b;
  451. if (ntohl (a->router_id) > ntohl (b->router_id))
  452. return a;
  453. if (ntohl (a->router_id) < ntohl (b->router_id))
  454. return b;
  455. zlog_warn ("Router-ID duplicate ?");
  456. return a;
  457. }
  458. static struct ospf6_neighbor *
  459. better_drouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
  460. {
  461. if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id) &&
  462. (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id))
  463. return NULL;
  464. else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id)
  465. return b;
  466. else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id)
  467. return a;
  468. if (a->drouter == a->router_id && b->drouter != b->router_id)
  469. return a;
  470. if (a->drouter != a->router_id && b->drouter == b->router_id)
  471. return b;
  472. if (a->priority > b->priority)
  473. return a;
  474. if (a->priority < b->priority)
  475. return b;
  476. if (ntohl (a->router_id) > ntohl (b->router_id))
  477. return a;
  478. if (ntohl (a->router_id) < ntohl (b->router_id))
  479. return b;
  480. zlog_warn ("Router-ID duplicate ?");
  481. return a;
  482. }
  483. static u_char
  484. dr_election (struct ospf6_interface *oi)
  485. {
  486. struct listnode *node, *nnode;
  487. struct ospf6_neighbor *on, *drouter, *bdrouter, myself;
  488. struct ospf6_neighbor *best_drouter, *best_bdrouter;
  489. u_char next_state = 0;
  490. drouter = bdrouter = NULL;
  491. best_drouter = best_bdrouter = NULL;
  492. /* pseudo neighbor myself, including noting current DR/BDR (1) */
  493. memset (&myself, 0, sizeof (myself));
  494. inet_ntop (AF_INET, &oi->area->ospf6->router_id, myself.name,
  495. sizeof (myself.name));
  496. myself.state = OSPF6_NEIGHBOR_TWOWAY;
  497. myself.drouter = oi->drouter;
  498. myself.bdrouter = oi->bdrouter;
  499. myself.priority = oi->priority;
  500. myself.router_id = oi->area->ospf6->router_id;
  501. /* Electing BDR (2) */
  502. for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
  503. bdrouter = better_bdrouter (bdrouter, on);
  504. best_bdrouter = bdrouter;
  505. bdrouter = better_bdrouter (best_bdrouter, &myself);
  506. /* Electing DR (3) */
  507. for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
  508. drouter = better_drouter (drouter, on);
  509. best_drouter = drouter;
  510. drouter = better_drouter (best_drouter, &myself);
  511. if (drouter == NULL)
  512. drouter = bdrouter;
  513. /* the router itself is newly/no longer DR/BDR (4) */
  514. if ((drouter == &myself && myself.drouter != myself.router_id) ||
  515. (drouter != &myself && myself.drouter == myself.router_id) ||
  516. (bdrouter == &myself && myself.bdrouter != myself.router_id) ||
  517. (bdrouter != &myself && myself.bdrouter == myself.router_id))
  518. {
  519. myself.drouter = (drouter ? drouter->router_id : htonl (0));
  520. myself.bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
  521. /* compatible to Electing BDR (2) */
  522. bdrouter = better_bdrouter (best_bdrouter, &myself);
  523. /* compatible to Electing DR (3) */
  524. drouter = better_drouter (best_drouter, &myself);
  525. if (drouter == NULL)
  526. drouter = bdrouter;
  527. }
  528. /* Set interface state accordingly (5) */
  529. if (drouter && drouter == &myself)
  530. next_state = OSPF6_INTERFACE_DR;
  531. else if (bdrouter && bdrouter == &myself)
  532. next_state = OSPF6_INTERFACE_BDR;
  533. else
  534. next_state = OSPF6_INTERFACE_DROTHER;
  535. /* If NBMA, schedule Start for each neighbor having priority of 0 (6) */
  536. /* XXX */
  537. /* If DR or BDR change, invoke AdjOK? for each neighbor (7) */
  538. /* RFC 2328 section 12.4. Originating LSAs (3) will be handled
  539. accordingly after AdjOK */
  540. if (oi->drouter != (drouter ? drouter->router_id : htonl (0)) ||
  541. oi->bdrouter != (bdrouter ? bdrouter->router_id : htonl (0)))
  542. {
  543. if (IS_OSPF6_DEBUG_INTERFACE)
  544. zlog_debug ("DR Election on %s: DR: %s BDR: %s", oi->interface->name,
  545. (drouter ? drouter->name : "0.0.0.0"),
  546. (bdrouter ? bdrouter->name : "0.0.0.0"));
  547. for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, node, on))
  548. {
  549. if (on->state < OSPF6_NEIGHBOR_TWOWAY)
  550. continue;
  551. /* Schedule AdjOK. */
  552. thread_add_event (master, adj_ok, on, 0);
  553. }
  554. }
  555. oi->drouter = (drouter ? drouter->router_id : htonl (0));
  556. oi->bdrouter = (bdrouter ? bdrouter->router_id : htonl (0));
  557. return next_state;
  558. }
  559. /* Interface State Machine */
  560. int
  561. interface_up (struct thread *thread)
  562. {
  563. struct ospf6_interface *oi;
  564. oi = (struct ospf6_interface *) THREAD_ARG (thread);
  565. assert (oi && oi->interface);
  566. if (IS_OSPF6_DEBUG_INTERFACE)
  567. zlog_debug ("Interface Event %s: [InterfaceUp]",
  568. oi->interface->name);
  569. /* check physical interface is up */
  570. if (! if_is_operative (oi->interface))
  571. {
  572. if (IS_OSPF6_DEBUG_INTERFACE)
  573. zlog_debug ("Interface %s is down, can't execute [InterfaceUp]",
  574. oi->interface->name);
  575. return 0;
  576. }
  577. /* check interface has a link-local address */
  578. if (! (ospf6_interface_get_linklocal_address(oi->interface)
  579. || if_is_loopback(oi->interface)))
  580. {
  581. if (IS_OSPF6_DEBUG_INTERFACE)
  582. zlog_debug ("Interface %s has no link local address, can't execute [InterfaceUp]",
  583. oi->interface->name);
  584. return 0;
  585. }
  586. /* Recompute cost */
  587. ospf6_interface_recalculate_cost (oi);
  588. /* if already enabled, do nothing */
  589. if (oi->state > OSPF6_INTERFACE_DOWN)
  590. {
  591. if (IS_OSPF6_DEBUG_INTERFACE)
  592. zlog_debug ("Interface %s already enabled",
  593. oi->interface->name);
  594. return 0;
  595. }
  596. /* If no area assigned, return */
  597. if (oi->area == NULL)
  598. {
  599. zlog_debug ("%s: Not scheduleing Hello for %s as there is no area assigned yet", __func__,
  600. oi->interface->name);
  601. return 0;
  602. }
  603. /* Join AllSPFRouters */
  604. ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_JOIN_GROUP);
  605. /* Update interface route */
  606. ospf6_interface_connected_route_update (oi->interface);
  607. /* Schedule Hello */
  608. if (! CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
  609. oi->thread_send_hello = thread_add_event (master, ospf6_hello_send, oi, 0);
  610. /* decide next interface state */
  611. if ((if_is_pointopoint (oi->interface)) ||
  612. (oi->type == OSPF_IFTYPE_POINTOPOINT)) {
  613. ospf6_interface_state_change (OSPF6_INTERFACE_POINTTOPOINT, oi);
  614. }
  615. else if (oi->priority == 0)
  616. ospf6_interface_state_change (OSPF6_INTERFACE_DROTHER, oi);
  617. else
  618. {
  619. ospf6_interface_state_change (OSPF6_INTERFACE_WAITING, oi);
  620. thread_add_timer (master, wait_timer, oi, oi->dead_interval);
  621. }
  622. return 0;
  623. }
  624. int
  625. wait_timer (struct thread *thread)
  626. {
  627. struct ospf6_interface *oi;
  628. oi = (struct ospf6_interface *) THREAD_ARG (thread);
  629. assert (oi && oi->interface);
  630. if (IS_OSPF6_DEBUG_INTERFACE)
  631. zlog_debug ("Interface Event %s: [WaitTimer]",
  632. oi->interface->name);
  633. if (oi->state == OSPF6_INTERFACE_WAITING)
  634. ospf6_interface_state_change (dr_election (oi), oi);
  635. return 0;
  636. }
  637. int
  638. backup_seen (struct thread *thread)
  639. {
  640. struct ospf6_interface *oi;
  641. oi = (struct ospf6_interface *) THREAD_ARG (thread);
  642. assert (oi && oi->interface);
  643. if (IS_OSPF6_DEBUG_INTERFACE)
  644. zlog_debug ("Interface Event %s: [BackupSeen]",
  645. oi->interface->name);
  646. if (oi->state == OSPF6_INTERFACE_WAITING)
  647. ospf6_interface_state_change (dr_election (oi), oi);
  648. return 0;
  649. }
  650. int
  651. neighbor_change (struct thread *thread)
  652. {
  653. struct ospf6_interface *oi;
  654. oi = (struct ospf6_interface *) THREAD_ARG (thread);
  655. assert (oi && oi->interface);
  656. if (IS_OSPF6_DEBUG_INTERFACE)
  657. zlog_debug ("Interface Event %s: [NeighborChange]",
  658. oi->interface->name);
  659. if (oi->state == OSPF6_INTERFACE_DROTHER ||
  660. oi->state == OSPF6_INTERFACE_BDR ||
  661. oi->state == OSPF6_INTERFACE_DR)
  662. ospf6_interface_state_change (dr_election (oi), oi);
  663. return 0;
  664. }
  665. int
  666. interface_down (struct thread *thread)
  667. {
  668. struct ospf6_interface *oi;
  669. struct listnode *node, *nnode;
  670. struct ospf6_neighbor *on;
  671. oi = (struct ospf6_interface *) THREAD_ARG (thread);
  672. assert (oi && oi->interface);
  673. if (IS_OSPF6_DEBUG_INTERFACE)
  674. zlog_debug ("Interface Event %s: [InterfaceDown]",
  675. oi->interface->name);
  676. /* Stop Hellos */
  677. THREAD_OFF (oi->thread_send_hello);
  678. /* Leave AllSPFRouters */
  679. if (oi->state > OSPF6_INTERFACE_DOWN)
  680. ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_LEAVE_GROUP);
  681. ospf6_interface_state_change (OSPF6_INTERFACE_DOWN, oi);
  682. for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
  683. ospf6_neighbor_delete (on);
  684. list_delete_all_node (oi->neighbor_list);
  685. /* When interface state is reset, also reset information about
  686. * DR election, as it is no longer valid. */
  687. oi->drouter = oi->prev_drouter = htonl(0);
  688. oi->bdrouter = oi->prev_bdrouter = htonl(0);
  689. return 0;
  690. }
  691. /* show specified interface structure */
  692. static int
  693. ospf6_interface_show (struct vty *vty, struct interface *ifp)
  694. {
  695. struct ospf6_interface *oi;
  696. struct connected *c;
  697. struct prefix *p;
  698. struct listnode *i;
  699. char strbuf[64], drouter[32], bdrouter[32];
  700. const char *updown[3] = {"down", "up", NULL};
  701. const char *type;
  702. struct timeval res, now;
  703. char duration[32];
  704. struct ospf6_lsa *lsa;
  705. /* check physical interface type */
  706. if (if_is_loopback (ifp))
  707. type = "LOOPBACK";
  708. else if (if_is_broadcast (ifp))
  709. type = "BROADCAST";
  710. else if (if_is_pointopoint (ifp))
  711. type = "POINTOPOINT";
  712. else
  713. type = "UNKNOWN";
  714. vty_out (vty, "%s is %s, type %s%s",
  715. ifp->name, updown[if_is_operative (ifp)], type,
  716. VNL);
  717. vty_out (vty, " Interface ID: %d%s", ifp->ifindex, VNL);
  718. if (ifp->info == NULL)
  719. {
  720. vty_out (vty, " OSPF not enabled on this interface%s", VNL);
  721. return 0;
  722. }
  723. else
  724. oi = (struct ospf6_interface *) ifp->info;
  725. vty_out (vty, " Internet Address:%s", VNL);
  726. for (ALL_LIST_ELEMENTS_RO (ifp->connected, i, c))
  727. {
  728. p = c->address;
  729. prefix2str (p, strbuf, sizeof (strbuf));
  730. switch (p->family)
  731. {
  732. case AF_INET:
  733. vty_out (vty, " inet : %s%s", strbuf,
  734. VNL);
  735. break;
  736. case AF_INET6:
  737. vty_out (vty, " inet6: %s%s", strbuf,
  738. VNL);
  739. break;
  740. default:
  741. vty_out (vty, " ??? : %s%s", strbuf,
  742. VNL);
  743. break;
  744. }
  745. }
  746. if (oi->area)
  747. {
  748. vty_out (vty, " Instance ID %d, Interface MTU %d (autodetect: %d)%s",
  749. oi->instance_id, oi->ifmtu, ifp->mtu6, VNL);
  750. vty_out (vty, " MTU mismatch detection: %s%s", oi->mtu_ignore ?
  751. "disabled" : "enabled", VNL);
  752. inet_ntop (AF_INET, &oi->area->area_id,
  753. strbuf, sizeof (strbuf));
  754. vty_out (vty, " Area ID %s, Cost %u%s", strbuf, oi->cost,
  755. VNL);
  756. }
  757. else
  758. vty_out (vty, " Not Attached to Area%s", VNL);
  759. vty_out (vty, " State %s, Transmit Delay %d sec, Priority %d%s",
  760. ospf6_interface_state_str[oi->state],
  761. oi->transdelay, oi->priority,
  762. VNL);
  763. vty_out (vty, " Timer intervals configured:%s", VNL);
  764. vty_out (vty, " Hello %d, Dead %d, Retransmit %d%s",
  765. oi->hello_interval, oi->dead_interval, oi->rxmt_interval,
  766. VNL);
  767. inet_ntop (AF_INET, &oi->drouter, drouter, sizeof (drouter));
  768. inet_ntop (AF_INET, &oi->bdrouter, bdrouter, sizeof (bdrouter));
  769. vty_out (vty, " DR: %s BDR: %s%s", drouter, bdrouter, VNL);
  770. vty_out (vty, " Number of I/F scoped LSAs is %u%s",
  771. oi->lsdb->count, VNL);
  772. quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
  773. timerclear (&res);
  774. if (oi->thread_send_lsupdate)
  775. timersub (&oi->thread_send_lsupdate->u.sands, &now, &res);
  776. timerstring (&res, duration, sizeof (duration));
  777. vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",
  778. oi->lsupdate_list->count, duration,
  779. (oi->thread_send_lsupdate ? "on" : "off"),
  780. VNL);
  781. for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa;
  782. lsa = ospf6_lsdb_next (lsa))
  783. vty_out (vty, " %s%s", lsa->name, VNL);
  784. timerclear (&res);
  785. if (oi->thread_send_lsack)
  786. timersub (&oi->thread_send_lsack->u.sands, &now, &res);
  787. timerstring (&res, duration, sizeof (duration));
  788. vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s",
  789. oi->lsack_list->count, duration,
  790. (oi->thread_send_lsack ? "on" : "off"),
  791. VNL);
  792. for (lsa = ospf6_lsdb_head (oi->lsack_list); lsa;
  793. lsa = ospf6_lsdb_next (lsa))
  794. vty_out (vty, " %s%s", lsa->name, VNL);
  795. return 0;
  796. }
  797. /* show interface */
  798. DEFUN (show_ipv6_ospf6_interface,
  799. show_ipv6_ospf6_interface_ifname_cmd,
  800. "show ipv6 ospf6 interface IFNAME",
  801. SHOW_STR
  802. IP6_STR
  803. OSPF6_STR
  804. INTERFACE_STR
  805. IFNAME_STR
  806. )
  807. {
  808. struct interface *ifp;
  809. struct listnode *i;
  810. if (argc)
  811. {
  812. ifp = if_lookup_by_name (argv[0]);
  813. if (ifp == NULL)
  814. {
  815. vty_out (vty, "No such Interface: %s%s", argv[0],
  816. VNL);
  817. return CMD_WARNING;
  818. }
  819. ospf6_interface_show (vty, ifp);
  820. }
  821. else
  822. {
  823. for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
  824. ospf6_interface_show (vty, ifp);
  825. }
  826. return CMD_SUCCESS;
  827. }
  828. ALIAS (show_ipv6_ospf6_interface,
  829. show_ipv6_ospf6_interface_cmd,
  830. "show ipv6 ospf6 interface",
  831. SHOW_STR
  832. IP6_STR
  833. OSPF6_STR
  834. INTERFACE_STR
  835. )
  836. DEFUN (show_ipv6_ospf6_interface_ifname_prefix,
  837. show_ipv6_ospf6_interface_ifname_prefix_cmd,
  838. "show ipv6 ospf6 interface IFNAME prefix",
  839. SHOW_STR
  840. IP6_STR
  841. OSPF6_STR
  842. INTERFACE_STR
  843. IFNAME_STR
  844. "Display connected prefixes to advertise\n"
  845. )
  846. {
  847. struct interface *ifp;
  848. struct ospf6_interface *oi;
  849. ifp = if_lookup_by_name (argv[0]);
  850. if (ifp == NULL)
  851. {
  852. vty_out (vty, "No such Interface: %s%s", argv[0], VNL);
  853. return CMD_WARNING;
  854. }
  855. oi = ifp->info;
  856. if (oi == NULL)
  857. {
  858. vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[0], VNL);
  859. return CMD_WARNING;
  860. }
  861. argc--;
  862. argv++;
  863. ospf6_route_table_show (vty, argc, argv, oi->route_connected);
  864. return CMD_SUCCESS;
  865. }
  866. ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
  867. show_ipv6_ospf6_interface_ifname_prefix_detail_cmd,
  868. "show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)",
  869. SHOW_STR
  870. IP6_STR
  871. OSPF6_STR
  872. INTERFACE_STR
  873. IFNAME_STR
  874. "Display connected prefixes to advertise\n"
  875. OSPF6_ROUTE_ADDRESS_STR
  876. OSPF6_ROUTE_PREFIX_STR
  877. "Display details of the prefixes\n"
  878. )
  879. ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
  880. show_ipv6_ospf6_interface_ifname_prefix_match_cmd,
  881. "show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)",
  882. SHOW_STR
  883. IP6_STR
  884. OSPF6_STR
  885. INTERFACE_STR
  886. IFNAME_STR
  887. "Display connected prefixes to advertise\n"
  888. OSPF6_ROUTE_PREFIX_STR
  889. OSPF6_ROUTE_MATCH_STR
  890. "Display details of the prefixes\n"
  891. )
  892. DEFUN (show_ipv6_ospf6_interface_prefix,
  893. show_ipv6_ospf6_interface_prefix_cmd,
  894. "show ipv6 ospf6 interface prefix",
  895. SHOW_STR
  896. IP6_STR
  897. OSPF6_STR
  898. INTERFACE_STR
  899. "Display connected prefixes to advertise\n"
  900. )
  901. {
  902. struct listnode *i;
  903. struct ospf6_interface *oi;
  904. struct interface *ifp;
  905. for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
  906. {
  907. oi = (struct ospf6_interface *) ifp->info;
  908. if (oi == NULL)
  909. continue;
  910. ospf6_route_table_show (vty, argc, argv, oi->route_connected);
  911. }
  912. return CMD_SUCCESS;
  913. }
  914. ALIAS (show_ipv6_ospf6_interface_prefix,
  915. show_ipv6_ospf6_interface_prefix_detail_cmd,
  916. "show ipv6 ospf6 interface prefix (X:X::X:X|X:X::X:X/M|detail)",
  917. SHOW_STR
  918. IP6_STR
  919. OSPF6_STR
  920. INTERFACE_STR
  921. "Display connected prefixes to advertise\n"
  922. OSPF6_ROUTE_ADDRESS_STR
  923. OSPF6_ROUTE_PREFIX_STR
  924. "Display details of the prefixes\n"
  925. )
  926. ALIAS (show_ipv6_ospf6_interface_prefix,
  927. show_ipv6_ospf6_interface_prefix_match_cmd,
  928. "show ipv6 ospf6 interface prefix X:X::X:X/M (match|detail)",
  929. SHOW_STR
  930. IP6_STR
  931. OSPF6_STR
  932. INTERFACE_STR
  933. "Display connected prefixes to advertise\n"
  934. OSPF6_ROUTE_PREFIX_STR
  935. OSPF6_ROUTE_MATCH_STR
  936. "Display details of the prefixes\n"
  937. )
  938. /* interface variable set command */
  939. DEFUN (ipv6_ospf6_ifmtu,
  940. ipv6_ospf6_ifmtu_cmd,
  941. "ipv6 ospf6 ifmtu <1-65535>",
  942. IP6_STR
  943. OSPF6_STR
  944. "Interface MTU\n"
  945. "OSPFv3 Interface MTU\n"
  946. )
  947. {
  948. struct ospf6_interface *oi;
  949. struct interface *ifp;
  950. unsigned int ifmtu, iobuflen;
  951. struct listnode *node, *nnode;
  952. struct ospf6_neighbor *on;
  953. ifp = (struct interface *) vty->index;
  954. assert (ifp);
  955. oi = (struct ospf6_interface *) ifp->info;
  956. if (oi == NULL)
  957. oi = ospf6_interface_create (ifp);
  958. assert (oi);
  959. ifmtu = strtol (argv[0], NULL, 10);
  960. if (oi->ifmtu == ifmtu)
  961. return CMD_SUCCESS;
  962. if (ifp->mtu6 != 0 && ifp->mtu6 < ifmtu)
  963. {
  964. vty_out (vty, "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)%s",
  965. ifp->name, ifp->mtu6, VNL);
  966. return CMD_WARNING;
  967. }
  968. if (oi->ifmtu < ifmtu)
  969. {
  970. iobuflen = ospf6_iobuf_size (ifmtu);
  971. if (iobuflen < ifmtu)
  972. {
  973. vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
  974. ifp->name, iobuflen, VNL);
  975. oi->ifmtu = iobuflen;
  976. }
  977. else
  978. oi->ifmtu = ifmtu;
  979. }
  980. else
  981. oi->ifmtu = ifmtu;
  982. /* re-establish adjacencies */
  983. for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
  984. {
  985. THREAD_OFF (on->inactivity_timer);
  986. thread_add_event (master, inactivity_timer, on, 0);
  987. }
  988. return CMD_SUCCESS;
  989. }
  990. DEFUN (no_ipv6_ospf6_ifmtu,
  991. no_ipv6_ospf6_ifmtu_cmd,
  992. "no ipv6 ospf6 ifmtu",
  993. NO_STR
  994. IP6_STR
  995. OSPF6_STR
  996. "Interface MTU\n"
  997. )
  998. {
  999. struct ospf6_interface *oi;
  1000. struct interface *ifp;
  1001. unsigned int iobuflen;
  1002. struct listnode *node, *nnode;
  1003. struct ospf6_neighbor *on;
  1004. ifp = (struct interface *) vty->index;
  1005. assert (ifp);
  1006. oi = (struct ospf6_interface *) ifp->info;
  1007. if (oi == NULL)
  1008. oi = ospf6_interface_create (ifp);
  1009. assert (oi);
  1010. if (oi->ifmtu < ifp->mtu)
  1011. {
  1012. iobuflen = ospf6_iobuf_size (ifp->mtu);
  1013. if (iobuflen < ifp->mtu)
  1014. {
  1015. vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s",
  1016. ifp->name, iobuflen, VNL);
  1017. oi->ifmtu = iobuflen;
  1018. }
  1019. else
  1020. oi->ifmtu = ifp->mtu;
  1021. }
  1022. else
  1023. oi->ifmtu = ifp->mtu;
  1024. /* re-establish adjacencies */
  1025. for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
  1026. {
  1027. THREAD_OFF (on->inactivity_timer);
  1028. thread_add_event (master, inactivity_timer, on, 0);
  1029. }
  1030. return CMD_SUCCESS;
  1031. }
  1032. DEFUN (ipv6_ospf6_cost,
  1033. ipv6_ospf6_cost_cmd,
  1034. "ipv6 ospf6 cost <1-65535>",
  1035. IP6_STR
  1036. OSPF6_STR
  1037. "Interface cost\n"
  1038. "Outgoing metric of this interface\n"
  1039. )
  1040. {
  1041. struct ospf6_interface *oi;
  1042. struct interface *ifp;
  1043. unsigned long int lcost;
  1044. ifp = (struct interface *) vty->index;
  1045. assert (ifp);
  1046. oi = (struct ospf6_interface *) ifp->info;
  1047. if (oi == NULL)
  1048. oi = ospf6_interface_create (ifp);
  1049. assert (oi);
  1050. lcost = strtol (argv[0], NULL, 10);
  1051. if (lcost > UINT32_MAX)
  1052. {
  1053. vty_out (vty, "Cost %ld is out of range%s", lcost, VNL);
  1054. return CMD_WARNING;
  1055. }
  1056. if (oi->cost == lcost)
  1057. return CMD_SUCCESS;
  1058. oi->cost = lcost;
  1059. SET_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST);
  1060. ospf6_interface_recalculate_cost(oi);
  1061. return CMD_SUCCESS;
  1062. }
  1063. DEFUN (no_ipv6_ospf6_cost,
  1064. no_ipv6_ospf6_cost_cmd,
  1065. "no ipv6 ospf6 cost",
  1066. NO_STR
  1067. IP6_STR
  1068. OSPF6_STR
  1069. "Calculate interface cost from bandwidth\n"
  1070. )
  1071. {
  1072. struct ospf6_interface *oi;
  1073. struct interface *ifp;
  1074. ifp = (struct interface *) vty->index;
  1075. assert (ifp);
  1076. oi = (struct ospf6_interface *) ifp->info;
  1077. if (oi == NULL)
  1078. oi = ospf6_interface_create (ifp);
  1079. assert (oi);
  1080. UNSET_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST);
  1081. ospf6_interface_recalculate_cost(oi);
  1082. return CMD_SUCCESS;
  1083. }
  1084. DEFUN (auto_cost_reference_bandwidth,
  1085. auto_cost_reference_bandwidth_cmd,
  1086. "auto-cost reference-bandwidth <1-4294967>",
  1087. "Calculate OSPF interface cost according to bandwidth\n"
  1088. "Use reference bandwidth method to assign OSPF cost\n"
  1089. "The reference bandwidth in terms of Mbits per second\n")
  1090. {
  1091. struct ospf6 *o = vty->index;
  1092. struct ospf6_area *oa;
  1093. struct ospf6_interface *oi;
  1094. struct listnode *i, *j;
  1095. u_int32_t refbw;
  1096. refbw = strtol (argv[0], NULL, 10);
  1097. if (refbw < 1 || refbw > 4294967)
  1098. {
  1099. vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
  1100. return CMD_WARNING;
  1101. }
  1102. /* If reference bandwidth is changed. */
  1103. if ((refbw * 1000) == o->ref_bandwidth)
  1104. return CMD_SUCCESS;
  1105. o->ref_bandwidth = refbw * 1000;
  1106. for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
  1107. for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
  1108. ospf6_interface_recalculate_cost (oi);
  1109. return CMD_SUCCESS;
  1110. }
  1111. DEFUN (no_auto_cost_reference_bandwidth,
  1112. no_auto_cost_reference_bandwidth_cmd,
  1113. "no auto-cost reference-bandwidth",
  1114. NO_STR
  1115. "Calculate OSPF interface cost according to bandwidth\n"
  1116. "Use reference bandwidth method to assign OSPF cost\n")
  1117. {
  1118. struct ospf6 *o = vty->index;
  1119. struct ospf6_area *oa;
  1120. struct ospf6_interface *oi;
  1121. struct listnode *i, *j;
  1122. if (o->ref_bandwidth == OSPF6_REFERENCE_BANDWIDTH)
  1123. return CMD_SUCCESS;
  1124. o->ref_bandwidth = OSPF6_REFERENCE_BANDWIDTH;
  1125. for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
  1126. for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
  1127. ospf6_interface_recalculate_cost (oi);
  1128. return CMD_SUCCESS;
  1129. }
  1130. DEFUN (ipv6_ospf6_hellointerval,
  1131. ipv6_ospf6_hellointerval_cmd,
  1132. "ipv6 ospf6 hello-interval <1-65535>",
  1133. IP6_STR
  1134. OSPF6_STR
  1135. "Interval time of Hello packets\n"
  1136. SECONDS_STR
  1137. )
  1138. {
  1139. struct ospf6_interface *oi;
  1140. struct interface *ifp;
  1141. ifp = (struct interface *) vty->index;
  1142. assert (ifp);
  1143. oi = (struct ospf6_interface *) ifp->info;
  1144. if (oi == NULL)
  1145. oi = ospf6_interface_create (ifp);
  1146. assert (oi);
  1147. oi->hello_interval = strtol (argv[0], NULL, 10);
  1148. return CMD_SUCCESS;
  1149. }
  1150. /* interface variable set command */
  1151. DEFUN (ipv6_ospf6_deadinterval,
  1152. ipv6_ospf6_deadinterval_cmd,
  1153. "ipv6 ospf6 dead-interval <1-65535>",
  1154. IP6_STR
  1155. OSPF6_STR
  1156. "Interval time after which a neighbor is declared down\n"
  1157. SECONDS_STR
  1158. )
  1159. {
  1160. struct ospf6_interface *oi;
  1161. struct interface *ifp;
  1162. ifp = (struct interface *) vty->index;
  1163. assert (ifp);
  1164. oi = (struct ospf6_interface *) ifp->info;
  1165. if (oi == NULL)
  1166. oi = ospf6_interface_create (ifp);
  1167. assert (oi);
  1168. oi->dead_interval = strtol (argv[0], NULL, 10);
  1169. return CMD_SUCCESS;
  1170. }
  1171. /* interface variable set command */
  1172. DEFUN (ipv6_ospf6_transmitdelay,
  1173. ipv6_ospf6_transmitdelay_cmd,
  1174. "ipv6 ospf6 transmit-delay <1-3600>",
  1175. IP6_STR
  1176. OSPF6_STR
  1177. "Transmit delay of this interface\n"
  1178. SECONDS_STR
  1179. )
  1180. {
  1181. struct ospf6_interface *oi;
  1182. struct interface *ifp;
  1183. ifp = (struct interface *) vty->index;
  1184. assert (ifp);
  1185. oi = (struct ospf6_interface *) ifp->info;
  1186. if (oi == NULL)
  1187. oi = ospf6_interface_create (ifp);
  1188. assert (oi);
  1189. oi->transdelay = strtol (argv[0], NULL, 10);
  1190. return CMD_SUCCESS;
  1191. }
  1192. /* interface variable set command */
  1193. DEFUN (ipv6_ospf6_retransmitinterval,
  1194. ipv6_ospf6_retransmitinterval_cmd,
  1195. "ipv6 ospf6 retransmit-interval <1-65535>",
  1196. IP6_STR
  1197. OSPF6_STR
  1198. "Time between retransmitting lost link state advertisements\n"
  1199. SECONDS_STR
  1200. )
  1201. {
  1202. struct ospf6_interface *oi;
  1203. struct interface *ifp;
  1204. ifp = (struct interface *) vty->index;
  1205. assert (ifp);
  1206. oi = (struct ospf6_interface *) ifp->info;
  1207. if (oi == NULL)
  1208. oi = ospf6_interface_create (ifp);
  1209. assert (oi);
  1210. oi->rxmt_interval = strtol (argv[0], NULL, 10);
  1211. return CMD_SUCCESS;
  1212. }
  1213. /* interface variable set command */
  1214. DEFUN (ipv6_ospf6_priority,
  1215. ipv6_ospf6_priority_cmd,
  1216. "ipv6 ospf6 priority <0-255>",
  1217. IP6_STR
  1218. OSPF6_STR
  1219. "Router priority\n"
  1220. "Priority value\n"
  1221. )
  1222. {
  1223. struct ospf6_interface *oi;
  1224. struct interface *ifp;
  1225. ifp = (struct interface *) vty->index;
  1226. assert (ifp);
  1227. oi = (struct ospf6_interface *) ifp->info;
  1228. if (oi == NULL)
  1229. oi = ospf6_interface_create (ifp);
  1230. assert (oi);
  1231. oi->priority = strtol (argv[0], NULL, 10);
  1232. if (oi->area &&
  1233. (oi->state == OSPF6_INTERFACE_DROTHER ||
  1234. oi->state == OSPF6_INTERFACE_BDR ||
  1235. oi->state == OSPF6_INTERFACE_DR))
  1236. ospf6_interface_state_change (dr_election (oi), oi);
  1237. return CMD_SUCCESS;
  1238. }
  1239. DEFUN (ipv6_ospf6_instance,
  1240. ipv6_ospf6_instance_cmd,
  1241. "ipv6 ospf6 instance-id <0-255>",
  1242. IP6_STR
  1243. OSPF6_STR
  1244. "Instance ID for this interface\n"
  1245. "Instance ID value\n"
  1246. )
  1247. {
  1248. struct ospf6_interface *oi;
  1249. struct interface *ifp;
  1250. ifp = (struct interface *)vty->index;
  1251. assert (ifp);
  1252. oi = (struct ospf6_interface *)ifp->info;
  1253. if (oi == NULL)
  1254. oi = ospf6_interface_create (ifp);
  1255. assert (oi);
  1256. oi->instance_id = strtol (argv[0], NULL, 10);
  1257. return CMD_SUCCESS;
  1258. }
  1259. DEFUN (ipv6_ospf6_passive,
  1260. ipv6_ospf6_passive_cmd,
  1261. "ipv6 ospf6 passive",
  1262. IP6_STR
  1263. OSPF6_STR
  1264. "passive interface, No adjacency will be formed on this interface\n"
  1265. )
  1266. {
  1267. struct ospf6_interface *oi;
  1268. struct interface *ifp;
  1269. struct listnode *node, *nnode;
  1270. struct ospf6_neighbor *on;
  1271. ifp = (struct interface *) vty->index;
  1272. assert (ifp);
  1273. oi = (struct ospf6_interface *) ifp->info;
  1274. if (oi == NULL)
  1275. oi = ospf6_interface_create (ifp);
  1276. assert (oi);
  1277. SET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
  1278. THREAD_OFF (oi->thread_send_hello);
  1279. for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
  1280. {
  1281. THREAD_OFF (on->inactivity_timer);
  1282. thread_add_event (master, inactivity_timer, on, 0);
  1283. }
  1284. return CMD_SUCCESS;
  1285. }
  1286. DEFUN (no_ipv6_ospf6_passive,
  1287. no_ipv6_ospf6_passive_cmd,
  1288. "no ipv6 ospf6 passive",
  1289. NO_STR
  1290. IP6_STR
  1291. OSPF6_STR
  1292. "passive interface: No Adjacency will be formed on this I/F\n"
  1293. )
  1294. {
  1295. struct ospf6_interface *oi;
  1296. struct interface *ifp;
  1297. ifp = (struct interface *) vty->index;
  1298. assert (ifp);
  1299. oi = (struct ospf6_interface *) ifp->info;
  1300. if (oi == NULL)
  1301. oi = ospf6_interface_create (ifp);
  1302. assert (oi);
  1303. UNSET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
  1304. THREAD_OFF (oi->thread_send_hello);
  1305. oi->thread_send_hello =
  1306. thread_add_event (master, ospf6_hello_send, oi, 0);
  1307. return CMD_SUCCESS;
  1308. }
  1309. DEFUN (ipv6_ospf6_mtu_ignore,
  1310. ipv6_ospf6_mtu_ignore_cmd,
  1311. "ipv6 ospf6 mtu-ignore",
  1312. IP6_STR
  1313. OSPF6_STR
  1314. "Ignore MTU mismatch on this interface\n"
  1315. )
  1316. {
  1317. struct ospf6_interface *oi;
  1318. struct interface *ifp;
  1319. ifp = (struct interface *) vty->index;
  1320. assert (ifp);
  1321. oi = (struct ospf6_interface *) ifp->info;
  1322. if (oi == NULL)
  1323. oi = ospf6_interface_create (ifp);
  1324. assert (oi);
  1325. oi->mtu_ignore = 1;
  1326. return CMD_SUCCESS;
  1327. }
  1328. DEFUN (no_ipv6_ospf6_mtu_ignore,
  1329. no_ipv6_ospf6_mtu_ignore_cmd,
  1330. "no ipv6 ospf6 mtu-ignore",
  1331. NO_STR
  1332. IP6_STR
  1333. OSPF6_STR
  1334. "Ignore MTU mismatch on this interface\n"
  1335. )
  1336. {
  1337. struct ospf6_interface *oi;
  1338. struct interface *ifp;
  1339. ifp = (struct interface *) vty->index;
  1340. assert (ifp);
  1341. oi = (struct ospf6_interface *) ifp->info;
  1342. if (oi == NULL)
  1343. oi = ospf6_interface_create (ifp);
  1344. assert (oi);
  1345. oi->mtu_ignore = 0;
  1346. return CMD_SUCCESS;
  1347. }
  1348. DEFUN (ipv6_ospf6_advertise_prefix_list,
  1349. ipv6_ospf6_advertise_prefix_list_cmd,
  1350. "ipv6 ospf6 advertise prefix-list WORD",
  1351. IP6_STR
  1352. OSPF6_STR
  1353. "Advertising options\n"
  1354. "Filter prefix using prefix-list\n"
  1355. "Prefix list name\n"
  1356. )
  1357. {
  1358. struct ospf6_interface *oi;
  1359. struct interface *ifp;
  1360. ifp = (struct interface *) vty->index;
  1361. assert (ifp);
  1362. oi = (struct ospf6_interface *) ifp->info;
  1363. if (oi == NULL)
  1364. oi = ospf6_interface_create (ifp);
  1365. assert (oi);
  1366. if (oi->plist_name)
  1367. XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
  1368. oi->plist_name = XSTRDUP (MTYPE_PREFIX_LIST_STR, argv[0]);
  1369. ospf6_interface_connected_route_update (oi->interface);
  1370. if (oi->area)
  1371. {
  1372. OSPF6_LINK_LSA_SCHEDULE (oi);
  1373. if (oi->state == OSPF6_INTERFACE_DR)
  1374. {
  1375. OSPF6_NETWORK_LSA_SCHEDULE (oi);
  1376. OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
  1377. }
  1378. OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
  1379. }
  1380. return CMD_SUCCESS;
  1381. }
  1382. DEFUN (no_ipv6_ospf6_advertise_prefix_list,
  1383. no_ipv6_ospf6_advertise_prefix_list_cmd,
  1384. "no ipv6 ospf6 advertise prefix-list",
  1385. NO_STR
  1386. IP6_STR
  1387. OSPF6_STR
  1388. "Advertising options\n"
  1389. "Filter prefix using prefix-list\n"
  1390. )
  1391. {
  1392. struct ospf6_interface *oi;
  1393. struct interface *ifp;
  1394. ifp = (struct interface *) vty->index;
  1395. assert (ifp);
  1396. oi = (struct ospf6_interface *) ifp->info;
  1397. if (oi == NULL)
  1398. oi = ospf6_interface_create (ifp);
  1399. assert (oi);
  1400. if (oi->plist_name)
  1401. {
  1402. XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
  1403. oi->plist_name = NULL;
  1404. }
  1405. ospf6_interface_connected_route_update (oi->interface);
  1406. if (oi->area)
  1407. {
  1408. OSPF6_LINK_LSA_SCHEDULE (oi);
  1409. if (oi->state == OSPF6_INTERFACE_DR)
  1410. {
  1411. OSPF6_NETWORK_LSA_SCHEDULE (oi);
  1412. OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi);
  1413. }
  1414. OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
  1415. }
  1416. return CMD_SUCCESS;
  1417. }
  1418. DEFUN (ipv6_ospf6_network,
  1419. ipv6_ospf6_network_cmd,
  1420. "ipv6 ospf6 network (broadcast|point-to-point)",
  1421. IP6_STR
  1422. OSPF6_STR
  1423. "Network Type\n"
  1424. "Specify OSPFv6 broadcast network\n"
  1425. "Specify OSPF6 point-to-point network\n"
  1426. )
  1427. {
  1428. struct ospf6_interface *oi;
  1429. struct interface *ifp;
  1430. ifp = (struct interface *) vty->index;
  1431. assert (ifp);
  1432. oi = (struct ospf6_interface *) ifp->info;
  1433. if (oi == NULL) {
  1434. oi = ospf6_interface_create (ifp);
  1435. }
  1436. assert (oi);
  1437. if (strncmp (argv[0], "b", 1) == 0)
  1438. {
  1439. if (oi->type == OSPF_IFTYPE_BROADCAST)
  1440. return CMD_SUCCESS;
  1441. oi->type = OSPF_IFTYPE_BROADCAST;
  1442. }
  1443. else if (strncmp (argv[0], "point-to-p", 10) == 0)
  1444. {
  1445. if (oi->type == OSPF_IFTYPE_POINTOPOINT) {
  1446. return CMD_SUCCESS;
  1447. }
  1448. oi->type = OSPF_IFTYPE_POINTOPOINT;
  1449. }
  1450. /* Reset the interface */
  1451. thread_add_event (master, interface_down, oi, 0);
  1452. thread_add_event (master, interface_up, oi, 0);
  1453. return CMD_SUCCESS;
  1454. }
  1455. DEFUN (no_ipv6_ospf6_network,
  1456. no_ipv6_ospf6_network_cmd,
  1457. "no ipv6 ospf6 network",
  1458. NO_STR
  1459. IP6_STR
  1460. OSPF6_STR
  1461. "Network Type\n"
  1462. "Default to whatever interface type system specifies"
  1463. )
  1464. {
  1465. struct ospf6_interface *oi;
  1466. struct interface *ifp;
  1467. int type;
  1468. ifp = (struct interface *) vty->index;
  1469. assert (ifp);
  1470. oi = (struct ospf6_interface *) ifp->info;
  1471. if (oi == NULL) {
  1472. return CMD_SUCCESS;
  1473. }
  1474. type = ospf6_default_iftype (ifp);
  1475. if (oi->type == type)
  1476. {
  1477. return CMD_SUCCESS;
  1478. }
  1479. oi->type = type;
  1480. /* Reset the interface */
  1481. thread_add_event (master, interface_down, oi, 0);
  1482. thread_add_event (master, interface_up, oi, 0);
  1483. return CMD_SUCCESS;
  1484. }
  1485. static int
  1486. config_write_ospf6_interface (struct vty *vty)
  1487. {
  1488. struct listnode *i;
  1489. struct ospf6_interface *oi;
  1490. struct interface *ifp;
  1491. for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
  1492. {
  1493. oi = (struct ospf6_interface *) ifp->info;
  1494. if (oi == NULL)
  1495. continue;
  1496. vty_out (vty, "interface %s%s",
  1497. oi->interface->name, VNL);
  1498. if (ifp->desc)
  1499. vty_out (vty, " description %s%s", ifp->desc, VNL);
  1500. if (ifp->mtu6 != oi->ifmtu)
  1501. vty_out (vty, " ipv6 ospf6 ifmtu %d%s", oi->ifmtu, VNL);
  1502. if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST))
  1503. vty_out (vty, " ipv6 ospf6 cost %d%s",
  1504. oi->cost, VNL);
  1505. if (oi->hello_interval != OSPF6_INTERFACE_HELLO_INTERVAL)
  1506. vty_out (vty, " ipv6 ospf6 hello-interval %d%s",
  1507. oi->hello_interval, VNL);
  1508. if (oi->dead_interval != OSPF6_INTERFACE_DEAD_INTERVAL)
  1509. vty_out (vty, " ipv6 ospf6 dead-interval %d%s",
  1510. oi->dead_interval, VNL);
  1511. if (oi->rxmt_interval != OSPF6_INTERFACE_RXMT_INTERVAL)
  1512. vty_out (vty, " ipv6 ospf6 retransmit-interval %d%s",
  1513. oi->rxmt_interval, VNL);
  1514. if (oi->priority != OSPF6_INTERFACE_PRIORITY)
  1515. vty_out (vty, " ipv6 ospf6 priority %d%s",
  1516. oi->priority, VNL);
  1517. if (oi->transdelay != OSPF6_INTERFACE_TRANSDELAY)
  1518. vty_out (vty, " ipv6 ospf6 transmit-delay %d%s",
  1519. oi->transdelay, VNL);
  1520. if (oi->instance_id != OSPF6_INTERFACE_INSTANCE_ID)
  1521. vty_out (vty, " ipv6 ospf6 instance-id %d%s",
  1522. oi->instance_id, VNL);
  1523. if (oi->plist_name)
  1524. vty_out (vty, " ipv6 ospf6 advertise prefix-list %s%s",
  1525. oi->plist_name, VNL);
  1526. if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE))
  1527. vty_out (vty, " ipv6 ospf6 passive%s", VNL);
  1528. if (oi->mtu_ignore)
  1529. vty_out (vty, " ipv6 ospf6 mtu-ignore%s", VNL);
  1530. if (oi->type == OSPF_IFTYPE_POINTOPOINT)
  1531. vty_out (vty, " ipv6 ospf6 network point-to-point%s", VNL);
  1532. else if (oi->type == OSPF_IFTYPE_BROADCAST)
  1533. vty_out (vty, " ipv6 ospf6 network broadcast%s", VNL);
  1534. vty_out (vty, "!%s", VNL);
  1535. }
  1536. return 0;
  1537. }
  1538. static struct cmd_node interface_node =
  1539. {
  1540. INTERFACE_NODE,
  1541. "%s(config-if)# ",
  1542. 1 /* VTYSH */
  1543. };
  1544. void
  1545. ospf6_interface_init (void)
  1546. {
  1547. /* Install interface node. */
  1548. install_node (&interface_node, config_write_ospf6_interface);
  1549. install_element (VIEW_NODE, &show_ipv6_ospf6_interface_cmd);
  1550. install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
  1551. install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
  1552. install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
  1553. install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
  1554. install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
  1555. install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
  1556. install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
  1557. install_element (CONFIG_NODE, &interface_cmd);
  1558. install_default (INTERFACE_NODE);
  1559. install_element (INTERFACE_NODE, &interface_desc_cmd);
  1560. install_element (INTERFACE_NODE, &no_interface_desc_cmd);
  1561. install_element (INTERFACE_NODE, &ipv6_ospf6_cost_cmd);
  1562. install_element (INTERFACE_NODE, &no_ipv6_ospf6_cost_cmd);
  1563. install_element (INTERFACE_NODE, &ipv6_ospf6_ifmtu_cmd);
  1564. install_element (INTERFACE_NODE, &no_ipv6_ospf6_ifmtu_cmd);
  1565. install_element (INTERFACE_NODE, &ipv6_ospf6_deadinterval_cmd);
  1566. install_element (INTERFACE_NODE, &ipv6_ospf6_hellointerval_cmd);
  1567. install_element (INTERFACE_NODE, &ipv6_ospf6_priority_cmd);
  1568. install_element (INTERFACE_NODE, &ipv6_ospf6_retransmitinterval_cmd);
  1569. install_element (INTERFACE_NODE, &ipv6_ospf6_transmitdelay_cmd);
  1570. install_element (INTERFACE_NODE, &ipv6_ospf6_instance_cmd);
  1571. install_element (INTERFACE_NODE, &ipv6_ospf6_passive_cmd);
  1572. install_element (INTERFACE_NODE, &no_ipv6_ospf6_passive_cmd);
  1573. install_element (INTERFACE_NODE, &ipv6_ospf6_mtu_ignore_cmd);
  1574. install_element (INTERFACE_NODE, &no_ipv6_ospf6_mtu_ignore_cmd);
  1575. install_element (INTERFACE_NODE, &ipv6_ospf6_advertise_prefix_list_cmd);
  1576. install_element (INTERFACE_NODE, &no_ipv6_ospf6_advertise_prefix_list_cmd);
  1577. install_element (INTERFACE_NODE, &ipv6_ospf6_network_cmd);
  1578. install_element (INTERFACE_NODE, &no_ipv6_ospf6_network_cmd);
  1579. /* reference bandwidth commands */
  1580. install_element (OSPF6_NODE, &auto_cost_reference_bandwidth_cmd);
  1581. install_element (OSPF6_NODE, &no_auto_cost_reference_bandwidth_cmd);
  1582. }
  1583. DEFUN (debug_ospf6_interface,
  1584. debug_ospf6_interface_cmd,
  1585. "debug ospf6 interface",
  1586. DEBUG_STR
  1587. OSPF6_STR
  1588. "Debug OSPFv3 Interface\n"
  1589. )
  1590. {
  1591. OSPF6_DEBUG_INTERFACE_ON ();
  1592. return CMD_SUCCESS;
  1593. }
  1594. DEFUN (no_debug_ospf6_interface,
  1595. no_debug_ospf6_interface_cmd,
  1596. "no debug ospf6 interface",
  1597. NO_STR
  1598. DEBUG_STR
  1599. OSPF6_STR
  1600. "Debug OSPFv3 Interface\n"
  1601. )
  1602. {
  1603. OSPF6_DEBUG_INTERFACE_OFF ();
  1604. return CMD_SUCCESS;
  1605. }
  1606. int
  1607. config_write_ospf6_debug_interface (struct vty *vty)
  1608. {
  1609. if (IS_OSPF6_DEBUG_INTERFACE)
  1610. vty_out (vty, "debug ospf6 interface%s", VNL);
  1611. return 0;
  1612. }
  1613. void
  1614. install_element_ospf6_debug_interface (void)
  1615. {
  1616. install_element (ENABLE_NODE, &debug_ospf6_interface_cmd);
  1617. install_element (ENABLE_NODE, &no_debug_ospf6_interface_cmd);
  1618. install_element (CONFIG_NODE, &debug_ospf6_interface_cmd);
  1619. install_element (CONFIG_NODE, &no_debug_ospf6_interface_cmd);
  1620. }