Debian Codegraph @

include/net-snmp/library/snmp_enum.h

raw
1 #ifndef SNMP_ENUM_H
2 #define SNMP_ENUM_H
3
4 /*
5 * Portions of this file are copyrighted by:
6 * Copyright (c) 2016 VMware, Inc. All rights reserved.
7 * Use is subject to license terms specified in the COPYING file
8 * distributed with the Net-SNMP package.
9 */
10
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14
15 struct snmp_enum_list {
16 struct snmp_enum_list *next;
17 int value;
18 char *label;
19 };
20
21 #define SE_MAX_IDS 5
22 #define SE_MAX_SUBIDS 32 /* needs to be a multiple of 8 */
23
24 /*
25 * begin storage definitions
26 */
27 /*
28 * These definitions correspond with the "storid" argument to the API
29 */
30 #define SE_LIBRARY_ID 0
31 #define SE_MIB_ID 1
32 #define SE_APPLICATION_ID 2
33 #define SE_ASSIGNED_ID 3
34
35 /*
36 * library specific enum locations
37 */
38
39 /*
40 * error codes
41 */
42 #define SE_OK 0
43 #define SE_NOMEM 1
44 #define SE_ALREADY_THERE 2
45 #define SE_DNE -2
46
47 int init_snmp_enum(const char *type);
48 struct snmp_enum_list *se_find_list(unsigned int major,
49 unsigned int minor);
50 struct snmp_enum_list *se_find_slist(const char *listname);
51 int se_find_value(unsigned int major, unsigned int minor,
52 const char *label);
53 int se_find_free_value(unsigned int major, unsigned int minor);
54 char *se_find_label(unsigned int major, unsigned int minor,
55 int value);
56 /**
57 * Add the pair (label, value) to the list (major, minor). Transfers
58 * ownership of the memory pointed to by label to the list:
59 * clear_snmp_enum() deallocates that memory.
60 */
61 int se_add_pair(unsigned int major, unsigned int minor,
62 char *label, int value);
63
64 /*
65 * finds a list of enums in a list of enum structs associated by a name.
66 */
67 /*
68 * find a list, and then operate on that list
69 * ( direct methods further below if you already have the list pointer)
70 */
71 NETSNMP_IMPORT
72 char *se_find_label_in_slist(const char *listname,
73 int value);
74 NETSNMP_IMPORT
75 int se_find_value_in_slist(const char *listname,
76 const char *label);
77 NETSNMP_IMPORT
78 int se_find_casevalue_in_slist(const char *listname,
79 const char *label);
80 int se_find_free_value_in_slist(const char *listname);
81 /**
82 * Add the pair (label, value) to the slist with name listname. Transfers
83 * ownership of the memory pointed to by label to the list:
84 * clear_snmp_enum() deallocates that memory.
85 */
86 NETSNMP_IMPORT
87 int se_add_pair_to_slist(const char *listname, char *label,
88 int value);
89
90 /*
91 * operates directly on a possibly external list
92 */
93 char *se_find_label_in_list(struct snmp_enum_list *list,
94 int value);
95 int se_find_value_in_list(struct snmp_enum_list *list,
96 const char *label);
97 int se_find_casevalue_in_list(struct snmp_enum_list *list,
98 const char *label);
99 int se_find_free_value_in_list(struct snmp_enum_list *list);
100 int se_add_pair_to_list(struct snmp_enum_list **list,
101 char *label, int value);
102
103 /*
104 * Persistent enumeration lists
105 */
106 void se_store_enum_list(struct snmp_enum_list *new_list,
107 const char *token, const char *type);
108 void se_store_list(unsigned int major, unsigned int minor,
109 const char *type);
110 void se_clear_slist(const char *listname);
111 void se_store_slist(const char *listname, const char *type);
112 int se_store_slist_callback(int majorID, int minorID,
113 void *serverargs, void *clientargs);
114 void se_read_conf(const char *word, const char *cptr);
115 /**
116 * Deallocate the memory allocated by init_snmp_enum(): remove all key/value
117 * pairs stored by se_add_*() calls.
118 */
119 NETSNMP_IMPORT
120 void clear_snmp_enum(void);
121
122 #ifdef __cplusplus
123 }
124 #endif
125 #endif /* SNMP_ENUM_H */