--------------------- PatchSet 6226 Date: 2007/12/03 09:24:48 Author: rmartinez Branch: squid3-ipv6 Tag: (none) Log: 1.- Added log's support lines 2.- Added new node to the MIB tree (peer_Index) 3.- Droping IP indexing schema on MIB tree (now peer_Index). Members: src/snmp_core.cc:1.10.8.34->1.10.8.35 Index: squid3/src/snmp_core.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/snmp_core.cc,v retrieving revision 1.10.8.34 retrieving revision 1.10.8.35 diff -u -r1.10.8.34 -r1.10.8.35 --- squid3/src/snmp_core.cc 25 Nov 2007 20:06:19 -0000 1.10.8.34 +++ squid3/src/snmp_core.cc 3 Dec 2007 09:24:48 -0000 1.10.8.35 @@ -1,6 +1,6 @@ /* - * $Id: snmp_core.cc,v 1.10.8.34 2007/11/25 20:06:19 rmartinez Exp $ + * $Id: snmp_core.cc,v 1.10.8.35 2007/12/03 09:24:48 rmartinez Exp $ * * DEBUG: section 49 SNMP support * AUTHOR: Glenn Chisholm @@ -293,7 +293,9 @@ snmpAddNode(snmpCreateOid(LEN_SQ_MESH + 1, SQ_MESH, MESH_PTBL), LEN_SQ_MESH + 1, NULL, NULL, 1, snmpAddNode(snmpCreateOid(LEN_SQ_MESH + 2, SQ_MESH, 1, 1), - LEN_SQ_MESH + 2, NULL, NULL, 14, + LEN_SQ_MESH + 2, NULL, NULL, 15, + snmpAddNode(snmpCreateOid(LEN_SQ_MESH + 3, SQ_MESH, MESH_PTBL, 1, MESH_PTBL_INDEX), + LEN_SQ_MESH + 3, snmp_meshPtblFn, peer_Inst, 0), snmpAddNode(snmpCreateOid(LEN_SQ_MESH + 3, SQ_MESH, MESH_PTBL, 1, MESH_PTBL_NAME), LEN_SQ_MESH + 3, snmp_meshPtblFn, peer_Inst, 0), snmpAddNode(snmpCreateOid(LEN_SQ_MESH + 3, SQ_MESH, MESH_PTBL, 1, MESH_PTBL_ADDR_TYPE), @@ -737,7 +739,11 @@ *NextLen = CurrentLen; *Next = (*mibTreeEntry->instancefunction) (Current, NextLen, mibTreeEntry, &Fn); if (*Next) - return (Fn); + { + debugs(49, 6, "snmpTreeNext: Next : "); + snmpDebugOid(6, *Next, *NextLen); + return (Fn); + } } if ((mibTreeEntry) && (mibTreeEntry->parsefunction)) { @@ -778,7 +784,11 @@ } if (*Next) + { + debugs(49, 6, "snmpTreeNext: Next : "); + snmpDebugOid(6, *Next, *NextLen); return (Fn); + } else return NULL; } @@ -832,12 +842,6 @@ { oid *instance = NULL; peer *peers = Config.peers; - IPAddress laddr; - char host_addr[MAX_IPSTRLEN]; - char *last_addr = NULL; - char current_addr[MAX_IPSTRLEN]; - current_addr[0] = '\0'; - host_addr[0] = '\0'; if (peers == NULL) { current = current->parent->parent->parent->leaves[1]; @@ -846,65 +850,24 @@ instance = client_Inst(current->name, len, current, Fn); } else if (*len <= current->len) { - // I'm almost sure always *len == current->len in calls. - // by the MIB-tree instantation - // instance function are reached only then. -#if USE_IPV6 - int size = peers->in_addr.IsIPv4()? sizeof(in_addr) : sizeof(in6_addr) ; -#else - int size = sizeof(in_addr); -#endif - instance = (oid *)xmalloc(sizeof(name) * ( *len + size)); + instance = (oid *)xmalloc(sizeof(name) * ( *len + 1)); xmemcpy(instance, name, (sizeof(name) * *len)); - addr2oid(peers->in_addr, &instance[*len]); // the address - *len += size; + instance[*len] = 1 ; + *len += 1; } else { - int shift = *len - current->len ; // i.e 4 or 16 - oid2addr(&name[current->len], laddr, shift); - laddr.NtoA(host_addr,MAX_IPSTRLEN); - last_addr = (char *)xmalloc(strlen(host_addr)); - strncpy(last_addr, host_addr, strlen(host_addr)); - peers->in_addr.NtoA(current_addr,MAX_IPSTRLEN); - /* WARNING : In the peer table, - * let's assume IPv4 address to precceed IPv6 ones, - * to keep lexicographical order in OID, - * (see mib.txt : they are indexed by - * the pair ( type_addr, addr ) - * type_addr 1 for IPv4 , 2 for IPv6 . - */ - while ((peers) && (strncmp(last_addr, current_addr, strlen(current_addr)))) { - if (peers->next) { - peers = peers->next; - peers->in_addr.NtoA(current_addr, MAX_IPSTRLEN); - } else { - peers = NULL; - } - } - - xfree(last_addr); + int no = name[current->len] ; + int i ; // Note: This works because the Confifg.peers + // keep its index acording to its position. + for ( i=0 ; peers && (i < no) ; peers = peers->next , i++ ) ; if (peers) { - if (peers->next) { - peers = peers->next; -#if USE_IPV6 - int newshift = peers->in_addr.IsIPv4()? sizeof(in_addr) : sizeof(in6_addr) ; -#else - int newshift = sizeof(in_addr) ; -#endif - // *len == current->len + shift - // *newlen == current->len + newshift - instance = (oid *)xmalloc(sizeof(name) * (current->len + newshift )); + instance = (oid *)xmalloc(sizeof(name) * (current->len + 1 )); xmemcpy(instance, name, (sizeof(name) * current->len )); - addr2oid(peers->in_addr, &instance[current->len]); // the address - *len = current->len + newshift ; - } else { - return (instance); - } + instance[current->len] = no + 1 ; // i.e. the next index on cache_peeer table. } else { return (instance); } } - *Fn = current->parsefunction; return (instance); }