| 1 |
/* |
| 2 |
* Note: this file originally auto-generated by mib2c using |
| 3 |
* version : 1.17 $ of : mfd-data-access.m2c,v $ |
| 4 |
* |
| 5 |
* $Id$ |
| 6 |
*/ |
| 7 |
/* |
| 8 |
* standard Net-SNMP includes |
| 9 |
*/ |
| 10 |
#include <net-snmp/net-snmp-config.h> |
| 11 |
#include <net-snmp/net-snmp-includes.h> |
| 12 |
#include <net-snmp/agent/net-snmp-agent-includes.h> |
| 13 |
|
| 14 |
/* |
| 15 |
* include our parent header |
| 16 |
*/ |
| 17 |
#include "ipv4InterfaceTable.h" |
| 18 |
|
| 19 |
|
| 20 |
#include "ipv4InterfaceTable_data_access.h" |
| 21 |
|
| 22 |
|
| 23 |
/** @ingroup interface |
| 24 |
* @addtogroup data_access data_access: Routines to access data |
| 25 |
* |
| 26 |
* These routines are used to locate the data used to satisfy |
| 27 |
* requests. |
| 28 |
* |
| 29 |
* @{ |
| 30 |
*/ |
| 31 |
/********************************************************************** |
| 32 |
********************************************************************** |
| 33 |
*** |
| 34 |
*** Table ipv4InterfaceTable |
| 35 |
*** |
| 36 |
********************************************************************** |
| 37 |
**********************************************************************/ |
| 38 |
/* |
| 39 |
* IP-MIB::ipv4InterfaceTable is subid 28 of ip. |
| 40 |
* Its status is Current. |
| 41 |
* OID: .1.3.6.1.2.1.4.28, length: 8 |
| 42 |
*/ |
| 43 |
|
| 44 |
/** |
| 45 |
* initialization for ipv4InterfaceTable data access |
| 46 |
* |
| 47 |
* This function is called during startup to allow you to |
| 48 |
* allocate any resources you need for the data table. |
| 49 |
* |
| 50 |
* @param ipv4InterfaceTable_reg |
| 51 |
* Pointer to ipv4InterfaceTable_registration |
| 52 |
* |
| 53 |
* @retval MFD_SUCCESS : success. |
| 54 |
* @retval MFD_ERROR : unrecoverable error. |
| 55 |
*/ |
| 56 |
int |
| 57 |
ipv4InterfaceTable_init_data(ipv4InterfaceTable_registration * |
| 58 |
ipv4InterfaceTable_reg) |
| 59 |
{ |
| 60 |
DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_init_data", |
| 61 |
"called\n")); |
| 62 |
|
| 63 |
/* |
| 64 |
* TODO:303:o: Initialize ipv4InterfaceTable data. |
| 65 |
*/ |
| 66 |
|
| 67 |
return MFD_SUCCESS; |
| 68 |
} /* ipv4InterfaceTable_init_data */ |
| 69 |
|
| 70 |
/** |
| 71 |
* container overview |
| 72 |
* |
| 73 |
*/ |
| 74 |
|
| 75 |
/** |
| 76 |
* container initialization |
| 77 |
* |
| 78 |
* @param container_ptr_ptr A pointer to a container pointer. If you |
| 79 |
* create a custom container, use this parameter to return it |
| 80 |
* to the MFD helper. If set to NULL, the MFD helper will |
| 81 |
* allocate a container for you. |
| 82 |
* |
| 83 |
* This function is called at startup to allow you to customize certain |
| 84 |
* aspects of the access method. For the most part, it is for advanced |
| 85 |
* users. The default code should suffice for most cases. If no custom |
| 86 |
* container is allocated, the MFD code will create one for your. |
| 87 |
* |
| 88 |
* @remark |
| 89 |
* This would also be a good place to do any initialization needed |
| 90 |
* for you data source. For example, opening a connection to another |
| 91 |
* process that will supply the data, opening a database, etc. |
| 92 |
*/ |
| 93 |
void |
| 94 |
ipv4InterfaceTable_container_init(netsnmp_container **container_ptr_ptr) |
| 95 |
{ |
| 96 |
DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_container_init", "called\n")); |
| 97 |
|
| 98 |
if (NULL == container_ptr_ptr) { |
| 99 |
snmp_log(LOG_ERR, |
| 100 |
"bad container param to ipv4InterfaceTable_container_init\n"); |
| 101 |
return; |
| 102 |
} |
| 103 |
|
| 104 |
/* |
| 105 |
* For advanced users, you can use a custom container. If you |
| 106 |
* do not create one, one will be created for you. |
| 107 |
*/ |
| 108 |
} /* ipv4InterfaceTable_container_init */ |
| 109 |
|
| 110 |
|
| 111 |
/** |
| 112 |
* @internal |
| 113 |
* determine if we want a ifTable row in our container |
| 114 |
*/ |
| 115 |
void |
| 116 |
ipv4InterfaceTable_check_entry_for_updates(const ifTable_rowreq_ctx * |
| 117 |
ift_rrc, |
| 118 |
netsnmp_interface_entry *entry) |
| 119 |
{ |
| 120 |
netsnmp_container *c = ipv4InterfaceTable_container_get(); |
| 121 |
ifTable_rowreq_ctx *ip4if_rrc; |
| 122 |
int changed = 0; |
| 123 |
|
| 124 |
DEBUGMSGTL(("verbose:ipv4InterfaceTable:check_entry_for_updates", |
| 125 |
"called\n")); |
| 126 |
|
| 127 |
/* |
| 128 |
* do we have a corresponding row? |
| 129 |
*/ |
| 130 |
ip4if_rrc = CONTAINER_FIND(c, ift_rrc); |
| 131 |
if (NULL == ip4if_rrc) { |
| 132 |
/* |
| 133 |
* no corresponding row. should we have one? |
| 134 |
*/ |
| 135 |
if ((NULL != entry) && |
| 136 |
(entry->ns_flags & NETSNMP_INTERFACE_FLAGS_HAS_IPV4)) { |
| 137 |
/* |
| 138 |
* yes. |
| 139 |
*/ |
| 140 |
DEBUGMSGTL(("ipv4InterfaceTable:check_entry_for_updates", |
| 141 |
"inserted row for %" NETSNMP_PRIo "d\n", entry->index)); |
| 142 |
CONTAINER_INSERT(c, ift_rrc); |
| 143 |
changed = 1; |
| 144 |
} |
| 145 |
} else { |
| 146 |
/* |
| 147 |
* found corresponding row. is it still applicable? |
| 148 |
*/ |
| 149 |
if ((NULL == entry) || |
| 150 |
(0 == (entry->ns_flags & NETSNMP_INTERFACE_FLAGS_HAS_IPV4))) { |
| 151 |
/* |
| 152 |
* no |
| 153 |
*/ |
| 154 |
DEBUGMSGTL(("ipv4InterfaceTable:check_entry_for_updates", |
| 155 |
"removed row for %" NETSNMP_PRIo "d\n", |
| 156 |
ift_rrc->data.ifentry->index)); |
| 157 |
CONTAINER_REMOVE(c, ift_rrc); |
| 158 |
changed = 1; |
| 159 |
} else { |
| 160 |
/* |
| 161 |
* still applicable. anything changed? |
| 162 |
*/ |
| 163 |
if ((entry->retransmit_v4 != |
| 164 |
ift_rrc->data.ifentry->retransmit_v4) || |
| 165 |
(entry->reasm_max_v4 != ift_rrc->data.ifentry->reasm_max_v4)) { |
| 166 |
DEBUGMSGTL(("ipv4InterfaceTable:check_entry_for_updates", |
| 167 |
"row changed for %" NETSNMP_PRIo "d\n", |
| 168 |
ift_rrc->data.ifentry->index)); |
| 169 |
changed = 1; |
| 170 |
} |
| 171 |
} |
| 172 |
} |
| 173 |
|
| 174 |
/* |
| 175 |
* if something changed, update table last changed |
| 176 |
*/ |
| 177 |
if (changed) |
| 178 |
ipv4InterfaceTable_lastChange_set(netsnmp_get_agent_uptime()); |
| 179 |
} |
| 180 |
|
| 181 |
|
| 182 |
/** |
| 183 |
* container shutdown |
| 184 |
* |
| 185 |
* @param container_ptr A pointer to the container. |
| 186 |
* |
| 187 |
* This function is called at shutdown to allow you to customize certain |
| 188 |
* aspects of the access method. For the most part, it is for advanced |
| 189 |
* users. The default code should suffice for most cases. |
| 190 |
* |
| 191 |
* This function is called before ipv4InterfaceTable_container_free(). |
| 192 |
* |
| 193 |
* @remark |
| 194 |
* This would also be a good place to do any cleanup needed |
| 195 |
* for you data source. For example, closing a connection to another |
| 196 |
* process that supplied the data, closing a database, etc. |
| 197 |
*/ |
| 198 |
void |
| 199 |
ipv4InterfaceTable_container_shutdown(netsnmp_container *container_ptr) |
| 200 |
{ |
| 201 |
DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_container_shutdown", "called\n")); |
| 202 |
|
| 203 |
if (NULL == container_ptr) { |
| 204 |
snmp_log(LOG_ERR, |
| 205 |
"bad params to ipv4InterfaceTable_container_shutdown\n"); |
| 206 |
return; |
| 207 |
} |
| 208 |
|
| 209 |
} /* ipv4InterfaceTable_container_shutdown */ |
| 210 |
|
| 211 |
/** |
| 212 |
* load initial data |
| 213 |
* |
| 214 |
* TODO:350:M: Implement ipv4InterfaceTable data load |
| 215 |
* |
| 216 |
* @param container container to which items should be inserted |
| 217 |
* |
| 218 |
* @retval MFD_SUCCESS : success. |
| 219 |
* @retval MFD_RESOURCE_UNAVAILABLE : Can't access data source |
| 220 |
* @retval MFD_ERROR : other error. |
| 221 |
* |
| 222 |
* This function is called to load the index(es) (and data, optionally) |
| 223 |
* for the every row in the data set. |
| 224 |
* |
| 225 |
* @remark |
| 226 |
* While loading the data, the only important thing is the indexes. |
| 227 |
* If access to your data is cheap/fast (e.g. you have a pointer to a |
| 228 |
* structure in memory), it would make sense to update the data here. |
| 229 |
* If, however, the accessing the data involves more work (e.g. parsing |
| 230 |
* some other existing data, or performing calculations to derive the data), |
| 231 |
* then you can limit yourself to setting the indexes and saving any |
| 232 |
* information you will need later. Then use the saved information in |
| 233 |
* ipv4InterfaceTable_row_prep() for populating data. |
| 234 |
* |
| 235 |
* @note |
| 236 |
* If you need consistency between rows (like you want statistics |
| 237 |
* for each row to be from the same time frame), you should set all |
| 238 |
* data here. |
| 239 |
* |
| 240 |
*/ |
| 241 |
int |
| 242 |
ipv4InterfaceTable_container_load(netsnmp_container *container) |
| 243 |
{ |
| 244 |
DEBUGMSGT(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_container_load", "illegal call!\n")); |
| 245 |
|
| 246 |
return MFD_ERROR; |
| 247 |
} /* ipv4InterfaceTable_container_load */ |
| 248 |
|
| 249 |
/** |
| 250 |
* container clean up |
| 251 |
* |
| 252 |
* @param container container with all current items |
| 253 |
* |
| 254 |
* This optional callback is called prior to all |
| 255 |
* item's being removed from the container. If you |
| 256 |
* need to do any processing before that, do it here. |
| 257 |
* |
| 258 |
* @note |
| 259 |
* The MFD helper will take care of releasing all the row contexts. |
| 260 |
* |
| 261 |
*/ |
| 262 |
void |
| 263 |
ipv4InterfaceTable_container_free(netsnmp_container *container) |
| 264 |
{ |
| 265 |
DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_container_free", "called\n")); |
| 266 |
|
| 267 |
/* |
| 268 |
* TODO:380:M: Free ipv4InterfaceTable container data. |
| 269 |
*/ |
| 270 |
} /* ipv4InterfaceTable_container_free */ |
| 271 |
|
| 272 |
/** |
| 273 |
* prepare row for processing. |
| 274 |
* |
| 275 |
* When the agent has located the row for a request, this function is |
| 276 |
* called to prepare the row for processing. If you fully populated |
| 277 |
* the data context during the index setup phase, you may not need to |
| 278 |
* do anything. |
| 279 |
* |
| 280 |
* @param rowreq_ctx pointer to a context. |
| 281 |
* |
| 282 |
* @retval MFD_SUCCESS : success. |
| 283 |
* @retval MFD_ERROR : other error. |
| 284 |
*/ |
| 285 |
int |
| 286 |
ipv4InterfaceTable_row_prep(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx) |
| 287 |
{ |
| 288 |
DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_row_prep", |
| 289 |
"called\n")); |
| 290 |
|
| 291 |
netsnmp_assert(NULL != rowreq_ctx); |
| 292 |
|
| 293 |
/* |
| 294 |
* TODO:390:o: Prepare row for request. |
| 295 |
* If populating row data was delayed, this is the place to |
| 296 |
* fill in the row for this request. |
| 297 |
*/ |
| 298 |
|
| 299 |
return MFD_SUCCESS; |
| 300 |
} /* ipv4InterfaceTable_row_prep */ |
| 301 |
|
| 302 |
/** @} */ |