Subject: sctp_bindx(0.0.0.0), what should happen?

From: Craig Rodrigues <[email-masked]>
Date: Fri, 13 Feb 2004 18:54:20 -0500

Randall, 

I have the attached testcase.

Basically what it does is:

bind(some address)
sctp_bindx(0.0.0.0)

In LKSCTP, sctp_bindx() returns -1 (errno == EINVAL) in this case.

Is this the correct thing to do?
What does your SCTP stack in KAME do?
What do other SCTP stacks do?

This came about as I was testing some stuff out from a 3rd party
networking library.  There could be wrong stuff happening in
my library, but I just wanted to verify this.

Thanks. 
-- 
Craig Rodrigues        Distributed Systems and Logistics, Office 6/325A
[email-masked]       BBN Technologies
(617) 873-4725         Cambridge, MA

---

From: Michael Tuexen <[email-masked]>
Date: Sat, 14 Feb 2004 12:26:55 +0100

Hi Craig,

the idea of sctp_bindx was to add/delete specific (non wildcard) 
addresses.
It does not make sense to bind a specific address and later on you say 
add
all addresses. (at least for me).

So I would expect that bindx returns an error.

Best regards
Michael

On 14. Feb 2004, at 0:54 Uhr, Craig Rodrigues wrote:

> #include <sys/socket.h>
> #include <sys/types.h>
> #include <netinet/in.h>
> #include <netinet/sctp.h>
> #include <arpa/inet.h>
>
> #include <errno.h>
> #include <stdio.h>
> #include <string.h>
>
> #define CHECK_ERROR(num) if (num < 0 ) { printf("Line: %d, Error %d 
> %s\n", __LINE__, errno, strerror(errno)); exit(1); }
>
> const char *address1 = "128.33.15.53";
> const char *address2 = "0.0.0.0";
> unsigned short port1 = 3505;
> unsigned short port2 = 3505;
>
> void
> initialize_addr(struct sockaddr_in *addr, const char *address, 
> unsigned short port)
> {
>    in_addr_t addr1;
>
>    memset(addr, 0, sizeof(struct sockaddr_in));
>    addr->sin_family = AF_INET;
>    addr->sin_port = htons(port);
>
>    addr1 = inet_addr(address);
>    addr->sin_addr.s_addr = addr1;
> }
>
>
> int
> main(int argc, char *argv[])
> {
>    int fd, ret, i;
>    struct sockaddr_in addr1, addr2;
>    struct sockaddr *addrs=0;
>    struct sockaddr_in *addr;
>    struct sockaddr *a, *b;
>    socklen_t namelen;
>    in_addr_t addr3, addr4;
>    char buf[255];
>
>    fd = socket(PF_INET, SOCK_STREAM, IPPROTO_SCTP);
>    CHECK_ERROR(fd);
>
>    initialize_addr(&addr1, address1, port1);
>    initialize_addr(&addr2, address2, port2);
>
>    ret = bind(fd, (struct sockaddr *)&addr1, sizeof(addr1));
>    CHECK_ERROR(ret);
>
>    ret = sctp_bindx(fd, (struct sockaddr *)&addr2 , 1, 
> SCTP_BINDX_ADD_ADDR );
>    CHECK_ERROR(ret);
>
>    ret = listen(fd, 5);
>    CHECK_ERROR(ret);
>
>    ret = sctp_getladdrs(fd, 0, &addrs);
>    CHECK_ERROR(ret);
>    printf("Num Addrs: %d\n\n", ret);
>
>    for(i=0, a = (struct sockaddr *)addrs; i < ret; ++i, a = a + 1 ) {
>        if( a->sa_family == AF_INET ) {
>          addr = (struct sockaddr_in *)a;
>          printf("IPv4 address: %s, ", inet_ntoa( addr->sin_addr ) );
>          printf("Port: %u, ", addr->sin_port );
>          printf("NTOHS(Port): %u\n", ntohs(addr->sin_port ) );
>        }
>    }
>
>    ret = getsockname(fd, (struct sockaddr *)b, &namelen );
>    CHECK_ERROR(ret);
>    printf("\nGetsockname: \n\n");
>    if( b->sa_family == AF_INET ) {
>      addr = (struct sockaddr_in *)b;
>      printf("IPv4 address: %s, ", inet_ntoa( addr->sin_addr ) );
>      printf("Port: %u, ", addr->sin_port );
>      printf("NTOHS (Port): %u\n", ntohs(addr->sin_port) );
>    }
>
>    sctp_freeladdrs(addrs);
>    return 0;
> }
>

---

From: Craig Rodrigues <[email-masked]>
Date: Wed, 18 Feb 2004 18:00:29 -0500

> So I would expect that bindx returns an error.

This seems like a reasonable thing.  Is this documented
anywhere, like in an RFC?  It would be nice to have
these semantics agreed upon, so that
SCTP user-level code can be ported to different SCTP implementations
and see the same behavior.

---

From: "Randall Stewart (cisco)" <[email-masked]>
Date: Wed, 18 Feb 2004 17:26:53 -0600

>and see the same behavior.
Sounds like more grist for socket-08 :->

R

-- 
Randall R. Stewart
ITD - Transport Technologies
815-477-2127(o) or 815-342-5222(c)