isis_circuit.c 79 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883
  1. /*
  2. * IS-IS Rout(e)ing protocol - isis_circuit.h
  3. *
  4. * Copyright (C) 2001,2002 Sampo Saaristo
  5. * Tampere University of Technology
  6. * Institute of Communications Engineering
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public Licenseas published by the Free
  10. * Software Foundation; either version 2 of the License, or (at your option)
  11. * any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,but WITHOUT
  14. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  15. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  16. * more details.
  17. * You should have received a copy of the GNU General Public License along
  18. * with this program; if not, write to the Free Software Foundation, Inc.,
  19. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20. */
  21. #include <zebra.h>
  22. #ifdef GNU_LINUX
  23. #include <net/ethernet.h>
  24. #else
  25. #include <netinet/if_ether.h>
  26. #endif
  27. #ifndef ETHER_ADDR_LEN
  28. #define ETHER_ADDR_LEN ETHERADDRL
  29. #endif
  30. #include "log.h"
  31. #include "memory.h"
  32. #include "if.h"
  33. #include "linklist.h"
  34. #include "command.h"
  35. #include "thread.h"
  36. #include "hash.h"
  37. #include "prefix.h"
  38. #include "stream.h"
  39. #include "isisd/dict.h"
  40. #include "isisd/include-netbsd/iso.h"
  41. #include "isisd/isis_constants.h"
  42. #include "isisd/isis_common.h"
  43. #include "isisd/isis_flags.h"
  44. #include "isisd/isis_circuit.h"
  45. #include "isisd/isis_tlv.h"
  46. #include "isisd/isis_lsp.h"
  47. #include "isisd/isis_pdu.h"
  48. #include "isisd/isis_network.h"
  49. #include "isisd/isis_misc.h"
  50. #include "isisd/isis_constants.h"
  51. #include "isisd/isis_adjacency.h"
  52. #include "isisd/isis_dr.h"
  53. #include "isisd/isisd.h"
  54. #include "isisd/isis_csm.h"
  55. #include "isisd/isis_events.h"
  56. /*
  57. * Prototypes.
  58. */
  59. int isis_interface_config_write(struct vty *);
  60. int isis_if_new_hook(struct interface *);
  61. int isis_if_delete_hook(struct interface *);
  62. struct isis_circuit *
  63. isis_circuit_new ()
  64. {
  65. struct isis_circuit *circuit;
  66. int i;
  67. circuit = XCALLOC (MTYPE_ISIS_CIRCUIT, sizeof (struct isis_circuit));
  68. if (circuit == NULL)
  69. {
  70. zlog_err ("Can't malloc isis circuit");
  71. return NULL;
  72. }
  73. /*
  74. * Default values
  75. */
  76. circuit->is_type = IS_LEVEL_1_AND_2;
  77. circuit->flags = 0;
  78. circuit->pad_hellos = 1;
  79. for (i = 0; i < 2; i++)
  80. {
  81. circuit->hello_interval[i] = DEFAULT_HELLO_INTERVAL;
  82. circuit->hello_multiplier[i] = DEFAULT_HELLO_MULTIPLIER;
  83. circuit->csnp_interval[i] = DEFAULT_CSNP_INTERVAL;
  84. circuit->psnp_interval[i] = DEFAULT_PSNP_INTERVAL;
  85. circuit->priority[i] = DEFAULT_PRIORITY;
  86. circuit->metrics[i].metric_default = DEFAULT_CIRCUIT_METRIC;
  87. circuit->metrics[i].metric_expense = METRICS_UNSUPPORTED;
  88. circuit->metrics[i].metric_error = METRICS_UNSUPPORTED;
  89. circuit->metrics[i].metric_delay = METRICS_UNSUPPORTED;
  90. circuit->te_metric[i] = DEFAULT_CIRCUIT_METRIC;
  91. }
  92. return circuit;
  93. }
  94. void
  95. isis_circuit_del (struct isis_circuit *circuit)
  96. {
  97. if (!circuit)
  98. return;
  99. isis_circuit_if_unbind (circuit, circuit->interface);
  100. /* and lastly the circuit itself */
  101. XFREE (MTYPE_ISIS_CIRCUIT, circuit);
  102. return;
  103. }
  104. void
  105. isis_circuit_configure (struct isis_circuit *circuit, struct isis_area *area)
  106. {
  107. assert (area);
  108. circuit->area = area;
  109. /*
  110. * Whenever the is-type of an area is changed, the is-type of each circuit
  111. * in that area is updated to a non-empty subset of the area is-type.
  112. * Inversely, when configuring a new circuit, this property should be
  113. * ensured as well.
  114. */
  115. if (area->is_type != IS_LEVEL_1_AND_2)
  116. circuit->is_type = area->is_type;
  117. /*
  118. * Add the circuit into area
  119. */
  120. listnode_add (area->circuit_list, circuit);
  121. circuit->idx = flags_get_index (&area->flags);
  122. return;
  123. }
  124. void
  125. isis_circuit_deconfigure (struct isis_circuit *circuit, struct isis_area *area)
  126. {
  127. /* Free the index of SRM and SSN flags */
  128. flags_free_index (&area->flags, circuit->idx);
  129. circuit->idx = 0;
  130. /* Remove circuit from area */
  131. assert (circuit->area == area);
  132. listnode_delete (area->circuit_list, circuit);
  133. circuit->area = NULL;
  134. return;
  135. }
  136. struct isis_circuit *
  137. circuit_lookup_by_ifp (struct interface *ifp, struct list *list)
  138. {
  139. struct isis_circuit *circuit = NULL;
  140. struct listnode *node;
  141. if (!list)
  142. return NULL;
  143. for (ALL_LIST_ELEMENTS_RO (list, node, circuit))
  144. if (circuit->interface == ifp)
  145. {
  146. assert (ifp->info == circuit);
  147. return circuit;
  148. }
  149. return NULL;
  150. }
  151. struct isis_circuit *
  152. circuit_scan_by_ifp (struct interface *ifp)
  153. {
  154. struct isis_area *area;
  155. struct listnode *node;
  156. struct isis_circuit *circuit;
  157. if (ifp->info)
  158. return (struct isis_circuit *)ifp->info;
  159. if (isis->area_list)
  160. {
  161. for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
  162. {
  163. circuit = circuit_lookup_by_ifp (ifp, area->circuit_list);
  164. if (circuit)
  165. return circuit;
  166. }
  167. }
  168. return circuit_lookup_by_ifp (ifp, isis->init_circ_list);
  169. }
  170. static struct isis_circuit *
  171. isis_circuit_lookup (struct vty *vty)
  172. {
  173. struct interface *ifp;
  174. struct isis_circuit *circuit;
  175. ifp = (struct interface *) vty->index;
  176. if (!ifp)
  177. {
  178. vty_out (vty, "Invalid interface %s", VTY_NEWLINE);
  179. return NULL;
  180. }
  181. circuit = circuit_scan_by_ifp (ifp);
  182. if (!circuit)
  183. {
  184. vty_out (vty, "ISIS is not enabled on circuit %s%s",
  185. ifp->name, VTY_NEWLINE);
  186. return NULL;
  187. }
  188. return circuit;
  189. }
  190. void
  191. isis_circuit_add_addr (struct isis_circuit *circuit,
  192. struct connected *connected)
  193. {
  194. struct listnode *node;
  195. struct prefix_ipv4 *ipv4;
  196. u_char buf[BUFSIZ];
  197. #ifdef HAVE_IPV6
  198. struct prefix_ipv6 *ipv6;
  199. #endif /* HAVE_IPV6 */
  200. memset (&buf, 0, BUFSIZ);
  201. if (connected->address->family == AF_INET)
  202. {
  203. u_int32_t addr = connected->address->u.prefix4.s_addr;
  204. addr = ntohl (addr);
  205. if (IPV4_NET0(addr) ||
  206. IPV4_NET127(addr) ||
  207. IN_CLASSD(addr) ||
  208. IPV4_LINKLOCAL(addr))
  209. return;
  210. for (ALL_LIST_ELEMENTS_RO (circuit->ip_addrs, node, ipv4))
  211. if (prefix_same ((struct prefix *) ipv4, connected->address))
  212. return;
  213. ipv4 = prefix_ipv4_new ();
  214. ipv4->prefixlen = connected->address->prefixlen;
  215. ipv4->prefix = connected->address->u.prefix4;
  216. listnode_add (circuit->ip_addrs, ipv4);
  217. if (circuit->area)
  218. lsp_regenerate_schedule (circuit->area, circuit->is_type, 0);
  219. #ifdef EXTREME_DEBUG
  220. prefix2str (connected->address, buf, BUFSIZ);
  221. zlog_debug ("Added IP address %s to circuit %d", buf,
  222. circuit->circuit_id);
  223. #endif /* EXTREME_DEBUG */
  224. }
  225. #ifdef HAVE_IPV6
  226. if (connected->address->family == AF_INET6)
  227. {
  228. if (IN6_IS_ADDR_LOOPBACK(&connected->address->u.prefix6))
  229. return;
  230. for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_link, node, ipv6))
  231. if (prefix_same ((struct prefix *) ipv6, connected->address))
  232. return;
  233. for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_non_link, node, ipv6))
  234. if (prefix_same ((struct prefix *) ipv6, connected->address))
  235. return;
  236. ipv6 = prefix_ipv6_new ();
  237. ipv6->prefixlen = connected->address->prefixlen;
  238. ipv6->prefix = connected->address->u.prefix6;
  239. if (IN6_IS_ADDR_LINKLOCAL (&ipv6->prefix))
  240. listnode_add (circuit->ipv6_link, ipv6);
  241. else
  242. listnode_add (circuit->ipv6_non_link, ipv6);
  243. if (circuit->area)
  244. lsp_regenerate_schedule (circuit->area, circuit->is_type, 0);
  245. #ifdef EXTREME_DEBUG
  246. prefix2str (connected->address, buf, BUFSIZ);
  247. zlog_debug ("Added IPv6 address %s to circuit %d", buf,
  248. circuit->circuit_id);
  249. #endif /* EXTREME_DEBUG */
  250. }
  251. #endif /* HAVE_IPV6 */
  252. return;
  253. }
  254. void
  255. isis_circuit_del_addr (struct isis_circuit *circuit,
  256. struct connected *connected)
  257. {
  258. struct prefix_ipv4 *ipv4, *ip = NULL;
  259. struct listnode *node;
  260. u_char buf[BUFSIZ];
  261. #ifdef HAVE_IPV6
  262. struct prefix_ipv6 *ipv6, *ip6 = NULL;
  263. int found = 0;
  264. #endif /* HAVE_IPV6 */
  265. memset (&buf, 0, BUFSIZ);
  266. if (connected->address->family == AF_INET)
  267. {
  268. ipv4 = prefix_ipv4_new ();
  269. ipv4->prefixlen = connected->address->prefixlen;
  270. ipv4->prefix = connected->address->u.prefix4;
  271. for (ALL_LIST_ELEMENTS_RO (circuit->ip_addrs, node, ip))
  272. if (prefix_same ((struct prefix *) ip, (struct prefix *) ipv4))
  273. break;
  274. if (ip)
  275. {
  276. listnode_delete (circuit->ip_addrs, ip);
  277. if (circuit->area)
  278. lsp_regenerate_schedule (circuit->area, circuit->is_type, 0);
  279. }
  280. else
  281. {
  282. prefix2str (connected->address, (char *)buf, BUFSIZ);
  283. zlog_warn ("Nonexitant ip address %s removal attempt from \
  284. circuit %d", buf, circuit->circuit_id);
  285. }
  286. prefix_ipv4_free (ipv4);
  287. }
  288. #ifdef HAVE_IPV6
  289. if (connected->address->family == AF_INET6)
  290. {
  291. ipv6 = prefix_ipv6_new ();
  292. ipv6->prefixlen = connected->address->prefixlen;
  293. ipv6->prefix = connected->address->u.prefix6;
  294. if (IN6_IS_ADDR_LINKLOCAL (&ipv6->prefix))
  295. {
  296. for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_link, node, ip6))
  297. {
  298. if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6))
  299. break;
  300. }
  301. if (ip6)
  302. {
  303. listnode_delete (circuit->ipv6_link, ip6);
  304. found = 1;
  305. }
  306. }
  307. else
  308. {
  309. for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_non_link, node, ip6))
  310. {
  311. if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6))
  312. break;
  313. }
  314. if (ip6)
  315. {
  316. listnode_delete (circuit->ipv6_non_link, ip6);
  317. found = 1;
  318. }
  319. }
  320. if (!found)
  321. {
  322. prefix2str (connected->address, (char *)buf, BUFSIZ);
  323. zlog_warn ("Nonexitant ip address %s removal attempt from \
  324. circuit %d", buf, circuit->circuit_id);
  325. }
  326. else if (circuit->area)
  327. lsp_regenerate_schedule (circuit->area, circuit->is_type, 0);
  328. prefix_ipv6_free (ipv6);
  329. }
  330. #endif /* HAVE_IPV6 */
  331. return;
  332. }
  333. static u_char
  334. isis_circuit_id_gen (struct interface *ifp)
  335. {
  336. u_char id = 0;
  337. char ifname[16];
  338. unsigned int i;
  339. int start = -1, end = -1;
  340. /*
  341. * Get a stable circuit id from ifname. This makes
  342. * the ifindex from flapping when netdevs are created
  343. * and deleted on the fly. Note that this circuit id
  344. * is used in pseudo lsps so it is better to be stable.
  345. * The following code works on any reasonanle ifname
  346. * like: eth1 or trk-1.1 etc.
  347. */
  348. for (i = 0; i < strlen (ifp->name); i++)
  349. {
  350. if (isdigit((unsigned char)ifp->name[i]))
  351. {
  352. if (start < 0)
  353. {
  354. start = i;
  355. end = i + 1;
  356. }
  357. else
  358. {
  359. end = i + 1;
  360. }
  361. }
  362. else if (start >= 0)
  363. break;
  364. }
  365. if ((start >= 0) && (end >= start) && (end - start) < 16)
  366. {
  367. memset (ifname, 0, 16);
  368. strncpy (ifname, &ifp->name[start], end - start);
  369. id = (u_char)atoi(ifname);
  370. }
  371. /* Try to be unique. */
  372. if (!id)
  373. id = (u_char)((ifp->ifindex & 0xff) | 0x80);
  374. return id;
  375. }
  376. void
  377. isis_circuit_if_add (struct isis_circuit *circuit, struct interface *ifp)
  378. {
  379. struct listnode *node, *nnode;
  380. struct connected *conn;
  381. circuit->circuit_id = isis_circuit_id_gen (ifp);
  382. isis_circuit_if_bind (circuit, ifp);
  383. /* isis_circuit_update_addrs (circuit, ifp); */
  384. if (if_is_broadcast (ifp))
  385. {
  386. if (circuit->circ_type_config == CIRCUIT_T_P2P)
  387. circuit->circ_type = CIRCUIT_T_P2P;
  388. else
  389. circuit->circ_type = CIRCUIT_T_BROADCAST;
  390. }
  391. else if (if_is_pointopoint (ifp))
  392. {
  393. circuit->circ_type = CIRCUIT_T_P2P;
  394. }
  395. else if (if_is_loopback (ifp))
  396. {
  397. circuit->circ_type = CIRCUIT_T_LOOPBACK;
  398. circuit->is_passive = 1;
  399. }
  400. else
  401. {
  402. /* It's normal in case of loopback etc. */
  403. if (isis->debugs & DEBUG_EVENTS)
  404. zlog_debug ("isis_circuit_if_add: unsupported media");
  405. circuit->circ_type = CIRCUIT_T_UNKNOWN;
  406. }
  407. circuit->ip_addrs = list_new ();
  408. #ifdef HAVE_IPV6
  409. circuit->ipv6_link = list_new ();
  410. circuit->ipv6_non_link = list_new ();
  411. #endif /* HAVE_IPV6 */
  412. for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, conn))
  413. isis_circuit_add_addr (circuit, conn);
  414. return;
  415. }
  416. void
  417. isis_circuit_if_del (struct isis_circuit *circuit, struct interface *ifp)
  418. {
  419. struct listnode *node, *nnode;
  420. struct connected *conn;
  421. assert (circuit->interface == ifp);
  422. /* destroy addresses */
  423. for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, conn))
  424. isis_circuit_del_addr (circuit, conn);
  425. if (circuit->ip_addrs)
  426. {
  427. assert (listcount(circuit->ip_addrs) == 0);
  428. list_delete (circuit->ip_addrs);
  429. circuit->ip_addrs = NULL;
  430. }
  431. #ifdef HAVE_IPV6
  432. if (circuit->ipv6_link)
  433. {
  434. assert (listcount(circuit->ipv6_link) == 0);
  435. list_delete (circuit->ipv6_link);
  436. circuit->ipv6_link = NULL;
  437. }
  438. if (circuit->ipv6_non_link)
  439. {
  440. assert (listcount(circuit->ipv6_non_link) == 0);
  441. list_delete (circuit->ipv6_non_link);
  442. circuit->ipv6_non_link = NULL;
  443. }
  444. #endif /* HAVE_IPV6 */
  445. circuit->circ_type = CIRCUIT_T_UNKNOWN;
  446. circuit->circuit_id = 0;
  447. return;
  448. }
  449. void
  450. isis_circuit_if_bind (struct isis_circuit *circuit, struct interface *ifp)
  451. {
  452. assert (circuit != NULL);
  453. assert (ifp != NULL);
  454. if (circuit->interface)
  455. assert (circuit->interface == ifp);
  456. else
  457. circuit->interface = ifp;
  458. if (ifp->info)
  459. assert (ifp->info == circuit);
  460. else
  461. ifp->info = circuit;
  462. }
  463. void
  464. isis_circuit_if_unbind (struct isis_circuit *circuit, struct interface *ifp)
  465. {
  466. assert (circuit != NULL);
  467. assert (ifp != NULL);
  468. assert (circuit->interface == ifp);
  469. assert (ifp->info == circuit);
  470. circuit->interface = NULL;
  471. ifp->info = NULL;
  472. }
  473. static void
  474. isis_circuit_update_all_srmflags (struct isis_circuit *circuit, int is_set)
  475. {
  476. struct isis_area *area;
  477. struct isis_lsp *lsp;
  478. dnode_t *dnode, *dnode_next;
  479. int level;
  480. assert (circuit);
  481. area = circuit->area;
  482. assert (area);
  483. for (level = ISIS_LEVEL1; level <= ISIS_LEVEL2; level++)
  484. {
  485. if (level & circuit->is_type)
  486. {
  487. if (area->lspdb[level - 1] &&
  488. dict_count (area->lspdb[level - 1]) > 0)
  489. {
  490. for (dnode = dict_first (area->lspdb[level - 1]);
  491. dnode != NULL; dnode = dnode_next)
  492. {
  493. dnode_next = dict_next (area->lspdb[level - 1], dnode);
  494. lsp = dnode_get (dnode);
  495. if (is_set)
  496. {
  497. ISIS_SET_FLAG (lsp->SRMflags, circuit);
  498. }
  499. else
  500. {
  501. ISIS_CLEAR_FLAG (lsp->SRMflags, circuit);
  502. }
  503. }
  504. }
  505. }
  506. }
  507. }
  508. size_t
  509. isis_circuit_pdu_size(struct isis_circuit *circuit)
  510. {
  511. return ISO_MTU(circuit);
  512. }
  513. void
  514. isis_circuit_stream(struct isis_circuit *circuit, struct stream **stream)
  515. {
  516. size_t stream_size = isis_circuit_pdu_size(circuit);
  517. if (!*stream)
  518. {
  519. *stream = stream_new(stream_size);
  520. }
  521. else
  522. {
  523. if (STREAM_SIZE(*stream) != stream_size)
  524. stream_resize(*stream, stream_size);
  525. stream_reset(*stream);
  526. }
  527. }
  528. int
  529. isis_circuit_up (struct isis_circuit *circuit)
  530. {
  531. int retv;
  532. /* Set the flags for all the lsps of the circuit. */
  533. isis_circuit_update_all_srmflags (circuit, 1);
  534. if (circuit->state == C_STATE_UP)
  535. return ISIS_OK;
  536. if (circuit->is_passive)
  537. return ISIS_OK;
  538. if (circuit->area->lsp_mtu > isis_circuit_pdu_size(circuit))
  539. {
  540. zlog_err("Interface MTU %zu on %s is too low to support area lsp mtu %u!",
  541. isis_circuit_pdu_size(circuit), circuit->interface->name,
  542. circuit->area->lsp_mtu);
  543. isis_circuit_down(circuit);
  544. return ISIS_ERROR;
  545. }
  546. if (circuit->circ_type == CIRCUIT_T_BROADCAST)
  547. {
  548. /*
  549. * Get the Hardware Address
  550. */
  551. #ifdef HAVE_STRUCT_SOCKADDR_DL
  552. #ifndef SUNOS_5
  553. if (circuit->interface->sdl.sdl_alen != ETHER_ADDR_LEN)
  554. zlog_warn ("unsupported link layer");
  555. else
  556. memcpy (circuit->u.bc.snpa, LLADDR (&circuit->interface->sdl),
  557. ETH_ALEN);
  558. #endif
  559. #else
  560. if (circuit->interface->hw_addr_len != ETH_ALEN)
  561. {
  562. zlog_warn ("unsupported link layer");
  563. }
  564. else
  565. {
  566. memcpy (circuit->u.bc.snpa, circuit->interface->hw_addr, ETH_ALEN);
  567. }
  568. #ifdef EXTREME_DEGUG
  569. zlog_debug ("isis_circuit_if_add: if_id %d, isomtu %d snpa %s",
  570. circuit->interface->ifindex, ISO_MTU (circuit),
  571. snpa_print (circuit->u.bc.snpa));
  572. #endif /* EXTREME_DEBUG */
  573. #endif /* HAVE_STRUCT_SOCKADDR_DL */
  574. circuit->u.bc.adjdb[0] = list_new ();
  575. circuit->u.bc.adjdb[1] = list_new ();
  576. /*
  577. * ISO 10589 - 8.4.1 Enabling of broadcast circuits
  578. */
  579. /* initilizing the hello sending threads
  580. * for a broadcast IF
  581. */
  582. /* 8.4.1 a) commence sending of IIH PDUs */
  583. if (circuit->is_type & IS_LEVEL_1)
  584. {
  585. thread_add_event (master, send_lan_l1_hello, circuit, 0);
  586. circuit->u.bc.lan_neighs[0] = list_new ();
  587. }
  588. if (circuit->is_type & IS_LEVEL_2)
  589. {
  590. thread_add_event (master, send_lan_l2_hello, circuit, 0);
  591. circuit->u.bc.lan_neighs[1] = list_new ();
  592. }
  593. /* 8.4.1 b) FIXME: solicit ES - 8.4.6 */
  594. /* 8.4.1 c) FIXME: listen for ESH PDUs */
  595. /* 8.4.1 d) */
  596. /* dr election will commence in... */
  597. if (circuit->is_type & IS_LEVEL_1)
  598. THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1,
  599. circuit, 2 * circuit->hello_interval[0]);
  600. if (circuit->is_type & IS_LEVEL_2)
  601. THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
  602. circuit, 2 * circuit->hello_interval[1]);
  603. }
  604. else
  605. {
  606. /* initializing the hello send threads
  607. * for a ptp IF
  608. */
  609. circuit->u.p2p.neighbor = NULL;
  610. thread_add_event (master, send_p2p_hello, circuit, 0);
  611. }
  612. /* initializing PSNP timers */
  613. if (circuit->is_type & IS_LEVEL_1)
  614. THREAD_TIMER_ON (master, circuit->t_send_psnp[0], send_l1_psnp, circuit,
  615. isis_jitter (circuit->psnp_interval[0], PSNP_JITTER));
  616. if (circuit->is_type & IS_LEVEL_2)
  617. THREAD_TIMER_ON (master, circuit->t_send_psnp[1], send_l2_psnp, circuit,
  618. isis_jitter (circuit->psnp_interval[1], PSNP_JITTER));
  619. /* unified init for circuits; ignore warnings below this level */
  620. retv = isis_sock_init (circuit);
  621. if (retv != ISIS_OK)
  622. {
  623. isis_circuit_down (circuit);
  624. return retv;
  625. }
  626. /* initialize the circuit streams after opening connection */
  627. isis_circuit_stream(circuit, &circuit->rcv_stream);
  628. isis_circuit_stream(circuit, &circuit->snd_stream);
  629. #ifdef GNU_LINUX
  630. THREAD_READ_ON (master, circuit->t_read, isis_receive, circuit,
  631. circuit->fd);
  632. #else
  633. THREAD_TIMER_ON (master, circuit->t_read, isis_receive, circuit,
  634. circuit->fd);
  635. #endif
  636. circuit->lsp_queue = list_new ();
  637. circuit->lsp_queue_last_cleared = time (NULL);
  638. return ISIS_OK;
  639. }
  640. void
  641. isis_circuit_down (struct isis_circuit *circuit)
  642. {
  643. if (circuit->state != C_STATE_UP)
  644. return;
  645. /* Clear the flags for all the lsps of the circuit. */
  646. isis_circuit_update_all_srmflags (circuit, 0);
  647. if (circuit->circ_type == CIRCUIT_T_BROADCAST)
  648. {
  649. /* destroy neighbour lists */
  650. if (circuit->u.bc.lan_neighs[0])
  651. {
  652. list_delete (circuit->u.bc.lan_neighs[0]);
  653. circuit->u.bc.lan_neighs[0] = NULL;
  654. }
  655. if (circuit->u.bc.lan_neighs[1])
  656. {
  657. list_delete (circuit->u.bc.lan_neighs[1]);
  658. circuit->u.bc.lan_neighs[1] = NULL;
  659. }
  660. /* destroy adjacency databases */
  661. if (circuit->u.bc.adjdb[0])
  662. {
  663. circuit->u.bc.adjdb[0]->del = isis_delete_adj;
  664. list_delete (circuit->u.bc.adjdb[0]);
  665. circuit->u.bc.adjdb[0] = NULL;
  666. }
  667. if (circuit->u.bc.adjdb[1])
  668. {
  669. circuit->u.bc.adjdb[1]->del = isis_delete_adj;
  670. list_delete (circuit->u.bc.adjdb[1]);
  671. circuit->u.bc.adjdb[1] = NULL;
  672. }
  673. if (circuit->u.bc.is_dr[0])
  674. {
  675. isis_dr_resign (circuit, 1);
  676. circuit->u.bc.is_dr[0] = 0;
  677. }
  678. memset (circuit->u.bc.l1_desig_is, 0, ISIS_SYS_ID_LEN + 1);
  679. if (circuit->u.bc.is_dr[1])
  680. {
  681. isis_dr_resign (circuit, 2);
  682. circuit->u.bc.is_dr[1] = 0;
  683. }
  684. memset (circuit->u.bc.l2_desig_is, 0, ISIS_SYS_ID_LEN + 1);
  685. memset (circuit->u.bc.snpa, 0, ETH_ALEN);
  686. THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[0]);
  687. THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[1]);
  688. THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[0]);
  689. THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[1]);
  690. THREAD_TIMER_OFF (circuit->u.bc.t_refresh_pseudo_lsp[0]);
  691. THREAD_TIMER_OFF (circuit->u.bc.t_refresh_pseudo_lsp[1]);
  692. }
  693. else if (circuit->circ_type == CIRCUIT_T_P2P)
  694. {
  695. isis_delete_adj (circuit->u.p2p.neighbor);
  696. circuit->u.p2p.neighbor = NULL;
  697. THREAD_TIMER_OFF (circuit->u.p2p.t_send_p2p_hello);
  698. }
  699. /* Cancel all active threads */
  700. THREAD_TIMER_OFF (circuit->t_send_csnp[0]);
  701. THREAD_TIMER_OFF (circuit->t_send_csnp[1]);
  702. THREAD_TIMER_OFF (circuit->t_send_psnp[0]);
  703. THREAD_TIMER_OFF (circuit->t_send_psnp[1]);
  704. THREAD_OFF (circuit->t_read);
  705. if (circuit->lsp_queue)
  706. {
  707. circuit->lsp_queue->del = NULL;
  708. list_delete (circuit->lsp_queue);
  709. circuit->lsp_queue = NULL;
  710. }
  711. /* send one gratuitous hello to spead up convergence */
  712. if (circuit->is_type & IS_LEVEL_1)
  713. send_hello (circuit, IS_LEVEL_1);
  714. if (circuit->is_type & IS_LEVEL_2)
  715. send_hello (circuit, IS_LEVEL_2);
  716. circuit->upadjcount[0] = 0;
  717. circuit->upadjcount[1] = 0;
  718. /* close the socket */
  719. if (circuit->fd)
  720. {
  721. close (circuit->fd);
  722. circuit->fd = 0;
  723. }
  724. if (circuit->rcv_stream != NULL)
  725. {
  726. stream_free (circuit->rcv_stream);
  727. circuit->rcv_stream = NULL;
  728. }
  729. if (circuit->snd_stream != NULL)
  730. {
  731. stream_free (circuit->snd_stream);
  732. circuit->snd_stream = NULL;
  733. }
  734. thread_cancel_event (master, circuit);
  735. return;
  736. }
  737. void
  738. circuit_update_nlpids (struct isis_circuit *circuit)
  739. {
  740. circuit->nlpids.count = 0;
  741. if (circuit->ip_router)
  742. {
  743. circuit->nlpids.nlpids[0] = NLPID_IP;
  744. circuit->nlpids.count++;
  745. }
  746. #ifdef HAVE_IPV6
  747. if (circuit->ipv6_router)
  748. {
  749. circuit->nlpids.nlpids[circuit->nlpids.count] = NLPID_IPV6;
  750. circuit->nlpids.count++;
  751. }
  752. #endif /* HAVE_IPV6 */
  753. return;
  754. }
  755. void
  756. isis_circuit_print_vty (struct isis_circuit *circuit, struct vty *vty,
  757. char detail)
  758. {
  759. if (detail == ISIS_UI_LEVEL_BRIEF)
  760. {
  761. vty_out (vty, " %-12s", circuit->interface->name);
  762. vty_out (vty, "0x%-7x", circuit->circuit_id);
  763. vty_out (vty, "%-9s", circuit_state2string (circuit->state));
  764. vty_out (vty, "%-9s", circuit_type2string (circuit->circ_type));
  765. vty_out (vty, "%-9s", circuit_t2string (circuit->is_type));
  766. vty_out (vty, "%s", VTY_NEWLINE);
  767. }
  768. if (detail == ISIS_UI_LEVEL_DETAIL)
  769. {
  770. vty_out (vty, " Interface: %s", circuit->interface->name);
  771. vty_out (vty, ", State: %s", circuit_state2string (circuit->state));
  772. if (circuit->is_passive)
  773. vty_out (vty, ", Passive");
  774. else
  775. vty_out (vty, ", Active");
  776. vty_out (vty, ", Circuit Id: 0x%x", circuit->circuit_id);
  777. vty_out (vty, "%s", VTY_NEWLINE);
  778. vty_out (vty, " Type: %s", circuit_type2string (circuit->circ_type));
  779. vty_out (vty, ", Level: %s", circuit_t2string (circuit->is_type));
  780. if (circuit->circ_type == CIRCUIT_T_BROADCAST)
  781. vty_out (vty, ", SNPA: %-10s", snpa_print (circuit->u.bc.snpa));
  782. vty_out (vty, "%s", VTY_NEWLINE);
  783. if (circuit->is_type & IS_LEVEL_1)
  784. {
  785. vty_out (vty, " Level-1 Information:%s", VTY_NEWLINE);
  786. if (circuit->area->newmetric)
  787. vty_out (vty, " Metric: %d", circuit->te_metric[0]);
  788. else
  789. vty_out (vty, " Metric: %d",
  790. circuit->metrics[0].metric_default);
  791. if (!circuit->is_passive)
  792. {
  793. vty_out (vty, ", Active neighbors: %u%s",
  794. circuit->upadjcount[0], VTY_NEWLINE);
  795. vty_out (vty, " Hello interval: %u, "
  796. "Holddown count: %u %s%s",
  797. circuit->hello_interval[0],
  798. circuit->hello_multiplier[0],
  799. (circuit->pad_hellos ? "(pad)" : "(no-pad)"),
  800. VTY_NEWLINE);
  801. vty_out (vty, " CNSP interval: %u, "
  802. "PSNP interval: %u%s",
  803. circuit->csnp_interval[0],
  804. circuit->psnp_interval[0], VTY_NEWLINE);
  805. if (circuit->circ_type == CIRCUIT_T_BROADCAST)
  806. vty_out (vty, " LAN Priority: %u, %s%s",
  807. circuit->priority[0],
  808. (circuit->u.bc.is_dr[0] ? \
  809. "is DIS" : "is not DIS"), VTY_NEWLINE);
  810. }
  811. else
  812. {
  813. vty_out (vty, "%s", VTY_NEWLINE);
  814. }
  815. }
  816. if (circuit->is_type & IS_LEVEL_2)
  817. {
  818. vty_out (vty, " Level-2 Information:%s", VTY_NEWLINE);
  819. if (circuit->area->newmetric)
  820. vty_out (vty, " Metric: %d", circuit->te_metric[1]);
  821. else
  822. vty_out (vty, " Metric: %d",
  823. circuit->metrics[1].metric_default);
  824. if (!circuit->is_passive)
  825. {
  826. vty_out (vty, ", Active neighbors: %u%s",
  827. circuit->upadjcount[1], VTY_NEWLINE);
  828. vty_out (vty, " Hello interval: %u, "
  829. "Holddown count: %u %s%s",
  830. circuit->hello_interval[1],
  831. circuit->hello_multiplier[1],
  832. (circuit->pad_hellos ? "(pad)" : "(no-pad)"),
  833. VTY_NEWLINE);
  834. vty_out (vty, " CNSP interval: %u, "
  835. "PSNP interval: %u%s",
  836. circuit->csnp_interval[1],
  837. circuit->psnp_interval[1], VTY_NEWLINE);
  838. if (circuit->circ_type == CIRCUIT_T_BROADCAST)
  839. vty_out (vty, " LAN Priority: %u, %s%s",
  840. circuit->priority[1],
  841. (circuit->u.bc.is_dr[1] ? \
  842. "is DIS" : "is not DIS"), VTY_NEWLINE);
  843. }
  844. else
  845. {
  846. vty_out (vty, "%s", VTY_NEWLINE);
  847. }
  848. }
  849. if (circuit->ip_addrs && listcount (circuit->ip_addrs) > 0)
  850. {
  851. struct listnode *node;
  852. struct prefix *ip_addr;
  853. u_char buf[BUFSIZ];
  854. vty_out (vty, " IP Prefix(es):%s", VTY_NEWLINE);
  855. for (ALL_LIST_ELEMENTS_RO (circuit->ip_addrs, node, ip_addr))
  856. {
  857. prefix2str (ip_addr, (char*)buf, BUFSIZ),
  858. vty_out (vty, " %s%s", buf, VTY_NEWLINE);
  859. }
  860. }
  861. vty_out (vty, "%s", VTY_NEWLINE);
  862. }
  863. return;
  864. }
  865. int
  866. isis_interface_config_write (struct vty *vty)
  867. {
  868. int write = 0;
  869. struct listnode *node, *node2;
  870. struct interface *ifp;
  871. struct isis_area *area;
  872. struct isis_circuit *circuit;
  873. int i;
  874. for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
  875. {
  876. /* IF name */
  877. vty_out (vty, "interface %s%s", ifp->name, VTY_NEWLINE);
  878. write++;
  879. /* IF desc */
  880. if (ifp->desc)
  881. {
  882. vty_out (vty, " description %s%s", ifp->desc, VTY_NEWLINE);
  883. write++;
  884. }
  885. /* ISIS Circuit */
  886. for (ALL_LIST_ELEMENTS_RO (isis->area_list, node2, area))
  887. {
  888. circuit = circuit_lookup_by_ifp (ifp, area->circuit_list);
  889. if (circuit == NULL)
  890. continue;
  891. if (circuit->ip_router)
  892. {
  893. vty_out (vty, " ip router isis %s%s", area->area_tag,
  894. VTY_NEWLINE);
  895. write++;
  896. }
  897. if (circuit->is_passive)
  898. {
  899. vty_out (vty, " isis passive%s", VTY_NEWLINE);
  900. write++;
  901. }
  902. if (circuit->circ_type_config == CIRCUIT_T_P2P)
  903. {
  904. vty_out (vty, " isis network point-to-point%s", VTY_NEWLINE);
  905. write++;
  906. }
  907. #ifdef HAVE_IPV6
  908. if (circuit->ipv6_router)
  909. {
  910. vty_out (vty, " ipv6 router isis %s%s", area->area_tag,
  911. VTY_NEWLINE);
  912. write++;
  913. }
  914. #endif /* HAVE_IPV6 */
  915. /* ISIS - circuit type */
  916. if (circuit->is_type == IS_LEVEL_1)
  917. {
  918. vty_out (vty, " isis circuit-type level-1%s", VTY_NEWLINE);
  919. write++;
  920. }
  921. else
  922. {
  923. if (circuit->is_type == IS_LEVEL_2)
  924. {
  925. vty_out (vty, " isis circuit-type level-2-only%s",
  926. VTY_NEWLINE);
  927. write++;
  928. }
  929. }
  930. /* ISIS - CSNP interval */
  931. if (circuit->csnp_interval[0] == circuit->csnp_interval[1])
  932. {
  933. if (circuit->csnp_interval[0] != DEFAULT_CSNP_INTERVAL)
  934. {
  935. vty_out (vty, " isis csnp-interval %d%s",
  936. circuit->csnp_interval[0], VTY_NEWLINE);
  937. write++;
  938. }
  939. }
  940. else
  941. {
  942. for (i = 0; i < 2; i++)
  943. {
  944. if (circuit->csnp_interval[i] != DEFAULT_CSNP_INTERVAL)
  945. {
  946. vty_out (vty, " isis csnp-interval %d level-%d%s",
  947. circuit->csnp_interval[i], i + 1, VTY_NEWLINE);
  948. write++;
  949. }
  950. }
  951. }
  952. /* ISIS - PSNP interval */
  953. if (circuit->psnp_interval[0] == circuit->psnp_interval[1])
  954. {
  955. if (circuit->psnp_interval[0] != DEFAULT_PSNP_INTERVAL)
  956. {
  957. vty_out (vty, " isis psnp-interval %d%s",
  958. circuit->psnp_interval[0], VTY_NEWLINE);
  959. write++;
  960. }
  961. }
  962. else
  963. {
  964. for (i = 0; i < 2; i++)
  965. {
  966. if (circuit->psnp_interval[i] != DEFAULT_PSNP_INTERVAL)
  967. {
  968. vty_out (vty, " isis psnp-interval %d level-%d%s",
  969. circuit->psnp_interval[i], i + 1, VTY_NEWLINE);
  970. write++;
  971. }
  972. }
  973. }
  974. /* ISIS - Hello padding - Defaults to true so only display if false */
  975. if (circuit->pad_hellos == 0)
  976. {
  977. vty_out (vty, " no isis hello padding%s", VTY_NEWLINE);
  978. write++;
  979. }
  980. /* ISIS - Hello interval */
  981. if (circuit->hello_interval[0] == circuit->hello_interval[1])
  982. {
  983. if (circuit->hello_interval[0] != DEFAULT_HELLO_INTERVAL)
  984. {
  985. vty_out (vty, " isis hello-interval %d%s",
  986. circuit->hello_interval[0], VTY_NEWLINE);
  987. write++;
  988. }
  989. }
  990. else
  991. {
  992. for (i = 0; i < 2; i++)
  993. {
  994. if (circuit->hello_interval[i] != DEFAULT_HELLO_INTERVAL)
  995. {
  996. vty_out (vty, " isis hello-interval %d level-%d%s",
  997. circuit->hello_interval[i], i + 1, VTY_NEWLINE);
  998. write++;
  999. }
  1000. }
  1001. }
  1002. /* ISIS - Hello Multiplier */
  1003. if (circuit->hello_multiplier[0] == circuit->hello_multiplier[1])
  1004. {
  1005. if (circuit->hello_multiplier[0] != DEFAULT_HELLO_MULTIPLIER)
  1006. {
  1007. vty_out (vty, " isis hello-multiplier %d%s",
  1008. circuit->hello_multiplier[0], VTY_NEWLINE);
  1009. write++;
  1010. }
  1011. }
  1012. else
  1013. {
  1014. for (i = 0; i < 2; i++)
  1015. {
  1016. if (circuit->hello_multiplier[i] != DEFAULT_HELLO_MULTIPLIER)
  1017. {
  1018. vty_out (vty, " isis hello-multiplier %d level-%d%s",
  1019. circuit->hello_multiplier[i], i + 1,
  1020. VTY_NEWLINE);
  1021. write++;
  1022. }
  1023. }
  1024. }
  1025. /* ISIS - Priority */
  1026. if (circuit->priority[0] == circuit->priority[1])
  1027. {
  1028. if (circuit->priority[0] != DEFAULT_PRIORITY)
  1029. {
  1030. vty_out (vty, " isis priority %d%s",
  1031. circuit->priority[0], VTY_NEWLINE);
  1032. write++;
  1033. }
  1034. }
  1035. else
  1036. {
  1037. for (i = 0; i < 2; i++)
  1038. {
  1039. if (circuit->priority[i] != DEFAULT_PRIORITY)
  1040. {
  1041. vty_out (vty, " isis priority %d level-%d%s",
  1042. circuit->priority[i], i + 1, VTY_NEWLINE);
  1043. write++;
  1044. }
  1045. }
  1046. }
  1047. /* ISIS - Metric */
  1048. if (circuit->te_metric[0] == circuit->te_metric[1])
  1049. {
  1050. if (circuit->te_metric[0] != DEFAULT_CIRCUIT_METRIC)
  1051. {
  1052. vty_out (vty, " isis metric %d%s", circuit->te_metric[0],
  1053. VTY_NEWLINE);
  1054. write++;
  1055. }
  1056. }
  1057. else
  1058. {
  1059. for (i = 0; i < 2; i++)
  1060. {
  1061. if (circuit->te_metric[i] != DEFAULT_CIRCUIT_METRIC)
  1062. {
  1063. vty_out (vty, " isis metric %d level-%d%s",
  1064. circuit->te_metric[i], i + 1, VTY_NEWLINE);
  1065. write++;
  1066. }
  1067. }
  1068. }
  1069. if (circuit->passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5)
  1070. {
  1071. vty_out (vty, " isis password md5 %s%s", circuit->passwd.passwd,
  1072. VTY_NEWLINE);
  1073. write++;
  1074. }
  1075. else if (circuit->passwd.type == ISIS_PASSWD_TYPE_CLEARTXT)
  1076. {
  1077. vty_out (vty, " isis password clear %s%s", circuit->passwd.passwd,
  1078. VTY_NEWLINE);
  1079. write++;
  1080. }
  1081. }
  1082. vty_out (vty, "!%s", VTY_NEWLINE);
  1083. }
  1084. return write;
  1085. }
  1086. DEFUN (ip_router_isis,
  1087. ip_router_isis_cmd,
  1088. "ip router isis WORD",
  1089. "Interface Internet Protocol config commands\n"
  1090. "IP router interface commands\n"
  1091. "IS-IS Routing for IP\n"
  1092. "Routing process tag\n")
  1093. {
  1094. struct isis_circuit *circuit;
  1095. struct interface *ifp;
  1096. struct isis_area *area;
  1097. int rv;
  1098. ifp = (struct interface *) vty->index;
  1099. assert (ifp);
  1100. /* Prevent more than one area per circuit */
  1101. circuit = circuit_scan_by_ifp (ifp);
  1102. if (circuit)
  1103. {
  1104. if (circuit->ip_router == 1)
  1105. {
  1106. if (strcmp (circuit->area->area_tag, argv[0]))
  1107. {
  1108. vty_out (vty, "ISIS circuit is already defined on %s%s",
  1109. circuit->area->area_tag, VTY_NEWLINE);
  1110. return CMD_ERR_NOTHING_TODO;
  1111. }
  1112. return CMD_SUCCESS;
  1113. }
  1114. }
  1115. if (isis_area_get (vty, argv[0]) != CMD_SUCCESS)
  1116. {
  1117. vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
  1118. return CMD_ERR_NO_MATCH;
  1119. }
  1120. area = vty->index;
  1121. circuit = isis_csm_state_change (ISIS_ENABLE, circuit, area);
  1122. if (circuit->state != C_STATE_CONF && circuit->state != C_STATE_UP)
  1123. {
  1124. vty_out(vty, "Couldn't bring up interface, please check log.%s", VTY_NEWLINE);
  1125. rv = CMD_WARNING;
  1126. }
  1127. else
  1128. {
  1129. isis_circuit_if_bind (circuit, ifp);
  1130. circuit->ip_router = 1;
  1131. area->ip_circuits++;
  1132. circuit_update_nlpids (circuit);
  1133. rv = CMD_SUCCESS;
  1134. }
  1135. vty->node = INTERFACE_NODE;
  1136. vty->index = ifp;
  1137. return rv;
  1138. }
  1139. DEFUN (no_ip_router_isis,
  1140. no_ip_router_isis_cmd,
  1141. "no ip router isis WORD",
  1142. NO_STR
  1143. "Interface Internet Protocol config commands\n"
  1144. "IP router interface commands\n"
  1145. "IS-IS Routing for IP\n"
  1146. "Routing process tag\n")
  1147. {
  1148. struct interface *ifp;
  1149. struct isis_area *area;
  1150. struct isis_circuit *circuit;
  1151. ifp = (struct interface *) vty->index;
  1152. if (!ifp)
  1153. {
  1154. vty_out (vty, "Invalid interface %s", VTY_NEWLINE);
  1155. return CMD_ERR_NO_MATCH;
  1156. }
  1157. area = isis_area_lookup (argv[0]);
  1158. if (!area)
  1159. {
  1160. vty_out (vty, "Can't find ISIS instance %s%s",
  1161. argv[0], VTY_NEWLINE);
  1162. return CMD_ERR_NO_MATCH;
  1163. }
  1164. circuit = circuit_lookup_by_ifp (ifp, area->circuit_list);
  1165. if (!circuit)
  1166. {
  1167. vty_out (vty, "ISIS is not enabled on circuit %s%s",
  1168. ifp->name, VTY_NEWLINE);
  1169. return CMD_ERR_NO_MATCH;
  1170. }
  1171. circuit->ip_router = 0;
  1172. area->ip_circuits--;
  1173. #ifdef HAVE_IPV6
  1174. if (circuit->ipv6_router == 0)
  1175. #endif
  1176. isis_csm_state_change (ISIS_DISABLE, circuit, area);
  1177. return CMD_SUCCESS;
  1178. }
  1179. #ifdef HAVE_IPV6
  1180. DEFUN (ipv6_router_isis,
  1181. ipv6_router_isis_cmd,
  1182. "ipv6 router isis WORD",
  1183. "IPv6 interface subcommands\n"
  1184. "IPv6 Router interface commands\n"
  1185. "IS-IS Routing for IPv6\n"
  1186. "Routing process tag\n")
  1187. {
  1188. struct isis_circuit *circuit;
  1189. struct interface *ifp;
  1190. struct isis_area *area;
  1191. int rv;
  1192. ifp = (struct interface *) vty->index;
  1193. assert (ifp);
  1194. /* Prevent more than one area per circuit */
  1195. circuit = circuit_scan_by_ifp (ifp);
  1196. if (circuit)
  1197. {
  1198. if (circuit->ipv6_router == 1)
  1199. {
  1200. if (strcmp (circuit->area->area_tag, argv[0]))
  1201. {
  1202. vty_out (vty, "ISIS circuit is already defined for IPv6 on %s%s",
  1203. circuit->area->area_tag, VTY_NEWLINE);
  1204. return CMD_ERR_NOTHING_TODO;
  1205. }
  1206. return CMD_SUCCESS;
  1207. }
  1208. }
  1209. if (isis_area_get (vty, argv[0]) != CMD_SUCCESS)
  1210. {
  1211. vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
  1212. return CMD_ERR_NO_MATCH;
  1213. }
  1214. area = vty->index;
  1215. circuit = isis_csm_state_change (ISIS_ENABLE, circuit, area);
  1216. if (circuit->state != C_STATE_CONF && circuit->state != C_STATE_UP)
  1217. {
  1218. vty_out(vty, "Couldn't bring up interface, please check log.%s", VTY_NEWLINE);
  1219. rv = CMD_WARNING;
  1220. }
  1221. else
  1222. {
  1223. isis_circuit_if_bind (circuit, ifp);
  1224. circuit->ipv6_router = 1;
  1225. area->ipv6_circuits++;
  1226. circuit_update_nlpids (circuit);
  1227. rv = CMD_SUCCESS;
  1228. }
  1229. vty->node = INTERFACE_NODE;
  1230. vty->index = ifp;
  1231. return rv;
  1232. }
  1233. DEFUN (no_ipv6_router_isis,
  1234. no_ipv6_router_isis_cmd,
  1235. "no ipv6 router isis WORD",
  1236. NO_STR
  1237. "IPv6 interface subcommands\n"
  1238. "IPv6 Router interface commands\n"
  1239. "IS-IS Routing for IPv6\n"
  1240. "Routing process tag\n")
  1241. {
  1242. struct interface *ifp;
  1243. struct isis_area *area;
  1244. struct isis_circuit *circuit;
  1245. ifp = (struct interface *) vty->index;
  1246. if (!ifp)
  1247. {
  1248. vty_out (vty, "Invalid interface %s", VTY_NEWLINE);
  1249. return CMD_ERR_NO_MATCH;
  1250. }
  1251. area = isis_area_lookup (argv[0]);
  1252. if (!area)
  1253. {
  1254. vty_out (vty, "Can't find ISIS instance %s%s",
  1255. argv[0], VTY_NEWLINE);
  1256. return CMD_ERR_NO_MATCH;
  1257. }
  1258. circuit = circuit_lookup_by_ifp (ifp, area->circuit_list);
  1259. if (!circuit)
  1260. {
  1261. vty_out (vty, "ISIS is not enabled on circuit %s%s",
  1262. ifp->name, VTY_NEWLINE);
  1263. return CMD_ERR_NO_MATCH;
  1264. }
  1265. circuit->ipv6_router = 0;
  1266. area->ipv6_circuits--;
  1267. if (circuit->ip_router == 0)
  1268. isis_csm_state_change (ISIS_DISABLE, circuit, area);
  1269. return CMD_SUCCESS;
  1270. }
  1271. #endif /* HAVE_IPV6 */
  1272. DEFUN (isis_passive,
  1273. isis_passive_cmd,
  1274. "isis passive",
  1275. "IS-IS commands\n"
  1276. "Configure the passive mode for interface\n")
  1277. {
  1278. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  1279. if (!circuit)
  1280. return CMD_ERR_NO_MATCH;
  1281. if (circuit->is_passive == 1)
  1282. return CMD_SUCCESS;
  1283. if (circuit->state != C_STATE_UP)
  1284. {
  1285. circuit->is_passive = 1;
  1286. }
  1287. else
  1288. {
  1289. struct isis_area *area = circuit->area;
  1290. isis_csm_state_change (ISIS_DISABLE, circuit, area);
  1291. circuit->is_passive = 1;
  1292. isis_csm_state_change (ISIS_ENABLE, circuit, area);
  1293. }
  1294. return CMD_SUCCESS;
  1295. }
  1296. DEFUN (no_isis_passive,
  1297. no_isis_passive_cmd,
  1298. "no isis passive",
  1299. NO_STR
  1300. "IS-IS commands\n"
  1301. "Configure the passive mode for interface\n")
  1302. {
  1303. struct interface *ifp;
  1304. struct isis_circuit *circuit;
  1305. ifp = (struct interface *) vty->index;
  1306. if (!ifp)
  1307. {
  1308. vty_out (vty, "Invalid interface %s", VTY_NEWLINE);
  1309. return CMD_ERR_NO_MATCH;
  1310. }
  1311. /* FIXME: what is wrong with circuit = ifp->info ? */
  1312. circuit = circuit_scan_by_ifp (ifp);
  1313. if (!circuit)
  1314. {
  1315. vty_out (vty, "ISIS is not enabled on circuit %s%s",
  1316. ifp->name, VTY_NEWLINE);
  1317. return CMD_ERR_NO_MATCH;
  1318. }
  1319. if (if_is_loopback(ifp))
  1320. {
  1321. vty_out (vty, "Can't set no passive for loopback interface%s",
  1322. VTY_NEWLINE);
  1323. return CMD_ERR_AMBIGUOUS;
  1324. }
  1325. if (circuit->is_passive == 0)
  1326. return CMD_SUCCESS;
  1327. if (circuit->state != C_STATE_UP)
  1328. {
  1329. circuit->is_passive = 0;
  1330. }
  1331. else
  1332. {
  1333. struct isis_area *area = circuit->area;
  1334. isis_csm_state_change (ISIS_DISABLE, circuit, area);
  1335. circuit->is_passive = 0;
  1336. isis_csm_state_change (ISIS_ENABLE, circuit, area);
  1337. }
  1338. return CMD_SUCCESS;
  1339. }
  1340. DEFUN (isis_circuit_type,
  1341. isis_circuit_type_cmd,
  1342. "isis circuit-type (level-1|level-1-2|level-2-only)",
  1343. "IS-IS commands\n"
  1344. "Configure circuit type for interface\n"
  1345. "Level-1 only adjacencies are formed\n"
  1346. "Level-1-2 adjacencies are formed\n"
  1347. "Level-2 only adjacencies are formed\n")
  1348. {
  1349. int circuit_type;
  1350. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  1351. if (!circuit)
  1352. return CMD_ERR_NO_MATCH;
  1353. circuit_type = string2circuit_t (argv[0]);
  1354. if (!circuit_type)
  1355. {
  1356. vty_out (vty, "Unknown circuit-type %s", VTY_NEWLINE);
  1357. return CMD_ERR_AMBIGUOUS;
  1358. }
  1359. if (circuit->state == C_STATE_UP &&
  1360. circuit->area->is_type != IS_LEVEL_1_AND_2 &&
  1361. circuit->area->is_type != circuit_type)
  1362. {
  1363. vty_out (vty, "Invalid circuit level for area %s.%s",
  1364. circuit->area->area_tag, VTY_NEWLINE);
  1365. return CMD_ERR_AMBIGUOUS;
  1366. }
  1367. isis_event_circuit_type_change (circuit, circuit_type);
  1368. return CMD_SUCCESS;
  1369. }
  1370. DEFUN (no_isis_circuit_type,
  1371. no_isis_circuit_type_cmd,
  1372. "no isis circuit-type (level-1|level-1-2|level-2-only)",
  1373. NO_STR
  1374. "IS-IS commands\n"
  1375. "Configure circuit type for interface\n"
  1376. "Level-1 only adjacencies are formed\n"
  1377. "Level-1-2 adjacencies are formed\n"
  1378. "Level-2 only adjacencies are formed\n")
  1379. {
  1380. int circuit_type;
  1381. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  1382. if (!circuit)
  1383. return CMD_ERR_NO_MATCH;
  1384. /*
  1385. * Set the circuits level to its default value
  1386. */
  1387. if (circuit->state == C_STATE_UP)
  1388. circuit_type = circuit->area->is_type;
  1389. else
  1390. circuit_type = IS_LEVEL_1_AND_2;
  1391. isis_event_circuit_type_change (circuit, circuit_type);
  1392. return CMD_SUCCESS;
  1393. }
  1394. DEFUN (isis_passwd_md5,
  1395. isis_passwd_md5_cmd,
  1396. "isis password md5 WORD",
  1397. "IS-IS commands\n"
  1398. "Configure the authentication password for a circuit\n"
  1399. "Authentication type\n"
  1400. "Circuit password\n")
  1401. {
  1402. int len;
  1403. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  1404. if (!circuit)
  1405. return CMD_ERR_NO_MATCH;
  1406. len = strlen (argv[0]);
  1407. if (len > 254)
  1408. {
  1409. vty_out (vty, "Too long circuit password (>254)%s", VTY_NEWLINE);
  1410. return CMD_ERR_AMBIGUOUS;
  1411. }
  1412. circuit->passwd.len = len;
  1413. circuit->passwd.type = ISIS_PASSWD_TYPE_HMAC_MD5;
  1414. strncpy ((char *)circuit->passwd.passwd, argv[0], 255);
  1415. return CMD_SUCCESS;
  1416. }
  1417. DEFUN (isis_passwd_clear,
  1418. isis_passwd_clear_cmd,
  1419. "isis password clear WORD",
  1420. "IS-IS commands\n"
  1421. "Configure the authentication password for a circuit\n"
  1422. "Authentication type\n"
  1423. "Circuit password\n")
  1424. {
  1425. int len;
  1426. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  1427. if (!circuit)
  1428. return CMD_ERR_NO_MATCH;
  1429. len = strlen (argv[0]);
  1430. if (len > 254)
  1431. {
  1432. vty_out (vty, "Too long circuit password (>254)%s", VTY_NEWLINE);
  1433. return CMD_ERR_AMBIGUOUS;
  1434. }
  1435. circuit->passwd.len = len;
  1436. circuit->passwd.type = ISIS_PASSWD_TYPE_CLEARTXT;
  1437. strncpy ((char *)circuit->passwd.passwd, argv[0], 255);
  1438. return CMD_SUCCESS;
  1439. }
  1440. DEFUN (no_isis_passwd,
  1441. no_isis_passwd_cmd,
  1442. "no isis password",
  1443. NO_STR
  1444. "IS-IS commands\n"
  1445. "Configure the authentication password for a circuit\n")
  1446. {
  1447. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  1448. if (!circuit)
  1449. return CMD_ERR_NO_MATCH;
  1450. memset (&circuit->passwd, 0, sizeof (struct isis_passwd));
  1451. return CMD_SUCCESS;
  1452. }
  1453. DEFUN (isis_priority,
  1454. isis_priority_cmd,
  1455. "isis priority <0-127>",
  1456. "IS-IS commands\n"
  1457. "Set priority for Designated Router election\n"
  1458. "Priority value\n")
  1459. {
  1460. int prio;
  1461. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  1462. if (!circuit)
  1463. return CMD_ERR_NO_MATCH;
  1464. prio = atoi (argv[0]);
  1465. if (prio < MIN_PRIORITY || prio > MAX_PRIORITY)
  1466. {
  1467. vty_out (vty, "Invalid priority %d - should be <0-127>%s",
  1468. prio, VTY_NEWLINE);
  1469. return CMD_ERR_AMBIGUOUS;
  1470. }
  1471. circuit->priority[0] = prio;
  1472. circuit->priority[1] = prio;
  1473. return CMD_SUCCESS;
  1474. }
  1475. DEFUN (no_isis_priority,
  1476. no_isis_priority_cmd,
  1477. "no isis priority",
  1478. NO_STR
  1479. "IS-IS commands\n"
  1480. "Set priority for Designated Router election\n")
  1481. {
  1482. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  1483. if (!circuit)
  1484. return CMD_ERR_NO_MATCH;
  1485. circuit->priority[0] = DEFAULT_PRIORITY;
  1486. circuit->priority[1] = DEFAULT_PRIORITY;
  1487. return CMD_SUCCESS;
  1488. }
  1489. ALIAS (no_isis_priority,
  1490. no_isis_priority_arg_cmd,
  1491. "no isis priority <0-127>",
  1492. NO_STR
  1493. "IS-IS commands\n"
  1494. "Set priority for Designated Router election\n"
  1495. "Priority value\n")
  1496. DEFUN (isis_priority_l1,
  1497. isis_priority_l1_cmd,
  1498. "isis priority <0-127> level-1",
  1499. "IS-IS commands\n"
  1500. "Set priority for Designated Router election\n"
  1501. "Priority value\n"
  1502. "Specify priority for level-1 routing\n")
  1503. {
  1504. int prio;
  1505. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  1506. if (!circuit)
  1507. return CMD_ERR_NO_MATCH;
  1508. prio = atoi (argv[0]);
  1509. if (prio < MIN_PRIORITY || prio > MAX_PRIORITY)
  1510. {
  1511. vty_out (vty, "Invalid priority %d - should be <0-127>%s",
  1512. prio, VTY_NEWLINE);
  1513. return CMD_ERR_AMBIGUOUS;
  1514. }
  1515. circuit->priority[0] = prio;
  1516. return CMD_SUCCESS;
  1517. }
  1518. DEFUN (no_isis_priority_l1,
  1519. no_isis_priority_l1_cmd,
  1520. "no isis priority level-1",
  1521. NO_STR
  1522. "IS-IS commands\n"
  1523. "Set priority for Designated Router election\n"
  1524. "Specify priority for level-1 routing\n")
  1525. {
  1526. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  1527. if (!circuit)
  1528. return CMD_ERR_NO_MATCH;
  1529. circuit->priority[0] = DEFAULT_PRIORITY;
  1530. return CMD_SUCCESS;
  1531. }
  1532. ALIAS (no_isis_priority_l1,
  1533. no_isis_priority_l1_arg_cmd,
  1534. "no isis priority <0-127> level-1",
  1535. NO_STR
  1536. "IS-IS commands\n"
  1537. "Set priority for Designated Router election\n"
  1538. "Priority value\n"
  1539. "Specify priority for level-1 routing\n")
  1540. DEFUN (isis_priority_l2,
  1541. isis_priority_l2_cmd,
  1542. "isis priority <0-127> level-2",
  1543. "IS-IS commands\n"
  1544. "Set priority for Designated Router election\n"
  1545. "Priority value\n"
  1546. "Specify priority for level-2 routing\n")
  1547. {
  1548. int prio;
  1549. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  1550. if (!circuit)
  1551. return CMD_ERR_NO_MATCH;
  1552. prio = atoi (argv[0]);
  1553. if (prio < MIN_PRIORITY || prio > MAX_PRIORITY)
  1554. {
  1555. vty_out (vty, "Invalid priority %d - should be <0-127>%s",
  1556. prio, VTY_NEWLINE);
  1557. return CMD_ERR_AMBIGUOUS;
  1558. }
  1559. circuit->priority[1] = prio;
  1560. return CMD_SUCCESS;
  1561. }
  1562. DEFUN (no_isis_priority_l2,
  1563. no_isis_priority_l2_cmd,
  1564. "no isis priority level-2",
  1565. NO_STR
  1566. "IS-IS commands\n"
  1567. "Set priority for Designated Router election\n"
  1568. "Specify priority for level-2 routing\n")
  1569. {
  1570. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  1571. if (!circuit)
  1572. return CMD_ERR_NO_MATCH;
  1573. circuit->priority[1] = DEFAULT_PRIORITY;
  1574. return CMD_SUCCESS;
  1575. }
  1576. ALIAS (no_isis_priority_l2,
  1577. no_isis_priority_l2_arg_cmd,
  1578. "no isis priority <0-127> level-2",
  1579. NO_STR
  1580. "IS-IS commands\n"
  1581. "Set priority for Designated Router election\n"
  1582. "Priority value\n"
  1583. "Specify priority for level-2 routing\n")
  1584. /* Metric command */
  1585. DEFUN (isis_metric,
  1586. isis_metric_cmd,
  1587. "isis metric <0-16777215>",
  1588. "IS-IS commands\n"
  1589. "Set default metric for circuit\n"
  1590. "Default metric value\n")
  1591. {
  1592. int met;
  1593. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  1594. if (!circuit)
  1595. return CMD_ERR_NO_MATCH;
  1596. met = atoi (argv[0]);
  1597. /* RFC3787 section 5.1 */
  1598. if (circuit->area && circuit->area->oldmetric == 1 &&
  1599. met > MAX_NARROW_LINK_METRIC)
  1600. {
  1601. vty_out (vty, "Invalid metric %d - should be <0-63> "
  1602. "when narrow metric type enabled%s",
  1603. met, VTY_NEWLINE);
  1604. return CMD_ERR_AMBIGUOUS;
  1605. }
  1606. /* RFC4444 */
  1607. if (circuit->area && circuit->area->newmetric == 1 &&
  1608. met > MAX_WIDE_LINK_METRIC)
  1609. {
  1610. vty_out (vty, "Invalid metric %d - should be <0-16777215> "
  1611. "when wide metric type enabled%s",
  1612. met, VTY_NEWLINE);
  1613. return CMD_ERR_AMBIGUOUS;
  1614. }
  1615. circuit->te_metric[0] = met;
  1616. circuit->te_metric[1] = met;
  1617. circuit->metrics[0].metric_default = met;
  1618. circuit->metrics[1].metric_default = met;
  1619. if (circuit->area)
  1620. lsp_regenerate_schedule (circuit->area, circuit->is_type, 0);
  1621. return CMD_SUCCESS;
  1622. }
  1623. DEFUN (no_isis_metric,
  1624. no_isis_metric_cmd,
  1625. "no isis metric",
  1626. NO_STR
  1627. "IS-IS commands\n"
  1628. "Set default metric for circuit\n")
  1629. {
  1630. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  1631. if (!circuit)
  1632. return CMD_ERR_NO_MATCH;
  1633. circuit->te_metric[0] = DEFAULT_CIRCUIT_METRIC;
  1634. circuit->te_metric[1] = DEFAULT_CIRCUIT_METRIC;
  1635. circuit->metrics[0].metric_default = DEFAULT_CIRCUIT_METRIC;
  1636. circuit->metrics[1].metric_default = DEFAULT_CIRCUIT_METRIC;
  1637. if (circuit->area)
  1638. lsp_regenerate_schedule (circuit->area, circuit->is_type, 0);
  1639. return CMD_SUCCESS;
  1640. }
  1641. ALIAS (no_isis_metric,
  1642. no_isis_metric_arg_cmd,
  1643. "no isis metric <0-16777215>",
  1644. NO_STR
  1645. "IS-IS commands\n"
  1646. "Set default metric for circuit\n"
  1647. "Default metric value\n")
  1648. DEFUN (isis_metric_l1,
  1649. isis_metric_l1_cmd,
  1650. "isis metric <0-16777215> level-1",
  1651. "IS-IS commands\n"
  1652. "Set default metric for circuit\n"
  1653. "Default metric value\n"
  1654. "Specify metric for level-1 routing\n")
  1655. {
  1656. int met;
  1657. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  1658. if (!circuit)
  1659. return CMD_ERR_NO_MATCH;
  1660. met = atoi (argv[0]);
  1661. /* RFC3787 section 5.1 */
  1662. if (circuit->area && circuit->area->oldmetric == 1 &&
  1663. met > MAX_NARROW_LINK_METRIC)
  1664. {
  1665. vty_out (vty, "Invalid metric %d - should be <0-63> "
  1666. "when narrow metric type enabled%s",
  1667. met, VTY_NEWLINE);
  1668. return CMD_ERR_AMBIGUOUS;
  1669. }
  1670. /* RFC4444 */
  1671. if (circuit->area && circuit->area->newmetric == 1 &&
  1672. met > MAX_WIDE_LINK_METRIC)
  1673. {
  1674. vty_out (vty, "Invalid metric %d - should be <0-16777215> "
  1675. "when wide metric type enabled%s",
  1676. met, VTY_NEWLINE);
  1677. return CMD_ERR_AMBIGUOUS;
  1678. }
  1679. circuit->te_metric[0] = met;
  1680. circuit->metrics[0].metric_default = met;
  1681. if (circuit->area)
  1682. lsp_regenerate_schedule (circuit->area, IS_LEVEL_1, 0);
  1683. return CMD_SUCCESS;
  1684. }
  1685. DEFUN (no_isis_metric_l1,
  1686. no_isis_metric_l1_cmd,
  1687. "no isis metric level-1",
  1688. NO_STR
  1689. "IS-IS commands\n"
  1690. "Set default metric for circuit\n"
  1691. "Specify metric for level-1 routing\n")
  1692. {
  1693. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  1694. if (!circuit)
  1695. return CMD_ERR_NO_MATCH;
  1696. circuit->te_metric[0] = DEFAULT_CIRCUIT_METRIC;
  1697. circuit->metrics[0].metric_default = DEFAULT_CIRCUIT_METRIC;
  1698. if (circuit->area)
  1699. lsp_regenerate_schedule (circuit->area, IS_LEVEL_1, 0);
  1700. return CMD_SUCCESS;
  1701. }
  1702. ALIAS (no_isis_metric_l1,
  1703. no_isis_metric_l1_arg_cmd,
  1704. "no isis metric <0-16777215> level-1",
  1705. NO_STR
  1706. "IS-IS commands\n"
  1707. "Set default metric for circuit\n"
  1708. "Default metric value\n"
  1709. "Specify metric for level-1 routing\n")
  1710. DEFUN (isis_metric_l2,
  1711. isis_metric_l2_cmd,
  1712. "isis metric <0-16777215> level-2",
  1713. "IS-IS commands\n"
  1714. "Set default metric for circuit\n"
  1715. "Default metric value\n"
  1716. "Specify metric for level-2 routing\n")
  1717. {
  1718. int met;
  1719. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  1720. if (!circuit)
  1721. return CMD_ERR_NO_MATCH;
  1722. met = atoi (argv[0]);
  1723. /* RFC3787 section 5.1 */
  1724. if (circuit->area && circuit->area->oldmetric == 1 &&
  1725. met > MAX_NARROW_LINK_METRIC)
  1726. {
  1727. vty_out (vty, "Invalid metric %d - should be <0-63> "
  1728. "when narrow metric type enabled%s",
  1729. met, VTY_NEWLINE);
  1730. return CMD_ERR_AMBIGUOUS;
  1731. }
  1732. /* RFC4444 */
  1733. if (circuit->area && circuit->area->newmetric == 1 &&
  1734. met > MAX_WIDE_LINK_METRIC)
  1735. {
  1736. vty_out (vty, "Invalid metric %d - should be <0-16777215> "
  1737. "when wide metric type enabled%s",
  1738. met, VTY_NEWLINE);
  1739. return CMD_ERR_AMBIGUOUS;
  1740. }
  1741. circuit->te_metric[1] = met;
  1742. circuit->metrics[1].metric_default = met;
  1743. if (circuit->area)
  1744. lsp_regenerate_schedule (circuit->area, IS_LEVEL_2, 0);
  1745. return CMD_SUCCESS;
  1746. }
  1747. DEFUN (no_isis_metric_l2,
  1748. no_isis_metric_l2_cmd,
  1749. "no isis metric level-2",
  1750. NO_STR
  1751. "IS-IS commands\n"
  1752. "Set default metric for circuit\n"
  1753. "Specify metric for level-2 routing\n")
  1754. {
  1755. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  1756. if (!circuit)
  1757. return CMD_ERR_NO_MATCH;
  1758. circuit->te_metric[1] = DEFAULT_CIRCUIT_METRIC;
  1759. circuit->metrics[1].metric_default = DEFAULT_CIRCUIT_METRIC;
  1760. if (circuit->area)
  1761. lsp_regenerate_schedule (circuit->area, IS_LEVEL_2, 0);
  1762. return CMD_SUCCESS;
  1763. }
  1764. ALIAS (no_isis_metric_l2,
  1765. no_isis_metric_l2_arg_cmd,
  1766. "no isis metric <0-16777215> level-2",
  1767. NO_STR
  1768. "IS-IS commands\n"
  1769. "Set default metric for circuit\n"
  1770. "Default metric value\n"
  1771. "Specify metric for level-2 routing\n")
  1772. /* end of metrics */
  1773. DEFUN (isis_hello_interval,
  1774. isis_hello_interval_cmd,
  1775. "isis hello-interval <1-600>",
  1776. "IS-IS commands\n"
  1777. "Set Hello interval\n"
  1778. "Hello interval value\n"
  1779. "Holdtime 1 seconds, interval depends on multiplier\n")
  1780. {
  1781. int interval;
  1782. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  1783. if (!circuit)
  1784. return CMD_ERR_NO_MATCH;
  1785. interval = atoi (argv[0]);
  1786. if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL)
  1787. {
  1788. vty_out (vty, "Invalid hello-interval %d - should be <1-600>%s",
  1789. interval, VTY_NEWLINE);
  1790. return CMD_ERR_AMBIGUOUS;
  1791. }
  1792. circuit->hello_interval[0] = (u_int16_t) interval;
  1793. circuit->hello_interval[1] = (u_int16_t) interval;
  1794. return CMD_SUCCESS;
  1795. }
  1796. DEFUN (no_isis_hello_interval,
  1797. no_isis_hello_interval_cmd,
  1798. "no isis hello-interval",
  1799. NO_STR
  1800. "IS-IS commands\n"
  1801. "Set Hello interval\n")
  1802. {
  1803. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  1804. if (!circuit)
  1805. return CMD_ERR_NO_MATCH;
  1806. circuit->hello_interval[0] = DEFAULT_HELLO_INTERVAL;
  1807. circuit->hello_interval[1] = DEFAULT_HELLO_INTERVAL;
  1808. return CMD_SUCCESS;
  1809. }
  1810. ALIAS (no_isis_hello_interval,
  1811. no_isis_hello_interval_arg_cmd,
  1812. "no isis hello-interval <1-600>",
  1813. NO_STR
  1814. "IS-IS commands\n"
  1815. "Set Hello interval\n"
  1816. "Hello interval value\n"
  1817. "Holdtime 1 second, interval depends on multiplier\n")
  1818. DEFUN (isis_hello_interval_l1,
  1819. isis_hello_interval_l1_cmd,
  1820. "isis hello-interval <1-600> level-1",
  1821. "IS-IS commands\n"
  1822. "Set Hello interval\n"
  1823. "Hello interval value\n"
  1824. "Holdtime 1 second, interval depends on multiplier\n"
  1825. "Specify hello-interval for level-1 IIHs\n")
  1826. {
  1827. long interval;
  1828. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  1829. if (!circuit)
  1830. return CMD_ERR_NO_MATCH;
  1831. interval = atoi (argv[0]);
  1832. if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL)
  1833. {
  1834. vty_out (vty, "Invalid hello-interval %ld - should be <1-600>%s",
  1835. interval, VTY_NEWLINE);
  1836. return CMD_ERR_AMBIGUOUS;
  1837. }
  1838. circuit->hello_interval[0] = (u_int16_t) interval;
  1839. return CMD_SUCCESS;
  1840. }
  1841. DEFUN (no_isis_hello_interval_l1,
  1842. no_isis_hello_interval_l1_cmd,
  1843. "no isis hello-interval level-1",
  1844. NO_STR
  1845. "IS-IS commands\n"
  1846. "Set Hello interval\n"
  1847. "Specify hello-interval for level-1 IIHs\n")
  1848. {
  1849. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  1850. if (!circuit)
  1851. return CMD_ERR_NO_MATCH;
  1852. circuit->hello_interval[0] = DEFAULT_HELLO_INTERVAL;
  1853. return CMD_SUCCESS;
  1854. }
  1855. ALIAS (no_isis_hello_interval_l1,
  1856. no_isis_hello_interval_l1_arg_cmd,
  1857. "no isis hello-interval <1-600> level-1",
  1858. NO_STR
  1859. "IS-IS commands\n"
  1860. "Set Hello interval\n"
  1861. "Hello interval value\n"
  1862. "Holdtime 1 second, interval depends on multiplier\n"
  1863. "Specify hello-interval for level-1 IIHs\n")
  1864. DEFUN (isis_hello_interval_l2,
  1865. isis_hello_interval_l2_cmd,
  1866. "isis hello-interval <1-600> level-2",
  1867. "IS-IS commands\n"
  1868. "Set Hello interval\n"
  1869. "Hello interval value\n"
  1870. "Holdtime 1 second, interval depends on multiplier\n"
  1871. "Specify hello-interval for level-2 IIHs\n")
  1872. {
  1873. long interval;
  1874. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  1875. if (!circuit)
  1876. return CMD_ERR_NO_MATCH;
  1877. interval = atoi (argv[0]);
  1878. if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL)
  1879. {
  1880. vty_out (vty, "Invalid hello-interval %ld - should be <1-600>%s",
  1881. interval, VTY_NEWLINE);
  1882. return CMD_ERR_AMBIGUOUS;
  1883. }
  1884. circuit->hello_interval[1] = (u_int16_t) interval;
  1885. return CMD_SUCCESS;
  1886. }
  1887. DEFUN (no_isis_hello_interval_l2,
  1888. no_isis_hello_interval_l2_cmd,
  1889. "no isis hello-interval level-2",
  1890. NO_STR
  1891. "IS-IS commands\n"
  1892. "Set Hello interval\n"
  1893. "Specify hello-interval for level-2 IIHs\n")
  1894. {
  1895. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  1896. if (!circuit)
  1897. return CMD_ERR_NO_MATCH;
  1898. circuit->hello_interval[1] = DEFAULT_HELLO_INTERVAL;
  1899. return CMD_SUCCESS;
  1900. }
  1901. ALIAS (no_isis_hello_interval_l2,
  1902. no_isis_hello_interval_l2_arg_cmd,
  1903. "no isis hello-interval <1-600> level-2",
  1904. NO_STR
  1905. "IS-IS commands\n"
  1906. "Set Hello interval\n"
  1907. "Hello interval value\n"
  1908. "Holdtime 1 second, interval depends on multiplier\n"
  1909. "Specify hello-interval for level-2 IIHs\n")
  1910. DEFUN (isis_hello_multiplier,
  1911. isis_hello_multiplier_cmd,
  1912. "isis hello-multiplier <2-100>",
  1913. "IS-IS commands\n"
  1914. "Set multiplier for Hello holding time\n"
  1915. "Hello multiplier value\n")
  1916. {
  1917. int mult;
  1918. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  1919. if (!circuit)
  1920. return CMD_ERR_NO_MATCH;
  1921. mult = atoi (argv[0]);
  1922. if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER)
  1923. {
  1924. vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>%s",
  1925. mult, VTY_NEWLINE);
  1926. return CMD_ERR_AMBIGUOUS;
  1927. }
  1928. circuit->hello_multiplier[0] = (u_int16_t) mult;
  1929. circuit->hello_multiplier[1] = (u_int16_t) mult;
  1930. return CMD_SUCCESS;
  1931. }
  1932. DEFUN (no_isis_hello_multiplier,
  1933. no_isis_hello_multiplier_cmd,
  1934. "no isis hello-multiplier",
  1935. NO_STR
  1936. "IS-IS commands\n"
  1937. "Set multiplier for Hello holding time\n")
  1938. {
  1939. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  1940. if (!circuit)
  1941. return CMD_ERR_NO_MATCH;
  1942. circuit->hello_multiplier[0] = DEFAULT_HELLO_MULTIPLIER;
  1943. circuit->hello_multiplier[1] = DEFAULT_HELLO_MULTIPLIER;
  1944. return CMD_SUCCESS;
  1945. }
  1946. ALIAS (no_isis_hello_multiplier,
  1947. no_isis_hello_multiplier_arg_cmd,
  1948. "no isis hello-multiplier <2-100>",
  1949. NO_STR
  1950. "IS-IS commands\n"
  1951. "Set multiplier for Hello holding time\n"
  1952. "Hello multiplier value\n")
  1953. DEFUN (isis_hello_multiplier_l1,
  1954. isis_hello_multiplier_l1_cmd,
  1955. "isis hello-multiplier <2-100> level-1",
  1956. "IS-IS commands\n"
  1957. "Set multiplier for Hello holding time\n"
  1958. "Hello multiplier value\n"
  1959. "Specify hello multiplier for level-1 IIHs\n")
  1960. {
  1961. int mult;
  1962. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  1963. if (!circuit)
  1964. return CMD_ERR_NO_MATCH;
  1965. mult = atoi (argv[0]);
  1966. if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER)
  1967. {
  1968. vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>%s",
  1969. mult, VTY_NEWLINE);
  1970. return CMD_ERR_AMBIGUOUS;
  1971. }
  1972. circuit->hello_multiplier[0] = (u_int16_t) mult;
  1973. return CMD_SUCCESS;
  1974. }
  1975. DEFUN (no_isis_hello_multiplier_l1,
  1976. no_isis_hello_multiplier_l1_cmd,
  1977. "no isis hello-multiplier level-1",
  1978. NO_STR
  1979. "IS-IS commands\n"
  1980. "Set multiplier for Hello holding time\n"
  1981. "Specify hello multiplier for level-1 IIHs\n")
  1982. {
  1983. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  1984. if (!circuit)
  1985. return CMD_ERR_NO_MATCH;
  1986. circuit->hello_multiplier[0] = DEFAULT_HELLO_MULTIPLIER;
  1987. return CMD_SUCCESS;
  1988. }
  1989. ALIAS (no_isis_hello_multiplier_l1,
  1990. no_isis_hello_multiplier_l1_arg_cmd,
  1991. "no isis hello-multiplier <2-100> level-1",
  1992. NO_STR
  1993. "IS-IS commands\n"
  1994. "Set multiplier for Hello holding time\n"
  1995. "Hello multiplier value\n"
  1996. "Specify hello multiplier for level-1 IIHs\n")
  1997. DEFUN (isis_hello_multiplier_l2,
  1998. isis_hello_multiplier_l2_cmd,
  1999. "isis hello-multiplier <2-100> level-2",
  2000. "IS-IS commands\n"
  2001. "Set multiplier for Hello holding time\n"
  2002. "Hello multiplier value\n"
  2003. "Specify hello multiplier for level-2 IIHs\n")
  2004. {
  2005. int mult;
  2006. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  2007. if (!circuit)
  2008. return CMD_ERR_NO_MATCH;
  2009. mult = atoi (argv[0]);
  2010. if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER)
  2011. {
  2012. vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>%s",
  2013. mult, VTY_NEWLINE);
  2014. return CMD_ERR_AMBIGUOUS;
  2015. }
  2016. circuit->hello_multiplier[1] = (u_int16_t) mult;
  2017. return CMD_SUCCESS;
  2018. }
  2019. DEFUN (no_isis_hello_multiplier_l2,
  2020. no_isis_hello_multiplier_l2_cmd,
  2021. "no isis hello-multiplier level-2",
  2022. NO_STR
  2023. "IS-IS commands\n"
  2024. "Set multiplier for Hello holding time\n"
  2025. "Specify hello multiplier for level-2 IIHs\n")
  2026. {
  2027. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  2028. if (!circuit)
  2029. return CMD_ERR_NO_MATCH;
  2030. circuit->hello_multiplier[1] = DEFAULT_HELLO_MULTIPLIER;
  2031. return CMD_SUCCESS;
  2032. }
  2033. ALIAS (no_isis_hello_multiplier_l2,
  2034. no_isis_hello_multiplier_l2_arg_cmd,
  2035. "no isis hello-multiplier <2-100> level-2",
  2036. NO_STR
  2037. "IS-IS commands\n"
  2038. "Set multiplier for Hello holding time\n"
  2039. "Hello multiplier value\n"
  2040. "Specify hello multiplier for level-2 IIHs\n")
  2041. DEFUN (isis_hello_padding,
  2042. isis_hello_padding_cmd,
  2043. "isis hello padding",
  2044. "IS-IS commands\n"
  2045. "Add padding to IS-IS hello packets\n"
  2046. "Pad hello packets\n"
  2047. "<cr>\n")
  2048. {
  2049. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  2050. if (!circuit)
  2051. return CMD_ERR_NO_MATCH;
  2052. circuit->pad_hellos = 1;
  2053. return CMD_SUCCESS;
  2054. }
  2055. DEFUN (no_isis_hello_padding,
  2056. no_isis_hello_padding_cmd,
  2057. "no isis hello padding",
  2058. NO_STR
  2059. "IS-IS commands\n"
  2060. "Add padding to IS-IS hello packets\n"
  2061. "Pad hello packets\n"
  2062. "<cr>\n")
  2063. {
  2064. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  2065. if (!circuit)
  2066. return CMD_ERR_NO_MATCH;
  2067. circuit->pad_hellos = 0;
  2068. return CMD_SUCCESS;
  2069. }
  2070. DEFUN (csnp_interval,
  2071. csnp_interval_cmd,
  2072. "isis csnp-interval <1-600>",
  2073. "IS-IS commands\n"
  2074. "Set CSNP interval in seconds\n"
  2075. "CSNP interval value\n")
  2076. {
  2077. unsigned long interval;
  2078. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  2079. if (!circuit)
  2080. return CMD_ERR_NO_MATCH;
  2081. interval = atol (argv[0]);
  2082. if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL)
  2083. {
  2084. vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>%s",
  2085. interval, VTY_NEWLINE);
  2086. return CMD_ERR_AMBIGUOUS;
  2087. }
  2088. circuit->csnp_interval[0] = (u_int16_t) interval;
  2089. circuit->csnp_interval[1] = (u_int16_t) interval;
  2090. return CMD_SUCCESS;
  2091. }
  2092. DEFUN (no_csnp_interval,
  2093. no_csnp_interval_cmd,
  2094. "no isis csnp-interval",
  2095. NO_STR
  2096. "IS-IS commands\n"
  2097. "Set CSNP interval in seconds\n")
  2098. {
  2099. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  2100. if (!circuit)
  2101. return CMD_ERR_NO_MATCH;
  2102. circuit->csnp_interval[0] = DEFAULT_CSNP_INTERVAL;
  2103. circuit->csnp_interval[1] = DEFAULT_CSNP_INTERVAL;
  2104. return CMD_SUCCESS;
  2105. }
  2106. ALIAS (no_csnp_interval,
  2107. no_csnp_interval_arg_cmd,
  2108. "no isis csnp-interval <1-600>",
  2109. NO_STR
  2110. "IS-IS commands\n"
  2111. "Set CSNP interval in seconds\n"
  2112. "CSNP interval value\n")
  2113. DEFUN (csnp_interval_l1,
  2114. csnp_interval_l1_cmd,
  2115. "isis csnp-interval <1-600> level-1",
  2116. "IS-IS commands\n"
  2117. "Set CSNP interval in seconds\n"
  2118. "CSNP interval value\n"
  2119. "Specify interval for level-1 CSNPs\n")
  2120. {
  2121. unsigned long interval;
  2122. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  2123. if (!circuit)
  2124. return CMD_ERR_NO_MATCH;
  2125. interval = atol (argv[0]);
  2126. if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL)
  2127. {
  2128. vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>%s",
  2129. interval, VTY_NEWLINE);
  2130. return CMD_ERR_AMBIGUOUS;
  2131. }
  2132. circuit->csnp_interval[0] = (u_int16_t) interval;
  2133. return CMD_SUCCESS;
  2134. }
  2135. DEFUN (no_csnp_interval_l1,
  2136. no_csnp_interval_l1_cmd,
  2137. "no isis csnp-interval level-1",
  2138. NO_STR
  2139. "IS-IS commands\n"
  2140. "Set CSNP interval in seconds\n"
  2141. "Specify interval for level-1 CSNPs\n")
  2142. {
  2143. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  2144. if (!circuit)
  2145. return CMD_ERR_NO_MATCH;
  2146. circuit->csnp_interval[0] = DEFAULT_CSNP_INTERVAL;
  2147. return CMD_SUCCESS;
  2148. }
  2149. ALIAS (no_csnp_interval_l1,
  2150. no_csnp_interval_l1_arg_cmd,
  2151. "no isis csnp-interval <1-600> level-1",
  2152. NO_STR
  2153. "IS-IS commands\n"
  2154. "Set CSNP interval in seconds\n"
  2155. "CSNP interval value\n"
  2156. "Specify interval for level-1 CSNPs\n")
  2157. DEFUN (csnp_interval_l2,
  2158. csnp_interval_l2_cmd,
  2159. "isis csnp-interval <1-600> level-2",
  2160. "IS-IS commands\n"
  2161. "Set CSNP interval in seconds\n"
  2162. "CSNP interval value\n"
  2163. "Specify interval for level-2 CSNPs\n")
  2164. {
  2165. unsigned long interval;
  2166. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  2167. if (!circuit)
  2168. return CMD_ERR_NO_MATCH;
  2169. interval = atol (argv[0]);
  2170. if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL)
  2171. {
  2172. vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>%s",
  2173. interval, VTY_NEWLINE);
  2174. return CMD_ERR_AMBIGUOUS;
  2175. }
  2176. circuit->csnp_interval[1] = (u_int16_t) interval;
  2177. return CMD_SUCCESS;
  2178. }
  2179. DEFUN (no_csnp_interval_l2,
  2180. no_csnp_interval_l2_cmd,
  2181. "no isis csnp-interval level-2",
  2182. NO_STR
  2183. "IS-IS commands\n"
  2184. "Set CSNP interval in seconds\n"
  2185. "Specify interval for level-2 CSNPs\n")
  2186. {
  2187. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  2188. if (!circuit)
  2189. return CMD_ERR_NO_MATCH;
  2190. circuit->csnp_interval[1] = DEFAULT_CSNP_INTERVAL;
  2191. return CMD_SUCCESS;
  2192. }
  2193. ALIAS (no_csnp_interval_l2,
  2194. no_csnp_interval_l2_arg_cmd,
  2195. "no isis csnp-interval <1-600> level-2",
  2196. NO_STR
  2197. "IS-IS commands\n"
  2198. "Set CSNP interval in seconds\n"
  2199. "CSNP interval value\n"
  2200. "Specify interval for level-2 CSNPs\n")
  2201. DEFUN (psnp_interval,
  2202. psnp_interval_cmd,
  2203. "isis psnp-interval <1-120>",
  2204. "IS-IS commands\n"
  2205. "Set PSNP interval in seconds\n"
  2206. "PSNP interval value\n")
  2207. {
  2208. unsigned long interval;
  2209. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  2210. if (!circuit)
  2211. return CMD_ERR_NO_MATCH;
  2212. interval = atol (argv[0]);
  2213. if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL)
  2214. {
  2215. vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>%s",
  2216. interval, VTY_NEWLINE);
  2217. return CMD_ERR_AMBIGUOUS;
  2218. }
  2219. circuit->psnp_interval[0] = (u_int16_t) interval;
  2220. circuit->psnp_interval[1] = (u_int16_t) interval;
  2221. return CMD_SUCCESS;
  2222. }
  2223. DEFUN (no_psnp_interval,
  2224. no_psnp_interval_cmd,
  2225. "no isis psnp-interval",
  2226. NO_STR
  2227. "IS-IS commands\n"
  2228. "Set PSNP interval in seconds\n")
  2229. {
  2230. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  2231. if (!circuit)
  2232. return CMD_ERR_NO_MATCH;
  2233. circuit->psnp_interval[0] = DEFAULT_PSNP_INTERVAL;
  2234. circuit->psnp_interval[1] = DEFAULT_PSNP_INTERVAL;
  2235. return CMD_SUCCESS;
  2236. }
  2237. ALIAS (no_psnp_interval,
  2238. no_psnp_interval_arg_cmd,
  2239. "no isis psnp-interval <1-120>",
  2240. NO_STR
  2241. "IS-IS commands\n"
  2242. "Set PSNP interval in seconds\n"
  2243. "PSNP interval value\n")
  2244. DEFUN (psnp_interval_l1,
  2245. psnp_interval_l1_cmd,
  2246. "isis psnp-interval <1-120> level-1",
  2247. "IS-IS commands\n"
  2248. "Set PSNP interval in seconds\n"
  2249. "PSNP interval value\n"
  2250. "Specify interval for level-1 PSNPs\n")
  2251. {
  2252. unsigned long interval;
  2253. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  2254. if (!circuit)
  2255. return CMD_ERR_NO_MATCH;
  2256. interval = atol (argv[0]);
  2257. if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL)
  2258. {
  2259. vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>%s",
  2260. interval, VTY_NEWLINE);
  2261. return CMD_ERR_AMBIGUOUS;
  2262. }
  2263. circuit->psnp_interval[0] = (u_int16_t) interval;
  2264. return CMD_SUCCESS;
  2265. }
  2266. DEFUN (no_psnp_interval_l1,
  2267. no_psnp_interval_l1_cmd,
  2268. "no isis psnp-interval level-1",
  2269. NO_STR
  2270. "IS-IS commands\n"
  2271. "Set PSNP interval in seconds\n"
  2272. "Specify interval for level-1 PSNPs\n")
  2273. {
  2274. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  2275. if (!circuit)
  2276. return CMD_ERR_NO_MATCH;
  2277. circuit->psnp_interval[0] = DEFAULT_PSNP_INTERVAL;
  2278. return CMD_SUCCESS;
  2279. }
  2280. ALIAS (no_psnp_interval_l1,
  2281. no_psnp_interval_l1_arg_cmd,
  2282. "no isis psnp-interval <1-120> level-1",
  2283. NO_STR
  2284. "IS-IS commands\n"
  2285. "Set PSNP interval in seconds\n"
  2286. "PSNP interval value\n"
  2287. "Specify interval for level-1 PSNPs\n")
  2288. DEFUN (psnp_interval_l2,
  2289. psnp_interval_l2_cmd,
  2290. "isis psnp-interval <1-120> level-2",
  2291. "IS-IS commands\n"
  2292. "Set PSNP interval in seconds\n"
  2293. "PSNP interval value\n"
  2294. "Specify interval for level-2 PSNPs\n")
  2295. {
  2296. unsigned long interval;
  2297. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  2298. if (!circuit)
  2299. return CMD_ERR_NO_MATCH;
  2300. interval = atol (argv[0]);
  2301. if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL)
  2302. {
  2303. vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>%s",
  2304. interval, VTY_NEWLINE);
  2305. return CMD_ERR_AMBIGUOUS;
  2306. }
  2307. circuit->psnp_interval[1] = (u_int16_t) interval;
  2308. return CMD_SUCCESS;
  2309. }
  2310. DEFUN (no_psnp_interval_l2,
  2311. no_psnp_interval_l2_cmd,
  2312. "no isis psnp-interval level-2",
  2313. NO_STR
  2314. "IS-IS commands\n"
  2315. "Set PSNP interval in seconds\n"
  2316. "Specify interval for level-2 PSNPs\n")
  2317. {
  2318. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  2319. if (!circuit)
  2320. return CMD_ERR_NO_MATCH;
  2321. circuit->psnp_interval[1] = DEFAULT_PSNP_INTERVAL;
  2322. return CMD_SUCCESS;
  2323. }
  2324. ALIAS (no_psnp_interval_l2,
  2325. no_psnp_interval_l2_arg_cmd,
  2326. "no isis psnp-interval <1-120> level-2",
  2327. NO_STR
  2328. "IS-IS commands\n"
  2329. "Set PSNP interval in seconds\n"
  2330. "PSNP interval value\n"
  2331. "Specify interval for level-2 PSNPs\n")
  2332. struct cmd_node interface_node = {
  2333. INTERFACE_NODE,
  2334. "%s(config-if)# ",
  2335. 1,
  2336. };
  2337. DEFUN (isis_network,
  2338. isis_network_cmd,
  2339. "isis network point-to-point",
  2340. "IS-IS commands\n"
  2341. "Set network type\n"
  2342. "point-to-point network type\n")
  2343. {
  2344. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  2345. if (!circuit)
  2346. return CMD_ERR_NO_MATCH;
  2347. /* RFC5309 section 4 */
  2348. if (circuit->circ_type == CIRCUIT_T_P2P)
  2349. return CMD_SUCCESS;
  2350. if (circuit->state != C_STATE_UP)
  2351. {
  2352. circuit->circ_type = CIRCUIT_T_P2P;
  2353. circuit->circ_type_config = CIRCUIT_T_P2P;
  2354. }
  2355. else
  2356. {
  2357. struct isis_area *area = circuit->area;
  2358. if (!if_is_broadcast (circuit->interface))
  2359. {
  2360. vty_out (vty, "isis network point-to-point "
  2361. "is valid only on broadcast interfaces%s",
  2362. VTY_NEWLINE);
  2363. return CMD_ERR_AMBIGUOUS;
  2364. }
  2365. isis_csm_state_change (ISIS_DISABLE, circuit, area);
  2366. circuit->circ_type = CIRCUIT_T_P2P;
  2367. circuit->circ_type_config = CIRCUIT_T_P2P;
  2368. isis_csm_state_change (ISIS_ENABLE, circuit, area);
  2369. }
  2370. return CMD_SUCCESS;
  2371. }
  2372. DEFUN (no_isis_network,
  2373. no_isis_network_cmd,
  2374. "no isis network point-to-point",
  2375. NO_STR
  2376. "IS-IS commands\n"
  2377. "Set network type for circuit\n"
  2378. "point-to-point network type\n")
  2379. {
  2380. struct isis_circuit *circuit = isis_circuit_lookup (vty);
  2381. if (!circuit)
  2382. return CMD_ERR_NO_MATCH;
  2383. /* RFC5309 section 4 */
  2384. if (circuit->circ_type == CIRCUIT_T_BROADCAST)
  2385. return CMD_SUCCESS;
  2386. if (circuit->state != C_STATE_UP)
  2387. {
  2388. circuit->circ_type = CIRCUIT_T_BROADCAST;
  2389. circuit->circ_type_config = CIRCUIT_T_BROADCAST;
  2390. }
  2391. else
  2392. {
  2393. struct isis_area *area = circuit->area;
  2394. if (circuit->interface &&
  2395. !if_is_broadcast (circuit->interface))
  2396. {
  2397. vty_out (vty, "no isis network point-to-point "
  2398. "is valid only on broadcast interfaces%s",
  2399. VTY_NEWLINE);
  2400. return CMD_ERR_AMBIGUOUS;
  2401. }
  2402. isis_csm_state_change (ISIS_DISABLE, circuit, area);
  2403. circuit->circ_type = CIRCUIT_T_BROADCAST;
  2404. circuit->circ_type_config = CIRCUIT_T_BROADCAST;
  2405. isis_csm_state_change (ISIS_ENABLE, circuit, area);
  2406. }
  2407. return CMD_SUCCESS;
  2408. }
  2409. int
  2410. isis_if_new_hook (struct interface *ifp)
  2411. {
  2412. return 0;
  2413. }
  2414. int
  2415. isis_if_delete_hook (struct interface *ifp)
  2416. {
  2417. struct isis_circuit *circuit;
  2418. /* Clean up the circuit data */
  2419. if (ifp && ifp->info)
  2420. {
  2421. circuit = ifp->info;
  2422. isis_csm_state_change (IF_DOWN_FROM_Z, circuit, circuit->area);
  2423. isis_csm_state_change (ISIS_DISABLE, circuit, circuit->area);
  2424. }
  2425. return 0;
  2426. }
  2427. void
  2428. isis_circuit_init ()
  2429. {
  2430. /* Initialize Zebra interface data structure */
  2431. if_add_hook (IF_NEW_HOOK, isis_if_new_hook);
  2432. if_add_hook (IF_DELETE_HOOK, isis_if_delete_hook);
  2433. /* Install interface node */
  2434. install_node (&interface_node, isis_interface_config_write);
  2435. install_element (CONFIG_NODE, &interface_cmd);
  2436. install_element (CONFIG_NODE, &no_interface_cmd);
  2437. install_default (INTERFACE_NODE);
  2438. install_element (INTERFACE_NODE, &interface_desc_cmd);
  2439. install_element (INTERFACE_NODE, &no_interface_desc_cmd);
  2440. install_element (INTERFACE_NODE, &ip_router_isis_cmd);
  2441. install_element (INTERFACE_NODE, &no_ip_router_isis_cmd);
  2442. install_element (INTERFACE_NODE, &isis_passive_cmd);
  2443. install_element (INTERFACE_NODE, &no_isis_passive_cmd);
  2444. install_element (INTERFACE_NODE, &isis_circuit_type_cmd);
  2445. install_element (INTERFACE_NODE, &no_isis_circuit_type_cmd);
  2446. install_element (INTERFACE_NODE, &isis_passwd_clear_cmd);
  2447. install_element (INTERFACE_NODE, &isis_passwd_md5_cmd);
  2448. install_element (INTERFACE_NODE, &no_isis_passwd_cmd);
  2449. install_element (INTERFACE_NODE, &isis_priority_cmd);
  2450. install_element (INTERFACE_NODE, &no_isis_priority_cmd);
  2451. install_element (INTERFACE_NODE, &no_isis_priority_arg_cmd);
  2452. install_element (INTERFACE_NODE, &isis_priority_l1_cmd);
  2453. install_element (INTERFACE_NODE, &no_isis_priority_l1_cmd);
  2454. install_element (INTERFACE_NODE, &no_isis_priority_l1_arg_cmd);
  2455. install_element (INTERFACE_NODE, &isis_priority_l2_cmd);
  2456. install_element (INTERFACE_NODE, &no_isis_priority_l2_cmd);
  2457. install_element (INTERFACE_NODE, &no_isis_priority_l2_arg_cmd);
  2458. install_element (INTERFACE_NODE, &isis_metric_cmd);
  2459. install_element (INTERFACE_NODE, &no_isis_metric_cmd);
  2460. install_element (INTERFACE_NODE, &no_isis_metric_arg_cmd);
  2461. install_element (INTERFACE_NODE, &isis_metric_l1_cmd);
  2462. install_element (INTERFACE_NODE, &no_isis_metric_l1_cmd);
  2463. install_element (INTERFACE_NODE, &no_isis_metric_l1_arg_cmd);
  2464. install_element (INTERFACE_NODE, &isis_metric_l2_cmd);
  2465. install_element (INTERFACE_NODE, &no_isis_metric_l2_cmd);
  2466. install_element (INTERFACE_NODE, &no_isis_metric_l2_arg_cmd);
  2467. install_element (INTERFACE_NODE, &isis_hello_interval_cmd);
  2468. install_element (INTERFACE_NODE, &no_isis_hello_interval_cmd);
  2469. install_element (INTERFACE_NODE, &no_isis_hello_interval_arg_cmd);
  2470. install_element (INTERFACE_NODE, &isis_hello_interval_l1_cmd);
  2471. install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_cmd);
  2472. install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_arg_cmd);
  2473. install_element (INTERFACE_NODE, &isis_hello_interval_l2_cmd);
  2474. install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_cmd);
  2475. install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_arg_cmd);
  2476. install_element (INTERFACE_NODE, &isis_hello_multiplier_cmd);
  2477. install_element (INTERFACE_NODE, &no_isis_hello_multiplier_cmd);
  2478. install_element (INTERFACE_NODE, &no_isis_hello_multiplier_arg_cmd);
  2479. install_element (INTERFACE_NODE, &isis_hello_multiplier_l1_cmd);
  2480. install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_cmd);
  2481. install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_arg_cmd);
  2482. install_element (INTERFACE_NODE, &isis_hello_multiplier_l2_cmd);
  2483. install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_cmd);
  2484. install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_arg_cmd);
  2485. install_element (INTERFACE_NODE, &isis_hello_padding_cmd);
  2486. install_element (INTERFACE_NODE, &no_isis_hello_padding_cmd);
  2487. install_element (INTERFACE_NODE, &csnp_interval_cmd);
  2488. install_element (INTERFACE_NODE, &no_csnp_interval_cmd);
  2489. install_element (INTERFACE_NODE, &no_csnp_interval_arg_cmd);
  2490. install_element (INTERFACE_NODE, &csnp_interval_l1_cmd);
  2491. install_element (INTERFACE_NODE, &no_csnp_interval_l1_cmd);
  2492. install_element (INTERFACE_NODE, &no_csnp_interval_l1_arg_cmd);
  2493. install_element (INTERFACE_NODE, &csnp_interval_l2_cmd);
  2494. install_element (INTERFACE_NODE, &no_csnp_interval_l2_cmd);
  2495. install_element (INTERFACE_NODE, &no_csnp_interval_l2_arg_cmd);
  2496. install_element (INTERFACE_NODE, &psnp_interval_cmd);
  2497. install_element (INTERFACE_NODE, &no_psnp_interval_cmd);
  2498. install_element (INTERFACE_NODE, &no_psnp_interval_arg_cmd);
  2499. install_element (INTERFACE_NODE, &psnp_interval_l1_cmd);
  2500. install_element (INTERFACE_NODE, &no_psnp_interval_l1_cmd);
  2501. install_element (INTERFACE_NODE, &no_psnp_interval_l1_arg_cmd);
  2502. install_element (INTERFACE_NODE, &psnp_interval_l2_cmd);
  2503. install_element (INTERFACE_NODE, &no_psnp_interval_l2_cmd);
  2504. install_element (INTERFACE_NODE, &no_psnp_interval_l2_arg_cmd);
  2505. install_element (INTERFACE_NODE, &isis_network_cmd);
  2506. install_element (INTERFACE_NODE, &no_isis_network_cmd);
  2507. #ifdef HAVE_IPV6
  2508. install_element (INTERFACE_NODE, &ipv6_router_isis_cmd);
  2509. install_element (INTERFACE_NODE, &no_ipv6_router_isis_cmd);
  2510. #endif
  2511. }