Re: squid3-ipv6 squid3/src snmp_core.cc,1.10.8.22,1.10.8.23

From: Amos Jeffries <squid3@dont-contact.us>
Date: Tue, 20 Nov 2007 11:24:48 +1300 (NZDT)

> Update of cvs.devel.squid-cache.org:/cvsroot/squid/squid3/src
>
> Modified Files:
> Tag: squid3-ipv6
> snmp_core.cc
> Log Message:
>
> This is a very imporant commit.
> 1.- Fix a duplicate node ICP_REPLY, ( a typo on a previous copy-paste)
> 2.- Implement the peer_Inst and client_Inst acording to new SQUID MIB,
> that is, adding a new field OID reserved for INET_ADDRTYPE
> 3.- Fix addr2oid and oid2addr routines to fullfill SQUID MIB
>
>
> Index: snmp_core.cc
> ===================================================================

> --- 536,542 ----
> }
>
> + /* RAFA, Amos, DO NOT COMMIT INTO AHEAD with this !!! */
> + allow = 1 ;
> + /* allow */
> if ((snmp_coexist_V2toV1(PDU)) && (Community) && (allow)) {
> rq->community = Community;

Noted.
I have also wrapped it with a FIXME INET6 so it shows up on my automatic
todo list.

> --- 1140,1222 ----
> }
>
> +
> +
> + /*
> + IPv4 address: 10.10.0.9 ==>
> + oid == 1.10.10.0.9
> + IPv6 adress : 20:01:32:ef:a2:21:fb:32:00:00:00:00:00:00:00:00:OO:01
> ==>
> + oid == 2.32.1.50.239.162.33.251.20.50.0.0.0.0.0.0.0.0.0.1
> + */
> void
> addr2oid(IPAddress &addr, oid * Dest)
> {
> ! u_int i ;
> ! u_char *cp = NULL;
> ! struct in_addr iaddr;
> ! #if USE_IPV6
> ! struct in6_addr i6addr;
> ! oid code = addr.IsIPv4()? INETADDRESSTYPE_IPV4 : INETADDRESSTYPE_IPV6
> ;
> ! u_int size = (code == INETADDRESSTYPE_IPV4) ? sizeof(struct
> in_addr):sizeof(struct in6_addr);
> ! #else
> ! oid code = INETADDRESSTYPE_IPV4 ;
> ! u_int size = sizeof(struct in_addr) ;
> ! #endif /* USE_IPV6 */
> ! Dest[0] = code ;
> ! if ( code == INETADDRESSTYPE_IPV4 ) {
> addr.GetInAddr(iaddr);
> cp = (u_char *) &(iaddr.s_addr);
> ! }
> ! #if USE_IPV6
> ! else
> ! {
> ! addr.GetInAddr(i6addr);
> ! cp = (u_char *) &i6addr;
> ! }
> ! #endif
> ! for ( i=0 ; i < size ; i++)
> ! {
> ! // OID's are in network order
> ! Dest[1+i] = *cp++;
> ! }

This looks like a double copy to me. Does it really need to be that way?
GetInAddr preserves network-order and writes to an arbitrary buffer if
cast to an addr type.

Looks to me like the below would be sufficient:

   struct in_addr *iaddr = &(Dest[1]);
 #if USE_IPV6
   struct in6_addr *i6addr = &(Dest[1]);
   if(addr.IsIPv4()) {
 #endif
     Dest[0] = INETADDRESSTYPE_IPV4;
     addr.GetAddr(*iaddr);
 #if USE_IPV6
   } else {
     Dest[0] = INETADDRESSTYPE_IPV6;
     addr.GetAddr(*i6addr);
   }
 #endif

Similar in reverse for oid2addr.

Amos
Received on Mon Nov 19 2007 - 15:24:53 MST

This archive was generated by hypermail pre-2.1.9 : Sat Dec 01 2007 - 12:00:05 MST