--------------------- PatchSet 10610 Date: 2008/06/16 14:41:01 Author: adri Branch: delay_snmp Tag: (none) Log: Add in the SNMP walk support. It turns out the _inst functions actually control the walk instance mappings. I think I've done it "right". Members: src/delay_pools.c:1.21.2.5->1.21.2.6 src/mib.txt:1.10.4.4->1.10.4.5 src/snmp_core.c:1.19.2.3->1.19.2.4 Index: squid/src/delay_pools.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/delay_pools.c,v retrieving revision 1.21.2.5 retrieving revision 1.21.2.6 diff -u -r1.21.2.5 -r1.21.2.6 --- squid/src/delay_pools.c 16 Jun 2008 12:52:23 -0000 1.21.2.5 +++ squid/src/delay_pools.c 16 Jun 2008 14:41:01 -0000 1.21.2.6 @@ -1,6 +1,6 @@ /* - * $Id: delay_pools.c,v 1.21.2.5 2008/06/16 12:52:23 adri Exp $ + * $Id: delay_pools.c,v 1.21.2.6 2008/06/16 14:41:01 adri Exp $ * * DEBUG: section 77 Delay Pools * AUTHOR: David Luyer @@ -1083,7 +1083,7 @@ switch (Var->name[LEN_SQ_NET + 3]) { case 1: /* cacheDelayPoolIndex */ - Answer = snmp_var_new_integer(Var->name, Var->name_length, poolindex, ASN_INTEGER); + Answer = snmp_var_new_integer(Var->name, Var->name_length, poolid, ASN_INTEGER); break; case 2: /* cacheDelayPoolId */ Index: squid/src/mib.txt =================================================================== RCS file: /cvsroot/squid-sf//squid/src/mib.txt,v retrieving revision 1.10.4.4 retrieving revision 1.10.4.5 diff -u -r1.10.4.4 -r1.10.4.5 --- squid/src/mib.txt 10 Jun 2008 14:13:43 -0000 1.10.4.4 +++ squid/src/mib.txt 16 Jun 2008 14:41:01 -0000 1.10.4.5 @@ -2,7 +2,7 @@ SQUID-MIB DEFINITIONS ::= BEGIN -- --- $Id: mib.txt,v 1.10.4.4 2008/06/10 14:13:43 adri Exp $ +-- $Id: mib.txt,v 1.10.4.5 2008/06/16 14:41:01 adri Exp $ -- IMPORTS @@ -735,8 +735,8 @@ cacheDelayPoolClass Integer32, cacheDelayPoolAggregate Gauge32, cacheDelayPoolAggregateBytes Counter32, - cacheDelayPoolAggregateMax Integer32, - cacheDelayPoolAggregateRestore Integer32 + cacheDelayPoolAggregateMax Gauge32, + cacheDelayPoolAggregateRestore Gauge32 } cacheDelayPoolIndex OBJECT-TYPE @@ -780,7 +780,7 @@ ::= { cacheDelayPoolSummaryEntry 5 } cacheDelayPoolAggregateMax OBJECT-TYPE - SYNTAX Integer32 + SYNTAX Gauge32 MAX-ACCESS read-only STATUS current DESCRIPTION @@ -788,7 +788,7 @@ ::= { cacheDelayPoolSummaryEntry 6 } cacheDelayPoolAggregateRestore OBJECT-TYPE - SYNTAX Integer32 + SYNTAX Gauge32 MAX-ACCESS read-only STATUS current DESCRIPTION Index: squid/src/snmp_core.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/snmp_core.c,v retrieving revision 1.19.2.3 retrieving revision 1.19.2.4 diff -u -r1.19.2.3 -r1.19.2.4 --- squid/src/snmp_core.c 16 Jun 2008 12:52:23 -0000 1.19.2.3 +++ squid/src/snmp_core.c 16 Jun 2008 14:41:01 -0000 1.19.2.4 @@ -1,6 +1,6 @@ /* - * $Id: snmp_core.c,v 1.19.2.3 2008/06/16 12:52:23 adri Exp $ + * $Id: snmp_core.c,v 1.19.2.4 2008/06/16 14:41:01 adri Exp $ * * DEBUG: section 49 SNMP support * AUTHOR: Glenn Chisholm @@ -63,6 +63,7 @@ #endif extern void (*snmplib_debug_hook) (int, char *); static oid *static_Inst(oid * name, snint * len, mib_tree_entry * current, oid_ParseFn ** Fn); +static oid *delayTable_Inst(oid * name, snint * len, mib_tree_entry * current, oid_ParseFn ** Fn); static oid *time_Inst(oid * name, snint * len, mib_tree_entry * current, oid_ParseFn ** Fn); static oid *peer_Inst(oid * name, snint * len, mib_tree_entry * current, oid_ParseFn ** Fn); static oid *peer_InstIndex(oid * name, snint * len, mib_tree_entry * current, oid_ParseFn ** Fn); @@ -301,26 +302,26 @@ /* cacheDelayPools.cacheDelayPoolSummaryTable */ snmpAddNode(snmpCreateOid(LEN_SQ_NET + 2, SQ_NET, NET_DELAY_CACHE, 2), - LEN_SQ_NET + 3, NULL, NULL, 1, + LEN_SQ_NET + 2, NULL, delayTable_Inst, 1, /* cacheDelayPools.cacheDelayPoolSummaryTable.cacheDelayPoolEntry */ snmpAddNode(snmpCreateOid(LEN_SQ_NET + 3, SQ_NET, NET_DELAY_CACHE, 2, 1), - LEN_SQ_NET + 4, snmp_DelaySummaryTable, static_Inst, 7, + LEN_SQ_NET + 3, snmp_DelaySummaryTable, delayTable_Inst, 7, snmpAddNode(snmpCreateOid(LEN_SQ_NET + 4, SQ_NET, NET_DELAY_CACHE, 2, 1, 1), - LEN_SQ_NET + 5, snmp_DelaySummaryTable, static_Inst, 0), + LEN_SQ_NET + 4, snmp_DelaySummaryTable, static_Inst, 0), snmpAddNode(snmpCreateOid(LEN_SQ_NET + 4, SQ_NET, NET_DELAY_CACHE, 2, 1, 2), - LEN_SQ_NET + 5, snmp_DelaySummaryTable, static_Inst, 0), + LEN_SQ_NET + 4, snmp_DelaySummaryTable, static_Inst, 0), snmpAddNode(snmpCreateOid(LEN_SQ_NET + 4, SQ_NET, NET_DELAY_CACHE, 2, 1, 3), - LEN_SQ_NET + 5, snmp_DelaySummaryTable, static_Inst, 0), + LEN_SQ_NET + 4, snmp_DelaySummaryTable, static_Inst, 0), snmpAddNode(snmpCreateOid(LEN_SQ_NET + 4, SQ_NET, NET_DELAY_CACHE, 2, 1, 4), - LEN_SQ_NET + 5, snmp_DelaySummaryTable, static_Inst, 0), + LEN_SQ_NET + 4, snmp_DelaySummaryTable, static_Inst, 0), snmpAddNode(snmpCreateOid(LEN_SQ_NET + 4, SQ_NET, NET_DELAY_CACHE, 2, 1, 5), - LEN_SQ_NET + 5, snmp_DelaySummaryTable, static_Inst, 0), + LEN_SQ_NET + 4, snmp_DelaySummaryTable, static_Inst, 0), snmpAddNode(snmpCreateOid(LEN_SQ_NET + 4, SQ_NET, NET_DELAY_CACHE, 2, 1, 6), - LEN_SQ_NET + 5, snmp_DelaySummaryTable, static_Inst, 0), + LEN_SQ_NET + 4, snmp_DelaySummaryTable, static_Inst, 0), snmpAddNode(snmpCreateOid(LEN_SQ_NET + 4, SQ_NET, NET_DELAY_CACHE, 2, 1, 7), - LEN_SQ_NET + 5, snmp_DelaySummaryTable, static_Inst, 0) + LEN_SQ_NET + 4, snmp_DelaySummaryTable, static_Inst, 0) )))), snmpAddNode(snmpCreateOid(LEN_SQ_MESH, SQ_MESH), @@ -815,6 +816,33 @@ } static oid * +delayTable_Inst(oid * name, snint * len, mib_tree_entry * current, oid_ParseFn ** Fn) +{ + oid *instance = NULL; + + if (*len <= current->len) { + instance = xmalloc(sizeof(name) * (*len + 2)); + xmemcpy(instance, name, (sizeof(name) * *len)); + instance[*len] = 1; + *len += 1; + instance[*len] = 1; + *len += 1; + } else { + instance = xmalloc(sizeof(name) * (*len + 1)); + xmemcpy(instance, name, (sizeof(name) * *len)); + if (instance[(*len)-1] < Config.Delay.pools) { + instance[(*len)-1] ++; + } else { + instance[(*len)-2] ++; + instance[(*len)-1] = 1; + } + } + *Fn = current->parsefunction; + return (instance); +} + + +static oid * time_Inst(oid * name, snint * len, mib_tree_entry * current, oid_ParseFn ** Fn) { oid *instance = NULL;