/* -- DO NOT EDIT -- * Generated by smidump version 0.4.3-pre1: * smidump -f scli CISCO-PROCESS-MIB * * Derived from CISCO-PROCESS-MIB: * The MIB module to describe active system processes. * * Revision 2001-05-18 00:00: * The objects cpmProcExtUtil5Sec, cpmProcExtUtil1Min, * cpmProcExtUtil5Min,cpmCPUTotal5sec, cpmCPUTotal1min * and cpmCPUTotal5min are deprecated to increase the * value range as 0..100. The table cpmProcessExtTable * is deprecated. The new objects added are * cpmProcessExtRevTable, cpmProcExtMemAllocatedRev, * cpmProcExtMemFreedRev, cpmProcExtInvokedRev, * cpmProcExtRuntimeRev, cpmProcExtUtil5SecRev, * cpmProcExtUtil1MinRev, cpmCPUTotal5MinRev, * cpmCPUTotal5secRev, cpmCPUTotal1minRev and * cpmCPUTotal5minRev. * * Revision 1998-04-15 00:00: * Initial version of this MIB. * * $Id: cisco-process-mib.c 1994 2006-08-22 21:57:59Z schoenw $ */ #include "cisco-process-mib.h" GNetSnmpEnum const cisco_process_mib_enums_cpmProcExtPriority[] = { { CISCO_PROCESS_MIB_CPMPROCEXTPRIORITY_CRITICAL, "critical" }, { CISCO_PROCESS_MIB_CPMPROCEXTPRIORITY_HIGH, "high" }, { CISCO_PROCESS_MIB_CPMPROCEXTPRIORITY_NORMAL, "normal" }, { CISCO_PROCESS_MIB_CPMPROCEXTPRIORITY_LOW, "low" }, { CISCO_PROCESS_MIB_CPMPROCEXTPRIORITY_NOTASSIGNED, "notAssigned" }, { 0, NULL } }; GNetSnmpEnum const cisco_process_mib_enums_cpmProcExtPriorityRev[] = { { CISCO_PROCESS_MIB_CPMPROCEXTPRIORITYREV_CRITICAL, "critical" }, { CISCO_PROCESS_MIB_CPMPROCEXTPRIORITYREV_HIGH, "high" }, { CISCO_PROCESS_MIB_CPMPROCEXTPRIORITYREV_NORMAL, "normal" }, { CISCO_PROCESS_MIB_CPMPROCEXTPRIORITYREV_LOW, "low" }, { CISCO_PROCESS_MIB_CPMPROCEXTPRIORITYREV_NOTASSIGNED, "notAssigned" }, { 0, NULL } }; static gint32 cpmCPUTotalPhysicalIndex_constraints[] = {0L, 2147483647L, 0, 0}; static guint32 cpmCPUTotal5sec_constraints[] = {1UL, 100UL, 0, 0}; static guint32 cpmCPUTotal1min_constraints[] = {1UL, 100UL, 0, 0}; static guint32 cpmCPUTotal5min_constraints[] = {1UL, 100UL, 0, 0}; static guint32 cpmCPUTotal5secRev_constraints[] = {0UL, 100UL, 0, 0}; static guint32 cpmCPUTotal1minRev_constraints[] = {0UL, 100UL, 0, 0}; static guint32 cpmCPUTotal5minRev_constraints[] = {0UL, 100UL, 0, 0}; static guint16 cpmProcessName_constraints[] = {1U, 32U, 0, 0}; static guint32 cpmProcExtUtil5Sec_constraints[] = {1UL, 100UL, 0, 0}; static guint32 cpmProcExtUtil1Min_constraints[] = {1UL, 100UL, 0, 0}; static guint32 cpmProcExtUtil5Min_constraints[] = {1UL, 100UL, 0, 0}; static guint32 cpmProcExtUtil5SecRev_constraints[] = {0UL, 100UL, 0, 0}; static guint32 cpmProcExtUtil1MinRev_constraints[] = {0UL, 100UL, 0, 0}; static guint32 cpmProcExtUtil5MinRev_constraints[] = {0UL, 100UL, 0, 0}; static guint32 const cpmCPUTotalEntry_oid[] = {1, 3, 6, 1, 4, 1, 9, 9, 109, 1, 1, 1, 1}; static GNetSnmpAttribute cpmCPUTotalEntry_attr[] = { { 2, GNET_SNMP_VARBIND_TYPE_INTEGER32, CISCO_PROCESS_MIB_CPMCPUTOTALPHYSICALINDEX, "cpmCPUTotalPhysicalIndex", cpmCPUTotalPhysicalIndex_constraints, G_STRUCT_OFFSET(cisco_process_mib_cpmCPUTotalEntry_t, cpmCPUTotalPhysicalIndex), 0, 0 }, { 3, GNET_SNMP_VARBIND_TYPE_UNSIGNED32, CISCO_PROCESS_MIB_CPMCPUTOTAL5SEC, "cpmCPUTotal5sec", cpmCPUTotal5sec_constraints, G_STRUCT_OFFSET(cisco_process_mib_cpmCPUTotalEntry_t, cpmCPUTotal5sec), 0, 0 }, { 4, GNET_SNMP_VARBIND_TYPE_UNSIGNED32, CISCO_PROCESS_MIB_CPMCPUTOTAL1MIN, "cpmCPUTotal1min", cpmCPUTotal1min_constraints, G_STRUCT_OFFSET(cisco_process_mib_cpmCPUTotalEntry_t, cpmCPUTotal1min), 0, 0 }, { 5, GNET_SNMP_VARBIND_TYPE_UNSIGNED32, CISCO_PROCESS_MIB_CPMCPUTOTAL5MIN, "cpmCPUTotal5min", cpmCPUTotal5min_constraints, G_STRUCT_OFFSET(cisco_process_mib_cpmCPUTotalEntry_t, cpmCPUTotal5min), 0, 0 }, { 6, GNET_SNMP_VARBIND_TYPE_UNSIGNED32, CISCO_PROCESS_MIB_CPMCPUTOTAL5SECREV, "cpmCPUTotal5secRev", cpmCPUTotal5secRev_constraints, G_STRUCT_OFFSET(cisco_process_mib_cpmCPUTotalEntry_t, cpmCPUTotal5secRev), 0, 0 }, { 7, GNET_SNMP_VARBIND_TYPE_UNSIGNED32, CISCO_PROCESS_MIB_CPMCPUTOTAL1MINREV, "cpmCPUTotal1minRev", cpmCPUTotal1minRev_constraints, G_STRUCT_OFFSET(cisco_process_mib_cpmCPUTotalEntry_t, cpmCPUTotal1minRev), 0, 0 }, { 8, GNET_SNMP_VARBIND_TYPE_UNSIGNED32, CISCO_PROCESS_MIB_CPMCPUTOTAL5MINREV, "cpmCPUTotal5minRev", cpmCPUTotal5minRev_constraints, G_STRUCT_OFFSET(cisco_process_mib_cpmCPUTotalEntry_t, cpmCPUTotal5minRev), 0, 0 }, { 0, 0, 0, NULL } }; static guint32 const cpmProcessEntry_oid[] = {1, 3, 6, 1, 4, 1, 9, 9, 109, 1, 2, 1, 1}; static GNetSnmpAttribute cpmProcessEntry_attr[] = { { 2, GNET_SNMP_VARBIND_TYPE_OCTETSTRING, CISCO_PROCESS_MIB_CPMPROCESSNAME, "cpmProcessName", cpmProcessName_constraints, G_STRUCT_OFFSET(cisco_process_mib_cpmProcessEntry_t, cpmProcessName), G_STRUCT_OFFSET(cisco_process_mib_cpmProcessEntry_t, _cpmProcessNameLength), 0 }, { 4, GNET_SNMP_VARBIND_TYPE_UNSIGNED32, CISCO_PROCESS_MIB_CPMPROCESSUSECS, "cpmProcessuSecs", NULL, G_STRUCT_OFFSET(cisco_process_mib_cpmProcessEntry_t, cpmProcessuSecs), 0, 0 }, { 5, GNET_SNMP_VARBIND_TYPE_TIMETICKS, CISCO_PROCESS_MIB_CPMPROCESSTIMECREATED, "cpmProcessTimeCreated", NULL, G_STRUCT_OFFSET(cisco_process_mib_cpmProcessEntry_t, cpmProcessTimeCreated), 0, 0 }, { 6, GNET_SNMP_VARBIND_TYPE_UNSIGNED32, CISCO_PROCESS_MIB_CPMPROCESSAVERAGEUSECS, "cpmProcessAverageUSecs", NULL, G_STRUCT_OFFSET(cisco_process_mib_cpmProcessEntry_t, cpmProcessAverageUSecs), 0, 0 }, { 0, 0, 0, NULL } }; static guint32 const cpmProcessExtEntry_oid[] = {1, 3, 6, 1, 4, 1, 9, 9, 109, 1, 2, 2, 1}; static GNetSnmpAttribute cpmProcessExtEntry_attr[] = { { 1, GNET_SNMP_VARBIND_TYPE_UNSIGNED32, CISCO_PROCESS_MIB_CPMPROCEXTMEMALLOCATED, "cpmProcExtMemAllocated", NULL, G_STRUCT_OFFSET(cisco_process_mib_cpmProcessExtEntry_t, cpmProcExtMemAllocated), 0, 0 }, { 2, GNET_SNMP_VARBIND_TYPE_UNSIGNED32, CISCO_PROCESS_MIB_CPMPROCEXTMEMFREED, "cpmProcExtMemFreed", NULL, G_STRUCT_OFFSET(cisco_process_mib_cpmProcessExtEntry_t, cpmProcExtMemFreed), 0, 0 }, { 3, GNET_SNMP_VARBIND_TYPE_COUNTER32, CISCO_PROCESS_MIB_CPMPROCEXTINVOKED, "cpmProcExtInvoked", NULL, G_STRUCT_OFFSET(cisco_process_mib_cpmProcessExtEntry_t, cpmProcExtInvoked), 0, 0 }, { 4, GNET_SNMP_VARBIND_TYPE_COUNTER32, CISCO_PROCESS_MIB_CPMPROCEXTRUNTIME, "cpmProcExtRuntime", NULL, G_STRUCT_OFFSET(cisco_process_mib_cpmProcessExtEntry_t, cpmProcExtRuntime), 0, 0 }, { 5, GNET_SNMP_VARBIND_TYPE_UNSIGNED32, CISCO_PROCESS_MIB_CPMPROCEXTUTIL5SEC, "cpmProcExtUtil5Sec", cpmProcExtUtil5Sec_constraints, G_STRUCT_OFFSET(cisco_process_mib_cpmProcessExtEntry_t, cpmProcExtUtil5Sec), 0, 0 }, { 6, GNET_SNMP_VARBIND_TYPE_UNSIGNED32, CISCO_PROCESS_MIB_CPMPROCEXTUTIL1MIN, "cpmProcExtUtil1Min", cpmProcExtUtil1Min_constraints, G_STRUCT_OFFSET(cisco_process_mib_cpmProcessExtEntry_t, cpmProcExtUtil1Min), 0, 0 }, { 7, GNET_SNMP_VARBIND_TYPE_UNSIGNED32, CISCO_PROCESS_MIB_CPMPROCEXTUTIL5MIN, "cpmProcExtUtil5Min", cpmProcExtUtil5Min_constraints, G_STRUCT_OFFSET(cisco_process_mib_cpmProcessExtEntry_t, cpmProcExtUtil5Min), 0, 0 }, { 8, GNET_SNMP_VARBIND_TYPE_INTEGER32, CISCO_PROCESS_MIB_CPMPROCEXTPRIORITY, "cpmProcExtPriority", NULL, G_STRUCT_OFFSET(cisco_process_mib_cpmProcessExtEntry_t, cpmProcExtPriority), 0, GSNMP_ATTR_FLAG_WRITABLE }, { 0, 0, 0, NULL } }; static guint32 const cpmProcessExtRevEntry_oid[] = {1, 3, 6, 1, 4, 1, 9, 9, 109, 1, 2, 3, 1}; static GNetSnmpAttribute cpmProcessExtRevEntry_attr[] = { { 1, GNET_SNMP_VARBIND_TYPE_UNSIGNED32, CISCO_PROCESS_MIB_CPMPROCEXTMEMALLOCATEDREV, "cpmProcExtMemAllocatedRev", NULL, G_STRUCT_OFFSET(cisco_process_mib_cpmProcessExtRevEntry_t, cpmProcExtMemAllocatedRev), 0, 0 }, { 2, GNET_SNMP_VARBIND_TYPE_UNSIGNED32, CISCO_PROCESS_MIB_CPMPROCEXTMEMFREEDREV, "cpmProcExtMemFreedRev", NULL, G_STRUCT_OFFSET(cisco_process_mib_cpmProcessExtRevEntry_t, cpmProcExtMemFreedRev), 0, 0 }, { 3, GNET_SNMP_VARBIND_TYPE_COUNTER32, CISCO_PROCESS_MIB_CPMPROCEXTINVOKEDREV, "cpmProcExtInvokedRev", NULL, G_STRUCT_OFFSET(cisco_process_mib_cpmProcessExtRevEntry_t, cpmProcExtInvokedRev), 0, 0 }, { 4, GNET_SNMP_VARBIND_TYPE_COUNTER32, CISCO_PROCESS_MIB_CPMPROCEXTRUNTIMEREV, "cpmProcExtRuntimeRev", NULL, G_STRUCT_OFFSET(cisco_process_mib_cpmProcessExtRevEntry_t, cpmProcExtRuntimeRev), 0, 0 }, { 5, GNET_SNMP_VARBIND_TYPE_UNSIGNED32, CISCO_PROCESS_MIB_CPMPROCEXTUTIL5SECREV, "cpmProcExtUtil5SecRev", cpmProcExtUtil5SecRev_constraints, G_STRUCT_OFFSET(cisco_process_mib_cpmProcessExtRevEntry_t, cpmProcExtUtil5SecRev), 0, 0 }, { 6, GNET_SNMP_VARBIND_TYPE_UNSIGNED32, CISCO_PROCESS_MIB_CPMPROCEXTUTIL1MINREV, "cpmProcExtUtil1MinRev", cpmProcExtUtil1MinRev_constraints, G_STRUCT_OFFSET(cisco_process_mib_cpmProcessExtRevEntry_t, cpmProcExtUtil1MinRev), 0, 0 }, { 7, GNET_SNMP_VARBIND_TYPE_UNSIGNED32, CISCO_PROCESS_MIB_CPMPROCEXTUTIL5MINREV, "cpmProcExtUtil5MinRev", cpmProcExtUtil5MinRev_constraints, G_STRUCT_OFFSET(cisco_process_mib_cpmProcessExtRevEntry_t, cpmProcExtUtil5MinRev), 0, 0 }, { 8, GNET_SNMP_VARBIND_TYPE_INTEGER32, CISCO_PROCESS_MIB_CPMPROCEXTPRIORITYREV, "cpmProcExtPriorityRev", NULL, G_STRUCT_OFFSET(cisco_process_mib_cpmProcessExtRevEntry_t, cpmProcExtPriorityRev), 0, 0 }, { 0, 0, 0, NULL } }; cisco_process_mib_cpmCPUTotalEntry_t * cisco_process_mib_new_cpmCPUTotalEntry() { cisco_process_mib_cpmCPUTotalEntry_t *cpmCPUTotalEntry; cpmCPUTotalEntry = (cisco_process_mib_cpmCPUTotalEntry_t *) g_malloc0(sizeof(cisco_process_mib_cpmCPUTotalEntry_t) + sizeof(gpointer)); return cpmCPUTotalEntry; } static inline int unpack_cpmCPUTotalEntry(GNetSnmpVarBind *vb, cisco_process_mib_cpmCPUTotalEntry_t *cpmCPUTotalEntry) { guint8 idx = 14; if (vb->oid_len < idx) return -1; cpmCPUTotalEntry->cpmCPUTotalIndex = vb->oid[idx++]; if ((cpmCPUTotalEntry->cpmCPUTotalIndex < 1)) { return -1; } if (vb->oid_len > idx) return -1; return 0; } static inline gint8 pack_cpmCPUTotalEntry(guint32 *base, guint32 cpmCPUTotalIndex) { guint8 idx = 14; base[idx++] = cpmCPUTotalIndex; return idx; } static inline cisco_process_mib_cpmCPUTotalEntry_t * assign_cpmCPUTotalEntry(GList *vbl) { cisco_process_mib_cpmCPUTotalEntry_t *cpmCPUTotalEntry; char *p; cpmCPUTotalEntry = cisco_process_mib_new_cpmCPUTotalEntry(); p = (char *) cpmCPUTotalEntry + sizeof(cisco_process_mib_cpmCPUTotalEntry_t); * (GList **) p = vbl; if (unpack_cpmCPUTotalEntry((GNetSnmpVarBind *) vbl->data, cpmCPUTotalEntry) < 0) { g_warning("%s: invalid instance identifier", "cpmCPUTotalEntry"); g_free(cpmCPUTotalEntry); return NULL; } gnet_snmp_attr_assign(vbl, cpmCPUTotalEntry_oid, G_N_ELEMENTS(cpmCPUTotalEntry_oid), cpmCPUTotalEntry_attr, cpmCPUTotalEntry); return cpmCPUTotalEntry; } void cisco_process_mib_get_cpmCPUTotalTable(GNetSnmp *s, cisco_process_mib_cpmCPUTotalEntry_t ***cpmCPUTotalEntry, gint64 mask) { GList *in = NULL, *out = NULL; GList *row; int i; static guint32 base[] = {1, 3, 6, 1, 4, 1, 9, 9, 109, 1, 1, 1, 1, 0}; *cpmCPUTotalEntry = NULL; gnet_snmp_attr_get(s, &in, base, 14, 13, cpmCPUTotalEntry_attr, mask); out = gnet_snmp_sync_table(s, in); /* gnet_snmp_varbind_list_free(in); */ if (out) { *cpmCPUTotalEntry = (cisco_process_mib_cpmCPUTotalEntry_t **) g_malloc0((g_list_length(out) + 1) * sizeof(cisco_process_mib_cpmCPUTotalEntry_t *)); for (row = out, i = 0; row; row = g_list_next(row), i++) { (*cpmCPUTotalEntry)[i] = assign_cpmCPUTotalEntry(row->data); } } } void cisco_process_mib_get_cpmCPUTotalEntry(GNetSnmp *s, cisco_process_mib_cpmCPUTotalEntry_t **cpmCPUTotalEntry, guint32 cpmCPUTotalIndex, gint64 mask) { GList *in = NULL, *out = NULL; guint32 base[128]; gint8 len; memcpy(base, cpmCPUTotalEntry_oid, sizeof(cpmCPUTotalEntry_oid)); len = pack_cpmCPUTotalEntry(base, cpmCPUTotalIndex); if (len < 0) { g_warning("%s: invalid index values", "cpmCPUTotalEntry"); s->error_status = GNET_SNMP_PDU_ERR_INTERNAL; return; } *cpmCPUTotalEntry = NULL; gnet_snmp_attr_get(s, &in, base, len, 13, cpmCPUTotalEntry_attr, mask); out = gnet_snmp_sync_get(s, in); g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); g_list_free(in); if (out) { if (s->error_status != GNET_SNMP_PDU_ERR_NOERROR) { g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); g_list_free(out); return; } *cpmCPUTotalEntry = assign_cpmCPUTotalEntry(out); } } void cisco_process_mib_free_cpmCPUTotalEntry(cisco_process_mib_cpmCPUTotalEntry_t *cpmCPUTotalEntry) { GList *vbl; char *p; if (cpmCPUTotalEntry) { p = (char *) cpmCPUTotalEntry + sizeof(cisco_process_mib_cpmCPUTotalEntry_t); vbl = * (GList **) p; g_list_foreach(vbl, (GFunc) gnet_snmp_varbind_delete, NULL); g_list_free(vbl); g_free(cpmCPUTotalEntry); } } void cisco_process_mib_free_cpmCPUTotalTable(cisco_process_mib_cpmCPUTotalEntry_t **cpmCPUTotalEntry) { int i; if (cpmCPUTotalEntry) { for (i = 0; cpmCPUTotalEntry[i]; i++) { cisco_process_mib_free_cpmCPUTotalEntry(cpmCPUTotalEntry[i]); } g_free(cpmCPUTotalEntry); } } cisco_process_mib_cpmProcessEntry_t * cisco_process_mib_new_cpmProcessEntry() { cisco_process_mib_cpmProcessEntry_t *cpmProcessEntry; cpmProcessEntry = (cisco_process_mib_cpmProcessEntry_t *) g_malloc0(sizeof(cisco_process_mib_cpmProcessEntry_t) + sizeof(gpointer)); return cpmProcessEntry; } static inline int unpack_cpmProcessEntry(GNetSnmpVarBind *vb, cisco_process_mib_cpmProcessEntry_t *cpmProcessEntry) { guint8 idx = 14; if (vb->oid_len < idx) return -1; cpmProcessEntry->cpmCPUTotalIndex = vb->oid[idx++]; if ((cpmProcessEntry->cpmCPUTotalIndex < 1)) { return -1; } if (vb->oid_len < idx) return -1; cpmProcessEntry->cpmProcessPID = vb->oid[idx++]; if (vb->oid_len > idx) return -1; return 0; } static inline gint8 pack_cpmProcessEntry(guint32 *base, guint32 cpmCPUTotalIndex, guint32 cpmProcessPID) { guint8 idx = 14; base[idx++] = cpmCPUTotalIndex; base[idx++] = cpmProcessPID; return idx; } static inline cisco_process_mib_cpmProcessEntry_t * assign_cpmProcessEntry(GList *vbl) { cisco_process_mib_cpmProcessEntry_t *cpmProcessEntry; char *p; cpmProcessEntry = cisco_process_mib_new_cpmProcessEntry(); p = (char *) cpmProcessEntry + sizeof(cisco_process_mib_cpmProcessEntry_t); * (GList **) p = vbl; if (unpack_cpmProcessEntry((GNetSnmpVarBind *) vbl->data, cpmProcessEntry) < 0) { g_warning("%s: invalid instance identifier", "cpmProcessEntry"); g_free(cpmProcessEntry); return NULL; } gnet_snmp_attr_assign(vbl, cpmProcessEntry_oid, G_N_ELEMENTS(cpmProcessEntry_oid), cpmProcessEntry_attr, cpmProcessEntry); return cpmProcessEntry; } void cisco_process_mib_get_cpmProcessTable(GNetSnmp *s, cisco_process_mib_cpmProcessEntry_t ***cpmProcessEntry, gint64 mask) { GList *in = NULL, *out = NULL; GList *row; int i; static guint32 base[] = {1, 3, 6, 1, 4, 1, 9, 9, 109, 1, 2, 1, 1, 0}; *cpmProcessEntry = NULL; gnet_snmp_attr_get(s, &in, base, 14, 13, cpmProcessEntry_attr, mask); out = gnet_snmp_sync_table(s, in); /* gnet_snmp_varbind_list_free(in); */ if (out) { *cpmProcessEntry = (cisco_process_mib_cpmProcessEntry_t **) g_malloc0((g_list_length(out) + 1) * sizeof(cisco_process_mib_cpmProcessEntry_t *)); for (row = out, i = 0; row; row = g_list_next(row), i++) { (*cpmProcessEntry)[i] = assign_cpmProcessEntry(row->data); } } } void cisco_process_mib_get_cpmProcessEntry(GNetSnmp *s, cisco_process_mib_cpmProcessEntry_t **cpmProcessEntry, guint32 cpmCPUTotalIndex, guint32 cpmProcessPID, gint64 mask) { GList *in = NULL, *out = NULL; guint32 base[128]; gint8 len; memcpy(base, cpmProcessEntry_oid, sizeof(cpmProcessEntry_oid)); len = pack_cpmProcessEntry(base, cpmCPUTotalIndex, cpmProcessPID); if (len < 0) { g_warning("%s: invalid index values", "cpmProcessEntry"); s->error_status = GNET_SNMP_PDU_ERR_INTERNAL; return; } *cpmProcessEntry = NULL; gnet_snmp_attr_get(s, &in, base, len, 13, cpmProcessEntry_attr, mask); out = gnet_snmp_sync_get(s, in); g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); g_list_free(in); if (out) { if (s->error_status != GNET_SNMP_PDU_ERR_NOERROR) { g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); g_list_free(out); return; } *cpmProcessEntry = assign_cpmProcessEntry(out); } } void cisco_process_mib_free_cpmProcessEntry(cisco_process_mib_cpmProcessEntry_t *cpmProcessEntry) { GList *vbl; char *p; if (cpmProcessEntry) { p = (char *) cpmProcessEntry + sizeof(cisco_process_mib_cpmProcessEntry_t); vbl = * (GList **) p; g_list_foreach(vbl, (GFunc) gnet_snmp_varbind_delete, NULL); g_list_free(vbl); g_free(cpmProcessEntry); } } void cisco_process_mib_free_cpmProcessTable(cisco_process_mib_cpmProcessEntry_t **cpmProcessEntry) { int i; if (cpmProcessEntry) { for (i = 0; cpmProcessEntry[i]; i++) { cisco_process_mib_free_cpmProcessEntry(cpmProcessEntry[i]); } g_free(cpmProcessEntry); } } cisco_process_mib_cpmProcessExtEntry_t * cisco_process_mib_new_cpmProcessExtEntry() { cisco_process_mib_cpmProcessExtEntry_t *cpmProcessExtEntry; cpmProcessExtEntry = (cisco_process_mib_cpmProcessExtEntry_t *) g_malloc0(sizeof(cisco_process_mib_cpmProcessExtEntry_t) + sizeof(gpointer)); return cpmProcessExtEntry; } static inline int unpack_cpmProcessExtEntry(GNetSnmpVarBind *vb, cisco_process_mib_cpmProcessExtEntry_t *cpmProcessExtEntry) { guint8 idx = 14; if (vb->oid_len < idx) return -1; cpmProcessExtEntry->cpmCPUTotalIndex = vb->oid[idx++]; if ((cpmProcessExtEntry->cpmCPUTotalIndex < 1)) { return -1; } if (vb->oid_len < idx) return -1; cpmProcessExtEntry->cpmProcessPID = vb->oid[idx++]; if (vb->oid_len > idx) return -1; return 0; } static inline gint8 pack_cpmProcessExtEntry(guint32 *base, guint32 cpmCPUTotalIndex, guint32 cpmProcessPID) { guint8 idx = 14; base[idx++] = cpmCPUTotalIndex; base[idx++] = cpmProcessPID; return idx; } static inline cisco_process_mib_cpmProcessExtEntry_t * assign_cpmProcessExtEntry(GList *vbl) { cisco_process_mib_cpmProcessExtEntry_t *cpmProcessExtEntry; char *p; cpmProcessExtEntry = cisco_process_mib_new_cpmProcessExtEntry(); p = (char *) cpmProcessExtEntry + sizeof(cisco_process_mib_cpmProcessExtEntry_t); * (GList **) p = vbl; if (unpack_cpmProcessExtEntry((GNetSnmpVarBind *) vbl->data, cpmProcessExtEntry) < 0) { g_warning("%s: invalid instance identifier", "cpmProcessExtEntry"); g_free(cpmProcessExtEntry); return NULL; } gnet_snmp_attr_assign(vbl, cpmProcessExtEntry_oid, G_N_ELEMENTS(cpmProcessExtEntry_oid), cpmProcessExtEntry_attr, cpmProcessExtEntry); return cpmProcessExtEntry; } void cisco_process_mib_get_cpmProcessExtTable(GNetSnmp *s, cisco_process_mib_cpmProcessExtEntry_t ***cpmProcessExtEntry, gint64 mask) { GList *in = NULL, *out = NULL; GList *row; int i; static guint32 base[] = {1, 3, 6, 1, 4, 1, 9, 9, 109, 1, 2, 2, 1, 0}; *cpmProcessExtEntry = NULL; gnet_snmp_attr_get(s, &in, base, 14, 13, cpmProcessExtEntry_attr, mask); out = gnet_snmp_sync_table(s, in); /* gnet_snmp_varbind_list_free(in); */ if (out) { *cpmProcessExtEntry = (cisco_process_mib_cpmProcessExtEntry_t **) g_malloc0((g_list_length(out) + 1) * sizeof(cisco_process_mib_cpmProcessExtEntry_t *)); for (row = out, i = 0; row; row = g_list_next(row), i++) { (*cpmProcessExtEntry)[i] = assign_cpmProcessExtEntry(row->data); } } } void cisco_process_mib_get_cpmProcessExtEntry(GNetSnmp *s, cisco_process_mib_cpmProcessExtEntry_t **cpmProcessExtEntry, guint32 cpmCPUTotalIndex, guint32 cpmProcessPID, gint64 mask) { GList *in = NULL, *out = NULL; guint32 base[128]; gint8 len; memcpy(base, cpmProcessExtEntry_oid, sizeof(cpmProcessExtEntry_oid)); len = pack_cpmProcessExtEntry(base, cpmCPUTotalIndex, cpmProcessPID); if (len < 0) { g_warning("%s: invalid index values", "cpmProcessExtEntry"); s->error_status = GNET_SNMP_PDU_ERR_INTERNAL; return; } *cpmProcessExtEntry = NULL; gnet_snmp_attr_get(s, &in, base, len, 13, cpmProcessExtEntry_attr, mask); out = gnet_snmp_sync_get(s, in); g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); g_list_free(in); if (out) { if (s->error_status != GNET_SNMP_PDU_ERR_NOERROR) { g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); g_list_free(out); return; } *cpmProcessExtEntry = assign_cpmProcessExtEntry(out); } } void cisco_process_mib_set_cpmProcessExtEntry(GNetSnmp *s, cisco_process_mib_cpmProcessExtEntry_t *cpmProcessExtEntry, gint64 mask) { GList *in = NULL, *out = NULL; guint32 base[128]; gint8 len; memcpy(base, cpmProcessExtEntry_oid, sizeof(cpmProcessExtEntry_oid)); len = pack_cpmProcessExtEntry(base, cpmProcessExtEntry->cpmCPUTotalIndex, cpmProcessExtEntry->cpmProcessPID); if (len < 0) { g_warning("%s: invalid index values", "cpmProcessExtEntry"); s->error_status = GNET_SNMP_PDU_ERR_INTERNAL; return; } gnet_snmp_attr_set(s, &in, base, len, 13, cpmProcessExtEntry_attr, mask, cpmProcessExtEntry); out = gnet_snmp_sync_set(s, in); g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); g_list_free(in); if (out) { g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); g_list_free(out); } } void cisco_process_mib_free_cpmProcessExtEntry(cisco_process_mib_cpmProcessExtEntry_t *cpmProcessExtEntry) { GList *vbl; char *p; if (cpmProcessExtEntry) { p = (char *) cpmProcessExtEntry + sizeof(cisco_process_mib_cpmProcessExtEntry_t); vbl = * (GList **) p; g_list_foreach(vbl, (GFunc) gnet_snmp_varbind_delete, NULL); g_list_free(vbl); g_free(cpmProcessExtEntry); } } void cisco_process_mib_free_cpmProcessExtTable(cisco_process_mib_cpmProcessExtEntry_t **cpmProcessExtEntry) { int i; if (cpmProcessExtEntry) { for (i = 0; cpmProcessExtEntry[i]; i++) { cisco_process_mib_free_cpmProcessExtEntry(cpmProcessExtEntry[i]); } g_free(cpmProcessExtEntry); } } cisco_process_mib_cpmProcessExtRevEntry_t * cisco_process_mib_new_cpmProcessExtRevEntry() { cisco_process_mib_cpmProcessExtRevEntry_t *cpmProcessExtRevEntry; cpmProcessExtRevEntry = (cisco_process_mib_cpmProcessExtRevEntry_t *) g_malloc0(sizeof(cisco_process_mib_cpmProcessExtRevEntry_t) + sizeof(gpointer)); return cpmProcessExtRevEntry; } static inline int unpack_cpmProcessExtRevEntry(GNetSnmpVarBind *vb, cisco_process_mib_cpmProcessExtRevEntry_t *cpmProcessExtRevEntry) { guint8 idx = 14; if (vb->oid_len < idx) return -1; cpmProcessExtRevEntry->cpmCPUTotalIndex = vb->oid[idx++]; if ((cpmProcessExtRevEntry->cpmCPUTotalIndex < 1)) { return -1; } if (vb->oid_len < idx) return -1; cpmProcessExtRevEntry->cpmProcessPID = vb->oid[idx++]; if (vb->oid_len > idx) return -1; return 0; } static inline gint8 pack_cpmProcessExtRevEntry(guint32 *base, guint32 cpmCPUTotalIndex, guint32 cpmProcessPID) { guint8 idx = 14; base[idx++] = cpmCPUTotalIndex; base[idx++] = cpmProcessPID; return idx; } static inline cisco_process_mib_cpmProcessExtRevEntry_t * assign_cpmProcessExtRevEntry(GList *vbl) { cisco_process_mib_cpmProcessExtRevEntry_t *cpmProcessExtRevEntry; char *p; cpmProcessExtRevEntry = cisco_process_mib_new_cpmProcessExtRevEntry(); p = (char *) cpmProcessExtRevEntry + sizeof(cisco_process_mib_cpmProcessExtRevEntry_t); * (GList **) p = vbl; if (unpack_cpmProcessExtRevEntry((GNetSnmpVarBind *) vbl->data, cpmProcessExtRevEntry) < 0) { g_warning("%s: invalid instance identifier", "cpmProcessExtRevEntry"); g_free(cpmProcessExtRevEntry); return NULL; } gnet_snmp_attr_assign(vbl, cpmProcessExtRevEntry_oid, G_N_ELEMENTS(cpmProcessExtRevEntry_oid), cpmProcessExtRevEntry_attr, cpmProcessExtRevEntry); return cpmProcessExtRevEntry; } void cisco_process_mib_get_cpmProcessExtRevTable(GNetSnmp *s, cisco_process_mib_cpmProcessExtRevEntry_t ***cpmProcessExtRevEntry, gint64 mask) { GList *in = NULL, *out = NULL; GList *row; int i; static guint32 base[] = {1, 3, 6, 1, 4, 1, 9, 9, 109, 1, 2, 3, 1, 0}; *cpmProcessExtRevEntry = NULL; gnet_snmp_attr_get(s, &in, base, 14, 13, cpmProcessExtRevEntry_attr, mask); out = gnet_snmp_sync_table(s, in); /* gnet_snmp_varbind_list_free(in); */ if (out) { *cpmProcessExtRevEntry = (cisco_process_mib_cpmProcessExtRevEntry_t **) g_malloc0((g_list_length(out) + 1) * sizeof(cisco_process_mib_cpmProcessExtRevEntry_t *)); for (row = out, i = 0; row; row = g_list_next(row), i++) { (*cpmProcessExtRevEntry)[i] = assign_cpmProcessExtRevEntry(row->data); } } } void cisco_process_mib_get_cpmProcessExtRevEntry(GNetSnmp *s, cisco_process_mib_cpmProcessExtRevEntry_t **cpmProcessExtRevEntry, guint32 cpmCPUTotalIndex, guint32 cpmProcessPID, gint64 mask) { GList *in = NULL, *out = NULL; guint32 base[128]; gint8 len; memcpy(base, cpmProcessExtRevEntry_oid, sizeof(cpmProcessExtRevEntry_oid)); len = pack_cpmProcessExtRevEntry(base, cpmCPUTotalIndex, cpmProcessPID); if (len < 0) { g_warning("%s: invalid index values", "cpmProcessExtRevEntry"); s->error_status = GNET_SNMP_PDU_ERR_INTERNAL; return; } *cpmProcessExtRevEntry = NULL; gnet_snmp_attr_get(s, &in, base, len, 13, cpmProcessExtRevEntry_attr, mask); out = gnet_snmp_sync_get(s, in); g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); g_list_free(in); if (out) { if (s->error_status != GNET_SNMP_PDU_ERR_NOERROR) { g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); g_list_free(out); return; } *cpmProcessExtRevEntry = assign_cpmProcessExtRevEntry(out); } } void cisco_process_mib_free_cpmProcessExtRevEntry(cisco_process_mib_cpmProcessExtRevEntry_t *cpmProcessExtRevEntry) { GList *vbl; char *p; if (cpmProcessExtRevEntry) { p = (char *) cpmProcessExtRevEntry + sizeof(cisco_process_mib_cpmProcessExtRevEntry_t); vbl = * (GList **) p; g_list_foreach(vbl, (GFunc) gnet_snmp_varbind_delete, NULL); g_list_free(vbl); g_free(cpmProcessExtRevEntry); } } void cisco_process_mib_free_cpmProcessExtRevTable(cisco_process_mib_cpmProcessExtRevEntry_t **cpmProcessExtRevEntry) { int i; if (cpmProcessExtRevEntry) { for (i = 0; cpmProcessExtRevEntry[i]; i++) { cisco_process_mib_free_cpmProcessExtRevEntry(cpmProcessExtRevEntry[i]); } g_free(cpmProcessExtRevEntry); } }