Skip to content

Byte order of message ID interface is inconsistent #13

@kb2ma

Description

@kb2ma

coap_get_id() performs a ntohs() on the coap_hdr_t.id attribute to return a value in host byte order.

However, coap_build_hdr() assumes the id parameter input already is in network order. Since it is a public function, I think the id parameter should be in host order, to reverse the effect of coap_get_id(). For example, the use of coap_build_hdr() in nanocoap_get() expects to store a message id of 1, but actually stores 256 (0x0100).

This change would require an update in coap_build_reply() to swap the byte order before passing to coap_build_hdr().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions