| 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 ipv4InterfaceTable |
| 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 "ipv4InterfaceTable.h" |
| 24 |
|
| 25 |
#include <net-snmp/agent/mib_modules.h> |
| 26 |
|
| 27 |
#include "ipv4InterfaceTable_interface.h" |
| 28 |
|
| 29 |
const oid ipv4InterfaceTable_oid[] = { IPV4INTERFACETABLE_OID }; |
| 30 |
const int ipv4InterfaceTable_oid_size = |
| 31 |
OID_LENGTH(ipv4InterfaceTable_oid); |
| 32 |
|
| 33 |
ipv4InterfaceTable_registration ipv4InterfaceTable_user_context; |
| 34 |
static ipv4InterfaceTable_registration *ipv4InterfaceTable_user_context_p; |
| 35 |
|
| 36 |
static void shutdown_table_ipv4InterfaceTable(void); |
| 37 |
|
| 38 |
|
| 39 |
/** |
| 40 |
* Initializes the ipv4InterfaceTable module |
| 41 |
*/ |
| 42 |
void |
| 43 |
init_ipv4InterfaceTable(void) |
| 44 |
{ |
| 45 |
DEBUGMSGTL(("verbose:ipv4InterfaceTable:init_ipv4InterfaceTable", |
| 46 |
"called\n")); |
| 47 |
|
| 48 |
/* |
| 49 |
* TODO:300:o: Perform ipv4InterfaceTable one-time module initialization. |
| 50 |
*/ |
| 51 |
|
| 52 |
/* |
| 53 |
* we depend on the ifTable, so we put our init in with it |
| 54 |
* to guarantee order of execution. |
| 55 |
*/ |
| 56 |
init_ifTable(); |
| 57 |
|
| 58 |
/* |
| 59 |
* last changed should be 0 at startup |
| 60 |
*/ |
| 61 |
ipv4InterfaceTable_lastChange_set(0); |
| 62 |
|
| 63 |
} /* init_ipv4InterfaceTable */ |
| 64 |
|
| 65 |
/** |
| 66 |
* Shut-down the ipv4InterfaceTable module (agent is exiting) |
| 67 |
*/ |
| 68 |
void |
| 69 |
shutdown_ipv4InterfaceTable(void) |
| 70 |
{ |
| 71 |
if (should_init("ipv4InterfaceTable")) |
| 72 |
shutdown_table_ipv4InterfaceTable(); |
| 73 |
|
| 74 |
} |
| 75 |
|
| 76 |
/** |
| 77 |
* Initialize the table ipv4InterfaceTable |
| 78 |
* (Define its contents and how it's structured) |
| 79 |
*/ |
| 80 |
void |
| 81 |
initialize_table_ipv4InterfaceTable(void) |
| 82 |
{ |
| 83 |
u_long flags; |
| 84 |
|
| 85 |
DEBUGMSGTL(("verbose:ipv4InterfaceTable:initialize_table_ipv4InterfaceTable", "called\n")); |
| 86 |
|
| 87 |
/* |
| 88 |
* TODO:301:o: Perform ipv4InterfaceTable one-time table initialization. |
| 89 |
*/ |
| 90 |
|
| 91 |
/* |
| 92 |
* TODO:302:o: |->Initialize ipv4InterfaceTable user context |
| 93 |
* if you'd like to pass in a pointer to some data for this |
| 94 |
* table, allocate or set it up here. |
| 95 |
*/ |
| 96 |
/* |
| 97 |
* a netsnmp_data_list is a simple way to store void pointers. A simple |
| 98 |
* string token is used to add, find or remove pointers. |
| 99 |
*/ |
| 100 |
ipv4InterfaceTable_user_context_p = |
| 101 |
netsnmp_create_data_list("ipv4InterfaceTable", NULL, NULL); |
| 102 |
|
| 103 |
/* |
| 104 |
* No support for any flags yet, but in the future you would |
| 105 |
* set any flags here. |
| 106 |
*/ |
| 107 |
flags = 0; |
| 108 |
|
| 109 |
/* |
| 110 |
* call interface initialization code |
| 111 |
*/ |
| 112 |
_ipv4InterfaceTable_initialize_interface |
| 113 |
(ipv4InterfaceTable_user_context_p, flags); |
| 114 |
} /* initialize_table_ipv4InterfaceTable */ |
| 115 |
|
| 116 |
/** |
| 117 |
* Shutdown the table ipv4InterfaceTable |
| 118 |
*/ |
| 119 |
void |
| 120 |
shutdown_table_ipv4InterfaceTable(void) |
| 121 |
{ |
| 122 |
/* |
| 123 |
* call interface shutdown code |
| 124 |
*/ |
| 125 |
_ipv4InterfaceTable_shutdown_interface |
| 126 |
(ipv4InterfaceTable_user_context_p); |
| 127 |
netsnmp_free_all_list_data(ipv4InterfaceTable_user_context_p); |
| 128 |
ipv4InterfaceTable_user_context_p = NULL; |
| 129 |
} |
| 130 |
|
| 131 |
/** |
| 132 |
* extra context initialization (eg default values) |
| 133 |
* |
| 134 |
* @param rowreq_ctx : row request context |
| 135 |
* @param user_init_ctx : void pointer for user (parameter to rowreq_ctx_allocate) |
| 136 |
* |
| 137 |
* @retval MFD_SUCCESS : no errors |
| 138 |
* @retval MFD_ERROR : error (context allocate will fail) |
| 139 |
*/ |
| 140 |
int |
| 141 |
ipv4InterfaceTable_rowreq_ctx_init(ipv4InterfaceTable_rowreq_ctx * |
| 142 |
rowreq_ctx, void *user_init_ctx) |
| 143 |
{ |
| 144 |
DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_rowreq_ctx_init", "called\n")); |
| 145 |
|
| 146 |
netsnmp_assert(NULL != rowreq_ctx); |
| 147 |
|
| 148 |
/* |
| 149 |
* TODO:210:o: |-> Perform extra ipv4InterfaceTable rowreq initialization. (eg DEFVALS) |
| 150 |
*/ |
| 151 |
rowreq_ctx->data.ipv4InterfaceRetransmitTime = 1000; |
| 152 |
|
| 153 |
|
| 154 |
return MFD_SUCCESS; |
| 155 |
} /* ipv4InterfaceTable_rowreq_ctx_init */ |
| 156 |
|
| 157 |
/** |
| 158 |
* extra context cleanup |
| 159 |
* @param rowreq_ctx |
| 160 |
* |
| 161 |
*/ |
| 162 |
void |
| 163 |
ipv4InterfaceTable_rowreq_ctx_cleanup(ipv4InterfaceTable_rowreq_ctx * |
| 164 |
rowreq_ctx) |
| 165 |
{ |
| 166 |
DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_rowreq_ctx_cleanup", "called\n")); |
| 167 |
|
| 168 |
netsnmp_assert(NULL != rowreq_ctx); |
| 169 |
|
| 170 |
/* |
| 171 |
* TODO:211:o: |-> Perform extra ipv4InterfaceTable rowreq cleanup. |
| 172 |
*/ |
| 173 |
} /* ipv4InterfaceTable_rowreq_ctx_cleanup */ |
| 174 |
|
| 175 |
/** |
| 176 |
* pre-request callback |
| 177 |
* |
| 178 |
* @param user_context |
| 179 |
* |
| 180 |
* @retval MFD_SUCCESS : success. |
| 181 |
* @retval MFD_ERROR : other error |
| 182 |
*/ |
| 183 |
int |
| 184 |
ipv4InterfaceTable_pre_request(ipv4InterfaceTable_registration * |
| 185 |
user_context) |
| 186 |
{ |
| 187 |
DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_pre_request", "called\n")); |
| 188 |
|
| 189 |
/* |
| 190 |
* TODO:510:o: Perform ipv4InterfaceTable pre-request actions. |
| 191 |
*/ |
| 192 |
|
| 193 |
return MFD_SUCCESS; |
| 194 |
} /* ipv4InterfaceTable_pre_request */ |
| 195 |
|
| 196 |
/** |
| 197 |
* post-request callback |
| 198 |
* |
| 199 |
* Note: |
| 200 |
* New rows have been inserted into the container, and |
| 201 |
* deleted rows have been removed from the container and |
| 202 |
* released. |
| 203 |
* |
| 204 |
* @param user_context |
| 205 |
* @param rc : MFD_SUCCESS if all requests succeeded |
| 206 |
* |
| 207 |
* @retval MFD_SUCCESS : success. |
| 208 |
* @retval MFD_ERROR : other error (ignored) |
| 209 |
*/ |
| 210 |
int |
| 211 |
ipv4InterfaceTable_post_request(ipv4InterfaceTable_registration * |
| 212 |
user_context, int rc) |
| 213 |
{ |
| 214 |
DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_post_request", "called\n")); |
| 215 |
|
| 216 |
/* |
| 217 |
* TODO:511:o: Perform ipv4InterfaceTable post-request actions. |
| 218 |
*/ |
| 219 |
|
| 220 |
/* |
| 221 |
* check to set if any rows were changed. |
| 222 |
*/ |
| 223 |
if (ipv4InterfaceTable_dirty_get()) { |
| 224 |
/* |
| 225 |
* check if request was successful. If so, this would be |
| 226 |
* a good place to save data to its persistent store. |
| 227 |
*/ |
| 228 |
if (MFD_SUCCESS == rc) { |
| 229 |
/* |
| 230 |
* save changed rows, if you haven't already |
| 231 |
*/ |
| 232 |
} |
| 233 |
|
| 234 |
ipv4InterfaceTable_dirty_set(0); /* clear table dirty flag */ |
| 235 |
} |
| 236 |
|
| 237 |
return MFD_SUCCESS; |
| 238 |
} /* ipv4InterfaceTable_post_request */ |
| 239 |
|
| 240 |
|
| 241 |
/********************************************************************** |
| 242 |
********************************************************************** |
| 243 |
*** |
| 244 |
*** Table ipv4InterfaceTable |
| 245 |
*** |
| 246 |
********************************************************************** |
| 247 |
**********************************************************************/ |
| 248 |
/* |
| 249 |
* IP-MIB::ipv4InterfaceTable is subid 28 of ip. |
| 250 |
* Its status is Current. |
| 251 |
* OID: .1.3.6.1.2.1.4.28, length: 8 |
| 252 |
*/ |
| 253 |
|
| 254 |
/* |
| 255 |
* --------------------------------------------------------------------- |
| 256 |
* * TODO:200:r: Implement ipv4InterfaceTable data context functions. |
| 257 |
*/ |
| 258 |
|
| 259 |
|
| 260 |
/*--------------------------------------------------------------------- |
| 261 |
* IP-MIB::ipv4InterfaceEntry.ipv4InterfaceReasmMaxSize |
| 262 |
* ipv4InterfaceReasmMaxSize is subid 2 of ipv4InterfaceEntry. |
| 263 |
* Its status is Current, and its access level is ReadOnly. |
| 264 |
* OID: .1.3.6.1.2.1.4.28.1.2 |
| 265 |
* Description: |
| 266 |
The size of the largest IPv4 datagram which this entity can |
| 267 |
re-assemble from incoming IPv4 fragmented datagrams received |
| 268 |
on this interface. |
| 269 |
* |
| 270 |
* Attributes: |
| 271 |
* accessible 1 isscalar 0 enums 0 hasdefval 0 |
| 272 |
* readable 1 iscolumn 1 ranges 1 hashint 0 |
| 273 |
* settable 0 |
| 274 |
* |
| 275 |
* Ranges: 0 - 65535; |
| 276 |
* |
| 277 |
* Its syntax is INTEGER32 (based on perltype INTEGER32) |
| 278 |
* The net-snmp type is ASN_INTEGER. The C type decl is long (long) |
| 279 |
*/ |
| 280 |
/** |
| 281 |
* Extract the current value of the ipv4InterfaceReasmMaxSize data. |
| 282 |
* |
| 283 |
* Set a value using the data context for the row. |
| 284 |
* |
| 285 |
* @param rowreq_ctx |
| 286 |
* Pointer to the row request context. |
| 287 |
* @param ipv4InterfaceReasmMaxSize_val_ptr |
| 288 |
* Pointer to storage for a long variable |
| 289 |
* |
| 290 |
* @retval MFD_SUCCESS : success |
| 291 |
* @retval MFD_SKIP : skip this node (no value for now) |
| 292 |
* @retval MFD_ERROR : Any other error |
| 293 |
*/ |
| 294 |
int |
| 295 |
ipv4InterfaceReasmMaxSize_get(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx, |
| 296 |
long *ipv4InterfaceReasmMaxSize_val_ptr) |
| 297 |
{ |
| 298 |
/** we should have a non-NULL pointer */ |
| 299 |
netsnmp_assert(NULL != ipv4InterfaceReasmMaxSize_val_ptr); |
| 300 |
|
| 301 |
|
| 302 |
DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceReasmMaxSize_get", |
| 303 |
"called\n")); |
| 304 |
|
| 305 |
netsnmp_assert(NULL != rowreq_ctx); |
| 306 |
|
| 307 |
if (! |
| 308 |
(rowreq_ctx->data.ifentry-> |
| 309 |
ns_flags & NETSNMP_INTERFACE_FLAGS_HAS_V4_REASMMAX)) |
| 310 |
return MFD_SKIP; |
| 311 |
|
| 312 |
/* |
| 313 |
* TODO:231:o: |-> Extract the current value of the ipv4InterfaceReasmMaxSize data. |
| 314 |
* copy (* ipv4InterfaceReasmMaxSize_val_ptr ) from rowreq_ctx->data |
| 315 |
*/ |
| 316 |
(*ipv4InterfaceReasmMaxSize_val_ptr) = |
| 317 |
rowreq_ctx->data.ipv4InterfaceReasmMaxSize; |
| 318 |
|
| 319 |
return MFD_SUCCESS; |
| 320 |
} /* ipv4InterfaceReasmMaxSize_get */ |
| 321 |
|
| 322 |
/*--------------------------------------------------------------------- |
| 323 |
* IP-MIB::ipv4InterfaceEntry.ipv4InterfaceEnableStatus |
| 324 |
* ipv4InterfaceEnableStatus is subid 3 of ipv4InterfaceEntry. |
| 325 |
* Its status is Current, and its access level is ReadWrite. |
| 326 |
* OID: .1.3.6.1.2.1.4.28.1.3 |
| 327 |
* Description: |
| 328 |
The indication of whether IPv4 is enabled (up) or disabled |
| 329 |
(down) on this interface. This object does not affect the |
| 330 |
state of the interface itself, only its connection to an |
| 331 |
IPv4 stack. The IF-MIB should be used to control the state |
| 332 |
of the interface. |
| 333 |
* |
| 334 |
* Attributes: |
| 335 |
* accessible 1 isscalar 0 enums 1 hasdefval 0 |
| 336 |
* readable 1 iscolumn 1 ranges 0 hashint 0 |
| 337 |
* settable 1 |
| 338 |
* |
| 339 |
* Enum range: 1/8. Values: up(1), down(2) |
| 340 |
* |
| 341 |
* Its syntax is INTEGER (based on perltype INTEGER) |
| 342 |
* The net-snmp type is ASN_INTEGER. The C type decl is long (u_long) |
| 343 |
*/ |
| 344 |
/** |
| 345 |
* Extract the current value of the ipv4InterfaceEnableStatus data. |
| 346 |
* |
| 347 |
* Set a value using the data context for the row. |
| 348 |
* |
| 349 |
* @param rowreq_ctx |
| 350 |
* Pointer to the row request context. |
| 351 |
* @param ipv4InterfaceEnableStatus_val_ptr |
| 352 |
* Pointer to storage for a long variable |
| 353 |
* |
| 354 |
* @retval MFD_SUCCESS : success |
| 355 |
* @retval MFD_SKIP : skip this node (no value for now) |
| 356 |
* @retval MFD_ERROR : Any other error |
| 357 |
*/ |
| 358 |
int |
| 359 |
ipv4InterfaceEnableStatus_get(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx, |
| 360 |
u_long * ipv4InterfaceEnableStatus_val_ptr) |
| 361 |
{ |
| 362 |
/** we should have a non-NULL pointer */ |
| 363 |
netsnmp_assert(NULL != ipv4InterfaceEnableStatus_val_ptr); |
| 364 |
|
| 365 |
|
| 366 |
DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceEnableStatus_get", |
| 367 |
"called\n")); |
| 368 |
|
| 369 |
netsnmp_assert(NULL != rowreq_ctx); |
| 370 |
|
| 371 |
/* |
| 372 |
* TODO:231:o: |-> Extract the current value of the ipv4InterfaceEnableStatus data. |
| 373 |
* copy (* ipv4InterfaceEnableStatus_val_ptr ) from rowreq_ctx->data |
| 374 |
*/ |
| 375 |
(*ipv4InterfaceEnableStatus_val_ptr) = |
| 376 |
rowreq_ctx->data.ipv4InterfaceEnableStatus; |
| 377 |
|
| 378 |
return MFD_SUCCESS; |
| 379 |
} /* ipv4InterfaceEnableStatus_get */ |
| 380 |
|
| 381 |
/*--------------------------------------------------------------------- |
| 382 |
* IP-MIB::ipv4InterfaceEntry.ipv4InterfaceRetransmitTime |
| 383 |
* ipv4InterfaceRetransmitTime is subid 4 of ipv4InterfaceEntry. |
| 384 |
* Its status is Current, and its access level is ReadOnly. |
| 385 |
* OID: .1.3.6.1.2.1.4.28.1.4 |
| 386 |
* Description: |
| 387 |
The time between retransmissions of ARP requests to a |
| 388 |
neighbor when resolving the address or when probing the |
| 389 |
reachability of a neighbor. |
| 390 |
* |
| 391 |
* Attributes: |
| 392 |
* accessible 1 isscalar 0 enums 0 hasdefval 1 |
| 393 |
* readable 1 iscolumn 1 ranges 0 hashint 0 |
| 394 |
* settable 0 |
| 395 |
* defval: 1000 |
| 396 |
* |
| 397 |
* |
| 398 |
* Its syntax is UNSIGNED32 (based on perltype UNSIGNED32) |
| 399 |
* The net-snmp type is ASN_UNSIGNED. The C type decl is u_long (u_long) |
| 400 |
*/ |
| 401 |
/** |
| 402 |
* Extract the current value of the ipv4InterfaceRetransmitTime data. |
| 403 |
* |
| 404 |
* Set a value using the data context for the row. |
| 405 |
* |
| 406 |
* @param rowreq_ctx |
| 407 |
* Pointer to the row request context. |
| 408 |
* @param ipv4InterfaceRetransmitTime_val_ptr |
| 409 |
* Pointer to storage for a u_long variable |
| 410 |
* |
| 411 |
* @retval MFD_SUCCESS : success |
| 412 |
* @retval MFD_SKIP : skip this node (no value for now) |
| 413 |
* @retval MFD_ERROR : Any other error |
| 414 |
*/ |
| 415 |
int |
| 416 |
ipv4InterfaceRetransmitTime_get(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx, |
| 417 |
u_long * |
| 418 |
ipv4InterfaceRetransmitTime_val_ptr) |
| 419 |
{ |
| 420 |
/** we should have a non-NULL pointer */ |
| 421 |
netsnmp_assert(NULL != ipv4InterfaceRetransmitTime_val_ptr); |
| 422 |
|
| 423 |
|
| 424 |
DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceRetransmitTime_get", "called\n")); |
| 425 |
|
| 426 |
netsnmp_assert(NULL != rowreq_ctx); |
| 427 |
|
| 428 |
if (! |
| 429 |
(rowreq_ctx->data.ifentry-> |
| 430 |
ns_flags & NETSNMP_INTERFACE_FLAGS_HAS_V4_RETRANSMIT)) |
| 431 |
return MFD_SKIP; |
| 432 |
|
| 433 |
/* |
| 434 |
* TODO:231:o: |-> Extract the current value of the ipv4InterfaceRetransmitTime data. |
| 435 |
* copy (* ipv4InterfaceRetransmitTime_val_ptr ) from rowreq_ctx->data |
| 436 |
*/ |
| 437 |
(*ipv4InterfaceRetransmitTime_val_ptr) = |
| 438 |
rowreq_ctx->data.ipv4InterfaceRetransmitTime; |
| 439 |
|
| 440 |
return MFD_SUCCESS; |
| 441 |
} /* ipv4InterfaceRetransmitTime_get */ |
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
/** @} */ |
| 446 |
/********************************************************************** |
| 447 |
********************************************************************** |
| 448 |
*** |
| 449 |
*** Table ipv4InterfaceTable |
| 450 |
*** |
| 451 |
********************************************************************** |
| 452 |
**********************************************************************/ |
| 453 |
/* |
| 454 |
* IP-MIB::ipv4InterfaceTable is subid 28 of ip. |
| 455 |
* Its status is Current. |
| 456 |
* OID: .1.3.6.1.2.1.4.28, length: 8 |
| 457 |
*/ |
| 458 |
/* |
| 459 |
* NOTE: if you update this chart, please update the versions in |
| 460 |
* local/mib2c-conf.d/parent-set.m2i |
| 461 |
* agent/mibgroup/helpers/baby_steps.c |
| 462 |
* while you're at it. |
| 463 |
*/ |
| 464 |
/* |
| 465 |
*********************************************************************** |
| 466 |
* Baby Steps Flow Chart (2004.06.05) * |
| 467 |
* * |
| 468 |
* +--------------+ +================+ U = unconditional path * |
| 469 |
* |optional state| ||required state|| S = path for success * |
| 470 |
* +--------------+ +================+ E = path for error * |
| 471 |
*********************************************************************** |
| 472 |
* |
| 473 |
* +--------------+ |
| 474 |
* | pre | |
| 475 |
* | request | |
| 476 |
* +--------------+ |
| 477 |
* | U |
| 478 |
* +==============+ |
| 479 |
* +----------------|| object || |
| 480 |
* | E || lookup || |
| 481 |
* | +==============+ |
| 482 |
* | | S |
| 483 |
* | +==============+ |
| 484 |
* | E || check || |
| 485 |
* |<---------------|| values || |
| 486 |
* | +==============+ |
| 487 |
* | | S |
| 488 |
* | +==============+ |
| 489 |
* | +<-------|| undo || |
| 490 |
* | | E || setup || |
| 491 |
* | | +==============+ |
| 492 |
* | | | S |
| 493 |
* | | +==============+ |
| 494 |
* | | || set ||-------------------------->+ |
| 495 |
* | | || value || E | |
| 496 |
* | | +==============+ | |
| 497 |
* | | | S | |
| 498 |
* | | +--------------+ | |
| 499 |
* | | | check |-------------------------->| |
| 500 |
* | | | consistency | E | |
| 501 |
* | | +--------------+ | |
| 502 |
* | | | S | |
| 503 |
* | | +==============+ +==============+ | |
| 504 |
* | | || commit ||-------->|| undo || | |
| 505 |
* | | || || E || commit || | |
| 506 |
* | | +==============+ +==============+ | |
| 507 |
* | | | S U |<--------+ |
| 508 |
* | | +--------------+ +==============+ |
| 509 |
* | | | irreversible | || undo || |
| 510 |
* | | | commit | || set || |
| 511 |
* | | +--------------+ +==============+ |
| 512 |
* | | | U U | |
| 513 |
* | +-------------->|<------------------------+ |
| 514 |
* | +==============+ |
| 515 |
* | || undo || |
| 516 |
* | || cleanup || |
| 517 |
* | +==============+ |
| 518 |
* +---------------------->| U |
| 519 |
* +--------------+ |
| 520 |
* | post | |
| 521 |
* | request | |
| 522 |
* +--------------+ |
| 523 |
* |
| 524 |
*/ |
| 525 |
|
| 526 |
/** |
| 527 |
* Setup up context with information needed to undo a set request. |
| 528 |
* |
| 529 |
* This function will be called before the individual node undo setup |
| 530 |
* functions are called. If you need to do any undo setup that is not |
| 531 |
* related to a specific column, you can do it here. |
| 532 |
* |
| 533 |
* Note that the undo context has been allocated with |
| 534 |
* ipv4InterfaceTable_allocate_data(), but may need extra |
| 535 |
* initialization similar to what you may have done in |
| 536 |
* ipv4InterfaceTable_rowreq_ctx_init(). |
| 537 |
* Note that an individual node's undo_setup function will only be called |
| 538 |
* if that node is being set to a new value. |
| 539 |
* |
| 540 |
* If there is any setup specific to a particular column (e.g. allocating |
| 541 |
* memory for a string), you should do that setup in the node's undo_setup |
| 542 |
* function, so it won't be done unless it is necessary. |
| 543 |
* |
| 544 |
* @param rowreq_ctx |
| 545 |
* Pointer to the table context (ipv4InterfaceTable_rowreq_ctx) |
| 546 |
* |
| 547 |
* @retval MFD_SUCCESS : success |
| 548 |
* @retval MFD_ERROR : error. set will fail. |
| 549 |
*/ |
| 550 |
int |
| 551 |
ipv4InterfaceTable_undo_setup(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx) |
| 552 |
{ |
| 553 |
int rc = MFD_SUCCESS; |
| 554 |
|
| 555 |
DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_undo_setup", |
| 556 |
"called\n")); |
| 557 |
|
| 558 |
/** we should have a non-NULL pointer */ |
| 559 |
netsnmp_assert(NULL != rowreq_ctx); |
| 560 |
|
| 561 |
/* |
| 562 |
* TODO:451:M: |-> Setup ipv4InterfaceTable undo. |
| 563 |
* set up ipv4InterfaceTable undo information, in preparation for a set. |
| 564 |
* Undo storage is in (* ipv4InterfaceRetransmitTime_val_ptr )* |
| 565 |
*/ |
| 566 |
|
| 567 |
return rc; |
| 568 |
} /* ipv4InterfaceTable_undo_setup */ |
| 569 |
|
| 570 |
/** |
| 571 |
* Undo a set request. |
| 572 |
* |
| 573 |
* This function will be called before the individual node undo |
| 574 |
* functions are called. If you need to do any undo that is not |
| 575 |
* related to a specific column, you can do it here. |
| 576 |
* |
| 577 |
* Note that an individual node's undo function will only be called |
| 578 |
* if that node is being set to a new value. |
| 579 |
* |
| 580 |
* If there is anything specific to a particular column (e.g. releasing |
| 581 |
* memory for a string), you should do that setup in the node's undo |
| 582 |
* function, so it won't be done unless it is necessary. |
| 583 |
* |
| 584 |
* @param rowreq_ctx |
| 585 |
* Pointer to the table context (ipv4InterfaceTable_rowreq_ctx) |
| 586 |
* |
| 587 |
* @retval MFD_SUCCESS : success |
| 588 |
* @retval MFD_ERROR : error. set will fail. |
| 589 |
*/ |
| 590 |
int |
| 591 |
ipv4InterfaceTable_undo(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx) |
| 592 |
{ |
| 593 |
int rc = MFD_SUCCESS; |
| 594 |
|
| 595 |
DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_undo", |
| 596 |
"called\n")); |
| 597 |
|
| 598 |
/** we should have a non-NULL pointer */ |
| 599 |
netsnmp_assert(NULL != rowreq_ctx); |
| 600 |
|
| 601 |
/* |
| 602 |
* TODO:451:M: |-> ipv4InterfaceTable undo. |
| 603 |
* ipv4InterfaceTable undo information, in response to a failed set. |
| 604 |
* Undo storage is in (* ipv4InterfaceRetransmitTime_val_ptr )* |
| 605 |
*/ |
| 606 |
|
| 607 |
return rc; |
| 608 |
} /* ipv4InterfaceTable_undo_setup */ |
| 609 |
|
| 610 |
/** |
| 611 |
* Cleanup up context undo information. |
| 612 |
* |
| 613 |
* This function will be called after set/commit processing. If you |
| 614 |
* allocated any resources in undo_setup, this is the place to release |
| 615 |
* those resources. |
| 616 |
* |
| 617 |
* This function is called regardless of the success or failure of the set |
| 618 |
* request. If you need to perform different steps for cleanup depending |
| 619 |
* on success or failure, you can add a flag to the rowreq_ctx. |
| 620 |
* |
| 621 |
* @param rowreq_ctx |
| 622 |
* Pointer to the table context (ipv4InterfaceTable_rowreq_ctx) |
| 623 |
* |
| 624 |
* @retval MFD_SUCCESS : success |
| 625 |
* @retval MFD_ERROR : error |
| 626 |
*/ |
| 627 |
int |
| 628 |
ipv4InterfaceTable_undo_cleanup(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx) |
| 629 |
{ |
| 630 |
int rc = MFD_SUCCESS; |
| 631 |
|
| 632 |
DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_undo_cleanup", "called\n")); |
| 633 |
|
| 634 |
/** we should have a non-NULL pointer */ |
| 635 |
netsnmp_assert(NULL != rowreq_ctx); |
| 636 |
|
| 637 |
/* |
| 638 |
* TODO:452:M: |-> Cleanup ipv4InterfaceTable undo. |
| 639 |
* Undo storage is in (* ipv4InterfaceRetransmitTime_val_ptr )* |
| 640 |
*/ |
| 641 |
|
| 642 |
return rc; |
| 643 |
} /* ipv4InterfaceTable_undo_cleanup */ |
| 644 |
|
| 645 |
/** |
| 646 |
* commit new values. |
| 647 |
* |
| 648 |
* At this point, you should have done everything you can to ensure that |
| 649 |
* this commit will not fail. |
| 650 |
* |
| 651 |
* Should you need different behavior depending on which columns were |
| 652 |
* set, rowreq_ctx->column_set_flags will indicate which writeable columns were |
| 653 |
* set. The definitions for the COLUMN_*_FLAG bits can be found in |
| 654 |
* ipv4InterfaceTable.h. |
| 655 |
* A new row will have the MFD_ROW_CREATED bit set in rowreq_flags. |
| 656 |
* |
| 657 |
* @param rowreq_ctx |
| 658 |
* Pointer to the users context. |
| 659 |
* |
| 660 |
* @retval MFD_SUCCESS : success |
| 661 |
* @retval MFD_ERROR : error |
| 662 |
*/ |
| 663 |
int |
| 664 |
ipv4InterfaceTable_commit(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx) |
| 665 |
{ |
| 666 |
int rc = MFD_SUCCESS; |
| 667 |
int save_flags; |
| 668 |
|
| 669 |
DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_commit", |
| 670 |
"called\n")); |
| 671 |
|
| 672 |
/** we should have a non-NULL pointer */ |
| 673 |
netsnmp_assert(NULL != rowreq_ctx); |
| 674 |
|
| 675 |
/* |
| 676 |
* save flags, then clear until we actually do something |
| 677 |
*/ |
| 678 |
save_flags = rowreq_ctx->column_set_flags; |
| 679 |
rowreq_ctx->column_set_flags = 0; |
| 680 |
|
| 681 |
/* |
| 682 |
* commit ipv4InterfaceTable data |
| 683 |
* 1) check the column's flag in save_flags to see if it was set. |
| 684 |
* 2) clear the flag when you handle that column |
| 685 |
* 3) set the column's flag in column_set_flags if it needs undo |
| 686 |
* processing in case of a failure. |
| 687 |
*/ |
| 688 |
if (save_flags & COLUMN_IPV4INTERFACEENABLESTATUS_FLAG) { |
| 689 |
save_flags &= ~COLUMN_IPV4INTERFACEENABLESTATUS_FLAG; /* clear ipv4InterfaceEnableStatus */ |
| 690 |
/* |
| 691 |
* TODO:482:o: |-> commit column ipv4InterfaceEnableStatus. |
| 692 |
*/ |
| 693 |
rc = -1; |
| 694 |
if (-1 == rc) { |
| 695 |
snmp_log(LOG_ERR, |
| 696 |
"ipv4InterfaceTable column ipv4InterfaceEnableStatus commit failed\n"); |
| 697 |
} else { |
| 698 |
/* |
| 699 |
* set flag, in case we need to undo ipv4InterfaceEnableStatus |
| 700 |
*/ |
| 701 |
rowreq_ctx->column_set_flags |= |
| 702 |
COLUMN_IPV4INTERFACEENABLESTATUS_FLAG; |
| 703 |
} |
| 704 |
} |
| 705 |
|
| 706 |
/* |
| 707 |
* if we successfully committed this row, set the dirty flag. |
| 708 |
*/ |
| 709 |
if (MFD_SUCCESS == rc) { |
| 710 |
rowreq_ctx->rowreq_flags |= MFD_ROW_DIRTY; |
| 711 |
} |
| 712 |
|
| 713 |
if (save_flags) { |
| 714 |
snmp_log(LOG_ERR, "unhandled columns (0x%x) in commit\n", |
| 715 |
save_flags); |
| 716 |
return MFD_ERROR; |
| 717 |
} |
| 718 |
|
| 719 |
return rc; |
| 720 |
} /* ipv4InterfaceTable_commit */ |
| 721 |
|
| 722 |
/** |
| 723 |
* undo commit new values. |
| 724 |
* |
| 725 |
* Should you need different behavior depending on which columns were |
| 726 |
* set, rowreq_ctx->column_set_flags will indicate which writeable columns were |
| 727 |
* set. The definitions for the COLUMN_*_FLAG bits can be found in |
| 728 |
* ipv4InterfaceTable.h. |
| 729 |
* A new row will have the MFD_ROW_CREATED bit set in rowreq_flags. |
| 730 |
* |
| 731 |
* @param rowreq_ctx |
| 732 |
* Pointer to the users context. |
| 733 |
* |
| 734 |
* @retval MFD_SUCCESS : success |
| 735 |
* @retval MFD_ERROR : error |
| 736 |
*/ |
| 737 |
int |
| 738 |
ipv4InterfaceTable_undo_commit(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx) |
| 739 |
{ |
| 740 |
int rc = MFD_SUCCESS; |
| 741 |
|
| 742 |
DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_undo_commit", "called\n")); |
| 743 |
|
| 744 |
/** we should have a non-NULL pointer */ |
| 745 |
netsnmp_assert(NULL != rowreq_ctx); |
| 746 |
|
| 747 |
/* |
| 748 |
* TODO:485:M: |-> Undo ipv4InterfaceTable commit. |
| 749 |
* check the column's flag in rowreq_ctx->column_set_flags to see |
| 750 |
* if it was set during commit, then undo it. |
| 751 |
* |
| 752 |
* eg: if (rowreq_ctx->column_set_flags & COLUMN__FLAG) {} |
| 753 |
*/ |
| 754 |
|
| 755 |
|
| 756 |
/* |
| 757 |
* if we successfully un-committed this row, clear the dirty flag. |
| 758 |
*/ |
| 759 |
if (MFD_SUCCESS == rc) { |
| 760 |
rowreq_ctx->rowreq_flags &= ~MFD_ROW_DIRTY; |
| 761 |
} |
| 762 |
|
| 763 |
return rc; |
| 764 |
} /* ipv4InterfaceTable_undo_commit */ |
| 765 |
|
| 766 |
/* |
| 767 |
* TODO:440:M: Implement ipv4InterfaceTable node value checks. |
| 768 |
* TODO:450:M: Implement ipv4InterfaceTable undo functions. |
| 769 |
* TODO:460:M: Implement ipv4InterfaceTable set functions. |
| 770 |
* TODO:480:M: Implement ipv4InterfaceTable commit functions. |
| 771 |
*/ |
| 772 |
/*--------------------------------------------------------------------- |
| 773 |
* IP-MIB::ipv4InterfaceEntry.ipv4InterfaceEnableStatus |
| 774 |
* ipv4InterfaceEnableStatus is subid 3 of ipv4InterfaceEntry. |
| 775 |
* Its status is Current, and its access level is ReadWrite. |
| 776 |
* OID: .1.3.6.1.2.1.4.28.1.3 |
| 777 |
* Description: |
| 778 |
The indication of whether IPv4 is enabled (up) or disabled |
| 779 |
(down) on this interface. This object does not affect the |
| 780 |
state of the interface itself, only its connection to an |
| 781 |
IPv4 stack. The IF-MIB should be used to control the state |
| 782 |
of the interface. |
| 783 |
* |
| 784 |
* Attributes: |
| 785 |
* accessible 1 isscalar 0 enums 1 hasdefval 0 |
| 786 |
* readable 1 iscolumn 1 ranges 0 hashint 0 |
| 787 |
* settable 1 |
| 788 |
* |
| 789 |
* Enum range: 1/8. Values: up(1), down(2) |
| 790 |
* |
| 791 |
* Its syntax is INTEGER (based on perltype INTEGER) |
| 792 |
* The net-snmp type is ASN_INTEGER. The C type decl is long (u_long) |
| 793 |
*/ |
| 794 |
/** |
| 795 |
* Check that the proposed new value is potentially valid. |
| 796 |
* |
| 797 |
* @param rowreq_ctx |
| 798 |
* Pointer to the row request context. |
| 799 |
* @param ipv4InterfaceEnableStatus_val |
| 800 |
* A long containing the new value. |
| 801 |
* |
| 802 |
* @retval MFD_SUCCESS : incoming value is legal |
| 803 |
* @retval MFD_NOT_VALID_NOW : incoming value is not valid now |
| 804 |
* @retval MFD_NOT_VALID_EVER : incoming value is never valid |
| 805 |
* |
| 806 |
* This is the place to check for requirements that are not |
| 807 |
* expressed in the mib syntax (for example, a requirement that |
| 808 |
* is detailed in the description for an object). |
| 809 |
* |
| 810 |
* You should check that the requested change between the undo value and the |
| 811 |
* new value is legal (ie, the transistion from one value to another |
| 812 |
* is legal). |
| 813 |
* |
| 814 |
*@note |
| 815 |
* This check is only to determine if the new value |
| 816 |
* is \b potentially valid. This is the first check of many, and |
| 817 |
* is one of the simplest ones. |
| 818 |
* |
| 819 |
*@note |
| 820 |
* this is not the place to do any checks for values |
| 821 |
* which depend on some other value in the mib. Those |
| 822 |
* types of checks should be done in the |
| 823 |
* ipv4InterfaceTable_check_dependencies() function. |
| 824 |
* |
| 825 |
* The following checks have already been done for you: |
| 826 |
* The syntax is ASN_INTEGER |
| 827 |
* The value is one of up(1), down(2) |
| 828 |
* |
| 829 |
* If there a no other checks you need to do, simply return MFD_SUCCESS. |
| 830 |
* |
| 831 |
*/ |
| 832 |
int |
| 833 |
ipv4InterfaceEnableStatus_check_value(ipv4InterfaceTable_rowreq_ctx * |
| 834 |
rowreq_ctx, |
| 835 |
u_long ipv4InterfaceEnableStatus_val) |
| 836 |
{ |
| 837 |
DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceEnableStatus_check_value", "called\n")); |
| 838 |
|
| 839 |
/** should never get a NULL pointer */ |
| 840 |
netsnmp_assert(NULL != rowreq_ctx); |
| 841 |
|
| 842 |
/* |
| 843 |
* TODO:441:o: |-> Check for valid ipv4InterfaceEnableStatus value. |
| 844 |
*/ |
| 845 |
/* |
| 846 |
* did the access code set the flag indicating that we can control |
| 847 |
* individual protocols on this interface? |
| 848 |
*/ |
| 849 |
if (rowreq_ctx->data.ifentry->ns_flags & |
| 850 |
NETSNMP_INTERFACE_FLAGS_CAN_DOWN_PROTOCOL); |
| 851 |
else |
| 852 |
return MFD_NOT_VALID_EVER; |
| 853 |
|
| 854 |
return MFD_SUCCESS; /* ipv4InterfaceEnableStatus value not illegal */ |
| 855 |
} /* ipv4InterfaceEnableStatus_check_value */ |
| 856 |
|
| 857 |
/** |
| 858 |
* Save old value information |
| 859 |
* |
| 860 |
* @param rowreq_ctx |
| 861 |
* Pointer to the table context (ipv4InterfaceTable_rowreq_ctx) |
| 862 |
* |
| 863 |
* @retval MFD_SUCCESS : success |
| 864 |
* @retval MFD_ERROR : error. set will fail. |
| 865 |
* |
| 866 |
* This function will be called after the table level undo setup function |
| 867 |
* ipv4InterfaceTable_undo_setup has been called. |
| 868 |
* |
| 869 |
*@note |
| 870 |
* this function will only be called if a new value is set for this column. |
| 871 |
* |
| 872 |
* If there is any setup specific to a particular column (e.g. allocating |
| 873 |
* memory for a string), you should do that setup in this function, so it |
| 874 |
* won't be done unless it is necessary. |
| 875 |
*/ |
| 876 |
int |
| 877 |
ipv4InterfaceEnableStatus_undo_setup(ipv4InterfaceTable_rowreq_ctx * |
| 878 |
rowreq_ctx) |
| 879 |
{ |
| 880 |
DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceEnableStatus_undo_setup", "called\n")); |
| 881 |
|
| 882 |
/** should never get a NULL pointer */ |
| 883 |
netsnmp_assert(NULL != rowreq_ctx); |
| 884 |
|
| 885 |
/* |
| 886 |
* TODO:455:o: |-> Setup ipv4InterfaceEnableStatus undo. |
| 887 |
*/ |
| 888 |
/* |
| 889 |
* copy ipv4InterfaceEnableStatus data |
| 890 |
* set rowreq_ctx->undo->ipv4InterfaceEnableStatus from rowreq_ctx->data.ipv4InterfaceEnableStatus |
| 891 |
*/ |
| 892 |
rowreq_ctx->undo->ipv4InterfaceEnableStatus = |
| 893 |
rowreq_ctx->data.ipv4InterfaceEnableStatus; |
| 894 |
|
| 895 |
|
| 896 |
return MFD_SUCCESS; |
| 897 |
} /* ipv4InterfaceEnableStatus_undo_setup */ |
| 898 |
|
| 899 |
/** |
| 900 |
* Set the new value. |
| 901 |
* |
| 902 |
* @param rowreq_ctx |
| 903 |
* Pointer to the users context. You should know how to |
| 904 |
* manipulate the value from this object. |
| 905 |
* @param ipv4InterfaceEnableStatus_val |
| 906 |
* A long containing the new value. |
| 907 |
*/ |
| 908 |
int |
| 909 |
ipv4InterfaceEnableStatus_set(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx, |
| 910 |
u_long ipv4InterfaceEnableStatus_val) |
| 911 |
{ |
| 912 |
|
| 913 |
DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceEnableStatus_set", |
| 914 |
"called\n")); |
| 915 |
|
| 916 |
/** should never get a NULL pointer */ |
| 917 |
netsnmp_assert(NULL != rowreq_ctx); |
| 918 |
|
| 919 |
/* |
| 920 |
* TODO:461:M: |-> Set ipv4InterfaceEnableStatus value. |
| 921 |
* set ipv4InterfaceEnableStatus value in rowreq_ctx->data |
| 922 |
*/ |
| 923 |
rowreq_ctx->data.ipv4InterfaceEnableStatus = |
| 924 |
ipv4InterfaceEnableStatus_val; |
| 925 |
|
| 926 |
return MFD_SUCCESS; |
| 927 |
} /* ipv4InterfaceEnableStatus_set */ |
| 928 |
|
| 929 |
/** |
| 930 |
* undo the previous set. |
| 931 |
* |
| 932 |
* @param rowreq_ctx |
| 933 |
* Pointer to the users context. |
| 934 |
*/ |
| 935 |
int |
| 936 |
ipv4InterfaceEnableStatus_undo(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx) |
| 937 |
{ |
| 938 |
|
| 939 |
DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceEnableStatus_undo", "called\n")); |
| 940 |
|
| 941 |
netsnmp_assert(NULL != rowreq_ctx); |
| 942 |
|
| 943 |
/* |
| 944 |
* TODO:456:o: |-> Clean up ipv4InterfaceEnableStatus undo. |
| 945 |
*/ |
| 946 |
/* |
| 947 |
* copy ipv4InterfaceEnableStatus data |
| 948 |
* set rowreq_ctx->data.ipv4InterfaceEnableStatus from rowreq_ctx->undo->ipv4InterfaceEnableStatus |
| 949 |
*/ |
| 950 |
rowreq_ctx->data.ipv4InterfaceEnableStatus = |
| 951 |
rowreq_ctx->undo->ipv4InterfaceEnableStatus; |
| 952 |
|
| 953 |
|
| 954 |
return MFD_SUCCESS; |
| 955 |
} /* ipv4InterfaceEnableStatus_undo */ |
| 956 |
|
| 957 |
/** @} */ |
| 958 |
/** @{ */ |