Debian Codegraph @

agent/mibgroup/udp-mib/udpEndpointTable/udpEndpointTable.c

raw
1 /*
2 * Note: this file originally auto-generated by mib2c using
3 * version : 1.48 $ of : mfd-top.m2c,v $
4 *
5 * $Id$
6 */
7 /** \page MFD helper for udpEndpointTable
8 *
9 * \section intro Introduction
10 * Introductory text.
11 *
12 */
13 /*
14 * standard Net-SNMP includes
15 */
16 #include <net-snmp/net-snmp-config.h>
17 #include <net-snmp/net-snmp-includes.h>
18 #include <net-snmp/agent/net-snmp-agent-includes.h>
19
20 /*
21 * include our parent header
22 */
23 #include "udpEndpointTable.h"
24
25 #include <net-snmp/agent/mib_modules.h>
26
27 #include "udpEndpointTable_interface.h"
28
29 const oid udpEndpointTable_oid[] = { UDPENDPOINTTABLE_OID };
30 const int udpEndpointTable_oid_size =
31 OID_LENGTH(udpEndpointTable_oid);
32
33 udpEndpointTable_registration udpEndpointTable_user_context;
34 static udpEndpointTable_registration *udpEndpointTable_user_context_p;
35
36 void initialize_table_udpEndpointTable(void);
37 void shutdown_table_udpEndpointTable(void);
38
39
40 /**
41 * Initializes the udpEndpointTable module
42 */
43 void
44 init_udpEndpointTable(void)
45 {
46 DEBUGMSGTL(("verbose:udpEndpointTable:init_udpEndpointTable",
47 "called\n"));
48
49 /*
50 * TODO:300:o: Perform udpEndpointTable one-time module initialization.
51 */
52
53 /*
54 * here we initialize all the tables we're planning on supporting
55 */
56 if (should_init("udpEndpointTable"))
57 initialize_table_udpEndpointTable();
58
59 } /* init_udpEndpointTable */
60
61 /**
62 * Shut-down the udpEndpointTable module (agent is exiting)
63 */
64 void
65 shutdown_udpEndpointTable(void)
66 {
67 if (should_init("udpEndpointTable"))
68 shutdown_table_udpEndpointTable();
69
70 }
71
72 /**
73 * Initialize the table udpEndpointTable
74 * (Define its contents and how it's structured)
75 */
76 void
77 initialize_table_udpEndpointTable(void)
78 {
79 u_long flags;
80
81 DEBUGMSGTL(("verbose:udpEndpointTable:initialize_table_udpEndpointTable", "called\n"));
82
83 /*
84 * TODO:301:o: Perform udpEndpointTable one-time table initialization.
85 */
86
87 /*
88 * TODO:302:o: |->Initialize udpEndpointTable user context
89 * if you'd like to pass in a pointer to some data for this
90 * table, allocate or set it up here.
91 */
92 /*
93 * a netsnmp_data_list is a simple way to store void pointers. A simple
94 * string token is used to add, find or remove pointers.
95 */
96 udpEndpointTable_user_context_p =
97 netsnmp_create_data_list("udpEndpointTable", NULL, NULL);
98
99 /*
100 * No support for any flags yet, but in the future you would
101 * set any flags here.
102 */
103 flags = 0;
104
105 /*
106 * call interface initialization code
107 */
108 _udpEndpointTable_initialize_interface
109 (udpEndpointTable_user_context_p, flags);
110 } /* initialize_table_udpEndpointTable */
111
112 /**
113 * Shutdown the table udpEndpointTable
114 */
115 void
116 shutdown_table_udpEndpointTable(void)
117 {
118 /*
119 * call interface shutdown code
120 */
121 _udpEndpointTable_shutdown_interface(udpEndpointTable_user_context_p);
122 netsnmp_free_all_list_data(udpEndpointTable_user_context_p);
123 udpEndpointTable_user_context_p = NULL;
124 }
125
126 /**
127 * pre-request callback
128 *
129 * @param user_context
130 * @retval MFD_SUCCESS : success.
131 * @retval MFD_ERROR : other error
132 */
133 int
134 udpEndpointTable_pre_request(udpEndpointTable_registration * user_context)
135 {
136 DEBUGMSGTL(("verbose:udpEndpointTable:udpEndpointTable_pre_request",
137 "called\n"));
138
139 /*
140 * TODO:510:o: Perform udpEndpointTable pre-request actions.
141 */
142
143 return MFD_SUCCESS;
144 } /* udpEndpointTable_pre_request */
145
146 /**
147 * post-request callback
148 *
149 * Note:
150 * New rows have been inserted into the container, and
151 * deleted rows have been removed from the container and
152 * released.
153 * @param user_context
154 * @param rc : MFD_SUCCESS if all requests succeeded
155 *
156 * @retval MFD_SUCCESS : success.
157 * @retval MFD_ERROR : other error (ignored)
158 */
159 int
160 udpEndpointTable_post_request(udpEndpointTable_registration * user_context,
161 int rc)
162 {
163 DEBUGMSGTL(("verbose:udpEndpointTable:udpEndpointTable_post_request",
164 "called\n"));
165
166 /*
167 * TODO:511:o: Perform udpEndpointTable post-request actions.
168 */
169
170 return MFD_SUCCESS;
171 } /* udpEndpointTable_post_request */
172
173
174 /**********************************************************************
175 **********************************************************************
176 ***
177 *** Table udpEndpointTable
178 ***
179 **********************************************************************
180 **********************************************************************/
181 /*
182 * UDP-MIB::udpEndpointTable is subid 7 of udp.
183 * Its status is Current.
184 * OID: .1.3.6.1.2.1.7.7, length: 8
185 */
186
187 /*
188 * ---------------------------------------------------------------------
189 * * TODO:200:r: Implement udpEndpointTable data context functions.
190 */
191
192
193 /**
194 * set mib index(es)
195 *
196 * @param tbl_idx mib index structure
197 * @param udpEndpointLocalAddressType_val
198 * @param udpEndpointLocalAddress_val_ptr
199 * @param udpEndpointLocalAddress_val_ptr_len
200 * @param udpEndpointLocalPort_val
201 * @param udpEndpointRemoteAddressType_val
202 * @param udpEndpointRemoteAddress_val_ptr
203 * @param udpEndpointRemoteAddress_val_ptr_len
204 * @param udpEndpointRemotePort_val
205 * @param udpEndpointInstance_val
206 *
207 * @retval MFD_SUCCESS : success.
208 * @retval MFD_ERROR : other error.
209 *
210 * @remark
211 * This convenience function is useful for setting all the MIB index
212 * components with a single function call. It is assume that the C values
213 * have already been mapped from their native/rawformat to the MIB format.
214 */
215 int
216 udpEndpointTable_indexes_set_tbl_idx(udpEndpointTable_mib_index * tbl_idx,
217 u_long
218 udpEndpointLocalAddressType_val,
219 char *udpEndpointLocalAddress_val_ptr,
220 size_t
221 udpEndpointLocalAddress_val_ptr_len,
222 u_long udpEndpointLocalPort_val,
223 u_long
224 udpEndpointRemoteAddressType_val, char
225 *udpEndpointRemoteAddress_val_ptr,
226 size_t
227 udpEndpointRemoteAddress_val_ptr_len,
228 u_long udpEndpointRemotePort_val,
229 u_long udpEndpointInstance_val,
230 u_long udpEndpointProcess_val)
231 {
232 DEBUGMSGTL(("verbose:udpEndpointTable:udpEndpointTable_indexes_set_tbl_idx", "called\n"));
233
234 /*
235 * udpEndpointLocalAddressType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
236 */
237 tbl_idx->udpEndpointLocalAddressType = udpEndpointLocalAddressType_val;
238
239 /*
240 * udpEndpointLocalAddress(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h
241 */
242 tbl_idx->udpEndpointLocalAddress_len = sizeof(tbl_idx->udpEndpointLocalAddress) / sizeof(tbl_idx->udpEndpointLocalAddress[0]); /* max length */
243 /*
244 * make sure there is enough space for udpEndpointLocalAddress data
245 */
246 if (tbl_idx->udpEndpointLocalAddress_len <
247 udpEndpointLocalAddress_val_ptr_len) {
248 snmp_log(LOG_ERR, "not enough space for value\n");
249 return MFD_ERROR;
250 }
251 tbl_idx->udpEndpointLocalAddress_len =
252 udpEndpointLocalAddress_val_ptr_len;
253 memcpy(tbl_idx->udpEndpointLocalAddress,
254 udpEndpointLocalAddress_val_ptr,
255 udpEndpointLocalAddress_val_ptr_len *
256 sizeof(udpEndpointLocalAddress_val_ptr[0]));
257
258 /*
259 * udpEndpointLocalPort(3)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H
260 */
261 tbl_idx->udpEndpointLocalPort = udpEndpointLocalPort_val;
262
263 /*
264 * udpEndpointRemoteAddressType(4)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
265 */
266 tbl_idx->udpEndpointRemoteAddressType =
267 udpEndpointRemoteAddressType_val;
268
269 /*
270 * udpEndpointRemoteAddress(5)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h
271 */
272 tbl_idx->udpEndpointRemoteAddress_len = sizeof(tbl_idx->udpEndpointRemoteAddress) / sizeof(tbl_idx->udpEndpointRemoteAddress[0]); /* max length */
273 /*
274 * make sure there is enough space for udpEndpointRemoteAddress data
275 */
276 if (tbl_idx->udpEndpointRemoteAddress_len <
277 udpEndpointRemoteAddress_val_ptr_len) {
278 snmp_log(LOG_ERR, "not enough space for value\n");
279 return MFD_ERROR;
280 }
281 tbl_idx->udpEndpointRemoteAddress_len =
282 udpEndpointRemoteAddress_val_ptr_len;
283 memcpy(tbl_idx->udpEndpointRemoteAddress,
284 udpEndpointRemoteAddress_val_ptr,
285 udpEndpointRemoteAddress_val_ptr_len *
286 sizeof(udpEndpointRemoteAddress_val_ptr[0]));
287
288 /*
289 * udpEndpointRemotePort(6)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H
290 */
291 tbl_idx->udpEndpointRemotePort = udpEndpointRemotePort_val;
292
293 /*
294 * udpEndpointInstance(7)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/h
295 */
296 tbl_idx->udpEndpointInstance = udpEndpointInstance_val;
297 /*
298 * udpEndpointProcess(8)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/h
299 */
300 tbl_idx->udpEndpointProcess = udpEndpointProcess_val;
301
302
303 return MFD_SUCCESS;
304 } /* udpEndpointTable_indexes_set_tbl_idx */
305
306 /**
307 * @internal
308 * set row context indexes
309 *
310 * @param reqreq_ctx the row context that needs updated indexes
311 *
312 * @retval MFD_SUCCESS : success.
313 * @retval MFD_ERROR : other error.
314 *
315 * @remark
316 * This function sets the mib indexs, then updates the oid indexs
317 * from the mib index.
318 */
319 int
320 udpEndpointTable_indexes_set(udpEndpointTable_rowreq_ctx * rowreq_ctx,
321 u_long udpEndpointLocalAddressType_val,
322 char *udpEndpointLocalAddress_val_ptr,
323 size_t udpEndpointLocalAddress_val_ptr_len,
324 u_long udpEndpointLocalPort_val,
325 u_long udpEndpointRemoteAddressType_val,
326 char *udpEndpointRemoteAddress_val_ptr,
327 size_t udpEndpointRemoteAddress_val_ptr_len,
328 u_long udpEndpointRemotePort_val,
329 u_long udpEndpointInstance_val,
330 u_long udpEndpointProcess_val)
331 {
332 DEBUGMSGTL(("verbose:udpEndpointTable:udpEndpointTable_indexes_set",
333 "called\n"));
334
335 if (MFD_SUCCESS !=
336 udpEndpointTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx,
337 udpEndpointLocalAddressType_val,
338 udpEndpointLocalAddress_val_ptr,
339 udpEndpointLocalAddress_val_ptr_len,
340 udpEndpointLocalPort_val,
341 udpEndpointRemoteAddressType_val,
342 udpEndpointRemoteAddress_val_ptr,
343 udpEndpointRemoteAddress_val_ptr_len,
344 udpEndpointRemotePort_val,
345 udpEndpointInstance_val,
346 udpEndpointProcess_val))
347 return MFD_ERROR;
348
349 /*
350 * convert mib index to oid index
351 */
352 rowreq_ctx->oid_idx.len = sizeof(rowreq_ctx->oid_tmp) / sizeof(oid);
353 if (0 != udpEndpointTable_index_to_oid(&rowreq_ctx->oid_idx,
354 &rowreq_ctx->tbl_idx)) {
355 return MFD_ERROR;
356 }
357
358 return MFD_SUCCESS;
359 } /* udpEndpointTable_indexes_set */
360
361
362 /*---------------------------------------------------------------------
363 * UDP-MIB::udpEndpointEntry.udpEndpointProcess
364 * udpEndpointProcess is subid 8 of udpEndpointEntry.
365 * Its status is Current, and its access level is ReadOnly.
366 * OID: .1.3.6.1.2.1.7.7.1.8
367 * Description:
368 The system's process ID for the process associated with
369 this endpoint, or zero if there is no such process.
370 This value is expected to be the same as
371 HOST-RESOURCES-MIB::hrSWRunIndex or SYSAPPL-MIB::
372 sysApplElmtRunIndex for some row in the appropriate
373 tables.
374 *
375 * Attributes:
376 * accessible 1 isscalar 0 enums 0 hasdefval 0
377 * readable 1 iscolumn 1 ranges 0 hashint 0
378 * settable 0
379 *
380 *
381 * Its syntax is UNSIGNED32 (based on perltype UNSIGNED32)
382 * The net-snmp type is ASN_UNSIGNED. The C type decl is u_long (u_long)
383 */
384 /**
385 * Extract the current value of the udpEndpointProcess data.
386 *
387 * Set a value using the data context for the row.
388 *
389 * @param rowreq_ctx
390 * Pointer to the row request context.
391 * @param udpEndpointProcess_val_ptr
392 * Pointer to storage for a u_long variable
393 *
394 * @retval MFD_SUCCESS : success
395 * @retval MFD_SKIP : skip this node (no value for now)
396 * @retval MFD_ERROR : Any other error
397 */
398 int
399 udpEndpointProcess_get(udpEndpointTable_rowreq_ctx * rowreq_ctx,
400 u_long * udpEndpointProcess_val_ptr)
401 {
402 /** we should have a non-NULL pointer */
403 netsnmp_assert(NULL != udpEndpointProcess_val_ptr);
404
405
406 DEBUGMSGTL(("verbose:udpEndpointTable:udpEndpointProcess_get",
407 "called\n"));
408
409 netsnmp_assert(NULL != rowreq_ctx);
410
411 /*
412 * TODO:231:o: |-> Extract the current value of the udpEndpointProcess data.
413 * copy (* udpEndpointProcess_val_ptr ) from rowreq_ctx->tbl_idx.udpEndpointProcess
414 */
415 (*udpEndpointProcess_val_ptr) = rowreq_ctx->tbl_idx.udpEndpointProcess;
416
417 return MFD_SUCCESS;
418 } /* udpEndpointProcess_get */
419
420
421
422 /** @} */
423 /** @} */
424 /** @{ */