Skip to content
Snippets Groups Projects
Commit d4a0b3f5 authored by Oleg Hahm's avatar Oleg Hahm
Browse files

gnrc: add some assertions

parent e3165b49
No related branches found
No related tags found
No related merge requests found
...@@ -62,10 +62,14 @@ void ng_icmpv6_demux(kernel_pid_t iface, ng_pktsnip_t *pkt) ...@@ -62,10 +62,14 @@ void ng_icmpv6_demux(kernel_pid_t iface, ng_pktsnip_t *pkt)
LL_SEARCH_SCALAR(pkt, icmpv6, type, NG_NETTYPE_ICMPV6); LL_SEARCH_SCALAR(pkt, icmpv6, type, NG_NETTYPE_ICMPV6);
assert(icmpv6 != NULL);
/* there can be extension headers between IPv6 and ICMPv6 header so we have /* there can be extension headers between IPv6 and ICMPv6 header so we have
* to search it */ * to search it */
LL_SEARCH_SCALAR(icmpv6, ipv6, type, NG_NETTYPE_IPV6); LL_SEARCH_SCALAR(icmpv6, ipv6, type, NG_NETTYPE_IPV6);
assert(ipv6 != NULL);
hdr = (ng_icmpv6_hdr_t *)icmpv6->data; hdr = (ng_icmpv6_hdr_t *)icmpv6->data;
if (_calc_csum(icmpv6, ipv6, pkt)) { if (_calc_csum(icmpv6, ipv6, pkt)) {
......
...@@ -593,6 +593,8 @@ static void _receive(ng_pktsnip_t *pkt) ...@@ -593,6 +593,8 @@ static void _receive(ng_pktsnip_t *pkt)
ng_pktsnip_t *ipv6, *netif; ng_pktsnip_t *ipv6, *netif;
ng_ipv6_hdr_t *hdr; ng_ipv6_hdr_t *hdr;
assert(pkt != NULL);
LL_SEARCH_SCALAR(pkt, netif, type, NG_NETTYPE_NETIF); LL_SEARCH_SCALAR(pkt, netif, type, NG_NETTYPE_NETIF);
if (netif != NULL) { if (netif != NULL) {
......
...@@ -120,6 +120,8 @@ static void _receive(ng_pktsnip_t *pkt) ...@@ -120,6 +120,8 @@ static void _receive(ng_pktsnip_t *pkt)
LL_SEARCH_SCALAR(pkt, ipv6, type, NG_NETTYPE_IPV6); LL_SEARCH_SCALAR(pkt, ipv6, type, NG_NETTYPE_IPV6);
assert(ipv6 != NULL);
/* validate checksum */ /* validate checksum */
if (_calc_csum(udp, ipv6, pkt)) { if (_calc_csum(udp, ipv6, pkt)) {
DEBUG("udp: received packet with invalid checksum, dropping it\n"); DEBUG("udp: received packet with invalid checksum, dropping it\n");
...@@ -144,6 +146,9 @@ static void _send(ng_pktsnip_t *pkt) ...@@ -144,6 +146,9 @@ static void _send(ng_pktsnip_t *pkt)
/* get udp snip and hdr */ /* get udp snip and hdr */
LL_SEARCH_SCALAR(pkt, udp_snip, type, NG_NETTYPE_UDP); LL_SEARCH_SCALAR(pkt, udp_snip, type, NG_NETTYPE_UDP);
assert(udp_snip != NULL);
udp_snip = ng_pktbuf_start_write(udp_snip); udp_snip = ng_pktbuf_start_write(udp_snip);
if (udp_snip == NULL) { if (udp_snip == NULL) {
DEBUG("udp: cannot send packet: unable to allocate packet\n"); DEBUG("udp: cannot send packet: unable to allocate packet\n");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment