/*************************************************** * Function:var_etherStats2Entry * Purpose: Handles the request for etherStats2Entry variable instances ***************************************************/ u_char * var_etherStats2Entry(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 = NULL; hdr = ROWAPI_header_ControlEntry(vp, name, length, exact, var_len, table_ptr, &theEntry, sizeof(CRTL_ENTRY_T)); if (!hdr) return NULL; *var_len = sizeof(long); /* default */ switch (vp->magic) { case IDetherStatsDroppedFrames: long_return = 0; return (u_char *) & long_return; case IDetherStatsCreateTime: long_return = theEntry.etherStatsCreateTime; return (u_char *) & long_return; default: ag_trace("%s: unknown vp->magic=%d", table_ptr->name, (int) vp->magic); ERROR_MSG(""); }; /* of switch by 'vp->magic' */ return NULL; }
unsigned char * var_eventTable(struct variable *vp, oid * name, size_t * length, int exact, size_t * var_len, WriteMethod ** write_method) { static long long_ret; static CRTL_ENTRY_T theEntry; RMON_ENTRY_T *hdr; *write_method = write_eventControl; hdr = ROWAPI_header_ControlEntry(vp, name, length, exact, var_len, table_ptr, &theEntry, sizeof(CRTL_ENTRY_T)); if (!hdr) return NULL; *var_len = sizeof(long); /* default */ switch (vp->magic) { case EVENTINDEX: long_ret = hdr->ctrl_index; return (unsigned char *) &long_ret; case EVENTDESCRIPTION: if (theEntry.event_description) { *var_len = strlen(theEntry.event_description); return (unsigned char *) theEntry.event_description; } else { *var_len = 0; return zero_octet_string; } case EVENTTYPE: long_ret = theEntry.event_type; return (unsigned char *) &long_ret; case EVENTCOMMUNITY: if (theEntry.event_community) { *var_len = strlen(theEntry.event_community); return (unsigned char *) theEntry.event_community; } else { *var_len = 0; return zero_octet_string; } case EVENTLASTTIMESENT: long_ret = theEntry.event_last_time_sent; return (unsigned char *) &long_ret; case EVENTOWNER: if (hdr->owner) { *var_len = strlen(hdr->owner); return (unsigned char *) hdr->owner; } else { *var_len = 0; return zero_octet_string; } case EVENTSTATUS: long_ret = hdr->status; return (unsigned char *) &long_ret; default: ag_trace("EventControlTable: unknown vp->magic=%d", (int) vp->magic); ERROR_MSG(""); } return NULL; }
/*************************************************** * 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; }
u_char *var_alarmEntry (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_alarmEntry; hdr = ROWAPI_header_ControlEntry (vp, name, length, exact, var_len, table_ptr, &theEntry, sizeof (CRTL_ENTRY_T)); if (!hdr) return NULL; *var_len = sizeof (long); /* default */ switch (vp->magic) { case IDalarmIndex: long_return = hdr->ctrl_index; return (u_char *) & long_return; case IDalarmInterval: long_return = theEntry.interval; return (u_char *) & long_return; case IDalarmVariable: *var_len = sizeof (oid) * theEntry.var_name.length; return (unsigned char *) theEntry.var_name.objid; return (u_char *) & long_return; case IDalarmSampleType: long_return = theEntry.sample_type; return (u_char *) & long_return; case IDalarmValue: long_return = theEntry.value; return (u_char *) & long_return; case IDalarmStartupAlarm: long_return = theEntry.startup_type; return (u_char *) & long_return; case IDalarmRisingThreshold: long_return = theEntry.rising_threshold; return (u_char *) & long_return; case IDalarmFallingThreshold: long_return = theEntry.falling_threshold; return (u_char *) & long_return; case IDalarmRisingEventIndex: long_return = theEntry.rising_event_index; return (u_char *) & long_return; case IDalarmFallingEventIndex: long_return = theEntry.falling_event_index; return (u_char *) & long_return; case IDalarmOwner: if (hdr->owner) { *var_len = strlen (hdr->owner); return (unsigned char *) hdr->owner; } else { *var_len = 0; return (unsigned char *) ""; } case IDalarmStatus: long_return = hdr->status; return (u_char *) & long_return; default: ag_trace ("%s: unknown vp->magic=%d", table_ptr->name, (int) vp->magic); ERROR_MSG (""); }; /* of switch by 'vp->magic' */ return NULL; }