ospf6_asbr.c 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265
  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. XCALLOC (MTYPE_OSPF6_EXTERNAL_INFO, sizeof (struct ospf6_external_info));
  429. route->route_option = info;
  430. info->id = ospf6->external_id++;
  431. /* copy result of route-map */
  432. if (ospf6->rmap[type].map)
  433. {
  434. if (troute.path.metric_type)
  435. route->path.metric_type = troute.path.metric_type;
  436. if (troute.path.cost)
  437. route->path.cost = troute.path.cost;
  438. if (! IN6_IS_ADDR_UNSPECIFIED (&tinfo.forwarding))
  439. memcpy (&info->forwarding, &tinfo.forwarding,
  440. sizeof (struct in6_addr));
  441. }
  442. info->type = type;
  443. route->nexthop[0].ifindex = ifindex;
  444. if (nexthop_num && nexthop)
  445. memcpy (&route->nexthop[0].address, nexthop, sizeof (struct in6_addr));
  446. /* create/update binding in external_id_table */
  447. prefix_id.family = AF_INET;
  448. prefix_id.prefixlen = 32;
  449. prefix_id.u.prefix4.s_addr = htonl (info->id);
  450. node = route_node_get (ospf6->external_id_table, &prefix_id);
  451. node->info = route;
  452. route = ospf6_route_add (route, ospf6->external_table);
  453. route->route_option = info;
  454. if (IS_OSPF6_DEBUG_ASBR)
  455. {
  456. inet_ntop (AF_INET, &prefix_id.u.prefix4, ibuf, sizeof (ibuf));
  457. zlog_debug ("Advertise as AS-External Id:%s", ibuf);
  458. }
  459. route->path.origin.id = htonl (info->id);
  460. ospf6_as_external_lsa_originate (route);
  461. /* Router-Bit (ASBR Flag) may have to be updated */
  462. for (ALL_LIST_ELEMENTS (ospf6->area_list, lnode, lnnode, oa))
  463. OSPF6_ROUTER_LSA_SCHEDULE (oa);
  464. }
  465. void
  466. ospf6_asbr_redistribute_remove (int type, int ifindex, struct prefix *prefix)
  467. {
  468. struct ospf6_route *match;
  469. struct ospf6_external_info *info = NULL;
  470. struct route_node *node;
  471. struct ospf6_lsa *lsa;
  472. struct prefix prefix_id;
  473. char pbuf[64], ibuf[16];
  474. struct listnode *lnode, *lnnode;
  475. struct ospf6_area *oa;
  476. match = ospf6_route_lookup (prefix, ospf6->external_table);
  477. if (match == NULL)
  478. {
  479. if (IS_OSPF6_DEBUG_ASBR)
  480. {
  481. prefix2str (prefix, pbuf, sizeof (pbuf));
  482. zlog_debug ("No such route %s to withdraw", pbuf);
  483. }
  484. return;
  485. }
  486. info = match->route_option;
  487. assert (info);
  488. if (info->type != type)
  489. {
  490. if (IS_OSPF6_DEBUG_ASBR)
  491. {
  492. prefix2str (prefix, pbuf, sizeof (pbuf));
  493. zlog_debug ("Original protocol mismatch: %s", pbuf);
  494. }
  495. return;
  496. }
  497. if (IS_OSPF6_DEBUG_ASBR)
  498. {
  499. prefix2str (prefix, pbuf, sizeof (pbuf));
  500. inet_ntop (AF_INET, &prefix_id.u.prefix4, ibuf, sizeof (ibuf));
  501. zlog_debug ("Withdraw %s (AS-External Id:%s)", pbuf, ibuf);
  502. }
  503. lsa = ospf6_lsdb_lookup (htons (OSPF6_LSTYPE_AS_EXTERNAL),
  504. htonl (info->id), ospf6->router_id, ospf6->lsdb);
  505. if (lsa)
  506. ospf6_lsa_purge (lsa);
  507. /* remove binding in external_id_table */
  508. prefix_id.family = AF_INET;
  509. prefix_id.prefixlen = 32;
  510. prefix_id.u.prefix4.s_addr = htonl (info->id);
  511. node = route_node_lookup (ospf6->external_id_table, &prefix_id);
  512. assert (node);
  513. node->info = NULL;
  514. route_unlock_node (node);
  515. ospf6_route_remove (match, ospf6->external_table);
  516. XFREE (MTYPE_OSPF6_EXTERNAL_INFO, info);
  517. /* Router-Bit (ASBR Flag) may have to be updated */
  518. for (ALL_LIST_ELEMENTS (ospf6->area_list, lnode, lnnode, oa))
  519. OSPF6_ROUTER_LSA_SCHEDULE (oa);
  520. }
  521. DEFUN (ospf6_redistribute,
  522. ospf6_redistribute_cmd,
  523. "redistribute (static|kernel|connected|ripng|bgp)",
  524. "Redistribute\n"
  525. "Static route\n"
  526. "Kernel route\n"
  527. "Connected route\n"
  528. "RIPng route\n"
  529. "BGP route\n"
  530. )
  531. {
  532. int type = 0;
  533. if (strncmp (argv[0], "sta", 3) == 0)
  534. type = ZEBRA_ROUTE_STATIC;
  535. else if (strncmp (argv[0], "ker", 3) == 0)
  536. type = ZEBRA_ROUTE_KERNEL;
  537. else if (strncmp (argv[0], "con", 3) == 0)
  538. type = ZEBRA_ROUTE_CONNECT;
  539. else if (strncmp (argv[0], "rip", 3) == 0)
  540. type = ZEBRA_ROUTE_RIPNG;
  541. else if (strncmp (argv[0], "bgp", 3) == 0)
  542. type = ZEBRA_ROUTE_BGP;
  543. ospf6_asbr_redistribute_unset (type);
  544. ospf6_asbr_routemap_unset (type);
  545. ospf6_asbr_redistribute_set (type);
  546. return CMD_SUCCESS;
  547. }
  548. DEFUN (ospf6_redistribute_routemap,
  549. ospf6_redistribute_routemap_cmd,
  550. "redistribute (static|kernel|connected|ripng|bgp) route-map WORD",
  551. "Redistribute\n"
  552. "Static routes\n"
  553. "Kernel route\n"
  554. "Connected route\n"
  555. "RIPng route\n"
  556. "BGP route\n"
  557. "Route map reference\n"
  558. "Route map name\n"
  559. )
  560. {
  561. int type = 0;
  562. if (strncmp (argv[0], "sta", 3) == 0)
  563. type = ZEBRA_ROUTE_STATIC;
  564. else if (strncmp (argv[0], "ker", 3) == 0)
  565. type = ZEBRA_ROUTE_KERNEL;
  566. else if (strncmp (argv[0], "con", 3) == 0)
  567. type = ZEBRA_ROUTE_CONNECT;
  568. else if (strncmp (argv[0], "rip", 3) == 0)
  569. type = ZEBRA_ROUTE_RIPNG;
  570. else if (strncmp (argv[0], "bgp", 3) == 0)
  571. type = ZEBRA_ROUTE_BGP;
  572. ospf6_asbr_redistribute_unset (type);
  573. ospf6_asbr_routemap_set (type, argv[1]);
  574. ospf6_asbr_redistribute_set (type);
  575. return CMD_SUCCESS;
  576. }
  577. DEFUN (no_ospf6_redistribute,
  578. no_ospf6_redistribute_cmd,
  579. "no redistribute (static|kernel|connected|ripng|bgp)",
  580. NO_STR
  581. "Redistribute\n"
  582. "Static route\n"
  583. "Kernel route\n"
  584. "Connected route\n"
  585. "RIPng route\n"
  586. "BGP route\n"
  587. )
  588. {
  589. int type = 0;
  590. if (strncmp (argv[0], "sta", 3) == 0)
  591. type = ZEBRA_ROUTE_STATIC;
  592. else if (strncmp (argv[0], "ker", 3) == 0)
  593. type = ZEBRA_ROUTE_KERNEL;
  594. else if (strncmp (argv[0], "con", 3) == 0)
  595. type = ZEBRA_ROUTE_CONNECT;
  596. else if (strncmp (argv[0], "rip", 3) == 0)
  597. type = ZEBRA_ROUTE_RIPNG;
  598. else if (strncmp (argv[0], "bgp", 3) == 0)
  599. type = ZEBRA_ROUTE_BGP;
  600. ospf6_asbr_redistribute_unset (type);
  601. ospf6_asbr_routemap_unset (type);
  602. return CMD_SUCCESS;
  603. }
  604. int
  605. ospf6_redistribute_config_write (struct vty *vty)
  606. {
  607. int type;
  608. for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
  609. {
  610. if (type == ZEBRA_ROUTE_OSPF6)
  611. continue;
  612. if (! ospf6_zebra_is_redistribute (type))
  613. continue;
  614. if (ospf6->rmap[type].name)
  615. vty_out (vty, " redistribute %s route-map %s%s",
  616. ZROUTE_NAME (type), ospf6->rmap[type].name, VNL);
  617. else
  618. vty_out (vty, " redistribute %s%s",
  619. ZROUTE_NAME (type), VNL);
  620. }
  621. return 0;
  622. }
  623. static void
  624. ospf6_redistribute_show_config (struct vty *vty)
  625. {
  626. int type;
  627. int nroute[ZEBRA_ROUTE_MAX];
  628. int total;
  629. struct ospf6_route *route;
  630. struct ospf6_external_info *info;
  631. total = 0;
  632. for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
  633. nroute[type] = 0;
  634. for (route = ospf6_route_head (ospf6->external_table); route;
  635. route = ospf6_route_next (route))
  636. {
  637. info = route->route_option;
  638. nroute[info->type]++;
  639. total++;
  640. }
  641. vty_out (vty, "Redistributing External Routes from:%s", VNL);
  642. for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
  643. {
  644. if (type == ZEBRA_ROUTE_OSPF6)
  645. continue;
  646. if (! ospf6_zebra_is_redistribute (type))
  647. continue;
  648. if (ospf6->rmap[type].name)
  649. vty_out (vty, " %d: %s with route-map \"%s\"%s%s", nroute[type],
  650. ZROUTE_NAME (type), ospf6->rmap[type].name,
  651. (ospf6->rmap[type].map ? "" : " (not found !)"),
  652. VNL);
  653. else
  654. vty_out (vty, " %d: %s%s", nroute[type],
  655. ZROUTE_NAME (type), VNL);
  656. }
  657. vty_out (vty, "Total %d routes%s", total, VNL);
  658. }
  659. /* Routemap Functions */
  660. static route_map_result_t
  661. ospf6_routemap_rule_match_address_prefixlist (void *rule,
  662. struct prefix *prefix,
  663. route_map_object_t type,
  664. void *object)
  665. {
  666. struct prefix_list *plist;
  667. if (type != RMAP_OSPF6)
  668. return RMAP_NOMATCH;
  669. plist = prefix_list_lookup (AFI_IP6, (char *) rule);
  670. if (plist == NULL)
  671. return RMAP_NOMATCH;
  672. return (prefix_list_apply (plist, prefix) == PREFIX_DENY ?
  673. RMAP_NOMATCH : RMAP_MATCH);
  674. }
  675. static void *
  676. ospf6_routemap_rule_match_address_prefixlist_compile (const char *arg)
  677. {
  678. return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
  679. }
  680. static void
  681. ospf6_routemap_rule_match_address_prefixlist_free (void *rule)
  682. {
  683. XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
  684. }
  685. struct route_map_rule_cmd
  686. ospf6_routemap_rule_match_address_prefixlist_cmd =
  687. {
  688. "ipv6 address prefix-list",
  689. ospf6_routemap_rule_match_address_prefixlist,
  690. ospf6_routemap_rule_match_address_prefixlist_compile,
  691. ospf6_routemap_rule_match_address_prefixlist_free,
  692. };
  693. static route_map_result_t
  694. ospf6_routemap_rule_set_metric_type (void *rule, struct prefix *prefix,
  695. route_map_object_t type, void *object)
  696. {
  697. char *metric_type = rule;
  698. struct ospf6_route *route = object;
  699. if (type != RMAP_OSPF6)
  700. return RMAP_OKAY;
  701. if (strcmp (metric_type, "type-2") == 0)
  702. route->path.metric_type = 2;
  703. else
  704. route->path.metric_type = 1;
  705. return RMAP_OKAY;
  706. }
  707. static void *
  708. ospf6_routemap_rule_set_metric_type_compile (const char *arg)
  709. {
  710. if (strcmp (arg, "type-2") && strcmp (arg, "type-1"))
  711. return NULL;
  712. return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
  713. }
  714. static void
  715. ospf6_routemap_rule_set_metric_type_free (void *rule)
  716. {
  717. XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
  718. }
  719. struct route_map_rule_cmd
  720. ospf6_routemap_rule_set_metric_type_cmd =
  721. {
  722. "metric-type",
  723. ospf6_routemap_rule_set_metric_type,
  724. ospf6_routemap_rule_set_metric_type_compile,
  725. ospf6_routemap_rule_set_metric_type_free,
  726. };
  727. static route_map_result_t
  728. ospf6_routemap_rule_set_metric (void *rule, struct prefix *prefix,
  729. route_map_object_t type, void *object)
  730. {
  731. char *metric = rule;
  732. struct ospf6_route *route = object;
  733. if (type != RMAP_OSPF6)
  734. return RMAP_OKAY;
  735. route->path.cost = atoi (metric);
  736. return RMAP_OKAY;
  737. }
  738. static void *
  739. ospf6_routemap_rule_set_metric_compile (const char *arg)
  740. {
  741. u_int32_t metric;
  742. char *endp;
  743. metric = strtoul (arg, &endp, 0);
  744. if (metric > LS_INFINITY || *endp != '\0')
  745. return NULL;
  746. return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
  747. }
  748. static void
  749. ospf6_routemap_rule_set_metric_free (void *rule)
  750. {
  751. XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
  752. }
  753. struct route_map_rule_cmd
  754. ospf6_routemap_rule_set_metric_cmd =
  755. {
  756. "metric",
  757. ospf6_routemap_rule_set_metric,
  758. ospf6_routemap_rule_set_metric_compile,
  759. ospf6_routemap_rule_set_metric_free,
  760. };
  761. static route_map_result_t
  762. ospf6_routemap_rule_set_forwarding (void *rule, struct prefix *prefix,
  763. route_map_object_t type, void *object)
  764. {
  765. char *forwarding = rule;
  766. struct ospf6_route *route = object;
  767. struct ospf6_external_info *info = route->route_option;
  768. if (type != RMAP_OSPF6)
  769. return RMAP_OKAY;
  770. if (inet_pton (AF_INET6, forwarding, &info->forwarding) != 1)
  771. {
  772. memset (&info->forwarding, 0, sizeof (struct in6_addr));
  773. return RMAP_ERROR;
  774. }
  775. return RMAP_OKAY;
  776. }
  777. static void *
  778. ospf6_routemap_rule_set_forwarding_compile (const char *arg)
  779. {
  780. struct in6_addr a;
  781. if (inet_pton (AF_INET6, arg, &a) != 1)
  782. return NULL;
  783. return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
  784. }
  785. static void
  786. ospf6_routemap_rule_set_forwarding_free (void *rule)
  787. {
  788. XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
  789. }
  790. struct route_map_rule_cmd
  791. ospf6_routemap_rule_set_forwarding_cmd =
  792. {
  793. "forwarding-address",
  794. ospf6_routemap_rule_set_forwarding,
  795. ospf6_routemap_rule_set_forwarding_compile,
  796. ospf6_routemap_rule_set_forwarding_free,
  797. };
  798. static int
  799. route_map_command_status (struct vty *vty, int ret)
  800. {
  801. if (! ret)
  802. return CMD_SUCCESS;
  803. switch (ret)
  804. {
  805. case RMAP_RULE_MISSING:
  806. vty_out (vty, "Can't find rule.%s", VNL);
  807. break;
  808. case RMAP_COMPILE_ERROR:
  809. vty_out (vty, "Argument is malformed.%s", VNL);
  810. break;
  811. default:
  812. vty_out (vty, "route-map add set failed.%s", VNL);
  813. break;
  814. }
  815. return CMD_WARNING;
  816. }
  817. /* add "match address" */
  818. DEFUN (ospf6_routemap_match_address_prefixlist,
  819. ospf6_routemap_match_address_prefixlist_cmd,
  820. "match ipv6 address prefix-list WORD",
  821. "Match values\n"
  822. IPV6_STR
  823. "Match address of route\n"
  824. "Match entries of prefix-lists\n"
  825. "IPv6 prefix-list name\n")
  826. {
  827. int ret = route_map_add_match ((struct route_map_index *) vty->index,
  828. "ipv6 address prefix-list", argv[0]);
  829. return route_map_command_status (vty, ret);
  830. }
  831. /* delete "match address" */
  832. DEFUN (ospf6_routemap_no_match_address_prefixlist,
  833. ospf6_routemap_no_match_address_prefixlist_cmd,
  834. "no match ipv6 address prefix-list WORD",
  835. NO_STR
  836. "Match values\n"
  837. IPV6_STR
  838. "Match address of route\n"
  839. "Match entries of prefix-lists\n"
  840. "IPv6 prefix-list name\n")
  841. {
  842. int ret = route_map_delete_match ((struct route_map_index *) vty->index,
  843. "ipv6 address prefix-list", argv[0]);
  844. return route_map_command_status (vty, ret);
  845. }
  846. /* add "set metric-type" */
  847. DEFUN (ospf6_routemap_set_metric_type,
  848. ospf6_routemap_set_metric_type_cmd,
  849. "set metric-type (type-1|type-2)",
  850. "Set value\n"
  851. "Type of metric\n"
  852. "OSPF6 external type 1 metric\n"
  853. "OSPF6 external type 2 metric\n")
  854. {
  855. int ret = route_map_add_set ((struct route_map_index *) vty->index,
  856. "metric-type", argv[0]);
  857. return route_map_command_status (vty, ret);
  858. }
  859. /* delete "set metric-type" */
  860. DEFUN (ospf6_routemap_no_set_metric_type,
  861. ospf6_routemap_no_set_metric_type_cmd,
  862. "no set metric-type (type-1|type-2)",
  863. NO_STR
  864. "Set value\n"
  865. "Type of metric\n"
  866. "OSPF6 external type 1 metric\n"
  867. "OSPF6 external type 2 metric\n")
  868. {
  869. int ret = route_map_delete_set ((struct route_map_index *) vty->index,
  870. "metric-type", argv[0]);
  871. return route_map_command_status (vty, ret);
  872. }
  873. /* add "set metric" */
  874. DEFUN (set_metric,
  875. set_metric_cmd,
  876. "set metric <0-4294967295>",
  877. "Set value\n"
  878. "Metric value\n"
  879. "Metric value\n")
  880. {
  881. int ret = route_map_add_set ((struct route_map_index *) vty->index,
  882. "metric", argv[0]);
  883. return route_map_command_status (vty, ret);
  884. }
  885. /* delete "set metric" */
  886. DEFUN (no_set_metric,
  887. no_set_metric_cmd,
  888. "no set metric <0-4294967295>",
  889. NO_STR
  890. "Set value\n"
  891. "Metric\n"
  892. "METRIC value\n")
  893. {
  894. int ret = route_map_delete_set ((struct route_map_index *) vty->index,
  895. "metric", argv[0]);
  896. return route_map_command_status (vty, ret);
  897. }
  898. /* add "set forwarding-address" */
  899. DEFUN (ospf6_routemap_set_forwarding,
  900. ospf6_routemap_set_forwarding_cmd,
  901. "set forwarding-address X:X::X:X",
  902. "Set value\n"
  903. "Forwarding Address\n"
  904. "IPv6 Address\n")
  905. {
  906. int ret = route_map_add_set ((struct route_map_index *) vty->index,
  907. "forwarding-address", argv[0]);
  908. return route_map_command_status (vty, ret);
  909. }
  910. /* delete "set forwarding-address" */
  911. DEFUN (ospf6_routemap_no_set_forwarding,
  912. ospf6_routemap_no_set_forwarding_cmd,
  913. "no set forwarding-address X:X::X:X",
  914. NO_STR
  915. "Set value\n"
  916. "Forwarding Address\n"
  917. "IPv6 Address\n")
  918. {
  919. int ret = route_map_delete_set ((struct route_map_index *) vty->index,
  920. "forwarding-address", argv[0]);
  921. return route_map_command_status (vty, ret);
  922. }
  923. static void
  924. ospf6_routemap_init (void)
  925. {
  926. route_map_init ();
  927. route_map_init_vty ();
  928. route_map_add_hook (ospf6_asbr_routemap_update);
  929. route_map_delete_hook (ospf6_asbr_routemap_update);
  930. route_map_install_match (&ospf6_routemap_rule_match_address_prefixlist_cmd);
  931. route_map_install_set (&ospf6_routemap_rule_set_metric_type_cmd);
  932. route_map_install_set (&ospf6_routemap_rule_set_metric_cmd);
  933. route_map_install_set (&ospf6_routemap_rule_set_forwarding_cmd);
  934. /* Match address prefix-list */
  935. install_element (RMAP_NODE, &ospf6_routemap_match_address_prefixlist_cmd);
  936. install_element (RMAP_NODE, &ospf6_routemap_no_match_address_prefixlist_cmd);
  937. /* ASE Metric Type (e.g. Type-1/Type-2) */
  938. install_element (RMAP_NODE, &ospf6_routemap_set_metric_type_cmd);
  939. install_element (RMAP_NODE, &ospf6_routemap_no_set_metric_type_cmd);
  940. /* ASE Metric */
  941. install_element (RMAP_NODE, &set_metric_cmd);
  942. install_element (RMAP_NODE, &no_set_metric_cmd);
  943. /* ASE Metric */
  944. install_element (RMAP_NODE, &ospf6_routemap_set_forwarding_cmd);
  945. install_element (RMAP_NODE, &ospf6_routemap_no_set_forwarding_cmd);
  946. }
  947. /* Display functions */
  948. static int
  949. ospf6_as_external_lsa_show (struct vty *vty, struct ospf6_lsa *lsa)
  950. {
  951. struct ospf6_as_external_lsa *external;
  952. char buf[64];
  953. struct in6_addr in6, *forwarding;
  954. assert (lsa->header);
  955. external = (struct ospf6_as_external_lsa *)
  956. OSPF6_LSA_HEADER_END (lsa->header);
  957. /* bits */
  958. snprintf (buf, sizeof (buf), "%c%c%c",
  959. (CHECK_FLAG (external->bits_metric, OSPF6_ASBR_BIT_E) ? 'E' : '-'),
  960. (CHECK_FLAG (external->bits_metric, OSPF6_ASBR_BIT_F) ? 'F' : '-'),
  961. (CHECK_FLAG (external->bits_metric, OSPF6_ASBR_BIT_T) ? 'T' : '-'));
  962. vty_out (vty, " Bits: %s%s", buf, VNL);
  963. vty_out (vty, " Metric: %5lu%s", (u_long) OSPF6_ASBR_METRIC (external),
  964. VNL);
  965. ospf6_prefix_options_printbuf (external->prefix.prefix_options,
  966. buf, sizeof (buf));
  967. vty_out (vty, " Prefix Options: %s%s", buf,
  968. VNL);
  969. vty_out (vty, " Referenced LSType: %d%s",
  970. ntohs (external->prefix.prefix_refer_lstype),
  971. VNL);
  972. ospf6_prefix_in6_addr (&in6, &external->prefix);
  973. inet_ntop (AF_INET6, &in6, buf, sizeof (buf));
  974. vty_out (vty, " Prefix: %s/%d%s", buf,
  975. external->prefix.prefix_length, VNL);
  976. /* Forwarding-Address */
  977. if (CHECK_FLAG (external->bits_metric, OSPF6_ASBR_BIT_F))
  978. {
  979. forwarding = (struct in6_addr *)
  980. ((caddr_t) external + sizeof (struct ospf6_as_external_lsa) +
  981. OSPF6_PREFIX_SPACE (external->prefix.prefix_length));
  982. inet_ntop (AF_INET6, forwarding, buf, sizeof (buf));
  983. vty_out (vty, " Forwarding-Address: %s%s", buf, VNL);
  984. }
  985. return 0;
  986. }
  987. static void
  988. ospf6_asbr_external_route_show (struct vty *vty, struct ospf6_route *route)
  989. {
  990. struct ospf6_external_info *info = route->route_option;
  991. char prefix[64], id[16], forwarding[64];
  992. u_int32_t tmp_id;
  993. prefix2str (&route->prefix, prefix, sizeof (prefix));
  994. tmp_id = ntohl (info->id);
  995. inet_ntop (AF_INET, &tmp_id, id, sizeof (id));
  996. if (! IN6_IS_ADDR_UNSPECIFIED (&info->forwarding))
  997. inet_ntop (AF_INET6, &info->forwarding, forwarding, sizeof (forwarding));
  998. else
  999. snprintf (forwarding, sizeof (forwarding), ":: (ifindex %d)",
  1000. route->nexthop[0].ifindex);
  1001. vty_out (vty, "%c %-32s %-15s type-%d %5lu %s%s",
  1002. zebra_route_char(info->type),
  1003. prefix, id, route->path.metric_type,
  1004. (u_long) (route->path.metric_type == 2 ?
  1005. route->path.cost_e2 : route->path.cost),
  1006. forwarding, VNL);
  1007. }
  1008. DEFUN (show_ipv6_ospf6_redistribute,
  1009. show_ipv6_ospf6_redistribute_cmd,
  1010. "show ipv6 ospf6 redistribute",
  1011. SHOW_STR
  1012. IP6_STR
  1013. OSPF6_STR
  1014. "redistributing External information\n"
  1015. )
  1016. {
  1017. struct ospf6_route *route;
  1018. ospf6_redistribute_show_config (vty);
  1019. for (route = ospf6_route_head (ospf6->external_table); route;
  1020. route = ospf6_route_next (route))
  1021. ospf6_asbr_external_route_show (vty, route);
  1022. return CMD_SUCCESS;
  1023. }
  1024. struct ospf6_lsa_handler as_external_handler =
  1025. {
  1026. OSPF6_LSTYPE_AS_EXTERNAL,
  1027. "AS-External",
  1028. ospf6_as_external_lsa_show
  1029. };
  1030. void
  1031. ospf6_asbr_init (void)
  1032. {
  1033. ospf6_routemap_init ();
  1034. ospf6_install_lsa_handler (&as_external_handler);
  1035. install_element (VIEW_NODE, &show_ipv6_ospf6_redistribute_cmd);
  1036. install_element (ENABLE_NODE, &show_ipv6_ospf6_redistribute_cmd);
  1037. install_element (OSPF6_NODE, &ospf6_redistribute_cmd);
  1038. install_element (OSPF6_NODE, &ospf6_redistribute_routemap_cmd);
  1039. install_element (OSPF6_NODE, &no_ospf6_redistribute_cmd);
  1040. }
  1041. DEFUN (debug_ospf6_asbr,
  1042. debug_ospf6_asbr_cmd,
  1043. "debug ospf6 asbr",
  1044. DEBUG_STR
  1045. OSPF6_STR
  1046. "Debug OSPFv3 ASBR function\n"
  1047. )
  1048. {
  1049. OSPF6_DEBUG_ASBR_ON ();
  1050. return CMD_SUCCESS;
  1051. }
  1052. DEFUN (no_debug_ospf6_asbr,
  1053. no_debug_ospf6_asbr_cmd,
  1054. "no debug ospf6 asbr",
  1055. NO_STR
  1056. DEBUG_STR
  1057. OSPF6_STR
  1058. "Debug OSPFv3 ASBR function\n"
  1059. )
  1060. {
  1061. OSPF6_DEBUG_ASBR_OFF ();
  1062. return CMD_SUCCESS;
  1063. }
  1064. int
  1065. config_write_ospf6_debug_asbr (struct vty *vty)
  1066. {
  1067. if (IS_OSPF6_DEBUG_ASBR)
  1068. vty_out (vty, "debug ospf6 asbr%s", VNL);
  1069. return 0;
  1070. }
  1071. void
  1072. install_element_ospf6_debug_asbr ()
  1073. {
  1074. install_element (ENABLE_NODE, &debug_ospf6_asbr_cmd);
  1075. install_element (ENABLE_NODE, &no_debug_ospf6_asbr_cmd);
  1076. install_element (CONFIG_NODE, &debug_ospf6_asbr_cmd);
  1077. install_element (CONFIG_NODE, &no_debug_ospf6_asbr_cmd);
  1078. }