| 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 "sctpAssocRemAddrTable.h" |
| 11 |
|
| 12 |
/* |
| 13 |
* content of the sctpAssocRemAddrTable |
| 14 |
*/ |
| 15 |
static netsnmp_container *sctpAssocRemAddrTable_container; |
| 16 |
static netsnmp_table_registration_info *table_info; |
| 17 |
|
| 18 |
/** Initializes the sctpAssocRemAddrTable module */ |
| 19 |
void |
| 20 |
init_sctpAssocRemAddrTable(void) |
| 21 |
{ |
| 22 |
/* |
| 23 |
* here we initialize all the tables we're planning on supporting |
| 24 |
*/ |
| 25 |
initialize_table_sctpAssocRemAddrTable(); |
| 26 |
} |
| 27 |
|
| 28 |
void |
| 29 |
shutdown_sctpAssocRemAddrTable(void) |
| 30 |
{ |
| 31 |
shutdown_table_sctpAssocRemAddrTable(); |
| 32 |
} |
| 33 |
|
| 34 |
/** Initialize the sctpAssocRemAddrTable table by defining its contents and how it's structured */ |
| 35 |
void |
| 36 |
initialize_table_sctpAssocRemAddrTable(void) |
| 37 |
{ |
| 38 |
static oid sctpAssocRemAddrTable_oid[] = |
| 39 |
{ 1, 3, 6, 1, 2, 1, 104, 1, 5 }; |
| 40 |
size_t sctpAssocRemAddrTable_oid_len = |
| 41 |
OID_LENGTH(sctpAssocRemAddrTable_oid); |
| 42 |
netsnmp_handler_registration *reg = NULL; |
| 43 |
netsnmp_mib_handler *handler = NULL; |
| 44 |
netsnmp_container *container = NULL; |
| 45 |
|
| 46 |
reg = |
| 47 |
netsnmp_create_handler_registration("sctpAssocRemAddrTable", |
| 48 |
sctpAssocRemAddrTable_handler, |
| 49 |
sctpAssocRemAddrTable_oid, |
| 50 |
sctpAssocRemAddrTable_oid_len, |
| 51 |
HANDLER_CAN_RONLY); |
| 52 |
if (NULL == reg) { |
| 53 |
snmp_log(LOG_ERR, |
| 54 |
"error creating handler registration for sctpAssocRemAddrTable\n"); |
| 55 |
goto bail; |
| 56 |
} |
| 57 |
|
| 58 |
container = |
| 59 |
netsnmp_container_find("sctpAssocRemAddrTable:table_container"); |
| 60 |
if (NULL == container) { |
| 61 |
snmp_log(LOG_ERR, |
| 62 |
"error creating container for sctpAssocRemAddrTable\n"); |
| 63 |
goto bail; |
| 64 |
} |
| 65 |
sctpAssocRemAddrTable_container = container; |
| 66 |
|
| 67 |
table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info); |
| 68 |
if (NULL == table_info) { |
| 69 |
snmp_log(LOG_ERR, |
| 70 |
"error allocating table registration for sctpAssocRemAddrTable\n"); |
| 71 |
goto bail; |
| 72 |
} |
| 73 |
netsnmp_table_helper_add_indexes(table_info, ASN_UNSIGNED, /* index: sctpAssocId */ |
| 74 |
ASN_INTEGER, /* index: sctpAssocRemAddrType */ |
| 75 |
ASN_OCTET_STR, /* index: sctpAssocRemAddr */ |
| 76 |
0); |
| 77 |
table_info->min_column = COLUMN_SCTPASSOCREMADDRACTIVE; |
| 78 |
table_info->max_column = COLUMN_SCTPASSOCREMADDRSTARTTIME; |
| 79 |
|
| 80 |
/************************************************* |
| 81 |
* |
| 82 |
* inject container_table helper |
| 83 |
*/ |
| 84 |
handler = netsnmp_container_table_handler_get(table_info, container, |
| 85 |
TABLE_CONTAINER_KEY_NETSNMP_INDEX); |
| 86 |
if (NULL == handler) { |
| 87 |
snmp_log(LOG_ERR, |
| 88 |
"error allocating table registration for sctpAssocRemAddrTable\n"); |
| 89 |
goto bail; |
| 90 |
} |
| 91 |
if (SNMPERR_SUCCESS != netsnmp_inject_handler(reg, handler)) { |
| 92 |
snmp_log(LOG_ERR, |
| 93 |
"error injecting container_table handler for sctpAssocRemAddrTable\n"); |
| 94 |
goto bail; |
| 95 |
} |
| 96 |
handler = NULL; /* reg has it, will reuse below */ |
| 97 |
|
| 98 |
/* |
| 99 |
* register the table |
| 100 |
*/ |
| 101 |
if (SNMPERR_SUCCESS != netsnmp_register_table(reg, table_info)) { |
| 102 |
snmp_log(LOG_ERR, |
| 103 |
"error registering table handler for sctpAssocRemAddrTable\n"); |
| 104 |
reg = NULL; /* it was freed inside netsnmp_register_table */ |
| 105 |
goto bail; |
| 106 |
} |
| 107 |
|
| 108 |
/* |
| 109 |
* Initialise the contents of the table here |
| 110 |
*/ |
| 111 |
|
| 112 |
|
| 113 |
return; /* ok */ |
| 114 |
|
| 115 |
/* |
| 116 |
* Some error occurred during registration. Clean up and bail. |
| 117 |
*/ |
| 118 |
bail: /* not ok */ |
| 119 |
|
| 120 |
if (handler) |
| 121 |
netsnmp_handler_free(handler); |
| 122 |
|
| 123 |
if (table_info) |
| 124 |
netsnmp_table_registration_info_free(table_info); |
| 125 |
|
| 126 |
if (container) |
| 127 |
CONTAINER_FREE(container); |
| 128 |
|
| 129 |
if (reg) |
| 130 |
netsnmp_handler_registration_free(reg); |
| 131 |
} |
| 132 |
|
| 133 |
void |
| 134 |
shutdown_table_sctpAssocRemAddrTable(void) |
| 135 |
{ |
| 136 |
if (table_info) { |
| 137 |
netsnmp_table_registration_info_free(table_info); |
| 138 |
table_info = NULL; |
| 139 |
} |
| 140 |
sctpAssocRemAddrTable_container_clear(sctpAssocRemAddrTable_container); |
| 141 |
} |
| 142 |
|
| 143 |
|
| 144 |
/** handles requests for the sctpAssocRemAddrTable table */ |
| 145 |
int |
| 146 |
sctpAssocRemAddrTable_handler(netsnmp_mib_handler *handler, |
| 147 |
netsnmp_handler_registration *reginfo, |
| 148 |
netsnmp_agent_request_info *reqinfo, |
| 149 |
netsnmp_request_info *requests) |
| 150 |
{ |
| 151 |
|
| 152 |
netsnmp_request_info *request; |
| 153 |
netsnmp_table_request_info *table_info; |
| 154 |
sctpAssocRemAddrTable_entry *table_entry; |
| 155 |
|
| 156 |
switch (reqinfo->mode) { |
| 157 |
/* |
| 158 |
* Read-support (also covers GetNext requests) |
| 159 |
*/ |
| 160 |
case MODE_GET: |
| 161 |
for (request = requests; request; request = request->next) { |
| 162 |
if (request->processed) |
| 163 |
continue; |
| 164 |
table_entry = (sctpAssocRemAddrTable_entry *) |
| 165 |
netsnmp_container_table_extract_context(request); |
| 166 |
table_info = netsnmp_extract_table_info(request); |
| 167 |
if ((NULL == table_entry) || (NULL == table_info)) { |
| 168 |
snmp_log(LOG_ERR, |
| 169 |
"could not extract table entry or info for sctpAssocRemAddrTable\n"); |
| 170 |
snmp_set_var_typed_value(request->requestvb, |
| 171 |
SNMP_ERR_GENERR, NULL, 0); |
| 172 |
continue; |
| 173 |
} |
| 174 |
|
| 175 |
switch (table_info->colnum) { |
| 176 |
case COLUMN_SCTPASSOCREMADDRACTIVE: |
| 177 |
if (!table_entry) { |
| 178 |
netsnmp_set_request_error(reqinfo, request, |
| 179 |
SNMP_NOSUCHINSTANCE); |
| 180 |
continue; |
| 181 |
} |
| 182 |
snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, |
| 183 |
table_entry->sctpAssocRemAddrActive); |
| 184 |
break; |
| 185 |
case COLUMN_SCTPASSOCREMADDRHBACTIVE: |
| 186 |
if (!table_entry) { |
| 187 |
netsnmp_set_request_error(reqinfo, request, |
| 188 |
SNMP_NOSUCHINSTANCE); |
| 189 |
continue; |
| 190 |
} |
| 191 |
snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, |
| 192 |
table_entry->sctpAssocRemAddrHBActive); |
| 193 |
break; |
| 194 |
case COLUMN_SCTPASSOCREMADDRRTO: |
| 195 |
if (!table_entry) { |
| 196 |
netsnmp_set_request_error(reqinfo, request, |
| 197 |
SNMP_NOSUCHINSTANCE); |
| 198 |
continue; |
| 199 |
} |
| 200 |
snmp_set_var_typed_integer(request->requestvb, |
| 201 |
ASN_UNSIGNED, |
| 202 |
table_entry->sctpAssocRemAddrRTO); |
| 203 |
break; |
| 204 |
case COLUMN_SCTPASSOCREMADDRMAXPATHRTX: |
| 205 |
if (!table_entry) { |
| 206 |
netsnmp_set_request_error(reqinfo, request, |
| 207 |
SNMP_NOSUCHINSTANCE); |
| 208 |
continue; |
| 209 |
} |
| 210 |
snmp_set_var_typed_integer(request->requestvb, |
| 211 |
ASN_UNSIGNED, |
| 212 |
table_entry->sctpAssocRemAddrMaxPathRtx); |
| 213 |
break; |
| 214 |
case COLUMN_SCTPASSOCREMADDRRTX: |
| 215 |
if (!table_entry) { |
| 216 |
netsnmp_set_request_error(reqinfo, request, |
| 217 |
SNMP_NOSUCHINSTANCE); |
| 218 |
continue; |
| 219 |
} |
| 220 |
snmp_set_var_typed_integer(request->requestvb, ASN_COUNTER, |
| 221 |
table_entry->sctpAssocRemAddrRtx); |
| 222 |
break; |
| 223 |
case COLUMN_SCTPASSOCREMADDRSTARTTIME: |
| 224 |
if (!table_entry) { |
| 225 |
netsnmp_set_request_error(reqinfo, request, |
| 226 |
SNMP_NOSUCHINSTANCE); |
| 227 |
continue; |
| 228 |
} |
| 229 |
snmp_set_var_typed_integer(request->requestvb, |
| 230 |
ASN_TIMETICKS, |
| 231 |
table_entry->sctpAssocRemAddrStartTime); |
| 232 |
break; |
| 233 |
default: |
| 234 |
netsnmp_set_request_error(reqinfo, request, |
| 235 |
SNMP_NOSUCHOBJECT); |
| 236 |
break; |
| 237 |
} |
| 238 |
} |
| 239 |
break; |
| 240 |
|
| 241 |
} |
| 242 |
return SNMP_ERR_NOERROR; |
| 243 |
} |
| 244 |
|
| 245 |
sctpAssocRemAddrTable_entry * |
| 246 |
sctpAssocRemAddrTable_entry_create(void) |
| 247 |
{ |
| 248 |
sctpAssocRemAddrTable_entry *entry = |
| 249 |
SNMP_MALLOC_TYPEDEF(sctpAssocRemAddrTable_entry); |
| 250 |
if (entry != NULL) { |
| 251 |
entry->oid_index.len = SCTP_ASSOC_REM_ADDR_TABLE_INDEX_SIZE; |
| 252 |
entry->oid_index.oids = entry->oid_tmp; |
| 253 |
} |
| 254 |
|
| 255 |
return entry; |
| 256 |
} |
| 257 |
|
| 258 |
int |
| 259 |
sctpAssocRemAddrTable_entry_update_index(sctpAssocRemAddrTable_entry * |
| 260 |
entry) |
| 261 |
{ |
| 262 |
int err = 0; |
| 263 |
|
| 264 |
netsnmp_variable_list var_sctpAssocId; |
| 265 |
netsnmp_variable_list var_sctpAssocRemAddrType; |
| 266 |
netsnmp_variable_list var_sctpAssocRemAddr; |
| 267 |
|
| 268 |
/* |
| 269 |
* prepare the values to be converted |
| 270 |
*/ |
| 271 |
memset(&var_sctpAssocId, 0, sizeof(var_sctpAssocId)); |
| 272 |
var_sctpAssocId.type = ASN_UNSIGNED; |
| 273 |
memset(&var_sctpAssocRemAddrType, 0, sizeof(var_sctpAssocRemAddrType)); |
| 274 |
var_sctpAssocRemAddrType.type = ASN_INTEGER; |
| 275 |
memset(&var_sctpAssocRemAddr, 0, sizeof(var_sctpAssocRemAddr)); |
| 276 |
var_sctpAssocRemAddr.type = ASN_OCTET_STR; |
| 277 |
|
| 278 |
var_sctpAssocId.next_variable = &var_sctpAssocRemAddrType; |
| 279 |
var_sctpAssocRemAddrType.next_variable = &var_sctpAssocRemAddr; |
| 280 |
var_sctpAssocRemAddr.next_variable = NULL; |
| 281 |
|
| 282 |
snmp_set_var_value(&var_sctpAssocId, (u_char *) & entry->sctpAssocId, |
| 283 |
sizeof(entry->sctpAssocId)); |
| 284 |
snmp_set_var_value(&var_sctpAssocRemAddrType, |
| 285 |
(u_char *) & entry->sctpAssocRemAddrType, |
| 286 |
sizeof(entry->sctpAssocRemAddrType)); |
| 287 |
snmp_set_var_value(&var_sctpAssocRemAddr, |
| 288 |
(u_char *) & entry->sctpAssocRemAddr, |
| 289 |
entry->sctpAssocRemAddr_len * |
| 290 |
sizeof(entry->sctpAssocRemAddr[0])); |
| 291 |
|
| 292 |
/* |
| 293 |
* convert it |
| 294 |
*/ |
| 295 |
err = |
| 296 |
build_oid_noalloc(entry->oid_index.oids, entry->oid_index.len, |
| 297 |
&entry->oid_index.len, NULL, 0, |
| 298 |
&var_sctpAssocId); |
| 299 |
if (err) |
| 300 |
snmp_log(LOG_ERR, "error %d converting index to oid\n", err); |
| 301 |
|
| 302 |
/* |
| 303 |
* release any memory allocated during the conversion |
| 304 |
*/ |
| 305 |
snmp_reset_var_buffers(&var_sctpAssocId); |
| 306 |
|
| 307 |
return err; |
| 308 |
|
| 309 |
} |
| 310 |
|
| 311 |
void |
| 312 |
sctpAssocRemAddrTable_entry_copy(sctpAssocRemAddrTable_entry * from, |
| 313 |
sctpAssocRemAddrTable_entry * to) |
| 314 |
{ |
| 315 |
memcpy(to, from, sizeof(sctpAssocRemAddrTable_entry)); |
| 316 |
to->oid_index.oids = to->oid_tmp; |
| 317 |
} |
| 318 |
|
| 319 |
void |
| 320 |
sctpAssocRemAddrTable_entry_free(sctpAssocRemAddrTable_entry * entry) |
| 321 |
{ |
| 322 |
SNMP_FREE(entry); |
| 323 |
} |
| 324 |
|
| 325 |
netsnmp_container * |
| 326 |
sctpAssocRemAddrTable_get_container(void) |
| 327 |
{ |
| 328 |
return sctpAssocRemAddrTable_container; |
| 329 |
} |
| 330 |
|
| 331 |
|
| 332 |
static void |
| 333 |
sctpAssocRemAddrTable_entry_clear(void *what, void *magic) |
| 334 |
{ |
| 335 |
sctpAssocRemAddrTable_entry_free(what); |
| 336 |
} |
| 337 |
|
| 338 |
void |
| 339 |
sctpAssocRemAddrTable_container_clear(netsnmp_container *container) |
| 340 |
{ |
| 341 |
CONTAINER_CLEAR(container, sctpAssocRemAddrTable_entry_clear, NULL); |
| 342 |
} |