Skip to content

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

Merged
smlng merged 1 commit intoRIOT-OS:masterfrom
kb2ma:gcoap/remote_in_request
Dec 18, 2017
Merged

net/gcoap: Track remote endpoint for all requests#8250
smlng merged 1 commit intoRIOT-OS:masterfrom
kb2ma:gcoap/remote_in_request

Conversation

@kb2ma
Copy link
Copy Markdown
Member

@kb2ma kb2ma commented Dec 13, 2017

Contribution description

Used to improve request/response matching.

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

smlng commented Dec 18, 2017

please squash, I'll test in ASAP.

@kb2ma kb2ma force-pushed the gcoap/remote_in_request branch from 692bd83 to 062bc15 Compare December 18, 2017 11:27
@kb2ma
Copy link
Copy Markdown
Member Author

kb2ma commented Dec 18, 2017

Squashed.

@smlng
Copy link
Copy Markdown
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