/contrib/bsnmp/snmpd/snmpmod.h

https://bitbucket.org/freebsd/freebsd-head/ · C Header · 625 lines · 390 code · 91 blank · 144 comment · 29 complexity · 6abc37c64b8cad431f2e438549ecd063 MD5 · raw file

  1. /*
  2. * Copyright (c) 2001-2003
  3. * Fraunhofer Institute for Open Communication Systems (FhG Fokus).
  4. * All rights reserved.
  5. *
  6. * Author: Harti Brandt <harti@freebsd.org>
  7. *
  8. * Copyright (c) 2010 The FreeBSD Foundation
  9. * All rights reserved.
  10. *
  11. * Portions of this software were developed by Shteryana Sotirova Shopova
  12. * under sponsorship from the FreeBSD Foundation.
  13. *
  14. * Redistribution and use in source and binary forms, with or without
  15. * modification, are permitted provided that the following conditions
  16. * are met:
  17. * 1. Redistributions of source code must retain the above copyright
  18. * notice, this list of conditions and the following disclaimer.
  19. * 2. Redistributions in binary form must reproduce the above copyright
  20. * notice, this list of conditions and the following disclaimer in the
  21. * documentation and/or other materials provided with the distribution.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  24. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26. * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
  27. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  28. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  29. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  30. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  31. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  32. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  33. * SUCH DAMAGE.
  34. *
  35. * $Begemot: bsnmp/snmpd/snmpmod.h,v 1.32 2006/02/14 09:04:20 brandt_h Exp $
  36. *
  37. * SNMP daemon data and functions exported to modules.
  38. */
  39. #ifndef snmpmod_h_
  40. #define snmpmod_h_
  41. #include <sys/types.h>
  42. #include <sys/queue.h>
  43. #include <sys/socket.h>
  44. #include <net/if.h>
  45. #include <netinet/in.h>
  46. #include "asn1.h"
  47. #include "snmp.h"
  48. #include "snmpagent.h"
  49. #define MAX_MOD_ARGS 16
  50. /*
  51. * These macros help to handle object lists for SNMP tables. They use
  52. * tail queues to hold the objects in ascending order in the list.
  53. * ordering can be done either on an integer/unsigned field, an asn_oid
  54. * or an ordering function.
  55. */
  56. #define INSERT_OBJECT_OID_LINK_INDEX(PTR, LIST, LINK, INDEX) do { \
  57. __typeof (PTR) _lelem; \
  58. \
  59. TAILQ_FOREACH(_lelem, (LIST), LINK) \
  60. if (asn_compare_oid(&_lelem->INDEX, &(PTR)->INDEX) > 0) \
  61. break; \
  62. if (_lelem == NULL) \
  63. TAILQ_INSERT_TAIL((LIST), (PTR), LINK); \
  64. else \
  65. TAILQ_INSERT_BEFORE(_lelem, (PTR), LINK); \
  66. } while (0)
  67. #define INSERT_OBJECT_INT_LINK_INDEX(PTR, LIST, LINK, INDEX) do { \
  68. __typeof (PTR) _lelem; \
  69. \
  70. TAILQ_FOREACH(_lelem, (LIST), LINK) \
  71. if ((asn_subid_t)_lelem->INDEX > (asn_subid_t)(PTR)->INDEX)\
  72. break; \
  73. if (_lelem == NULL) \
  74. TAILQ_INSERT_TAIL((LIST), (PTR), LINK); \
  75. else \
  76. TAILQ_INSERT_BEFORE(_lelem, (PTR), LINK); \
  77. } while (0)
  78. #define INSERT_OBJECT_FUNC_LINK(PTR, LIST, LINK, FUNC) do { \
  79. __typeof (PTR) _lelem; \
  80. \
  81. TAILQ_FOREACH(_lelem, (LIST), LINK) \
  82. if ((FUNC)(_lelem, (PTR)) > 0) \
  83. break; \
  84. if (_lelem == NULL) \
  85. TAILQ_INSERT_TAIL((LIST), (PTR), LINK); \
  86. else \
  87. TAILQ_INSERT_BEFORE(_lelem, (PTR), LINK); \
  88. } while (0)
  89. #define INSERT_OBJECT_FUNC_LINK_REV(PTR, LIST, HEAD, LINK, FUNC) do { \
  90. __typeof (PTR) _lelem; \
  91. \
  92. TAILQ_FOREACH_REVERSE(_lelem, (LIST), HEAD, LINK) \
  93. if ((FUNC)(_lelem, (PTR)) < 0) \
  94. break; \
  95. if (_lelem == NULL) \
  96. TAILQ_INSERT_HEAD((LIST), (PTR), LINK); \
  97. else \
  98. TAILQ_INSERT_AFTER((LIST), _lelem, (PTR), LINK); \
  99. } while (0)
  100. #define FIND_OBJECT_OID_LINK_INDEX(LIST, OID, SUB, LINK, INDEX) ({ \
  101. __typeof (TAILQ_FIRST(LIST)) _lelem; \
  102. \
  103. TAILQ_FOREACH(_lelem, (LIST), LINK) \
  104. if (index_compare(OID, SUB, &_lelem->INDEX) == 0) \
  105. break; \
  106. (_lelem); \
  107. })
  108. #define NEXT_OBJECT_OID_LINK_INDEX(LIST, OID, SUB, LINK, INDEX) ({ \
  109. __typeof (TAILQ_FIRST(LIST)) _lelem; \
  110. \
  111. TAILQ_FOREACH(_lelem, (LIST), LINK) \
  112. if (index_compare(OID, SUB, &_lelem->INDEX) < 0) \
  113. break; \
  114. (_lelem); \
  115. })
  116. #define FIND_OBJECT_INT_LINK_INDEX(LIST, OID, SUB, LINK, INDEX) ({ \
  117. __typeof (TAILQ_FIRST(LIST)) _lelem; \
  118. \
  119. if ((OID)->len - SUB != 1) \
  120. _lelem = NULL; \
  121. else \
  122. TAILQ_FOREACH(_lelem, (LIST), LINK) \
  123. if ((OID)->subs[SUB] == (asn_subid_t)_lelem->INDEX)\
  124. break; \
  125. (_lelem); \
  126. })
  127. #define NEXT_OBJECT_INT_LINK_INDEX(LIST, OID, SUB, LINK, INDEX) ({ \
  128. __typeof (TAILQ_FIRST(LIST)) _lelem; \
  129. \
  130. if ((OID)->len - SUB == 0) \
  131. _lelem = TAILQ_FIRST(LIST); \
  132. else \
  133. TAILQ_FOREACH(_lelem, (LIST), LINK) \
  134. if ((OID)->subs[SUB] < (asn_subid_t)_lelem->INDEX)\
  135. break; \
  136. (_lelem); \
  137. })
  138. #define FIND_OBJECT_FUNC_LINK(LIST, OID, SUB, LINK, FUNC) ({ \
  139. __typeof (TAILQ_FIRST(LIST)) _lelem; \
  140. \
  141. TAILQ_FOREACH(_lelem, (LIST), LINK) \
  142. if ((FUNC)(OID, SUB, _lelem) == 0) \
  143. break; \
  144. (_lelem); \
  145. })
  146. #define NEXT_OBJECT_FUNC_LINK(LIST, OID, SUB, LINK, FUNC) ({ \
  147. __typeof (TAILQ_FIRST(LIST)) _lelem; \
  148. \
  149. TAILQ_FOREACH(_lelem, (LIST), LINK) \
  150. if ((FUNC)(OID, SUB, _lelem) < 0) \
  151. break; \
  152. (_lelem); \
  153. })
  154. /*
  155. * Macros for the case where the index field is called 'index'
  156. */
  157. #define INSERT_OBJECT_OID_LINK(PTR, LIST, LINK) \
  158. INSERT_OBJECT_OID_LINK_INDEX(PTR, LIST, LINK, index)
  159. #define INSERT_OBJECT_INT_LINK(PTR, LIST, LINK) do { \
  160. INSERT_OBJECT_INT_LINK_INDEX(PTR, LIST, LINK, index)
  161. #define FIND_OBJECT_OID_LINK(LIST, OID, SUB, LINK) \
  162. FIND_OBJECT_OID_LINK_INDEX(LIST, OID, SUB, LINK, index)
  163. #define NEXT_OBJECT_OID_LINK(LIST, OID, SUB, LINK) \
  164. NEXT_OBJECT_OID_LINK_INDEX(LIST, OID, SUB, LINK, index)
  165. #define FIND_OBJECT_INT_LINK(LIST, OID, SUB, LINK) \
  166. FIND_OBJECT_INT_LINK_INDEX(LIST, OID, SUB, LINK, index)
  167. #define NEXT_OBJECT_INT_LINK(LIST, OID, SUB, LINK) \
  168. NEXT_OBJECT_INT_LINK_INDEX(LIST, OID, SUB, LINK, index)
  169. /*
  170. * Macros for the case where the index field is called 'index' and the
  171. * link field 'link'.
  172. */
  173. #define INSERT_OBJECT_OID(PTR, LIST) \
  174. INSERT_OBJECT_OID_LINK_INDEX(PTR, LIST, link, index)
  175. #define INSERT_OBJECT_INT(PTR, LIST) \
  176. INSERT_OBJECT_INT_LINK_INDEX(PTR, LIST, link, index)
  177. #define INSERT_OBJECT_FUNC_REV(PTR, LIST, HEAD, FUNC) \
  178. INSERT_OBJECT_FUNC_LINK_REV(PTR, LIST, HEAD, link, FUNC)
  179. #define FIND_OBJECT_OID(LIST, OID, SUB) \
  180. FIND_OBJECT_OID_LINK_INDEX(LIST, OID, SUB, link, index)
  181. #define FIND_OBJECT_INT(LIST, OID, SUB) \
  182. FIND_OBJECT_INT_LINK_INDEX(LIST, OID, SUB, link, index)
  183. #define FIND_OBJECT_FUNC(LIST, OID, SUB, FUNC) \
  184. FIND_OBJECT_FUNC_LINK(LIST, OID, SUB, link, FUNC)
  185. #define NEXT_OBJECT_OID(LIST, OID, SUB) \
  186. NEXT_OBJECT_OID_LINK_INDEX(LIST, OID, SUB, link, index)
  187. #define NEXT_OBJECT_INT(LIST, OID, SUB) \
  188. NEXT_OBJECT_INT_LINK_INDEX(LIST, OID, SUB, link, index)
  189. #define NEXT_OBJECT_FUNC(LIST, OID, SUB, FUNC) \
  190. NEXT_OBJECT_FUNC_LINK(LIST, OID, SUB, link, FUNC)
  191. struct lmodule;
  192. /* The tick when the program was started. This is the absolute time of
  193. * the start in 100th of a second. */
  194. extern uint64_t start_tick;
  195. /* The tick when the current packet was received. This is the absolute
  196. * time in 100th of second. */
  197. extern uint64_t this_tick;
  198. /* Get the current absolute time in 100th of a second. */
  199. uint64_t get_ticks(void);
  200. /*
  201. * Return code for proxy function
  202. */
  203. enum snmpd_proxy_err {
  204. /* proxy code will process the PDU */
  205. SNMPD_PROXY_OK,
  206. /* proxy code does not process PDU */
  207. SNMPD_PROXY_REJ,
  208. /* drop this PDU */
  209. SNMPD_PROXY_DROP,
  210. /* drop because of bad community */
  211. SNMPD_PROXY_BADCOMM,
  212. /* drop because of bad community use */
  213. SNMPD_PROXY_BADCOMMUSE
  214. };
  215. /*
  216. * Input handling
  217. */
  218. enum snmpd_input_err {
  219. /* proceed with packet */
  220. SNMPD_INPUT_OK,
  221. /* fatal error in packet, ignore it */
  222. SNMPD_INPUT_FAILED,
  223. /* value encoding has wrong length in a SET operation */
  224. SNMPD_INPUT_VALBADLEN,
  225. /* value encoding is out of range */
  226. SNMPD_INPUT_VALRANGE,
  227. /* value has bad encoding */
  228. SNMPD_INPUT_VALBADENC,
  229. /* need more data (truncated packet) */
  230. SNMPD_INPUT_TRUNC,
  231. /* unknown community */
  232. SNMPD_INPUT_BAD_COMM,
  233. };
  234. /*
  235. * Every loadable module must have one of this structures with
  236. * the external name 'config'.
  237. */
  238. struct snmp_module {
  239. /* a comment describing what this module implements */
  240. const char *comment;
  241. /* the initialization function */
  242. int (*init)(struct lmodule *, int argc, char *argv[]);
  243. /* the finalisation function */
  244. int (*fini)(void);
  245. /* the idle function */
  246. void (*idle)(void);
  247. /* the dump function */
  248. void (*dump)(void);
  249. /* re-configuration function */
  250. void (*config)(void);
  251. /* start operation */
  252. void (*start)(void);
  253. /* proxy a PDU */
  254. enum snmpd_proxy_err (*proxy)(struct snmp_pdu *, void *,
  255. const struct asn_oid *, const struct sockaddr *, socklen_t,
  256. enum snmpd_input_err, int32_t, int);
  257. /* the tree this module is going to server */
  258. const struct snmp_node *tree;
  259. u_int tree_size;
  260. /* function called, when another module was unloaded/loaded */
  261. void (*loading)(const struct lmodule *, int);
  262. };
  263. /*
  264. * Stuff exported to modules
  265. */
  266. /*
  267. * The system group.
  268. */
  269. struct systemg {
  270. u_char *descr;
  271. struct asn_oid object_id;
  272. u_char *contact;
  273. u_char *name;
  274. u_char *location;
  275. u_int32_t services;
  276. u_int32_t or_last_change;
  277. };
  278. extern struct systemg systemg;
  279. /*
  280. * Community support.
  281. *
  282. * We have 2 fixed communities for SNMP read and write access. Modules
  283. * can create their communities dynamically. They are deleted automatically
  284. * if the module is unloaded.
  285. */
  286. #define COMM_INITIALIZE 0
  287. #define COMM_READ 1
  288. #define COMM_WRITE 2
  289. u_int comm_define(u_int, const char *descr, struct lmodule *, const char *str);
  290. const char * comm_string(u_int);
  291. /* community for current packet */
  292. extern u_int community;
  293. /*
  294. * SNMP User-based Security Model data. Modified via the snmp_usm(3) module.
  295. */
  296. struct snmpd_usmstat {
  297. uint32_t unsupported_seclevels;
  298. uint32_t not_in_time_windows;
  299. uint32_t unknown_users;
  300. uint32_t unknown_engine_ids;
  301. uint32_t wrong_digests;
  302. uint32_t decrypt_errors;
  303. };
  304. extern struct snmpd_usmstat snmpd_usmstats;
  305. struct snmpd_usmstat *bsnmpd_get_usm_stats(void);
  306. void bsnmpd_reset_usm_stats(void);
  307. struct usm_user {
  308. struct snmp_user suser;
  309. uint8_t user_engine_id[SNMP_ENGINE_ID_SIZ];
  310. uint32_t user_engine_len;
  311. char user_public[SNMP_ADM_STR32_SIZ];
  312. uint32_t user_public_len;
  313. int32_t status;
  314. int32_t type;
  315. SLIST_ENTRY(usm_user) up;
  316. };
  317. SLIST_HEAD(usm_userlist, usm_user);
  318. struct usm_user *usm_first_user(void);
  319. struct usm_user *usm_next_user(struct usm_user *);
  320. struct usm_user *usm_find_user(uint8_t *, uint32_t, char *);
  321. struct usm_user *usm_new_user(uint8_t *, uint32_t, char *);
  322. void usm_delete_user(struct usm_user *);
  323. void usm_flush_users(void);
  324. /* USM user for current packet */
  325. extern struct usm_user *usm_user;
  326. /*
  327. * SNMP View-based Access Control Model data. Modified via the snmp_vacm(3) module.
  328. */
  329. struct vacm_group;
  330. struct vacm_user {
  331. /* Security user name from USM */
  332. char secname[SNMP_ADM_STR32_SIZ];
  333. int32_t sec_model;
  334. /* Back pointer to user assigned group name */
  335. struct vacm_group *group;
  336. int32_t type;
  337. int32_t status;
  338. SLIST_ENTRY(vacm_user) vvu;
  339. SLIST_ENTRY(vacm_user) vvg;
  340. };
  341. SLIST_HEAD(vacm_userlist, vacm_user);
  342. struct vacm_group {
  343. char groupname[SNMP_ADM_STR32_SIZ];
  344. struct vacm_userlist group_users;
  345. SLIST_ENTRY(vacm_group) vge;
  346. };
  347. SLIST_HEAD(vacm_grouplist, vacm_group);
  348. struct vacm_access {
  349. /* The group name is index, not a column in the table */
  350. struct vacm_group *group;
  351. char ctx_prefix[SNMP_ADM_STR32_SIZ];
  352. int32_t sec_model;
  353. int32_t sec_level;
  354. int32_t ctx_match;
  355. struct vacm_view *read_view;
  356. struct vacm_view *write_view;
  357. struct vacm_view *notify_view;
  358. int32_t type;
  359. int32_t status;
  360. TAILQ_ENTRY(vacm_access) vva;
  361. };
  362. TAILQ_HEAD(vacm_accesslist, vacm_access);
  363. struct vacm_view {
  364. char viewname[SNMP_ADM_STR32_SIZ]; /* key */
  365. struct asn_oid subtree; /* key */
  366. uint8_t mask[16];
  367. uint8_t exclude;
  368. int32_t type;
  369. int32_t status;
  370. SLIST_ENTRY(vacm_view) vvl;
  371. };
  372. SLIST_HEAD(vacm_viewlist, vacm_view);
  373. struct vacm_context {
  374. /* The ID of the module that registered this context */
  375. int32_t regid;
  376. char ctxname[SNMP_ADM_STR32_SIZ];
  377. SLIST_ENTRY(vacm_context) vcl;
  378. };
  379. SLIST_HEAD(vacm_contextlist, vacm_context);
  380. void vacm_groups_init(void);
  381. struct vacm_user *vacm_first_user(void);
  382. struct vacm_user *vacm_next_user(struct vacm_user *);
  383. struct vacm_user *vacm_new_user(int32_t, char *);
  384. int vacm_delete_user(struct vacm_user *);
  385. int vacm_user_set_group(struct vacm_user *, u_char *, u_int);
  386. struct vacm_access *vacm_first_access_rule(void);
  387. struct vacm_access *vacm_next_access_rule(struct vacm_access *);
  388. struct vacm_access *vacm_new_access_rule(char *, char *, int32_t, int32_t);
  389. int vacm_delete_access_rule(struct vacm_access *);
  390. struct vacm_view *vacm_first_view(void);
  391. struct vacm_view *vacm_next_view(struct vacm_view *);
  392. struct vacm_view *vacm_new_view(char *, struct asn_oid *);
  393. int vacm_delete_view(struct vacm_view *);
  394. struct vacm_context *vacm_first_context(void);
  395. struct vacm_context *vacm_next_context(struct vacm_context *);
  396. struct vacm_context *vacm_add_context(char *, int32_t);
  397. void vacm_flush_contexts(int32_t);
  398. /*
  399. * RFC 3413 SNMP Management Target & Notification MIB
  400. */
  401. struct snmpd_target_stats {
  402. uint32_t unavail_contexts;
  403. uint32_t unknown_contexts;
  404. };
  405. #define SNMP_UDP_ADDR_SIZ 6
  406. #define SNMP_TAG_SIZ (255 + 1)
  407. struct target_address {
  408. char name[SNMP_ADM_STR32_SIZ];
  409. uint8_t address[SNMP_UDP_ADDR_SIZ];
  410. int32_t timeout;
  411. int32_t retry;
  412. char taglist[SNMP_TAG_SIZ];
  413. char paramname[SNMP_ADM_STR32_SIZ];
  414. int32_t type;
  415. int32_t socket;
  416. int32_t status;
  417. SLIST_ENTRY(target_address) ta;
  418. };
  419. SLIST_HEAD(target_addresslist, target_address);
  420. struct target_param {
  421. char name[SNMP_ADM_STR32_SIZ];
  422. int32_t mpmodel;
  423. int32_t sec_model;
  424. char secname[SNMP_ADM_STR32_SIZ];
  425. enum snmp_usm_level sec_level;
  426. int32_t type;
  427. int32_t status;
  428. SLIST_ENTRY(target_param) tp;
  429. };
  430. SLIST_HEAD(target_paramlist, target_param);
  431. struct target_notify {
  432. char name[SNMP_ADM_STR32_SIZ];
  433. char taglist[SNMP_TAG_SIZ];
  434. int32_t notify_type;
  435. int32_t type;
  436. int32_t status;
  437. SLIST_ENTRY(target_notify) tn;
  438. };
  439. SLIST_HEAD(target_notifylist, target_notify);
  440. extern struct snmpd_target_stats snmpd_target_stats;
  441. struct snmpd_target_stats *bsnmpd_get_target_stats(void);
  442. struct target_address *target_first_address(void);
  443. struct target_address *target_next_address(struct target_address *);
  444. struct target_address *target_new_address(char *);
  445. int target_activate_address(struct target_address *);
  446. int target_delete_address(struct target_address *);
  447. struct target_param *target_first_param(void);
  448. struct target_param *target_next_param(struct target_param *);
  449. struct target_param *target_new_param(char *);
  450. int target_delete_param(struct target_param *);
  451. struct target_notify *target_first_notify(void);
  452. struct target_notify *target_next_notify(struct target_notify *);
  453. struct target_notify *target_new_notify(char *);
  454. int target_delete_notify (struct target_notify *);
  455. void target_flush_all(void);
  456. /*
  457. * Well known OIDs
  458. */
  459. extern const struct asn_oid oid_zeroDotZero;
  460. /* SNMPv3 Engine Discovery */
  461. extern const struct asn_oid oid_usmUnknownEngineIDs;
  462. extern const struct asn_oid oid_usmNotInTimeWindows;
  463. /*
  464. * Request ID ranges.
  465. *
  466. * A module can request a range of request ids and associate them with a
  467. * type field. All ranges are deleted if a module is unloaded.
  468. */
  469. u_int reqid_allocate(int size, struct lmodule *);
  470. int32_t reqid_next(u_int type);
  471. int32_t reqid_base(u_int type);
  472. int reqid_istype(int32_t reqid, u_int type);
  473. u_int reqid_type(int32_t reqid);
  474. /*
  475. * Timers.
  476. */
  477. void *timer_start(u_int, void (*)(void *), void *, struct lmodule *);
  478. void *timer_start_repeat(u_int, u_int, void (*)(void *), void *,
  479. struct lmodule *);
  480. void timer_stop(void *);
  481. /*
  482. * File descriptors
  483. */
  484. void *fd_select(int, void (*)(int, void *), void *, struct lmodule *);
  485. void fd_deselect(void *);
  486. void fd_suspend(void *);
  487. int fd_resume(void *);
  488. /*
  489. * Object resources
  490. */
  491. u_int or_register(const struct asn_oid *, const char *, struct lmodule *);
  492. void or_unregister(u_int);
  493. /*
  494. * Buffers
  495. */
  496. void *buf_alloc(int tx);
  497. size_t buf_size(int tx);
  498. /* decode PDU and find community */
  499. enum snmpd_input_err snmp_input_start(const u_char *, size_t, const char *,
  500. struct snmp_pdu *, int32_t *, size_t *);
  501. /* process the pdu. returns either _OK or _FAILED */
  502. enum snmpd_input_err snmp_input_finish(struct snmp_pdu *, const u_char *,
  503. size_t, u_char *, size_t *, const char *, enum snmpd_input_err, int32_t,
  504. void *);
  505. void snmp_output(struct snmp_pdu *, u_char *, size_t *, const char *);
  506. void snmp_send_port(void *, const struct asn_oid *, struct snmp_pdu *,
  507. const struct sockaddr *, socklen_t);
  508. enum snmp_code snmp_pdu_auth_access(struct snmp_pdu *, int32_t *);
  509. /* sending traps */
  510. void snmp_send_trap(const struct asn_oid *, ...);
  511. /*
  512. * Action support
  513. */
  514. int string_save(struct snmp_value *, struct snmp_context *, ssize_t, u_char **);
  515. void string_commit(struct snmp_context *);
  516. void string_rollback(struct snmp_context *, u_char **);
  517. int string_get(struct snmp_value *, const u_char *, ssize_t);
  518. int string_get_max(struct snmp_value *, const u_char *, ssize_t, size_t);
  519. void string_free(struct snmp_context *);
  520. int ip_save(struct snmp_value *, struct snmp_context *, u_char *);
  521. void ip_rollback(struct snmp_context *, u_char *);
  522. void ip_commit(struct snmp_context *);
  523. int ip_get(struct snmp_value *, u_char *);
  524. int oid_save(struct snmp_value *, struct snmp_context *, struct asn_oid *);
  525. void oid_rollback(struct snmp_context *, struct asn_oid *);
  526. void oid_commit(struct snmp_context *);
  527. int oid_get(struct snmp_value *, const struct asn_oid *);
  528. int index_decode(const struct asn_oid *oid, u_int sub, u_int code, ...);
  529. int index_compare(const struct asn_oid *, u_int, const struct asn_oid *);
  530. int index_compare_off(const struct asn_oid *, u_int, const struct asn_oid *,
  531. u_int);
  532. void index_append(struct asn_oid *, u_int, const struct asn_oid *);
  533. void index_append_off(struct asn_oid *, u_int, const struct asn_oid *, u_int);
  534. #endif