des-testbed / libdessert

DES-SERT is the DES Simple and Extensible Routing-Framework for Testbeds that is realized as user space library and can be used to implement proactive, reactive, and hybrid routing protocols.
http://www.des-testbed.net/DES-SERT
GNU General Public License v3.0
3 stars 2 forks source link

payload length in dessert_msg_getpayload #5

Open mfrey opened 10 years ago

mfrey commented 10 years ago

The method dessert_msg_getpayload retrieves a pointer to the payload of a dessert message. It returns the length of the payload. However the payload is not transformed to host byte order. From the source code

int dessert_msg_getpayload(dessert_msg_t* msg, void** payload) {
    /* test if payload is present in msg */
    if(msg->plen == 0) {
        *payload = NULL;
        return 0;
    }

    *payload = (uint8_t*) msg + ntohs(msg->hlen);

    return msg->plen;
}

It sets the pointer to the right position (after the header), but the payload length should be transformed via ntohs.