0

I am using the following code to receive SCTP notifications. I am using Linux ubuntu 20.04. Please could you help to intercept SACK_SCTP messages. Here you find attached my code to receive all possible notifications.

void *
receive_sacks(void *arg)
{

    sockParamRcv_t paramsDest = *((sockParamRcv_t *) arg);
    char buffer[100];
    int ret;
    int flags = 0;

    struct sctp_sndrcvinfo info;
    union sctp_notification *notification;
    struct sctp_event_subscribe events;

    socklen_t from_len = sizeof(paramsDest.servaddr.sin_addr);

    // Set the events of interest for the socket
    memset(&events, 0, sizeof(events));
    events.sctp_data_io_event = 1;
    events.sctp_association_event = 1;

    events.sctp_adaptation_layer_event = 1;
    events.sctp_send_failure_event = 1;
    events.sctp_assoc_reset_event = 1;

    events.sctp_stream_change_event = 1;
    events.sctp_stream_reset_event = 1;
    events.sctp_shutdown_event = 1;

    events.sctp_send_failure_event = 1;
    ret = setsockopt(paramsDest.sock, IPPROTO_SCTP, SCTP_EVENTS, &events, sizeof(events));
    if (ret < 0) {
        perror("setsockopt");
        return 1;
    }

    while (1) {
        ret = sctp_recvmsg(paramsDest.sock, buffer, sizeof(buffer), (struct sockaddr *) NULL, 0, &info, &flags);

        if (ret < 0) {
            perror("sctp_get_sndrcvinfo() failed");
            close(paramsDest.sock);
            exit(1);
        }

        printf("Received SCTP SACK message, %d\n", info.sinfo_flags);
        printf("Received unexpected SCTP message type\n");

        if (ret > 0) {
            printf("flags  : %d\n", flags);
            printf("Received message: %s\n", buffer);
            if (flags & MSG_NOTIFICATION) {
                notification = (union sctp_notification *) buffer;

                printf("flags : %d\n", flags);

            }
        }

    }

    return NULL;
}
Craig Estey
  • 30,627
  • 4
  • 24
  • 48
rafinf
  • 21
  • 4

0 Answers0