Re: updated ipv6 patch for postfix
>>>>> On Thu, 20 Jan 2000 12:24:11 +0000,
>>>>> Philip Blundell <pb@labs.futuretv.com> said:
>> I may still misunderstand the point, but I think you can calculate the
>> offset (i.e. sizeof(struct sockaddr_in6)) if you first check the
>> sa_family likt the following code:
>>
>> struct ifconf ifconf;
>> struct ifreq *ifrp;
>>
>> ioctl(sockt, SIOCGIFCONF, (char *)&ifconf);
>>
>> for (i = 0; i < ifconf.ifc_len; i += sizeof(struct ifreq)) {
>> ifrp = (struct ifreq *)(ifconfg.ifc_buf + i);
>>
>> .../* use ifrp as you want */
>>
>> if (ifrp->ifr_addr.sa_family == AF_INET6) /* you may need more cases */
>> i += (sizeof(struct sockaddr_in6) - sizeof(struct sockaddr));
>> }
> Sure, but old programs don't know to do that and so they would break. This is
> why I don't think we can extend SIOCGIFCONF and instead a new ioctl is needed.
> (Apologies if we've been talking at cross purposes.)
> Other than the compatibility issues I don't think there is any problem.
Okay, I finally get your point. You're right, but there's a
compatibility issue even in the 4.4BSD world. Some applications
assume that the data length returned by SIOCGIFCONF is a multiple of
sizeof(ifreq) when they estimate an enough buffer size to store all
the addresses.
By the way, bsdi has an interesting library function called
"getifaddrs", which returns a linked list of addresses. We may have to
consider to standardize such a function...
JINMEI, Tatuya
Communication Platform Lab.
Corporate R&D Center, Toshiba Corp.
jinmei@isl.rdc.toshiba.co.jp
Reply to: