NEAT-project / usrsctp-neat

A portable SCTP userland stack
BSD 3-Clause "New" or "Revised" License
4 stars 1 forks source link

Size of next incoming message (upcall handler) #4

Open lgrahl opened 7 years ago

lgrahl commented 7 years ago

When using the upcall handler, we need to use usrsctp_recvv to retrieve the next message once the SCTP_EVENT_READ has been raised. In order to optimise memory allocation, can we get a function that returns the size of the message we would receive in the next usrsctp_recvv call?

Something like this:

size_t usrsctp_next_message_size(
    struct socket *so,
    struct sockaddr *from,
    socklen_t fromlen,
    int msg_flags
);
tuexen commented 7 years ago

I thought about add a socket option using IPPROTO_SCTP as its level and SCTP_GET_NXT_INFO as its name and using

struct sctp_nxtinfo {
    uint16_t nxt_sid;
    uint16_t nxt_flags;
    uint32_t nxt_ppid;
    uint32_t nxt_length;
    sctp_assoc_t nxt_assoc_id;
};

as its value, which is already defined in RFC6458. This could only be used with getsockopt(). The only thing I'm not sure about is how to handle the case where no next message is queued. Returning -1 from getsockopt() and setting errno to EAGAIN is something I want to avoid. So I think it might be good to define a constant SCTP_NO_MESSAGE which is used in nxt_flags. Any opinion on that?

lgrahl commented 7 years ago

Fine by me. I agree that getsockopt should not return -1 in case no message is available.

lgrahl commented 6 years ago

It has been a year now. :) Any update?