/* * if (explain) ag_trace ("Dbg:'%s'", explain); */ event_save_log(evptr, explain); if (explain) AGFREE(explain); } return SNMP_ERR_NOERROR; } #if 1 /* debug, but may be used for init. TBD: may be token snmpd.conf ? */ int add_event_entry(int ctrl_index, char *event_description, EVENT_TYPE_T event_type, char *event_community) { register RMON_ENTRY_T *eptr; register CRTL_ENTRY_T *body; int ierr; ierr = ROWAPI_new(table_ptr, ctrl_index); if (ierr) { ag_trace("ROWAPI_new failed with %d", ierr); return ierr; } eptr = ROWAPI_find(table_ptr, ctrl_index); if (!eptr) { ag_trace("ROWAPI_find failed"); return -4; } body = (CRTL_ENTRY_T *) eptr->body; /* * set parameters */ if (event_description) { if (body->event_description) AGFREE(body->event_description); body->event_description = AGSTRDUP(event_description); } if (event_community) { if (body->event_community) AGFREE(body->event_community); body->event_community = AGSTRDUP(event_community); } body->event_type = event_type; eptr->new_status = RMON1_ENTRY_VALID; ierr = ROWAPI_commit(table_ptr, ctrl_index); if (ierr) { ag_trace("ROWAPI_commit failed with %d", ierr); } return ierr; }
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; }
/*************************************************** * Function:var_etherStatsEntry * Purpose: Handles the request for etherStatsEntry variable instances ***************************************************/ u_char * var_etherStatsEntry(struct variable * vp, oid * name, size_t * length, int exact, size_t * var_len, WriteMethod ** write_method) { static long long_return; static CRTL_ENTRY_T theEntry; RMON_ENTRY_T *hdr; *write_method = write_etherStatsEntry; hdr = ROWAPI_header_ControlEntry(vp, name, length, exact, var_len, table_ptr, &theEntry, sizeof(CRTL_ENTRY_T)); if (!hdr) return NULL; if (RMON1_ENTRY_VALID == hdr->status) SYSTEM_get_eth_statistics(&theEntry.data_source, &theEntry.eth); *var_len = sizeof(long); switch (vp->magic) { case IDetherStatsIndex: long_return = hdr->ctrl_index; return (u_char *) & long_return; case IDetherStatsDataSource: *var_len = sizeof(oid) * theEntry.data_source.length; return (unsigned char *) theEntry.data_source.objid; case IDetherStatsDropEvents: long_return = 0; /* theEntry.eth.etherStatsDropEvents; */ return (u_char *) & long_return; case IDetherStatsOctets: long_return = theEntry.eth.octets; return (u_char *) & long_return; case IDetherStatsPkts: long_return = theEntry.eth.packets; return (u_char *) & long_return; case IDetherStatsBroadcastPkts: long_return = theEntry.eth.bcast_pkts; return (u_char *) & long_return; case IDetherStatsMulticastPkts: long_return = theEntry.eth.mcast_pkts; return (u_char *) & long_return; case IDetherStatsCRCAlignErrors: long_return = theEntry.eth.crc_align; return (u_char *) & long_return; case IDetherStatsUndersizePkts: long_return = theEntry.eth.undersize; return (u_char *) & long_return; case IDetherStatsOversizePkts: long_return = theEntry.eth.oversize; return (u_char *) & long_return; case IDetherStatsFragments: long_return = theEntry.eth.fragments; return (u_char *) & long_return; case IDetherStatsJabbers: long_return = theEntry.eth.jabbers; return (u_char *) & long_return; case IDetherStatsCollisions: long_return = theEntry.eth.collisions; return (u_char *) & long_return; case IDetherStatsPkts64Octets: long_return = theEntry.eth.pkts_64; return (u_char *) & long_return; case IDetherStatsPkts65to127Octets: long_return = theEntry.eth.pkts_65_127; return (u_char *) & long_return; case IDetherStatsPkts128to255Octets: long_return = theEntry.eth.pkts_128_255; return (u_char *) & long_return; case IDetherStatsPkts256to511Octets: long_return = theEntry.eth.pkts_256_511; return (u_char *) & long_return; case IDetherStatsPkts512to1023Octets: long_return = theEntry.eth.pkts_512_1023; return (u_char *) & long_return; case IDetherStatsPkts1024to1518Octets: long_return = theEntry.eth.pkts_1024_1518; return (u_char *) & long_return; case IDetherStatsOwner: if (hdr->owner) { *var_len = strlen(hdr->owner); return (unsigned char *) hdr->owner; } else { *var_len = 0; return NETSNMP_REMOVE_CONST(unsigned char *, ""); } case IDetherStatsStatus: long_return = hdr->status; return (u_char *) & long_return; default: ERROR_MSG(""); }; /* of switch by 'vp->magic' */ return NULL; } #if 1 /* debug, but may be used for init. TBD: may be token snmpd.conf ? */ int add_statistics_entry(int ctrl_index, int ifIndex) { int ierr; ierr = ROWAPI_new(table_ptr, ctrl_index); switch (ierr) { case -1: ag_trace("max. number exedes\n"); break; case -2: ag_trace("malloc failed"); break; case -3: ag_trace("ClbkCreate failed"); break; case 0: break; default: ag_trace("Unknown code %d", ierr); break; } if (!ierr) { register RMON_ENTRY_T *eptr = ROWAPI_find(table_ptr, ctrl_index); if (!eptr) { ag_trace("cannot find it"); ierr = -4; } else { CRTL_ENTRY_T *body = (CRTL_ENTRY_T *) eptr->body; body->data_source.objid[body->data_source.length - 1] = ifIndex; eptr->new_status = RMON1_ENTRY_VALID; ierr = ROWAPI_commit(table_ptr, ctrl_index); if (ierr) { ag_trace("ROWAPI_commit returned %d", ierr); } } } return ierr; }