📄 snmpnotifyfiltertable.c
字号:
case COMMIT: /* Things are working well, so it's now safe to make the change permanently. Make sure that anything done here can't fail! */ SNMP_FREE(tmpvar); break; } return SNMP_ERR_NOERROR;}intwrite_snmpNotifyFilterType(int action, u_char *var_val, u_char var_val_type, size_t var_val_len, u_char *statP, oid *name, size_t name_len){ static int tmpvar; struct snmpNotifyFilterTable_data *StorageTmp = NULL; size_t newlen=name_len - (sizeof(snmpNotifyFilterTable_variables_oid)/sizeof(oid) + 3 - 1); DEBUGMSGTL(("snmpNotifyFilterTable", "write_snmpNotifyFilterType entering action=%d... \n", action)); if ((StorageTmp = (struct snmpNotifyFilterTable_data *) header_complex((struct header_complex_index *)snmpNotifyFilterTableStorage, NULL, &name[sizeof(snmpNotifyFilterTable_variables_oid)/sizeof(oid) + 3 - 1], &newlen, 1, NULL, NULL)) == NULL) return SNMP_ERR_NOSUCHNAME; /* remove if you support creation here */ switch ( action ) { case RESERVE1: if (var_val_type != ASN_INTEGER){ fprintf(stderr, "write to snmpNotifyFilterType not ASN_INTEGER\n"); return SNMP_ERR_WRONGTYPE; } break; case RESERVE2: /* memory reseveration, final preparation... */ break; case FREE: /* Release any resources that have been allocated */ break; case ACTION: /* The variable has been stored in long_ret for you to use, and you have just been asked to do something with it. Note that anything done here must be reversable in the UNDO case */ tmpvar = StorageTmp->snmpNotifyFilterType; StorageTmp->snmpNotifyFilterType = *((long *) var_val); break; case UNDO: /* Back out any changes made in the ACTION case */ StorageTmp->snmpNotifyFilterType = tmpvar; break; case COMMIT: /* Things are working well, so it's now safe to make the change permanently. Make sure that anything done here can't fail! */ break; } return SNMP_ERR_NOERROR;}intwrite_snmpNotifyFilterStorageType(int action, u_char *var_val, u_char var_val_type, size_t var_val_len, u_char *statP, oid *name, size_t name_len){ static int tmpvar; struct snmpNotifyFilterTable_data *StorageTmp = NULL; size_t newlen=name_len - (sizeof(snmpNotifyFilterTable_variables_oid)/sizeof(oid) + 3 - 1); DEBUGMSGTL(("snmpNotifyFilterTable", "write_snmpNotifyFilterStorageType entering action=%d... \n", action)); if ((StorageTmp = (struct snmpNotifyFilterTable_data *) header_complex((struct header_complex_index *)snmpNotifyFilterTableStorage, NULL, &name[sizeof(snmpNotifyFilterTable_variables_oid)/sizeof(oid) + 3 - 1], &newlen, 1, NULL, NULL)) == NULL) return SNMP_ERR_NOSUCHNAME; /* remove if you support creation here */ switch ( action ) { case RESERVE1: if (var_val_type != ASN_INTEGER){ fprintf(stderr, "write to snmpNotifyFilterStorageType not ASN_INTEGER\n"); return SNMP_ERR_WRONGTYPE; } break; case RESERVE2: /* memory reseveration, final preparation... */ break; case FREE: /* Release any resources that have been allocated */ break; case ACTION: /* The variable has been stored in long_ret for you to use, and you have just been asked to do something with it. Note that anything done here must be reversable in the UNDO case */ tmpvar = StorageTmp->snmpNotifyFilterStorageType; StorageTmp->snmpNotifyFilterStorageType = *((long *) var_val); break; case UNDO: /* Back out any changes made in the ACTION case */ StorageTmp->snmpNotifyFilterStorageType = tmpvar; break; case COMMIT: /* Things are working well, so it's now safe to make the change permanently. Make sure that anything done here can't fail! */ break; } return SNMP_ERR_NOERROR;}intwrite_snmpNotifyFilterRowStatus(int action, u_char *var_val, u_char var_val_type, size_t var_val_len, u_char *statP, oid *name, size_t name_len){ struct snmpNotifyFilterTable_data *StorageTmp = NULL; static struct snmpNotifyFilterTable_data *StorageNew, *StorageDel; size_t newlen=name_len - (sizeof(snmpNotifyFilterTable_variables_oid)/sizeof(oid) + 3 - 1); static int old_value; int set_value; static struct variable_list *vars, *vp; struct header_complex_index *hciptr; StorageTmp = (struct snmpNotifyFilterTable_data *) header_complex((struct header_complex_index *)snmpNotifyFilterTableStorage, NULL, &name[sizeof(snmpNotifyFilterTable_variables_oid)/sizeof(oid) + 3 - 1], &newlen, 1, NULL, NULL); if (var_val_type != ASN_INTEGER || var_val == NULL){ fprintf(stderr, "write to snmpNotifyFilterRowStatus not ASN_INTEGER\n"); return SNMP_ERR_WRONGTYPE; } set_value = *((long *) var_val); /* check legal range, and notReady is reserved for us, not a user */ if (set_value < 1 || set_value > 6 || set_value == RS_NOTREADY) return SNMP_ERR_INCONSISTENTVALUE; switch ( action ) { case RESERVE1: /* stage one: test validity */ if (StorageTmp == NULL) { /* create the row now? */ /* ditch illegal values now */ if (set_value == RS_ACTIVE || set_value == RS_NOTINSERVICE) return SNMP_ERR_INCONSISTENTVALUE; } else { /* row exists. Check for a valid state change */ if (set_value == RS_CREATEANDGO || set_value == RS_CREATEANDWAIT) { /* can't create a row that exists */ return SNMP_ERR_INCONSISTENTVALUE; } /* XXX: interaction with row storage type needed */ } break; case RESERVE2: /* memory reseveration, final preparation... */ if (StorageTmp == NULL && (set_value == RS_CREATEANDGO || set_value == RS_CREATEANDWAIT)) { /* creation */ vars = NULL; snmp_varlist_add_variable(&vars, NULL, 0, ASN_OCTET_STR, NULL, 0); /* snmpNotifyFilterSubtree */ snmp_varlist_add_variable(&vars, NULL, 0, ASN_PRIV_IMPLIED_OBJECT_ID, NULL, 0); /* snmpNotifyFilterSubtree */ if (header_complex_parse_oid(&(name[sizeof(snmpNotifyFilterTable_variables_oid)/sizeof(oid)+2]), newlen, vars) != SNMPERR_SUCCESS) { /* XXX: free, zero vars */ return SNMP_ERR_INCONSISTENTNAME; } vp = vars; StorageNew = SNMP_MALLOC_STRUCT(snmpNotifyFilterTable_data); memdup((u_char **) &(StorageNew->snmpNotifyFilterProfileName), (u_char *) vp->val.string, vp->val_len); StorageNew->snmpNotifyFilterProfileNameLen = vp->val_len; vp = vp->next_variable; memdup((u_char **) &(StorageNew->snmpNotifyFilterSubtree), (u_char *) vp->val.objid, vp->val_len); StorageNew->snmpNotifyFilterSubtreeLen = vp->val_len/sizeof(oid); StorageNew->snmpNotifyFilterMask = (char *)calloc(1,1); StorageNew->snmpNotifyFilterMaskLen = 0; StorageNew->snmpNotifyFilterType = SNMPNOTIFYFILTERTYPE_INCLUDED; StorageNew->snmpNotifyFilterStorageType = ST_NONVOLATILE; StorageNew->snmpNotifyFilterRowStatus = set_value; /* XXX: free, zero vars, no longer needed? */ } break; case FREE: /* XXX: free, zero vars */ /* Release any resources that have been allocated */ break; case ACTION: /* The variable has been stored in set_value for you to use, and you have just been asked to do something with it. Note that anything done here must be reversable in the UNDO case */ if (StorageTmp == NULL&& (set_value == RS_CREATEANDGO || set_value == RS_CREATEANDWAIT)) { /* row creation, so add it */ if (StorageNew != NULL) snmpNotifyFilterTable_add(StorageNew); /* XXX: ack, and if it is NULL? */ } else if (set_value != RS_DESTROY) { /* set the flag? */ old_value = StorageTmp->snmpNotifyFilterRowStatus; StorageTmp->snmpNotifyFilterRowStatus = *((long *) var_val); } else { /* destroy... extract it for now */ if (StorageTmp) { hciptr = header_complex_find_entry(snmpNotifyFilterTableStorage, StorageTmp); StorageDel = (struct snmpNotifyFilterTable_data *) header_complex_extract_entry((struct header_complex_index **)&snmpNotifyFilterTableStorage, hciptr); } } break; case UNDO: /* Back out any changes made in the ACTION case */ if (StorageTmp == NULL && (set_value == RS_CREATEANDGO || set_value == RS_CREATEANDWAIT)) { /* row creation, so remove it again */ hciptr = header_complex_find_entry(snmpNotifyFilterTableStorage, StorageNew); StorageDel = (struct snmpNotifyFilterTable_data *) header_complex_extract_entry((struct header_complex_index **)&snmpNotifyFilterTableStorage, hciptr); /* XXX: free it */ } else if (StorageDel != NULL) { /* row deletion, so add it again */ snmpNotifyFilterTable_add(StorageDel); StorageDel = NULL; } else if (set_value != RS_DESTROY) { StorageTmp->snmpNotifyFilterRowStatus = old_value; } break; case COMMIT: /* Things are working well, so it's now safe to make the change permanently. Make sure that anything done here can't fail! */ if (StorageDel != NULL) { StorageDel = NULL; /* XXX: free it, its dead */ } else { if (StorageTmp && StorageTmp->snmpNotifyFilterRowStatus == RS_CREATEANDGO) { StorageTmp->snmpNotifyFilterRowStatus = RS_ACTIVE; } else if (StorageTmp && StorageTmp->snmpNotifyFilterRowStatus == RS_CREATEANDWAIT) { StorageTmp->snmpNotifyFilterRowStatus = RS_NOTINSERVICE; } } break; } return SNMP_ERR_NOERROR;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -