0

So I am getting started with SCTP and have written the basics of the SCTP server application(which I intend to modify to make it a peer-to-peer app). The code is incomplete but I compiled and ran it to test the socket options and the first setsockopt returns error 10042(protocol not supported). I have determined that it's the first call of setsockopt() that returns an error. So here is the incomplete code:

#include "stdafx.h"
#include <iostream>
#include <iostream>
#include <string.h>
#include <stdlib.h>

#ifndef UNICODE
#define UNICODE
#endif

#define WIN32_LEAN_AND_MEAN

#include <WinSock2.h>
#include <WS2tcpip.h>
#include <WS2spi.h>
#include <ws2sctp.h>
#include <wsipv6ok.h>
#include <if.h>
#include "ws2isatap.h"
#include "if_tunnel.h"





#pragma comment(lib, "ws2_32.lib")
#pragma comment(lib, "sctpsp.lib")


using namespace std;
using namespace System;

static int LISTENQ = 5;

void isatap_enable(void);

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



WSADATA wsaData;
    int iResult;
    int optv = 10;
    u_long imode = 1;
    bool connected = false;
    char *optval = (char*)&optv;
    int optlen = sizeof(optval);
    sockaddr_in6 servAddr;
    sctp_sndrcvinfo sr;
    sctp_event_subscribe evnts;
    sctp_initmsg init;



    memset(&sr,0,sizeof(sr));
    memset(&evnts,0,sizeof(evnts));
    memset(&init,0,sizeof(init));
    memset(&servAddr,0,sizeof(servAddr));



    iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
    if (iResult != NO_ERROR) {
        wprintf(L"WSAStartup function failed with error: %d\n", iResult);
        return 1;
    }




    SOCKET servSock = socket(AF_INET6,SOCK_STREAM,IPPROTO_SCTP);
    if(servSock==INVALID_SOCKET){
        printf("Socket function failed with error: %d\n",GetLastError());
        return 1;
    }


    if(setsockopt(servSock,IPPROTO_IPV6,IPV6_PROTECTION_LEVEL,optval,sizeof(optval))<0){
        printf("setsockopt function failed with error: %d\n", GetLastError());
        return 1;
    }





    u_int servPort = 5000;  
    servAddr.sin6_family = AF_INET6;
    servAddr.sin6_addr = in6addr_any;
    servAddr.sin6_port = htons(servPort);



    if(setsockopt(servSock,IPPROTO_SCTP,SCTP_EVENTS,(const char*)&evnts,sizeof(evnts)) < 0){
        printf("setsockopt function failed with error: %d\n", GetLastError());
        return 1;
    }




    ioctlsocket(servSock,FIONBIO, &imode);

    if(bind(servSock,(struct sockaddr*)&servAddr,sizeof(servAddr))<0){
        printf("Bind function failed with error: %d\n", GetLastError());
        return 1;
    }

    evnts.sctp_data_io_event = 1;
    evnts.sctp_association_event = *(u_char*)optval;

    for(;;){

       if(listen(servSock,LISTENQ) < 0){
        printf("Listen function failed with error: %d/n",GetLastError());
        return 1;
        }else{

            printf("Listening on port %d\n",servPort);
        }














    }


}
Mr X
  • 336
  • 1
  • 6
  • 22

2 Answers2

1

If it's related to python packages nameko/kombu/amqp, then it's reported here Issue with 2.1.4 version.

Temporary soln: Roll-back the version to 2.1.3 till it's fixed.

Abhijeet
  • 8,561
  • 5
  • 70
  • 76
0

OK guys, I fixed it(for now lol). What I did is substitute the IPPROTO_IPV6 with IPPROTO_SCTP and it seems to work.

Mr X
  • 336
  • 1
  • 6
  • 22