isisd.c 87 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267
  1. /*
  2. * IS-IS Rout(e)ing protocol - isisd.c
  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. #include "thread.h"
  23. #include "vty.h"
  24. #include "command.h"
  25. #include "log.h"
  26. #include "memory.h"
  27. #include "time.h"
  28. #include "linklist.h"
  29. #include "if.h"
  30. #include "hash.h"
  31. #include "stream.h"
  32. #include "prefix.h"
  33. #include "table.h"
  34. #include "isisd/dict.h"
  35. #include "isisd/include-netbsd/iso.h"
  36. #include "isisd/isis_constants.h"
  37. #include "isisd/isis_common.h"
  38. #include "isisd/isis_flags.h"
  39. #include "isisd/isis_circuit.h"
  40. #include "isisd/isis_csm.h"
  41. #include "isisd/isisd.h"
  42. #include "isisd/isis_dynhn.h"
  43. #include "isisd/isis_adjacency.h"
  44. #include "isisd/isis_pdu.h"
  45. #include "isisd/isis_misc.h"
  46. #include "isisd/isis_constants.h"
  47. #include "isisd/isis_tlv.h"
  48. #include "isisd/isis_lsp.h"
  49. #include "isisd/isis_spf.h"
  50. #include "isisd/isis_route.h"
  51. #include "isisd/isis_zebra.h"
  52. #include "isisd/isis_events.h"
  53. #ifdef TOPOLOGY_GENERATE
  54. #include "spgrid.h"
  55. u_char DEFAULT_TOPOLOGY_BASEIS[6] = { 0xFE, 0xED, 0xFE, 0xED, 0x00, 0x00 };
  56. #endif /* TOPOLOGY_GENERATE */
  57. struct isis *isis = NULL;
  58. /*
  59. * Prototypes.
  60. */
  61. int isis_area_get(struct vty *, const char *);
  62. int isis_area_destroy(struct vty *, const char *);
  63. int area_net_title(struct vty *, const char *);
  64. int area_clear_net_title(struct vty *, const char *);
  65. int show_isis_interface_common(struct vty *, const char *ifname, char);
  66. int show_isis_neighbor_common(struct vty *, const char *id, char);
  67. int clear_isis_neighbor_common(struct vty *, const char *id);
  68. int isis_config_write(struct vty *);
  69. void
  70. isis_new (unsigned long process_id)
  71. {
  72. isis = XCALLOC (MTYPE_ISIS, sizeof (struct isis));
  73. /*
  74. * Default values
  75. */
  76. isis->max_area_addrs = 3;
  77. isis->process_id = process_id;
  78. isis->router_id = 0;
  79. isis->area_list = list_new ();
  80. isis->init_circ_list = list_new ();
  81. isis->uptime = time (NULL);
  82. isis->nexthops = list_new ();
  83. #ifdef HAVE_IPV6
  84. isis->nexthops6 = list_new ();
  85. #endif /* HAVE_IPV6 */
  86. dyn_cache_init ();
  87. /*
  88. * uncomment the next line for full debugs
  89. */
  90. /* isis->debugs = 0xFFFF; */
  91. }
  92. struct isis_area *
  93. isis_area_create (const char *area_tag)
  94. {
  95. struct isis_area *area;
  96. area = XCALLOC (MTYPE_ISIS_AREA, sizeof (struct isis_area));
  97. /*
  98. * The first instance is level-1-2 rest are level-1, unless otherwise
  99. * configured
  100. */
  101. if (listcount (isis->area_list) > 0)
  102. area->is_type = IS_LEVEL_1;
  103. else
  104. area->is_type = IS_LEVEL_1_AND_2;
  105. /*
  106. * intialize the databases
  107. */
  108. if (area->is_type & IS_LEVEL_1)
  109. {
  110. area->lspdb[0] = lsp_db_init ();
  111. area->route_table[0] = route_table_init ();
  112. #ifdef HAVE_IPV6
  113. area->route_table6[0] = route_table_init ();
  114. #endif /* HAVE_IPV6 */
  115. }
  116. if (area->is_type & IS_LEVEL_2)
  117. {
  118. area->lspdb[1] = lsp_db_init ();
  119. area->route_table[1] = route_table_init ();
  120. #ifdef HAVE_IPV6
  121. area->route_table6[1] = route_table_init ();
  122. #endif /* HAVE_IPV6 */
  123. }
  124. spftree_area_init (area);
  125. area->circuit_list = list_new ();
  126. area->area_addrs = list_new ();
  127. THREAD_TIMER_ON (master, area->t_tick, lsp_tick, area, 1);
  128. flags_initialize (&area->flags);
  129. /*
  130. * Default values
  131. */
  132. area->max_lsp_lifetime[0] = DEFAULT_LSP_LIFETIME; /* 1200 */
  133. area->max_lsp_lifetime[1] = DEFAULT_LSP_LIFETIME; /* 1200 */
  134. area->lsp_refresh[0] = DEFAULT_MAX_LSP_GEN_INTERVAL; /* 900 */
  135. area->lsp_refresh[1] = DEFAULT_MAX_LSP_GEN_INTERVAL; /* 900 */
  136. area->lsp_gen_interval[0] = DEFAULT_MIN_LSP_GEN_INTERVAL;
  137. area->lsp_gen_interval[1] = DEFAULT_MIN_LSP_GEN_INTERVAL;
  138. area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL;
  139. area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL;
  140. area->dynhostname = 1;
  141. area->oldmetric = 0;
  142. area->newmetric = 1;
  143. area->lsp_frag_threshold = 90;
  144. #ifdef TOPOLOGY_GENERATE
  145. memcpy (area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS, ISIS_SYS_ID_LEN);
  146. #endif /* TOPOLOGY_GENERATE */
  147. /* FIXME: Think of a better way... */
  148. area->min_bcast_mtu = 1497;
  149. area->area_tag = strdup (area_tag);
  150. listnode_add (isis->area_list, area);
  151. area->isis = isis;
  152. return area;
  153. }
  154. struct isis_area *
  155. isis_area_lookup (const char *area_tag)
  156. {
  157. struct isis_area *area;
  158. struct listnode *node;
  159. for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
  160. if ((area->area_tag == NULL && area_tag == NULL) ||
  161. (area->area_tag && area_tag
  162. && strcmp (area->area_tag, area_tag) == 0))
  163. return area;
  164. return NULL;
  165. }
  166. int
  167. isis_area_get (struct vty *vty, const char *area_tag)
  168. {
  169. struct isis_area *area;
  170. area = isis_area_lookup (area_tag);
  171. if (area)
  172. {
  173. vty->node = ISIS_NODE;
  174. vty->index = area;
  175. return CMD_SUCCESS;
  176. }
  177. area = isis_area_create (area_tag);
  178. if (isis->debugs & DEBUG_EVENTS)
  179. zlog_debug ("New IS-IS area instance %s", area->area_tag);
  180. vty->node = ISIS_NODE;
  181. vty->index = area;
  182. return CMD_SUCCESS;
  183. }
  184. int
  185. isis_area_destroy (struct vty *vty, const char *area_tag)
  186. {
  187. struct isis_area *area;
  188. struct listnode *node, *nnode;
  189. struct isis_circuit *circuit;
  190. struct area_addr *addr;
  191. area = isis_area_lookup (area_tag);
  192. if (area == NULL)
  193. {
  194. vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
  195. return CMD_ERR_NO_MATCH;
  196. }
  197. if (area->circuit_list)
  198. {
  199. for (ALL_LIST_ELEMENTS (area->circuit_list, node, nnode, circuit))
  200. {
  201. circuit->ip_router = 0;
  202. #ifdef HAVE_IPV6
  203. circuit->ipv6_router = 0;
  204. #endif
  205. isis_csm_state_change (ISIS_DISABLE, circuit, area);
  206. }
  207. list_delete (area->circuit_list);
  208. area->circuit_list = NULL;
  209. }
  210. if (area->lspdb[0] != NULL)
  211. {
  212. lsp_db_destroy (area->lspdb[0]);
  213. area->lspdb[0] = NULL;
  214. }
  215. if (area->lspdb[1] != NULL)
  216. {
  217. lsp_db_destroy (area->lspdb[1]);
  218. area->lspdb[1] = NULL;
  219. }
  220. spftree_area_del (area);
  221. /* invalidate and validate would delete all routes from zebra */
  222. isis_route_invalidate (area);
  223. isis_route_validate (area);
  224. if (area->route_table[0])
  225. {
  226. route_table_finish (area->route_table[0]);
  227. area->route_table[0] = NULL;
  228. }
  229. if (area->route_table[1])
  230. {
  231. route_table_finish (area->route_table[1]);
  232. area->route_table[1] = NULL;
  233. }
  234. #ifdef HAVE_IPV6
  235. if (area->route_table6[0])
  236. {
  237. route_table_finish (area->route_table6[0]);
  238. area->route_table6[0] = NULL;
  239. }
  240. if (area->route_table6[1])
  241. {
  242. route_table_finish (area->route_table6[1]);
  243. area->route_table6[1] = NULL;
  244. }
  245. #endif /* HAVE_IPV6 */
  246. for (ALL_LIST_ELEMENTS (area->area_addrs, node, nnode, addr))
  247. {
  248. list_delete_node (area->area_addrs, node);
  249. XFREE (MTYPE_ISIS_AREA_ADDR, addr);
  250. }
  251. area->area_addrs = NULL;
  252. THREAD_TIMER_OFF (area->t_tick);
  253. THREAD_TIMER_OFF (area->t_lsp_refresh[0]);
  254. THREAD_TIMER_OFF (area->t_lsp_refresh[1]);
  255. thread_cancel_event (master, area);
  256. listnode_delete (isis->area_list, area);
  257. free (area->area_tag);
  258. XFREE (MTYPE_ISIS_AREA, area);
  259. if (listcount (isis->area_list) == 0)
  260. {
  261. memset (isis->sysid, 0, ISIS_SYS_ID_LEN);
  262. isis->sysid_set = 0;
  263. }
  264. return CMD_SUCCESS;
  265. }
  266. int
  267. area_net_title (struct vty *vty, const char *net_title)
  268. {
  269. struct isis_area *area;
  270. struct area_addr *addr;
  271. struct area_addr *addrp;
  272. struct listnode *node;
  273. u_char buff[255];
  274. area = vty->index;
  275. if (!area)
  276. {
  277. vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
  278. return CMD_ERR_NO_MATCH;
  279. }
  280. /* We check that we are not over the maximal number of addresses */
  281. if (listcount (area->area_addrs) >= isis->max_area_addrs)
  282. {
  283. vty_out (vty, "Maximum of area addresses (%d) already reached %s",
  284. isis->max_area_addrs, VTY_NEWLINE);
  285. return CMD_ERR_NOTHING_TODO;
  286. }
  287. addr = XMALLOC (MTYPE_ISIS_AREA_ADDR, sizeof (struct area_addr));
  288. addr->addr_len = dotformat2buff (buff, net_title);
  289. memcpy (addr->area_addr, buff, addr->addr_len);
  290. #ifdef EXTREME_DEBUG
  291. zlog_debug ("added area address %s for area %s (address length %d)",
  292. net_title, area->area_tag, addr->addr_len);
  293. #endif /* EXTREME_DEBUG */
  294. if (addr->addr_len < 8 || addr->addr_len > 20)
  295. {
  296. vty_out (vty, "area address must be at least 8..20 octets long (%d)%s",
  297. addr->addr_len, VTY_NEWLINE);
  298. XFREE (MTYPE_ISIS_AREA_ADDR, addr);
  299. return CMD_ERR_AMBIGUOUS;
  300. }
  301. if (addr->area_addr[addr->addr_len-1] != 0)
  302. {
  303. vty_out (vty, "nsel byte (last byte) in area address must be 0%s",
  304. VTY_NEWLINE);
  305. XFREE (MTYPE_ISIS_AREA_ADDR, addr);
  306. return CMD_ERR_AMBIGUOUS;
  307. }
  308. if (isis->sysid_set == 0)
  309. {
  310. /*
  311. * First area address - get the SystemID for this router
  312. */
  313. memcpy (isis->sysid, GETSYSID (addr), ISIS_SYS_ID_LEN);
  314. isis->sysid_set = 1;
  315. if (isis->debugs & DEBUG_EVENTS)
  316. zlog_debug ("Router has SystemID %s", sysid_print (isis->sysid));
  317. }
  318. else
  319. {
  320. /*
  321. * Check that the SystemID portions match
  322. */
  323. if (memcmp (isis->sysid, GETSYSID (addr), ISIS_SYS_ID_LEN))
  324. {
  325. vty_out (vty,
  326. "System ID must not change when defining additional area"
  327. " addresses%s", VTY_NEWLINE);
  328. XFREE (MTYPE_ISIS_AREA_ADDR, addr);
  329. return CMD_ERR_AMBIGUOUS;
  330. }
  331. /* now we see that we don't already have this address */
  332. for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node, addrp))
  333. {
  334. if ((addrp->addr_len + ISIS_SYS_ID_LEN + ISIS_NSEL_LEN) != (addr->addr_len))
  335. continue;
  336. if (!memcmp (addrp->area_addr, addr->area_addr, addr->addr_len))
  337. {
  338. XFREE (MTYPE_ISIS_AREA_ADDR, addr);
  339. return CMD_SUCCESS; /* silent fail */
  340. }
  341. }
  342. }
  343. /*
  344. * Forget the systemID part of the address
  345. */
  346. addr->addr_len -= (ISIS_SYS_ID_LEN + ISIS_NSEL_LEN);
  347. listnode_add (area->area_addrs, addr);
  348. /* only now we can safely generate our LSPs for this area */
  349. if (listcount (area->area_addrs) > 0)
  350. {
  351. if (area->is_type & IS_LEVEL_1)
  352. lsp_generate (area, IS_LEVEL_1);
  353. if (area->is_type & IS_LEVEL_2)
  354. lsp_generate (area, IS_LEVEL_2);
  355. }
  356. return CMD_SUCCESS;
  357. }
  358. int
  359. area_clear_net_title (struct vty *vty, const char *net_title)
  360. {
  361. struct isis_area *area;
  362. struct area_addr addr, *addrp = NULL;
  363. struct listnode *node;
  364. u_char buff[255];
  365. area = vty->index;
  366. if (!area)
  367. {
  368. vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
  369. return CMD_ERR_NO_MATCH;
  370. }
  371. addr.addr_len = dotformat2buff (buff, net_title);
  372. if (addr.addr_len < 8 || addr.addr_len > 20)
  373. {
  374. vty_out (vty, "Unsupported area address length %d, should be 8...20 %s",
  375. addr.addr_len, VTY_NEWLINE);
  376. return CMD_ERR_AMBIGUOUS;
  377. }
  378. memcpy (addr.area_addr, buff, (int) addr.addr_len);
  379. for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node, addrp))
  380. if ((addrp->addr_len + ISIS_SYS_ID_LEN + 1) == addr.addr_len &&
  381. !memcmp (addrp->area_addr, addr.area_addr, addr.addr_len))
  382. break;
  383. if (!addrp)
  384. {
  385. vty_out (vty, "No area address %s for area %s %s", net_title,
  386. area->area_tag, VTY_NEWLINE);
  387. return CMD_ERR_NO_MATCH;
  388. }
  389. listnode_delete (area->area_addrs, addrp);
  390. XFREE (MTYPE_ISIS_AREA_ADDR, addrp);
  391. /*
  392. * Last area address - reset the SystemID for this router
  393. */
  394. if (listcount (area->area_addrs) == 0)
  395. {
  396. memset (isis->sysid, 0, ISIS_SYS_ID_LEN);
  397. isis->sysid_set = 0;
  398. if (isis->debugs & DEBUG_EVENTS)
  399. zlog_debug ("Router has no SystemID");
  400. }
  401. return CMD_SUCCESS;
  402. }
  403. /*
  404. * 'show isis interface' command
  405. */
  406. int
  407. show_isis_interface_common (struct vty *vty, const char *ifname, char detail)
  408. {
  409. struct listnode *anode, *cnode;
  410. struct isis_area *area;
  411. struct isis_circuit *circuit;
  412. if (!isis)
  413. {
  414. vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE);
  415. return CMD_SUCCESS;
  416. }
  417. for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area))
  418. {
  419. vty_out (vty, "Area %s:%s", area->area_tag, VTY_NEWLINE);
  420. if (detail == ISIS_UI_LEVEL_BRIEF)
  421. vty_out (vty, " Interface CircId State Type Level%s",
  422. VTY_NEWLINE);
  423. for (ALL_LIST_ELEMENTS_RO (area->circuit_list, cnode, circuit))
  424. if (!ifname)
  425. isis_circuit_print_vty (circuit, vty, detail);
  426. else if (strcmp(circuit->interface->name, ifname) == 0)
  427. isis_circuit_print_vty (circuit, vty, detail);
  428. }
  429. return CMD_SUCCESS;
  430. }
  431. DEFUN (show_isis_interface,
  432. show_isis_interface_cmd,
  433. "show isis interface",
  434. SHOW_STR
  435. "ISIS network information\n"
  436. "ISIS interface\n")
  437. {
  438. return show_isis_interface_common (vty, NULL, ISIS_UI_LEVEL_BRIEF);
  439. }
  440. DEFUN (show_isis_interface_detail,
  441. show_isis_interface_detail_cmd,
  442. "show isis interface detail",
  443. SHOW_STR
  444. "ISIS network information\n"
  445. "ISIS interface\n"
  446. "show detailed information\n")
  447. {
  448. return show_isis_interface_common (vty, NULL, ISIS_UI_LEVEL_DETAIL);
  449. }
  450. DEFUN (show_isis_interface_arg,
  451. show_isis_interface_arg_cmd,
  452. "show isis interface WORD",
  453. SHOW_STR
  454. "ISIS network information\n"
  455. "ISIS interface\n"
  456. "ISIS interface name\n")
  457. {
  458. return show_isis_interface_common (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
  459. }
  460. /*
  461. * 'show isis neighbor' command
  462. */
  463. int
  464. show_isis_neighbor_common (struct vty *vty, const char *id, char detail)
  465. {
  466. struct listnode *anode, *cnode, *node;
  467. struct isis_area *area;
  468. struct isis_circuit *circuit;
  469. struct list *adjdb;
  470. struct isis_adjacency *adj;
  471. struct isis_dynhn *dynhn;
  472. u_char sysid[ISIS_SYS_ID_LEN];
  473. int i;
  474. if (!isis)
  475. {
  476. vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE);
  477. return CMD_SUCCESS;
  478. }
  479. memset (sysid, 0, ISIS_SYS_ID_LEN);
  480. if (id)
  481. {
  482. if (sysid2buff (sysid, id) == 0)
  483. {
  484. dynhn = dynhn_find_by_name (id);
  485. if (dynhn == NULL)
  486. {
  487. vty_out (vty, "Invalid system id %s%s", id, VTY_NEWLINE);
  488. return CMD_SUCCESS;
  489. }
  490. memcpy (sysid, dynhn->id, ISIS_SYS_ID_LEN);
  491. }
  492. }
  493. for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area))
  494. {
  495. vty_out (vty, "Area %s:%s", area->area_tag, VTY_NEWLINE);
  496. if (detail == ISIS_UI_LEVEL_BRIEF)
  497. vty_out (vty, " System Id Interface L State"
  498. " Holdtime SNPA%s", VTY_NEWLINE);
  499. for (ALL_LIST_ELEMENTS_RO (area->circuit_list, cnode, circuit))
  500. {
  501. if (circuit->circ_type == CIRCUIT_T_BROADCAST)
  502. {
  503. for (i = 0; i < 2; i++)
  504. {
  505. adjdb = circuit->u.bc.adjdb[i];
  506. if (adjdb && adjdb->count)
  507. {
  508. for (ALL_LIST_ELEMENTS_RO (adjdb, node, adj))
  509. if (!id || !memcmp (adj->sysid, sysid,
  510. ISIS_SYS_ID_LEN))
  511. isis_adj_print_vty (adj, vty, detail);
  512. }
  513. }
  514. }
  515. else if (circuit->circ_type == CIRCUIT_T_P2P &&
  516. circuit->u.p2p.neighbor)
  517. {
  518. adj = circuit->u.p2p.neighbor;
  519. if (!id || !memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN))
  520. isis_adj_print_vty (adj, vty, detail);
  521. }
  522. }
  523. }
  524. return CMD_SUCCESS;
  525. }
  526. /*
  527. * 'clear isis neighbor' command
  528. */
  529. int
  530. clear_isis_neighbor_common (struct vty *vty, const char *id)
  531. {
  532. struct listnode *anode, *cnode, *cnextnode, *node, *nnode;
  533. struct isis_area *area;
  534. struct isis_circuit *circuit;
  535. struct list *adjdb;
  536. struct isis_adjacency *adj;
  537. struct isis_dynhn *dynhn;
  538. u_char sysid[ISIS_SYS_ID_LEN];
  539. int i;
  540. if (!isis)
  541. {
  542. vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE);
  543. return CMD_SUCCESS;
  544. }
  545. memset (sysid, 0, ISIS_SYS_ID_LEN);
  546. if (id)
  547. {
  548. if (sysid2buff (sysid, id) == 0)
  549. {
  550. dynhn = dynhn_find_by_name (id);
  551. if (dynhn == NULL)
  552. {
  553. vty_out (vty, "Invalid system id %s%s", id, VTY_NEWLINE);
  554. return CMD_SUCCESS;
  555. }
  556. memcpy (sysid, dynhn->id, ISIS_SYS_ID_LEN);
  557. }
  558. }
  559. for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area))
  560. {
  561. for (ALL_LIST_ELEMENTS (area->circuit_list, cnode, cnextnode, circuit))
  562. {
  563. if (circuit->circ_type == CIRCUIT_T_BROADCAST)
  564. {
  565. for (i = 0; i < 2; i++)
  566. {
  567. adjdb = circuit->u.bc.adjdb[i];
  568. if (adjdb && adjdb->count)
  569. {
  570. for (ALL_LIST_ELEMENTS (adjdb, node, nnode, adj))
  571. if (!id || !memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN))
  572. isis_adj_state_change (adj, ISIS_ADJ_DOWN,
  573. "clear user request");
  574. }
  575. }
  576. }
  577. else if (circuit->circ_type == CIRCUIT_T_P2P &&
  578. circuit->u.p2p.neighbor)
  579. {
  580. adj = circuit->u.p2p.neighbor;
  581. if (!id || !memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN))
  582. isis_adj_state_change (adj, ISIS_ADJ_DOWN,
  583. "clear user request");
  584. }
  585. }
  586. }
  587. return CMD_SUCCESS;
  588. }
  589. DEFUN (show_isis_neighbor,
  590. show_isis_neighbor_cmd,
  591. "show isis neighbor",
  592. SHOW_STR
  593. "ISIS network information\n"
  594. "ISIS neighbor adjacencies\n")
  595. {
  596. return show_isis_neighbor_common (vty, NULL, ISIS_UI_LEVEL_BRIEF);
  597. }
  598. DEFUN (show_isis_neighbor_detail,
  599. show_isis_neighbor_detail_cmd,
  600. "show isis neighbor detail",
  601. SHOW_STR
  602. "ISIS network information\n"
  603. "ISIS neighbor adjacencies\n"
  604. "show detailed information\n")
  605. {
  606. return show_isis_neighbor_common (vty, NULL, ISIS_UI_LEVEL_DETAIL);
  607. }
  608. DEFUN (show_isis_neighbor_arg,
  609. show_isis_neighbor_arg_cmd,
  610. "show isis neighbor WORD",
  611. SHOW_STR
  612. "ISIS network information\n"
  613. "ISIS neighbor adjacencies\n"
  614. "System id\n")
  615. {
  616. return show_isis_neighbor_common (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
  617. }
  618. DEFUN (clear_isis_neighbor,
  619. clear_isis_neighbor_cmd,
  620. "clear isis neighbor",
  621. CLEAR_STR
  622. "Reset ISIS network information\n"
  623. "Reset ISIS neighbor adjacencies\n")
  624. {
  625. return clear_isis_neighbor_common (vty, NULL);
  626. }
  627. DEFUN (clear_isis_neighbor_arg,
  628. clear_isis_neighbor_arg_cmd,
  629. "clear isis neighbor WORD",
  630. CLEAR_STR
  631. "ISIS network information\n"
  632. "ISIS neighbor adjacencies\n"
  633. "System id\n")
  634. {
  635. return clear_isis_neighbor_common (vty, argv[0]);
  636. }
  637. /*
  638. * 'isis debug', 'show debugging'
  639. */
  640. void
  641. print_debug (struct vty *vty, int flags, int onoff)
  642. {
  643. char onoffs[4];
  644. if (onoff)
  645. strcpy (onoffs, "on");
  646. else
  647. strcpy (onoffs, "off");
  648. if (flags & DEBUG_ADJ_PACKETS)
  649. vty_out (vty, "IS-IS Adjacency related packets debugging is %s%s", onoffs,
  650. VTY_NEWLINE);
  651. if (flags & DEBUG_CHECKSUM_ERRORS)
  652. vty_out (vty, "IS-IS checksum errors debugging is %s%s", onoffs,
  653. VTY_NEWLINE);
  654. if (flags & DEBUG_LOCAL_UPDATES)
  655. vty_out (vty, "IS-IS local updates debugging is %s%s", onoffs,
  656. VTY_NEWLINE);
  657. if (flags & DEBUG_PROTOCOL_ERRORS)
  658. vty_out (vty, "IS-IS protocol errors debugging is %s%s", onoffs,
  659. VTY_NEWLINE);
  660. if (flags & DEBUG_SNP_PACKETS)
  661. vty_out (vty, "IS-IS CSNP/PSNP packets debugging is %s%s", onoffs,
  662. VTY_NEWLINE);
  663. if (flags & DEBUG_SPF_EVENTS)
  664. vty_out (vty, "IS-IS SPF events debugging is %s%s", onoffs, VTY_NEWLINE);
  665. if (flags & DEBUG_SPF_STATS)
  666. vty_out (vty, "IS-IS SPF Timing and Statistics Data debugging is %s%s",
  667. onoffs, VTY_NEWLINE);
  668. if (flags & DEBUG_SPF_TRIGGERS)
  669. vty_out (vty, "IS-IS SPF triggering events debugging is %s%s", onoffs,
  670. VTY_NEWLINE);
  671. if (flags & DEBUG_UPDATE_PACKETS)
  672. vty_out (vty, "IS-IS Update related packet debugging is %s%s", onoffs,
  673. VTY_NEWLINE);
  674. if (flags & DEBUG_RTE_EVENTS)
  675. vty_out (vty, "IS-IS Route related debuggin is %s%s", onoffs,
  676. VTY_NEWLINE);
  677. if (flags & DEBUG_EVENTS)
  678. vty_out (vty, "IS-IS Event debugging is %s%s", onoffs, VTY_NEWLINE);
  679. if (flags & DEBUG_PACKET_DUMP)
  680. vty_out (vty, "IS-IS Packet dump debugging is %s%s", onoffs, VTY_NEWLINE);
  681. }
  682. DEFUN (show_debugging,
  683. show_debugging_cmd,
  684. "show debugging",
  685. SHOW_STR
  686. "State of each debugging option\n")
  687. {
  688. vty_out (vty, "IS-IS:%s", VTY_NEWLINE);
  689. print_debug (vty, isis->debugs, 1);
  690. return CMD_SUCCESS;
  691. }
  692. /* Debug node. */
  693. static struct cmd_node debug_node = {
  694. DEBUG_NODE,
  695. "",
  696. 1
  697. };
  698. static int
  699. config_write_debug (struct vty *vty)
  700. {
  701. int write = 0;
  702. int flags = isis->debugs;
  703. if (flags & DEBUG_ADJ_PACKETS)
  704. {
  705. vty_out (vty, "debug isis adj-packets%s", VTY_NEWLINE);
  706. write++;
  707. }
  708. if (flags & DEBUG_CHECKSUM_ERRORS)
  709. {
  710. vty_out (vty, "debug isis checksum-errors%s", VTY_NEWLINE);
  711. write++;
  712. }
  713. if (flags & DEBUG_LOCAL_UPDATES)
  714. {
  715. vty_out (vty, "debug isis local-updates%s", VTY_NEWLINE);
  716. write++;
  717. }
  718. if (flags & DEBUG_PROTOCOL_ERRORS)
  719. {
  720. vty_out (vty, "debug isis protocol-errors%s", VTY_NEWLINE);
  721. write++;
  722. }
  723. if (flags & DEBUG_SNP_PACKETS)
  724. {
  725. vty_out (vty, "debug isis snp-packets%s", VTY_NEWLINE);
  726. write++;
  727. }
  728. if (flags & DEBUG_SPF_EVENTS)
  729. {
  730. vty_out (vty, "debug isis spf-events%s", VTY_NEWLINE);
  731. write++;
  732. }
  733. if (flags & DEBUG_SPF_STATS)
  734. {
  735. vty_out (vty, "debug isis spf-statistics%s", VTY_NEWLINE);
  736. write++;
  737. }
  738. if (flags & DEBUG_SPF_TRIGGERS)
  739. {
  740. vty_out (vty, "debug isis spf-triggers%s", VTY_NEWLINE);
  741. write++;
  742. }
  743. if (flags & DEBUG_UPDATE_PACKETS)
  744. {
  745. vty_out (vty, "debug isis update-packets%s", VTY_NEWLINE);
  746. write++;
  747. }
  748. if (flags & DEBUG_RTE_EVENTS)
  749. {
  750. vty_out (vty, "debug isis route-events%s", VTY_NEWLINE);
  751. write++;
  752. }
  753. if (flags & DEBUG_EVENTS)
  754. {
  755. vty_out (vty, "debug isis events%s", VTY_NEWLINE);
  756. write++;
  757. }
  758. if (flags & DEBUG_PACKET_DUMP)
  759. {
  760. vty_out (vty, "debug isis packet-dump%s", VTY_NEWLINE);
  761. write++;
  762. }
  763. return write;
  764. }
  765. DEFUN (debug_isis_adj,
  766. debug_isis_adj_cmd,
  767. "debug isis adj-packets",
  768. DEBUG_STR
  769. "IS-IS information\n"
  770. "IS-IS Adjacency related packets\n")
  771. {
  772. isis->debugs |= DEBUG_ADJ_PACKETS;
  773. print_debug (vty, DEBUG_ADJ_PACKETS, 1);
  774. return CMD_SUCCESS;
  775. }
  776. DEFUN (no_debug_isis_adj,
  777. no_debug_isis_adj_cmd,
  778. "no debug isis adj-packets",
  779. UNDEBUG_STR
  780. "IS-IS information\n"
  781. "IS-IS Adjacency related packets\n")
  782. {
  783. isis->debugs &= ~DEBUG_ADJ_PACKETS;
  784. print_debug (vty, DEBUG_ADJ_PACKETS, 0);
  785. return CMD_SUCCESS;
  786. }
  787. DEFUN (debug_isis_csum,
  788. debug_isis_csum_cmd,
  789. "debug isis checksum-errors",
  790. DEBUG_STR
  791. "IS-IS information\n"
  792. "IS-IS LSP checksum errors\n")
  793. {
  794. isis->debugs |= DEBUG_CHECKSUM_ERRORS;
  795. print_debug (vty, DEBUG_CHECKSUM_ERRORS, 1);
  796. return CMD_SUCCESS;
  797. }
  798. DEFUN (no_debug_isis_csum,
  799. no_debug_isis_csum_cmd,
  800. "no debug isis checksum-errors",
  801. UNDEBUG_STR
  802. "IS-IS information\n"
  803. "IS-IS LSP checksum errors\n")
  804. {
  805. isis->debugs &= ~DEBUG_CHECKSUM_ERRORS;
  806. print_debug (vty, DEBUG_CHECKSUM_ERRORS, 0);
  807. return CMD_SUCCESS;
  808. }
  809. DEFUN (debug_isis_lupd,
  810. debug_isis_lupd_cmd,
  811. "debug isis local-updates",
  812. DEBUG_STR
  813. "IS-IS information\n"
  814. "IS-IS local update packets\n")
  815. {
  816. isis->debugs |= DEBUG_LOCAL_UPDATES;
  817. print_debug (vty, DEBUG_LOCAL_UPDATES, 1);
  818. return CMD_SUCCESS;
  819. }
  820. DEFUN (no_debug_isis_lupd,
  821. no_debug_isis_lupd_cmd,
  822. "no debug isis local-updates",
  823. UNDEBUG_STR
  824. "IS-IS information\n"
  825. "IS-IS local update packets\n")
  826. {
  827. isis->debugs &= ~DEBUG_LOCAL_UPDATES;
  828. print_debug (vty, DEBUG_LOCAL_UPDATES, 0);
  829. return CMD_SUCCESS;
  830. }
  831. DEFUN (debug_isis_err,
  832. debug_isis_err_cmd,
  833. "debug isis protocol-errors",
  834. DEBUG_STR
  835. "IS-IS information\n"
  836. "IS-IS LSP protocol errors\n")
  837. {
  838. isis->debugs |= DEBUG_PROTOCOL_ERRORS;
  839. print_debug (vty, DEBUG_PROTOCOL_ERRORS, 1);
  840. return CMD_SUCCESS;
  841. }
  842. DEFUN (no_debug_isis_err,
  843. no_debug_isis_err_cmd,
  844. "no debug isis protocol-errors",
  845. UNDEBUG_STR
  846. "IS-IS information\n"
  847. "IS-IS LSP protocol errors\n")
  848. {
  849. isis->debugs &= ~DEBUG_PROTOCOL_ERRORS;
  850. print_debug (vty, DEBUG_PROTOCOL_ERRORS, 0);
  851. return CMD_SUCCESS;
  852. }
  853. DEFUN (debug_isis_snp,
  854. debug_isis_snp_cmd,
  855. "debug isis snp-packets",
  856. DEBUG_STR
  857. "IS-IS information\n"
  858. "IS-IS CSNP/PSNP packets\n")
  859. {
  860. isis->debugs |= DEBUG_SNP_PACKETS;
  861. print_debug (vty, DEBUG_SNP_PACKETS, 1);
  862. return CMD_SUCCESS;
  863. }
  864. DEFUN (no_debug_isis_snp,
  865. no_debug_isis_snp_cmd,
  866. "no debug isis snp-packets",
  867. UNDEBUG_STR
  868. "IS-IS information\n"
  869. "IS-IS CSNP/PSNP packets\n")
  870. {
  871. isis->debugs &= ~DEBUG_SNP_PACKETS;
  872. print_debug (vty, DEBUG_SNP_PACKETS, 0);
  873. return CMD_SUCCESS;
  874. }
  875. DEFUN (debug_isis_upd,
  876. debug_isis_upd_cmd,
  877. "debug isis update-packets",
  878. DEBUG_STR
  879. "IS-IS information\n"
  880. "IS-IS Update related packets\n")
  881. {
  882. isis->debugs |= DEBUG_UPDATE_PACKETS;
  883. print_debug (vty, DEBUG_UPDATE_PACKETS, 1);
  884. return CMD_SUCCESS;
  885. }
  886. DEFUN (no_debug_isis_upd,
  887. no_debug_isis_upd_cmd,
  888. "no debug isis update-packets",
  889. UNDEBUG_STR
  890. "IS-IS information\n"
  891. "IS-IS Update related packets\n")
  892. {
  893. isis->debugs &= ~DEBUG_UPDATE_PACKETS;
  894. print_debug (vty, DEBUG_UPDATE_PACKETS, 0);
  895. return CMD_SUCCESS;
  896. }
  897. DEFUN (debug_isis_spfevents,
  898. debug_isis_spfevents_cmd,
  899. "debug isis spf-events",
  900. DEBUG_STR
  901. "IS-IS information\n"
  902. "IS-IS Shortest Path First Events\n")
  903. {
  904. isis->debugs |= DEBUG_SPF_EVENTS;
  905. print_debug (vty, DEBUG_SPF_EVENTS, 1);
  906. return CMD_SUCCESS;
  907. }
  908. DEFUN (no_debug_isis_spfevents,
  909. no_debug_isis_spfevents_cmd,
  910. "no debug isis spf-events",
  911. UNDEBUG_STR
  912. "IS-IS information\n"
  913. "IS-IS Shortest Path First Events\n")
  914. {
  915. isis->debugs &= ~DEBUG_SPF_EVENTS;
  916. print_debug (vty, DEBUG_SPF_EVENTS, 0);
  917. return CMD_SUCCESS;
  918. }
  919. DEFUN (debug_isis_spfstats,
  920. debug_isis_spfstats_cmd,
  921. "debug isis spf-statistics ",
  922. DEBUG_STR
  923. "IS-IS information\n"
  924. "IS-IS SPF Timing and Statistic Data\n")
  925. {
  926. isis->debugs |= DEBUG_SPF_STATS;
  927. print_debug (vty, DEBUG_SPF_STATS, 1);
  928. return CMD_SUCCESS;
  929. }
  930. DEFUN (no_debug_isis_spfstats,
  931. no_debug_isis_spfstats_cmd,
  932. "no debug isis spf-statistics",
  933. UNDEBUG_STR
  934. "IS-IS information\n"
  935. "IS-IS SPF Timing and Statistic Data\n")
  936. {
  937. isis->debugs &= ~DEBUG_SPF_STATS;
  938. print_debug (vty, DEBUG_SPF_STATS, 0);
  939. return CMD_SUCCESS;
  940. }
  941. DEFUN (debug_isis_spftrigg,
  942. debug_isis_spftrigg_cmd,
  943. "debug isis spf-triggers",
  944. DEBUG_STR
  945. "IS-IS information\n"
  946. "IS-IS SPF triggering events\n")
  947. {
  948. isis->debugs |= DEBUG_SPF_TRIGGERS;
  949. print_debug (vty, DEBUG_SPF_TRIGGERS, 1);
  950. return CMD_SUCCESS;
  951. }
  952. DEFUN (no_debug_isis_spftrigg,
  953. no_debug_isis_spftrigg_cmd,
  954. "no debug isis spf-triggers",
  955. UNDEBUG_STR
  956. "IS-IS information\n"
  957. "IS-IS SPF triggering events\n")
  958. {
  959. isis->debugs &= ~DEBUG_SPF_TRIGGERS;
  960. print_debug (vty, DEBUG_SPF_TRIGGERS, 0);
  961. return CMD_SUCCESS;
  962. }
  963. DEFUN (debug_isis_rtevents,
  964. debug_isis_rtevents_cmd,
  965. "debug isis route-events",
  966. DEBUG_STR
  967. "IS-IS information\n"
  968. "IS-IS Route related events\n")
  969. {
  970. isis->debugs |= DEBUG_RTE_EVENTS;
  971. print_debug (vty, DEBUG_RTE_EVENTS, 1);
  972. return CMD_SUCCESS;
  973. }
  974. DEFUN (no_debug_isis_rtevents,
  975. no_debug_isis_rtevents_cmd,
  976. "no debug isis route-events",
  977. UNDEBUG_STR
  978. "IS-IS information\n"
  979. "IS-IS Route related events\n")
  980. {
  981. isis->debugs &= ~DEBUG_RTE_EVENTS;
  982. print_debug (vty, DEBUG_RTE_EVENTS, 0);
  983. return CMD_SUCCESS;
  984. }
  985. DEFUN (debug_isis_events,
  986. debug_isis_events_cmd,
  987. "debug isis events",
  988. DEBUG_STR
  989. "IS-IS information\n"
  990. "IS-IS Events\n")
  991. {
  992. isis->debugs |= DEBUG_EVENTS;
  993. print_debug (vty, DEBUG_EVENTS, 1);
  994. return CMD_SUCCESS;
  995. }
  996. DEFUN (no_debug_isis_events,
  997. no_debug_isis_events_cmd,
  998. "no debug isis events",
  999. UNDEBUG_STR
  1000. "IS-IS information\n"
  1001. "IS-IS Events\n")
  1002. {
  1003. isis->debugs &= ~DEBUG_EVENTS;
  1004. print_debug (vty, DEBUG_EVENTS, 0);
  1005. return CMD_SUCCESS;
  1006. }
  1007. DEFUN (debug_isis_packet_dump,
  1008. debug_isis_packet_dump_cmd,
  1009. "debug isis packet-dump",
  1010. DEBUG_STR
  1011. "IS-IS information\n"
  1012. "IS-IS packet dump\n")
  1013. {
  1014. isis->debugs |= DEBUG_PACKET_DUMP;
  1015. print_debug (vty, DEBUG_PACKET_DUMP, 1);
  1016. return CMD_SUCCESS;
  1017. }
  1018. DEFUN (no_debug_isis_packet_dump,
  1019. no_debug_isis_packet_dump_cmd,
  1020. "no debug isis packet-dump",
  1021. UNDEBUG_STR
  1022. "IS-IS information\n"
  1023. "IS-IS packet dump\n")
  1024. {
  1025. isis->debugs &= ~DEBUG_PACKET_DUMP;
  1026. print_debug (vty, DEBUG_PACKET_DUMP, 0);
  1027. return CMD_SUCCESS;
  1028. }
  1029. DEFUN (show_hostname,
  1030. show_hostname_cmd,
  1031. "show isis hostname",
  1032. SHOW_STR
  1033. "IS-IS information\n"
  1034. "IS-IS Dynamic hostname mapping\n")
  1035. {
  1036. dynhn_print_all (vty);
  1037. return CMD_SUCCESS;
  1038. }
  1039. static void
  1040. vty_out_timestr(struct vty *vty, time_t uptime)
  1041. {
  1042. struct tm *tm;
  1043. time_t difftime = time (NULL);
  1044. difftime -= uptime;
  1045. tm = gmtime (&difftime);
  1046. #define ONE_DAY_SECOND 60*60*24
  1047. #define ONE_WEEK_SECOND 60*60*24*7
  1048. if (difftime < ONE_DAY_SECOND)
  1049. vty_out (vty, "%02d:%02d:%02d",
  1050. tm->tm_hour, tm->tm_min, tm->tm_sec);
  1051. else if (difftime < ONE_WEEK_SECOND)
  1052. vty_out (vty, "%dd%02dh%02dm",
  1053. tm->tm_yday, tm->tm_hour, tm->tm_min);
  1054. else
  1055. vty_out (vty, "%02dw%dd%02dh",
  1056. tm->tm_yday/7,
  1057. tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
  1058. vty_out (vty, " ago");
  1059. }
  1060. DEFUN (show_isis_summary,
  1061. show_isis_summary_cmd,
  1062. "show isis summary",
  1063. SHOW_STR "IS-IS information\n" "IS-IS summary\n")
  1064. {
  1065. struct listnode *node, *node2;
  1066. struct isis_area *area;
  1067. struct isis_spftree *spftree;
  1068. int level;
  1069. if (isis == NULL)
  1070. {
  1071. vty_out (vty, "ISIS is not running%s", VTY_NEWLINE);
  1072. return CMD_SUCCESS;
  1073. }
  1074. vty_out (vty, "Process Id : %ld%s", isis->process_id,
  1075. VTY_NEWLINE);
  1076. if (isis->sysid_set)
  1077. vty_out (vty, "System Id : %s%s", sysid_print (isis->sysid),
  1078. VTY_NEWLINE);
  1079. vty_out (vty, "Up time : ");
  1080. vty_out_timestr(vty, isis->uptime);
  1081. vty_out (vty, "%s", VTY_NEWLINE);
  1082. if (isis->area_list)
  1083. vty_out (vty, "Number of areas : %d%s", isis->area_list->count,
  1084. VTY_NEWLINE);
  1085. for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
  1086. {
  1087. vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
  1088. VTY_NEWLINE);
  1089. if (listcount (area->area_addrs) > 0)
  1090. {
  1091. struct area_addr *area_addr;
  1092. for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node2, area_addr))
  1093. {
  1094. vty_out (vty, " Net: %s%s",
  1095. isonet_print (area_addr->area_addr,
  1096. area_addr->addr_len + ISIS_SYS_ID_LEN +
  1097. 1), VTY_NEWLINE);
  1098. }
  1099. }
  1100. for (level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++)
  1101. {
  1102. if ((area->is_type & level) == 0)
  1103. continue;
  1104. vty_out (vty, " Level-%d:%s", level, VTY_NEWLINE);
  1105. spftree = area->spftree[level - 1];
  1106. if (spftree->pending)
  1107. vty_out (vty, " IPv4 SPF: (pending)%s", VTY_NEWLINE);
  1108. else
  1109. vty_out (vty, " IPv4 SPF:%s", VTY_NEWLINE);
  1110. vty_out (vty, " minimum interval : %d%s",
  1111. area->min_spf_interval[level - 1], VTY_NEWLINE);
  1112. vty_out (vty, " last run elapsed : ");
  1113. vty_out_timestr(vty, spftree->last_run_timestamp);
  1114. vty_out (vty, "%s", VTY_NEWLINE);
  1115. vty_out (vty, " last run duration : %u usec%s",
  1116. (u_int32_t)spftree->last_run_duration, VTY_NEWLINE);
  1117. vty_out (vty, " run count : %d%s",
  1118. spftree->runcount, VTY_NEWLINE);
  1119. #ifdef HAVE_IPV6
  1120. spftree = area->spftree6[level - 1];
  1121. if (spftree->pending)
  1122. vty_out (vty, " IPv6 SPF: (pending)%s", VTY_NEWLINE);
  1123. else
  1124. vty_out (vty, " IPv6 SPF:%s", VTY_NEWLINE);
  1125. vty_out (vty, " minimum interval : %d%s",
  1126. area->min_spf_interval[level - 1], VTY_NEWLINE);
  1127. vty_out (vty, " last run elapsed : ");
  1128. vty_out_timestr(vty, spftree->last_run_timestamp);
  1129. vty_out (vty, "%s", VTY_NEWLINE);
  1130. vty_out (vty, " last run duration : %llu msec%s",
  1131. (unsigned long long)spftree->last_run_duration, VTY_NEWLINE);
  1132. vty_out (vty, " run count : %d%s",
  1133. spftree->runcount, VTY_NEWLINE);
  1134. #endif
  1135. }
  1136. }
  1137. vty_out (vty, "%s", VTY_NEWLINE);
  1138. return CMD_SUCCESS;
  1139. }
  1140. /*
  1141. * This function supports following display options:
  1142. * [ show isis database [detail] ]
  1143. * [ show isis database <sysid> [detail] ]
  1144. * [ show isis database <hostname> [detail] ]
  1145. * [ show isis database <sysid>.<pseudo-id> [detail] ]
  1146. * [ show isis database <hostname>.<pseudo-id> [detail] ]
  1147. * [ show isis database <sysid>.<pseudo-id>-<fragment-number> [detail] ]
  1148. * [ show isis database <hostname>.<pseudo-id>-<fragment-number> [detail] ]
  1149. * [ show isis database detail <sysid> ]
  1150. * [ show isis database detail <hostname> ]
  1151. * [ show isis database detail <sysid>.<pseudo-id> ]
  1152. * [ show isis database detail <hostname>.<pseudo-id> ]
  1153. * [ show isis database detail <sysid>.<pseudo-id>-<fragment-number> ]
  1154. * [ show isis database detail <hostname>.<pseudo-id>-<fragment-number> ]
  1155. */
  1156. static int
  1157. show_isis_database (struct vty *vty, const char *argv, int ui_level)
  1158. {
  1159. struct listnode *node;
  1160. struct isis_area *area;
  1161. struct isis_lsp *lsp;
  1162. struct isis_dynhn *dynhn;
  1163. const char *pos = argv;
  1164. u_char lspid[ISIS_SYS_ID_LEN+2];
  1165. char sysid[255];
  1166. u_char number[3];
  1167. int level, lsp_count;
  1168. if (isis->area_list->count == 0)
  1169. return CMD_SUCCESS;
  1170. memset (&lspid, 0, ISIS_SYS_ID_LEN);
  1171. memset (&sysid, 0, 255);
  1172. /*
  1173. * extract fragment and pseudo id from the string argv
  1174. * in the forms:
  1175. * (a) <systemid/hostname>.<pseudo-id>-<framenent> or
  1176. * (b) <systemid/hostname>.<pseudo-id> or
  1177. * (c) <systemid/hostname> or
  1178. * Where systemid is in the form:
  1179. * xxxx.xxxx.xxxx
  1180. */
  1181. if (argv)
  1182. strncpy (sysid, argv, 254);
  1183. if (argv && strlen (argv) > 3)
  1184. {
  1185. pos = argv + strlen (argv) - 3;
  1186. if (strncmp (pos, "-", 1) == 0)
  1187. {
  1188. memcpy (number, ++pos, 2);
  1189. lspid[ISIS_SYS_ID_LEN+1] = (u_char) strtol ((char *)number, NULL, 16);
  1190. pos -= 4;
  1191. if (strncmp (pos, ".", 1) != 0)
  1192. return CMD_ERR_AMBIGUOUS;
  1193. }
  1194. if (strncmp (pos, ".", 1) == 0)
  1195. {
  1196. memcpy (number, ++pos, 2);
  1197. lspid[ISIS_SYS_ID_LEN] = (u_char) strtol ((char *)number, NULL, 16);
  1198. sysid[pos - argv - 1] = '\0';
  1199. }
  1200. }
  1201. for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
  1202. {
  1203. vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
  1204. VTY_NEWLINE);
  1205. for (level = 0; level < ISIS_LEVELS; level++)
  1206. {
  1207. if (area->lspdb[level] && dict_count (area->lspdb[level]) > 0)
  1208. {
  1209. lsp = NULL;
  1210. if (argv != NULL)
  1211. {
  1212. /*
  1213. * Try to find the lsp-id if the argv string is in
  1214. * the form hostname.<pseudo-id>-<fragment>
  1215. */
  1216. if (sysid2buff (lspid, sysid))
  1217. {
  1218. lsp = lsp_search (lspid, area->lspdb[level]);
  1219. }
  1220. else if ((dynhn = dynhn_find_by_name (sysid)))
  1221. {
  1222. memcpy (lspid, dynhn->id, ISIS_SYS_ID_LEN);
  1223. lsp = lsp_search (lspid, area->lspdb[level]);
  1224. }
  1225. else if (strncmp(unix_hostname (), sysid, 15) == 0)
  1226. {
  1227. memcpy (lspid, isis->sysid, ISIS_SYS_ID_LEN);
  1228. lsp = lsp_search (lspid, area->lspdb[level]);
  1229. }
  1230. }
  1231. if (lsp != NULL || argv == NULL)
  1232. {
  1233. vty_out (vty, "IS-IS Level-%d link-state database:%s",
  1234. level + 1, VTY_NEWLINE);
  1235. /* print the title in all cases */
  1236. vty_out (vty, "LSP ID PduLen "
  1237. "SeqNumber Chksum Holdtime ATT/P/OL%s",
  1238. VTY_NEWLINE);
  1239. }
  1240. if (lsp)
  1241. {
  1242. if (ui_level == ISIS_UI_LEVEL_DETAIL)
  1243. lsp_print_detail (lsp, vty, area->dynhostname);
  1244. else
  1245. lsp_print (lsp, vty, area->dynhostname);
  1246. }
  1247. else if (argv == NULL)
  1248. {
  1249. lsp_count = lsp_print_all (vty, area->lspdb[level],
  1250. ui_level,
  1251. area->dynhostname);
  1252. vty_out (vty, " %u LSPs%s%s",
  1253. lsp_count, VTY_NEWLINE, VTY_NEWLINE);
  1254. }
  1255. }
  1256. }
  1257. }
  1258. return CMD_SUCCESS;
  1259. }
  1260. DEFUN (show_database_brief,
  1261. show_database_cmd,
  1262. "show isis database",
  1263. SHOW_STR
  1264. "IS-IS information\n"
  1265. "IS-IS link state database\n")
  1266. {
  1267. return show_isis_database (vty, NULL, ISIS_UI_LEVEL_BRIEF);
  1268. }
  1269. DEFUN (show_database_lsp_brief,
  1270. show_database_arg_cmd,
  1271. "show isis database WORD",
  1272. SHOW_STR
  1273. "IS-IS information\n"
  1274. "IS-IS link state database\n"
  1275. "LSP ID\n")
  1276. {
  1277. return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_BRIEF);
  1278. }
  1279. DEFUN (show_database_lsp_detail,
  1280. show_database_arg_detail_cmd,
  1281. "show isis database WORD detail",
  1282. SHOW_STR
  1283. "IS-IS information\n"
  1284. "IS-IS link state database\n"
  1285. "LSP ID\n"
  1286. "Detailed information\n")
  1287. {
  1288. return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
  1289. }
  1290. DEFUN (show_database_detail,
  1291. show_database_detail_cmd,
  1292. "show isis database detail",
  1293. SHOW_STR
  1294. "IS-IS information\n"
  1295. "IS-IS link state database\n")
  1296. {
  1297. return show_isis_database (vty, NULL, ISIS_UI_LEVEL_DETAIL);
  1298. }
  1299. DEFUN (show_database_detail_lsp,
  1300. show_database_detail_arg_cmd,
  1301. "show isis database detail WORD",
  1302. SHOW_STR
  1303. "IS-IS information\n"
  1304. "IS-IS link state database\n"
  1305. "Detailed information\n"
  1306. "LSP ID\n")
  1307. {
  1308. return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
  1309. }
  1310. /*
  1311. * 'router isis' command
  1312. */
  1313. DEFUN (router_isis,
  1314. router_isis_cmd,
  1315. "router isis WORD",
  1316. ROUTER_STR
  1317. "ISO IS-IS\n"
  1318. "ISO Routing area tag")
  1319. {
  1320. return isis_area_get (vty, argv[0]);
  1321. }
  1322. /*
  1323. *'no router isis' command
  1324. */
  1325. DEFUN (no_router_isis,
  1326. no_router_isis_cmd,
  1327. "no router isis WORD",
  1328. "no\n" ROUTER_STR "ISO IS-IS\n" "ISO Routing area tag")
  1329. {
  1330. return isis_area_destroy (vty, argv[0]);
  1331. }
  1332. /*
  1333. * 'net' command
  1334. */
  1335. DEFUN (net,
  1336. net_cmd,
  1337. "net WORD",
  1338. "A Network Entity Title for this process (OSI only)\n"
  1339. "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
  1340. {
  1341. return area_net_title (vty, argv[0]);
  1342. }
  1343. /*
  1344. * 'no net' command
  1345. */
  1346. DEFUN (no_net,
  1347. no_net_cmd,
  1348. "no net WORD",
  1349. NO_STR
  1350. "A Network Entity Title for this process (OSI only)\n"
  1351. "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
  1352. {
  1353. return area_clear_net_title (vty, argv[0]);
  1354. }
  1355. DEFUN (area_passwd_md5,
  1356. area_passwd_md5_cmd,
  1357. "area-password md5 WORD",
  1358. "Configure the authentication password for an area\n"
  1359. "Authentication type\n"
  1360. "Area password\n")
  1361. {
  1362. struct isis_area *area;
  1363. int len;
  1364. area = vty->index;
  1365. if (!area)
  1366. {
  1367. vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
  1368. return CMD_ERR_NO_MATCH;
  1369. }
  1370. len = strlen (argv[0]);
  1371. if (len > 254)
  1372. {
  1373. vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
  1374. return CMD_ERR_AMBIGUOUS;
  1375. }
  1376. area->area_passwd.len = (u_char) len;
  1377. area->area_passwd.type = ISIS_PASSWD_TYPE_HMAC_MD5;
  1378. strncpy ((char *)area->area_passwd.passwd, argv[0], 255);
  1379. if (argc > 1)
  1380. {
  1381. SET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND);
  1382. if (strncmp(argv[1], "v", 1) == 0)
  1383. SET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
  1384. else
  1385. UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
  1386. }
  1387. else
  1388. {
  1389. UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND);
  1390. UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
  1391. }
  1392. lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
  1393. return CMD_SUCCESS;
  1394. }
  1395. ALIAS (area_passwd_md5,
  1396. area_passwd_md5_snpauth_cmd,
  1397. "area-password md5 WORD authenticate snp (send-only|validate)",
  1398. "Configure the authentication password for an area\n"
  1399. "Authentication type\n"
  1400. "Area password\n"
  1401. "Authentication\n"
  1402. "SNP PDUs\n"
  1403. "Send but do not check PDUs on receiving\n"
  1404. "Send and check PDUs on receiving\n");
  1405. DEFUN (area_passwd_clear,
  1406. area_passwd_clear_cmd,
  1407. "area-password clear WORD",
  1408. "Configure the authentication password for an area\n"
  1409. "Authentication type\n"
  1410. "Area password\n")
  1411. {
  1412. struct isis_area *area;
  1413. int len;
  1414. area = vty->index;
  1415. if (!area)
  1416. {
  1417. vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
  1418. return CMD_ERR_NO_MATCH;
  1419. }
  1420. len = strlen (argv[0]);
  1421. if (len > 254)
  1422. {
  1423. vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
  1424. return CMD_ERR_AMBIGUOUS;
  1425. }
  1426. area->area_passwd.len = (u_char) len;
  1427. area->area_passwd.type = ISIS_PASSWD_TYPE_CLEARTXT;
  1428. strncpy ((char *)area->area_passwd.passwd, argv[0], 255);
  1429. if (argc > 1)
  1430. {
  1431. SET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND);
  1432. if (strncmp(argv[1], "v", 1) == 0)
  1433. SET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
  1434. else
  1435. UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
  1436. }
  1437. else
  1438. {
  1439. UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND);
  1440. UNSET_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV);
  1441. }
  1442. lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
  1443. return CMD_SUCCESS;
  1444. }
  1445. ALIAS (area_passwd_clear,
  1446. area_passwd_clear_snpauth_cmd,
  1447. "area-password clear WORD authenticate snp (send-only|validate)",
  1448. "Configure the authentication password for an area\n"
  1449. "Authentication type\n"
  1450. "Area password\n"
  1451. "Authentication\n"
  1452. "SNP PDUs\n"
  1453. "Send but do not check PDUs on receiving\n"
  1454. "Send and check PDUs on receiving\n");
  1455. DEFUN (no_area_passwd,
  1456. no_area_passwd_cmd,
  1457. "no area-password",
  1458. NO_STR
  1459. "Configure the authentication password for an area\n")
  1460. {
  1461. struct isis_area *area;
  1462. area = vty->index;
  1463. if (!area)
  1464. {
  1465. vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
  1466. return CMD_ERR_NO_MATCH;
  1467. }
  1468. memset (&area->area_passwd, 0, sizeof (struct isis_passwd));
  1469. lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
  1470. return CMD_SUCCESS;
  1471. }
  1472. DEFUN (domain_passwd_md5,
  1473. domain_passwd_md5_cmd,
  1474. "domain-password md5 WORD",
  1475. "Set the authentication password for a routing domain\n"
  1476. "Authentication type\n"
  1477. "Routing domain password\n")
  1478. {
  1479. struct isis_area *area;
  1480. int len;
  1481. area = vty->index;
  1482. if (!area)
  1483. {
  1484. vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
  1485. return CMD_ERR_NO_MATCH;
  1486. }
  1487. len = strlen (argv[0]);
  1488. if (len > 254)
  1489. {
  1490. vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
  1491. return CMD_ERR_AMBIGUOUS;
  1492. }
  1493. area->domain_passwd.len = (u_char) len;
  1494. area->domain_passwd.type = ISIS_PASSWD_TYPE_HMAC_MD5;
  1495. strncpy ((char *)area->domain_passwd.passwd, argv[0], 255);
  1496. if (argc > 1)
  1497. {
  1498. SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
  1499. if (strncmp(argv[1], "v", 1) == 0)
  1500. SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
  1501. else
  1502. UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
  1503. }
  1504. else
  1505. {
  1506. UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
  1507. UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
  1508. }
  1509. lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
  1510. return CMD_SUCCESS;
  1511. }
  1512. ALIAS (domain_passwd_md5,
  1513. domain_passwd_md5_snpauth_cmd,
  1514. "domain-password md5 WORD authenticate snp (send-only|validate)",
  1515. "Set the authentication password for a routing domain\n"
  1516. "Authentication type\n"
  1517. "Routing domain password\n"
  1518. "Authentication\n"
  1519. "SNP PDUs\n"
  1520. "Send but do not check PDUs on receiving\n"
  1521. "Send and check PDUs on receiving\n");
  1522. DEFUN (domain_passwd_clear,
  1523. domain_passwd_clear_cmd,
  1524. "domain-password clear WORD",
  1525. "Set the authentication password for a routing domain\n"
  1526. "Authentication type\n"
  1527. "Routing domain password\n")
  1528. {
  1529. struct isis_area *area;
  1530. int len;
  1531. area = vty->index;
  1532. if (!area)
  1533. {
  1534. vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
  1535. return CMD_ERR_NO_MATCH;
  1536. }
  1537. len = strlen (argv[0]);
  1538. if (len > 254)
  1539. {
  1540. vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
  1541. return CMD_ERR_AMBIGUOUS;
  1542. }
  1543. area->domain_passwd.len = (u_char) len;
  1544. area->domain_passwd.type = ISIS_PASSWD_TYPE_CLEARTXT;
  1545. strncpy ((char *)area->domain_passwd.passwd, argv[0], 255);
  1546. if (argc > 1)
  1547. {
  1548. SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
  1549. if (strncmp(argv[1], "v", 1) == 0)
  1550. SET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
  1551. else
  1552. UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
  1553. }
  1554. else
  1555. {
  1556. UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND);
  1557. UNSET_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV);
  1558. }
  1559. lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
  1560. return CMD_SUCCESS;
  1561. }
  1562. ALIAS (domain_passwd_clear,
  1563. domain_passwd_clear_snpauth_cmd,
  1564. "domain-password clear WORD authenticate snp (send-only|validate)",
  1565. "Set the authentication password for a routing domain\n"
  1566. "Authentication type\n"
  1567. "Routing domain password\n"
  1568. "Authentication\n"
  1569. "SNP PDUs\n"
  1570. "Send but do not check PDUs on receiving\n"
  1571. "Send and check PDUs on receiving\n");
  1572. DEFUN (no_domain_passwd,
  1573. no_domain_passwd_cmd,
  1574. "no domain-password",
  1575. NO_STR
  1576. "Set the authentication password for a routing domain\n")
  1577. {
  1578. struct isis_area *area;
  1579. area = vty->index;
  1580. if (!area)
  1581. {
  1582. vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
  1583. return CMD_ERR_NO_MATCH;
  1584. }
  1585. memset (&area->domain_passwd, 0, sizeof (struct isis_passwd));
  1586. lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
  1587. return CMD_SUCCESS;
  1588. }
  1589. DEFUN (is_type,
  1590. is_type_cmd,
  1591. "is-type (level-1|level-1-2|level-2-only)",
  1592. "IS Level for this routing process (OSI only)\n"
  1593. "Act as a station router only\n"
  1594. "Act as both a station router and an area router\n"
  1595. "Act as an area router only\n")
  1596. {
  1597. struct isis_area *area;
  1598. int type;
  1599. area = vty->index;
  1600. if (!area)
  1601. {
  1602. vty_out (vty, "Can't find IS-IS instance%s", VTY_NEWLINE);
  1603. return CMD_ERR_NO_MATCH;
  1604. }
  1605. type = string2circuit_t (argv[0]);
  1606. if (!type)
  1607. {
  1608. vty_out (vty, "Unknown IS level %s", VTY_NEWLINE);
  1609. return CMD_SUCCESS;
  1610. }
  1611. isis_event_system_type_change (area, type);
  1612. return CMD_SUCCESS;
  1613. }
  1614. DEFUN (no_is_type,
  1615. no_is_type_cmd,
  1616. "no is-type (level-1|level-1-2|level-2-only)",
  1617. NO_STR
  1618. "IS Level for this routing process (OSI only)\n"
  1619. "Act as a station router only\n"
  1620. "Act as both a station router and an area router\n"
  1621. "Act as an area router only\n")
  1622. {
  1623. struct isis_area *area;
  1624. int type;
  1625. area = vty->index;
  1626. assert (area);
  1627. /*
  1628. * Put the is-type back to defaults:
  1629. * - level-1-2 on first area
  1630. * - level-1 for the rest
  1631. */
  1632. if (listgetdata (listhead (isis->area_list)) == area)
  1633. type = IS_LEVEL_1_AND_2;
  1634. else
  1635. type = IS_LEVEL_1;
  1636. isis_event_system_type_change (area, type);
  1637. return CMD_SUCCESS;
  1638. }
  1639. static int
  1640. set_lsp_gen_interval (struct vty *vty, struct isis_area *area,
  1641. uint16_t interval, int level)
  1642. {
  1643. int lvl;
  1644. for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
  1645. {
  1646. if (!(lvl & level))
  1647. continue;
  1648. if (interval >= area->lsp_refresh[lvl-1])
  1649. {
  1650. vty_out (vty, "LSP gen interval %us must be less than "
  1651. "the LSP refresh interval %us%s",
  1652. interval, area->lsp_refresh[lvl-1], VTY_NEWLINE);
  1653. return CMD_ERR_AMBIGUOUS;
  1654. }
  1655. }
  1656. for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
  1657. {
  1658. if (!(lvl & level))
  1659. continue;
  1660. area->lsp_gen_interval[lvl-1] = interval;
  1661. }
  1662. return CMD_SUCCESS;
  1663. }
  1664. DEFUN (lsp_gen_interval,
  1665. lsp_gen_interval_cmd,
  1666. "lsp-gen-interval <1-120>",
  1667. "Minimum interval between regenerating same LSP\n"
  1668. "Minimum interval in seconds\n")
  1669. {
  1670. struct isis_area *area;
  1671. uint16_t interval;
  1672. int level;
  1673. area = vty->index;
  1674. interval = atoi (argv[0]);
  1675. level = IS_LEVEL_1 | IS_LEVEL_2;
  1676. return set_lsp_gen_interval (vty, area, interval, level);
  1677. }
  1678. DEFUN (no_lsp_gen_interval,
  1679. no_lsp_gen_interval_cmd,
  1680. "no lsp-gen-interval",
  1681. NO_STR
  1682. "Minimum interval between regenerating same LSP\n")
  1683. {
  1684. struct isis_area *area;
  1685. uint16_t interval;
  1686. int level;
  1687. area = vty->index;
  1688. interval = DEFAULT_MIN_LSP_GEN_INTERVAL;
  1689. level = IS_LEVEL_1 | IS_LEVEL_2;
  1690. return set_lsp_gen_interval (vty, area, interval, level);
  1691. }
  1692. ALIAS (no_lsp_gen_interval,
  1693. no_lsp_gen_interval_arg_cmd,
  1694. "no lsp-gen-interval <1-120>",
  1695. NO_STR
  1696. "Minimum interval between regenerating same LSP\n"
  1697. "Minimum interval in seconds\n")
  1698. DEFUN (lsp_gen_interval_l1,
  1699. lsp_gen_interval_l1_cmd,
  1700. "lsp-gen-interval level-1 <1-120>",
  1701. "Minimum interval between regenerating same LSP\n"
  1702. "Set interval for level 1 only\n"
  1703. "Minimum interval in seconds\n")
  1704. {
  1705. struct isis_area *area;
  1706. uint16_t interval;
  1707. int level;
  1708. area = vty->index;
  1709. interval = atoi (argv[0]);
  1710. level = IS_LEVEL_1;
  1711. return set_lsp_gen_interval (vty, area, interval, level);
  1712. }
  1713. DEFUN (no_lsp_gen_interval_l1,
  1714. no_lsp_gen_interval_l1_cmd,
  1715. "no lsp-gen-interval level-1",
  1716. NO_STR
  1717. "Minimum interval between regenerating same LSP\n"
  1718. "Set interval for level 1 only\n")
  1719. {
  1720. struct isis_area *area;
  1721. uint16_t interval;
  1722. int level;
  1723. area = vty->index;
  1724. interval = DEFAULT_MIN_LSP_GEN_INTERVAL;
  1725. level = IS_LEVEL_1;
  1726. return set_lsp_gen_interval (vty, area, interval, level);
  1727. }
  1728. ALIAS (no_lsp_gen_interval_l1,
  1729. no_lsp_gen_interval_l1_arg_cmd,
  1730. "no lsp-gen-interval level-1 <1-120>",
  1731. NO_STR
  1732. "Minimum interval between regenerating same LSP\n"
  1733. "Set interval for level 1 only\n"
  1734. "Minimum interval in seconds\n")
  1735. DEFUN (lsp_gen_interval_l2,
  1736. lsp_gen_interval_l2_cmd,
  1737. "lsp-gen-interval level-2 <1-120>",
  1738. "Minimum interval between regenerating same LSP\n"
  1739. "Set interval for level 2 only\n"
  1740. "Minimum interval in seconds\n")
  1741. {
  1742. struct isis_area *area;
  1743. uint16_t interval;
  1744. int level;
  1745. area = vty->index;
  1746. interval = atoi (argv[0]);
  1747. level = IS_LEVEL_2;
  1748. return set_lsp_gen_interval (vty, area, interval, level);
  1749. }
  1750. DEFUN (no_lsp_gen_interval_l2,
  1751. no_lsp_gen_interval_l2_cmd,
  1752. "no lsp-gen-interval level-2",
  1753. NO_STR
  1754. "Minimum interval between regenerating same LSP\n"
  1755. "Set interval for level 2 only\n")
  1756. {
  1757. struct isis_area *area;
  1758. uint16_t interval;
  1759. int level;
  1760. area = vty->index;
  1761. interval = DEFAULT_MIN_LSP_GEN_INTERVAL;
  1762. level = IS_LEVEL_2;
  1763. return set_lsp_gen_interval (vty, area, interval, level);
  1764. }
  1765. ALIAS (no_lsp_gen_interval_l2,
  1766. no_lsp_gen_interval_l2_arg_cmd,
  1767. "no lsp-gen-interval level-2 <1-120>",
  1768. NO_STR
  1769. "Minimum interval between regenerating same LSP\n"
  1770. "Set interval for level 2 only\n"
  1771. "Minimum interval in seconds\n")
  1772. static int
  1773. validate_metric_style_narrow (struct vty *vty, struct isis_area *area)
  1774. {
  1775. struct isis_circuit *circuit;
  1776. struct listnode *node;
  1777. if (! vty)
  1778. return CMD_ERR_AMBIGUOUS;
  1779. if (! area)
  1780. {
  1781. vty_out (vty, "ISIS area is invalid%s", VTY_NEWLINE);
  1782. return CMD_ERR_AMBIGUOUS;
  1783. }
  1784. for (ALL_LIST_ELEMENTS_RO (area->circuit_list, node, circuit))
  1785. {
  1786. if ((area->is_type & IS_LEVEL_1) &&
  1787. (circuit->is_type & IS_LEVEL_1) &&
  1788. (circuit->te_metric[0] > MAX_NARROW_LINK_METRIC))
  1789. {
  1790. vty_out (vty, "ISIS circuit %s metric is invalid%s",
  1791. circuit->interface->name, VTY_NEWLINE);
  1792. return CMD_ERR_AMBIGUOUS;
  1793. }
  1794. if ((area->is_type & IS_LEVEL_2) &&
  1795. (circuit->is_type & IS_LEVEL_2) &&
  1796. (circuit->te_metric[1] > MAX_NARROW_LINK_METRIC))
  1797. {
  1798. vty_out (vty, "ISIS circuit %s metric is invalid%s",
  1799. circuit->interface->name, VTY_NEWLINE);
  1800. return CMD_ERR_AMBIGUOUS;
  1801. }
  1802. }
  1803. return CMD_SUCCESS;
  1804. }
  1805. DEFUN (metric_style,
  1806. metric_style_cmd,
  1807. "metric-style (narrow|transition|wide)",
  1808. "Use old-style (ISO 10589) or new-style packet formats\n"
  1809. "Use old style of TLVs with narrow metric\n"
  1810. "Send and accept both styles of TLVs during transition\n"
  1811. "Use new style of TLVs to carry wider metric\n")
  1812. {
  1813. struct isis_area *area;
  1814. int ret;
  1815. area = vty->index;
  1816. assert (area);
  1817. if (strncmp (argv[0], "w", 1) == 0)
  1818. {
  1819. area->newmetric = 1;
  1820. area->oldmetric = 0;
  1821. }
  1822. else
  1823. {
  1824. ret = validate_metric_style_narrow (vty, area);
  1825. if (ret != CMD_SUCCESS)
  1826. return ret;
  1827. if (strncmp (argv[0], "t", 1) == 0)
  1828. {
  1829. area->newmetric = 1;
  1830. area->oldmetric = 1;
  1831. }
  1832. else if (strncmp (argv[0], "n", 1) == 0)
  1833. {
  1834. area->newmetric = 0;
  1835. area->oldmetric = 1;
  1836. }
  1837. }
  1838. return CMD_SUCCESS;
  1839. }
  1840. DEFUN (no_metric_style,
  1841. no_metric_style_cmd,
  1842. "no metric-style",
  1843. NO_STR
  1844. "Use old-style (ISO 10589) or new-style packet formats\n")
  1845. {
  1846. struct isis_area *area;
  1847. int ret;
  1848. area = vty->index;
  1849. assert (area);
  1850. ret = validate_metric_style_narrow (vty, area);
  1851. if (ret != CMD_SUCCESS)
  1852. return ret;
  1853. /* Default is narrow metric. */
  1854. area->newmetric = 0;
  1855. area->oldmetric = 1;
  1856. return CMD_SUCCESS;
  1857. }
  1858. DEFUN (set_overload_bit,
  1859. set_overload_bit_cmd,
  1860. "set-overload-bit",
  1861. "Set overload bit to avoid any transit traffic\n"
  1862. "Set overload bit\n")
  1863. {
  1864. struct isis_area *area;
  1865. area = vty->index;
  1866. assert (area);
  1867. area->overload_bit = LSPBIT_OL;
  1868. lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
  1869. return CMD_SUCCESS;
  1870. }
  1871. DEFUN (no_set_overload_bit,
  1872. no_set_overload_bit_cmd,
  1873. "no set-overload-bit",
  1874. "Reset overload bit to accept transit traffic\n"
  1875. "Reset overload bit\n")
  1876. {
  1877. struct isis_area *area;
  1878. area = vty->index;
  1879. assert (area);
  1880. area->overload_bit = 0;
  1881. lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
  1882. return CMD_SUCCESS;
  1883. }
  1884. DEFUN (dynamic_hostname,
  1885. dynamic_hostname_cmd,
  1886. "hostname dynamic",
  1887. "Dynamic hostname for IS-IS\n"
  1888. "Dynamic hostname\n")
  1889. {
  1890. struct isis_area *area;
  1891. area = vty->index;
  1892. assert (area);
  1893. if (!area->dynhostname)
  1894. {
  1895. area->dynhostname = 1;
  1896. lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 0);
  1897. }
  1898. return CMD_SUCCESS;
  1899. }
  1900. DEFUN (no_dynamic_hostname,
  1901. no_dynamic_hostname_cmd,
  1902. "no hostname dynamic",
  1903. NO_STR
  1904. "Dynamic hostname for IS-IS\n"
  1905. "Dynamic hostname\n")
  1906. {
  1907. struct isis_area *area;
  1908. area = vty->index;
  1909. assert (area);
  1910. if (area->dynhostname)
  1911. {
  1912. area->dynhostname = 0;
  1913. lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 0);
  1914. }
  1915. return CMD_SUCCESS;
  1916. }
  1917. DEFUN (spf_interval,
  1918. spf_interval_cmd,
  1919. "spf-interval <1-120>",
  1920. "Minimum interval between SPF calculations\n"
  1921. "Minimum interval between consecutive SPFs in seconds\n")
  1922. {
  1923. struct isis_area *area;
  1924. u_int16_t interval;
  1925. area = vty->index;
  1926. interval = atoi (argv[0]);
  1927. area->min_spf_interval[0] = interval;
  1928. area->min_spf_interval[1] = interval;
  1929. return CMD_SUCCESS;
  1930. }
  1931. DEFUN (no_spf_interval,
  1932. no_spf_interval_cmd,
  1933. "no spf-interval",
  1934. NO_STR
  1935. "Minimum interval between SPF calculations\n")
  1936. {
  1937. struct isis_area *area;
  1938. area = vty->index;
  1939. area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL;
  1940. area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL;
  1941. return CMD_SUCCESS;
  1942. }
  1943. ALIAS (no_spf_interval,
  1944. no_spf_interval_arg_cmd,
  1945. "no spf-interval <1-120>",
  1946. NO_STR
  1947. "Minimum interval between SPF calculations\n"
  1948. "Minimum interval between consecutive SPFs in seconds\n")
  1949. DEFUN (spf_interval_l1,
  1950. spf_interval_l1_cmd,
  1951. "spf-interval level-1 <1-120>",
  1952. "Minimum interval between SPF calculations\n"
  1953. "Set interval for level 1 only\n"
  1954. "Minimum interval between consecutive SPFs in seconds\n")
  1955. {
  1956. struct isis_area *area;
  1957. u_int16_t interval;
  1958. area = vty->index;
  1959. interval = atoi (argv[0]);
  1960. area->min_spf_interval[0] = interval;
  1961. return CMD_SUCCESS;
  1962. }
  1963. DEFUN (no_spf_interval_l1,
  1964. no_spf_interval_l1_cmd,
  1965. "no spf-interval level-1",
  1966. NO_STR
  1967. "Minimum interval between SPF calculations\n"
  1968. "Set interval for level 1 only\n")
  1969. {
  1970. struct isis_area *area;
  1971. area = vty->index;
  1972. area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL;
  1973. return CMD_SUCCESS;
  1974. }
  1975. ALIAS (no_spf_interval,
  1976. no_spf_interval_l1_arg_cmd,
  1977. "no spf-interval level-1 <1-120>",
  1978. NO_STR
  1979. "Minimum interval between SPF calculations\n"
  1980. "Set interval for level 1 only\n"
  1981. "Minimum interval between consecutive SPFs in seconds\n")
  1982. DEFUN (spf_interval_l2,
  1983. spf_interval_l2_cmd,
  1984. "spf-interval level-2 <1-120>",
  1985. "Minimum interval between SPF calculations\n"
  1986. "Set interval for level 2 only\n"
  1987. "Minimum interval between consecutive SPFs in seconds\n")
  1988. {
  1989. struct isis_area *area;
  1990. u_int16_t interval;
  1991. area = vty->index;
  1992. interval = atoi (argv[0]);
  1993. area->min_spf_interval[1] = interval;
  1994. return CMD_SUCCESS;
  1995. }
  1996. DEFUN (no_spf_interval_l2,
  1997. no_spf_interval_l2_cmd,
  1998. "no spf-interval level-2",
  1999. NO_STR
  2000. "Minimum interval between SPF calculations\n"
  2001. "Set interval for level 2 only\n")
  2002. {
  2003. struct isis_area *area;
  2004. area = vty->index;
  2005. area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL;
  2006. return CMD_SUCCESS;
  2007. }
  2008. ALIAS (no_spf_interval,
  2009. no_spf_interval_l2_arg_cmd,
  2010. "no spf-interval level-2 <1-120>",
  2011. NO_STR
  2012. "Minimum interval between SPF calculations\n"
  2013. "Set interval for level 2 only\n"
  2014. "Minimum interval between consecutive SPFs in seconds\n")
  2015. static int
  2016. set_lsp_max_lifetime (struct vty *vty, struct isis_area *area,
  2017. uint16_t interval, int level)
  2018. {
  2019. int lvl;
  2020. int set_refresh_interval[ISIS_LEVELS] = {0, 0};
  2021. uint16_t refresh_interval;
  2022. refresh_interval = interval - 300;
  2023. for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; lvl++)
  2024. {
  2025. if (!(lvl & level))
  2026. continue;
  2027. if (refresh_interval < area->lsp_refresh[lvl-1])
  2028. {
  2029. vty_out (vty, "Level %d Max LSP lifetime %us must be 300s greater than "
  2030. "the configured LSP refresh interval %us%s",
  2031. lvl, interval, area->lsp_refresh[lvl-1], VTY_NEWLINE);
  2032. vty_out (vty, "Automatically reducing level %d LSP refresh interval "
  2033. "to %us%s", lvl, refresh_interval, VTY_NEWLINE);
  2034. set_refresh_interval[lvl-1] = 1;
  2035. if (refresh_interval <= area->lsp_gen_interval[lvl-1])
  2036. {
  2037. vty_out (vty, "LSP refresh interval %us must be greater than "
  2038. "the configured LSP gen interval %us%s",
  2039. refresh_interval, area->lsp_gen_interval[lvl-1],
  2040. VTY_NEWLINE);
  2041. return CMD_ERR_AMBIGUOUS;
  2042. }
  2043. }
  2044. }
  2045. for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; lvl++)
  2046. {
  2047. if (!(lvl & level))
  2048. continue;
  2049. area->max_lsp_lifetime[lvl-1] = interval;
  2050. /* Automatically reducing lsp_refresh_interval to interval - 300 */
  2051. if (set_refresh_interval[lvl-1])
  2052. area->lsp_refresh[lvl-1] = refresh_interval;
  2053. }
  2054. lsp_regenerate_schedule (area, level, 1);
  2055. return CMD_SUCCESS;
  2056. }
  2057. DEFUN (max_lsp_lifetime,
  2058. max_lsp_lifetime_cmd,
  2059. "max-lsp-lifetime <350-65535>",
  2060. "Maximum LSP lifetime\n"
  2061. "LSP lifetime in seconds\n")
  2062. {
  2063. struct isis_area *area;
  2064. uint16_t interval;
  2065. int level;
  2066. area = vty->index;
  2067. interval = atoi (argv[0]);
  2068. level = IS_LEVEL_1 | IS_LEVEL_2;
  2069. return set_lsp_max_lifetime (vty, area, interval, level);
  2070. }
  2071. DEFUN (no_max_lsp_lifetime,
  2072. no_max_lsp_lifetime_cmd,
  2073. "no max-lsp-lifetime",
  2074. NO_STR
  2075. "LSP lifetime in seconds\n")
  2076. {
  2077. struct isis_area *area;
  2078. uint16_t interval;
  2079. int level;
  2080. area = vty->index;
  2081. interval = DEFAULT_LSP_LIFETIME;
  2082. level = IS_LEVEL_1 | IS_LEVEL_2;
  2083. return set_lsp_max_lifetime (vty, area, interval, level);
  2084. }
  2085. ALIAS (no_max_lsp_lifetime,
  2086. no_max_lsp_lifetime_arg_cmd,
  2087. "no max-lsp-lifetime <350-65535>",
  2088. NO_STR
  2089. "Maximum LSP lifetime\n"
  2090. "LSP lifetime in seconds\n")
  2091. DEFUN (max_lsp_lifetime_l1,
  2092. max_lsp_lifetime_l1_cmd,
  2093. "max-lsp-lifetime level-1 <350-65535>",
  2094. "Maximum LSP lifetime for Level 1 only\n"
  2095. "LSP lifetime for Level 1 only in seconds\n")
  2096. {
  2097. struct isis_area *area;
  2098. uint16_t interval;
  2099. int level;
  2100. area = vty->index;
  2101. interval = atoi (argv[0]);
  2102. level = IS_LEVEL_1;
  2103. return set_lsp_max_lifetime (vty, area, interval, level);
  2104. }
  2105. DEFUN (no_max_lsp_lifetime_l1,
  2106. no_max_lsp_lifetime_l1_cmd,
  2107. "no max-lsp-lifetime level-1",
  2108. NO_STR
  2109. "LSP lifetime for Level 1 only in seconds\n")
  2110. {
  2111. struct isis_area *area;
  2112. uint16_t interval;
  2113. int level;
  2114. area = vty->index;
  2115. interval = DEFAULT_LSP_LIFETIME;
  2116. level = IS_LEVEL_1;
  2117. return set_lsp_max_lifetime (vty, area, interval, level);
  2118. }
  2119. ALIAS (no_max_lsp_lifetime_l1,
  2120. no_max_lsp_lifetime_l1_arg_cmd,
  2121. "no max-lsp-lifetime level-1 <350-65535>",
  2122. NO_STR
  2123. "Maximum LSP lifetime for Level 1 only\n"
  2124. "LSP lifetime for Level 1 only in seconds\n")
  2125. DEFUN (max_lsp_lifetime_l2,
  2126. max_lsp_lifetime_l2_cmd,
  2127. "max-lsp-lifetime level-2 <350-65535>",
  2128. "Maximum LSP lifetime for Level 2 only\n"
  2129. "LSP lifetime for Level 2 only in seconds\n")
  2130. {
  2131. struct isis_area *area;
  2132. uint16_t interval;
  2133. int level;
  2134. area = vty->index;
  2135. interval = atoi (argv[0]);
  2136. level = IS_LEVEL_2;
  2137. return set_lsp_max_lifetime (vty, area, interval, level);
  2138. }
  2139. DEFUN (no_max_lsp_lifetime_l2,
  2140. no_max_lsp_lifetime_l2_cmd,
  2141. "no max-lsp-lifetime level-2",
  2142. NO_STR
  2143. "LSP lifetime for Level 2 only in seconds\n")
  2144. {
  2145. struct isis_area *area;
  2146. uint16_t interval;
  2147. int level;
  2148. area = vty->index;
  2149. interval = DEFAULT_LSP_LIFETIME;
  2150. level = IS_LEVEL_2;
  2151. return set_lsp_max_lifetime (vty, area, interval, level);
  2152. }
  2153. ALIAS (no_max_lsp_lifetime_l2,
  2154. no_max_lsp_lifetime_l2_arg_cmd,
  2155. "no max-lsp-lifetime level-2 <350-65535>",
  2156. NO_STR
  2157. "Maximum LSP lifetime for Level 2 only\n"
  2158. "LSP lifetime for Level 2 only in seconds\n")
  2159. static int
  2160. set_lsp_refresh_interval (struct vty *vty, struct isis_area *area,
  2161. uint16_t interval, int level)
  2162. {
  2163. int lvl;
  2164. for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
  2165. {
  2166. if (!(lvl & level))
  2167. continue;
  2168. if (interval <= area->lsp_gen_interval[lvl-1])
  2169. {
  2170. vty_out (vty, "LSP refresh interval %us must be greater than "
  2171. "the configured LSP gen interval %us%s",
  2172. interval, area->lsp_gen_interval[lvl-1],
  2173. VTY_NEWLINE);
  2174. return CMD_ERR_AMBIGUOUS;
  2175. }
  2176. if (interval > (area->max_lsp_lifetime[lvl-1] - 300))
  2177. {
  2178. vty_out (vty, "LSP refresh interval %us must be less than "
  2179. "the configured LSP lifetime %us less 300%s",
  2180. interval, area->max_lsp_lifetime[lvl-1],
  2181. VTY_NEWLINE);
  2182. return CMD_ERR_AMBIGUOUS;
  2183. }
  2184. }
  2185. for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl)
  2186. {
  2187. if (!(lvl & level))
  2188. continue;
  2189. area->lsp_refresh[lvl-1] = interval;
  2190. }
  2191. lsp_regenerate_schedule (area, level, 1);
  2192. return CMD_SUCCESS;
  2193. }
  2194. DEFUN (lsp_refresh_interval,
  2195. lsp_refresh_interval_cmd,
  2196. "lsp-refresh-interval <1-65235>",
  2197. "LSP refresh interval\n"
  2198. "LSP refresh interval in seconds\n")
  2199. {
  2200. struct isis_area *area;
  2201. uint16_t interval;
  2202. int level;
  2203. area = vty->index;
  2204. interval = atoi (argv[0]);
  2205. level = IS_LEVEL_1 | IS_LEVEL_2;
  2206. return set_lsp_refresh_interval (vty, area, interval, level);
  2207. }
  2208. DEFUN (no_lsp_refresh_interval,
  2209. no_lsp_refresh_interval_cmd,
  2210. "no lsp-refresh-interval",
  2211. NO_STR
  2212. "LSP refresh interval in seconds\n")
  2213. {
  2214. struct isis_area *area;
  2215. uint16_t interval;
  2216. int level;
  2217. area = vty->index;
  2218. interval = DEFAULT_MAX_LSP_GEN_INTERVAL;
  2219. level = IS_LEVEL_1 | IS_LEVEL_2;
  2220. return set_lsp_refresh_interval (vty, area, interval, level);
  2221. }
  2222. ALIAS (no_lsp_refresh_interval,
  2223. no_lsp_refresh_interval_arg_cmd,
  2224. "no lsp-refresh-interval <1-65235>",
  2225. NO_STR
  2226. "LSP refresh interval\n"
  2227. "LSP refresh interval in seconds\n")
  2228. DEFUN (lsp_refresh_interval_l1,
  2229. lsp_refresh_interval_l1_cmd,
  2230. "lsp-refresh-interval level-1 <1-65235>",
  2231. "LSP refresh interval for Level 1 only\n"
  2232. "LSP refresh interval for Level 1 only in seconds\n")
  2233. {
  2234. struct isis_area *area;
  2235. uint16_t interval;
  2236. int level;
  2237. area = vty->index;
  2238. interval = atoi (argv[0]);
  2239. level = IS_LEVEL_1;
  2240. return set_lsp_refresh_interval (vty, area, interval, level);
  2241. }
  2242. DEFUN (no_lsp_refresh_interval_l1,
  2243. no_lsp_refresh_interval_l1_cmd,
  2244. "no lsp-refresh-interval level-1",
  2245. NO_STR
  2246. "LSP refresh interval for Level 1 only in seconds\n")
  2247. {
  2248. struct isis_area *area;
  2249. uint16_t interval;
  2250. int level;
  2251. area = vty->index;
  2252. interval = DEFAULT_MAX_LSP_GEN_INTERVAL;
  2253. level = IS_LEVEL_1;
  2254. return set_lsp_refresh_interval (vty, area, interval, level);
  2255. }
  2256. ALIAS (no_lsp_refresh_interval_l1,
  2257. no_lsp_refresh_interval_l1_arg_cmd,
  2258. "no lsp-refresh-interval level-1 <1-65235>",
  2259. NO_STR
  2260. "LSP refresh interval for Level 1 only\n"
  2261. "LSP refresh interval for Level 1 only in seconds\n")
  2262. DEFUN (lsp_refresh_interval_l2,
  2263. lsp_refresh_interval_l2_cmd,
  2264. "lsp-refresh-interval level-2 <1-65235>",
  2265. "LSP refresh interval for Level 2 only\n"
  2266. "LSP refresh interval for Level 2 only in seconds\n")
  2267. {
  2268. struct isis_area *area;
  2269. uint16_t interval;
  2270. int level;
  2271. area = vty->index;
  2272. interval = atoi (argv[0]);
  2273. level = IS_LEVEL_2;
  2274. return set_lsp_refresh_interval (vty, area, interval, level);
  2275. }
  2276. DEFUN (no_lsp_refresh_interval_l2,
  2277. no_lsp_refresh_interval_l2_cmd,
  2278. "no lsp-refresh-interval level-2",
  2279. NO_STR
  2280. "LSP refresh interval for Level 2 only in seconds\n")
  2281. {
  2282. struct isis_area *area;
  2283. uint16_t interval;
  2284. int level;
  2285. area = vty->index;
  2286. interval = DEFAULT_MAX_LSP_GEN_INTERVAL;
  2287. level = IS_LEVEL_2;
  2288. return set_lsp_refresh_interval (vty, area, interval, level);
  2289. }
  2290. ALIAS (no_lsp_refresh_interval_l2,
  2291. no_lsp_refresh_interval_l2_arg_cmd,
  2292. "no lsp-refresh-interval level-2 <1-65235>",
  2293. NO_STR
  2294. "LSP refresh interval for Level 2 only\n"
  2295. "LSP refresh interval for Level 2 only in seconds\n")
  2296. DEFUN (log_adj_changes,
  2297. log_adj_changes_cmd,
  2298. "log-adjacency-changes",
  2299. "Log changes in adjacency state\n")
  2300. {
  2301. struct isis_area *area;
  2302. area = vty->index;
  2303. assert (area);
  2304. area->log_adj_changes = 1;
  2305. return CMD_SUCCESS;
  2306. }
  2307. DEFUN (no_log_adj_changes,
  2308. no_log_adj_changes_cmd,
  2309. "no log-adjacency-changes",
  2310. "Stop logging changes in adjacency state\n")
  2311. {
  2312. struct isis_area *area;
  2313. area = vty->index;
  2314. assert (area);
  2315. area->log_adj_changes = 0;
  2316. return CMD_SUCCESS;
  2317. }
  2318. #ifdef TOPOLOGY_GENERATE
  2319. DEFUN (topology_generate_grid,
  2320. topology_generate_grid_cmd,
  2321. "topology generate grid <1-100> <1-100> <1-65000> [param] [param] "
  2322. "[param]",
  2323. "Topology generation for IS-IS\n"
  2324. "Topology generation\n"
  2325. "Grid topology\n"
  2326. "X parameter of the grid\n"
  2327. "Y parameter of the grid\n"
  2328. "Random seed\n"
  2329. "Optional param 1\n"
  2330. "Optional param 2\n"
  2331. "Optional param 3\n"
  2332. "Topology\n")
  2333. {
  2334. struct isis_area *area;
  2335. area = vty->index;
  2336. assert (area);
  2337. if (!spgrid_check_params (vty, argc, argv))
  2338. {
  2339. if (area->topology)
  2340. list_delete (area->topology);
  2341. area->topology = list_new ();
  2342. memcpy (area->top_params, vty->buf, 200);
  2343. gen_spgrid_topology (vty, area->topology);
  2344. remove_topology_lsps (area);
  2345. generate_topology_lsps (area);
  2346. /* Regenerate L1 LSP to get two way connection to the generated
  2347. * topology. */
  2348. lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
  2349. }
  2350. return CMD_SUCCESS;
  2351. }
  2352. DEFUN (show_isis_generated_topology,
  2353. show_isis_generated_topology_cmd,
  2354. "show isis generated-topologies",
  2355. SHOW_STR
  2356. "ISIS network information\n"
  2357. "Show generated topologies\n")
  2358. {
  2359. struct isis_area *area;
  2360. struct listnode *node;
  2361. struct listnode *node2;
  2362. struct arc *arc;
  2363. for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
  2364. {
  2365. if (!area->topology)
  2366. continue;
  2367. vty_out (vty, "Topology for isis area: %s%s", area->area_tag,
  2368. VTY_NEWLINE);
  2369. vty_out (vty, "From node To node Distance%s", VTY_NEWLINE);
  2370. for (ALL_LIST_ELEMENTS_RO (area->topology, node2, arc))
  2371. vty_out (vty, "%9ld %11ld %12ld%s", arc->from_node, arc->to_node,
  2372. arc->distance, VTY_NEWLINE);
  2373. }
  2374. return CMD_SUCCESS;
  2375. }
  2376. /* Base IS for topology generation. */
  2377. DEFUN (topology_baseis,
  2378. topology_baseis_cmd,
  2379. "topology base-is WORD",
  2380. "Topology generation for IS-IS\n"
  2381. "A Network IS Base for this topology\n"
  2382. "XXXX.XXXX.XXXX Network entity title (NET)\n")
  2383. {
  2384. struct isis_area *area;
  2385. u_char buff[ISIS_SYS_ID_LEN];
  2386. area = vty->index;
  2387. assert (area);
  2388. if (sysid2buff (buff, argv[0]))
  2389. sysid2buff (area->topology_baseis, argv[0]);
  2390. return CMD_SUCCESS;
  2391. }
  2392. DEFUN (no_topology_baseis,
  2393. no_topology_baseis_cmd,
  2394. "no topology base-is WORD",
  2395. NO_STR
  2396. "Topology generation for IS-IS\n"
  2397. "A Network IS Base for this topology\n"
  2398. "XXXX.XXXX.XXXX Network entity title (NET)\n")
  2399. {
  2400. struct isis_area *area;
  2401. area = vty->index;
  2402. assert (area);
  2403. memcpy (area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS, ISIS_SYS_ID_LEN);
  2404. return CMD_SUCCESS;
  2405. }
  2406. ALIAS (no_topology_baseis,
  2407. no_topology_baseis_noid_cmd,
  2408. "no topology base-is",
  2409. NO_STR
  2410. "Topology generation for IS-IS\n"
  2411. "A Network IS Base for this topology\n")
  2412. DEFUN (topology_basedynh,
  2413. topology_basedynh_cmd,
  2414. "topology base-dynh WORD",
  2415. "Topology generation for IS-IS\n"
  2416. "Dynamic hostname base for this topology\n"
  2417. "Dynamic hostname base\n")
  2418. {
  2419. struct isis_area *area;
  2420. area = vty->index;
  2421. assert (area);
  2422. /* I hope that it's enough. */
  2423. area->topology_basedynh = strndup (argv[0], 16);
  2424. return CMD_SUCCESS;
  2425. }
  2426. #endif /* TOPOLOGY_GENERATE */
  2427. /* IS-IS configuration write function */
  2428. int
  2429. isis_config_write (struct vty *vty)
  2430. {
  2431. int write = 0;
  2432. if (isis != NULL)
  2433. {
  2434. struct isis_area *area;
  2435. struct listnode *node, *node2;
  2436. for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
  2437. {
  2438. /* ISIS - Area name */
  2439. vty_out (vty, "router isis %s%s", area->area_tag, VTY_NEWLINE);
  2440. write++;
  2441. /* ISIS - Net */
  2442. if (listcount (area->area_addrs) > 0)
  2443. {
  2444. struct area_addr *area_addr;
  2445. for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node2, area_addr))
  2446. {
  2447. vty_out (vty, " net %s%s",
  2448. isonet_print (area_addr->area_addr,
  2449. area_addr->addr_len + ISIS_SYS_ID_LEN +
  2450. 1), VTY_NEWLINE);
  2451. write++;
  2452. }
  2453. }
  2454. /* ISIS - Dynamic hostname - Defaults to true so only display if
  2455. * false. */
  2456. if (!area->dynhostname)
  2457. {
  2458. vty_out (vty, " no hostname dynamic%s", VTY_NEWLINE);
  2459. write++;
  2460. }
  2461. /* ISIS - Metric-Style - when true displays wide */
  2462. if (area->newmetric)
  2463. {
  2464. if (!area->oldmetric)
  2465. vty_out (vty, " metric-style wide%s", VTY_NEWLINE);
  2466. else
  2467. vty_out (vty, " metric-style transition%s", VTY_NEWLINE);
  2468. write++;
  2469. }
  2470. else
  2471. {
  2472. vty_out (vty, " metric-style narrow%s", VTY_NEWLINE);
  2473. write++;
  2474. }
  2475. /* ISIS - overload-bit */
  2476. if (area->overload_bit)
  2477. {
  2478. vty_out (vty, " set-overload-bit%s", VTY_NEWLINE);
  2479. write++;
  2480. }
  2481. /* ISIS - Area is-type (level-1-2 is default) */
  2482. if (area->is_type == IS_LEVEL_1)
  2483. {
  2484. vty_out (vty, " is-type level-1%s", VTY_NEWLINE);
  2485. write++;
  2486. }
  2487. else if (area->is_type == IS_LEVEL_2)
  2488. {
  2489. vty_out (vty, " is-type level-2-only%s", VTY_NEWLINE);
  2490. write++;
  2491. }
  2492. /* ISIS - Lsp generation interval */
  2493. if (area->lsp_gen_interval[0] == area->lsp_gen_interval[1])
  2494. {
  2495. if (area->lsp_gen_interval[0] != DEFAULT_MIN_LSP_GEN_INTERVAL)
  2496. {
  2497. vty_out (vty, " lsp-gen-interval %d%s",
  2498. area->lsp_gen_interval[0], VTY_NEWLINE);
  2499. write++;
  2500. }
  2501. }
  2502. else
  2503. {
  2504. if (area->lsp_gen_interval[0] != DEFAULT_MIN_LSP_GEN_INTERVAL)
  2505. {
  2506. vty_out (vty, " lsp-gen-interval level-1 %d%s",
  2507. area->lsp_gen_interval[0], VTY_NEWLINE);
  2508. write++;
  2509. }
  2510. if (area->lsp_gen_interval[1] != DEFAULT_MIN_LSP_GEN_INTERVAL)
  2511. {
  2512. vty_out (vty, " lsp-gen-interval level-2 %d%s",
  2513. area->lsp_gen_interval[1], VTY_NEWLINE);
  2514. write++;
  2515. }
  2516. }
  2517. /* ISIS - LSP lifetime */
  2518. if (area->max_lsp_lifetime[0] == area->max_lsp_lifetime[1])
  2519. {
  2520. if (area->max_lsp_lifetime[0] != DEFAULT_LSP_LIFETIME)
  2521. {
  2522. vty_out (vty, " max-lsp-lifetime %u%s", area->max_lsp_lifetime[0],
  2523. VTY_NEWLINE);
  2524. write++;
  2525. }
  2526. }
  2527. else
  2528. {
  2529. if (area->max_lsp_lifetime[0] != DEFAULT_LSP_LIFETIME)
  2530. {
  2531. vty_out (vty, " max-lsp-lifetime level-1 %u%s",
  2532. area->max_lsp_lifetime[0], VTY_NEWLINE);
  2533. write++;
  2534. }
  2535. if (area->max_lsp_lifetime[1] != DEFAULT_LSP_LIFETIME)
  2536. {
  2537. vty_out (vty, " max-lsp-lifetime level-2 %u%s",
  2538. area->max_lsp_lifetime[1], VTY_NEWLINE);
  2539. write++;
  2540. }
  2541. }
  2542. /* ISIS - LSP refresh interval */
  2543. if (area->lsp_refresh[0] == area->lsp_refresh[1])
  2544. {
  2545. if (area->lsp_refresh[0] != DEFAULT_MAX_LSP_GEN_INTERVAL)
  2546. {
  2547. vty_out (vty, " lsp-refresh-interval %u%s", area->lsp_refresh[0],
  2548. VTY_NEWLINE);
  2549. write++;
  2550. }
  2551. }
  2552. else
  2553. {
  2554. if (area->lsp_refresh[0] != DEFAULT_MAX_LSP_GEN_INTERVAL)
  2555. {
  2556. vty_out (vty, " lsp-refresh-interval level-1 %u%s",
  2557. area->lsp_refresh[0], VTY_NEWLINE);
  2558. write++;
  2559. }
  2560. if (area->lsp_refresh[1] != DEFAULT_MAX_LSP_GEN_INTERVAL)
  2561. {
  2562. vty_out (vty, " lsp-refresh-interval level-2 %u%s",
  2563. area->lsp_refresh[1], VTY_NEWLINE);
  2564. write++;
  2565. }
  2566. }
  2567. /* Minimum SPF interval. */
  2568. if (area->min_spf_interval[0] == area->min_spf_interval[1])
  2569. {
  2570. if (area->min_spf_interval[0] != MINIMUM_SPF_INTERVAL)
  2571. {
  2572. vty_out (vty, " spf-interval %d%s",
  2573. area->min_spf_interval[0], VTY_NEWLINE);
  2574. write++;
  2575. }
  2576. }
  2577. else
  2578. {
  2579. if (area->min_spf_interval[0] != MINIMUM_SPF_INTERVAL)
  2580. {
  2581. vty_out (vty, " spf-interval level-1 %d%s",
  2582. area->min_spf_interval[0], VTY_NEWLINE);
  2583. write++;
  2584. }
  2585. if (area->min_spf_interval[1] != MINIMUM_SPF_INTERVAL)
  2586. {
  2587. vty_out (vty, " spf-interval level-2 %d%s",
  2588. area->min_spf_interval[1], VTY_NEWLINE);
  2589. write++;
  2590. }
  2591. }
  2592. /* Authentication passwords. */
  2593. if (area->area_passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5)
  2594. {
  2595. vty_out(vty, " area-password md5 %s", area->area_passwd.passwd);
  2596. if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND))
  2597. {
  2598. vty_out(vty, " authenticate snp ");
  2599. if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV))
  2600. vty_out(vty, "validate");
  2601. else
  2602. vty_out(vty, "send-only");
  2603. }
  2604. vty_out(vty, "%s", VTY_NEWLINE);
  2605. write++;
  2606. }
  2607. else if (area->area_passwd.type == ISIS_PASSWD_TYPE_CLEARTXT)
  2608. {
  2609. vty_out(vty, " area-password clear %s", area->area_passwd.passwd);
  2610. if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_SEND))
  2611. {
  2612. vty_out(vty, " authenticate snp ");
  2613. if (CHECK_FLAG(area->area_passwd.snp_auth, SNP_AUTH_RECV))
  2614. vty_out(vty, "validate");
  2615. else
  2616. vty_out(vty, "send-only");
  2617. }
  2618. vty_out(vty, "%s", VTY_NEWLINE);
  2619. write++;
  2620. }
  2621. if (area->domain_passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5)
  2622. {
  2623. vty_out(vty, " domain-password md5 %s",
  2624. area->domain_passwd.passwd);
  2625. if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND))
  2626. {
  2627. vty_out(vty, " authenticate snp ");
  2628. if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV))
  2629. vty_out(vty, "validate");
  2630. else
  2631. vty_out(vty, "send-only");
  2632. }
  2633. vty_out(vty, "%s", VTY_NEWLINE);
  2634. write++;
  2635. }
  2636. else if (area->domain_passwd.type == ISIS_PASSWD_TYPE_CLEARTXT)
  2637. {
  2638. vty_out(vty, " domain-password clear %s",
  2639. area->domain_passwd.passwd);
  2640. if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_SEND))
  2641. {
  2642. vty_out(vty, " authenticate snp ");
  2643. if (CHECK_FLAG(area->domain_passwd.snp_auth, SNP_AUTH_RECV))
  2644. vty_out(vty, "validate");
  2645. else
  2646. vty_out(vty, "send-only");
  2647. }
  2648. vty_out(vty, "%s", VTY_NEWLINE);
  2649. write++;
  2650. }
  2651. if (area->log_adj_changes)
  2652. {
  2653. vty_out (vty, " log-adjacency-changes%s", VTY_NEWLINE);
  2654. write++;
  2655. }
  2656. #ifdef TOPOLOGY_GENERATE
  2657. if (memcmp (area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS,
  2658. ISIS_SYS_ID_LEN))
  2659. {
  2660. vty_out (vty, " topology base-is %s%s",
  2661. sysid_print ((u_char *)area->topology_baseis), VTY_NEWLINE);
  2662. write++;
  2663. }
  2664. if (area->topology_basedynh)
  2665. {
  2666. vty_out (vty, " topology base-dynh %s%s",
  2667. area->topology_basedynh, VTY_NEWLINE);
  2668. write++;
  2669. }
  2670. /* We save the whole command line here. */
  2671. if (strlen(area->top_params))
  2672. {
  2673. vty_out (vty, " %s%s", area->top_params, VTY_NEWLINE);
  2674. write++;
  2675. }
  2676. #endif /* TOPOLOGY_GENERATE */
  2677. }
  2678. }
  2679. return write;
  2680. }
  2681. struct cmd_node isis_node = {
  2682. ISIS_NODE,
  2683. "%s(config-router)# ",
  2684. 1
  2685. };
  2686. void
  2687. isis_init ()
  2688. {
  2689. /* Install IS-IS top node */
  2690. install_node (&isis_node, isis_config_write);
  2691. install_element (VIEW_NODE, &show_isis_summary_cmd);
  2692. install_element (VIEW_NODE, &show_isis_interface_cmd);
  2693. install_element (VIEW_NODE, &show_isis_interface_detail_cmd);
  2694. install_element (VIEW_NODE, &show_isis_interface_arg_cmd);
  2695. install_element (VIEW_NODE, &show_isis_neighbor_cmd);
  2696. install_element (VIEW_NODE, &show_isis_neighbor_detail_cmd);
  2697. install_element (VIEW_NODE, &show_isis_neighbor_arg_cmd);
  2698. install_element (VIEW_NODE, &clear_isis_neighbor_cmd);
  2699. install_element (VIEW_NODE, &clear_isis_neighbor_arg_cmd);
  2700. install_element (VIEW_NODE, &show_hostname_cmd);
  2701. install_element (VIEW_NODE, &show_database_cmd);
  2702. install_element (VIEW_NODE, &show_database_arg_cmd);
  2703. install_element (VIEW_NODE, &show_database_arg_detail_cmd);
  2704. install_element (VIEW_NODE, &show_database_detail_cmd);
  2705. install_element (VIEW_NODE, &show_database_detail_arg_cmd);
  2706. install_element (ENABLE_NODE, &show_isis_summary_cmd);
  2707. install_element (ENABLE_NODE, &show_isis_interface_cmd);
  2708. install_element (ENABLE_NODE, &show_isis_interface_detail_cmd);
  2709. install_element (ENABLE_NODE, &show_isis_interface_arg_cmd);
  2710. install_element (ENABLE_NODE, &show_isis_neighbor_cmd);
  2711. install_element (ENABLE_NODE, &show_isis_neighbor_detail_cmd);
  2712. install_element (ENABLE_NODE, &show_isis_neighbor_arg_cmd);
  2713. install_element (ENABLE_NODE, &clear_isis_neighbor_cmd);
  2714. install_element (ENABLE_NODE, &clear_isis_neighbor_arg_cmd);
  2715. install_element (ENABLE_NODE, &show_hostname_cmd);
  2716. install_element (ENABLE_NODE, &show_database_cmd);
  2717. install_element (ENABLE_NODE, &show_database_arg_cmd);
  2718. install_element (ENABLE_NODE, &show_database_arg_detail_cmd);
  2719. install_element (ENABLE_NODE, &show_database_detail_cmd);
  2720. install_element (ENABLE_NODE, &show_database_detail_arg_cmd);
  2721. install_element (ENABLE_NODE, &show_debugging_cmd);
  2722. install_node (&debug_node, config_write_debug);
  2723. install_element (ENABLE_NODE, &debug_isis_adj_cmd);
  2724. install_element (ENABLE_NODE, &no_debug_isis_adj_cmd);
  2725. install_element (ENABLE_NODE, &debug_isis_csum_cmd);
  2726. install_element (ENABLE_NODE, &no_debug_isis_csum_cmd);
  2727. install_element (ENABLE_NODE, &debug_isis_lupd_cmd);
  2728. install_element (ENABLE_NODE, &no_debug_isis_lupd_cmd);
  2729. install_element (ENABLE_NODE, &debug_isis_err_cmd);
  2730. install_element (ENABLE_NODE, &no_debug_isis_err_cmd);
  2731. install_element (ENABLE_NODE, &debug_isis_snp_cmd);
  2732. install_element (ENABLE_NODE, &no_debug_isis_snp_cmd);
  2733. install_element (ENABLE_NODE, &debug_isis_upd_cmd);
  2734. install_element (ENABLE_NODE, &no_debug_isis_upd_cmd);
  2735. install_element (ENABLE_NODE, &debug_isis_spfevents_cmd);
  2736. install_element (ENABLE_NODE, &no_debug_isis_spfevents_cmd);
  2737. install_element (ENABLE_NODE, &debug_isis_spfstats_cmd);
  2738. install_element (ENABLE_NODE, &no_debug_isis_spfstats_cmd);
  2739. install_element (ENABLE_NODE, &debug_isis_spftrigg_cmd);
  2740. install_element (ENABLE_NODE, &no_debug_isis_spftrigg_cmd);
  2741. install_element (ENABLE_NODE, &debug_isis_rtevents_cmd);
  2742. install_element (ENABLE_NODE, &no_debug_isis_rtevents_cmd);
  2743. install_element (ENABLE_NODE, &debug_isis_events_cmd);
  2744. install_element (ENABLE_NODE, &no_debug_isis_events_cmd);
  2745. install_element (ENABLE_NODE, &debug_isis_packet_dump_cmd);
  2746. install_element (ENABLE_NODE, &no_debug_isis_packet_dump_cmd);
  2747. install_element (CONFIG_NODE, &debug_isis_adj_cmd);
  2748. install_element (CONFIG_NODE, &no_debug_isis_adj_cmd);
  2749. install_element (CONFIG_NODE, &debug_isis_csum_cmd);
  2750. install_element (CONFIG_NODE, &no_debug_isis_csum_cmd);
  2751. install_element (CONFIG_NODE, &debug_isis_lupd_cmd);
  2752. install_element (CONFIG_NODE, &no_debug_isis_lupd_cmd);
  2753. install_element (CONFIG_NODE, &debug_isis_err_cmd);
  2754. install_element (CONFIG_NODE, &no_debug_isis_err_cmd);
  2755. install_element (CONFIG_NODE, &debug_isis_snp_cmd);
  2756. install_element (CONFIG_NODE, &no_debug_isis_snp_cmd);
  2757. install_element (CONFIG_NODE, &debug_isis_upd_cmd);
  2758. install_element (CONFIG_NODE, &no_debug_isis_upd_cmd);
  2759. install_element (CONFIG_NODE, &debug_isis_spfevents_cmd);
  2760. install_element (CONFIG_NODE, &no_debug_isis_spfevents_cmd);
  2761. install_element (CONFIG_NODE, &debug_isis_spfstats_cmd);
  2762. install_element (CONFIG_NODE, &no_debug_isis_spfstats_cmd);
  2763. install_element (CONFIG_NODE, &debug_isis_spftrigg_cmd);
  2764. install_element (CONFIG_NODE, &no_debug_isis_spftrigg_cmd);
  2765. install_element (CONFIG_NODE, &debug_isis_rtevents_cmd);
  2766. install_element (CONFIG_NODE, &no_debug_isis_rtevents_cmd);
  2767. install_element (CONFIG_NODE, &debug_isis_events_cmd);
  2768. install_element (CONFIG_NODE, &no_debug_isis_events_cmd);
  2769. install_element (CONFIG_NODE, &debug_isis_packet_dump_cmd);
  2770. install_element (CONFIG_NODE, &no_debug_isis_packet_dump_cmd);
  2771. install_element (CONFIG_NODE, &router_isis_cmd);
  2772. install_element (CONFIG_NODE, &no_router_isis_cmd);
  2773. install_default (ISIS_NODE);
  2774. install_element (ISIS_NODE, &net_cmd);
  2775. install_element (ISIS_NODE, &no_net_cmd);
  2776. install_element (ISIS_NODE, &is_type_cmd);
  2777. install_element (ISIS_NODE, &no_is_type_cmd);
  2778. install_element (ISIS_NODE, &area_passwd_md5_cmd);
  2779. install_element (ISIS_NODE, &area_passwd_md5_snpauth_cmd);
  2780. install_element (ISIS_NODE, &area_passwd_clear_cmd);
  2781. install_element (ISIS_NODE, &area_passwd_clear_snpauth_cmd);
  2782. install_element (ISIS_NODE, &no_area_passwd_cmd);
  2783. install_element (ISIS_NODE, &domain_passwd_md5_cmd);
  2784. install_element (ISIS_NODE, &domain_passwd_md5_snpauth_cmd);
  2785. install_element (ISIS_NODE, &domain_passwd_clear_cmd);
  2786. install_element (ISIS_NODE, &domain_passwd_clear_snpauth_cmd);
  2787. install_element (ISIS_NODE, &no_domain_passwd_cmd);
  2788. install_element (ISIS_NODE, &lsp_gen_interval_cmd);
  2789. install_element (ISIS_NODE, &no_lsp_gen_interval_cmd);
  2790. install_element (ISIS_NODE, &no_lsp_gen_interval_arg_cmd);
  2791. install_element (ISIS_NODE, &lsp_gen_interval_l1_cmd);
  2792. install_element (ISIS_NODE, &no_lsp_gen_interval_l1_cmd);
  2793. install_element (ISIS_NODE, &no_lsp_gen_interval_l1_arg_cmd);
  2794. install_element (ISIS_NODE, &lsp_gen_interval_l2_cmd);
  2795. install_element (ISIS_NODE, &no_lsp_gen_interval_l2_cmd);
  2796. install_element (ISIS_NODE, &no_lsp_gen_interval_l2_arg_cmd);
  2797. install_element (ISIS_NODE, &spf_interval_cmd);
  2798. install_element (ISIS_NODE, &no_spf_interval_cmd);
  2799. install_element (ISIS_NODE, &no_spf_interval_arg_cmd);
  2800. install_element (ISIS_NODE, &spf_interval_l1_cmd);
  2801. install_element (ISIS_NODE, &no_spf_interval_l1_cmd);
  2802. install_element (ISIS_NODE, &no_spf_interval_l1_arg_cmd);
  2803. install_element (ISIS_NODE, &spf_interval_l2_cmd);
  2804. install_element (ISIS_NODE, &no_spf_interval_l2_cmd);
  2805. install_element (ISIS_NODE, &no_spf_interval_l2_arg_cmd);
  2806. install_element (ISIS_NODE, &max_lsp_lifetime_cmd);
  2807. install_element (ISIS_NODE, &no_max_lsp_lifetime_cmd);
  2808. install_element (ISIS_NODE, &no_max_lsp_lifetime_arg_cmd);
  2809. install_element (ISIS_NODE, &max_lsp_lifetime_l1_cmd);
  2810. install_element (ISIS_NODE, &no_max_lsp_lifetime_l1_cmd);
  2811. install_element (ISIS_NODE, &no_max_lsp_lifetime_l1_arg_cmd);
  2812. install_element (ISIS_NODE, &max_lsp_lifetime_l2_cmd);
  2813. install_element (ISIS_NODE, &no_max_lsp_lifetime_l2_cmd);
  2814. install_element (ISIS_NODE, &no_max_lsp_lifetime_l2_arg_cmd);
  2815. install_element (ISIS_NODE, &lsp_refresh_interval_cmd);
  2816. install_element (ISIS_NODE, &no_lsp_refresh_interval_cmd);
  2817. install_element (ISIS_NODE, &no_lsp_refresh_interval_arg_cmd);
  2818. install_element (ISIS_NODE, &lsp_refresh_interval_l1_cmd);
  2819. install_element (ISIS_NODE, &no_lsp_refresh_interval_l1_cmd);
  2820. install_element (ISIS_NODE, &no_lsp_refresh_interval_l1_arg_cmd);
  2821. install_element (ISIS_NODE, &lsp_refresh_interval_l2_cmd);
  2822. install_element (ISIS_NODE, &no_lsp_refresh_interval_l2_cmd);
  2823. install_element (ISIS_NODE, &no_lsp_refresh_interval_l2_arg_cmd);
  2824. install_element (ISIS_NODE, &set_overload_bit_cmd);
  2825. install_element (ISIS_NODE, &no_set_overload_bit_cmd);
  2826. install_element (ISIS_NODE, &dynamic_hostname_cmd);
  2827. install_element (ISIS_NODE, &no_dynamic_hostname_cmd);
  2828. install_element (ISIS_NODE, &metric_style_cmd);
  2829. install_element (ISIS_NODE, &no_metric_style_cmd);
  2830. install_element (ISIS_NODE, &log_adj_changes_cmd);
  2831. install_element (ISIS_NODE, &no_log_adj_changes_cmd);
  2832. #ifdef TOPOLOGY_GENERATE
  2833. install_element (ISIS_NODE, &topology_generate_grid_cmd);
  2834. install_element (ISIS_NODE, &topology_baseis_cmd);
  2835. install_element (ISIS_NODE, &topology_basedynh_cmd);
  2836. install_element (ISIS_NODE, &no_topology_baseis_cmd);
  2837. install_element (ISIS_NODE, &no_topology_baseis_noid_cmd);
  2838. install_element (VIEW_NODE, &show_isis_generated_topology_cmd);
  2839. install_element (ENABLE_NODE, &show_isis_generated_topology_cmd);
  2840. #endif /* TOPOLOGY_GENERATE */
  2841. }