Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/gcoap: Track remote endpoint for all requests #8250

Merged
merged 1 commit into from
Dec 18, 2017

Conversation

kb2ma
Copy link
Member

@kb2ma kb2ma commented Dec 13, 2017

Contribution description

Used to improve request/response matching.

Copy link
Member

@smlng smlng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me, still a suggestion:

* return Result of memcmp (-1, 0, 1) if address family and port match;
* otherwise -2.
*/
static int _cmp_endpoints(const sock_udp_ep_t *ep1, const sock_udp_ep_t *ep2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from its usage, IMHO a static bool _endpoints_equal(ep1, ep2) function would be more appropriate, which returns only true or false.

For example (untested):

static bool _endpoints_equal(const sock_udp_ep_t *ep1, const sock_udp_ep_t *ep2)
{
    if (ep1->family != ep2->family) {
        return false;
    }
    if (ep1->port != ep2->port) {
        return false;
    }
    if ((ep1->family == AF_INET) && (ep1->addr.ipv4_u32 != ep2->addr.ipv4_u32)) {
        return false;
    }
    else if (memcmp(&ep1->addr.ipv6[0], &ep2->addr.ipv6[0], 16) != 0) {
        return false;
    }
    return true;
} 

Only a suggestion, what do you think? Otherwise I trust that the changes fit your grander scheme 😉

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @smlng! I agree that your function fits the purpose better. Working on fixup commit.

@smlng smlng added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Area: network Area: Networking CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Dec 14, 2017
@smlng smlng added this to the Release 2018.01 milestone Dec 15, 2017
@smlng
Copy link
Member

smlng commented Dec 18, 2017

please squash, I'll test in ASAP.

@kb2ma
Copy link
Member Author

kb2ma commented Dec 18, 2017

Squashed.

@smlng
Copy link
Member

smlng commented Dec 18, 2017

ACK, tested on macOS and PhyNode, works!

@smlng smlng merged commit c24e87e into RIOT-OS:master Dec 18, 2017
@kb2ma kb2ma deleted the gcoap/remote_in_request branch February 4, 2019 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: network Area: Networking CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants