ospf6_asbr.c 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266
  1. /*
  2. * Copyright (C) 2003 Yasuhiro Ohara
  3. *
  4. * This file is part of GNU Zebra.
  5. *
  6. * GNU Zebra is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2, or (at your option) any
  9. * later version.
  10. *
  11. * GNU Zebra is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with GNU Zebra; see the file COPYING. If not, write to the
  18. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. * Boston, MA 02111-1307, USA.
  20. */
  21. #include <zebra.h>
  22. #include "log.h"
  23. #include "memory.h"
  24. #include "prefix.h"
  25. #include "command.h"
  26. #include "vty.h"
  27. #include "routemap.h"
  28. #include "table.h"
  29. #include "plist.h"
  30. #include "thread.h"
  31. #include "linklist.h"
  32. #include "ospf6_proto.h"
  33. #include "ospf6_lsa.h"
  34. #include "ospf6_lsdb.h"
  35. #include "ospf6_route.h"
  36. #include "ospf6_zebra.h"
  37. #include "ospf6_message.h"
  38. #include "ospf6_top.h"
  39. #include "ospf6_area.h"
  40. #include "ospf6_interface.h"
  41. #include "ospf6_neighbor.h"
  42. #include "ospf6_asbr.h"
  43. #include "ospf6_intra.h"
  44. #include "ospf6_flood.h"
  45. #include "ospf6d.h"
  46. unsigned char conf_debug_ospf6_asbr = 0;
  47. #define ZROUTE_NAME(x) zebra_route_string(x)
  48. /* AS External LSA origination */
  49. static void
  50. ospf6_as_external_lsa_originate (struct ospf6_route *route)
  51. {
  52. char buffer[OSPF6_MAX_LSASIZE];
  53. struct ospf6_lsa_header *lsa_header;
  54. struct ospf6_lsa *old, *lsa;
  55. struct ospf6_external_info *info = route->route_option;
  56. struct ospf6_as_external_lsa *as_external_lsa;
  57. char buf[64];
  58. caddr_t p;
  59. /* find previous LSA */
  60. old = ospf6_lsdb_lookup (htons (OSPF6_LSTYPE_AS_EXTERNAL),
  61. route->path.origin.id, ospf6->router_id,
  62. ospf6->lsdb);
  63. if (IS_OSPF6_DEBUG_ASBR || IS_OSPF6_DEBUG_ORIGINATE (AS_EXTERNAL))
  64. {
  65. prefix2str (&route->prefix, buf, sizeof (buf));
  66. zlog_debug ("Originate AS-External-LSA for %s", buf);
  67. }
  68. /* prepare buffer */
  69. memset (buffer, 0, sizeof (buffer));
  70. lsa_header = (struct ospf6_lsa_header *) buffer;
  71. as_external_lsa = (struct ospf6_as_external_lsa *)
  72. ((caddr_t) lsa_header + sizeof (struct ospf6_lsa_header));
  73. p = (caddr_t)
  74. ((caddr_t) as_external_lsa + sizeof (struct ospf6_as_external_lsa));
  75. /* Fill AS-External-LSA */
  76. /* Metric type */
  77. if (route->path.metric_type == 2)
  78. SET_FLAG (as_external_lsa->bits_metric, OSPF6_ASBR_BIT_E);
  79. else
  80. UNSET_FLAG (as_external_lsa->bits_metric, OSPF6_ASBR_BIT_E);
  81. /* forwarding address */
  82. if (! IN6_IS_ADDR_UNSPECIFIED (&info->forwarding))
  83. SET_FLAG (as_external_lsa->bits_metric, OSPF6_ASBR_BIT_F);
  84. else
  85. UNSET_FLAG (as_external_lsa->bits_metric, OSPF6_ASBR_BIT_F);
  86. /* external route tag */
  87. UNSET_FLAG (as_external_lsa->bits_metric, OSPF6_ASBR_BIT_T);
  88. /* Set metric */
  89. OSPF6_ASBR_METRIC_SET (as_external_lsa, route->path.cost);
  90. /* prefixlen */
  91. as_external_lsa->prefix.prefix_length = route->prefix.prefixlen;
  92. /* PrefixOptions */
  93. as_external_lsa->prefix.prefix_options = route->path.prefix_options;
  94. /* don't use refer LS-type */
  95. as_external_lsa->prefix.prefix_refer_lstype = htons (0);
  96. /* set Prefix */
  97. memcpy (p, &route->prefix.u.prefix6,
  98. OSPF6_PREFIX_SPACE (route->prefix.prefixlen));
  99. ospf6_prefix_apply_mask (&as_external_lsa->prefix);
  100. p += OSPF6_PREFIX_SPACE (route->prefix.prefixlen);
  101. /* Forwarding address */
  102. if (CHECK_FLAG (as_external_lsa->bits_metric, OSPF6_ASBR_BIT_F))
  103. {
  104. memcpy (p, &info->forwarding, sizeof (struct in6_addr));
  105. p += sizeof (struct in6_addr);
  106. }
  107. /* External Route Tag */
  108. if (CHECK_FLAG (as_external_lsa->bits_metric, OSPF6_ASBR_BIT_T))
  109. {
  110. /* xxx */
  111. }
  112. /* Fill LSA Header */
  113. lsa_header->age = 0;
  114. lsa_header->type = htons (OSPF6_LSTYPE_AS_EXTERNAL);
  115. lsa_header->id = route->path.origin.id;
  116. lsa_header->adv_router = ospf6->router_id;
  117. lsa_header->seqnum =
  118. ospf6_new_ls_seqnum (lsa_header->type, lsa_header->id,
  119. lsa_header->adv_router, ospf6->lsdb);
  120. lsa_header->length = htons ((caddr_t) p - (caddr_t) lsa_header);
  121. /* LSA checksum */
  122. ospf6_lsa_checksum (lsa_header);
  123. /* create LSA */
  124. lsa = ospf6_lsa_create (lsa_header);
  125. /* Originate */
  126. ospf6_lsa_originate_process (lsa, ospf6);
  127. }
  128. void
  129. ospf6_asbr_lsa_add (struct ospf6_lsa *lsa)
  130. {
  131. struct ospf6_as_external_lsa *external;
  132. struct prefix asbr_id;
  133. struct ospf6_route *asbr_entry, *route;
  134. char buf[64];
  135. int i;
  136. external = (struct ospf6_as_external_lsa *)
  137. OSPF6_LSA_HEADER_END (lsa->header);
  138. if (IS_OSPF6_DEBUG_EXAMIN (AS_EXTERNAL))
  139. zlog_debug ("Calculate AS-External route for %s", lsa->name);
  140. if (lsa->header->adv_router == ospf6->router_id)
  141. {
  142. if (IS_OSPF6_DEBUG_EXAMIN (AS_EXTERNAL))
  143. zlog_debug ("Ignore self-originated AS-External-LSA");
  144. return;
  145. }
  146. if (OSPF6_ASBR_METRIC (external) == LS_INFINITY)
  147. {
  148. if (IS_OSPF6_DEBUG_EXAMIN (AS_EXTERNAL))
  149. zlog_debug ("Ignore LSA with LSInfinity Metric");
  150. return;
  151. }
  152. ospf6_linkstate_prefix (lsa->header->adv_router, htonl (0), &asbr_id);
  153. asbr_entry = ospf6_route_lookup (&asbr_id, ospf6->brouter_table);
  154. if (asbr_entry == NULL ||
  155. ! CHECK_FLAG (asbr_entry->path.router_bits, OSPF6_ROUTER_BIT_E))
  156. {
  157. if (IS_OSPF6_DEBUG_EXAMIN (AS_EXTERNAL))
  158. {
  159. prefix2str (&asbr_id, buf, sizeof (buf));
  160. zlog_debug ("ASBR entry not found: %s", buf);
  161. }
  162. return;
  163. }
  164. route = ospf6_route_create ();
  165. route->type = OSPF6_DEST_TYPE_NETWORK;
  166. route->prefix.family = AF_INET6;
  167. route->prefix.prefixlen = external->prefix.prefix_length;
  168. ospf6_prefix_in6_addr (&route->prefix.u.prefix6, &external->prefix);
  169. route->path.area_id = asbr_entry->path.area_id;
  170. route->path.origin.type = lsa->header->type;
  171. route->path.origin.id = lsa->header->id;
  172. route->path.origin.adv_router = lsa->header->adv_router;
  173. route->path.prefix_options = external->prefix.prefix_options;
  174. if (CHECK_FLAG (external->bits_metric, OSPF6_ASBR_BIT_E))
  175. {
  176. route->path.type = OSPF6_PATH_TYPE_EXTERNAL2;
  177. route->path.metric_type = 2;
  178. route->path.cost = asbr_entry->path.cost;
  179. route->path.cost_e2 = OSPF6_ASBR_METRIC (external);
  180. }
  181. else
  182. {
  183. route->path.type = OSPF6_PATH_TYPE_EXTERNAL1;
  184. route->path.metric_type = 1;
  185. route->path.cost = asbr_entry->path.cost + OSPF6_ASBR_METRIC (external);
  186. route->path.cost_e2 = 0;
  187. }
  188. for (i = 0; i < OSPF6_MULTI_PATH_LIMIT; i++)
  189. ospf6_nexthop_copy (&route->nexthop[i], &asbr_entry->nexthop[i]);
  190. if (IS_OSPF6_DEBUG_EXAMIN (AS_EXTERNAL))
  191. {
  192. prefix2str (&route->prefix, buf, sizeof (buf));
  193. zlog_debug ("AS-External route add: %s", buf);
  194. }
  195. ospf6_route_add (route, ospf6->route_table);
  196. }
  197. void
  198. ospf6_asbr_lsa_remove (struct ospf6_lsa *lsa)
  199. {
  200. struct ospf6_as_external_lsa *external;
  201. struct prefix prefix;
  202. struct ospf6_route *route;
  203. char buf[64];
  204. external = (struct ospf6_as_external_lsa *)
  205. OSPF6_LSA_HEADER_END (lsa->header);
  206. if (IS_OSPF6_DEBUG_EXAMIN (AS_EXTERNAL))
  207. zlog_debug ("Withdraw AS-External route for %s", lsa->name);
  208. if (lsa->header->adv_router == ospf6->router_id)
  209. {
  210. if (IS_OSPF6_DEBUG_EXAMIN (AS_EXTERNAL))
  211. zlog_debug ("Ignore self-originated AS-External-LSA");
  212. return;
  213. }
  214. memset (&prefix, 0, sizeof (struct prefix));
  215. prefix.family = AF_INET6;
  216. prefix.prefixlen = external->prefix.prefix_length;
  217. ospf6_prefix_in6_addr (&prefix.u.prefix6, &external->prefix);
  218. route = ospf6_route_lookup (&prefix, ospf6->route_table);
  219. if (route == NULL)
  220. {
  221. if (IS_OSPF6_DEBUG_EXAMIN (AS_EXTERNAL))
  222. {
  223. prefix2str (&prefix, buf, sizeof (buf));
  224. zlog_debug ("AS-External route %s not found", buf);
  225. }
  226. return;
  227. }
  228. for (ospf6_route_lock (route);
  229. route && ospf6_route_is_prefix (&prefix, route);
  230. route = ospf6_route_next (route))
  231. {
  232. if (route->type != OSPF6_DEST_TYPE_NETWORK)
  233. continue;
  234. if (route->path.origin.type != lsa->header->type)
  235. continue;
  236. if (route->path.origin.id != lsa->header->id)
  237. continue;
  238. if (route->path.origin.adv_router != lsa->header->adv_router)
  239. continue;
  240. if (IS_OSPF6_DEBUG_EXAMIN (AS_EXTERNAL))
  241. {
  242. prefix2str (&route->prefix, buf, sizeof (buf));
  243. zlog_debug ("AS-External route remove: %s", buf);
  244. }
  245. ospf6_route_remove (route, ospf6->route_table);
  246. }
  247. }
  248. void
  249. ospf6_asbr_lsentry_add (struct ospf6_route *asbr_entry)
  250. {
  251. struct ospf6_lsa *lsa;
  252. u_int16_t type;
  253. u_int32_t router;
  254. if (! CHECK_FLAG (asbr_entry->flag, OSPF6_ROUTE_BEST))
  255. {
  256. char buf[16];
  257. inet_ntop (AF_INET, &ADV_ROUTER_IN_PREFIX (&asbr_entry->prefix),
  258. buf, sizeof (buf));
  259. zlog_info ("ignore non-best path: lsentry %s add", buf);
  260. return;
  261. }
  262. type = htons (OSPF6_LSTYPE_AS_EXTERNAL);
  263. router = ospf6_linkstate_prefix_adv_router (&asbr_entry->prefix);
  264. for (lsa = ospf6_lsdb_type_router_head (type, router, ospf6->lsdb); lsa;
  265. lsa = ospf6_lsdb_type_router_next (type, router, lsa))
  266. {
  267. if (! OSPF6_LSA_IS_MAXAGE (lsa))
  268. ospf6_asbr_lsa_add (lsa);
  269. }
  270. }
  271. void
  272. ospf6_asbr_lsentry_remove (struct ospf6_route *asbr_entry)
  273. {
  274. struct ospf6_lsa *lsa;
  275. u_int16_t type;
  276. u_int32_t router;
  277. type = htons (OSPF6_LSTYPE_AS_EXTERNAL);
  278. router = ospf6_linkstate_prefix_adv_router (&asbr_entry->prefix);
  279. for (lsa = ospf6_lsdb_type_router_head (type, router, ospf6->lsdb);
  280. lsa; lsa = ospf6_lsdb_type_router_next (type, router, lsa))
  281. ospf6_asbr_lsa_remove (lsa);
  282. }
  283. /* redistribute function */
  284. static void
  285. ospf6_asbr_routemap_set (int type, const char *mapname)
  286. {
  287. if (ospf6->rmap[type].name)
  288. free (ospf6->rmap[type].name);
  289. ospf6->rmap[type].name = strdup (mapname);
  290. ospf6->rmap[type].map = route_map_lookup_by_name (mapname);
  291. }
  292. static void
  293. ospf6_asbr_routemap_unset (int type)
  294. {
  295. if (ospf6->rmap[type].name)
  296. free (ospf6->rmap[type].name);
  297. ospf6->rmap[type].name = NULL;
  298. ospf6->rmap[type].map = NULL;
  299. }
  300. static void
  301. ospf6_asbr_routemap_update (const char *mapname)
  302. {
  303. int type;
  304. if (ospf6 == NULL)
  305. return;
  306. for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
  307. {
  308. if (ospf6->rmap[type].name)
  309. ospf6->rmap[type].map =
  310. route_map_lookup_by_name (ospf6->rmap[type].name);
  311. else
  312. ospf6->rmap[type].map = NULL;
  313. }
  314. }
  315. int
  316. ospf6_asbr_is_asbr (struct ospf6 *o)
  317. {
  318. return o->external_table->count;
  319. }
  320. static void
  321. ospf6_asbr_redistribute_set (int type)
  322. {
  323. ospf6_zebra_redistribute (type);
  324. }
  325. static void
  326. ospf6_asbr_redistribute_unset (int type)
  327. {
  328. struct ospf6_route *route;
  329. struct ospf6_external_info *info;
  330. ospf6_zebra_no_redistribute (type);
  331. for (route = ospf6_route_head (ospf6->external_table); route;
  332. route = ospf6_route_next (route))
  333. {
  334. info = route->route_option;
  335. if (info->type != type)
  336. continue;
  337. ospf6_asbr_redistribute_remove (info->type, route->nexthop[0].ifindex,
  338. &route->prefix);
  339. }
  340. }
  341. void
  342. ospf6_asbr_redistribute_add (int type, int ifindex, struct prefix *prefix,
  343. u_int nexthop_num, struct in6_addr *nexthop)
  344. {
  345. int ret;
  346. struct ospf6_route troute;
  347. struct ospf6_external_info tinfo;
  348. struct ospf6_route *route, *match;
  349. struct ospf6_external_info *info;
  350. struct prefix prefix_id;
  351. struct route_node *node;
  352. char pbuf[64], ibuf[16];
  353. struct listnode *lnode, *lnnode;
  354. struct ospf6_area *oa;
  355. if (! ospf6_zebra_is_redistribute (type))
  356. return;
  357. if (IS_OSPF6_DEBUG_ASBR)
  358. {
  359. prefix2str (prefix, pbuf, sizeof (pbuf));
  360. zlog_debug ("Redistribute %s (%s)", pbuf, ZROUTE_NAME (type));
  361. }
  362. /* if route-map was specified but not found, do not advertise */
  363. if (ospf6->rmap[type].name)
  364. {
  365. if (ospf6->rmap[type].map == NULL)
  366. ospf6_asbr_routemap_update (NULL);
  367. if (ospf6->rmap[type].map == NULL)
  368. {
  369. zlog_warn ("route-map \"%s\" not found, suppress redistributing",
  370. ospf6->rmap[type].name);
  371. return;
  372. }
  373. }
  374. /* apply route-map */
  375. if (ospf6->rmap[type].map)
  376. {
  377. memset (&troute, 0, sizeof (troute));
  378. memset (&tinfo, 0, sizeof (tinfo));
  379. troute.route_option = &tinfo;
  380. ret = route_map_apply (ospf6->rmap[type].map, prefix,
  381. RMAP_OSPF6, &troute);
  382. if (ret == RMAP_DENYMATCH)
  383. {
  384. if (IS_OSPF6_DEBUG_ASBR)
  385. zlog_debug ("Denied by route-map \"%s\"", ospf6->rmap[type].name);
  386. return;
  387. }
  388. }
  389. match = ospf6_route_lookup (prefix, ospf6->external_table);
  390. if (match)
  391. {
  392. info = match->route_option;
  393. /* copy result of route-map */
  394. if (ospf6->rmap[type].map)
  395. {
  396. if (troute.path.metric_type)
  397. match->path.metric_type = troute.path.metric_type;
  398. if (troute.path.cost)
  399. match->path.cost = troute.path.cost;
  400. if (! IN6_IS_ADDR_UNSPECIFIED (&tinfo.forwarding))
  401. memcpy (&info->forwarding, &tinfo.forwarding,
  402. sizeof (struct in6_addr));
  403. }
  404. info->type = type;
  405. match->nexthop[0].ifindex = ifindex;
  406. if (nexthop_num && nexthop)
  407. memcpy (&match->nexthop[0].address, nexthop, sizeof (struct in6_addr));
  408. /* create/update binding in external_id_table */
  409. prefix_id.family = AF_INET;
  410. prefix_id.prefixlen = 32;
  411. prefix_id.u.prefix4.s_addr = htonl (info->id);
  412. node = route_node_get (ospf6->external_id_table, &prefix_id);
  413. node->info = match;
  414. if (IS_OSPF6_DEBUG_ASBR)
  415. {
  416. inet_ntop (AF_INET, &prefix_id.u.prefix4, ibuf, sizeof (ibuf));
  417. zlog_debug ("Advertise as AS-External Id:%s", ibuf);
  418. }
  419. match->path.origin.id = htonl (info->id);
  420. ospf6_as_external_lsa_originate (match);
  421. return;
  422. }
  423. /* create new entry */
  424. route = ospf6_route_create ();
  425. route->type = OSPF6_DEST_TYPE_NETWORK;
  426. memcpy (&route->prefix, prefix, sizeof (struct prefix));
  427. info = (struct ospf6_external_info *)
  428. XMALLOC (MTYPE_OSPF6_EXTERNAL_INFO, sizeof (struct ospf6_external_info));
  429. memset (info, 0, sizeof (struct ospf6_external_info));
  430. route->route_option = info;
  431. info->id = ospf6->external_id++;
  432. /* copy result of route-map */
  433. if (ospf6->rmap[type].map)
  434. {
  435. if (troute.path.metric_type)
  436. route->path.metric_type = troute.path.metric_type;
  437. if (troute.path.cost)
  438. route->path.cost = troute.path.cost;
  439. if (! IN6_IS_ADDR_UNSPECIFIED (&tinfo.forwarding))
  440. memcpy (&info->forwarding, &tinfo.forwarding,
  441. sizeof (struct in6_addr));
  442. }
  443. info->type = type;
  444. route->nexthop[0].ifindex = ifindex;
  445. if (nexthop_num && nexthop)
  446. memcpy (&route->nexthop[0].address, nexthop, sizeof (struct in6_addr));
  447. /* create/update binding in external_id_table */
  448. prefix_id.family = AF_INET;
  449. prefix_id.prefixlen = 32;
  450. prefix_id.u.prefix4.s_addr = htonl (info->id);
  451. node = route_node_get (ospf6->external_id_table, &prefix_id);
  452. node->info = route;
  453. route = ospf6_route_add (route, ospf6->external_table);
  454. route->route_option = info;
  455. if (IS_OSPF6_DEBUG_ASBR)
  456. {
  457. inet_ntop (AF_INET, &prefix_id.u.prefix4, ibuf, sizeof (ibuf));
  458. zlog_debug ("Advertise as AS-External Id:%s", ibuf);
  459. }
  460. route->path.origin.id = htonl (info->id);
  461. ospf6_as_external_lsa_originate (route);
  462. /* Router-Bit (ASBR Flag) may have to be updated */
  463. for (ALL_LIST_ELEMENTS (ospf6->area_list, lnode, lnnode, oa))
  464. OSPF6_ROUTER_LSA_SCHEDULE (oa);
  465. }
  466. void
  467. ospf6_asbr_redistribute_remove (int type, int ifindex, struct prefix *prefix)
  468. {
  469. struct ospf6_route *match;
  470. struct ospf6_external_info *info = NULL;
  471. struct route_node *node;
  472. struct ospf6_lsa *lsa;
  473. struct prefix prefix_id;
  474. char pbuf[64], ibuf[16];
  475. struct listnode *lnode, *lnnode;
  476. struct ospf6_area *oa;
  477. match = ospf6_route_lookup (prefix, ospf6->external_table);
  478. if (match == NULL)
  479. {
  480. if (IS_OSPF6_DEBUG_ASBR)
  481. {
  482. prefix2str (prefix, pbuf, sizeof (pbuf));
  483. zlog_debug ("No such route %s to withdraw", pbuf);
  484. }
  485. return;
  486. }
  487. info = match->route_option;
  488. assert (info);
  489. if (info->type != type)
  490. {
  491. if (IS_OSPF6_DEBUG_ASBR)
  492. {
  493. prefix2str (prefix, pbuf, sizeof (pbuf));
  494. zlog_debug ("Original protocol mismatch: %s", pbuf);
  495. }
  496. return;
  497. }
  498. if (IS_OSPF6_DEBUG_ASBR)
  499. {
  500. prefix2str (prefix, pbuf, sizeof (pbuf));
  501. inet_ntop (AF_INET, &prefix_id.u.prefix4, ibuf, sizeof (ibuf));
  502. zlog_debug ("Withdraw %s (AS-External Id:%s)", pbuf, ibuf);
  503. }
  504. lsa = ospf6_lsdb_lookup (htons (OSPF6_LSTYPE_AS_EXTERNAL),
  505. htonl (info->id), ospf6->router_id, ospf6->lsdb);
  506. if (lsa)
  507. ospf6_lsa_purge (lsa);
  508. /* remove binding in external_id_table */
  509. prefix_id.family = AF_INET;
  510. prefix_id.prefixlen = 32;
  511. prefix_id.u.prefix4.s_addr = htonl (info->id);
  512. node = route_node_lookup (ospf6->external_id_table, &prefix_id);
  513. assert (node);
  514. node->info = NULL;
  515. route_unlock_node (node);
  516. ospf6_route_remove (match, ospf6->external_table);
  517. XFREE (MTYPE_OSPF6_EXTERNAL_INFO, info);
  518. /* Router-Bit (ASBR Flag) may have to be updated */
  519. for (ALL_LIST_ELEMENTS (ospf6->area_list, lnode, lnnode, oa))
  520. OSPF6_ROUTER_LSA_SCHEDULE (oa);
  521. }
  522. DEFUN (ospf6_redistribute,
  523. ospf6_redistribute_cmd,
  524. "redistribute (static|kernel|connected|ripng|bgp)",
  525. "Redistribute\n"
  526. "Static route\n"
  527. "Kernel route\n"
  528. "Connected route\n"
  529. "RIPng route\n"
  530. "BGP route\n"
  531. )
  532. {
  533. int type = 0;
  534. if (strncmp (argv[0], "sta", 3) == 0)
  535. type = ZEBRA_ROUTE_STATIC;
  536. else if (strncmp (argv[0], "ker", 3) == 0)
  537. type = ZEBRA_ROUTE_KERNEL;
  538. else if (strncmp (argv[0], "con", 3) == 0)
  539. type = ZEBRA_ROUTE_CONNECT;
  540. else if (strncmp (argv[0], "rip", 3) == 0)
  541. type = ZEBRA_ROUTE_RIPNG;
  542. else if (strncmp (argv[0], "bgp", 3) == 0)
  543. type = ZEBRA_ROUTE_BGP;
  544. ospf6_asbr_redistribute_unset (type);
  545. ospf6_asbr_routemap_unset (type);
  546. ospf6_asbr_redistribute_set (type);
  547. return CMD_SUCCESS;
  548. }
  549. DEFUN (ospf6_redistribute_routemap,
  550. ospf6_redistribute_routemap_cmd,
  551. "redistribute (static|kernel|connected|ripng|bgp) route-map WORD",
  552. "Redistribute\n"
  553. "Static routes\n"
  554. "Kernel route\n"
  555. "Connected route\n"
  556. "RIPng route\n"
  557. "BGP route\n"
  558. "Route map reference\n"
  559. "Route map name\n"
  560. )
  561. {
  562. int type = 0;
  563. if (strncmp (argv[0], "sta", 3) == 0)
  564. type = ZEBRA_ROUTE_STATIC;
  565. else if (strncmp (argv[0], "ker", 3) == 0)
  566. type = ZEBRA_ROUTE_KERNEL;
  567. else if (strncmp (argv[0], "con", 3) == 0)
  568. type = ZEBRA_ROUTE_CONNECT;
  569. else if (strncmp (argv[0], "rip", 3) == 0)
  570. type = ZEBRA_ROUTE_RIPNG;
  571. else if (strncmp (argv[0], "bgp", 3) == 0)
  572. type = ZEBRA_ROUTE_BGP;
  573. ospf6_asbr_redistribute_unset (type);
  574. ospf6_asbr_routemap_set (type, argv[1]);
  575. ospf6_asbr_redistribute_set (type);
  576. return CMD_SUCCESS;
  577. }
  578. DEFUN (no_ospf6_redistribute,
  579. no_ospf6_redistribute_cmd,
  580. "no redistribute (static|kernel|connected|ripng|bgp)",
  581. NO_STR
  582. "Redistribute\n"
  583. "Static route\n"
  584. "Kernel route\n"
  585. "Connected route\n"
  586. "RIPng route\n"
  587. "BGP route\n"
  588. )
  589. {
  590. int type = 0;
  591. if (strncmp (argv[0], "sta", 3) == 0)
  592. type = ZEBRA_ROUTE_STATIC;
  593. else if (strncmp (argv[0], "ker", 3) == 0)
  594. type = ZEBRA_ROUTE_KERNEL;
  595. else if (strncmp (argv[0], "con", 3) == 0)
  596. type = ZEBRA_ROUTE_CONNECT;
  597. else if (strncmp (argv[0], "rip", 3) == 0)
  598. type = ZEBRA_ROUTE_RIPNG;
  599. else if (strncmp (argv[0], "bgp", 3) == 0)
  600. type = ZEBRA_ROUTE_BGP;
  601. ospf6_asbr_redistribute_unset (type);
  602. ospf6_asbr_routemap_unset (type);
  603. return CMD_SUCCESS;
  604. }
  605. int
  606. ospf6_redistribute_config_write (struct vty *vty)
  607. {
  608. int type;
  609. for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
  610. {
  611. if (type == ZEBRA_ROUTE_OSPF6)
  612. continue;
  613. if (! ospf6_zebra_is_redistribute (type))
  614. continue;
  615. if (ospf6->rmap[type].name)
  616. vty_out (vty, " redistribute %s route-map %s%s",
  617. ZROUTE_NAME (type), ospf6->rmap[type].name, VNL);
  618. else
  619. vty_out (vty, " redistribute %s%s",
  620. ZROUTE_NAME (type), VNL);
  621. }
  622. return 0;
  623. }
  624. static void
  625. ospf6_redistribute_show_config (struct vty *vty)
  626. {
  627. int type;
  628. int nroute[ZEBRA_ROUTE_MAX];
  629. int total;
  630. struct ospf6_route *route;
  631. struct ospf6_external_info *info;
  632. total = 0;
  633. for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
  634. nroute[type] = 0;
  635. for (route = ospf6_route_head (ospf6->external_table); route;
  636. route = ospf6_route_next (route))
  637. {
  638. info = route->route_option;
  639. nroute[info->type]++;
  640. total++;
  641. }
  642. vty_out (vty, "Redistributing External Routes from:%s", VNL);
  643. for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
  644. {
  645. if (type == ZEBRA_ROUTE_OSPF6)
  646. continue;
  647. if (! ospf6_zebra_is_redistribute (type))
  648. continue;
  649. if (ospf6->rmap[type].name)
  650. vty_out (vty, " %d: %s with route-map \"%s\"%s%s", nroute[type],
  651. ZROUTE_NAME (type), ospf6->rmap[type].name,
  652. (ospf6->rmap[type].map ? "" : " (not found !)"),
  653. VNL);
  654. else
  655. vty_out (vty, " %d: %s%s", nroute[type],
  656. ZROUTE_NAME (type), VNL);
  657. }
  658. vty_out (vty, "Total %d routes%s", total, VNL);
  659. }
  660. /* Routemap Functions */
  661. static route_map_result_t
  662. ospf6_routemap_rule_match_address_prefixlist (void *rule,
  663. struct prefix *prefix,
  664. route_map_object_t type,
  665. void *object)
  666. {
  667. struct prefix_list *plist;
  668. if (type != RMAP_OSPF6)
  669. return RMAP_NOMATCH;
  670. plist = prefix_list_lookup (AFI_IP6, (char *) rule);
  671. if (plist == NULL)
  672. return RMAP_NOMATCH;
  673. return (prefix_list_apply (plist, prefix) == PREFIX_DENY ?
  674. RMAP_NOMATCH : RMAP_MATCH);
  675. }
  676. static void *
  677. ospf6_routemap_rule_match_address_prefixlist_compile (const char *arg)
  678. {
  679. return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
  680. }
  681. static void
  682. ospf6_routemap_rule_match_address_prefixlist_free (void *rule)
  683. {
  684. XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
  685. }
  686. struct route_map_rule_cmd
  687. ospf6_routemap_rule_match_address_prefixlist_cmd =
  688. {
  689. "ipv6 address prefix-list",
  690. ospf6_routemap_rule_match_address_prefixlist,
  691. ospf6_routemap_rule_match_address_prefixlist_compile,
  692. ospf6_routemap_rule_match_address_prefixlist_free,
  693. };
  694. static route_map_result_t
  695. ospf6_routemap_rule_set_metric_type (void *rule, struct prefix *prefix,
  696. route_map_object_t type, void *object)
  697. {
  698. char *metric_type = rule;
  699. struct ospf6_route *route = object;
  700. if (type != RMAP_OSPF6)
  701. return RMAP_OKAY;
  702. if (strcmp (metric_type, "type-2") == 0)
  703. route->path.metric_type = 2;
  704. else
  705. route->path.metric_type = 1;
  706. return RMAP_OKAY;
  707. }
  708. static void *
  709. ospf6_routemap_rule_set_metric_type_compile (const char *arg)
  710. {
  711. if (strcmp (arg, "type-2") && strcmp (arg, "type-1"))
  712. return NULL;
  713. return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
  714. }
  715. static void
  716. ospf6_routemap_rule_set_metric_type_free (void *rule)
  717. {
  718. XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
  719. }
  720. struct route_map_rule_cmd
  721. ospf6_routemap_rule_set_metric_type_cmd =
  722. {
  723. "metric-type",
  724. ospf6_routemap_rule_set_metric_type,
  725. ospf6_routemap_rule_set_metric_type_compile,
  726. ospf6_routemap_rule_set_metric_type_free,
  727. };
  728. static route_map_result_t
  729. ospf6_routemap_rule_set_metric (void *rule, struct prefix *prefix,
  730. route_map_object_t type, void *object)
  731. {
  732. char *metric = rule;
  733. struct ospf6_route *route = object;
  734. if (type != RMAP_OSPF6)
  735. return RMAP_OKAY;
  736. route->path.cost = atoi (metric);
  737. return RMAP_OKAY;
  738. }
  739. static void *
  740. ospf6_routemap_rule_set_metric_compile (const char *arg)
  741. {
  742. u_int32_t metric;
  743. char *endp;
  744. metric = strtoul (arg, &endp, 0);
  745. if (metric > LS_INFINITY || *endp != '\0')
  746. return NULL;
  747. return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
  748. }
  749. static void
  750. ospf6_routemap_rule_set_metric_free (void *rule)
  751. {
  752. XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
  753. }
  754. struct route_map_rule_cmd
  755. ospf6_routemap_rule_set_metric_cmd =
  756. {
  757. "metric",
  758. ospf6_routemap_rule_set_metric,
  759. ospf6_routemap_rule_set_metric_compile,
  760. ospf6_routemap_rule_set_metric_free,
  761. };
  762. static route_map_result_t
  763. ospf6_routemap_rule_set_forwarding (void *rule, struct prefix *prefix,
  764. route_map_object_t type, void *object)
  765. {
  766. char *forwarding = rule;
  767. struct ospf6_route *route = object;
  768. struct ospf6_external_info *info = route->route_option;
  769. if (type != RMAP_OSPF6)
  770. return RMAP_OKAY;
  771. if (inet_pton (AF_INET6, forwarding, &info->forwarding) != 1)
  772. {
  773. memset (&info->forwarding, 0, sizeof (struct in6_addr));
  774. return RMAP_ERROR;
  775. }
  776. return RMAP_OKAY;
  777. }
  778. static void *
  779. ospf6_routemap_rule_set_forwarding_compile (const char *arg)
  780. {
  781. struct in6_addr a;
  782. if (inet_pton (AF_INET6, arg, &a) != 1)
  783. return NULL;
  784. return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
  785. }
  786. static void
  787. ospf6_routemap_rule_set_forwarding_free (void *rule)
  788. {
  789. XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
  790. }
  791. struct route_map_rule_cmd
  792. ospf6_routemap_rule_set_forwarding_cmd =
  793. {
  794. "forwarding-address",
  795. ospf6_routemap_rule_set_forwarding,
  796. ospf6_routemap_rule_set_forwarding_compile,
  797. ospf6_routemap_rule_set_forwarding_free,
  798. };
  799. static int
  800. route_map_command_status (struct vty *vty, int ret)
  801. {
  802. if (! ret)
  803. return CMD_SUCCESS;
  804. switch (ret)
  805. {
  806. case RMAP_RULE_MISSING:
  807. vty_out (vty, "Can't find rule.%s", VNL);
  808. break;
  809. case RMAP_COMPILE_ERROR:
  810. vty_out (vty, "Argument is malformed.%s", VNL);
  811. break;
  812. default:
  813. vty_out (vty, "route-map add set failed.%s", VNL);
  814. break;
  815. }
  816. return CMD_WARNING;
  817. }
  818. /* add "match address" */
  819. DEFUN (ospf6_routemap_match_address_prefixlist,
  820. ospf6_routemap_match_address_prefixlist_cmd,
  821. "match ipv6 address prefix-list WORD",
  822. "Match values\n"
  823. IPV6_STR
  824. "Match address of route\n"
  825. "Match entries of prefix-lists\n"
  826. "IPv6 prefix-list name\n")
  827. {
  828. int ret = route_map_add_match ((struct route_map_index *) vty->index,
  829. "ipv6 address prefix-list", argv[0]);
  830. return route_map_command_status (vty, ret);
  831. }
  832. /* delete "match address" */
  833. DEFUN (ospf6_routemap_no_match_address_prefixlist,
  834. ospf6_routemap_no_match_address_prefixlist_cmd,
  835. "no match ipv6 address prefix-list WORD",
  836. NO_STR
  837. "Match values\n"
  838. IPV6_STR
  839. "Match address of route\n"
  840. "Match entries of prefix-lists\n"
  841. "IPv6 prefix-list name\n")
  842. {
  843. int ret = route_map_delete_match ((struct route_map_index *) vty->index,
  844. "ipv6 address prefix-list", argv[0]);
  845. return route_map_command_status (vty, ret);
  846. }
  847. /* add "set metric-type" */
  848. DEFUN (ospf6_routemap_set_metric_type,
  849. ospf6_routemap_set_metric_type_cmd,
  850. "set metric-type (type-1|type-2)",
  851. "Set value\n"
  852. "Type of metric\n"
  853. "OSPF6 external type 1 metric\n"
  854. "OSPF6 external type 2 metric\n")
  855. {
  856. int ret = route_map_add_set ((struct route_map_index *) vty->index,
  857. "metric-type", argv[0]);
  858. return route_map_command_status (vty, ret);
  859. }
  860. /* delete "set metric-type" */
  861. DEFUN (ospf6_routemap_no_set_metric_type,
  862. ospf6_routemap_no_set_metric_type_cmd,
  863. "no set metric-type (type-1|type-2)",
  864. NO_STR
  865. "Set value\n"
  866. "Type of metric\n"
  867. "OSPF6 external type 1 metric\n"
  868. "OSPF6 external type 2 metric\n")
  869. {
  870. int ret = route_map_delete_set ((struct route_map_index *) vty->index,
  871. "metric-type", argv[0]);
  872. return route_map_command_status (vty, ret);
  873. }
  874. /* add "set metric" */
  875. DEFUN (set_metric,
  876. set_metric_cmd,
  877. "set metric <0-4294967295>",
  878. "Set value\n"
  879. "Metric value\n"
  880. "Metric value\n")
  881. {
  882. int ret = route_map_add_set ((struct route_map_index *) vty->index,
  883. "metric", argv[0]);
  884. return route_map_command_status (vty, ret);
  885. }
  886. /* delete "set metric" */
  887. DEFUN (no_set_metric,
  888. no_set_metric_cmd,
  889. "no set metric <0-4294967295>",
  890. NO_STR
  891. "Set value\n"
  892. "Metric\n"
  893. "METRIC value\n")
  894. {
  895. int ret = route_map_delete_set ((struct route_map_index *) vty->index,
  896. "metric", argv[0]);
  897. return route_map_command_status (vty, ret);
  898. }
  899. /* add "set forwarding-address" */
  900. DEFUN (ospf6_routemap_set_forwarding,
  901. ospf6_routemap_set_forwarding_cmd,
  902. "set forwarding-address X:X::X:X",
  903. "Set value\n"
  904. "Forwarding Address\n"
  905. "IPv6 Address\n")
  906. {
  907. int ret = route_map_add_set ((struct route_map_index *) vty->index,
  908. "forwarding-address", argv[0]);
  909. return route_map_command_status (vty, ret);
  910. }
  911. /* delete "set forwarding-address" */
  912. DEFUN (ospf6_routemap_no_set_forwarding,
  913. ospf6_routemap_no_set_forwarding_cmd,
  914. "no set forwarding-address X:X::X:X",
  915. NO_STR
  916. "Set value\n"
  917. "Forwarding Address\n"
  918. "IPv6 Address\n")
  919. {
  920. int ret = route_map_delete_set ((struct route_map_index *) vty->index,
  921. "forwarding-address", argv[0]);
  922. return route_map_command_status (vty, ret);
  923. }
  924. static void
  925. ospf6_routemap_init (void)
  926. {
  927. route_map_init ();
  928. route_map_init_vty ();
  929. route_map_add_hook (ospf6_asbr_routemap_update);
  930. route_map_delete_hook (ospf6_asbr_routemap_update);
  931. route_map_install_match (&ospf6_routemap_rule_match_address_prefixlist_cmd);
  932. route_map_install_set (&ospf6_routemap_rule_set_metric_type_cmd);
  933. route_map_install_set (&ospf6_routemap_rule_set_metric_cmd);
  934. route_map_install_set (&ospf6_routemap_rule_set_forwarding_cmd);
  935. /* Match address prefix-list */
  936. install_element (RMAP_NODE, &ospf6_routemap_match_address_prefixlist_cmd);
  937. install_element (RMAP_NODE, &ospf6_routemap_no_match_address_prefixlist_cmd);
  938. /* ASE Metric Type (e.g. Type-1/Type-2) */
  939. install_element (RMAP_NODE, &ospf6_routemap_set_metric_type_cmd);
  940. install_element (RMAP_NODE, &ospf6_routemap_no_set_metric_type_cmd);
  941. /* ASE Metric */
  942. install_element (RMAP_NODE, &set_metric_cmd);
  943. install_element (RMAP_NODE, &no_set_metric_cmd);
  944. /* ASE Metric */
  945. install_element (RMAP_NODE, &ospf6_routemap_set_forwarding_cmd);
  946. install_element (RMAP_NODE, &ospf6_routemap_no_set_forwarding_cmd);
  947. }
  948. /* Display functions */
  949. static int
  950. ospf6_as_external_lsa_show (struct vty *vty, struct ospf6_lsa *lsa)
  951. {
  952. struct ospf6_as_external_lsa *external;
  953. char buf[64];
  954. struct in6_addr in6, *forwarding;
  955. assert (lsa->header);
  956. external = (struct ospf6_as_external_lsa *)
  957. OSPF6_LSA_HEADER_END (lsa->header);
  958. /* bits */
  959. snprintf (buf, sizeof (buf), "%c%c%c",
  960. (CHECK_FLAG (external->bits_metric, OSPF6_ASBR_BIT_E) ? 'E' : '-'),
  961. (CHECK_FLAG (external->bits_metric, OSPF6_ASBR_BIT_F) ? 'F' : '-'),
  962. (CHECK_FLAG (external->bits_metric, OSPF6_ASBR_BIT_T) ? 'T' : '-'));
  963. vty_out (vty, " Bits: %s%s", buf, VNL);
  964. vty_out (vty, " Metric: %5lu%s", (u_long) OSPF6_ASBR_METRIC (external),
  965. VNL);
  966. ospf6_prefix_options_printbuf (external->prefix.prefix_options,
  967. buf, sizeof (buf));
  968. vty_out (vty, " Prefix Options: %s%s", buf,
  969. VNL);
  970. vty_out (vty, " Referenced LSType: %d%s",
  971. ntohs (external->prefix.prefix_refer_lstype),
  972. VNL);
  973. ospf6_prefix_in6_addr (&in6, &external->prefix);
  974. inet_ntop (AF_INET6, &in6, buf, sizeof (buf));
  975. vty_out (vty, " Prefix: %s/%d%s", buf,
  976. external->prefix.prefix_length, VNL);
  977. /* Forwarding-Address */
  978. if (CHECK_FLAG (external->bits_metric, OSPF6_ASBR_BIT_F))
  979. {
  980. forwarding = (struct in6_addr *)
  981. ((caddr_t) external + sizeof (struct ospf6_as_external_lsa) +
  982. OSPF6_PREFIX_SPACE (external->prefix.prefix_length));
  983. inet_ntop (AF_INET6, forwarding, buf, sizeof (buf));
  984. vty_out (vty, " Forwarding-Address: %s%s", buf, VNL);
  985. }
  986. return 0;
  987. }
  988. static void
  989. ospf6_asbr_external_route_show (struct vty *vty, struct ospf6_route *route)
  990. {
  991. struct ospf6_external_info *info = route->route_option;
  992. char prefix[64], id[16], forwarding[64];
  993. u_int32_t tmp_id;
  994. prefix2str (&route->prefix, prefix, sizeof (prefix));
  995. tmp_id = ntohl (info->id);
  996. inet_ntop (AF_INET, &tmp_id, id, sizeof (id));
  997. if (! IN6_IS_ADDR_UNSPECIFIED (&info->forwarding))
  998. inet_ntop (AF_INET6, &info->forwarding, forwarding, sizeof (forwarding));
  999. else
  1000. snprintf (forwarding, sizeof (forwarding), ":: (ifindex %d)",
  1001. route->nexthop[0].ifindex);
  1002. vty_out (vty, "%c %-32s %-15s type-%d %5lu %s%s",
  1003. zebra_route_char(info->type),
  1004. prefix, id, route->path.metric_type,
  1005. (u_long) (route->path.metric_type == 2 ?
  1006. route->path.cost_e2 : route->path.cost),
  1007. forwarding, VNL);
  1008. }
  1009. DEFUN (show_ipv6_ospf6_redistribute,
  1010. show_ipv6_ospf6_redistribute_cmd,
  1011. "show ipv6 ospf6 redistribute",
  1012. SHOW_STR
  1013. IP6_STR
  1014. OSPF6_STR
  1015. "redistributing External information\n"
  1016. )
  1017. {
  1018. struct ospf6_route *route;
  1019. ospf6_redistribute_show_config (vty);
  1020. for (route = ospf6_route_head (ospf6->external_table); route;
  1021. route = ospf6_route_next (route))
  1022. ospf6_asbr_external_route_show (vty, route);
  1023. return CMD_SUCCESS;
  1024. }
  1025. struct ospf6_lsa_handler as_external_handler =
  1026. {
  1027. OSPF6_LSTYPE_AS_EXTERNAL,
  1028. "AS-External",
  1029. ospf6_as_external_lsa_show
  1030. };
  1031. void
  1032. ospf6_asbr_init (void)
  1033. {
  1034. ospf6_routemap_init ();
  1035. ospf6_install_lsa_handler (&as_external_handler);
  1036. install_element (VIEW_NODE, &show_ipv6_ospf6_redistribute_cmd);
  1037. install_element (ENABLE_NODE, &show_ipv6_ospf6_redistribute_cmd);
  1038. install_element (OSPF6_NODE, &ospf6_redistribute_cmd);
  1039. install_element (OSPF6_NODE, &ospf6_redistribute_routemap_cmd);
  1040. install_element (OSPF6_NODE, &no_ospf6_redistribute_cmd);
  1041. }
  1042. DEFUN (debug_ospf6_asbr,
  1043. debug_ospf6_asbr_cmd,
  1044. "debug ospf6 asbr",
  1045. DEBUG_STR
  1046. OSPF6_STR
  1047. "Debug OSPFv3 ASBR function\n"
  1048. )
  1049. {
  1050. OSPF6_DEBUG_ASBR_ON ();
  1051. return CMD_SUCCESS;
  1052. }
  1053. DEFUN (no_debug_ospf6_asbr,
  1054. no_debug_ospf6_asbr_cmd,
  1055. "no debug ospf6 asbr",
  1056. NO_STR
  1057. DEBUG_STR
  1058. OSPF6_STR
  1059. "Debug OSPFv3 ASBR function\n"
  1060. )
  1061. {
  1062. OSPF6_DEBUG_ASBR_OFF ();
  1063. return CMD_SUCCESS;
  1064. }
  1065. int
  1066. config_write_ospf6_debug_asbr (struct vty *vty)
  1067. {
  1068. if (IS_OSPF6_DEBUG_ASBR)
  1069. vty_out (vty, "debug ospf6 asbr%s", VNL);
  1070. return 0;
  1071. }
  1072. void
  1073. install_element_ospf6_debug_asbr ()
  1074. {
  1075. install_element (ENABLE_NODE, &debug_ospf6_asbr_cmd);
  1076. install_element (ENABLE_NODE, &no_debug_ospf6_asbr_cmd);
  1077. install_element (CONFIG_NODE, &debug_ospf6_asbr_cmd);
  1078. install_element (CONFIG_NODE, &no_debug_ospf6_asbr_cmd);
  1079. }