[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: updated ipv6 patch for postfix



>>>>> On Thu, 20 Jan 2000 09:20:58 +0000, 
>>>>> Philip Blundell <pb@labs.futuretv.com> said:

>>>> Sockaddr_in6 does not fit in ifreq{} in BSDs, either. But it doesn't
>>>> matter for us if we carefully parse the result of the ioctl.
>> 
>>> I remember that application increments its pointer manually by 
>>> sizeof(struct sockaddr_in6) - sizeof(struct sockaddr) bytes, 
>>> but it is not good for Linux because we don't know the actual size of 
>>> sockaddr_in6 structure returned from kernel
>> 
>> I don't get it. Why can't you just use sizeof(sockaddr_in6) for
>> AF_INET6? Are you concerned with padding issues?

> The returned structure includes (essentially) an array of `struct sockaddr'.
> You can't just vary the size of this structure since the user program would 
> then have no way to find elements beyond the first.  (For 4.4BSD this is not a 
> problem because you can use sa->sa_len to get this information.)

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));
  }

					JINMEI, Tatuya
					Communication Platform Lab.
					Corporate R&D Center, Toshiba Corp.
					jinmei@isl.rdc.toshiba.co.jp


Reply to: