Debian Codegraph @

agent/mibgroup/sctp-mib/sctpLookupRemPrimIPAddrTable.c

raw
1 /*
2 * Note: this file originally auto-generated by mib2c using
3 * $
4 */
5
6 #include <net-snmp/net-snmp-config.h>
7 #include <net-snmp/net-snmp-includes.h>
8 #include <net-snmp/agent/net-snmp-agent-includes.h>
9 #include <net-snmp/agent/table_container.h>
10 #include "sctpLookupRemPrimIPAddrTable.h"
11
12 static netsnmp_container *sctpLookupRemPrimIPAddrTable_container;
13 static netsnmp_table_registration_info *table_info;
14
15 /** Initializes the sctpLookupRemPrimIPAddrTable module */
16 void
17 init_sctpLookupRemPrimIPAddrTable(void)
18 {
19 /*
20 * here we initialize all the tables we're planning on supporting
21 */
22 initialize_table_sctpLookupRemPrimIPAddrTable();
23 }
24
25 void
26 shutdown_sctpLookupRemPrimIPAddrTable(void)
27 {
28 shutdown_table_sctpLookupRemPrimIPAddrTable();
29 }
30
31 /** Initialize the sctpLookupRemPrimIPAddrTable table by defining its contents and how it's structured */
32 void
33 initialize_table_sctpLookupRemPrimIPAddrTable(void)
34 {
35 static oid sctpLookupRemPrimIPAddrTable_oid[] =
36 { 1, 3, 6, 1, 2, 1, 104, 1, 9 };
37 size_t sctpLookupRemPrimIPAddrTable_oid_len =
38 OID_LENGTH(sctpLookupRemPrimIPAddrTable_oid);
39 netsnmp_handler_registration *reg = NULL;
40 netsnmp_mib_handler *handler = NULL;
41 netsnmp_container *container = NULL;
42
43 reg =
44 netsnmp_create_handler_registration("sctpLookupRemPrimIPAddrTable",
45 sctpLookupRemPrimIPAddrTable_handler,
46 sctpLookupRemPrimIPAddrTable_oid,
47 sctpLookupRemPrimIPAddrTable_oid_len,
48 HANDLER_CAN_RONLY);
49 if (NULL == reg) {
50 snmp_log(LOG_ERR,
51 "error creating handler registration for sctpLookupRemPrimIPAddrTable\n");
52 goto bail;
53 }
54
55 container =
56 netsnmp_container_find
57 ("sctpLookupRemPrimIPAddrTable:table_container");
58 if (NULL == container) {
59 snmp_log(LOG_ERR,
60 "error creating container for sctpLookupRemPrimIPAddrTable\n");
61 goto bail;
62 }
63 sctpLookupRemPrimIPAddrTable_container = container;
64
65 table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
66 if (NULL == table_info) {
67 snmp_log(LOG_ERR,
68 "error allocating table registration for sctpLookupRemPrimIPAddrTable\n");
69 goto bail;
70 }
71 netsnmp_table_helper_add_indexes(table_info, ASN_INTEGER, /* index: sctpAssocRemPrimAddrType */
72 ASN_OCTET_STR, /* index: sctpAssocRemPrimAddr */
73 ASN_UNSIGNED, /* index: sctpAssocId */
74 0);
75 table_info->min_column = COLUMN_SCTPLOOKUPREMPRIMIPADDRSTARTTIME;
76 table_info->max_column = COLUMN_SCTPLOOKUPREMPRIMIPADDRSTARTTIME;
77
78 /*************************************************
79 *
80 * inject container_table helper
81 */
82 handler = netsnmp_container_table_handler_get(table_info, container,
83 TABLE_CONTAINER_KEY_NETSNMP_INDEX);
84 if (NULL == handler) {
85 snmp_log(LOG_ERR,
86 "error allocating table registration for sctpLookupRemPrimIPAddrTable\n");
87 goto bail;
88 }
89 if (SNMPERR_SUCCESS != netsnmp_inject_handler(reg, handler)) {
90 snmp_log(LOG_ERR,
91 "error injecting container_table handler for sctpLookupRemPrimIPAddrTable\n");
92 goto bail;
93 }
94 handler = NULL; /* reg has it, will reuse below */
95
96 /*
97 * register the table
98 */
99 if (SNMPERR_SUCCESS != netsnmp_register_table(reg, table_info)) {
100 snmp_log(LOG_ERR,
101 "error registering table handler for sctpLookupRemPrimIPAddrTable\n");
102 reg = NULL; /* it was freed inside netsnmp_register_table */
103 goto bail;
104 }
105
106 return; /* ok */
107
108 /*
109 * Some error occurred during registration. Clean up and bail.
110 */
111 bail: /* not ok */
112
113 if (handler)
114 netsnmp_handler_free(handler);
115
116 if (table_info)
117 netsnmp_table_registration_info_free(table_info);
118
119 if (container)
120 CONTAINER_FREE(container);
121
122 if (reg)
123 netsnmp_handler_registration_free(reg);
124 }
125
126 void
127 shutdown_table_sctpLookupRemPrimIPAddrTable(void)
128 {
129 if (table_info) {
130 netsnmp_table_registration_info_free(table_info);
131 table_info = NULL;
132 }
133 sctpLookupRemPrimIPAddrTable_container_clear
134 (sctpLookupRemPrimIPAddrTable_container);
135 }
136
137 /** handles requests for the sctpLookupRemPrimIPAddrTable table */
138 int
139 sctpLookupRemPrimIPAddrTable_handler(netsnmp_mib_handler *handler,
140 netsnmp_handler_registration *reginfo,
141 netsnmp_agent_request_info *reqinfo,
142 netsnmp_request_info *requests)
143 {
144
145 netsnmp_request_info *request;
146 netsnmp_table_request_info *table_info;
147 sctpLookupRemPrimIPAddrTable_entry *table_entry;
148
149 switch (reqinfo->mode) {
150 /*
151 * Read-support (also covers GetNext requests)
152 */
153 case MODE_GET:
154 for (request = requests; request; request = request->next) {
155 if (request->processed)
156 continue;
157 table_entry = (sctpLookupRemPrimIPAddrTable_entry *)
158 netsnmp_container_table_extract_context(request);
159 table_info = netsnmp_extract_table_info(request);
160 if ((NULL == table_entry) || (NULL == table_info)) {
161 snmp_log(LOG_ERR,
162 "could not extract table entry or info for sctpLookupRemPrimIPAddrTable\n");
163 snmp_set_var_typed_value(request->requestvb,
164 SNMP_ERR_GENERR, NULL, 0);
165 continue;
166 }
167
168 switch (table_info->colnum) {
169 case COLUMN_SCTPLOOKUPREMPRIMIPADDRSTARTTIME:
170 if (!table_entry) {
171 netsnmp_set_request_error(reqinfo, request,
172 SNMP_NOSUCHINSTANCE);
173 continue;
174 }
175 snmp_set_var_typed_integer(request->requestvb,
176 ASN_TIMETICKS,
177 table_entry->sctpLookupRemPrimIPAddrStartTime);
178 break;
179 default:
180 netsnmp_set_request_error(reqinfo, request,
181 SNMP_NOSUCHOBJECT);
182 break;
183 }
184 }
185 break;
186
187 }
188 return SNMP_ERR_NOERROR;
189 }
190
191 sctpLookupRemPrimIPAddrTable_entry *
192 sctpLookupRemPrimIPAddrTable_entry_create(void)
193 {
194 sctpLookupRemPrimIPAddrTable_entry *entry =
195 SNMP_MALLOC_TYPEDEF(sctpLookupRemPrimIPAddrTable_entry);
196 if (entry != NULL) {
197 entry->oid_index.len =
198 SCTP_LOOKUP_REM_PRIM_IP_ADDR_TABLE_INDEX_SIZE;
199 entry->oid_index.oids = entry->oid_tmp;
200 }
201
202 return entry;
203 }
204
205 int
206 sctpLookupRemPrimIPAddrTable_entry_update_index
207 (sctpLookupRemPrimIPAddrTable_entry * entry)
208 {
209 netsnmp_variable_list var_sctpAssocRemPrimAddrType;
210 netsnmp_variable_list var_sctpAssocRemPrimAddr;
211 netsnmp_variable_list var_sctpAssocId;
212 int err = 0;
213
214 /*
215 * prepare the value to be converted
216 */
217 memset(&var_sctpAssocRemPrimAddrType, 0,
218 sizeof(var_sctpAssocRemPrimAddrType));
219 var_sctpAssocRemPrimAddrType.type = ASN_UNSIGNED;
220 var_sctpAssocRemPrimAddrType.next_variable = &var_sctpAssocRemPrimAddr;
221 snmp_set_var_value(&var_sctpAssocRemPrimAddrType,
222 (u_char *) & entry->sctpAssocRemPrimAddrType,
223 sizeof(entry->sctpAssocRemPrimAddrType));
224
225 memset(&var_sctpAssocRemPrimAddr, 0, sizeof(var_sctpAssocRemPrimAddr));
226 var_sctpAssocRemPrimAddr.type = ASN_OCTET_STR;
227 var_sctpAssocRemPrimAddr.next_variable = &var_sctpAssocId;
228 snmp_set_var_value(&var_sctpAssocRemPrimAddr,
229 (u_char *) & entry->sctpAssocRemPrimAddr,
230 entry->sctpAssocRemPrimAddr_len);
231
232 memset(&var_sctpAssocId, 0, sizeof(var_sctpAssocId));
233 var_sctpAssocId.type = ASN_UNSIGNED;
234 var_sctpAssocId.next_variable = NULL;
235 snmp_set_var_value(&var_sctpAssocId, (u_char *) & entry->sctpAssocId,
236 sizeof(entry->sctpAssocId));
237
238 /*
239 * convert it
240 */
241 err =
242 build_oid_noalloc(entry->oid_index.oids, entry->oid_index.len,
243 &entry->oid_index.len, NULL, 0,
244 &var_sctpAssocRemPrimAddrType);
245 if (err)
246 snmp_log(LOG_ERR, "error %d converting index to oid\n", err);
247
248 /*
249 * release any memory allocated during the conversion
250 */
251 snmp_reset_var_buffers(&var_sctpAssocRemPrimAddrType);
252
253 return err;
254 }
255
256 void
257 sctpLookupRemPrimIPAddrTable_entry_copy(sctpLookupRemPrimIPAddrTable_entry
258 * from,
259 sctpLookupRemPrimIPAddrTable_entry
260 * to)
261 {
262 memcpy(to, from, sizeof(sctpLookupRemPrimIPAddrTable_entry));
263 to->oid_index.oids = to->oid_tmp;
264 }
265
266
267 void
268 sctpLookupRemPrimIPAddrTable_entry_free(sctpLookupRemPrimIPAddrTable_entry
269 * entry)
270 {
271 SNMP_FREE(entry);
272 }
273
274 netsnmp_container *
275 sctpLookupRemPrimIPAddrTable_get_container(void)
276 {
277 return sctpLookupRemPrimIPAddrTable_container;
278 }
279
280
281 static void
282 sctpLookupRemPrimIPAddrTable_entry_clear(void *what, void *magic)
283 {
284 sctpLookupRemPrimIPAddrTable_entry_free(what);
285 }
286
287 void
288 sctpLookupRemPrimIPAddrTable_container_clear(netsnmp_container *container)
289 {
290 CONTAINER_CLEAR(container, sctpLookupRemPrimIPAddrTable_entry_clear,
291 NULL);
292 }