summaryrefslogtreecommitdiff
path: root/agent/mibgroup/udp-mib/udpEndpointTable/udpEndpointTable.c
blob: 5da022f7f1122ac6f7465248ec6c8b1630d7da12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
/*
 * Note: this file originally auto-generated by mib2c using
 *       version : 1.48 $ of : mfd-top.m2c,v $ 
 *
 * $Id: udpEndpointTable.c 14169 2006-01-25 16:28:12Z dts12 $
 */
/** \page MFD helper for udpEndpointTable
 *
 * \section intro Introduction
 * Introductory text.
 *
 */
/*
 * standard Net-SNMP includes 
 */
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>

/*
 * include our parent header 
 */
#include "udpEndpointTable.h"

#include <net-snmp/agent/mib_modules.h>

#include "udpEndpointTable_interface.h"

oid             udpEndpointTable_oid[] = { UDPENDPOINTTABLE_OID };
int             udpEndpointTable_oid_size =
OID_LENGTH(udpEndpointTable_oid);

udpEndpointTable_registration udpEndpointTable_user_context;

void            initialize_table_udpEndpointTable(void);
void            shutdown_table_udpEndpointTable(void);


/**
 * Initializes the udpEndpointTable module
 */
void
init_udpEndpointTable(void)
{
    DEBUGMSGTL(("verbose:udpEndpointTable:init_udpEndpointTable",
                "called\n"));

    /*
     * TODO:300:o: Perform udpEndpointTable one-time module initialization.
     */

    /*
     * here we initialize all the tables we're planning on supporting
     */
    if (should_init("udpEndpointTable"))
        initialize_table_udpEndpointTable();

}                               /* init_udpEndpointTable */

/**
 * Shut-down the udpEndpointTable module (agent is exiting)
 */
void
shutdown_udpEndpointTable(void)
{
    if (should_init("udpEndpointTable"))
        shutdown_table_udpEndpointTable();

}

/**
 * Initialize the table udpEndpointTable 
 *    (Define its contents and how it's structured)
 */
void
initialize_table_udpEndpointTable(void)
{
    udpEndpointTable_registration *user_context;
    u_long          flags;

    DEBUGMSGTL(("verbose:udpEndpointTable:initialize_table_udpEndpointTable", "called\n"));

    /*
     * TODO:301:o: Perform udpEndpointTable one-time table initialization.
     */

    /*
     * TODO:302:o: |->Initialize udpEndpointTable user context
     * if you'd like to pass in a pointer to some data for this
     * table, allocate or set it up here.
     */
    /*
     * a netsnmp_data_list is a simple way to store void pointers. A simple
     * string token is used to add, find or remove pointers.
     */
    user_context =
        netsnmp_create_data_list("udpEndpointTable", NULL, NULL);

    /*
     * No support for any flags yet, but in the future you would
     * set any flags here.
     */
    flags = 0;

    /*
     * call interface initialization code
     */
    _udpEndpointTable_initialize_interface(user_context, flags);
}                               /* initialize_table_udpEndpointTable */

/**
 * Shutdown the table udpEndpointTable 
 */
void
shutdown_table_udpEndpointTable(void)
{
    /*
     * call interface shutdown code
     */
    _udpEndpointTable_shutdown_interface(&udpEndpointTable_user_context);
}

/**
 * pre-request callback
 *
 * @param user_context
 * @retval MFD_SUCCESS              : success.
 * @retval MFD_ERROR                : other error
 */
int
udpEndpointTable_pre_request(udpEndpointTable_registration * user_context)
{
    DEBUGMSGTL(("verbose:udpEndpointTable:udpEndpointTable_pre_request",
                "called\n"));

    /*
     * TODO:510:o: Perform udpEndpointTable pre-request actions.
     */

    return MFD_SUCCESS;
}                               /* udpEndpointTable_pre_request */

/**
 * post-request callback
 *
 * Note:
 *   New rows have been inserted into the container, and
 *   deleted rows have been removed from the container and
 *   released.
 * @param user_context
 * @param rc : MFD_SUCCESS if all requests succeeded
 *
 * @retval MFD_SUCCESS : success.
 * @retval MFD_ERROR   : other error (ignored)
 */
int
udpEndpointTable_post_request(udpEndpointTable_registration * user_context,
                              int rc)
{
    DEBUGMSGTL(("verbose:udpEndpointTable:udpEndpointTable_post_request",
                "called\n"));

    /*
     * TODO:511:o: Perform udpEndpointTable post-request actions.
     */

    return MFD_SUCCESS;
}                               /* udpEndpointTable_post_request */


/**********************************************************************
 **********************************************************************
 ***
 *** Table udpEndpointTable
 ***
 **********************************************************************
 **********************************************************************/
/*
 * UDP-MIB::udpEndpointTable is subid 7 of udp.
 * Its status is Current.
 * OID: .1.3.6.1.2.1.7.7, length: 8
 */

/*
 * ---------------------------------------------------------------------
 * * TODO:200:r: Implement udpEndpointTable data context functions.
 */


/**
 * set mib index(es)
 *
 * @param tbl_idx mib index structure
 * @param udpEndpointLocalAddressType_val
 * @param udpEndpointLocalAddress_val_ptr
 * @param udpEndpointLocalAddress_val_ptr_len
 * @param udpEndpointLocalPort_val
 * @param udpEndpointRemoteAddressType_val
 * @param udpEndpointRemoteAddress_val_ptr
 * @param udpEndpointRemoteAddress_val_ptr_len
 * @param udpEndpointRemotePort_val
 * @param udpEndpointInstance_val
 *
 * @retval MFD_SUCCESS     : success.
 * @retval MFD_ERROR       : other error.
 *
 * @remark
 *  This convenience function is useful for setting all the MIB index
 *  components with a single function call. It is assume that the C values
 *  have already been mapped from their native/rawformat to the MIB format.
 */
int
udpEndpointTable_indexes_set_tbl_idx(udpEndpointTable_mib_index * tbl_idx,
                                     u_long
                                     udpEndpointLocalAddressType_val,
                                     char *udpEndpointLocalAddress_val_ptr,
                                     size_t
                                     udpEndpointLocalAddress_val_ptr_len,
                                     u_long udpEndpointLocalPort_val,
                                     u_long
                                     udpEndpointRemoteAddressType_val, char
                                     *udpEndpointRemoteAddress_val_ptr,
                                     size_t
                                     udpEndpointRemoteAddress_val_ptr_len,
                                     u_long udpEndpointRemotePort_val,
                                     u_long udpEndpointInstance_val)
{
    DEBUGMSGTL(("verbose:udpEndpointTable:udpEndpointTable_indexes_set_tbl_idx", "called\n"));

    /*
     * udpEndpointLocalAddressType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h 
     */
    tbl_idx->udpEndpointLocalAddressType = udpEndpointLocalAddressType_val;

    /*
     * udpEndpointLocalAddress(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h 
     */
    tbl_idx->udpEndpointLocalAddress_len = sizeof(tbl_idx->udpEndpointLocalAddress) / sizeof(tbl_idx->udpEndpointLocalAddress[0]);      /* max length */
    /*
     * make sure there is enough space for udpEndpointLocalAddress data
     */
    if ((NULL == tbl_idx->udpEndpointLocalAddress) ||
        (tbl_idx->udpEndpointLocalAddress_len <
         (udpEndpointLocalAddress_val_ptr_len))) {
        snmp_log(LOG_ERR, "not enough space for value\n");
        return MFD_ERROR;
    }
    tbl_idx->udpEndpointLocalAddress_len =
        udpEndpointLocalAddress_val_ptr_len;
    memcpy(tbl_idx->udpEndpointLocalAddress,
           udpEndpointLocalAddress_val_ptr,
           udpEndpointLocalAddress_val_ptr_len *
           sizeof(udpEndpointLocalAddress_val_ptr[0]));

    /*
     * udpEndpointLocalPort(3)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H 
     */
    tbl_idx->udpEndpointLocalPort = udpEndpointLocalPort_val;

    /*
     * udpEndpointRemoteAddressType(4)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h 
     */
    tbl_idx->udpEndpointRemoteAddressType =
        udpEndpointRemoteAddressType_val;

    /*
     * udpEndpointRemoteAddress(5)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h 
     */
    tbl_idx->udpEndpointRemoteAddress_len = sizeof(tbl_idx->udpEndpointRemoteAddress) / sizeof(tbl_idx->udpEndpointRemoteAddress[0]);   /* max length */
    /*
     * make sure there is enough space for udpEndpointRemoteAddress data
     */
    if ((NULL == tbl_idx->udpEndpointRemoteAddress) ||
        (tbl_idx->udpEndpointRemoteAddress_len <
         (udpEndpointRemoteAddress_val_ptr_len))) {
        snmp_log(LOG_ERR, "not enough space for value\n");
        return MFD_ERROR;
    }
    tbl_idx->udpEndpointRemoteAddress_len =
        udpEndpointRemoteAddress_val_ptr_len;
    memcpy(tbl_idx->udpEndpointRemoteAddress,
           udpEndpointRemoteAddress_val_ptr,
           udpEndpointRemoteAddress_val_ptr_len *
           sizeof(udpEndpointRemoteAddress_val_ptr[0]));

    /*
     * udpEndpointRemotePort(6)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H 
     */
    tbl_idx->udpEndpointRemotePort = udpEndpointRemotePort_val;

    /*
     * udpEndpointInstance(7)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/h 
     */
    tbl_idx->udpEndpointInstance = udpEndpointInstance_val;


    return MFD_SUCCESS;
}                               /* udpEndpointTable_indexes_set_tbl_idx */

/**
 * @internal
 * set row context indexes
 *
 * @param reqreq_ctx the row context that needs updated indexes
 *
 * @retval MFD_SUCCESS     : success.
 * @retval MFD_ERROR       : other error.
 *
 * @remark
 *  This function sets the mib indexs, then updates the oid indexs
 *  from the mib index.
 */
int
udpEndpointTable_indexes_set(udpEndpointTable_rowreq_ctx * rowreq_ctx,
                             u_long udpEndpointLocalAddressType_val,
                             char *udpEndpointLocalAddress_val_ptr,
                             size_t udpEndpointLocalAddress_val_ptr_len,
                             u_long udpEndpointLocalPort_val,
                             u_long udpEndpointRemoteAddressType_val,
                             char *udpEndpointRemoteAddress_val_ptr,
                             size_t udpEndpointRemoteAddress_val_ptr_len,
                             u_long udpEndpointRemotePort_val,
                             u_long udpEndpointInstance_val)
{
    DEBUGMSGTL(("verbose:udpEndpointTable:udpEndpointTable_indexes_set",
                "called\n"));

    if (MFD_SUCCESS !=
        udpEndpointTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx,
                                             udpEndpointLocalAddressType_val,
                                             udpEndpointLocalAddress_val_ptr,
                                             udpEndpointLocalAddress_val_ptr_len,
                                             udpEndpointLocalPort_val,
                                             udpEndpointRemoteAddressType_val,
                                             udpEndpointRemoteAddress_val_ptr,
                                             udpEndpointRemoteAddress_val_ptr_len,
                                             udpEndpointRemotePort_val,
                                             udpEndpointInstance_val))
        return MFD_ERROR;

    /*
     * convert mib index to oid index
     */
    rowreq_ctx->oid_idx.len = sizeof(rowreq_ctx->oid_tmp) / sizeof(oid);
    if (0 != udpEndpointTable_index_to_oid(&rowreq_ctx->oid_idx,
                                           &rowreq_ctx->tbl_idx)) {
        return MFD_ERROR;
    }

    return MFD_SUCCESS;
}                               /* udpEndpointTable_indexes_set */


/*---------------------------------------------------------------------
 * UDP-MIB::udpEndpointEntry.udpEndpointProcess
 * udpEndpointProcess is subid 8 of udpEndpointEntry.
 * Its status is Current, and its access level is ReadOnly.
 * OID: .1.3.6.1.2.1.7.7.1.8
 * Description:
The system's process ID for the process associated with
            this endpoint, or zero if there is no such process.
            This value is expected to be the same as
            HOST-RESOURCES-MIB::hrSWRunIndex or SYSAPPL-MIB::
            sysApplElmtRunIndex for some row in the appropriate
            tables.
 *
 * Attributes:
 *   accessible 1     isscalar 0     enums  0      hasdefval 0
 *   readable   1     iscolumn 1     ranges 0      hashint   0
 *   settable   0
 *
 *
 * Its syntax is UNSIGNED32 (based on perltype UNSIGNED32)
 * The net-snmp type is ASN_UNSIGNED. The C type decl is u_long (u_long)
 */
/**
 * Extract the current value of the udpEndpointProcess data.
 *
 * Set a value using the data context for the row.
 *
 * @param rowreq_ctx
 *        Pointer to the row request context.
 * @param udpEndpointProcess_val_ptr
 *        Pointer to storage for a u_long variable
 *
 * @retval MFD_SUCCESS         : success
 * @retval MFD_SKIP            : skip this node (no value for now)
 * @retval MFD_ERROR           : Any other error
 */
int
udpEndpointProcess_get(udpEndpointTable_rowreq_ctx * rowreq_ctx,
                       u_long * udpEndpointProcess_val_ptr)
{
   /** we should have a non-NULL pointer */
    netsnmp_assert(NULL != udpEndpointProcess_val_ptr);


    DEBUGMSGTL(("verbose:udpEndpointTable:udpEndpointProcess_get",
                "called\n"));

    netsnmp_assert(NULL != rowreq_ctx);

    /*
     * TODO:231:o: |-> Extract the current value of the udpEndpointProcess data.
     * copy (* udpEndpointProcess_val_ptr ) from rowreq_ctx->data
     */
    (*udpEndpointProcess_val_ptr) = rowreq_ctx->data.udpEndpointProcess;

    return MFD_SUCCESS;
}                               /* udpEndpointProcess_get */



/** @} */
/** @} */
/** @{ */