| 1 |
/* |
| 2 |
* Note: this file originally auto-generated by mib2c using |
| 3 |
* version : 12088 $ of $ |
| 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 "ipDefaultRouterTable.h" |
| 18 |
|
| 19 |
|
| 20 |
/** @defgroup data_get data_get: Routines to get data |
| 21 |
* |
| 22 |
* TODO:230:M: Implement ipDefaultRouterTable get routines. |
| 23 |
* TODO:240:M: Implement ipDefaultRouterTable mapping routines (if any). |
| 24 |
* |
| 25 |
* These routine are used to get the value for individual objects. The |
| 26 |
* row context is passed, along with a pointer to the memory where the |
| 27 |
* value should be copied. |
| 28 |
* |
| 29 |
* @{ |
| 30 |
*/ |
| 31 |
/********************************************************************** |
| 32 |
********************************************************************** |
| 33 |
*** |
| 34 |
*** Table ipDefaultRouterTable |
| 35 |
*** |
| 36 |
********************************************************************** |
| 37 |
**********************************************************************/ |
| 38 |
/* |
| 39 |
* IP-MIB::ipDefaultRouterTable is subid 37 of ip. |
| 40 |
* Its status is Current. |
| 41 |
* OID: .1.3.6.1.2.1.4.37, length: 8 |
| 42 |
*/ |
| 43 |
|
| 44 |
/* |
| 45 |
* --------------------------------------------------------------------- |
| 46 |
* * TODO:200:r: Implement ipDefaultRouterTable data context functions. |
| 47 |
*/ |
| 48 |
/* |
| 49 |
* ipDefaultRouterTable_allocate_data |
| 50 |
* |
| 51 |
* Purpose: create new ipDefaultRouterTable_data. |
| 52 |
*/ |
| 53 |
ipDefaultRouterTable_data * |
| 54 |
ipDefaultRouterTable_allocate_data(void) |
| 55 |
{ |
| 56 |
/* |
| 57 |
* TODO:201:r: |-> allocate memory for the ipDefaultRouterTable data context. |
| 58 |
*/ |
| 59 |
ipDefaultRouterTable_data *rtn = |
| 60 |
netsnmp_access_defaultrouter_entry_create(); |
| 61 |
|
| 62 |
DEBUGMSGTL(("verbose:ipDefaultRouterTable:ipDefaultRouterTable_allocate_data", "called\n")); |
| 63 |
|
| 64 |
if (NULL == rtn) { |
| 65 |
snmp_log(LOG_ERR, "unable to malloc memory for new " |
| 66 |
"ipDefaultRouterTable_data.\n"); |
| 67 |
} |
| 68 |
|
| 69 |
return rtn; |
| 70 |
} /* ipDefaultRouterTable_allocate_data */ |
| 71 |
|
| 72 |
/* |
| 73 |
* ipDefaultRouterTable_release_data |
| 74 |
* |
| 75 |
* Purpose: release ipDefaultRouterTable data. |
| 76 |
*/ |
| 77 |
void |
| 78 |
ipDefaultRouterTable_release_data(ipDefaultRouterTable_data * data) |
| 79 |
{ |
| 80 |
DEBUGMSGTL(("verbose:ipDefaultRouterTable:ipDefaultRouterTable_release_data", "called\n")); |
| 81 |
|
| 82 |
/* |
| 83 |
* TODO:202:r: |-> release memory for the ipDefaultRouterTable data context. |
| 84 |
*/ |
| 85 |
netsnmp_access_defaultrouter_entry_free(data); |
| 86 |
} /* ipDefaultRouterTable_release_data */ |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
/** |
| 91 |
* set mib index(es) |
| 92 |
* |
| 93 |
* @param tbl_idx mib index structure |
| 94 |
* @param ipDefaultRouterAddressType_val |
| 95 |
* @param ipDefaultRouterAddress_ptr |
| 96 |
* @param ipDefaultRouterAddress_ptr_len |
| 97 |
* @param ipDefaultRouterIfIndex_val |
| 98 |
* |
| 99 |
* @retval MFD_SUCCESS : success. |
| 100 |
* @retval MFD_ERROR : other error. |
| 101 |
* |
| 102 |
* @remark |
| 103 |
* This convenience function is useful for setting all the MIB index |
| 104 |
* components with a single function call. It is assume that the C values |
| 105 |
* have already been mapped from their native/rawformat to the MIB format. |
| 106 |
*/ |
| 107 |
int |
| 108 |
ipDefaultRouterTable_indexes_set_tbl_idx(ipDefaultRouterTable_mib_index * |
| 109 |
tbl_idx, |
| 110 |
u_long |
| 111 |
ipDefaultRouterAddressType_val, |
| 112 |
char |
| 113 |
*ipDefaultRouterAddress_val_ptr, |
| 114 |
size_t |
| 115 |
ipDefaultRouterAddress_val_ptr_len, |
| 116 |
long ipDefaultRouterIfIndex_val) |
| 117 |
{ |
| 118 |
DEBUGMSGTL(("verbose:ipDefaultRouterTable:ipDefaultRouterTable_indexes_set_tbl_idx", "called\n")); |
| 119 |
|
| 120 |
/* |
| 121 |
* ipDefaultRouterAddressType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h |
| 122 |
*/ |
| 123 |
/** WARNING: this code might not work for netsnmp_defaultrouter_entry */ |
| 124 |
tbl_idx->ipDefaultRouterAddressType = ipDefaultRouterAddressType_val; |
| 125 |
|
| 126 |
/* |
| 127 |
* ipDefaultRouterAddress(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h |
| 128 |
*/ |
| 129 |
tbl_idx->ipDefaultRouterAddress_len = sizeof(tbl_idx->ipDefaultRouterAddress) / sizeof(tbl_idx->ipDefaultRouterAddress[0]); /* max length */ |
| 130 |
/** WARNING: this code might not work for netsnmp_defaultrouter_entry */ |
| 131 |
/* |
| 132 |
* make sure there is enough space for ipDefaultRouterAddress data |
| 133 |
*/ |
| 134 |
if (tbl_idx->ipDefaultRouterAddress_len < |
| 135 |
ipDefaultRouterAddress_val_ptr_len) { |
| 136 |
snmp_log(LOG_ERR, "not enough space for value\n"); |
| 137 |
return MFD_ERROR; |
| 138 |
} |
| 139 |
tbl_idx->ipDefaultRouterAddress_len = |
| 140 |
ipDefaultRouterAddress_val_ptr_len; |
| 141 |
memcpy(tbl_idx->ipDefaultRouterAddress, ipDefaultRouterAddress_val_ptr, |
| 142 |
ipDefaultRouterAddress_val_ptr_len * |
| 143 |
sizeof(ipDefaultRouterAddress_val_ptr[0])); |
| 144 |
|
| 145 |
/* |
| 146 |
* ipDefaultRouterIfIndex(3)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H |
| 147 |
*/ |
| 148 |
/** WARNING: this code might not work for netsnmp_defaultrouter_entry */ |
| 149 |
tbl_idx->ipDefaultRouterIfIndex = ipDefaultRouterIfIndex_val; |
| 150 |
|
| 151 |
|
| 152 |
return MFD_SUCCESS; |
| 153 |
} /* ipDefaultRouterTable_indexes_set_tbl_idx */ |
| 154 |
|
| 155 |
/** |
| 156 |
* @internal |
| 157 |
* set row context indexes |
| 158 |
* |
| 159 |
* @param reqreq_ctx the row context that needs updated indexes |
| 160 |
* |
| 161 |
* @retval MFD_SUCCESS : success. |
| 162 |
* @retval MFD_ERROR : other error. |
| 163 |
* |
| 164 |
* @remark |
| 165 |
* This function sets the mib indexs, then updates the oid indexs |
| 166 |
* from the mib index. |
| 167 |
*/ |
| 168 |
int |
| 169 |
ipDefaultRouterTable_indexes_set(ipDefaultRouterTable_rowreq_ctx * |
| 170 |
rowreq_ctx, |
| 171 |
u_long ipDefaultRouterAddressType_val, |
| 172 |
char *ipDefaultRouterAddress_val_ptr, |
| 173 |
size_t ipDefaultRouterAddress_val_ptr_len, |
| 174 |
long ipDefaultRouterIfIndex_val) |
| 175 |
{ |
| 176 |
DEBUGMSGTL(("verbose:ipDefaultRouterTable:ipDefaultRouterTable_indexes_set", "called\n")); |
| 177 |
|
| 178 |
if (MFD_SUCCESS != |
| 179 |
ipDefaultRouterTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx, |
| 180 |
ipDefaultRouterAddressType_val, |
| 181 |
ipDefaultRouterAddress_val_ptr, |
| 182 |
ipDefaultRouterAddress_val_ptr_len, |
| 183 |
ipDefaultRouterIfIndex_val)) |
| 184 |
return MFD_ERROR; |
| 185 |
|
| 186 |
/* |
| 187 |
* convert mib index to oid index |
| 188 |
*/ |
| 189 |
rowreq_ctx->oid_idx.len = sizeof(rowreq_ctx->oid_tmp) / sizeof(oid); |
| 190 |
if (0 != ipDefaultRouterTable_index_to_oid(&rowreq_ctx->oid_idx, |
| 191 |
&rowreq_ctx->tbl_idx)) { |
| 192 |
return MFD_ERROR; |
| 193 |
} |
| 194 |
|
| 195 |
return MFD_SUCCESS; |
| 196 |
} /* ipDefaultRouterTable_indexes_set */ |
| 197 |
|
| 198 |
|
| 199 |
/*--------------------------------------------------------------------- |
| 200 |
* IP-MIB::ipDefaultRouterEntry.ipDefaultRouterLifetime |
| 201 |
* ipDefaultRouterLifetime is subid 4 of ipDefaultRouterEntry. |
| 202 |
* Its status is Current, and its access level is ReadOnly. |
| 203 |
* OID: .1.3.6.1.2.1.4.37.1.4 |
| 204 |
* Description: |
| 205 |
The remaining length of time, in seconds, that this router |
| 206 |
will continue to be useful as a default router. A value of |
| 207 |
zero indicates that it is no longer useful as a default |
| 208 |
router. It is left to the implementer of the MIB as to |
| 209 |
whether a router with a lifetime of zero is removed from the |
| 210 |
list. |
| 211 |
|
| 212 |
For IPv6, this value should be extracted from the router |
| 213 |
advertisement messages. |
| 214 |
* |
| 215 |
* Attributes: |
| 216 |
* accessible 1 isscalar 0 enums 0 hasdefval 0 |
| 217 |
* readable 1 iscolumn 1 ranges 1 hashint 0 |
| 218 |
* settable 0 |
| 219 |
* |
| 220 |
* Ranges: 0 - 65535; |
| 221 |
* |
| 222 |
* Its syntax is UNSIGNED32 (based on perltype UNSIGNED32) |
| 223 |
* The net-snmp type is ASN_UNSIGNED. The C type decl is u_long (u_long) |
| 224 |
*/ |
| 225 |
/** |
| 226 |
* Extract the current value of the ipDefaultRouterLifetime data. |
| 227 |
* |
| 228 |
* Set a value using the data context for the row. |
| 229 |
* |
| 230 |
* @param rowreq_ctx |
| 231 |
* Pointer to the row request context. |
| 232 |
* @param ipDefaultRouterLifetime_val_ptr |
| 233 |
* Pointer to storage for a u_long variable |
| 234 |
* |
| 235 |
* @retval MFD_SUCCESS : success |
| 236 |
* @retval MFD_SKIP : skip this node (no value for now) |
| 237 |
* @retval MFD_ERROR : Any other error |
| 238 |
*/ |
| 239 |
int |
| 240 |
ipDefaultRouterLifetime_get(ipDefaultRouterTable_rowreq_ctx * rowreq_ctx, |
| 241 |
u_long * ipDefaultRouterLifetime_val_ptr) |
| 242 |
{ |
| 243 |
/** we should have a non-NULL pointer */ |
| 244 |
netsnmp_assert(NULL != ipDefaultRouterLifetime_val_ptr); |
| 245 |
|
| 246 |
|
| 247 |
DEBUGMSGTL(("verbose:ipDefaultRouterTable:ipDefaultRouterLifetime_get", |
| 248 |
"called\n")); |
| 249 |
|
| 250 |
netsnmp_assert(NULL != rowreq_ctx); |
| 251 |
|
| 252 |
/* |
| 253 |
* TODO:231:o: |-> Extract the current value of the ipDefaultRouterLifetime data. |
| 254 |
* copy (* ipDefaultRouterLifetime_val_ptr ) from rowreq_ctx->data |
| 255 |
*/ |
| 256 |
(*ipDefaultRouterLifetime_val_ptr) = rowreq_ctx->data->dr_lifetime; |
| 257 |
|
| 258 |
return MFD_SUCCESS; |
| 259 |
} /* ipDefaultRouterLifetime_get */ |
| 260 |
|
| 261 |
/*--------------------------------------------------------------------- |
| 262 |
* IP-MIB::ipDefaultRouterEntry.ipDefaultRouterPreference |
| 263 |
* ipDefaultRouterPreference is subid 5 of ipDefaultRouterEntry. |
| 264 |
* Its status is Current, and its access level is ReadOnly. |
| 265 |
* OID: .1.3.6.1.2.1.4.37.1.5 |
| 266 |
* Description: |
| 267 |
An indication of preference given to this router as a |
| 268 |
default router as described in he Default Router |
| 269 |
Preferences document. Treating the value as a |
| 270 |
2 bit signed integer allows for simple arithmetic |
| 271 |
comparisons. |
| 272 |
|
| 273 |
For IPv4 routers or IPv6 routers that are not using the |
| 274 |
updated router advertisement format, this object is set to |
| 275 |
medium (0). |
| 276 |
* |
| 277 |
* Attributes: |
| 278 |
* accessible 1 isscalar 0 enums 1 hasdefval 0 |
| 279 |
* readable 1 iscolumn 1 ranges 0 hashint 0 |
| 280 |
* settable 0 |
| 281 |
* |
| 282 |
* Enum range: 3/8. Values: reserved(-2), low(-1), medium(0), high(1) |
| 283 |
* |
| 284 |
* Its syntax is INTEGER (based on perltype INTEGER) |
| 285 |
* The net-snmp type is ASN_INTEGER. The C type decl is long (u_long) |
| 286 |
*/ |
| 287 |
/** |
| 288 |
* Extract the current value of the ipDefaultRouterPreference data. |
| 289 |
* |
| 290 |
* Set a value using the data context for the row. |
| 291 |
* |
| 292 |
* @param rowreq_ctx |
| 293 |
* Pointer to the row request context. |
| 294 |
* @param ipDefaultRouterPreference_val_ptr |
| 295 |
* Pointer to storage for a long variable |
| 296 |
* |
| 297 |
* @retval MFD_SUCCESS : success |
| 298 |
* @retval MFD_SKIP : skip this node (no value for now) |
| 299 |
* @retval MFD_ERROR : Any other error |
| 300 |
*/ |
| 301 |
int |
| 302 |
ipDefaultRouterPreference_get(ipDefaultRouterTable_rowreq_ctx * rowreq_ctx, |
| 303 |
u_long * ipDefaultRouterPreference_val_ptr) |
| 304 |
{ |
| 305 |
/** we should have a non-NULL pointer */ |
| 306 |
netsnmp_assert(NULL != ipDefaultRouterPreference_val_ptr); |
| 307 |
|
| 308 |
|
| 309 |
DEBUGMSGTL(("verbose:ipDefaultRouterTable:ipDefaultRouterPreference_get", "called\n")); |
| 310 |
|
| 311 |
netsnmp_assert(NULL != rowreq_ctx); |
| 312 |
|
| 313 |
/* |
| 314 |
* TODO:231:o: |-> Extract the current value of the ipDefaultRouterPreference data. |
| 315 |
* copy (* ipDefaultRouterPreference_val_ptr ) from rowreq_ctx->data |
| 316 |
*/ |
| 317 |
(*ipDefaultRouterPreference_val_ptr) = rowreq_ctx->data->dr_preference; |
| 318 |
|
| 319 |
return MFD_SUCCESS; |
| 320 |
} /* ipDefaultRouterPreference_get */ |
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
/** @} */ |