ospf6_snmp.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  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. #include <net-snmp/net-snmp-config.h>
  24. #include <net-snmp/net-snmp-includes.h>
  25. #include "log.h"
  26. #include "vty.h"
  27. #include "linklist.h"
  28. #include "smux.h"
  29. #include "ospf6_proto.h"
  30. #include "ospf6_lsa.h"
  31. #include "ospf6_lsdb.h"
  32. #include "ospf6_route.h"
  33. #include "ospf6_top.h"
  34. #include "ospf6_area.h"
  35. #include "ospf6_interface.h"
  36. #include "ospf6_message.h"
  37. #include "ospf6_neighbor.h"
  38. #include "ospf6d.h"
  39. #include "ospf6_snmp.h"
  40. /* OSPFv3-MIB */
  41. #define OSPFv3MIB 1,3,6,1,3,102
  42. /* OSPFv3 MIB General Group values. */
  43. #define OSPFv3ROUTERID 1
  44. #define OSPFv3ADMINSTAT 2
  45. #define OSPFv3VERSIONNUMBER 3
  46. #define OSPFv3AREABDRRTRSTATUS 4
  47. #define OSPFv3ASBDRRTRSTATUS 5
  48. #define OSPFv3ASSCOPELSACOUNT 6
  49. #define OSPFv3ASSCOPELSACHECKSUMSUM 7
  50. #define OSPFv3ORIGINATENEWLSAS 8
  51. #define OSPFv3RXNEWLSAS 9
  52. #define OSPFv3EXTLSACOUNT 10
  53. #define OSPFv3EXTAREALSDBLIMIT 11
  54. #define OSPFv3MULTICASTEXTENSIONS 12
  55. #define OSPFv3EXITOVERFLOWINTERVAL 13
  56. #define OSPFv3DEMANDEXTENSIONS 14
  57. #define OSPFv3TRAFFICENGINEERINGSUPPORT 15
  58. #define OSPFv3REFERENCEBANDWIDTH 16
  59. #define OSPFv3RESTARTSUPPORT 17
  60. #define OSPFv3RESTARTINTERVAL 18
  61. #define OSPFv3RESTARTSTATUS 19
  62. #define OSPFv3RESTARTAGE 20
  63. #define OSPFv3RESTARTEXITREASON 21
  64. /* OSPFv3 MIB Area Table values. */
  65. #define OSPFv3AREAID 1
  66. #define OSPFv3IMPORTASEXTERN 2
  67. #define OSPFv3AREASPFRUNS 3
  68. #define OSPFv3AREABDRRTRCOUNT 4
  69. #define OSPFv3AREAASBDRRTRCOUNT 5
  70. #define OSPFv3AREASCOPELSACOUNT 6
  71. #define OSPFv3AREASCOPELSACKSUMSUM 7
  72. #define OSPFv3AREASUMMARY 8
  73. #define OSPFv3AREASTATUS 9
  74. #define OSPFv3STUBMETRIC 10
  75. #define OSPFv3AREANSSATRANSLATORROLE 11
  76. #define OSPFv3AREANSSATRANSLATORSTATE 12
  77. #define OSPFv3AREANSSATRANSLATORSTABILITYINTERVAL 13
  78. #define OSPFv3AREANSSATRANSLATOREVENTS 14
  79. #define OSPFv3AREASTUBMETRICTYPE 15
  80. /* OSPFv3 MIB Area Lsdb Table values. */
  81. #define OSPFv3AREALSDBAREAID 1
  82. #define OSPFv3AREALSDBTYPE 2
  83. #define OSPFv3AREALSDBROUTERID 3
  84. #define OSPFv3AREALSDBLSID 4
  85. #define OSPFv3AREALSDBSEQUENCE 5
  86. #define OSPFv3AREALSDBAGE 6
  87. #define OSPFv3AREALSDBCHECKSUM 7
  88. #define OSPFv3AREALSDBADVERTISEMENT 8
  89. #define OSPFv3AREALSDBTYPEKNOWN 9
  90. /* SYNTAX Status from OSPF-MIB. */
  91. #define OSPF_STATUS_ENABLED 1
  92. #define OSPF_STATUS_DISABLED 2
  93. /* SNMP value hack. */
  94. #define COUNTER ASN_COUNTER
  95. #define INTEGER ASN_INTEGER
  96. #define GAUGE ASN_GAUGE
  97. #define TIMETICKS ASN_TIMETICKS
  98. #define IPADDRESS ASN_IPADDRESS
  99. #define STRING ASN_OCTET_STR
  100. /* For return values e.g. SNMP_INTEGER macro */
  101. SNMP_LOCAL_VARIABLES
  102. static struct in_addr tmp;
  103. #define INT32_INADDR(x) \
  104. (tmp.s_addr = (x), tmp)
  105. /* OSPFv3-MIB instances. */
  106. oid ospfv3_oid [] = { OSPFv3MIB };
  107. /* empty ID 0.0.0.0 e.g. empty router-id */
  108. static struct in_addr ospf6_empty_id = {0};
  109. /* Hook functions. */
  110. static u_char *ospfv3GeneralGroup (struct variable *, oid *, size_t *,
  111. int, size_t *, WriteMethod **);
  112. static u_char *ospfv3AreaEntry (struct variable *, oid *, size_t *,
  113. int, size_t *, WriteMethod **);
  114. static u_char *ospfv3AreaLsdbEntry (struct variable *, oid *, size_t *,
  115. int, size_t *, WriteMethod **);
  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. if (smux_header_table(v, name, length, exact, var_len, write_method)
  285. == MATCH_FAILED)
  286. return NULL;
  287. len = *length - v->namelen;
  288. len = (len >= sizeof (u_int32_t) ? sizeof (u_int32_t) : 0);
  289. if (exact && len != sizeof (u_int32_t))
  290. return NULL;
  291. if (len)
  292. oid2in_addr (name + v->namelen, len, (struct in_addr *) &area_id);
  293. zlog_debug ("SNMP access by area: %s, exact=%d len=%d length=%lu",
  294. inet_ntoa (* (struct in_addr *) &area_id),
  295. exact, len, (u_long)*length);
  296. for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
  297. {
  298. if (area == NULL)
  299. {
  300. if (len == 0) /* return first area entry */
  301. area = oa;
  302. else if (exact && ntohl (oa->area_id) == ntohl (area_id))
  303. area = oa;
  304. else if (ntohl (oa->area_id) > ntohl (area_id))
  305. area = oa;
  306. }
  307. }
  308. if (area == NULL)
  309. return NULL;
  310. *length = v->namelen + sizeof (u_int32_t);
  311. oid_copy_addr (name + v->namelen, (struct in_addr *) &area->area_id,
  312. sizeof (u_int32_t));
  313. zlog_debug ("SNMP found area: %s, exact=%d len=%d length=%lu",
  314. inet_ntoa (* (struct in_addr *) &area->area_id),
  315. exact, len, (u_long)*length);
  316. switch (v->magic)
  317. {
  318. case OSPFv3AREAID: /* 1*/
  319. return SNMP_IPADDRESS (INT32_INADDR (area->area_id));
  320. break;
  321. case OSPFv3IMPORTASEXTERN: /* 2*/
  322. return SNMP_INTEGER (ospf6->external_table->count);
  323. break;
  324. default:
  325. return NULL;
  326. break;
  327. }
  328. return NULL;
  329. }
  330. static u_char *
  331. ospfv3AreaLsdbEntry (struct variable *v, oid *name, size_t *length,
  332. int exact, size_t *var_len, WriteMethod **write_method)
  333. {
  334. struct ospf6_lsa *lsa = NULL;
  335. struct in_addr area_id;
  336. u_int16_t type;
  337. struct in_addr id;
  338. struct in_addr adv_router;
  339. int len;
  340. oid *offset;
  341. int offsetlen;
  342. char a[16], b[16], c[16];
  343. struct ospf6_area *oa;
  344. struct listnode *node;
  345. if (smux_header_table(v, name, length, exact, var_len, write_method)
  346. == MATCH_FAILED)
  347. return NULL;
  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 */