I am trying to use socket options SCTP_PRIMARY_ADDR to make one of local address of SCTP association as primary and SCTP_SET_PEER_PRIMARY_ADDR to request SCTP server to make one of it's address as primary for SCTP future communication.
struct sctp_setprim setPrimary;
memset((void *)&setPrimary, 0, sizeof(struct sctp_setprim));
setPrimary.ssp_assoc_id = 0;
struct sockaddr_in *in_addr;
in_addr = (struct sockaddr_in *)&setPrimary.ssp_addr;
in_addr->sin_port = htons(localPort);
in_addr->sin_family = AF_INET;
in_addr->sin_addr.s_addr = localIps[0].Int32NetworkOrder();
int rc = setsockopt(m_s, IPPROTO_SCTP, SCTP_PRIMARY_ADDR, &setPrimary, sizeof(struct sctp_setprim));**
For above snippet of code, I see socket error "Invalid argument". I don't know the reason behind this error. I have verified ip address.
Also for SCTP_SET_PEER_PRIMARY_ADDR, below code snippet is added.
struct sctp_setpeerprim setPeerPrimary;
memset((void *)&setPeerPrimary, 0, sizeof(struct sctp_setpeerprim));
setPeerPrimary.sspp_assoc_id = 0;
struct sockaddr_in *in_addr;
in_addr = (struct sockaddr_in *)&setPeerPrimary.sspp_addr;
in_addr->sin_port = htons(remotePort);
in_addr->sin_family = AF_INET;
in_addr->sin_addr.s_addr = remoteIps[0].Int32NetworkOrder();
int rc = setsockopt(m_s, IPPROTO_SCTP, SCTP_SET_PEER_PRIMARY_ADDR, &setPeerPrimary, sizeof(struct sctp_setpeerprim));
For this code block, I see error "Operation not permitted". And again, I'm clueless about this error reason.
Am I doing something really wrong or my sctp library isn't supporting above socket options?
Please help.