ospf6_snmp.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. /* OSPFv3 SNMP support
  2. * Copyright (C) 2004 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. #ifdef HAVE_SNMP
  23. #ifdef HAVE_NETSNMP
  24. #include <net-snmp/net-snmp-config.h>
  25. #endif /*HAVE_NETSNMP*/
  26. #include <asn1.h>
  27. #include <snmp.h>
  28. #include <snmp_impl.h>
  29. #include "log.h"
  30. #include "vty.h"
  31. #include "linklist.h"
  32. #include "smux.h"
  33. #include "ospf6_proto.h"
  34. #include "ospf6_lsa.h"
  35. #include "ospf6_lsdb.h"
  36. #include "ospf6_route.h"
  37. #include "ospf6_top.h"
  38. #include "ospf6_area.h"
  39. #include "ospf6_interface.h"
  40. #include "ospf6_message.h"
  41. #include "ospf6_neighbor.h"
  42. #include "ospf6d.h"
  43. /* OSPFv3-MIB */
  44. #define OSPFv3MIB 1,3,6,1,3,102
  45. /* OSPFv3 MIB General Group values. */
  46. #define OSPFv3ROUTERID 1
  47. #define OSPFv3ADMINSTAT 2
  48. #define OSPFv3VERSIONNUMBER 3
  49. #define OSPFv3AREABDRRTRSTATUS 4
  50. #define OSPFv3ASBDRRTRSTATUS 5
  51. #define OSPFv3ASSCOPELSACOUNT 6
  52. #define OSPFv3ASSCOPELSACHECKSUMSUM 7
  53. #define OSPFv3ORIGINATENEWLSAS 8
  54. #define OSPFv3RXNEWLSAS 9
  55. #define OSPFv3EXTLSACOUNT 10
  56. #define OSPFv3EXTAREALSDBLIMIT 11
  57. #define OSPFv3MULTICASTEXTENSIONS 12
  58. #define OSPFv3EXITOVERFLOWINTERVAL 13
  59. #define OSPFv3DEMANDEXTENSIONS 14
  60. #define OSPFv3TRAFFICENGINEERINGSUPPORT 15
  61. #define OSPFv3REFERENCEBANDWIDTH 16
  62. #define OSPFv3RESTARTSUPPORT 17
  63. #define OSPFv3RESTARTINTERVAL 18
  64. #define OSPFv3RESTARTSTATUS 19
  65. #define OSPFv3RESTARTAGE 20
  66. #define OSPFv3RESTARTEXITREASON 21
  67. /* OSPFv3 MIB Area Table values. */
  68. #define OSPFv3AREAID 1
  69. #define OSPFv3IMPORTASEXTERN 2
  70. #define OSPFv3AREASPFRUNS 3
  71. #define OSPFv3AREABDRRTRCOUNT 4
  72. #define OSPFv3AREAASBDRRTRCOUNT 5
  73. #define OSPFv3AREASCOPELSACOUNT 6
  74. #define OSPFv3AREASCOPELSACKSUMSUM 7
  75. #define OSPFv3AREASUMMARY 8
  76. #define OSPFv3AREASTATUS 9
  77. #define OSPFv3STUBMETRIC 10
  78. #define OSPFv3AREANSSATRANSLATORROLE 11
  79. #define OSPFv3AREANSSATRANSLATORSTATE 12
  80. #define OSPFv3AREANSSATRANSLATORSTABILITYINTERVAL 13
  81. #define OSPFv3AREANSSATRANSLATOREVENTS 14
  82. #define OSPFv3AREASTUBMETRICTYPE 15
  83. /* OSPFv3 MIB Area Lsdb Table values. */
  84. #define OSPFv3AREALSDBAREAID 1
  85. #define OSPFv3AREALSDBTYPE 2
  86. #define OSPFv3AREALSDBROUTERID 3
  87. #define OSPFv3AREALSDBLSID 4
  88. #define OSPFv3AREALSDBSEQUENCE 5
  89. #define OSPFv3AREALSDBAGE 6
  90. #define OSPFv3AREALSDBCHECKSUM 7
  91. #define OSPFv3AREALSDBADVERTISEMENT 8
  92. #define OSPFv3AREALSDBTYPEKNOWN 9
  93. /* SYNTAX Status from OSPF-MIB. */
  94. #define OSPF_STATUS_ENABLED 1
  95. #define OSPF_STATUS_DISABLED 2
  96. /* SNMP value hack. */
  97. #define COUNTER ASN_COUNTER
  98. #define INTEGER ASN_INTEGER
  99. #define GAUGE ASN_GAUGE
  100. #define TIMETICKS ASN_TIMETICKS
  101. #define IPADDRESS ASN_IPADDRESS
  102. #define STRING ASN_OCTET_STR
  103. /* For return values e.g. SNMP_INTEGER macro */
  104. SNMP_LOCAL_VARIABLES
  105. static struct in_addr tmp;
  106. #define INT32_INADDR(x) \
  107. (tmp.s_addr = (x), tmp)
  108. /* OSPFv3-MIB instances. */
  109. oid ospfv3_oid [] = { OSPFv3MIB };
  110. /* empty ID 0.0.0.0 e.g. empty router-id */
  111. static struct in_addr ospf6_empty_id = {0};
  112. /* Hook functions. */
  113. static u_char *ospfv3GeneralGroup ();
  114. static u_char *ospfv3AreaEntry ();
  115. static u_char *ospfv3AreaLsdbEntry ();
  116. struct variable ospfv3_variables[] =
  117. {
  118. /* OSPF general variables */
  119. {OSPFv3ROUTERID, IPADDRESS, RWRITE, ospfv3GeneralGroup,
  120. 3, {1, 1, 1}},
  121. {OSPFv3ADMINSTAT, INTEGER, RWRITE, ospfv3GeneralGroup,
  122. 3, {1, 1, 2}},
  123. {OSPFv3VERSIONNUMBER, INTEGER, RONLY, ospfv3GeneralGroup,
  124. 3, {1, 1, 3}},
  125. {OSPFv3AREABDRRTRSTATUS, INTEGER, RONLY, ospfv3GeneralGroup,
  126. 3, {1, 1, 4}},
  127. {OSPFv3ASBDRRTRSTATUS, INTEGER, RWRITE, ospfv3GeneralGroup,
  128. 3, {1, 1, 5}},
  129. {OSPFv3ASSCOPELSACOUNT, GAUGE, RONLY, ospfv3GeneralGroup,
  130. 3, {1, 1, 6}},
  131. {OSPFv3ASSCOPELSACHECKSUMSUM, INTEGER, RONLY, ospfv3GeneralGroup,
  132. 3, {1, 1, 7}},
  133. {OSPFv3ORIGINATENEWLSAS, COUNTER, RONLY, ospfv3GeneralGroup,
  134. 3, {1, 1, 8}},
  135. {OSPFv3RXNEWLSAS, COUNTER, RONLY, ospfv3GeneralGroup,
  136. 3, {1, 1, 9}},
  137. {OSPFv3EXTLSACOUNT, GAUGE, RONLY, ospfv3GeneralGroup,
  138. 3, {1, 1, 10}},
  139. {OSPFv3EXTAREALSDBLIMIT, INTEGER, RWRITE, ospfv3GeneralGroup,
  140. 3, {1, 1, 11}},
  141. {OSPFv3MULTICASTEXTENSIONS, INTEGER, RWRITE, ospfv3GeneralGroup,
  142. 3, {1, 1, 12}},
  143. {OSPFv3EXITOVERFLOWINTERVAL, INTEGER, RWRITE, ospfv3GeneralGroup,
  144. 3, {1, 1, 13}},
  145. {OSPFv3DEMANDEXTENSIONS, INTEGER, RWRITE, ospfv3GeneralGroup,
  146. 3, {1, 1, 14}},
  147. {OSPFv3TRAFFICENGINEERINGSUPPORT, INTEGER, RWRITE, ospfv3GeneralGroup,
  148. 3, {1, 1, 15}},
  149. {OSPFv3REFERENCEBANDWIDTH, INTEGER, RWRITE, ospfv3GeneralGroup,
  150. 3, {1, 1, 16}},
  151. {OSPFv3RESTARTSUPPORT, INTEGER, RWRITE, ospfv3GeneralGroup,
  152. 3, {1, 1, 17}},
  153. {OSPFv3RESTARTINTERVAL, INTEGER, RWRITE, ospfv3GeneralGroup,
  154. 3, {1, 1, 18}},
  155. {OSPFv3RESTARTSTATUS, INTEGER, RONLY, ospfv3GeneralGroup,
  156. 3, {1, 1, 19}},
  157. {OSPFv3RESTARTAGE, INTEGER, RONLY, ospfv3GeneralGroup,
  158. 3, {1, 1, 20}},
  159. {OSPFv3RESTARTEXITREASON, INTEGER, RONLY, ospfv3GeneralGroup,
  160. 3, {1, 1, 21}},
  161. /* OSPFv3 Area Data Structure */
  162. {OSPFv3AREAID, IPADDRESS, RONLY, ospfv3AreaEntry,
  163. 4, {1, 2, 1, 1}},
  164. {OSPFv3IMPORTASEXTERN, INTEGER, RWRITE, ospfv3AreaEntry,
  165. 4, {1, 2, 1, 2}},
  166. {OSPFv3AREASPFRUNS, COUNTER, RONLY, ospfv3AreaEntry,
  167. 4, {1, 2, 1, 3}},
  168. {OSPFv3AREABDRRTRCOUNT, GAUGE, RONLY, ospfv3AreaEntry,
  169. 4, {1, 2, 1, 4}},
  170. {OSPFv3AREAASBDRRTRCOUNT, GAUGE, RONLY, ospfv3AreaEntry,
  171. 4, {1, 2, 1, 5}},
  172. {OSPFv3AREASCOPELSACOUNT, GAUGE, RONLY, ospfv3AreaEntry,
  173. 4, {1, 2, 1, 6}},
  174. {OSPFv3AREASCOPELSACKSUMSUM, INTEGER, RONLY, ospfv3AreaEntry,
  175. 4, {1, 2, 1, 7}},
  176. {OSPFv3AREASUMMARY, INTEGER, RWRITE, ospfv3AreaEntry,
  177. 4, {1, 2, 1, 8}},
  178. {OSPFv3AREASTATUS, INTEGER, RWRITE, ospfv3AreaEntry,
  179. 4, {1, 2, 1, 9}},
  180. {OSPFv3STUBMETRIC, INTEGER, RWRITE, ospfv3AreaEntry,
  181. 4, {1, 2, 1, 10}},
  182. {OSPFv3AREANSSATRANSLATORROLE, INTEGER, RWRITE, ospfv3AreaEntry,
  183. 4, {1, 2, 1, 11}},
  184. {OSPFv3AREANSSATRANSLATORSTATE, INTEGER, RONLY, ospfv3AreaEntry,
  185. 4, {1, 2, 1, 12}},
  186. {OSPFv3AREANSSATRANSLATORSTABILITYINTERVAL, INTEGER, RWRITE, ospfv3AreaEntry,
  187. 4, {1, 2, 1, 13}},
  188. {OSPFv3AREANSSATRANSLATOREVENTS, COUNTER, RONLY, ospfv3AreaEntry,
  189. 4, {1, 2, 1, 14}},
  190. {OSPFv3AREASTUBMETRICTYPE, INTEGER, RWRITE, ospfv3AreaEntry,
  191. 4, {1, 2, 1, 15}},
  192. {OSPFv3AREALSDBAREAID, IPADDRESS, RONLY, ospfv3AreaLsdbEntry,
  193. 4, {1, 4, 1, 1}},
  194. {OSPFv3AREALSDBTYPE, GAUGE, RONLY, ospfv3AreaLsdbEntry,
  195. 4, {1, 4, 1, 2}},
  196. {OSPFv3AREALSDBROUTERID, IPADDRESS, RONLY, ospfv3AreaLsdbEntry,
  197. 4, {1, 4, 1, 3}},
  198. {OSPFv3AREALSDBLSID, IPADDRESS, RONLY, ospfv3AreaLsdbEntry,
  199. 4, {1, 4, 1, 4}},
  200. {OSPFv3AREALSDBSEQUENCE, INTEGER, RONLY, ospfv3AreaLsdbEntry,
  201. 4, {1, 4, 1, 5}},
  202. {OSPFv3AREALSDBAGE, INTEGER, RONLY, ospfv3AreaLsdbEntry,
  203. 4, {1, 4, 1, 6}},
  204. {OSPFv3AREALSDBCHECKSUM, INTEGER, RONLY, ospfv3AreaLsdbEntry,
  205. 4, {1, 4, 1, 7}},
  206. {OSPFv3AREALSDBADVERTISEMENT, STRING, RONLY, ospfv3AreaLsdbEntry,
  207. 4, {1, 4, 1, 8}},
  208. {OSPFv3AREALSDBTYPEKNOWN, INTEGER, RONLY, ospfv3AreaLsdbEntry,
  209. 4, {1, 4, 1, 9}},
  210. };
  211. static u_char *
  212. ospfv3GeneralGroup (struct variable *v, oid *name, size_t *length,
  213. int exact, size_t *var_len, WriteMethod **write_method)
  214. {
  215. /* Check whether the instance identifier is valid */
  216. if (smux_header_generic (v, name, length, exact, var_len, write_method)
  217. == MATCH_FAILED)
  218. return NULL;
  219. /* Return the current value of the variable */
  220. switch (v->magic)
  221. {
  222. case OSPFv3ROUTERID: /* 1*/
  223. /* Router-ID of this OSPF instance. */
  224. if (ospf6)
  225. return SNMP_IPADDRESS (INT32_INADDR (ospf6->router_id));
  226. else
  227. return SNMP_IPADDRESS (ospf6_empty_id);
  228. break;
  229. case OSPFv3ADMINSTAT: /* 2*/
  230. break;
  231. case OSPFv3VERSIONNUMBER: /* 3*/
  232. break;
  233. case OSPFv3AREABDRRTRSTATUS: /* 4*/
  234. break;
  235. case OSPFv3ASBDRRTRSTATUS: /* 5*/
  236. break;
  237. case OSPFv3ASSCOPELSACOUNT: /* 6*/
  238. break;
  239. case OSPFv3ASSCOPELSACHECKSUMSUM: /* 7*/
  240. break;
  241. case OSPFv3ORIGINATENEWLSAS: /* 8*/
  242. break;
  243. case OSPFv3RXNEWLSAS: /* 9*/
  244. break;
  245. case OSPFv3EXTLSACOUNT: /*10*/
  246. break;
  247. case OSPFv3EXTAREALSDBLIMIT: /*11*/
  248. break;
  249. case OSPFv3MULTICASTEXTENSIONS: /*12*/
  250. break;
  251. case OSPFv3EXITOVERFLOWINTERVAL: /*13*/
  252. break;
  253. case OSPFv3DEMANDEXTENSIONS: /*14*/
  254. break;
  255. case OSPFv3TRAFFICENGINEERINGSUPPORT: /*15*/
  256. break;
  257. case OSPFv3REFERENCEBANDWIDTH: /*16*/
  258. break;
  259. case OSPFv3RESTARTSUPPORT: /*17*/
  260. break;
  261. case OSPFv3RESTARTINTERVAL: /*18*/
  262. break;
  263. case OSPFv3RESTARTSTATUS: /*19*/
  264. break;
  265. case OSPFv3RESTARTAGE: /*20*/
  266. break;
  267. case OSPFv3RESTARTEXITREASON: /*21*/
  268. break;
  269. default:
  270. return NULL;
  271. }
  272. return NULL;
  273. }
  274. static u_char *
  275. ospfv3AreaEntry (struct variable *v, oid *name, size_t *length,
  276. int exact, size_t *var_len, WriteMethod **write_method)
  277. {
  278. struct ospf6_area *oa, *area = NULL;
  279. u_int32_t area_id = 0;
  280. struct listnode *node;
  281. unsigned int len;
  282. if (ospf6 == NULL)
  283. return NULL;
  284. len = *length - v->namelen;
  285. len = (len >= sizeof (u_int32_t) ? sizeof (u_int32_t) : 0);
  286. if (exact && len != sizeof (u_int32_t))
  287. return NULL;
  288. if (len)
  289. oid2in_addr (name + v->namelen, len, (struct in_addr *) &area_id);
  290. zlog_info ("SNMP access by area: %s, exact=%d len=%d length=%d",
  291. inet_ntoa (* (struct in_addr *) &area_id),
  292. exact, len, *length);
  293. for (node = listhead (ospf6->area_list); node; nextnode (node))
  294. {
  295. oa = (struct ospf6_area *) getdata (node);
  296. if (area == NULL)
  297. {
  298. if (len == 0) /* return first area entry */
  299. area = oa;
  300. else if (exact && ntohl (oa->area_id) == ntohl (area_id))
  301. area = oa;
  302. else if (ntohl (oa->area_id) > ntohl (area_id))
  303. area = oa;
  304. }
  305. }
  306. if (area == NULL)
  307. return NULL;
  308. *length = v->namelen + sizeof (u_int32_t);
  309. oid_copy_addr (name + v->namelen, (struct in_addr *) &area->area_id,
  310. sizeof (u_int32_t));
  311. zlog_info ("SNMP found area: %s, exact=%d len=%d length=%d",
  312. inet_ntoa (* (struct in_addr *) &area->area_id),
  313. exact, len, *length);
  314. switch (v->magic)
  315. {
  316. case OSPFv3AREAID: /* 1*/
  317. return SNMP_IPADDRESS (INT32_INADDR (area->area_id));
  318. break;
  319. case OSPFv3IMPORTASEXTERN: /* 2*/
  320. return SNMP_INTEGER (ospf6->external_table->count);
  321. break;
  322. default:
  323. return NULL;
  324. break;
  325. }
  326. return NULL;
  327. }
  328. static u_char *
  329. ospfv3AreaLsdbEntry (struct variable *v, oid *name, size_t *length,
  330. int exact, size_t *var_len, WriteMethod **write_method)
  331. {
  332. struct ospf6_lsa *lsa = NULL;
  333. struct in_addr area_id;
  334. u_int16_t type;
  335. struct in_addr id;
  336. struct in_addr adv_router;
  337. int len;
  338. oid *offset;
  339. int offsetlen;
  340. char a[16], b[16], c[16];
  341. struct ospf6_area *oa;
  342. listnode node;
  343. memset (&area_id, 0, sizeof (struct in_addr));
  344. type = 0;
  345. memset (&id, 0, sizeof (struct in_addr));
  346. memset (&adv_router, 0, sizeof (struct in_addr));
  347. /* Check OSPFv3 instance. */
  348. if (ospf6 == NULL)
  349. return NULL;
  350. /* Get variable length. */
  351. offset = name + v->namelen;
  352. offsetlen = *length - v->namelen;
  353. #define OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET \
  354. (IN_ADDR_SIZE + 1 + IN_ADDR_SIZE + IN_ADDR_SIZE)
  355. if (exact && offsetlen != OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET)
  356. return NULL;
  357. /* Parse area-id */
  358. len = (offsetlen < IN_ADDR_SIZE ? offsetlen : IN_ADDR_SIZE);
  359. if (len)
  360. oid2in_addr (offset, len, &area_id);
  361. offset += len;
  362. offsetlen -= len;
  363. /* Parse type */
  364. len = (offsetlen < 1 ? offsetlen : 1);
  365. if (len)
  366. type = htons (*offset);
  367. offset += len;
  368. offsetlen -= len;
  369. /* Parse Router-ID */
  370. len = (offsetlen < IN_ADDR_SIZE ? offsetlen : IN_ADDR_SIZE);
  371. if (len)
  372. oid2in_addr (offset, len, &adv_router);
  373. offset += len;
  374. offsetlen -= len;
  375. /* Parse LS-ID */
  376. len = (offsetlen < IN_ADDR_SIZE ? offsetlen : IN_ADDR_SIZE);
  377. if (len)
  378. oid2in_addr (offset, len, &id);
  379. offset += len;
  380. offsetlen -= len;
  381. inet_ntop (AF_INET, &area_id, a, sizeof (a));
  382. inet_ntop (AF_INET, &adv_router, b, sizeof (b));
  383. inet_ntop (AF_INET, &id, c, sizeof (c));
  384. zlog_info ("SNMP access by lsdb: area=%s exact=%d length=%d magic=%d"
  385. " type=%#x adv_router=%s id=%s",
  386. a, exact, *length, v->magic, ntohs (type), b, c);
  387. if (exact)
  388. {
  389. oa = ospf6_area_lookup (area_id.s_addr, ospf6);
  390. lsa = ospf6_lsdb_lookup (type, id.s_addr, adv_router.s_addr, oa->lsdb);
  391. }
  392. else
  393. {
  394. for (node = listhead (ospf6->area_list); node; nextnode (node))
  395. {
  396. oa = (struct ospf6_area *) getdata (node);
  397. if (lsa)
  398. continue;
  399. if (ntohl (oa->area_id) < ntohl (area_id.s_addr))
  400. continue;
  401. lsa = ospf6_lsdb_lookup_next (type, id.s_addr, adv_router.s_addr,
  402. oa->lsdb);
  403. if (! lsa)
  404. {
  405. type = 0;
  406. memset (&id, 0, sizeof (struct in_addr));
  407. memset (&adv_router, 0, sizeof (struct in_addr));
  408. }
  409. }
  410. }
  411. if (! lsa)
  412. {
  413. zlog_info ("SNMP respond: No LSA to return");
  414. return NULL;
  415. }
  416. oa = OSPF6_AREA (lsa->lsdb->data);
  417. zlog_info ("SNMP respond: area: %s lsa: %s", oa->name, lsa->name);
  418. /* Add Index (AreaId, Type, RouterId, Lsid) */
  419. *length = v->namelen + OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET;
  420. offset = name + v->namelen;
  421. oid_copy_addr (offset, (struct in_addr *) &oa->area_id, IN_ADDR_SIZE);
  422. offset += IN_ADDR_SIZE;
  423. *offset = ntohs (lsa->header->type);
  424. offset++;
  425. oid_copy_addr (offset, (struct in_addr *) &lsa->header->adv_router,
  426. IN_ADDR_SIZE);
  427. offset += IN_ADDR_SIZE;
  428. oid_copy_addr (offset, (struct in_addr *) &lsa->header->id, IN_ADDR_SIZE);
  429. offset += IN_ADDR_SIZE;
  430. /* Return the current value of the variable */
  431. switch (v->magic)
  432. {
  433. case OSPFv3AREALSDBAREAID: /* 1 */
  434. area_id.s_addr = OSPF6_AREA (lsa->lsdb->data)->area_id;
  435. return SNMP_IPADDRESS (area_id);
  436. break;
  437. case OSPFv3AREALSDBTYPE: /* 2 */
  438. return SNMP_INTEGER (ntohs (lsa->header->type));
  439. break;
  440. case OSPFv3AREALSDBROUTERID: /* 3 */
  441. adv_router.s_addr = lsa->header->adv_router;
  442. return SNMP_IPADDRESS (adv_router);
  443. break;
  444. case OSPFv3AREALSDBLSID: /* 4 */
  445. id.s_addr = lsa->header->id;
  446. return SNMP_IPADDRESS (id);
  447. break;
  448. case OSPFv3AREALSDBSEQUENCE: /* 5 */
  449. return SNMP_INTEGER (lsa->header->seqnum);
  450. break;
  451. case OSPFv3AREALSDBAGE: /* 6 */
  452. ospf6_lsa_age_current (lsa);
  453. return SNMP_INTEGER (lsa->header->age);
  454. break;
  455. case OSPFv3AREALSDBCHECKSUM: /* 7 */
  456. return SNMP_INTEGER (lsa->header->checksum);
  457. break;
  458. case OSPFv3AREALSDBADVERTISEMENT: /* 8 */
  459. *var_len = ntohs (lsa->header->length);
  460. return (u_char *) lsa->header;
  461. break;
  462. case OSPFv3AREALSDBTYPEKNOWN: /* 9 */
  463. return SNMP_INTEGER (OSPF6_LSA_IS_KNOWN (lsa->header->type) ?
  464. SNMP_TRUE : SNMP_FALSE);
  465. break;
  466. default:
  467. return NULL;
  468. break;
  469. }
  470. return NULL;
  471. }
  472. /* Register OSPFv3-MIB. */
  473. void
  474. ospf6_snmp_init (struct thread_master *master)
  475. {
  476. smux_init (master);
  477. REGISTER_MIB ("OSPFv3MIB", ospfv3_variables, variable, ospfv3_oid);
  478. }
  479. #endif /* HAVE_SNMP */