--------------------- PatchSet 5740 Date: 2007/09/24 15:06:46 Author: rmartinez Branch: squid3-ipv6 Tag: (none) Log: Added IPv6 MIB values Members: src/snmp_agent.cc:1.7.4.7->1.7.4.8 Index: squid3/src/snmp_agent.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/snmp_agent.cc,v retrieving revision 1.7.4.7 retrieving revision 1.7.4.8 diff -u -r1.7.4.7 -r1.7.4.8 --- squid3/src/snmp_agent.cc 29 Aug 2007 02:07:46 -0000 1.7.4.7 +++ squid3/src/snmp_agent.cc 24 Sep 2007 15:06:46 -0000 1.7.4.8 @@ -1,6 +1,6 @@ /* - * $Id: snmp_agent.cc,v 1.7.4.7 2007/08/29 02:07:46 amosjeffries Exp $ + * $Id: snmp_agent.cc,v 1.7.4.8 2007/09/24 15:06:46 rmartinez Exp $ * * DEBUG: section 49 SNMP Interface * AUTHOR: Kostas Anagnostakis @@ -189,7 +189,6 @@ variable_list *Answer = NULL; IPAddress laddr; - struct in_addr iaddr; char *cp = NULL; peer *p = NULL; int cnt = 0; @@ -217,11 +216,26 @@ break; case MESH_PTBL_IP: - laddr.GetInAddr(iaddr); - Answer = snmp_var_new_integer(Var->name, Var->name_length, - (snint) iaddr.s_addr, - SMI_IPADDRESS); - break; + if (laddr.IsIPv4()) { + struct in_addr iaddr4; + laddr.GetInAddr(iaddr4); + Answer = snmp_var_new_integer(Var->name, Var->name_length, + (snint) iaddr4.s_addr, + SMI_IPADDRESS); + } + else + { + // IPv6 address doesn't have its own ASN.1 type (like IPv4 does) + // See: rfc2465.txt, rfc4001.txt + struct in6_addr iaddr6; + laddr.GetInAddr(iaddr6); + Answer = snmp_var_new(Var->name, Var->name_length); + Answer->type = ASN_OCTET_STR; + Answer->val_len = sizeof(struct in6_addr);// Use a symbolic constant. + Answer->val.string = (u_char *) malloc(sizeof(struct in6_addr)); + memcpy(Answer->val.string,&iaddr6,sizeof(struct in6_addr)); + } + break; case MESH_PTBL_HTTP: Answer = snmp_var_new_integer(Var->name, Var->name_length,