| 1 |
/* |
| 2 |
* Note: this file originally auto-generated by mib2c using |
| 3 |
* version : 14170 $ of $ |
| 4 |
* |
| 5 |
* $Id:$ |
| 6 |
*/ |
| 7 |
/** \page MFD helper for etherStatsTable |
| 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 "etherStatsTable.h" |
| 24 |
|
| 25 |
#include <net-snmp/agent/mib_modules.h> |
| 26 |
|
| 27 |
#include "etherStatsTable_interface.h" |
| 28 |
|
| 29 |
oid etherStatsTable_oid[] = { ETHERSTATSTABLE_OID }; |
| 30 |
int etherStatsTable_oid_size = OID_LENGTH(etherStatsTable_oid); |
| 31 |
|
| 32 |
etherStatsTable_registration etherStatsTable_user_context; |
| 33 |
static etherStatsTable_registration *etherStatsTable_user_context_p; |
| 34 |
|
| 35 |
void initialize_table_etherStatsTable(void); |
| 36 |
void shutdown_table_etherStatsTable(void); |
| 37 |
|
| 38 |
|
| 39 |
/** |
| 40 |
* Initializes the etherStatsTable module |
| 41 |
*/ |
| 42 |
void |
| 43 |
init_etherStatsTable(void) |
| 44 |
{ |
| 45 |
DEBUGMSGTL(("verbose:etherStatsTable:init_etherStatsTable", |
| 46 |
"called\n")); |
| 47 |
|
| 48 |
/* |
| 49 |
* TODO:300:o: Perform etherStatsTable one-time module initialization. |
| 50 |
*/ |
| 51 |
|
| 52 |
/* |
| 53 |
* here we initialize all the tables we're planning on supporting |
| 54 |
*/ |
| 55 |
if (should_init("etherStatsTable")) |
| 56 |
initialize_table_etherStatsTable(); |
| 57 |
|
| 58 |
} /* init_etherStatsTable */ |
| 59 |
|
| 60 |
/** |
| 61 |
* Shut-down the etherStatsTable module (agent is exiting) |
| 62 |
*/ |
| 63 |
void |
| 64 |
shutdown_etherStatsTable(void) |
| 65 |
{ |
| 66 |
if (should_init("etherStatsTable")) |
| 67 |
shutdown_table_etherStatsTable(); |
| 68 |
|
| 69 |
} |
| 70 |
|
| 71 |
/** |
| 72 |
* Initialize the table etherStatsTable |
| 73 |
* (Define its contents and how it's structured) |
| 74 |
*/ |
| 75 |
void |
| 76 |
initialize_table_etherStatsTable(void) |
| 77 |
{ |
| 78 |
u_long flags; |
| 79 |
|
| 80 |
DEBUGMSGTL(("verbose:etherStatsTable:initialize_table_etherStatsTable", |
| 81 |
"called\n")); |
| 82 |
|
| 83 |
/* |
| 84 |
* TODO:301:o: Perform etherStatsTable one-time table initialization. |
| 85 |
*/ |
| 86 |
|
| 87 |
/* |
| 88 |
* TODO:302:o: |->Initialize etherStatsTable 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 |
etherStatsTable_user_context_p |
| 97 |
= netsnmp_create_data_list("etherStatsTable", 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 |
_etherStatsTable_initialize_interface |
| 109 |
(etherStatsTable_user_context_p, flags); |
| 110 |
} /* initialize_table_etherStatsTable */ |
| 111 |
|
| 112 |
/** |
| 113 |
* Shutdown the table etherStatsTable |
| 114 |
*/ |
| 115 |
void |
| 116 |
shutdown_table_etherStatsTable(void) |
| 117 |
{ |
| 118 |
/* |
| 119 |
* call interface shutdown code |
| 120 |
*/ |
| 121 |
_etherStatsTable_shutdown_interface(etherStatsTable_user_context_p); |
| 122 |
netsnmp_free_all_list_data(etherStatsTable_user_context_p); |
| 123 |
etherStatsTable_user_context_p = NULL; |
| 124 |
} |
| 125 |
|
| 126 |
/** |
| 127 |
* extra context initialization (eg default values) |
| 128 |
* |
| 129 |
* @param rowreq_ctx : row request context |
| 130 |
* @param user_init_ctx : void pointer for user (parameter to rowreq_ctx_allocate) |
| 131 |
* |
| 132 |
* @retval MFD_SUCCESS : no errors |
| 133 |
* @retval MFD_ERROR : error (context allocate will fail) |
| 134 |
*/ |
| 135 |
int |
| 136 |
etherStatsTable_rowreq_ctx_init(etherStatsTable_rowreq_ctx * rowreq_ctx, |
| 137 |
void *user_init_ctx) |
| 138 |
{ |
| 139 |
DEBUGMSGTL(("verbose:etherStatsTable:etherStatsTable_rowreq_ctx_init", |
| 140 |
"called\n")); |
| 141 |
|
| 142 |
netsnmp_assert(NULL != rowreq_ctx); |
| 143 |
|
| 144 |
/* |
| 145 |
* TODO:210:o: |-> Perform extra etherStatsTable rowreq initialization. (eg DEFVALS) |
| 146 |
*/ |
| 147 |
|
| 148 |
return MFD_SUCCESS; |
| 149 |
} /* etherStatsTable_rowreq_ctx_init */ |
| 150 |
|
| 151 |
/** |
| 152 |
* extra context cleanup |
| 153 |
* |
| 154 |
*/ |
| 155 |
void |
| 156 |
etherStatsTable_rowreq_ctx_cleanup(etherStatsTable_rowreq_ctx * rowreq_ctx) |
| 157 |
{ |
| 158 |
DEBUGMSGTL(("verbose:etherStatsTable:etherStatsTable_rowreq_ctx_cleanup", "called\n")); |
| 159 |
|
| 160 |
netsnmp_assert(NULL != rowreq_ctx); |
| 161 |
|
| 162 |
/* |
| 163 |
* TODO:211:o: |-> Perform extra etherStatsTable rowreq cleanup. |
| 164 |
*/ |
| 165 |
} /* etherStatsTable_rowreq_ctx_cleanup */ |
| 166 |
|
| 167 |
/** |
| 168 |
* pre-request callback |
| 169 |
* |
| 170 |
* |
| 171 |
* @retval MFD_SUCCESS : success. |
| 172 |
* @retval MFD_ERROR : other error |
| 173 |
*/ |
| 174 |
int |
| 175 |
etherStatsTable_pre_request(etherStatsTable_registration * user_context) |
| 176 |
{ |
| 177 |
DEBUGMSGTL(("verbose:etherStatsTable:etherStatsTable_pre_request", |
| 178 |
"called\n")); |
| 179 |
|
| 180 |
/* |
| 181 |
* TODO:510:o: Perform etherStatsTable pre-request actions. |
| 182 |
*/ |
| 183 |
|
| 184 |
return MFD_SUCCESS; |
| 185 |
} /* etherStatsTable_pre_request */ |
| 186 |
|
| 187 |
/** |
| 188 |
* post-request callback |
| 189 |
* |
| 190 |
* Note: |
| 191 |
* New rows have been inserted into the container, and |
| 192 |
* deleted rows have been removed from the container and |
| 193 |
* released. |
| 194 |
* |
| 195 |
* @param user_context |
| 196 |
* @param rc : MFD_SUCCESS if all requests succeeded |
| 197 |
* |
| 198 |
* @retval MFD_SUCCESS : success. |
| 199 |
* @retval MFD_ERROR : other error (ignored) |
| 200 |
*/ |
| 201 |
int |
| 202 |
etherStatsTable_post_request(etherStatsTable_registration * user_context, |
| 203 |
int rc) |
| 204 |
{ |
| 205 |
DEBUGMSGTL(("verbose:etherStatsTable:etherStatsTable_post_request", |
| 206 |
"called\n")); |
| 207 |
|
| 208 |
/* |
| 209 |
* TODO:511:o: Perform etherStatsTable post-request actions. |
| 210 |
*/ |
| 211 |
|
| 212 |
/* |
| 213 |
* check to set if any rows were changed. |
| 214 |
*/ |
| 215 |
if (etherStatsTable_dirty_get()) { |
| 216 |
/* |
| 217 |
* check if request was successful. If so, this would be |
| 218 |
* a good place to save data to its persistent store. |
| 219 |
*/ |
| 220 |
if (MFD_SUCCESS == rc) { |
| 221 |
/* |
| 222 |
* save changed rows, if you haven't already |
| 223 |
*/ |
| 224 |
} |
| 225 |
|
| 226 |
etherStatsTable_dirty_set(0); /* clear table dirty flag */ |
| 227 |
} |
| 228 |
|
| 229 |
return MFD_SUCCESS; |
| 230 |
} /* etherStatsTable_post_request */ |
| 231 |
|
| 232 |
|
| 233 |
/** @{ */ |