ccnl_i_prefixof_c can return different negative values which indicate error cases. Users of this function (see here for example) should not only fail if !ccnl_i_prefixof_c but rather when values are negative.
Please review with care! I'm not 100% sure I missed something.
Testing
This can be tested with RIOT. Check out this branch locally and in your RIOT clone, point to your local ccn-lite repoby setting the build variable in the pkg Makefile like:
PKG_SOURCE_LOCAL ?= $(RIOTBASE)/../ccn-lite.
Build the ccn-lite demo application under RIOT/examples/ccn-lite-relay for native.
Start two native instances with make term and make term PORT=tap1.
On one instance, add two contents:
ccnl_cs /foo "Bar!"ccnl_cs /a/b/c/d content123
On the other instance, send an interest requests for both items:
ccnl_int /fooccnl_int /a/b/c/d
w/o this PR (on current ccn-lite master)
main(): This is RIOT! (Version: 2020.01-devel-25-gcbee3-HEAD)
Basic CCN-Lite example
> ccnl_int /foo
ccnl_int /foo
> PKTDUMP: data received:
~~ SNIP 0 - size: 4 byte, type: GNRC_NETTYPE_CCN_CHUNK (2)
Content is: Bar!
~~ PKT - 1 snips, total size: 4 byte
ccnl_int /a/b/c/d
ccnl_int /a/b/c/d
PKTDUMP: data received:
~~ SNIP 0 - size: 4 byte, type: GNRC_NETTYPE_CCN_CHUNK (2)
Content is: Bar!
~~ PKT - 1 snips, total size: 4 byte
-> Second request is answered incorrectly from local CS
w/ this PR
See the requested content being received
main(): This is RIOT! (Version: 2020.01-devel-25-gcbee3-HEAD)
Basic CCN-Lite example
> ccnl_int /foo
ccnl_int /foo
>PKTDUMP: data received:
~~ SNIP 0 - size: 4 byte, type: GNRC_NETTYPE_CCN_CHUNK (2)
Content is: Bar!
~~ PKT - 1 snips, total size: 4 byte
ccnl_int /a/b/c/d
ccnl_int /a/b/c/d
> PKTDUMP: data received:
~~ SNIP 0 - size: 10 byte, type: GNRC_NETTYPE_CCN_CHUNK (2)
Content is: content123
~~ PKT - 1 snips, total size: 10 byte
Contribution description
cmp > 0 && (uint32_t) cmp == prefix->compcnt;
seems like the aim to do an exact match. This PR changes to simply useCMP_EXACT
.ccnl_i_prefixof_c
can return different negative values which indicate error cases. Users of this function (see here for example) should not only fail if!ccnl_i_prefixof_c
but rather when values are negative.Please review with care! I'm not 100% sure I missed something.
Testing
PKG_SOURCE_LOCAL ?= $(RIOTBASE)/../ccn-lite
.native
.make term
andmake term PORT=tap1
.ccnl_cs /foo "Bar!"
ccnl_cs /a/b/c/d content123
ccnl_int /foo
ccnl_int /a/b/c/d
w/o this PR (on current ccn-lite master)
-> Second request is answered incorrectly from local CS
w/ this PR
See the requested content being received
-> Both requests answered correctly.