ospf6_snmp.c 17 KB

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