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