ospf_dump.c 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718
  1. /*
  2. * OSPFd dump routine.
  3. * Copyright (C) 1999, 2000 Toshiaki Takada
  4. *
  5. * This file is part of GNU Zebra.
  6. *
  7. * GNU Zebra is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2, or (at your option) any
  10. * later version.
  11. *
  12. * GNU Zebra is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with GNU Zebra; see the file COPYING. If not, write to the
  19. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  20. * Boston, MA 02111-1307, USA.
  21. */
  22. #include <zebra.h>
  23. #include "linklist.h"
  24. #include "thread.h"
  25. #include "prefix.h"
  26. #include "command.h"
  27. #include "stream.h"
  28. #include "log.h"
  29. #include "sockopt.h"
  30. #include "ospfd/ospfd.h"
  31. #include "ospfd/ospf_interface.h"
  32. #include "ospfd/ospf_ism.h"
  33. #include "ospfd/ospf_asbr.h"
  34. #include "ospfd/ospf_lsa.h"
  35. #include "ospfd/ospf_lsdb.h"
  36. #include "ospfd/ospf_neighbor.h"
  37. #include "ospfd/ospf_nsm.h"
  38. #include "ospfd/ospf_dump.h"
  39. #include "ospfd/ospf_packet.h"
  40. #include "ospfd/ospf_network.h"
  41. const struct message ospf_ism_state_msg[] =
  42. {
  43. { ISM_DependUpon, "DependUpon" },
  44. { ISM_Down, "Down" },
  45. { ISM_Loopback, "Loopback" },
  46. { ISM_Waiting, "Waiting" },
  47. { ISM_PointToPoint, "Point-To-Point" },
  48. { ISM_DROther, "DROther" },
  49. { ISM_Backup, "Backup" },
  50. { ISM_DR, "DR" },
  51. };
  52. const int ospf_ism_state_msg_max = OSPF_ISM_STATE_MAX;
  53. const struct message ospf_nsm_state_msg[] =
  54. {
  55. { NSM_DependUpon, "DependUpon" },
  56. { NSM_Deleted, "Deleted" },
  57. { NSM_Down, "Down" },
  58. { NSM_Attempt, "Attempt" },
  59. { NSM_Init, "Init" },
  60. { NSM_TwoWay, "2-Way" },
  61. { NSM_ExStart, "ExStart" },
  62. { NSM_Exchange, "Exchange" },
  63. { NSM_Loading, "Loading" },
  64. { NSM_Full, "Full" },
  65. };
  66. const int ospf_nsm_state_msg_max = OSPF_NSM_STATE_MAX;
  67. const struct message ospf_lsa_type_msg[] =
  68. {
  69. { OSPF_UNKNOWN_LSA, "unknown" },
  70. { OSPF_ROUTER_LSA, "router-LSA" },
  71. { OSPF_NETWORK_LSA, "network-LSA" },
  72. { OSPF_SUMMARY_LSA, "summary-LSA" },
  73. { OSPF_ASBR_SUMMARY_LSA, "summary-LSA" },
  74. { OSPF_AS_EXTERNAL_LSA, "AS-external-LSA" },
  75. { OSPF_GROUP_MEMBER_LSA, "GROUP MEMBER LSA" },
  76. { OSPF_AS_NSSA_LSA, "NSSA-LSA" },
  77. { 8, "Type-8 LSA" },
  78. { OSPF_OPAQUE_LINK_LSA, "Link-Local Opaque-LSA" },
  79. { OSPF_OPAQUE_AREA_LSA, "Area-Local Opaque-LSA" },
  80. { OSPF_OPAQUE_AS_LSA, "AS-external Opaque-LSA" },
  81. };
  82. const int ospf_lsa_type_msg_max = OSPF_MAX_LSA;
  83. const struct message ospf_link_state_id_type_msg[] =
  84. {
  85. { OSPF_UNKNOWN_LSA, "(unknown)" },
  86. { OSPF_ROUTER_LSA, "" },
  87. { OSPF_NETWORK_LSA, "(address of Designated Router)" },
  88. { OSPF_SUMMARY_LSA, "(summary Network Number)" },
  89. { OSPF_ASBR_SUMMARY_LSA, "(AS Boundary Router address)" },
  90. { OSPF_AS_EXTERNAL_LSA, "(External Network Number)" },
  91. { OSPF_GROUP_MEMBER_LSA, "(Group membership information)" },
  92. { OSPF_AS_NSSA_LSA, "(External Network Number for NSSA)" },
  93. { 8, "(Type-8 LSID)" },
  94. { OSPF_OPAQUE_LINK_LSA, "(Link-Local Opaque-Type/ID)" },
  95. { OSPF_OPAQUE_AREA_LSA, "(Area-Local Opaque-Type/ID)" },
  96. { OSPF_OPAQUE_AS_LSA, "(AS-external Opaque-Type/ID)" },
  97. };
  98. const int ospf_link_state_id_type_msg_max = OSPF_MAX_LSA;
  99. const struct message ospf_network_type_msg[] =
  100. {
  101. { OSPF_IFTYPE_NONE, "NONE" },
  102. { OSPF_IFTYPE_POINTOPOINT, "Point-to-Point" },
  103. { OSPF_IFTYPE_BROADCAST, "Broadcast" },
  104. { OSPF_IFTYPE_NBMA, "NBMA" },
  105. { OSPF_IFTYPE_POINTOMULTIPOINT, "Point-to-MultiPoint" },
  106. { OSPF_IFTYPE_VIRTUALLINK, "Virtual-Link" },
  107. };
  108. const int ospf_network_type_msg_max = OSPF_IFTYPE_MAX;
  109. /* AuType */
  110. const struct message ospf_auth_type_str[] =
  111. {
  112. { OSPF_AUTH_NULL, "Null" },
  113. { OSPF_AUTH_SIMPLE, "Simple" },
  114. { OSPF_AUTH_CRYPTOGRAPHIC, "Cryptographic" },
  115. };
  116. const size_t ospf_auth_type_str_max = sizeof (ospf_auth_type_str) /
  117. sizeof (ospf_auth_type_str[0]);
  118. /* Configuration debug option variables. */
  119. unsigned long conf_debug_ospf_packet[5] = {0, 0, 0, 0, 0};
  120. unsigned long conf_debug_ospf_event = 0;
  121. unsigned long conf_debug_ospf_ism = 0;
  122. unsigned long conf_debug_ospf_nsm = 0;
  123. unsigned long conf_debug_ospf_lsa = 0;
  124. unsigned long conf_debug_ospf_zebra = 0;
  125. unsigned long conf_debug_ospf_nssa = 0;
  126. /* Enable debug option variables -- valid only session. */
  127. unsigned long term_debug_ospf_packet[5] = {0, 0, 0, 0, 0};
  128. unsigned long term_debug_ospf_event = 0;
  129. unsigned long term_debug_ospf_ism = 0;
  130. unsigned long term_debug_ospf_nsm = 0;
  131. unsigned long term_debug_ospf_lsa = 0;
  132. unsigned long term_debug_ospf_zebra = 0;
  133. unsigned long term_debug_ospf_nssa = 0;
  134. const char *
  135. ospf_redist_string(u_int route_type)
  136. {
  137. return (route_type == ZEBRA_ROUTE_MAX) ?
  138. "Default" : zebra_route_string(route_type);
  139. }
  140. #define OSPF_AREA_STRING_MAXLEN 16
  141. const char *
  142. ospf_area_name_string (struct ospf_area *area)
  143. {
  144. static char buf[OSPF_AREA_STRING_MAXLEN] = "";
  145. u_int32_t area_id;
  146. if (!area)
  147. return "-";
  148. area_id = ntohl (area->area_id.s_addr);
  149. snprintf (buf, OSPF_AREA_STRING_MAXLEN, "%d.%d.%d.%d",
  150. (area_id >> 24) & 0xff, (area_id >> 16) & 0xff,
  151. (area_id >> 8) & 0xff, area_id & 0xff);
  152. return buf;
  153. }
  154. #define OSPF_AREA_DESC_STRING_MAXLEN 23
  155. const char *
  156. ospf_area_desc_string (struct ospf_area *area)
  157. {
  158. static char buf[OSPF_AREA_DESC_STRING_MAXLEN] = "";
  159. u_char type;
  160. if (!area)
  161. return "(incomplete)";
  162. type = area->external_routing;
  163. switch (type)
  164. {
  165. case OSPF_AREA_NSSA:
  166. snprintf (buf, OSPF_AREA_DESC_STRING_MAXLEN, "%s [NSSA]",
  167. ospf_area_name_string (area));
  168. break;
  169. case OSPF_AREA_STUB:
  170. snprintf (buf, OSPF_AREA_DESC_STRING_MAXLEN, "%s [Stub]",
  171. ospf_area_name_string (area));
  172. break;
  173. default:
  174. return ospf_area_name_string (area);
  175. }
  176. return buf;
  177. }
  178. #define OSPF_IF_STRING_MAXLEN 40
  179. const char *
  180. ospf_if_name_string (struct ospf_interface *oi)
  181. {
  182. static char buf[OSPF_IF_STRING_MAXLEN] = "";
  183. u_int32_t ifaddr;
  184. if (!oi)
  185. return "inactive";
  186. if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
  187. return oi->ifp->name;
  188. ifaddr = ntohl (oi->address->u.prefix4.s_addr);
  189. snprintf (buf, OSPF_IF_STRING_MAXLEN,
  190. "%s:%d.%d.%d.%d", oi->ifp->name,
  191. (ifaddr >> 24) & 0xff, (ifaddr >> 16) & 0xff,
  192. (ifaddr >> 8) & 0xff, ifaddr & 0xff);
  193. return buf;
  194. }
  195. void
  196. ospf_nbr_state_message (struct ospf_neighbor *nbr, char *buf, size_t size)
  197. {
  198. int state;
  199. struct ospf_interface *oi = nbr->oi;
  200. if (IPV4_ADDR_SAME (&DR (oi), &nbr->address.u.prefix4))
  201. state = ISM_DR;
  202. else if (IPV4_ADDR_SAME (&BDR (oi), &nbr->address.u.prefix4))
  203. state = ISM_Backup;
  204. else
  205. state = ISM_DROther;
  206. memset (buf, 0, size);
  207. snprintf (buf, size, "%s/%s",
  208. LOOKUP (ospf_nsm_state_msg, nbr->state),
  209. LOOKUP (ospf_ism_state_msg, state));
  210. }
  211. const char *
  212. ospf_timeval_dump (struct timeval *t, char *buf, size_t size)
  213. {
  214. /* Making formatted timer strings. */
  215. #define MINUTE_IN_SECONDS 60
  216. #define HOUR_IN_SECONDS (60*MINUTE_IN_SECONDS)
  217. #define DAY_IN_SECONDS (24*HOUR_IN_SECONDS)
  218. #define WEEK_IN_SECONDS (7*DAY_IN_SECONDS)
  219. unsigned long w, d, h, m, s, ms, us;
  220. if (!t)
  221. return "inactive";
  222. w = d = h = m = s = ms = us = 0;
  223. memset (buf, 0, size);
  224. us = t->tv_usec;
  225. if (us >= 1000)
  226. {
  227. ms = us / 1000;
  228. us %= 1000;
  229. }
  230. if (ms >= 1000)
  231. {
  232. t->tv_sec += ms / 1000;
  233. ms %= 1000;
  234. }
  235. if (t->tv_sec > WEEK_IN_SECONDS)
  236. {
  237. w = t->tv_sec / WEEK_IN_SECONDS;
  238. t->tv_sec -= w * WEEK_IN_SECONDS;
  239. }
  240. if (t->tv_sec > DAY_IN_SECONDS)
  241. {
  242. d = t->tv_sec / DAY_IN_SECONDS;
  243. t->tv_sec -= d * DAY_IN_SECONDS;
  244. }
  245. if (t->tv_sec >= HOUR_IN_SECONDS)
  246. {
  247. h = t->tv_sec / HOUR_IN_SECONDS;
  248. t->tv_sec -= h * HOUR_IN_SECONDS;
  249. }
  250. if (t->tv_sec >= MINUTE_IN_SECONDS)
  251. {
  252. m = t->tv_sec / MINUTE_IN_SECONDS;
  253. t->tv_sec -= m * MINUTE_IN_SECONDS;
  254. }
  255. if (w > 99)
  256. snprintf (buf, size, "%ldw%1ldd", w, d);
  257. else if (w)
  258. snprintf (buf, size, "%ldw%1ldd%02ldh", w, d, h);
  259. else if (d)
  260. snprintf (buf, size, "%1ldd%02ldh%02ldm", d, h, m);
  261. else if (h)
  262. snprintf (buf, size, "%ldh%02ldm%02lds", h, m, t->tv_sec);
  263. else if (m)
  264. snprintf (buf, size, "%ldm%02lds", m, t->tv_sec);
  265. else if (ms)
  266. snprintf (buf, size, "%ld.%03lds", t->tv_sec, ms);
  267. else
  268. snprintf (buf, size, "%ld usecs", t->tv_usec);
  269. return buf;
  270. }
  271. const char *
  272. ospf_timer_dump (struct thread *t, char *buf, size_t size)
  273. {
  274. struct timeval result;
  275. if (!t)
  276. return "inactive";
  277. result = tv_sub (t->u.sands, recent_relative_time());
  278. return ospf_timeval_dump (&result, buf, size);
  279. }
  280. #define OSPF_OPTION_STR_MAXLEN 24
  281. char *
  282. ospf_options_dump (u_char options)
  283. {
  284. static char buf[OSPF_OPTION_STR_MAXLEN];
  285. snprintf (buf, OSPF_OPTION_STR_MAXLEN, "*|%s|%s|%s|%s|%s|%s|*",
  286. (options & OSPF_OPTION_O) ? "O" : "-",
  287. (options & OSPF_OPTION_DC) ? "DC" : "-",
  288. (options & OSPF_OPTION_EA) ? "EA" : "-",
  289. (options & OSPF_OPTION_NP) ? "N/P" : "-",
  290. (options & OSPF_OPTION_MC) ? "MC" : "-",
  291. (options & OSPF_OPTION_E) ? "E" : "-");
  292. return buf;
  293. }
  294. static void
  295. ospf_packet_hello_dump (struct stream *s, u_int16_t length)
  296. {
  297. struct ospf_hello *hello;
  298. int i;
  299. hello = (struct ospf_hello *) STREAM_PNT (s);
  300. zlog_debug ("Hello");
  301. zlog_debug (" NetworkMask %s", inet_ntoa (hello->network_mask));
  302. zlog_debug (" HelloInterval %d", ntohs (hello->hello_interval));
  303. zlog_debug (" Options %d (%s)", hello->options,
  304. ospf_options_dump (hello->options));
  305. zlog_debug (" RtrPriority %d", hello->priority);
  306. zlog_debug (" RtrDeadInterval %ld", (u_long)ntohl (hello->dead_interval));
  307. zlog_debug (" DRouter %s", inet_ntoa (hello->d_router));
  308. zlog_debug (" BDRouter %s", inet_ntoa (hello->bd_router));
  309. length -= OSPF_HEADER_SIZE + OSPF_HELLO_MIN_SIZE;
  310. zlog_debug (" # Neighbors %d", length / 4);
  311. for (i = 0; length > 0; i++, length -= sizeof (struct in_addr))
  312. zlog_debug (" Neighbor %s", inet_ntoa (hello->neighbors[i]));
  313. }
  314. static char *
  315. ospf_dd_flags_dump (u_char flags, char *buf, size_t size)
  316. {
  317. memset (buf, 0, size);
  318. snprintf (buf, size, "%s|%s|%s",
  319. (flags & OSPF_DD_FLAG_I) ? "I" : "-",
  320. (flags & OSPF_DD_FLAG_M) ? "M" : "-",
  321. (flags & OSPF_DD_FLAG_MS) ? "MS" : "-");
  322. return buf;
  323. }
  324. void
  325. ospf_lsa_header_dump (struct lsa_header *lsah)
  326. {
  327. const char *lsah_type = LOOKUP (ospf_lsa_type_msg, lsah->type);
  328. zlog_debug (" LSA Header");
  329. zlog_debug (" LS age %d", ntohs (lsah->ls_age));
  330. zlog_debug (" Options %d (%s)", lsah->options,
  331. ospf_options_dump (lsah->options));
  332. zlog_debug (" LS type %d (%s)", lsah->type,
  333. (lsah->type ? lsah_type : "unknown type"));
  334. zlog_debug (" Link State ID %s", inet_ntoa (lsah->id));
  335. zlog_debug (" Advertising Router %s", inet_ntoa (lsah->adv_router));
  336. zlog_debug (" LS sequence number 0x%lx", (u_long)ntohl (lsah->ls_seqnum));
  337. zlog_debug (" LS checksum 0x%x", ntohs (lsah->checksum));
  338. zlog_debug (" length %d", ntohs (lsah->length));
  339. }
  340. static char *
  341. ospf_router_lsa_flags_dump (u_char flags, char *buf, size_t size)
  342. {
  343. memset (buf, 0, size);
  344. snprintf (buf, size, "%s|%s|%s",
  345. (flags & ROUTER_LSA_VIRTUAL) ? "V" : "-",
  346. (flags & ROUTER_LSA_EXTERNAL) ? "E" : "-",
  347. (flags & ROUTER_LSA_BORDER) ? "B" : "-");
  348. return buf;
  349. }
  350. static void
  351. ospf_router_lsa_dump (struct stream *s, u_int16_t length)
  352. {
  353. char buf[BUFSIZ];
  354. struct router_lsa *rl;
  355. int i, len;
  356. rl = (struct router_lsa *) STREAM_PNT (s);
  357. zlog_debug (" Router-LSA");
  358. zlog_debug (" flags %s",
  359. ospf_router_lsa_flags_dump (rl->flags, buf, BUFSIZ));
  360. zlog_debug (" # links %d", ntohs (rl->links));
  361. len = ntohs (rl->header.length) - OSPF_LSA_HEADER_SIZE - 4;
  362. for (i = 0; len > 0; i++)
  363. {
  364. zlog_debug (" Link ID %s", inet_ntoa (rl->link[i].link_id));
  365. zlog_debug (" Link Data %s", inet_ntoa (rl->link[i].link_data));
  366. zlog_debug (" Type %d", (u_char) rl->link[i].type);
  367. zlog_debug (" TOS %d", (u_char) rl->link[i].tos);
  368. zlog_debug (" metric %d", ntohs (rl->link[i].metric));
  369. len -= 12;
  370. }
  371. }
  372. static void
  373. ospf_network_lsa_dump (struct stream *s, u_int16_t length)
  374. {
  375. struct network_lsa *nl;
  376. int i, cnt;
  377. nl = (struct network_lsa *) STREAM_PNT (s);
  378. cnt = (ntohs (nl->header.length) - (OSPF_LSA_HEADER_SIZE + 4)) / 4;
  379. zlog_debug (" Network-LSA");
  380. /*
  381. zlog_debug ("LSA total size %d", ntohs (nl->header.length));
  382. zlog_debug ("Network-LSA size %d",
  383. ntohs (nl->header.length) - OSPF_LSA_HEADER_SIZE);
  384. */
  385. zlog_debug (" Network Mask %s", inet_ntoa (nl->mask));
  386. zlog_debug (" # Attached Routers %d", cnt);
  387. for (i = 0; i < cnt; i++)
  388. zlog_debug (" Attached Router %s", inet_ntoa (nl->routers[i]));
  389. }
  390. static void
  391. ospf_summary_lsa_dump (struct stream *s, u_int16_t length)
  392. {
  393. struct summary_lsa *sl;
  394. int size;
  395. int i;
  396. sl = (struct summary_lsa *) STREAM_PNT (s);
  397. zlog_debug (" Summary-LSA");
  398. zlog_debug (" Network Mask %s", inet_ntoa (sl->mask));
  399. size = ntohs (sl->header.length) - OSPF_LSA_HEADER_SIZE - 4;
  400. for (i = 0; size > 0; size -= 4, i++)
  401. zlog_debug (" TOS=%d metric %d", sl->tos,
  402. GET_METRIC (sl->metric));
  403. }
  404. static void
  405. ospf_as_external_lsa_dump (struct stream *s, u_int16_t length)
  406. {
  407. struct as_external_lsa *al;
  408. int size;
  409. int i;
  410. al = (struct as_external_lsa *) STREAM_PNT (s);
  411. zlog_debug (" %s", ospf_lsa_type_msg[al->header.type].str);
  412. zlog_debug (" Network Mask %s", inet_ntoa (al->mask));
  413. size = ntohs (al->header.length) - OSPF_LSA_HEADER_SIZE -4;
  414. for (i = 0; size > 0; size -= 12, i++)
  415. {
  416. zlog_debug (" bit %s TOS=%d metric %d",
  417. IS_EXTERNAL_METRIC (al->e[i].tos) ? "E" : "-",
  418. al->e[i].tos & 0x7f, GET_METRIC (al->e[i].metric));
  419. zlog_debug (" Forwarding address %s", inet_ntoa (al->e[i].fwd_addr));
  420. zlog_debug (" External Route Tag %d", al->e[i].route_tag);
  421. }
  422. }
  423. static void
  424. ospf_lsa_header_list_dump (struct stream *s, u_int16_t length)
  425. {
  426. struct lsa_header *lsa;
  427. zlog_debug (" # LSA Headers %d", length / OSPF_LSA_HEADER_SIZE);
  428. /* LSA Headers. */
  429. while (length > 0)
  430. {
  431. lsa = (struct lsa_header *) STREAM_PNT (s);
  432. ospf_lsa_header_dump (lsa);
  433. stream_forward_getp (s, OSPF_LSA_HEADER_SIZE);
  434. length -= OSPF_LSA_HEADER_SIZE;
  435. }
  436. }
  437. static void
  438. ospf_packet_db_desc_dump (struct stream *s, u_int16_t length)
  439. {
  440. struct ospf_db_desc *dd;
  441. char dd_flags[8];
  442. u_int32_t gp;
  443. gp = stream_get_getp (s);
  444. dd = (struct ospf_db_desc *) STREAM_PNT (s);
  445. zlog_debug ("Database Description");
  446. zlog_debug (" Interface MTU %d", ntohs (dd->mtu));
  447. zlog_debug (" Options %d (%s)", dd->options,
  448. ospf_options_dump (dd->options));
  449. zlog_debug (" Flags %d (%s)", dd->flags,
  450. ospf_dd_flags_dump (dd->flags, dd_flags, sizeof dd_flags));
  451. zlog_debug (" Sequence Number 0x%08lx", (u_long)ntohl (dd->dd_seqnum));
  452. length -= OSPF_HEADER_SIZE + OSPF_DB_DESC_MIN_SIZE;
  453. stream_forward_getp (s, OSPF_DB_DESC_MIN_SIZE);
  454. ospf_lsa_header_list_dump (s, length);
  455. stream_set_getp (s, gp);
  456. }
  457. static void
  458. ospf_packet_ls_req_dump (struct stream *s, u_int16_t length)
  459. {
  460. u_int32_t sp;
  461. u_int32_t ls_type;
  462. struct in_addr ls_id;
  463. struct in_addr adv_router;
  464. sp = stream_get_getp (s);
  465. length -= OSPF_HEADER_SIZE;
  466. zlog_debug ("Link State Request");
  467. zlog_debug (" # Requests %d", length / 12);
  468. for (; length > 0; length -= 12)
  469. {
  470. ls_type = stream_getl (s);
  471. ls_id.s_addr = stream_get_ipv4 (s);
  472. adv_router.s_addr = stream_get_ipv4 (s);
  473. zlog_debug (" LS type %d", ls_type);
  474. zlog_debug (" Link State ID %s", inet_ntoa (ls_id));
  475. zlog_debug (" Advertising Router %s",
  476. inet_ntoa (adv_router));
  477. }
  478. stream_set_getp (s, sp);
  479. }
  480. static void
  481. ospf_packet_ls_upd_dump (struct stream *s, u_int16_t length)
  482. {
  483. u_int32_t sp;
  484. struct lsa_header *lsa;
  485. int lsa_len;
  486. u_int32_t count;
  487. length -= OSPF_HEADER_SIZE;
  488. sp = stream_get_getp (s);
  489. count = stream_getl (s);
  490. length -= 4;
  491. zlog_debug ("Link State Update");
  492. zlog_debug (" # LSAs %d", count);
  493. while (length > 0 && count > 0)
  494. {
  495. if (length < OSPF_HEADER_SIZE || length % 4 != 0)
  496. {
  497. zlog_debug (" Remaining %d bytes; Incorrect length.", length);
  498. break;
  499. }
  500. lsa = (struct lsa_header *) STREAM_PNT (s);
  501. lsa_len = ntohs (lsa->length);
  502. ospf_lsa_header_dump (lsa);
  503. switch (lsa->type)
  504. {
  505. case OSPF_ROUTER_LSA:
  506. ospf_router_lsa_dump (s, length);
  507. break;
  508. case OSPF_NETWORK_LSA:
  509. ospf_network_lsa_dump (s, length);
  510. break;
  511. case OSPF_SUMMARY_LSA:
  512. case OSPF_ASBR_SUMMARY_LSA:
  513. ospf_summary_lsa_dump (s, length);
  514. break;
  515. case OSPF_AS_EXTERNAL_LSA:
  516. ospf_as_external_lsa_dump (s, length);
  517. break;
  518. case OSPF_AS_NSSA_LSA:
  519. ospf_as_external_lsa_dump (s, length);
  520. break;
  521. #ifdef HAVE_OPAQUE_LSA
  522. case OSPF_OPAQUE_LINK_LSA:
  523. case OSPF_OPAQUE_AREA_LSA:
  524. case OSPF_OPAQUE_AS_LSA:
  525. ospf_opaque_lsa_dump (s, length);
  526. break;
  527. #endif /* HAVE_OPAQUE_LSA */
  528. default:
  529. break;
  530. }
  531. stream_forward_getp (s, lsa_len);
  532. length -= lsa_len;
  533. count--;
  534. }
  535. stream_set_getp (s, sp);
  536. }
  537. static void
  538. ospf_packet_ls_ack_dump (struct stream *s, u_int16_t length)
  539. {
  540. u_int32_t sp;
  541. length -= OSPF_HEADER_SIZE;
  542. sp = stream_get_getp (s);
  543. zlog_debug ("Link State Acknowledgment");
  544. ospf_lsa_header_list_dump (s, length);
  545. stream_set_getp (s, sp);
  546. }
  547. /* Expects header to be in host order */
  548. void
  549. ospf_ip_header_dump (struct ip *iph)
  550. {
  551. /* IP Header dump. */
  552. zlog_debug ("ip_v %d", iph->ip_v);
  553. zlog_debug ("ip_hl %d", iph->ip_hl);
  554. zlog_debug ("ip_tos %d", iph->ip_tos);
  555. zlog_debug ("ip_len %d", iph->ip_len);
  556. zlog_debug ("ip_id %u", (u_int32_t) iph->ip_id);
  557. zlog_debug ("ip_off %u", (u_int32_t) iph->ip_off);
  558. zlog_debug ("ip_ttl %d", iph->ip_ttl);
  559. zlog_debug ("ip_p %d", iph->ip_p);
  560. zlog_debug ("ip_sum 0x%x", (u_int32_t) iph->ip_sum);
  561. zlog_debug ("ip_src %s", inet_ntoa (iph->ip_src));
  562. zlog_debug ("ip_dst %s", inet_ntoa (iph->ip_dst));
  563. }
  564. static void
  565. ospf_header_dump (struct ospf_header *ospfh)
  566. {
  567. char buf[9];
  568. u_int16_t auth_type = ntohs (ospfh->auth_type);
  569. zlog_debug ("Header");
  570. zlog_debug (" Version %d", ospfh->version);
  571. zlog_debug (" Type %d (%s)", ospfh->type,
  572. LOOKUP (ospf_packet_type_str, ospfh->type));
  573. zlog_debug (" Packet Len %d", ntohs (ospfh->length));
  574. zlog_debug (" Router ID %s", inet_ntoa (ospfh->router_id));
  575. zlog_debug (" Area ID %s", inet_ntoa (ospfh->area_id));
  576. zlog_debug (" Checksum 0x%x", ntohs (ospfh->checksum));
  577. zlog_debug (" AuType %s", LOOKUP (ospf_auth_type_str, auth_type));
  578. switch (auth_type)
  579. {
  580. case OSPF_AUTH_NULL:
  581. break;
  582. case OSPF_AUTH_SIMPLE:
  583. memset (buf, 0, 9);
  584. strncpy (buf, (char *) ospfh->u.auth_data, 8);
  585. zlog_debug (" Simple Password %s", buf);
  586. break;
  587. case OSPF_AUTH_CRYPTOGRAPHIC:
  588. zlog_debug (" Cryptographic Authentication");
  589. zlog_debug (" Key ID %d", ospfh->u.crypt.key_id);
  590. zlog_debug (" Auth Data Len %d", ospfh->u.crypt.auth_data_len);
  591. zlog_debug (" Sequence number %ld",
  592. (u_long)ntohl (ospfh->u.crypt.crypt_seqnum));
  593. break;
  594. default:
  595. zlog_debug ("* This is not supported authentication type");
  596. break;
  597. }
  598. }
  599. void
  600. ospf_packet_dump (struct stream *s)
  601. {
  602. struct ospf_header *ospfh;
  603. unsigned long gp;
  604. /* Preserve pointer. */
  605. gp = stream_get_getp (s);
  606. /* OSPF Header dump. */
  607. ospfh = (struct ospf_header *) STREAM_PNT (s);
  608. /* Until detail flag is set, return. */
  609. if (!(term_debug_ospf_packet[ospfh->type - 1] & OSPF_DEBUG_DETAIL))
  610. return;
  611. /* Show OSPF header detail. */
  612. ospf_header_dump (ospfh);
  613. stream_forward_getp (s, OSPF_HEADER_SIZE);
  614. switch (ospfh->type)
  615. {
  616. case OSPF_MSG_HELLO:
  617. ospf_packet_hello_dump (s, ntohs (ospfh->length));
  618. break;
  619. case OSPF_MSG_DB_DESC:
  620. ospf_packet_db_desc_dump (s, ntohs (ospfh->length));
  621. break;
  622. case OSPF_MSG_LS_REQ:
  623. ospf_packet_ls_req_dump (s, ntohs (ospfh->length));
  624. break;
  625. case OSPF_MSG_LS_UPD:
  626. ospf_packet_ls_upd_dump (s, ntohs (ospfh->length));
  627. break;
  628. case OSPF_MSG_LS_ACK:
  629. ospf_packet_ls_ack_dump (s, ntohs (ospfh->length));
  630. break;
  631. default:
  632. break;
  633. }
  634. stream_set_getp (s, gp);
  635. }
  636. /*
  637. [no] debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)
  638. [send|recv [detail]]
  639. */
  640. DEFUN (debug_ospf_packet,
  641. debug_ospf_packet_all_cmd,
  642. "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)",
  643. DEBUG_STR
  644. OSPF_STR
  645. "OSPF packets\n"
  646. "OSPF Hello\n"
  647. "OSPF Database Description\n"
  648. "OSPF Link State Request\n"
  649. "OSPF Link State Update\n"
  650. "OSPF Link State Acknowledgment\n"
  651. "OSPF all packets\n")
  652. {
  653. int type = 0;
  654. int flag = 0;
  655. int i;
  656. assert (argc > 0);
  657. /* Check packet type. */
  658. if (strncmp (argv[0], "h", 1) == 0)
  659. type = OSPF_DEBUG_HELLO;
  660. else if (strncmp (argv[0], "d", 1) == 0)
  661. type = OSPF_DEBUG_DB_DESC;
  662. else if (strncmp (argv[0], "ls-r", 4) == 0)
  663. type = OSPF_DEBUG_LS_REQ;
  664. else if (strncmp (argv[0], "ls-u", 4) == 0)
  665. type = OSPF_DEBUG_LS_UPD;
  666. else if (strncmp (argv[0], "ls-a", 4) == 0)
  667. type = OSPF_DEBUG_LS_ACK;
  668. else if (strncmp (argv[0], "a", 1) == 0)
  669. type = OSPF_DEBUG_ALL;
  670. /* Default, both send and recv. */
  671. if (argc == 1)
  672. flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV;
  673. /* send or recv. */
  674. if (argc >= 2)
  675. {
  676. if (strncmp (argv[1], "s", 1) == 0)
  677. flag = OSPF_DEBUG_SEND;
  678. else if (strncmp (argv[1], "r", 1) == 0)
  679. flag = OSPF_DEBUG_RECV;
  680. else if (strncmp (argv[1], "d", 1) == 0)
  681. flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL;
  682. }
  683. /* detail. */
  684. if (argc == 3)
  685. if (strncmp (argv[2], "d", 1) == 0)
  686. flag |= OSPF_DEBUG_DETAIL;
  687. for (i = 0; i < 5; i++)
  688. if (type & (0x01 << i))
  689. {
  690. if (vty->node == CONFIG_NODE)
  691. DEBUG_PACKET_ON (i, flag);
  692. else
  693. TERM_DEBUG_PACKET_ON (i, flag);
  694. }
  695. return CMD_SUCCESS;
  696. }
  697. ALIAS (debug_ospf_packet,
  698. debug_ospf_packet_send_recv_cmd,
  699. "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)",
  700. "Debugging functions\n"
  701. "OSPF information\n"
  702. "OSPF packets\n"
  703. "OSPF Hello\n"
  704. "OSPF Database Description\n"
  705. "OSPF Link State Request\n"
  706. "OSPF Link State Update\n"
  707. "OSPF Link State Acknowledgment\n"
  708. "OSPF all packets\n"
  709. "Packet sent\n"
  710. "Packet received\n"
  711. "Detail information\n")
  712. ALIAS (debug_ospf_packet,
  713. debug_ospf_packet_send_recv_detail_cmd,
  714. "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|)",
  715. "Debugging functions\n"
  716. "OSPF information\n"
  717. "OSPF packets\n"
  718. "OSPF Hello\n"
  719. "OSPF Database Description\n"
  720. "OSPF Link State Request\n"
  721. "OSPF Link State Update\n"
  722. "OSPF Link State Acknowledgment\n"
  723. "OSPF all packets\n"
  724. "Packet sent\n"
  725. "Packet received\n"
  726. "Detail Information\n")
  727. DEFUN (no_debug_ospf_packet,
  728. no_debug_ospf_packet_all_cmd,
  729. "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)",
  730. NO_STR
  731. DEBUG_STR
  732. OSPF_STR
  733. "OSPF packets\n"
  734. "OSPF Hello\n"
  735. "OSPF Database Description\n"
  736. "OSPF Link State Request\n"
  737. "OSPF Link State Update\n"
  738. "OSPF Link State Acknowledgment\n"
  739. "OSPF all packets\n")
  740. {
  741. int type = 0;
  742. int flag = 0;
  743. int i;
  744. assert (argc > 0);
  745. /* Check packet type. */
  746. if (strncmp (argv[0], "h", 1) == 0)
  747. type = OSPF_DEBUG_HELLO;
  748. else if (strncmp (argv[0], "d", 1) == 0)
  749. type = OSPF_DEBUG_DB_DESC;
  750. else if (strncmp (argv[0], "ls-r", 4) == 0)
  751. type = OSPF_DEBUG_LS_REQ;
  752. else if (strncmp (argv[0], "ls-u", 4) == 0)
  753. type = OSPF_DEBUG_LS_UPD;
  754. else if (strncmp (argv[0], "ls-a", 4) == 0)
  755. type = OSPF_DEBUG_LS_ACK;
  756. else if (strncmp (argv[0], "a", 1) == 0)
  757. type = OSPF_DEBUG_ALL;
  758. /* Default, both send and recv. */
  759. if (argc == 1)
  760. flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL ;
  761. /* send or recv. */
  762. if (argc == 2)
  763. {
  764. if (strncmp (argv[1], "s", 1) == 0)
  765. flag = OSPF_DEBUG_SEND | OSPF_DEBUG_DETAIL;
  766. else if (strncmp (argv[1], "r", 1) == 0)
  767. flag = OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL;
  768. else if (strncmp (argv[1], "d", 1) == 0)
  769. flag = OSPF_DEBUG_DETAIL;
  770. }
  771. /* detail. */
  772. if (argc == 3)
  773. if (strncmp (argv[2], "d", 1) == 0)
  774. flag = OSPF_DEBUG_DETAIL;
  775. for (i = 0; i < 5; i++)
  776. if (type & (0x01 << i))
  777. {
  778. if (vty->node == CONFIG_NODE)
  779. DEBUG_PACKET_OFF (i, flag);
  780. else
  781. TERM_DEBUG_PACKET_OFF (i, flag);
  782. }
  783. #ifdef DEBUG
  784. /*
  785. for (i = 0; i < 5; i++)
  786. zlog_debug ("flag[%d] = %d", i, ospf_debug_packet[i]);
  787. */
  788. #endif /* DEBUG */
  789. return CMD_SUCCESS;
  790. }
  791. ALIAS (no_debug_ospf_packet,
  792. no_debug_ospf_packet_send_recv_cmd,
  793. "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)",
  794. NO_STR
  795. "Debugging functions\n"
  796. "OSPF information\n"
  797. "OSPF packets\n"
  798. "OSPF Hello\n"
  799. "OSPF Database Description\n"
  800. "OSPF Link State Request\n"
  801. "OSPF Link State Update\n"
  802. "OSPF Link State Acknowledgment\n"
  803. "OSPF all packets\n"
  804. "Packet sent\n"
  805. "Packet received\n"
  806. "Detail Information\n")
  807. ALIAS (no_debug_ospf_packet,
  808. no_debug_ospf_packet_send_recv_detail_cmd,
  809. "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|)",
  810. NO_STR
  811. "Debugging functions\n"
  812. "OSPF information\n"
  813. "OSPF packets\n"
  814. "OSPF Hello\n"
  815. "OSPF Database Description\n"
  816. "OSPF Link State Request\n"
  817. "OSPF Link State Update\n"
  818. "OSPF Link State Acknowledgment\n"
  819. "OSPF all packets\n"
  820. "Packet sent\n"
  821. "Packet received\n"
  822. "Detail Information\n")
  823. DEFUN (debug_ospf_ism,
  824. debug_ospf_ism_cmd,
  825. "debug ospf ism",
  826. DEBUG_STR
  827. OSPF_STR
  828. "OSPF Interface State Machine\n")
  829. {
  830. if (vty->node == CONFIG_NODE)
  831. {
  832. if (argc == 0)
  833. DEBUG_ON (ism, ISM);
  834. else if (argc == 1)
  835. {
  836. if (strncmp (argv[0], "s", 1) == 0)
  837. DEBUG_ON (ism, ISM_STATUS);
  838. else if (strncmp (argv[0], "e", 1) == 0)
  839. DEBUG_ON (ism, ISM_EVENTS);
  840. else if (strncmp (argv[0], "t", 1) == 0)
  841. DEBUG_ON (ism, ISM_TIMERS);
  842. }
  843. return CMD_SUCCESS;
  844. }
  845. /* ENABLE_NODE. */
  846. if (argc == 0)
  847. TERM_DEBUG_ON (ism, ISM);
  848. else if (argc == 1)
  849. {
  850. if (strncmp (argv[0], "s", 1) == 0)
  851. TERM_DEBUG_ON (ism, ISM_STATUS);
  852. else if (strncmp (argv[0], "e", 1) == 0)
  853. TERM_DEBUG_ON (ism, ISM_EVENTS);
  854. else if (strncmp (argv[0], "t", 1) == 0)
  855. TERM_DEBUG_ON (ism, ISM_TIMERS);
  856. }
  857. return CMD_SUCCESS;
  858. }
  859. ALIAS (debug_ospf_ism,
  860. debug_ospf_ism_sub_cmd,
  861. "debug ospf ism (status|events|timers)",
  862. DEBUG_STR
  863. OSPF_STR
  864. "OSPF Interface State Machine\n"
  865. "ISM Status Information\n"
  866. "ISM Event Information\n"
  867. "ISM TImer Information\n")
  868. DEFUN (no_debug_ospf_ism,
  869. no_debug_ospf_ism_cmd,
  870. "no debug ospf ism",
  871. NO_STR
  872. DEBUG_STR
  873. OSPF_STR
  874. "OSPF Interface State Machine")
  875. {
  876. if (vty->node == CONFIG_NODE)
  877. {
  878. if (argc == 0)
  879. DEBUG_OFF (ism, ISM);
  880. else if (argc == 1)
  881. {
  882. if (strncmp (argv[0], "s", 1) == 0)
  883. DEBUG_OFF (ism, ISM_STATUS);
  884. else if (strncmp (argv[0], "e", 1) == 0)
  885. DEBUG_OFF (ism, ISM_EVENTS);
  886. else if (strncmp (argv[0], "t", 1) == 0)
  887. DEBUG_OFF (ism, ISM_TIMERS);
  888. }
  889. return CMD_SUCCESS;
  890. }
  891. /* ENABLE_NODE. */
  892. if (argc == 0)
  893. TERM_DEBUG_OFF (ism, ISM);
  894. else if (argc == 1)
  895. {
  896. if (strncmp (argv[0], "s", 1) == 0)
  897. TERM_DEBUG_OFF (ism, ISM_STATUS);
  898. else if (strncmp (argv[0], "e", 1) == 0)
  899. TERM_DEBUG_OFF (ism, ISM_EVENTS);
  900. else if (strncmp (argv[0], "t", 1) == 0)
  901. TERM_DEBUG_OFF (ism, ISM_TIMERS);
  902. }
  903. return CMD_SUCCESS;
  904. }
  905. ALIAS (no_debug_ospf_ism,
  906. no_debug_ospf_ism_sub_cmd,
  907. "no debug ospf ism (status|events|timers)",
  908. NO_STR
  909. "Debugging functions\n"
  910. "OSPF information\n"
  911. "OSPF Interface State Machine\n"
  912. "ISM Status Information\n"
  913. "ISM Event Information\n"
  914. "ISM Timer Information\n")
  915. DEFUN (debug_ospf_nsm,
  916. debug_ospf_nsm_cmd,
  917. "debug ospf nsm",
  918. DEBUG_STR
  919. OSPF_STR
  920. "OSPF Neighbor State Machine\n")
  921. {
  922. if (vty->node == CONFIG_NODE)
  923. {
  924. if (argc == 0)
  925. DEBUG_ON (nsm, NSM);
  926. else if (argc == 1)
  927. {
  928. if (strncmp (argv[0], "s", 1) == 0)
  929. DEBUG_ON (nsm, NSM_STATUS);
  930. else if (strncmp (argv[0], "e", 1) == 0)
  931. DEBUG_ON (nsm, NSM_EVENTS);
  932. else if (strncmp (argv[0], "t", 1) == 0)
  933. DEBUG_ON (nsm, NSM_TIMERS);
  934. }
  935. return CMD_SUCCESS;
  936. }
  937. /* ENABLE_NODE. */
  938. if (argc == 0)
  939. TERM_DEBUG_ON (nsm, NSM);
  940. else if (argc == 1)
  941. {
  942. if (strncmp (argv[0], "s", 1) == 0)
  943. TERM_DEBUG_ON (nsm, NSM_STATUS);
  944. else if (strncmp (argv[0], "e", 1) == 0)
  945. TERM_DEBUG_ON (nsm, NSM_EVENTS);
  946. else if (strncmp (argv[0], "t", 1) == 0)
  947. TERM_DEBUG_ON (nsm, NSM_TIMERS);
  948. }
  949. return CMD_SUCCESS;
  950. }
  951. ALIAS (debug_ospf_nsm,
  952. debug_ospf_nsm_sub_cmd,
  953. "debug ospf nsm (status|events|timers)",
  954. DEBUG_STR
  955. OSPF_STR
  956. "OSPF Neighbor State Machine\n"
  957. "NSM Status Information\n"
  958. "NSM Event Information\n"
  959. "NSM Timer Information\n")
  960. DEFUN (no_debug_ospf_nsm,
  961. no_debug_ospf_nsm_cmd,
  962. "no debug ospf nsm",
  963. NO_STR
  964. DEBUG_STR
  965. OSPF_STR
  966. "OSPF Neighbor State Machine")
  967. {
  968. if (vty->node == CONFIG_NODE)
  969. {
  970. if (argc == 0)
  971. DEBUG_OFF (nsm, NSM);
  972. else if (argc == 1)
  973. {
  974. if (strncmp (argv[0], "s", 1) == 0)
  975. DEBUG_OFF (nsm, NSM_STATUS);
  976. else if (strncmp (argv[0], "e", 1) == 0)
  977. DEBUG_OFF (nsm, NSM_EVENTS);
  978. else if (strncmp (argv[0], "t", 1) == 0)
  979. DEBUG_OFF (nsm, NSM_TIMERS);
  980. }
  981. return CMD_SUCCESS;
  982. }
  983. /* ENABLE_NODE. */
  984. if (argc == 0)
  985. TERM_DEBUG_OFF (nsm, NSM);
  986. else if (argc == 1)
  987. {
  988. if (strncmp (argv[0], "s", 1) == 0)
  989. TERM_DEBUG_OFF (nsm, NSM_STATUS);
  990. else if (strncmp (argv[0], "e", 1) == 0)
  991. TERM_DEBUG_OFF (nsm, NSM_EVENTS);
  992. else if (strncmp (argv[0], "t", 1) == 0)
  993. TERM_DEBUG_OFF (nsm, NSM_TIMERS);
  994. }
  995. return CMD_SUCCESS;
  996. }
  997. ALIAS (no_debug_ospf_nsm,
  998. no_debug_ospf_nsm_sub_cmd,
  999. "no debug ospf nsm (status|events|timers)",
  1000. NO_STR
  1001. "Debugging functions\n"
  1002. "OSPF information\n"
  1003. "OSPF Interface State Machine\n"
  1004. "NSM Status Information\n"
  1005. "NSM Event Information\n"
  1006. "NSM Timer Information\n")
  1007. DEFUN (debug_ospf_lsa,
  1008. debug_ospf_lsa_cmd,
  1009. "debug ospf lsa",
  1010. DEBUG_STR
  1011. OSPF_STR
  1012. "OSPF Link State Advertisement\n")
  1013. {
  1014. if (vty->node == CONFIG_NODE)
  1015. {
  1016. if (argc == 0)
  1017. DEBUG_ON (lsa, LSA);
  1018. else if (argc == 1)
  1019. {
  1020. if (strncmp (argv[0], "g", 1) == 0)
  1021. DEBUG_ON (lsa, LSA_GENERATE);
  1022. else if (strncmp (argv[0], "f", 1) == 0)
  1023. DEBUG_ON (lsa, LSA_FLOODING);
  1024. else if (strncmp (argv[0], "i", 1) == 0)
  1025. DEBUG_ON (lsa, LSA_INSTALL);
  1026. else if (strncmp (argv[0], "r", 1) == 0)
  1027. DEBUG_ON (lsa, LSA_REFRESH);
  1028. }
  1029. return CMD_SUCCESS;
  1030. }
  1031. /* ENABLE_NODE. */
  1032. if (argc == 0)
  1033. TERM_DEBUG_ON (lsa, LSA);
  1034. else if (argc == 1)
  1035. {
  1036. if (strncmp (argv[0], "g", 1) == 0)
  1037. TERM_DEBUG_ON (lsa, LSA_GENERATE);
  1038. else if (strncmp (argv[0], "f", 1) == 0)
  1039. TERM_DEBUG_ON (lsa, LSA_FLOODING);
  1040. else if (strncmp (argv[0], "i", 1) == 0)
  1041. TERM_DEBUG_ON (lsa, LSA_INSTALL);
  1042. else if (strncmp (argv[0], "r", 1) == 0)
  1043. TERM_DEBUG_ON (lsa, LSA_REFRESH);
  1044. }
  1045. return CMD_SUCCESS;
  1046. }
  1047. ALIAS (debug_ospf_lsa,
  1048. debug_ospf_lsa_sub_cmd,
  1049. "debug ospf lsa (generate|flooding|install|refresh)",
  1050. DEBUG_STR
  1051. OSPF_STR
  1052. "OSPF Link State Advertisement\n"
  1053. "LSA Generation\n"
  1054. "LSA Flooding\n"
  1055. "LSA Install/Delete\n"
  1056. "LSA Refresh\n")
  1057. DEFUN (no_debug_ospf_lsa,
  1058. no_debug_ospf_lsa_cmd,
  1059. "no debug ospf lsa",
  1060. NO_STR
  1061. DEBUG_STR
  1062. OSPF_STR
  1063. "OSPF Link State Advertisement\n")
  1064. {
  1065. if (vty->node == CONFIG_NODE)
  1066. {
  1067. if (argc == 0)
  1068. DEBUG_OFF (lsa, LSA);
  1069. else if (argc == 1)
  1070. {
  1071. if (strncmp (argv[0], "g", 1) == 0)
  1072. DEBUG_OFF (lsa, LSA_GENERATE);
  1073. else if (strncmp (argv[0], "f", 1) == 0)
  1074. DEBUG_OFF (lsa, LSA_FLOODING);
  1075. else if (strncmp (argv[0], "i", 1) == 0)
  1076. DEBUG_OFF (lsa, LSA_INSTALL);
  1077. else if (strncmp (argv[0], "r", 1) == 0)
  1078. DEBUG_OFF (lsa, LSA_REFRESH);
  1079. }
  1080. return CMD_SUCCESS;
  1081. }
  1082. /* ENABLE_NODE. */
  1083. if (argc == 0)
  1084. TERM_DEBUG_OFF (lsa, LSA);
  1085. else if (argc == 1)
  1086. {
  1087. if (strncmp (argv[0], "g", 1) == 0)
  1088. TERM_DEBUG_OFF (lsa, LSA_GENERATE);
  1089. else if (strncmp (argv[0], "f", 1) == 0)
  1090. TERM_DEBUG_OFF (lsa, LSA_FLOODING);
  1091. else if (strncmp (argv[0], "i", 1) == 0)
  1092. TERM_DEBUG_OFF (lsa, LSA_INSTALL);
  1093. else if (strncmp (argv[0], "r", 1) == 0)
  1094. TERM_DEBUG_OFF (lsa, LSA_REFRESH);
  1095. }
  1096. return CMD_SUCCESS;
  1097. }
  1098. ALIAS (no_debug_ospf_lsa,
  1099. no_debug_ospf_lsa_sub_cmd,
  1100. "no debug ospf lsa (generate|flooding|install|refresh)",
  1101. NO_STR
  1102. DEBUG_STR
  1103. OSPF_STR
  1104. "OSPF Link State Advertisement\n"
  1105. "LSA Generation\n"
  1106. "LSA Flooding\n"
  1107. "LSA Install/Delete\n"
  1108. "LSA Refres\n")
  1109. DEFUN (debug_ospf_zebra,
  1110. debug_ospf_zebra_cmd,
  1111. "debug ospf zebra",
  1112. DEBUG_STR
  1113. OSPF_STR
  1114. "OSPF Zebra information\n")
  1115. {
  1116. if (vty->node == CONFIG_NODE)
  1117. {
  1118. if (argc == 0)
  1119. DEBUG_ON (zebra, ZEBRA);
  1120. else if (argc == 1)
  1121. {
  1122. if (strncmp (argv[0], "i", 1) == 0)
  1123. DEBUG_ON (zebra, ZEBRA_INTERFACE);
  1124. else if (strncmp (argv[0], "r", 1) == 0)
  1125. DEBUG_ON (zebra, ZEBRA_REDISTRIBUTE);
  1126. }
  1127. return CMD_SUCCESS;
  1128. }
  1129. /* ENABLE_NODE. */
  1130. if (argc == 0)
  1131. TERM_DEBUG_ON (zebra, ZEBRA);
  1132. else if (argc == 1)
  1133. {
  1134. if (strncmp (argv[0], "i", 1) == 0)
  1135. TERM_DEBUG_ON (zebra, ZEBRA_INTERFACE);
  1136. else if (strncmp (argv[0], "r", 1) == 0)
  1137. TERM_DEBUG_ON (zebra, ZEBRA_REDISTRIBUTE);
  1138. }
  1139. return CMD_SUCCESS;
  1140. }
  1141. ALIAS (debug_ospf_zebra,
  1142. debug_ospf_zebra_sub_cmd,
  1143. "debug ospf zebra (interface|redistribute)",
  1144. DEBUG_STR
  1145. OSPF_STR
  1146. "OSPF Zebra information\n"
  1147. "Zebra interface\n"
  1148. "Zebra redistribute\n")
  1149. DEFUN (no_debug_ospf_zebra,
  1150. no_debug_ospf_zebra_cmd,
  1151. "no debug ospf zebra",
  1152. NO_STR
  1153. DEBUG_STR
  1154. OSPF_STR
  1155. "OSPF Zebra information\n")
  1156. {
  1157. if (vty->node == CONFIG_NODE)
  1158. {
  1159. if (argc == 0)
  1160. DEBUG_OFF (zebra, ZEBRA);
  1161. else if (argc == 1)
  1162. {
  1163. if (strncmp (argv[0], "i", 1) == 0)
  1164. DEBUG_OFF (zebra, ZEBRA_INTERFACE);
  1165. else if (strncmp (argv[0], "r", 1) == 0)
  1166. DEBUG_OFF (zebra, ZEBRA_REDISTRIBUTE);
  1167. }
  1168. return CMD_SUCCESS;
  1169. }
  1170. /* ENABLE_NODE. */
  1171. if (argc == 0)
  1172. TERM_DEBUG_OFF (zebra, ZEBRA);
  1173. else if (argc == 1)
  1174. {
  1175. if (strncmp (argv[0], "i", 1) == 0)
  1176. TERM_DEBUG_OFF (zebra, ZEBRA_INTERFACE);
  1177. else if (strncmp (argv[0], "r", 1) == 0)
  1178. TERM_DEBUG_OFF (zebra, ZEBRA_REDISTRIBUTE);
  1179. }
  1180. return CMD_SUCCESS;
  1181. }
  1182. ALIAS (no_debug_ospf_zebra,
  1183. no_debug_ospf_zebra_sub_cmd,
  1184. "no debug ospf zebra (interface|redistribute)",
  1185. NO_STR
  1186. DEBUG_STR
  1187. OSPF_STR
  1188. "OSPF Zebra information\n"
  1189. "Zebra interface\n"
  1190. "Zebra redistribute\n")
  1191. DEFUN (debug_ospf_event,
  1192. debug_ospf_event_cmd,
  1193. "debug ospf event",
  1194. DEBUG_STR
  1195. OSPF_STR
  1196. "OSPF event information\n")
  1197. {
  1198. if (vty->node == CONFIG_NODE)
  1199. CONF_DEBUG_ON (event, EVENT);
  1200. TERM_DEBUG_ON (event, EVENT);
  1201. return CMD_SUCCESS;
  1202. }
  1203. DEFUN (no_debug_ospf_event,
  1204. no_debug_ospf_event_cmd,
  1205. "no debug ospf event",
  1206. NO_STR
  1207. DEBUG_STR
  1208. OSPF_STR
  1209. "OSPF event information\n")
  1210. {
  1211. if (vty->node == CONFIG_NODE)
  1212. CONF_DEBUG_OFF (event, EVENT);
  1213. TERM_DEBUG_OFF (event, EVENT);
  1214. return CMD_SUCCESS;
  1215. }
  1216. DEFUN (debug_ospf_nssa,
  1217. debug_ospf_nssa_cmd,
  1218. "debug ospf nssa",
  1219. DEBUG_STR
  1220. OSPF_STR
  1221. "OSPF nssa information\n")
  1222. {
  1223. if (vty->node == CONFIG_NODE)
  1224. CONF_DEBUG_ON (nssa, NSSA);
  1225. TERM_DEBUG_ON (nssa, NSSA);
  1226. return CMD_SUCCESS;
  1227. }
  1228. DEFUN (no_debug_ospf_nssa,
  1229. no_debug_ospf_nssa_cmd,
  1230. "no debug ospf nssa",
  1231. NO_STR
  1232. DEBUG_STR
  1233. OSPF_STR
  1234. "OSPF nssa information\n")
  1235. {
  1236. if (vty->node == CONFIG_NODE)
  1237. CONF_DEBUG_OFF (nssa, NSSA);
  1238. TERM_DEBUG_OFF (nssa, NSSA);
  1239. return CMD_SUCCESS;
  1240. }
  1241. DEFUN (show_debugging_ospf,
  1242. show_debugging_ospf_cmd,
  1243. "show debugging ospf",
  1244. SHOW_STR
  1245. DEBUG_STR
  1246. OSPF_STR)
  1247. {
  1248. int i;
  1249. vty_out (vty, "OSPF debugging status:%s", VTY_NEWLINE);
  1250. /* Show debug status for events. */
  1251. if (IS_DEBUG_OSPF(event,EVENT))
  1252. vty_out (vty, " OSPF event debugging is on%s", VTY_NEWLINE);
  1253. /* Show debug status for ISM. */
  1254. if (IS_DEBUG_OSPF (ism, ISM) == OSPF_DEBUG_ISM)
  1255. vty_out (vty, " OSPF ISM debugging is on%s", VTY_NEWLINE);
  1256. else
  1257. {
  1258. if (IS_DEBUG_OSPF (ism, ISM_STATUS))
  1259. vty_out (vty, " OSPF ISM status debugging is on%s", VTY_NEWLINE);
  1260. if (IS_DEBUG_OSPF (ism, ISM_EVENTS))
  1261. vty_out (vty, " OSPF ISM event debugging is on%s", VTY_NEWLINE);
  1262. if (IS_DEBUG_OSPF (ism, ISM_TIMERS))
  1263. vty_out (vty, " OSPF ISM timer debugging is on%s", VTY_NEWLINE);
  1264. }
  1265. /* Show debug status for NSM. */
  1266. if (IS_DEBUG_OSPF (nsm, NSM) == OSPF_DEBUG_NSM)
  1267. vty_out (vty, " OSPF NSM debugging is on%s", VTY_NEWLINE);
  1268. else
  1269. {
  1270. if (IS_DEBUG_OSPF (nsm, NSM_STATUS))
  1271. vty_out (vty, " OSPF NSM status debugging is on%s", VTY_NEWLINE);
  1272. if (IS_DEBUG_OSPF (nsm, NSM_EVENTS))
  1273. vty_out (vty, " OSPF NSM event debugging is on%s", VTY_NEWLINE);
  1274. if (IS_DEBUG_OSPF (nsm, NSM_TIMERS))
  1275. vty_out (vty, " OSPF NSM timer debugging is on%s", VTY_NEWLINE);
  1276. }
  1277. /* Show debug status for OSPF Packets. */
  1278. for (i = 0; i < 5; i++)
  1279. if (IS_DEBUG_OSPF_PACKET (i, SEND) && IS_DEBUG_OSPF_PACKET (i, RECV))
  1280. {
  1281. vty_out (vty, " OSPF packet %s%s debugging is on%s",
  1282. LOOKUP (ospf_packet_type_str, i + 1),
  1283. IS_DEBUG_OSPF_PACKET (i, DETAIL) ? " detail" : "",
  1284. VTY_NEWLINE);
  1285. }
  1286. else
  1287. {
  1288. if (IS_DEBUG_OSPF_PACKET (i, SEND))
  1289. vty_out (vty, " OSPF packet %s send%s debugging is on%s",
  1290. LOOKUP (ospf_packet_type_str, i + 1),
  1291. IS_DEBUG_OSPF_PACKET (i, DETAIL) ? " detail" : "",
  1292. VTY_NEWLINE);
  1293. if (IS_DEBUG_OSPF_PACKET (i, RECV))
  1294. vty_out (vty, " OSPF packet %s receive%s debugging is on%s",
  1295. LOOKUP (ospf_packet_type_str, i + 1),
  1296. IS_DEBUG_OSPF_PACKET (i, DETAIL) ? " detail" : "",
  1297. VTY_NEWLINE);
  1298. }
  1299. /* Show debug status for OSPF LSAs. */
  1300. if (IS_DEBUG_OSPF (lsa, LSA) == OSPF_DEBUG_LSA)
  1301. vty_out (vty, " OSPF LSA debugging is on%s", VTY_NEWLINE);
  1302. else
  1303. {
  1304. if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
  1305. vty_out (vty, " OSPF LSA generation debugging is on%s", VTY_NEWLINE);
  1306. if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
  1307. vty_out (vty, " OSPF LSA flooding debugging is on%s", VTY_NEWLINE);
  1308. if (IS_DEBUG_OSPF (lsa, LSA_INSTALL))
  1309. vty_out (vty, " OSPF LSA install debugging is on%s", VTY_NEWLINE);
  1310. if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
  1311. vty_out (vty, " OSPF LSA refresh debugging is on%s", VTY_NEWLINE);
  1312. }
  1313. /* Show debug status for Zebra. */
  1314. if (IS_DEBUG_OSPF (zebra, ZEBRA) == OSPF_DEBUG_ZEBRA)
  1315. vty_out (vty, " OSPF Zebra debugging is on%s", VTY_NEWLINE);
  1316. else
  1317. {
  1318. if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
  1319. vty_out (vty, " OSPF Zebra interface debugging is on%s", VTY_NEWLINE);
  1320. if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
  1321. vty_out (vty, " OSPF Zebra redistribute debugging is on%s", VTY_NEWLINE);
  1322. }
  1323. /* Show debug status for NSSA. */
  1324. if (IS_DEBUG_OSPF (nssa, NSSA) == OSPF_DEBUG_NSSA)
  1325. vty_out (vty, " OSPF NSSA debugging is on%s", VTY_NEWLINE);
  1326. return CMD_SUCCESS;
  1327. }
  1328. /* Debug node. */
  1329. static struct cmd_node debug_node =
  1330. {
  1331. DEBUG_NODE,
  1332. "",
  1333. 1 /* VTYSH */
  1334. };
  1335. static int
  1336. config_write_debug (struct vty *vty)
  1337. {
  1338. int write = 0;
  1339. int i, r;
  1340. const char *type_str[] = {"hello", "dd", "ls-request", "ls-update", "ls-ack"};
  1341. const char *detail_str[] = {"", " send", " recv", "", " detail",
  1342. " send detail", " recv detail", " detail"};
  1343. /* debug ospf ism (status|events|timers). */
  1344. if (IS_CONF_DEBUG_OSPF (ism, ISM) == OSPF_DEBUG_ISM)
  1345. vty_out (vty, "debug ospf ism%s", VTY_NEWLINE);
  1346. else
  1347. {
  1348. if (IS_CONF_DEBUG_OSPF (ism, ISM_STATUS))
  1349. vty_out (vty, "debug ospf ism status%s", VTY_NEWLINE);
  1350. if (IS_CONF_DEBUG_OSPF (ism, ISM_EVENTS))
  1351. vty_out (vty, "debug ospf ism event%s", VTY_NEWLINE);
  1352. if (IS_CONF_DEBUG_OSPF (ism, ISM_TIMERS))
  1353. vty_out (vty, "debug ospf ism timer%s", VTY_NEWLINE);
  1354. }
  1355. /* debug ospf nsm (status|events|timers). */
  1356. if (IS_CONF_DEBUG_OSPF (nsm, NSM) == OSPF_DEBUG_NSM)
  1357. vty_out (vty, "debug ospf nsm%s", VTY_NEWLINE);
  1358. else
  1359. {
  1360. if (IS_CONF_DEBUG_OSPF (nsm, NSM_STATUS))
  1361. vty_out (vty, "debug ospf nsm status%s", VTY_NEWLINE);
  1362. if (IS_CONF_DEBUG_OSPF (nsm, NSM_EVENTS))
  1363. vty_out (vty, "debug ospf nsm event%s", VTY_NEWLINE);
  1364. if (IS_CONF_DEBUG_OSPF (nsm, NSM_TIMERS))
  1365. vty_out (vty, "debug ospf nsm timer%s", VTY_NEWLINE);
  1366. }
  1367. /* debug ospf lsa (generate|flooding|install|refresh). */
  1368. if (IS_CONF_DEBUG_OSPF (lsa, LSA) == OSPF_DEBUG_LSA)
  1369. vty_out (vty, "debug ospf lsa%s", VTY_NEWLINE);
  1370. else
  1371. {
  1372. if (IS_CONF_DEBUG_OSPF (lsa, LSA_GENERATE))
  1373. vty_out (vty, "debug ospf lsa generate%s", VTY_NEWLINE);
  1374. if (IS_CONF_DEBUG_OSPF (lsa, LSA_FLOODING))
  1375. vty_out (vty, "debug ospf lsa flooding%s", VTY_NEWLINE);
  1376. if (IS_CONF_DEBUG_OSPF (lsa, LSA_INSTALL))
  1377. vty_out (vty, "debug ospf lsa install%s", VTY_NEWLINE);
  1378. if (IS_CONF_DEBUG_OSPF (lsa, LSA_REFRESH))
  1379. vty_out (vty, "debug ospf lsa refresh%s", VTY_NEWLINE);
  1380. write = 1;
  1381. }
  1382. /* debug ospf zebra (interface|redistribute). */
  1383. if (IS_CONF_DEBUG_OSPF (zebra, ZEBRA) == OSPF_DEBUG_ZEBRA)
  1384. vty_out (vty, "debug ospf zebra%s", VTY_NEWLINE);
  1385. else
  1386. {
  1387. if (IS_CONF_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
  1388. vty_out (vty, "debug ospf zebra interface%s", VTY_NEWLINE);
  1389. if (IS_CONF_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
  1390. vty_out (vty, "debug ospf zebra redistribute%s", VTY_NEWLINE);
  1391. write = 1;
  1392. }
  1393. /* debug ospf event. */
  1394. if (IS_CONF_DEBUG_OSPF (event, EVENT) == OSPF_DEBUG_EVENT)
  1395. {
  1396. vty_out (vty, "debug ospf event%s", VTY_NEWLINE);
  1397. write = 1;
  1398. }
  1399. /* debug ospf nssa. */
  1400. if (IS_CONF_DEBUG_OSPF (nssa, NSSA) == OSPF_DEBUG_NSSA)
  1401. {
  1402. vty_out (vty, "debug ospf nssa%s", VTY_NEWLINE);
  1403. write = 1;
  1404. }
  1405. /* debug ospf packet all detail. */
  1406. r = OSPF_DEBUG_SEND_RECV|OSPF_DEBUG_DETAIL;
  1407. for (i = 0; i < 5; i++)
  1408. r &= conf_debug_ospf_packet[i] & (OSPF_DEBUG_SEND_RECV|OSPF_DEBUG_DETAIL);
  1409. if (r == (OSPF_DEBUG_SEND_RECV|OSPF_DEBUG_DETAIL))
  1410. {
  1411. vty_out (vty, "debug ospf packet all detail%s", VTY_NEWLINE);
  1412. return 1;
  1413. }
  1414. /* debug ospf packet all. */
  1415. r = OSPF_DEBUG_SEND_RECV;
  1416. for (i = 0; i < 5; i++)
  1417. r &= conf_debug_ospf_packet[i] & OSPF_DEBUG_SEND_RECV;
  1418. if (r == OSPF_DEBUG_SEND_RECV)
  1419. {
  1420. vty_out (vty, "debug ospf packet all%s", VTY_NEWLINE);
  1421. for (i = 0; i < 5; i++)
  1422. if (conf_debug_ospf_packet[i] & OSPF_DEBUG_DETAIL)
  1423. vty_out (vty, "debug ospf packet %s detail%s",
  1424. type_str[i],
  1425. VTY_NEWLINE);
  1426. return 1;
  1427. }
  1428. /* debug ospf packet (hello|dd|ls-request|ls-update|ls-ack)
  1429. (send|recv) (detail). */
  1430. for (i = 0; i < 5; i++)
  1431. {
  1432. if (conf_debug_ospf_packet[i] == 0)
  1433. continue;
  1434. vty_out (vty, "debug ospf packet %s%s%s",
  1435. type_str[i], detail_str[conf_debug_ospf_packet[i]],
  1436. VTY_NEWLINE);
  1437. write = 1;
  1438. }
  1439. return write;
  1440. }
  1441. /* Initialize debug commands. */
  1442. void
  1443. debug_init ()
  1444. {
  1445. install_node (&debug_node, config_write_debug);
  1446. install_element (ENABLE_NODE, &show_debugging_ospf_cmd);
  1447. install_element (ENABLE_NODE, &debug_ospf_packet_send_recv_detail_cmd);
  1448. install_element (ENABLE_NODE, &debug_ospf_packet_send_recv_cmd);
  1449. install_element (ENABLE_NODE, &debug_ospf_packet_all_cmd);
  1450. install_element (ENABLE_NODE, &debug_ospf_ism_sub_cmd);
  1451. install_element (ENABLE_NODE, &debug_ospf_ism_cmd);
  1452. install_element (ENABLE_NODE, &debug_ospf_nsm_sub_cmd);
  1453. install_element (ENABLE_NODE, &debug_ospf_nsm_cmd);
  1454. install_element (ENABLE_NODE, &debug_ospf_lsa_sub_cmd);
  1455. install_element (ENABLE_NODE, &debug_ospf_lsa_cmd);
  1456. install_element (ENABLE_NODE, &debug_ospf_zebra_sub_cmd);
  1457. install_element (ENABLE_NODE, &debug_ospf_zebra_cmd);
  1458. install_element (ENABLE_NODE, &debug_ospf_event_cmd);
  1459. install_element (ENABLE_NODE, &debug_ospf_nssa_cmd);
  1460. install_element (ENABLE_NODE, &no_debug_ospf_packet_send_recv_detail_cmd);
  1461. install_element (ENABLE_NODE, &no_debug_ospf_packet_send_recv_cmd);
  1462. install_element (ENABLE_NODE, &no_debug_ospf_packet_all_cmd);
  1463. install_element (ENABLE_NODE, &no_debug_ospf_ism_sub_cmd);
  1464. install_element (ENABLE_NODE, &no_debug_ospf_ism_cmd);
  1465. install_element (ENABLE_NODE, &no_debug_ospf_nsm_sub_cmd);
  1466. install_element (ENABLE_NODE, &no_debug_ospf_nsm_cmd);
  1467. install_element (ENABLE_NODE, &no_debug_ospf_lsa_sub_cmd);
  1468. install_element (ENABLE_NODE, &no_debug_ospf_lsa_cmd);
  1469. install_element (ENABLE_NODE, &no_debug_ospf_zebra_sub_cmd);
  1470. install_element (ENABLE_NODE, &no_debug_ospf_zebra_cmd);
  1471. install_element (ENABLE_NODE, &no_debug_ospf_event_cmd);
  1472. install_element (ENABLE_NODE, &no_debug_ospf_nssa_cmd);
  1473. install_element (CONFIG_NODE, &debug_ospf_packet_send_recv_detail_cmd);
  1474. install_element (CONFIG_NODE, &debug_ospf_packet_send_recv_cmd);
  1475. install_element (CONFIG_NODE, &debug_ospf_packet_all_cmd);
  1476. install_element (CONFIG_NODE, &debug_ospf_ism_sub_cmd);
  1477. install_element (CONFIG_NODE, &debug_ospf_ism_cmd);
  1478. install_element (CONFIG_NODE, &debug_ospf_nsm_sub_cmd);
  1479. install_element (CONFIG_NODE, &debug_ospf_nsm_cmd);
  1480. install_element (CONFIG_NODE, &debug_ospf_lsa_sub_cmd);
  1481. install_element (CONFIG_NODE, &debug_ospf_lsa_cmd);
  1482. install_element (CONFIG_NODE, &debug_ospf_zebra_sub_cmd);
  1483. install_element (CONFIG_NODE, &debug_ospf_zebra_cmd);
  1484. install_element (CONFIG_NODE, &debug_ospf_event_cmd);
  1485. install_element (CONFIG_NODE, &debug_ospf_nssa_cmd);
  1486. install_element (CONFIG_NODE, &no_debug_ospf_packet_send_recv_detail_cmd);
  1487. install_element (CONFIG_NODE, &no_debug_ospf_packet_send_recv_cmd);
  1488. install_element (CONFIG_NODE, &no_debug_ospf_packet_all_cmd);
  1489. install_element (CONFIG_NODE, &no_debug_ospf_ism_sub_cmd);
  1490. install_element (CONFIG_NODE, &no_debug_ospf_ism_cmd);
  1491. install_element (CONFIG_NODE, &no_debug_ospf_nsm_sub_cmd);
  1492. install_element (CONFIG_NODE, &no_debug_ospf_nsm_cmd);
  1493. install_element (CONFIG_NODE, &no_debug_ospf_lsa_sub_cmd);
  1494. install_element (CONFIG_NODE, &no_debug_ospf_lsa_cmd);
  1495. install_element (CONFIG_NODE, &no_debug_ospf_zebra_sub_cmd);
  1496. install_element (CONFIG_NODE, &no_debug_ospf_zebra_cmd);
  1497. install_element (CONFIG_NODE, &no_debug_ospf_event_cmd);
  1498. install_element (CONFIG_NODE, &no_debug_ospf_nssa_cmd);
  1499. }