Subject: Re: sctp_bindx (and sctp_connectx)

From: "Ryan W. Bickhart" <[email-masked]>
Date: Wed, 09 Jun 2004 14:38:07 -0400

Peter:

Thanks for the suggestion, it fixed the sctp_bindx problem. Along the
same lines, I'm also having trouble with sctp_connectx. I incorporated
the sin_len fix in this code as well, but when attempting to do an
sctp_connectx I get the error "Invalid argument". It appears to me that
this error is happening somewhere in the call to setsockopt that
sctp_connectx makes. I'm having trouble determining exactly what the
error is specifically. Any ideas?

Again, I listed a sample program exhibiting this problem below.

Thanks,

Ryan

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netinet/sctp.h>
#include <errno.h>
#include <stdio.h>

#define REMOTE_ADDRS 2
#define REMOTE_PORT 3333

int main(int argc, char *argv[]) {

   int sock_fd = 0;
   int i = 0;
   struct sockaddr_in remote_addrs[REMOTE_ADDRS];
   struct sctp_event_subscribe events;
   
   if(--argc != REMOTE_ADDRS) {
      printf("Usage: %s <addrs>\n", argv[0]);
      exit(1);
   }
   
   if((sock_fd = socket(AF_INET, SOCK_SEQPACKET, IPPROTO_SCTP)) < 0) {
      perror("socket");
      exit(1);
   }
     
   for(i = 0; i < REMOTE_ADDRS; i++) {
      bzero(&(remote_addrs[i]), sizeof(struct sockaddr_in));
      remote_addrs[i].sin_family = AF_INET;
      remote_addrs[i].sin_port = htons(REMOTE_PORT);
      remote_addrs[i].sin_len = sizeof(struct sockaddr_in);
      inet_pton(AF_INET, argv[i + 1], &(remote_addrs[i].sin_addr));      
   }
	
   if(sctp_connectx(sock_fd, (struct sockaddr *) remote_addrs, REMOTE_ADDRS) == -1) {
      perror("sctp_connectx");
      exit(1);
   }

   return 0;
}

> Interesting... not exactly sure why that is the error returned for
> this case... my guess is that because the sin_len is missing, the
> code can't figure out what the next address is, so is an invalid 
> family/proto.  I'll have to double-check that.
> 
> see below for a one line addition to fix your problem:
>          listen_addrs[i].sin_len = sizeof(struct sockaddr_in);

---

From: "Randall Stewart (cisco)" <[email-masked]>
Date: Wed, 09 Jun 2004 16:33:48 -0400

Ryan:

Its a bug in the connectx lib... I will send
you a seperate patch for this off-list..

R

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