Re: squid3-ipv6 squid3/src snmp_agent.cc,1.7.4.7,1.7.4.8

From: Amos Jeffries <squid3@dont-contact.us>
Date: Tue, 25 Sep 2007 15:48:23 +1200 (NZST)

> Update of cvs.devel.squid-cache.org:/cvsroot/squid/squid3/src
>
> Modified Files:
> Tag: squid3-ipv6
> snmp_agent.cc
> Log Message:
> Added IPv6 MIB values
>
<snip>

> ! {
> ! // 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));

No need to memcpy twice.
"
   struct in6_addr *iaddr6=(struct in6_addr*)Answer->val.string;
   laddr.GetInAddr(*iaddr6);
"
will do the job as nicely, with less memory, AND initialize the buffer
properly as needed.

Thanks SO much for taking this on.

Amos
Received on Mon Sep 24 2007 - 21:48:50 MDT

This archive was generated by hypermail pre-2.1.9 : Mon Oct 01 2007 - 12:00:05 MDT