Re: API draft: section 8.3 and 8.5

From: David Lehmann <lehmann@ulticom.com>
Date: Tue Feb 08 2005 - 14:12:04 EST
('binary' encoding is not supported, stored as-is) ('binary' encoding is not supported, stored as-is) Randall Stewart wrote:
> David Lehmann wrote:
>
>> Hello,
>>
>> Sections 8.3 and 8.5 are not clear on exactly what structures are being
>> returned. It states:
>> On return, addrs will point to a dynamically allocated array of
>> sockaddr structures of the appropriate type for the socket type. The
>> caller should use sctp_freeladdrs() to free the memory. Note that
>> the in/out parameter addrs must not be NULL.
>>
>> If sd is an IPv4 socket, the addresses returned will be all IPv4
>> addresses. If sd is an IPv6 socket, the addresses returned can be a
>> mix of IPv4 or IPv6 addresses.
>>
>> IMHO, something similar to the following would be more explicit:
>> On return, addrs will point to a dynamically allocated array of
>> sockaddr structures of the appropriate type for the socket type.
>> If sd is an IPv4 socket, 'addrs' will point to an array of struct
>> sockaddr_in
>> and the addresses returned will be all IPv4 addresses. If sd is an
>> IPv6 socket, 'addrs' will point to an array of struct sockaddr_in6
>> and the
>> addresses returned will be IPv6 addresses and/or IPv4 mapped
>> addresses.
>>
>> The caller should use sctp_freeladdrs() to free the memory. Note that
>> the in/out parameter 'addrs' must not be NULL.
>>
>>
> Except that if an implementation supports the
> SCTP_I_WANT_MAPPED_V4_ADDR
>
> And this is turned OFF
>
> Then you would get a mix of V4 and V6 addresses (what Kacheong hates)..
> which is why it is vague...
>
> For some O/S's (such as Kacheongs) you cannto turn
> SCTP_I_WANT_MAPPED_V4_ADDR
> Off... and thats fine.. then your statements above would be completely
> true..
>
> For other OS's.. aka BSD.. you CAN disable that option so you would
> get back a mix..

OK then, explain to me what the "mixed" return data is.
Are you stating that there could be sockaddr_in6 elements _and_
sockaddr_in elements returned? i.e. I can't index into the
"array" buy rather have to move the pointer down the appropriate
number of bytes depending on the record?

e.g.
        struct sockaddr *addrs;
        int count;

        count = sctp_getpaddrs(sd, id, &addrs);

        while (count-- >= 0)
        {
                if (addrs->sa_family == AF_INET)
                {
                        struct sockaddr_in *sin = (struct sockaddr_in *)addrs;

                        /* Do something with returned address */
                        ...
                
                        /* go to next addr */
                        addrs = (struct sockaddr *)(sin + 1)
                }
                else if (addrs->sa_family == AF_INET6)
                {
                        struct sockaddr_in6 *sin6 =
                                (struct sockaddr_in6 *)addrs;

                        /* Do something with returned address */
                        ...
                
                        /* go to next addr */
                        addrs = (struct sockaddr *)(sin6 + 1)
                }
                else
                {
                        /* bogus family */
                }
        }

-- 
David Lehmann                          Ulticom, Inc.
AOL/Yahoo IM: davidULCM                1020 Briggs Road
1-856-787-2729                         Mt. Laurel, NJ 08054   USA
Received on Tue Feb 8 14:37:27 2005

This archive was generated by hypermail 2.1.8 : Mon Mar 13 2006 - 15:22:23 EST