| 1 |
/* |
| 2 |
* Note: this file originally auto-generated by mib2c using |
| 3 |
* version : 1.19 $ of : mfd-data-set.m2c,v $ |
| 4 |
* |
| 5 |
* $Id$ |
| 6 |
* |
| 7 |
*/ |
| 8 |
/* |
| 9 |
* standard Net-SNMP includes |
| 10 |
*/ |
| 11 |
#include <net-snmp/net-snmp-config.h> |
| 12 |
#include <net-snmp/library/openssl_config.h> |
| 13 |
#include <net-snmp/net-snmp-includes.h> |
| 14 |
#include <net-snmp/agent/net-snmp-agent-includes.h> |
| 15 |
|
| 16 |
#include <openssl/dh.h> |
| 17 |
|
| 18 |
/* |
| 19 |
* include our parent header |
| 20 |
*/ |
| 21 |
#define NEED_USMDH_FUNCTIONS |
| 22 |
#include "usmDHUserKeyTable.h" |
| 23 |
|
| 24 |
int |
| 25 |
usmDHUserCheckValue(struct usmUser *user, int for_auth_key, |
| 26 |
u_char *val, size_t val_len) |
| 27 |
{ |
| 28 |
/* |
| 29 |
* The set value must be composed of 2 parts, the first being the |
| 30 |
* current value |
| 31 |
*/ |
| 32 |
u_char *current_value = NULL; |
| 33 |
size_t current_value_len = 0; |
| 34 |
int ret = MFD_SUCCESS; |
| 35 |
|
| 36 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserCheckValue", |
| 37 |
"called\n")); |
| 38 |
usmDHGetUserKeyChange(user, for_auth_key, |
| 39 |
¤t_value, ¤t_value_len); |
| 40 |
|
| 41 |
if (!current_value) |
| 42 |
return MFD_ERROR; |
| 43 |
|
| 44 |
if (val_len != current_value_len * 2) |
| 45 |
ret = MFD_NOT_VALID_NOW; |
| 46 |
|
| 47 |
else if (memcmp(current_value, val, current_value_len) != 0) |
| 48 |
ret = SNMP_ERR_WRONGVALUE; /* mandated error string */ |
| 49 |
|
| 50 |
SNMP_FREE(current_value); |
| 51 |
return ret; |
| 52 |
} |
| 53 |
|
| 54 |
int |
| 55 |
usmDHSetKey(struct usmUser *user, int for_auth_key, |
| 56 |
u_char *val, size_t val_len) |
| 57 |
{ |
| 58 |
DH *dh = NULL; |
| 59 |
BIGNUM *other_pub = NULL; |
| 60 |
u_char *key = NULL; |
| 61 |
size_t key_len = 0; |
| 62 |
|
| 63 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHSetKey", "called\n")); |
| 64 |
/* |
| 65 |
* XXX: mem leaks on errors abound |
| 66 |
*/ |
| 67 |
|
| 68 |
dh = usmDHGetUserDHptr(user, for_auth_key); |
| 69 |
if (!dh) |
| 70 |
return MFD_ERROR; |
| 71 |
|
| 72 |
other_pub = BN_bin2bn(val + val_len / 2, val_len / 2, NULL); |
| 73 |
if (!other_pub) |
| 74 |
return MFD_ERROR; |
| 75 |
|
| 76 |
/* |
| 77 |
* Set the new key for a user |
| 78 |
*/ |
| 79 |
key_len = DH_size(dh); |
| 80 |
key = malloc(DH_size(dh)); |
| 81 |
if (!key) |
| 82 |
{ |
| 83 |
BN_clear_free(other_pub); |
| 84 |
return MFD_ERROR; |
| 85 |
} |
| 86 |
|
| 87 |
if (DH_compute_key(key, other_pub, dh)) { |
| 88 |
u_char **replkey; |
| 89 |
size_t replkey_size; |
| 90 |
|
| 91 |
BN_clear_free(other_pub); |
| 92 |
|
| 93 |
if (for_auth_key) { |
| 94 |
replkey_size = user->authKeyLen; |
| 95 |
replkey = &user->authKey; |
| 96 |
} else { |
| 97 |
replkey_size = user->privKeyLen; |
| 98 |
replkey = &user->privKey; |
| 99 |
} |
| 100 |
|
| 101 |
/* |
| 102 |
* is it large enough? |
| 103 |
*/ |
| 104 |
if (key_len < replkey_size) |
| 105 |
{ |
| 106 |
SNMP_FREE(key); |
| 107 |
return MFD_ERROR; |
| 108 |
} |
| 109 |
|
| 110 |
/* |
| 111 |
* copy right most bits, per the object requirements |
| 112 |
*/ |
| 113 |
SNMP_FREE(*replkey); |
| 114 |
*replkey = netsnmp_memdup(key + key_len - replkey_size, replkey_size); |
| 115 |
SNMP_FREE(key); |
| 116 |
|
| 117 |
return MFD_SUCCESS; |
| 118 |
} |
| 119 |
SNMP_FREE(other_pub); |
| 120 |
SNMP_FREE(key); |
| 121 |
|
| 122 |
return MFD_ERROR; |
| 123 |
} |
| 124 |
|
| 125 |
/** @ingroup data_access |
| 126 |
* @defgroup data_set data_set: Routines to set data |
| 127 |
* |
| 128 |
* These routines are used to set the value for individual objects. The |
| 129 |
* row context is passed, along with the new value. |
| 130 |
* |
| 131 |
* @{ |
| 132 |
*/ |
| 133 |
/********************************************************************** |
| 134 |
********************************************************************** |
| 135 |
*** |
| 136 |
*** Table usmDHUserKeyTable |
| 137 |
*** |
| 138 |
********************************************************************** |
| 139 |
**********************************************************************/ |
| 140 |
/* |
| 141 |
* SNMP-USM-DH-OBJECTS-MIB::usmDHUserKeyTable is subid 2 of usmDHPublicObjects. |
| 142 |
* Its status is Current. |
| 143 |
* OID: .1.3.6.1.3.101.1.1.2, length: 9 |
| 144 |
*/ |
| 145 |
/* |
| 146 |
* NOTE: if you update this chart, please update the versions in |
| 147 |
* local/mib2c-conf.d/parent-set.m2i |
| 148 |
* agent/mibgroup/helpers/baby_steps.c |
| 149 |
* while you're at it. |
| 150 |
*/ |
| 151 |
/* |
| 152 |
*********************************************************************** |
| 153 |
* Baby Steps Flow Chart (2004.06.05) * |
| 154 |
* * |
| 155 |
* +--------------+ +================+ U = unconditional path * |
| 156 |
* |optional state| ||required state|| S = path for success * |
| 157 |
* +--------------+ +================+ E = path for error * |
| 158 |
*********************************************************************** |
| 159 |
* |
| 160 |
* +--------------+ |
| 161 |
* | pre | |
| 162 |
* | request | |
| 163 |
* +--------------+ |
| 164 |
* | U |
| 165 |
* +==============+ |
| 166 |
* +----------------|| object || |
| 167 |
* | E || lookup || |
| 168 |
* | +==============+ |
| 169 |
* | | S |
| 170 |
* | +==============+ |
| 171 |
* | E || check || |
| 172 |
* |<---------------|| values || |
| 173 |
* | +==============+ |
| 174 |
* | | S |
| 175 |
* | +==============+ |
| 176 |
* | +<-------|| undo || |
| 177 |
* | | E || setup || |
| 178 |
* | | +==============+ |
| 179 |
* | | | S |
| 180 |
* | | +==============+ |
| 181 |
* | | || set ||-------------------------->+ |
| 182 |
* | | || value || E | |
| 183 |
* | | +==============+ | |
| 184 |
* | | | S | |
| 185 |
* | | +--------------+ | |
| 186 |
* | | | check |-------------------------->| |
| 187 |
* | | | consistency | E | |
| 188 |
* | | +--------------+ | |
| 189 |
* | | | S | |
| 190 |
* | | +==============+ +==============+ | |
| 191 |
* | | || commit ||-------->|| undo || | |
| 192 |
* | | || || E || commit || | |
| 193 |
* | | +==============+ +==============+ | |
| 194 |
* | | | S U |<--------+ |
| 195 |
* | | +--------------+ +==============+ |
| 196 |
* | | | irreversible | || undo || |
| 197 |
* | | | commit | || set || |
| 198 |
* | | +--------------+ +==============+ |
| 199 |
* | | | U U | |
| 200 |
* | +-------------->|<------------------------+ |
| 201 |
* | +==============+ |
| 202 |
* | || undo || |
| 203 |
* | || cleanup || |
| 204 |
* | +==============+ |
| 205 |
* +---------------------->| U |
| 206 |
* +--------------+ |
| 207 |
* | post | |
| 208 |
* | request | |
| 209 |
* +--------------+ |
| 210 |
* |
| 211 |
*/ |
| 212 |
|
| 213 |
/** |
| 214 |
* Setup up context with information needed to undo a set request. |
| 215 |
* |
| 216 |
* This function will be called before the individual node undo setup |
| 217 |
* functions are called. If you need to do any undo setup that is not |
| 218 |
* related to a specific column, you can do it here. |
| 219 |
* |
| 220 |
* Note that the undo context has been allocated with |
| 221 |
* usmDHUserKeyTable_allocate_data(), but may need extra |
| 222 |
* initialization similar to what you may have done in |
| 223 |
* usmDHUserKeyTable_rowreq_ctx_init(). |
| 224 |
* Note that an individual node's undo_setup function will only be called |
| 225 |
* if that node is being set to a new value. |
| 226 |
* |
| 227 |
* If there is any setup specific to a particular column (e.g. allocating |
| 228 |
* memory for a string), you should do that setup in the node's undo_setup |
| 229 |
* function, so it won't be done unless it is necessary. |
| 230 |
* |
| 231 |
* @param rowreq_ctx |
| 232 |
* Pointer to the table context (usmDHUserKeyTable_rowreq_ctx) |
| 233 |
* |
| 234 |
* @retval MFD_SUCCESS : success |
| 235 |
* @retval MFD_ERROR : error. set will fail. |
| 236 |
*/ |
| 237 |
int |
| 238 |
usmDHUserKeyTable_undo_setup(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx) |
| 239 |
{ |
| 240 |
int rc = MFD_SUCCESS; |
| 241 |
|
| 242 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_undo_setup", |
| 243 |
"called\n")); |
| 244 |
|
| 245 |
/** we should have a non-NULL pointer */ |
| 246 |
netsnmp_assert(NULL != rowreq_ctx); |
| 247 |
/* |
| 248 |
* TODO:451:M: |-> Setup usmDHUserKeyTable undo. |
| 249 |
* set up usmDHUserKeyTable undo information, in preparation for a set. |
| 250 |
* Undo storage is in (* usmDHUserOwnPrivKeyChange_val_ptr_ptr )* |
| 251 |
*/ |
| 252 |
|
| 253 |
return rc; |
| 254 |
} /* usmDHUserKeyTable_undo_setup */ |
| 255 |
|
| 256 |
/** |
| 257 |
* Undo a set request. |
| 258 |
* |
| 259 |
* This function will be called before the individual node undo |
| 260 |
* functions are called. If you need to do any undo that is not |
| 261 |
* related to a specific column, you can do it here. |
| 262 |
* |
| 263 |
* Note that an individual node's undo function will only be called |
| 264 |
* if that node is being set to a new value. |
| 265 |
* |
| 266 |
* If there is anything specific to a particular column (e.g. releasing |
| 267 |
* memory for a string), you should do that setup in the node's undo |
| 268 |
* function, so it won't be done unless it is necessary. |
| 269 |
* |
| 270 |
* @param rowreq_ctx |
| 271 |
* Pointer to the table context (usmDHUserKeyTable_rowreq_ctx) |
| 272 |
* |
| 273 |
* @retval MFD_SUCCESS : success |
| 274 |
* @retval MFD_ERROR : error. set will fail. |
| 275 |
*/ |
| 276 |
int |
| 277 |
usmDHUserKeyTable_undo(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx) |
| 278 |
{ |
| 279 |
int rc = MFD_SUCCESS; |
| 280 |
|
| 281 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_undo", |
| 282 |
"called\n")); |
| 283 |
|
| 284 |
/** we should have a non-NULL pointer */ |
| 285 |
netsnmp_assert(NULL != rowreq_ctx); |
| 286 |
|
| 287 |
/* |
| 288 |
* TODO:451:M: |-> usmDHUserKeyTable undo. |
| 289 |
* usmDHUserKeyTable undo information, in response to a failed set. |
| 290 |
* Undo storage is in (* usmDHUserOwnPrivKeyChange_val_ptr_ptr )* |
| 291 |
*/ |
| 292 |
|
| 293 |
return rc; |
| 294 |
} /* usmDHUserKeyTable_undo_setup */ |
| 295 |
|
| 296 |
/** |
| 297 |
* Cleanup up context undo information. |
| 298 |
* |
| 299 |
* This function will be called after set/commit processing. If you |
| 300 |
* allocated any resources in undo_setup, this is the place to release |
| 301 |
* those resources. |
| 302 |
* |
| 303 |
* This function is called regardless of the success or failure of the set |
| 304 |
* request. If you need to perform different steps for cleanup depending |
| 305 |
* on success or failure, you can add a flag to the rowreq_ctx. |
| 306 |
* |
| 307 |
* @param rowreq_ctx |
| 308 |
* Pointer to the table context (usmDHUserKeyTable_rowreq_ctx) |
| 309 |
* |
| 310 |
* @retval MFD_SUCCESS : success |
| 311 |
* @retval MFD_ERROR : error |
| 312 |
*/ |
| 313 |
int |
| 314 |
usmDHUserKeyTable_undo_cleanup(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx) |
| 315 |
{ |
| 316 |
int rc = MFD_SUCCESS; |
| 317 |
|
| 318 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_undo_cleanup", |
| 319 |
"called\n")); |
| 320 |
/** we should have a non-NULL pointer */ |
| 321 |
netsnmp_assert(NULL != rowreq_ctx); |
| 322 |
|
| 323 |
/* |
| 324 |
* TODO:452:M: |-> Cleanup usmDHUserKeyTable undo. |
| 325 |
* Undo storage is in (* usmDHUserOwnPrivKeyChange_val_ptr_ptr )* |
| 326 |
*/ |
| 327 |
|
| 328 |
return rc; |
| 329 |
} /* usmDHUserKeyTable_undo_cleanup */ |
| 330 |
|
| 331 |
/** |
| 332 |
* commit new values. |
| 333 |
* |
| 334 |
* At this point, you should have done everything you can to ensure that |
| 335 |
* this commit will not fail. |
| 336 |
* |
| 337 |
* Should you need different behavior depending on which columns were |
| 338 |
* set, rowreq_ctx->column_set_flags will indicate which writeable columns were |
| 339 |
* set. The definitions for the COLUMN_*_FLAG bits can be found in |
| 340 |
* usmDHUserKeyTable_oids.h. |
| 341 |
* A new row will have the MFD_ROW_CREATED bit set in rowreq_flags. |
| 342 |
* |
| 343 |
* @param rowreq_ctx |
| 344 |
* Pointer to the users context. |
| 345 |
* |
| 346 |
* @retval MFD_SUCCESS : success |
| 347 |
* @retval MFD_ERROR : error |
| 348 |
*/ |
| 349 |
int |
| 350 |
usmDHUserKeyTable_commit(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx) |
| 351 |
{ |
| 352 |
int rc = MFD_SUCCESS; |
| 353 |
|
| 354 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_commit", |
| 355 |
"called\n")); |
| 356 |
|
| 357 |
/** we should have a non-NULL pointer */ |
| 358 |
netsnmp_assert(NULL != rowreq_ctx); |
| 359 |
|
| 360 |
/* |
| 361 |
* nothing to do; we wait for the irreversible commit |
| 362 |
*/ |
| 363 |
|
| 364 |
/* |
| 365 |
* if we successfully committed this row, set the dirty flag. |
| 366 |
*/ |
| 367 |
if (MFD_SUCCESS == rc) { |
| 368 |
rowreq_ctx->rowreq_flags |= MFD_ROW_DIRTY; |
| 369 |
} |
| 370 |
|
| 371 |
return rc; |
| 372 |
} /* usmDHUserKeyTable_commit */ |
| 373 |
|
| 374 |
/** |
| 375 |
* undo commit new values. |
| 376 |
* |
| 377 |
* Should you need different behavior depending on which columns were |
| 378 |
* set, rowreq_ctx->column_set_flags will indicate which writeable columns were |
| 379 |
* set. The definitions for the COLUMN_*_FLAG bits can be found in |
| 380 |
* usmDHUserKeyTable_oids.h. |
| 381 |
* A new row will have the MFD_ROW_CREATED bit set in rowreq_flags. |
| 382 |
* |
| 383 |
* @param rowreq_ctx |
| 384 |
* Pointer to the users context. |
| 385 |
* |
| 386 |
* @retval MFD_SUCCESS : success |
| 387 |
* @retval MFD_ERROR : error |
| 388 |
*/ |
| 389 |
int |
| 390 |
usmDHUserKeyTable_undo_commit(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx) |
| 391 |
{ |
| 392 |
int rc = MFD_SUCCESS; |
| 393 |
|
| 394 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_undo_commit", |
| 395 |
"called\n")); |
| 396 |
|
| 397 |
/** we should have a non-NULL pointer */ |
| 398 |
netsnmp_assert(NULL != rowreq_ctx); |
| 399 |
|
| 400 |
/* |
| 401 |
* TODO:485:M: |-> Undo usmDHUserKeyTable commit. |
| 402 |
* check the column's flag in rowreq_ctx->column_set_flags to see |
| 403 |
* if it was set during commit, then undo it. |
| 404 |
* |
| 405 |
* eg: if (rowreq_ctx->column_set_flags & COLUMN__FLAG) {} |
| 406 |
*/ |
| 407 |
|
| 408 |
|
| 409 |
/* |
| 410 |
* if we successfully un-committed this row, clear the dirty flag. |
| 411 |
*/ |
| 412 |
if (MFD_SUCCESS == rc) { |
| 413 |
rowreq_ctx->rowreq_flags &= ~MFD_ROW_DIRTY; |
| 414 |
} |
| 415 |
|
| 416 |
return rc; |
| 417 |
} /* usmDHUserKeyTable_undo_commit */ |
| 418 |
|
| 419 |
/** |
| 420 |
* perform commit actions that are not reversible |
| 421 |
* |
| 422 |
* THERE IS NO ATTEMPT AT RECOVERY FOR ERRORS FROM THIS STATE! |
| 423 |
* |
| 424 |
* @param rowreq_ctx |
| 425 |
* Pointer to the users context. |
| 426 |
* |
| 427 |
* @retval MFD_SUCCESS : success |
| 428 |
* @retval MFD_ERROR : other error |
| 429 |
*/ |
| 430 |
int |
| 431 |
usmDHUserKeyTable_irreversible_commit(usmDHUserKeyTable_rowreq_ctx * |
| 432 |
rowreq_ctx) |
| 433 |
{ |
| 434 |
struct usmUser *user; |
| 435 |
int flags; |
| 436 |
|
| 437 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_irreversible_commit", "called\n")); |
| 438 |
|
| 439 |
/** we should have a non-NULL pointer */ |
| 440 |
netsnmp_assert(NULL != rowreq_ctx); |
| 441 |
|
| 442 |
/* |
| 443 |
* TODO:495:o: Irreversible usmDHUserKeyTable commit. |
| 444 |
*/ |
| 445 |
user = rowreq_ctx->data; |
| 446 |
flags = rowreq_ctx->column_set_flags; |
| 447 |
|
| 448 |
if (flags & COLUMN_USMDHUSERAUTHKEYCHANGE_FLAG || |
| 449 |
flags & COLUMN_USMDHUSEROWNAUTHKEYCHANGE_FLAG) { |
| 450 |
/* |
| 451 |
* free the keychange objects so they reset to new values |
| 452 |
*/ |
| 453 |
DH_free(user->usmDHUserAuthKeyChange); |
| 454 |
user->usmDHUserAuthKeyChange = NULL; |
| 455 |
} |
| 456 |
|
| 457 |
if (flags & COLUMN_USMDHUSERPRIVKEYCHANGE_FLAG || |
| 458 |
flags & COLUMN_USMDHUSEROWNPRIVKEYCHANGE_FLAG) { |
| 459 |
/* |
| 460 |
* free the keychange objects so they reset to new values |
| 461 |
*/ |
| 462 |
DH_free(user->usmDHUserPrivKeyChange); |
| 463 |
user->usmDHUserPrivKeyChange = NULL; |
| 464 |
} |
| 465 |
|
| 466 |
return MFD_SUCCESS; |
| 467 |
} /* usmDHUserKeyTable_irreversible_commit */ |
| 468 |
|
| 469 |
/* |
| 470 |
* TODO:440:M: Implement usmDHUserKeyTable node value checks. |
| 471 |
* TODO:450:M: Implement usmDHUserKeyTable undo functions. |
| 472 |
* TODO:460:M: Implement usmDHUserKeyTable set functions. |
| 473 |
* TODO:480:M: Implement usmDHUserKeyTable commit functions. |
| 474 |
*/ |
| 475 |
/*--------------------------------------------------------------------- |
| 476 |
* SNMP-USM-DH-OBJECTS-MIB::usmDHUserKeyEntry.usmDHUserAuthKeyChange |
| 477 |
* usmDHUserAuthKeyChange is subid 1 of usmDHUserKeyEntry. |
| 478 |
* Its status is Current, and its access level is Create. |
| 479 |
* OID: .1.3.6.1.3.101.1.1.2.1.1 |
| 480 |
* Description: |
| 481 |
The object used to change any given user's Authentication Key |
| 482 |
using a Diffie-Hellman key exchange. |
| 483 |
|
| 484 |
The right-most n bits of the shared secret 'sk', where 'n' is the |
| 485 |
number of bits required for the protocol defined by |
| 486 |
usmUserAuthProtocol, are installed as the operational |
| 487 |
authentication key for this row after a successful SET. |
| 488 |
* |
| 489 |
* Attributes: |
| 490 |
* accessible 1 isscalar 0 enums 0 hasdefval 0 |
| 491 |
* readable 1 iscolumn 1 ranges 0 hashint 0 |
| 492 |
* settable 1 |
| 493 |
* |
| 494 |
* |
| 495 |
* Its syntax is DHKeyChange (based on perltype OCTETSTR) |
| 496 |
* The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) |
| 497 |
* This data type requires a length. |
| 498 |
*/ |
| 499 |
/** |
| 500 |
* Check that the proposed new value is potentially valid. |
| 501 |
* |
| 502 |
* @param rowreq_ctx |
| 503 |
* Pointer to the row request context. |
| 504 |
* @param usmDHUserAuthKeyChange_val_ptr |
| 505 |
* A char containing the new value. |
| 506 |
* @param usmDHUserAuthKeyChange_val_ptr_len |
| 507 |
* The size (in bytes) of the data pointed to by usmDHUserAuthKeyChange_val_ptr |
| 508 |
* |
| 509 |
* @retval MFD_SUCCESS : incoming value is legal |
| 510 |
* @retval MFD_NOT_VALID_NOW : incoming value is not valid now |
| 511 |
* @retval MFD_NOT_VALID_EVER : incoming value is never valid |
| 512 |
* |
| 513 |
* This is the place to check for requirements that are not |
| 514 |
* expressed in the mib syntax (for example, a requirement that |
| 515 |
* is detailed in the description for an object). |
| 516 |
* |
| 517 |
* Since you aren't using a generated data context, you also need to |
| 518 |
* check the length, to make sure you don't overflow your storage space. |
| 519 |
* |
| 520 |
* You should check that the requested change between the undo value and the |
| 521 |
* new value is legal (ie, the transistion from one value to another |
| 522 |
* is legal). |
| 523 |
* |
| 524 |
*@note |
| 525 |
* This check is only to determine if the new value |
| 526 |
* is \b potentially valid. This is the first check of many, and |
| 527 |
* is one of the simplest ones. |
| 528 |
* |
| 529 |
*@note |
| 530 |
* this is not the place to do any checks for values |
| 531 |
* which depend on some other value in the mib. Those |
| 532 |
* types of checks should be done in the |
| 533 |
* usmDHUserKeyTable_check_dependencies() function. |
| 534 |
* |
| 535 |
* The following checks have already been done for you: |
| 536 |
* The syntax is ASN_OCTET_STR |
| 537 |
* |
| 538 |
* If there a no other checks you need to do, simply return MFD_SUCCESS. |
| 539 |
* |
| 540 |
*/ |
| 541 |
int |
| 542 |
usmDHUserAuthKeyChange_check_value(usmDHUserKeyTable_rowreq_ctx * |
| 543 |
rowreq_ctx, |
| 544 |
u_char *usmDHUserAuthKeyChange_val_ptr, |
| 545 |
size_t |
| 546 |
usmDHUserAuthKeyChange_val_ptr_len) |
| 547 |
{ |
| 548 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserAuthKeyChange_check_value", "called\n")); |
| 549 |
|
| 550 |
/** should never get a NULL pointer */ |
| 551 |
netsnmp_assert(NULL != rowreq_ctx); |
| 552 |
netsnmp_assert(NULL != usmDHUserAuthKeyChange_val_ptr); |
| 553 |
|
| 554 |
/* |
| 555 |
* TODO:441:o: |-> Check for valid usmDHUserAuthKeyChange value. |
| 556 |
*/ |
| 557 |
return usmDHUserCheckValue(rowreq_ctx->data, 1, |
| 558 |
usmDHUserAuthKeyChange_val_ptr, |
| 559 |
usmDHUserAuthKeyChange_val_ptr_len); |
| 560 |
} /* usmDHUserAuthKeyChange_check_value */ |
| 561 |
|
| 562 |
/** |
| 563 |
* Save old value information |
| 564 |
* |
| 565 |
* @param rowreq_ctx |
| 566 |
* Pointer to the table context (usmDHUserKeyTable_rowreq_ctx) |
| 567 |
* |
| 568 |
* @retval MFD_SUCCESS : success |
| 569 |
* @retval MFD_ERROR : error. set will fail. |
| 570 |
* |
| 571 |
* This function will be called after the table level undo setup function |
| 572 |
* usmDHUserKeyTable_undo_setup has been called. |
| 573 |
* |
| 574 |
*@note |
| 575 |
* this function will only be called if a new value is set for this column. |
| 576 |
* |
| 577 |
* If there is any setup specific to a particular column (e.g. allocating |
| 578 |
* memory for a string), you should do that setup in this function, so it |
| 579 |
* won't be done unless it is necessary. |
| 580 |
*/ |
| 581 |
int |
| 582 |
usmDHUserAuthKeyChange_undo_setup(usmDHUserKeyTable_rowreq_ctx * |
| 583 |
rowreq_ctx) |
| 584 |
{ |
| 585 |
struct usmUser *undouser; |
| 586 |
|
| 587 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserAuthKeyChange_undo_setup", "called\n")); |
| 588 |
|
| 589 |
/** should never get a NULL pointer */ |
| 590 |
netsnmp_assert(NULL != rowreq_ctx); |
| 591 |
|
| 592 |
/* |
| 593 |
* TODO:455:o: |-> Setup usmDHUserAuthKeyChange undo. |
| 594 |
*/ |
| 595 |
/* |
| 596 |
* copy usmDHUserAuthKeyChange and usmDHUserAuthKeyChange_len data |
| 597 |
* set rowreq_ctx->undo->usmDHUserAuthKeyChange from rowreq_ctx->data->usmDHUserAuthKeyChange |
| 598 |
*/ |
| 599 |
undouser = rowreq_ctx->undo; |
| 600 |
|
| 601 |
undouser->authKeyLen = rowreq_ctx->data->authKeyLen; |
| 602 |
undouser->authKey = netsnmp_memdup(rowreq_ctx->data->authKey, |
| 603 |
rowreq_ctx->data->authKeyLen); |
| 604 |
|
| 605 |
return MFD_SUCCESS; |
| 606 |
} /* usmDHUserAuthKeyChange_undo_setup */ |
| 607 |
|
| 608 |
/** |
| 609 |
* Set the new value. |
| 610 |
* |
| 611 |
* @param rowreq_ctx |
| 612 |
* Pointer to the users context. You should know how to |
| 613 |
* manipulate the value from this object. |
| 614 |
* @param usmDHUserAuthKeyChange_val_ptr |
| 615 |
* A char containing the new value. |
| 616 |
* @param usmDHUserAuthKeyChange_val_ptr_len |
| 617 |
* The size (in bytes) of the data pointed to by usmDHUserAuthKeyChange_val_ptr |
| 618 |
*/ |
| 619 |
int |
| 620 |
usmDHUserAuthKeyChange_set(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx, |
| 621 |
u_char *usmDHUserAuthKeyChange_val_ptr, |
| 622 |
size_t usmDHUserAuthKeyChange_val_ptr_len) |
| 623 |
{ |
| 624 |
|
| 625 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserAuthKeyChange_set", |
| 626 |
"called\n")); |
| 627 |
|
| 628 |
/** should never get a NULL pointer */ |
| 629 |
netsnmp_assert(NULL != rowreq_ctx); |
| 630 |
netsnmp_assert(NULL != usmDHUserAuthKeyChange_val_ptr); |
| 631 |
|
| 632 |
/* |
| 633 |
* TODO:461:M: |-> Set usmDHUserAuthKeyChange value. |
| 634 |
* set usmDHUserAuthKeyChange value in rowreq_ctx->data |
| 635 |
*/ |
| 636 |
usmDHSetKey(rowreq_ctx->data, 1, |
| 637 |
usmDHUserAuthKeyChange_val_ptr, |
| 638 |
usmDHUserAuthKeyChange_val_ptr_len); |
| 639 |
|
| 640 |
return MFD_SUCCESS; |
| 641 |
} /* usmDHUserAuthKeyChange_set */ |
| 642 |
|
| 643 |
/** |
| 644 |
* undo the previous set. |
| 645 |
* |
| 646 |
* @param rowreq_ctx |
| 647 |
* Pointer to the users context. |
| 648 |
*/ |
| 649 |
int |
| 650 |
usmDHUserAuthKeyChange_undo(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx) |
| 651 |
{ |
| 652 |
struct usmUser *undouser; |
| 653 |
|
| 654 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserAuthKeyChange_undo", |
| 655 |
"called\n")); |
| 656 |
|
| 657 |
netsnmp_assert(NULL != rowreq_ctx); |
| 658 |
|
| 659 |
/* |
| 660 |
* TODO:456:o: |-> Clean up usmDHUserAuthKeyChange undo. |
| 661 |
*/ |
| 662 |
/* |
| 663 |
* copy usmDHUserAuthKeyChange and usmDHUserAuthKeyChange_len data |
| 664 |
* set rowreq_ctx->data->usmDHUserAuthKeyChange from rowreq_ctx->undo->usmDHUserAuthKeyChange |
| 665 |
*/ |
| 666 |
undouser = rowreq_ctx->undo; |
| 667 |
|
| 668 |
undouser->authKeyLen = rowreq_ctx->data->authKeyLen; |
| 669 |
SNMP_FREE(rowreq_ctx->data->authKey); |
| 670 |
rowreq_ctx->data->authKey = undouser->authKey; |
| 671 |
undouser->authKey = NULL; |
| 672 |
|
| 673 |
return MFD_SUCCESS; |
| 674 |
} /* usmDHUserAuthKeyChange_undo */ |
| 675 |
|
| 676 |
/*--------------------------------------------------------------------- |
| 677 |
* SNMP-USM-DH-OBJECTS-MIB::usmDHUserKeyEntry.usmDHUserOwnAuthKeyChange |
| 678 |
* usmDHUserOwnAuthKeyChange is subid 2 of usmDHUserKeyEntry. |
| 679 |
* Its status is Current, and its access level is Create. |
| 680 |
* OID: .1.3.6.1.3.101.1.1.2.1.2 |
| 681 |
* Description: |
| 682 |
The object used to change the agents own Authentication Key |
| 683 |
using a Diffie-Hellman key exchange. |
| 684 |
|
| 685 |
The right-most n bits of the shared secret 'sk', where 'n' is the |
| 686 |
number of bits required for the protocol defined by |
| 687 |
usmUserAuthProtocol, are installed as the operational |
| 688 |
authentication key for this row after a successful SET. |
| 689 |
* |
| 690 |
* Attributes: |
| 691 |
* accessible 1 isscalar 0 enums 0 hasdefval 0 |
| 692 |
* readable 1 iscolumn 1 ranges 0 hashint 0 |
| 693 |
* settable 1 |
| 694 |
* |
| 695 |
* |
| 696 |
* Its syntax is DHKeyChange (based on perltype OCTETSTR) |
| 697 |
* The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) |
| 698 |
* This data type requires a length. |
| 699 |
*/ |
| 700 |
/** |
| 701 |
* Check that the proposed new value is potentially valid. |
| 702 |
* |
| 703 |
* @param rowreq_ctx |
| 704 |
* Pointer to the row request context. |
| 705 |
* @param usmDHUserOwnAuthKeyChange_val_ptr |
| 706 |
* A char containing the new value. |
| 707 |
* @param usmDHUserOwnAuthKeyChange_val_ptr_len |
| 708 |
* The size (in bytes) of the data pointed to by usmDHUserOwnAuthKeyChange_val_ptr |
| 709 |
* |
| 710 |
* @retval MFD_SUCCESS : incoming value is legal |
| 711 |
* @retval MFD_NOT_VALID_NOW : incoming value is not valid now |
| 712 |
* @retval MFD_NOT_VALID_EVER : incoming value is never valid |
| 713 |
* |
| 714 |
* This is the place to check for requirements that are not |
| 715 |
* expressed in the mib syntax (for example, a requirement that |
| 716 |
* is detailed in the description for an object). |
| 717 |
* |
| 718 |
* Since you aren't using a generated data context, you also need to |
| 719 |
* check the length, to make sure you don't overflow your storage space. |
| 720 |
* |
| 721 |
* You should check that the requested change between the undo value and the |
| 722 |
* new value is legal (ie, the transistion from one value to another |
| 723 |
* is legal). |
| 724 |
* |
| 725 |
*@note |
| 726 |
* This check is only to determine if the new value |
| 727 |
* is \b potentially valid. This is the first check of many, and |
| 728 |
* is one of the simplest ones. |
| 729 |
* |
| 730 |
*@note |
| 731 |
* this is not the place to do any checks for values |
| 732 |
* which depend on some other value in the mib. Those |
| 733 |
* types of checks should be done in the |
| 734 |
* usmDHUserKeyTable_check_dependencies() function. |
| 735 |
* |
| 736 |
* The following checks have already been done for you: |
| 737 |
* The syntax is ASN_OCTET_STR |
| 738 |
* |
| 739 |
* If there a no other checks you need to do, simply return MFD_SUCCESS. |
| 740 |
* |
| 741 |
*/ |
| 742 |
int |
| 743 |
usmDHUserOwnAuthKeyChange_check_value(usmDHUserKeyTable_rowreq_ctx * |
| 744 |
rowreq_ctx, |
| 745 |
u_char *usmDHUserOwnAuthKeyChange_val_ptr, |
| 746 |
size_t |
| 747 |
usmDHUserOwnAuthKeyChange_val_ptr_len) |
| 748 |
{ |
| 749 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserOwnAuthKeyChange_check_value", "called\n")); |
| 750 |
|
| 751 |
/** should never get a NULL pointer */ |
| 752 |
netsnmp_assert(NULL != rowreq_ctx); |
| 753 |
netsnmp_assert(NULL != usmDHUserOwnAuthKeyChange_val_ptr); |
| 754 |
|
| 755 |
/* |
| 756 |
* TODO:441:o: |-> Check for valid usmDHUserOwnAuthKeyChange value. |
| 757 |
*/ |
| 758 |
return |
| 759 |
usmDHUserAuthKeyChange_check_value(rowreq_ctx, |
| 760 |
usmDHUserOwnAuthKeyChange_val_ptr, |
| 761 |
usmDHUserOwnAuthKeyChange_val_ptr_len); |
| 762 |
} /* usmDHUserOwnAuthKeyChange_check_value */ |
| 763 |
|
| 764 |
/** |
| 765 |
* Save old value information |
| 766 |
* |
| 767 |
* @param rowreq_ctx |
| 768 |
* Pointer to the table context (usmDHUserKeyTable_rowreq_ctx) |
| 769 |
* |
| 770 |
* @retval MFD_SUCCESS : success |
| 771 |
* @retval MFD_ERROR : error. set will fail. |
| 772 |
* |
| 773 |
* This function will be called after the table level undo setup function |
| 774 |
* usmDHUserKeyTable_undo_setup has been called. |
| 775 |
* |
| 776 |
*@note |
| 777 |
* this function will only be called if a new value is set for this column. |
| 778 |
* |
| 779 |
* If there is any setup specific to a particular column (e.g. allocating |
| 780 |
* memory for a string), you should do that setup in this function, so it |
| 781 |
* won't be done unless it is necessary. |
| 782 |
*/ |
| 783 |
int |
| 784 |
usmDHUserOwnAuthKeyChange_undo_setup(usmDHUserKeyTable_rowreq_ctx * |
| 785 |
rowreq_ctx) |
| 786 |
{ |
| 787 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserOwnAuthKeyChange_undo_setup", "called\n")); |
| 788 |
|
| 789 |
/** should never get a NULL pointer */ |
| 790 |
netsnmp_assert(NULL != rowreq_ctx); |
| 791 |
|
| 792 |
/* |
| 793 |
* TODO:455:o: |-> Setup usmDHUserOwnAuthKeyChange undo. |
| 794 |
*/ |
| 795 |
/* |
| 796 |
* copy usmDHUserOwnAuthKeyChange and usmDHUserOwnAuthKeyChange_len data |
| 797 |
* set rowreq_ctx->undo->usmDHUserOwnAuthKeyChange from rowreq_ctx->data->usmDHUserOwnAuthKeyChange |
| 798 |
*/ |
| 799 |
return usmDHUserAuthKeyChange_undo_setup(rowreq_ctx); |
| 800 |
} /* usmDHUserOwnAuthKeyChange_undo_setup */ |
| 801 |
|
| 802 |
/** |
| 803 |
* Set the new value. |
| 804 |
* |
| 805 |
* @param rowreq_ctx |
| 806 |
* Pointer to the users context. You should know how to |
| 807 |
* manipulate the value from this object. |
| 808 |
* @param usmDHUserOwnAuthKeyChange_val_ptr |
| 809 |
* A char containing the new value. |
| 810 |
* @param usmDHUserOwnAuthKeyChange_val_ptr_len |
| 811 |
* The size (in bytes) of the data pointed to by usmDHUserOwnAuthKeyChange_val_ptr |
| 812 |
*/ |
| 813 |
int |
| 814 |
usmDHUserOwnAuthKeyChange_set(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx, |
| 815 |
u_char *usmDHUserOwnAuthKeyChange_val_ptr, |
| 816 |
size_t usmDHUserOwnAuthKeyChange_val_ptr_len) |
| 817 |
{ |
| 818 |
|
| 819 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserOwnAuthKeyChange_set", |
| 820 |
"called\n")); |
| 821 |
|
| 822 |
/** should never get a NULL pointer */ |
| 823 |
netsnmp_assert(NULL != rowreq_ctx); |
| 824 |
netsnmp_assert(NULL != usmDHUserOwnAuthKeyChange_val_ptr); |
| 825 |
|
| 826 |
/* |
| 827 |
* TODO:461:M: |-> Set usmDHUserOwnAuthKeyChange value. |
| 828 |
* set usmDHUserOwnAuthKeyChange value in rowreq_ctx->data |
| 829 |
*/ |
| 830 |
return usmDHUserAuthKeyChange_set(rowreq_ctx, |
| 831 |
usmDHUserOwnAuthKeyChange_val_ptr, |
| 832 |
usmDHUserOwnAuthKeyChange_val_ptr_len); |
| 833 |
} /* usmDHUserOwnAuthKeyChange_set */ |
| 834 |
|
| 835 |
/** |
| 836 |
* undo the previous set. |
| 837 |
* |
| 838 |
* @param rowreq_ctx |
| 839 |
* Pointer to the users context. |
| 840 |
*/ |
| 841 |
int |
| 842 |
usmDHUserOwnAuthKeyChange_undo(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx) |
| 843 |
{ |
| 844 |
|
| 845 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserOwnAuthKeyChange_undo", |
| 846 |
"called\n")); |
| 847 |
|
| 848 |
netsnmp_assert(NULL != rowreq_ctx); |
| 849 |
|
| 850 |
/* |
| 851 |
* TODO:456:o: |-> Clean up usmDHUserOwnAuthKeyChange undo. |
| 852 |
*/ |
| 853 |
/* |
| 854 |
* copy usmDHUserOwnAuthKeyChange and usmDHUserOwnAuthKeyChange_len data |
| 855 |
* set rowreq_ctx->data->usmDHUserOwnAuthKeyChange from rowreq_ctx->undo->usmDHUserOwnAuthKeyChange |
| 856 |
*/ |
| 857 |
return usmDHUserAuthKeyChange_undo(rowreq_ctx); |
| 858 |
} /* usmDHUserOwnAuthKeyChange_undo */ |
| 859 |
|
| 860 |
/*--------------------------------------------------------------------- |
| 861 |
* SNMP-USM-DH-OBJECTS-MIB::usmDHUserKeyEntry.usmDHUserPrivKeyChange |
| 862 |
* usmDHUserPrivKeyChange is subid 3 of usmDHUserKeyEntry. |
| 863 |
* Its status is Current, and its access level is Create. |
| 864 |
* OID: .1.3.6.1.3.101.1.1.2.1.3 |
| 865 |
* Description: |
| 866 |
The object used to change any given user's Privacy Key using |
| 867 |
a Diffie-Hellman key exchange. |
| 868 |
|
| 869 |
The right-most n bits of the shared secret 'sk', where 'n' is the |
| 870 |
number of bits required for the protocol defined by |
| 871 |
usmUserPrivProtocol, are installed as the operational privacy key |
| 872 |
for this row after a successful SET. |
| 873 |
* |
| 874 |
* Attributes: |
| 875 |
* accessible 1 isscalar 0 enums 0 hasdefval 0 |
| 876 |
* readable 1 iscolumn 1 ranges 0 hashint 0 |
| 877 |
* settable 1 |
| 878 |
* |
| 879 |
* |
| 880 |
* Its syntax is DHKeyChange (based on perltype OCTETSTR) |
| 881 |
* The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) |
| 882 |
* This data type requires a length. |
| 883 |
*/ |
| 884 |
/** |
| 885 |
* Check that the proposed new value is potentially valid. |
| 886 |
* |
| 887 |
* @param rowreq_ctx |
| 888 |
* Pointer to the row request context. |
| 889 |
* @param usmDHUserPrivKeyChange_val_ptr |
| 890 |
* A char containing the new value. |
| 891 |
* @param usmDHUserPrivKeyChange_val_ptr_len |
| 892 |
* The size (in bytes) of the data pointed to by usmDHUserPrivKeyChange_val_ptr |
| 893 |
* |
| 894 |
* @retval MFD_SUCCESS : incoming value is legal |
| 895 |
* @retval MFD_NOT_VALID_NOW : incoming value is not valid now |
| 896 |
* @retval MFD_NOT_VALID_EVER : incoming value is never valid |
| 897 |
* |
| 898 |
* This is the place to check for requirements that are not |
| 899 |
* expressed in the mib syntax (for example, a requirement that |
| 900 |
* is detailed in the description for an object). |
| 901 |
* |
| 902 |
* Since you aren't using a generated data context, you also need to |
| 903 |
* check the length, to make sure you don't overflow your storage space. |
| 904 |
* |
| 905 |
* You should check that the requested change between the undo value and the |
| 906 |
* new value is legal (ie, the transistion from one value to another |
| 907 |
* is legal). |
| 908 |
* |
| 909 |
*@note |
| 910 |
* This check is only to determine if the new value |
| 911 |
* is \b potentially valid. This is the first check of many, and |
| 912 |
* is one of the simplest ones. |
| 913 |
* |
| 914 |
*@note |
| 915 |
* this is not the place to do any checks for values |
| 916 |
* which depend on some other value in the mib. Those |
| 917 |
* types of checks should be done in the |
| 918 |
* usmDHUserKeyTable_check_dependencies() function. |
| 919 |
* |
| 920 |
* The following checks have already been done for you: |
| 921 |
* The syntax is ASN_OCTET_STR |
| 922 |
* |
| 923 |
* If there a no other checks you need to do, simply return MFD_SUCCESS. |
| 924 |
* |
| 925 |
*/ |
| 926 |
int |
| 927 |
usmDHUserPrivKeyChange_check_value(usmDHUserKeyTable_rowreq_ctx * |
| 928 |
rowreq_ctx, |
| 929 |
u_char *usmDHUserPrivKeyChange_val_ptr, |
| 930 |
size_t |
| 931 |
usmDHUserPrivKeyChange_val_ptr_len) |
| 932 |
{ |
| 933 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserPrivKeyChange_check_value", "called\n")); |
| 934 |
|
| 935 |
/** should never get a NULL pointer */ |
| 936 |
netsnmp_assert(NULL != rowreq_ctx); |
| 937 |
netsnmp_assert(NULL != usmDHUserPrivKeyChange_val_ptr); |
| 938 |
|
| 939 |
/* |
| 940 |
* TODO:441:o: |-> Check for valid usmDHUserPrivKeyChange value. |
| 941 |
*/ |
| 942 |
return usmDHUserCheckValue(rowreq_ctx->data, 0, |
| 943 |
usmDHUserPrivKeyChange_val_ptr, |
| 944 |
usmDHUserPrivKeyChange_val_ptr_len); |
| 945 |
} /* usmDHUserPrivKeyChange_check_value */ |
| 946 |
|
| 947 |
/** |
| 948 |
* Save old value information |
| 949 |
* |
| 950 |
* @param rowreq_ctx |
| 951 |
* Pointer to the table context (usmDHUserKeyTable_rowreq_ctx) |
| 952 |
* |
| 953 |
* @retval MFD_SUCCESS : success |
| 954 |
* @retval MFD_ERROR : error. set will fail. |
| 955 |
* |
| 956 |
* This function will be called after the table level undo setup function |
| 957 |
* usmDHUserKeyTable_undo_setup has been called. |
| 958 |
* |
| 959 |
*@note |
| 960 |
* this function will only be called if a new value is set for this column. |
| 961 |
* |
| 962 |
* If there is any setup specific to a particular column (e.g. allocating |
| 963 |
* memory for a string), you should do that setup in this function, so it |
| 964 |
* won't be done unless it is necessary. |
| 965 |
*/ |
| 966 |
int |
| 967 |
usmDHUserPrivKeyChange_undo_setup(usmDHUserKeyTable_rowreq_ctx * |
| 968 |
rowreq_ctx) |
| 969 |
{ |
| 970 |
struct usmUser *undouser; |
| 971 |
|
| 972 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserPrivKeyChange_undo_setup", "called\n")); |
| 973 |
|
| 974 |
/** should never get a NULL pointer */ |
| 975 |
netsnmp_assert(NULL != rowreq_ctx); |
| 976 |
|
| 977 |
/* |
| 978 |
* TODO:455:o: |-> Setup usmDHUserPrivKeyChange undo. |
| 979 |
*/ |
| 980 |
/* |
| 981 |
* copy usmDHUserPrivKeyChange and usmDHUserPrivKeyChange_len data |
| 982 |
* set rowreq_ctx->undo->usmDHUserPrivKeyChange from rowreq_ctx->data->usmDHUserPrivKeyChange |
| 983 |
*/ |
| 984 |
undouser = rowreq_ctx->undo; |
| 985 |
|
| 986 |
undouser->privKeyLen = rowreq_ctx->data->privKeyLen; |
| 987 |
undouser->privKey = netsnmp_memdup(rowreq_ctx->data->privKey, |
| 988 |
rowreq_ctx->data->privKeyLen); |
| 989 |
|
| 990 |
return MFD_SUCCESS; |
| 991 |
} /* usmDHUserPrivKeyChange_undo_setup */ |
| 992 |
|
| 993 |
/** |
| 994 |
* Set the new value. |
| 995 |
* |
| 996 |
* @param rowreq_ctx |
| 997 |
* Pointer to the users context. You should know how to |
| 998 |
* manipulate the value from this object. |
| 999 |
* @param usmDHUserPrivKeyChange_val_ptr |
| 1000 |
* A char containing the new value. |
| 1001 |
* @param usmDHUserPrivKeyChange_val_ptr_len |
| 1002 |
* The size (in bytes) of the data pointed to by usmDHUserPrivKeyChange_val_ptr |
| 1003 |
*/ |
| 1004 |
int |
| 1005 |
usmDHUserPrivKeyChange_set(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx, |
| 1006 |
u_char *usmDHUserPrivKeyChange_val_ptr, |
| 1007 |
size_t usmDHUserPrivKeyChange_val_ptr_len) |
| 1008 |
{ |
| 1009 |
|
| 1010 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserPrivKeyChange_set", |
| 1011 |
"called\n")); |
| 1012 |
|
| 1013 |
/** should never get a NULL pointer */ |
| 1014 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1015 |
netsnmp_assert(NULL != usmDHUserPrivKeyChange_val_ptr); |
| 1016 |
|
| 1017 |
/* |
| 1018 |
* TODO:461:M: |-> Set usmDHUserPrivKeyChange value. |
| 1019 |
* set usmDHUserPrivKeyChange value in rowreq_ctx->data |
| 1020 |
*/ |
| 1021 |
usmDHSetKey(rowreq_ctx->data, 0, |
| 1022 |
usmDHUserPrivKeyChange_val_ptr, |
| 1023 |
usmDHUserPrivKeyChange_val_ptr_len); |
| 1024 |
|
| 1025 |
return MFD_SUCCESS; |
| 1026 |
} /* usmDHUserPrivKeyChange_set */ |
| 1027 |
|
| 1028 |
/** |
| 1029 |
* undo the previous set. |
| 1030 |
* |
| 1031 |
* @param rowreq_ctx |
| 1032 |
* Pointer to the users context. |
| 1033 |
*/ |
| 1034 |
int |
| 1035 |
usmDHUserPrivKeyChange_undo(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx) |
| 1036 |
{ |
| 1037 |
struct usmUser *undouser; |
| 1038 |
|
| 1039 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserPrivKeyChange_undo", |
| 1040 |
"called\n")); |
| 1041 |
|
| 1042 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1043 |
|
| 1044 |
/* |
| 1045 |
* TODO:456:o: |-> Clean up usmDHUserPrivKeyChange undo. |
| 1046 |
*/ |
| 1047 |
/* |
| 1048 |
* copy usmDHUserPrivKeyChange and usmDHUserPrivKeyChange_len data |
| 1049 |
* set rowreq_ctx->data->usmDHUserPrivKeyChange from rowreq_ctx->undo->usmDHUserPrivKeyChange |
| 1050 |
*/ |
| 1051 |
undouser = rowreq_ctx->undo; |
| 1052 |
|
| 1053 |
/** uncopy priv key */ |
| 1054 |
undouser->privKeyLen = rowreq_ctx->data->privKeyLen; |
| 1055 |
SNMP_FREE(rowreq_ctx->data->privKey); |
| 1056 |
rowreq_ctx->data->privKey = undouser->privKey; |
| 1057 |
undouser->privKey = NULL; |
| 1058 |
|
| 1059 |
return MFD_SUCCESS; |
| 1060 |
} /* usmDHUserPrivKeyChange_undo */ |
| 1061 |
|
| 1062 |
/*--------------------------------------------------------------------- |
| 1063 |
* SNMP-USM-DH-OBJECTS-MIB::usmDHUserKeyEntry.usmDHUserOwnPrivKeyChange |
| 1064 |
* usmDHUserOwnPrivKeyChange is subid 4 of usmDHUserKeyEntry. |
| 1065 |
* Its status is Current, and its access level is Create. |
| 1066 |
* OID: .1.3.6.1.3.101.1.1.2.1.4 |
| 1067 |
* Description: |
| 1068 |
The object used to change the agent's own Privacy Key using a |
| 1069 |
Diffie-Hellman key exchange. |
| 1070 |
|
| 1071 |
The right-most n bits of the shared secret 'sk', where 'n' is the |
| 1072 |
number of bits required for the protocol defined by |
| 1073 |
usmUserPrivProtocol, are installed as the operational privacy key |
| 1074 |
for this row after a successful SET. |
| 1075 |
* |
| 1076 |
* Attributes: |
| 1077 |
* accessible 1 isscalar 0 enums 0 hasdefval 0 |
| 1078 |
* readable 1 iscolumn 1 ranges 0 hashint 0 |
| 1079 |
* settable 1 |
| 1080 |
* |
| 1081 |
* |
| 1082 |
* Its syntax is DHKeyChange (based on perltype OCTETSTR) |
| 1083 |
* The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) |
| 1084 |
* This data type requires a length. |
| 1085 |
*/ |
| 1086 |
/** |
| 1087 |
* Check that the proposed new value is potentially valid. |
| 1088 |
* |
| 1089 |
* @param rowreq_ctx |
| 1090 |
* Pointer to the row request context. |
| 1091 |
* @param usmDHUserOwnPrivKeyChange_val_ptr |
| 1092 |
* A char containing the new value. |
| 1093 |
* @param usmDHUserOwnPrivKeyChange_val_ptr_len |
| 1094 |
* The size (in bytes) of the data pointed to by usmDHUserOwnPrivKeyChange_val_ptr |
| 1095 |
* |
| 1096 |
* @retval MFD_SUCCESS : incoming value is legal |
| 1097 |
* @retval MFD_NOT_VALID_NOW : incoming value is not valid now |
| 1098 |
* @retval MFD_NOT_VALID_EVER : incoming value is never valid |
| 1099 |
* |
| 1100 |
* This is the place to check for requirements that are not |
| 1101 |
* expressed in the mib syntax (for example, a requirement that |
| 1102 |
* is detailed in the description for an object). |
| 1103 |
* |
| 1104 |
* Since you aren't using a generated data context, you also need to |
| 1105 |
* check the length, to make sure you don't overflow your storage space. |
| 1106 |
* |
| 1107 |
* You should check that the requested change between the undo value and the |
| 1108 |
* new value is legal (ie, the transistion from one value to another |
| 1109 |
* is legal). |
| 1110 |
* |
| 1111 |
*@note |
| 1112 |
* This check is only to determine if the new value |
| 1113 |
* is \b potentially valid. This is the first check of many, and |
| 1114 |
* is one of the simplest ones. |
| 1115 |
* |
| 1116 |
*@note |
| 1117 |
* this is not the place to do any checks for values |
| 1118 |
* which depend on some other value in the mib. Those |
| 1119 |
* types of checks should be done in the |
| 1120 |
* usmDHUserKeyTable_check_dependencies() function. |
| 1121 |
* |
| 1122 |
* The following checks have already been done for you: |
| 1123 |
* The syntax is ASN_OCTET_STR |
| 1124 |
* |
| 1125 |
* If there a no other checks you need to do, simply return MFD_SUCCESS. |
| 1126 |
* |
| 1127 |
*/ |
| 1128 |
int |
| 1129 |
usmDHUserOwnPrivKeyChange_check_value(usmDHUserKeyTable_rowreq_ctx * |
| 1130 |
rowreq_ctx, |
| 1131 |
u_char *usmDHUserOwnPrivKeyChange_val_ptr, |
| 1132 |
size_t |
| 1133 |
usmDHUserOwnPrivKeyChange_val_ptr_len) |
| 1134 |
{ |
| 1135 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserOwnPrivKeyChange_check_value", "called\n")); |
| 1136 |
|
| 1137 |
/** should never get a NULL pointer */ |
| 1138 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1139 |
netsnmp_assert(NULL != usmDHUserOwnPrivKeyChange_val_ptr); |
| 1140 |
|
| 1141 |
/* |
| 1142 |
* TODO:441:o: |-> Check for valid usmDHUserOwnPrivKeyChange value. |
| 1143 |
*/ |
| 1144 |
return |
| 1145 |
usmDHUserPrivKeyChange_check_value(rowreq_ctx, |
| 1146 |
usmDHUserOwnPrivKeyChange_val_ptr, |
| 1147 |
usmDHUserOwnPrivKeyChange_val_ptr_len); |
| 1148 |
} /* usmDHUserOwnPrivKeyChange_check_value */ |
| 1149 |
|
| 1150 |
/** |
| 1151 |
* Save old value information |
| 1152 |
* |
| 1153 |
* @param rowreq_ctx |
| 1154 |
* Pointer to the table context (usmDHUserKeyTable_rowreq_ctx) |
| 1155 |
* |
| 1156 |
* @retval MFD_SUCCESS : success |
| 1157 |
* @retval MFD_ERROR : error. set will fail. |
| 1158 |
* |
| 1159 |
* This function will be called after the table level undo setup function |
| 1160 |
* usmDHUserKeyTable_undo_setup has been called. |
| 1161 |
* |
| 1162 |
*@note |
| 1163 |
* this function will only be called if a new value is set for this column. |
| 1164 |
* |
| 1165 |
* If there is any setup specific to a particular column (e.g. allocating |
| 1166 |
* memory for a string), you should do that setup in this function, so it |
| 1167 |
* won't be done unless it is necessary. |
| 1168 |
*/ |
| 1169 |
int |
| 1170 |
usmDHUserOwnPrivKeyChange_undo_setup(usmDHUserKeyTable_rowreq_ctx * |
| 1171 |
rowreq_ctx) |
| 1172 |
{ |
| 1173 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserOwnPrivKeyChange_undo_setup", "called\n")); |
| 1174 |
|
| 1175 |
/** should never get a NULL pointer */ |
| 1176 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1177 |
|
| 1178 |
/* |
| 1179 |
* TODO:455:o: |-> Setup usmDHUserOwnPrivKeyChange undo. |
| 1180 |
*/ |
| 1181 |
/* |
| 1182 |
* copy usmDHUserOwnPrivKeyChange and usmDHUserOwnPrivKeyChange_len data |
| 1183 |
* set rowreq_ctx->undo->usmDHUserOwnPrivKeyChange from rowreq_ctx->data->usmDHUserOwnPrivKeyChange |
| 1184 |
*/ |
| 1185 |
return usmDHUserPrivKeyChange_undo_setup(rowreq_ctx); |
| 1186 |
} /* usmDHUserOwnPrivKeyChange_undo_setup */ |
| 1187 |
|
| 1188 |
/** |
| 1189 |
* Set the new value. |
| 1190 |
* |
| 1191 |
* @param rowreq_ctx |
| 1192 |
* Pointer to the users context. You should know how to |
| 1193 |
* manipulate the value from this object. |
| 1194 |
* @param usmDHUserOwnPrivKeyChange_val_ptr |
| 1195 |
* A char containing the new value. |
| 1196 |
* @param usmDHUserOwnPrivKeyChange_val_ptr_len |
| 1197 |
* The size (in bytes) of the data pointed to by usmDHUserOwnPrivKeyChange_val_ptr |
| 1198 |
*/ |
| 1199 |
int |
| 1200 |
usmDHUserOwnPrivKeyChange_set(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx, |
| 1201 |
u_char *usmDHUserOwnPrivKeyChange_val_ptr, |
| 1202 |
size_t usmDHUserOwnPrivKeyChange_val_ptr_len) |
| 1203 |
{ |
| 1204 |
|
| 1205 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserOwnPrivKeyChange_set", |
| 1206 |
"called\n")); |
| 1207 |
|
| 1208 |
/** should never get a NULL pointer */ |
| 1209 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1210 |
netsnmp_assert(NULL != usmDHUserOwnPrivKeyChange_val_ptr); |
| 1211 |
|
| 1212 |
/* |
| 1213 |
* TODO:461:M: |-> Set usmDHUserOwnPrivKeyChange value. |
| 1214 |
* set usmDHUserOwnPrivKeyChange value in rowreq_ctx->data |
| 1215 |
*/ |
| 1216 |
return usmDHUserPrivKeyChange_set(rowreq_ctx, |
| 1217 |
usmDHUserOwnPrivKeyChange_val_ptr, |
| 1218 |
usmDHUserOwnPrivKeyChange_val_ptr_len); |
| 1219 |
} /* usmDHUserOwnPrivKeyChange_set */ |
| 1220 |
|
| 1221 |
/** |
| 1222 |
* undo the previous set. |
| 1223 |
* |
| 1224 |
* @param rowreq_ctx |
| 1225 |
* Pointer to the users context. |
| 1226 |
*/ |
| 1227 |
int |
| 1228 |
usmDHUserOwnPrivKeyChange_undo(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx) |
| 1229 |
{ |
| 1230 |
|
| 1231 |
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserOwnPrivKeyChange_undo", |
| 1232 |
"called\n")); |
| 1233 |
|
| 1234 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1235 |
|
| 1236 |
/* |
| 1237 |
* TODO:456:o: |-> Clean up usmDHUserOwnPrivKeyChange undo. |
| 1238 |
*/ |
| 1239 |
/* |
| 1240 |
* copy usmDHUserOwnPrivKeyChange and usmDHUserOwnPrivKeyChange_len data |
| 1241 |
* set rowreq_ctx->data->usmDHUserOwnPrivKeyChange from rowreq_ctx->undo->usmDHUserOwnPrivKeyChange |
| 1242 |
*/ |
| 1243 |
return usmDHUserPrivKeyChange_undo(rowreq_ctx); |
| 1244 |
} /* usmDHUserOwnPrivKeyChange_undo */ |
| 1245 |
|
| 1246 |
/** |
| 1247 |
* check dependencies |
| 1248 |
* |
| 1249 |
* This is useful for for tables which have dependencies between columns |
| 1250 |
* (or rows, or tables). For example, two columns allocating a percentage |
| 1251 |
* of something add up 100%. |
| 1252 |
* |
| 1253 |
* Should you need different behavior depending on which columns were |
| 1254 |
* set, rowreq_ctx->column_set_flags will indicate which writeable columns were |
| 1255 |
* set. The definitions for the COLUMN_*_FLAG bits can be found in |
| 1256 |
* usmDHUserKeyTable_oids.h. |
| 1257 |
* A new row will have the MFD_ROW_CREATED bit set in rowreq_flags. |
| 1258 |
* |
| 1259 |
* @retval MFD_SUCCESS all the changes to the row are legal |
| 1260 |
* @retval MFD_ERROR one or more changes are not legal |
| 1261 |
* |
| 1262 |
* (see README-table-usmDHUserKeyTable if you don't have dependencies) |
| 1263 |
*/ |
| 1264 |
int |
| 1265 |
usmDHUserKeyTable_check_dependencies(usmDHUserKeyTable_rowreq_ctx * |
| 1266 |
rowreq_ctx) |
| 1267 |
{ |
| 1268 |
int rc = MFD_SUCCESS; |
| 1269 |
int flags; |
| 1270 |
|
| 1271 |
DEBUGMSGTL(("internal:usmDHUserKeyTable:usmDHUserKeyTable_check_dependencies", "called\n")); |
| 1272 |
|
| 1273 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1274 |
|
| 1275 |
/* |
| 1276 |
* TODO:470:o: Check usmDHUserKeyTable row dependencies. |
| 1277 |
* check that all new value are legal and consistent with each other |
| 1278 |
*/ |
| 1279 |
flags = rowreq_ctx->column_set_flags; |
| 1280 |
|
| 1281 |
if (flags & COLUMN_USMDHUSERAUTHKEYCHANGE_FLAG && |
| 1282 |
flags & COLUMN_USMDHUSEROWNAUTHKEYCHANGE_FLAG) { |
| 1283 |
return MFD_ERROR; |
| 1284 |
} |
| 1285 |
|
| 1286 |
if (flags & COLUMN_USMDHUSERPRIVKEYCHANGE_FLAG && |
| 1287 |
flags & COLUMN_USMDHUSEROWNPRIVKEYCHANGE_FLAG) { |
| 1288 |
return MFD_ERROR; |
| 1289 |
} |
| 1290 |
|
| 1291 |
return rc; |
| 1292 |
} /* usmDHUserKeyTable_check_dependencies */ |
| 1293 |
|
| 1294 |
/** @} */ |