Subject: sctp_bindx

From: "Ryan W. Bickhart" <[email-masked]>
Date: Tue, 08 Jun 2004 16:00:06 -0400

Hello!

I'm not sure if anyone else has experienced this problem, but I am
currently having trouble with sctp_bindx. Specifically, if I try to bind
any number of addresses (so far I have tried both a single address and
two at a time), bindx fails with the error message "Address family not
supported by protocol family". Below is a small program that causes the
error. The system being used is FreeBSD 4.9 using the March 31 KAME
snapshot with SCTP patch 20 applied.

If you have any insight or suggestions they would be most appreciated.

Thanks!

Ryan

Sample code:

#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 LISTEN_ADDRS 2
#define LISTEN_PORT 3333

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

   int sock_fd = 0;
   int i = 0;
   struct sockaddr_in listen_addrs[LISTEN_ADDRS];

   if(--argc != LISTEN_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 < LISTEN_ADDRS; i++) {
      bzero(&listen_addrs[i], sizeof(struct sockaddr_in));
      listen_addrs[i].sin_family = AF_INET;
      inet_pton(AF_INET, argv[i + 1], &listen_addrs[i].sin_addr);
      listen_addrs[i].sin_port = htons(LISTEN_PORT);
   }
   
   printf("Binding the following:\n");
   
   for(i = 0; i < LISTEN_ADDRS; i++) {
      printf("Address: %s, ", inet_ntoa(listen_addrs[i].sin_addr));
      printf("Port: %d\n", ntohs(listen_addrs[i].sin_port));
   }
	
   if(sctp_bindx(sock_fd, (struct sockaddr *) listen_addrs, LISTEN_ADDRS, SCTP_BINDX_ADD_ADDR) == -1) {
      perror("sctp_bindx");
      exit(1);
   }
}