int ROWAPI_do_another_action (oid * name, int tbl_first_index_begin, int action, int *prev_action, TABLE_DEFINTION_T * table_ptr, size_t entry_size) { long long_temp; RMON_ENTRY_T *tmp; if (action == *prev_action) return SNMP_ERR_NOERROR; /* I want to process it only once ! */ *prev_action = action; long_temp = name[tbl_first_index_begin]; switch (action) { case RESERVE1: tmp = ROWAPI_get_clone (table_ptr, long_temp, entry_size); if (!tmp) { ag_trace ("RESERVE1: cannot get clone\n"); return SNMP_ERR_TOOBIG; } break; case FREE: /* if RESERVEx failed: release any resources that have been allocated */ case UNDO: /* if ACTION failed: release any resources that have been allocated */ ROWAPI_delete_clone (table_ptr, long_temp); break; case ACTION: long_temp = ROWAPI_action_check (table_ptr, long_temp); if (0 != long_temp) return long_temp; break; case COMMIT: long_temp = ROWAPI_commit (table_ptr, long_temp); if (0 != long_temp) /* it MUST NOT be */ return long_temp; break; default: ag_trace ("Unknown action %d", (int) action); return SNMP_ERR_GENERR; } /* of switch by actions */ return SNMP_ERR_NOERROR; }
int ROWAPI_commit(TABLE_DEFINTION_T * table_ptr, u_long ctrl_index) { register RMON_ENTRY_T *eptr; eptr = ROWAPI_find(table_ptr, ctrl_index); if (!eptr) { ag_trace("Smth wrong ?"); return SNMP_ERR_GENERR; } eptr->only_just_created = 0; switch (eptr->new_status) { /* this status we want to set */ case RMON1_ENTRY_CREATE_REQUEST: /* copy tmp => eprt */ if (eptr->new_owner) { if (eptr->owner) AGFREE(eptr->owner); eptr->owner = AGSTRDUP(eptr->new_owner); } if (table_ptr->ClbkCopy && eptr->tmp) table_ptr->ClbkCopy(eptr); break; case RMON1_ENTRY_INVALID: ROWAPI_delete_clone(table_ptr, ctrl_index); rowapi_delete(eptr); #if 0 /* for debug */ dbg_f_AG_MEM_REPORT(); #endif break; case RMON1_ENTRY_VALID: /* copy tmp => eprt and activate */ /* * Our MIB understanding extension: we permit to set * VALID when entry doesn't exit, in this case PDU has to have * the nessessary & valid set of non-default values */ if (eptr->new_owner) { if (eptr->owner) AGFREE(eptr->owner); eptr->owner = AGSTRDUP(eptr->new_owner); } if (table_ptr->ClbkCopy && eptr->tmp) table_ptr->ClbkCopy(eptr); if (RMON1_ENTRY_VALID != eptr->status) { rowapi_activate(table_ptr, eptr); } break; case RMON1_ENTRY_UNDER_CREATION: /* deactivate (if need) and copy tmp => eprt */ /* * Our MIB understanding extension: we permit to travel from * VALID to 'UNDER_CREATION' state */ rowapi_deactivate(table_ptr, eptr); if (eptr->new_owner) { if (eptr->owner) AGFREE(eptr->owner); eptr->owner = AGSTRDUP(eptr->new_owner); } if (table_ptr->ClbkCopy && eptr->tmp) table_ptr->ClbkCopy(eptr); break; } ROWAPI_delete_clone(table_ptr, ctrl_index); return SNMP_ERR_NOERROR; }