Skip to content

Commit

Permalink
gnrc: replace ng_pktbuf_add() with ng_pktbuf_mark() where it's needed
Browse files Browse the repository at this point in the history
  • Loading branch information
miri64 committed Jul 28, 2015
1 parent 68c9d3d commit 3f4b39a
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 14 deletions.
8 changes: 4 additions & 4 deletions sys/net/application_layer/ng_zep/ng_zep.c
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ static ng_pktsnip_t *_create_received(ng_zep_t *dev, ng_pktsnip_t *pkt,
return NULL;
}

payload = ng_pktbuf_add(pkt, pkt->data, pkt->size - 2, dev->proto);
payload = ng_pktbuf_mark(pkt, pkt->size - 2, dev->proto);

if (payload == NULL) {
return NULL;
Expand All @@ -742,7 +742,7 @@ static ng_pktsnip_t *_create_received(ng_zep_t *dev, ng_pktsnip_t *pkt,
return NULL;
}

mhr = ng_pktbuf_add(pkt, pkt->data, mhr_len, NG_NETTYPE_UNDEF);
mhr = ng_pktbuf_mark(pkt, mhr_len, NG_NETTYPE_UNDEF);

/* TODO: send ACK */

Expand Down Expand Up @@ -776,7 +776,7 @@ static ng_pktsnip_t *_recv_v1(ng_zep_t *dev, ng_pktsnip_t *pkt)
return NULL;
}

zep = ng_pktbuf_add(pkt, pkt->data, sizeof(ng_zep_v1_hdr_t), NG_NETTYPE_UNDEF);
zep = ng_pktbuf_mark(pkt, sizeof(ng_zep_v1_hdr_t), NG_NETTYPE_UNDEF);

if (zep == NULL) {
return NULL;
Expand Down Expand Up @@ -807,7 +807,7 @@ static ng_pktsnip_t *_recv_v2(ng_zep_t *dev, ng_pktsnip_t *pkt)
return NULL;
}

zep = ng_pktbuf_add(pkt, pkt->data, sizeof(ng_zep_v2_data_hdr_t), NG_NETTYPE_UNDEF);
zep = ng_pktbuf_mark(pkt, sizeof(ng_zep_v2_data_hdr_t), NG_NETTYPE_UNDEF);

if (zep == NULL) {
return NULL;
Expand Down
6 changes: 3 additions & 3 deletions sys/net/crosslayer/ng_pktbuf_static/ng_pktbuf_static.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,15 @@ ng_pktsnip_t *ng_pktbuf_start_write(ng_pktsnip_t *pkt)

#ifdef DEVELHELP
#ifdef MODULE_OD
void _print_chunk(void *chunk, size_t size, int num)
static inline void _print_chunk(void *chunk, size_t size, int num)
{
printf("================ chunk %3d (size: %4u) ================\n", num,
(unsigned int)size);
od(chunk, NG_PKTBUF_SIZE, OD_WIDTH_DEFAULT,
OD_FLAGS_ADDRESS_HEX | OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_1);
}

void _print_unused(_unused_t *ptr)
static inline void _print_unused(_unused_t *ptr)
{
printf("~ unused: %p (next: %p, size: %4u) ~\n", (void *)ptr,
(void *)ptr->next, ptr->size);
Expand Down Expand Up @@ -283,7 +283,7 @@ void ng_pktbuf_stats(void)
}

if (chunk <= &_pktbuf[NG_PKTBUF_SIZE - 1]) {
_print_chunk(chunk, &_pktbuf[NG_PKTBUF_SIZE] - chunk, count++);
_print_chunk(chunk, &_pktbuf[NG_PKTBUF_SIZE] - chunk, count);
}
#else
DEBUG("pktbuf: needs od module\n");
Expand Down
2 changes: 1 addition & 1 deletion sys/net/network_layer/ng_ipv6/ext/ng_ipv6_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ bool ng_ipv6_ext_demux(kernel_pid_t iface, ng_pktsnip_t *pkt,
}
}

ext_snip = ng_pktbuf_add(pkt, pkt->data, offset, NG_NETTYPE_IPV6);
ext_snip = ng_pktbuf_mark(pkt, offset, NG_NETTYPE_IPV6);

if (ext_snip == NULL) {
return false;
Expand Down
3 changes: 1 addition & 2 deletions sys/net/network_layer/ng_ipv6/ng_ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -630,8 +630,7 @@ static void _receive(ng_pktsnip_t *pkt)

pkt = ipv6; /* reset pkt from temporary variable */

ipv6 = ng_pktbuf_add(pkt, pkt->data, sizeof(ng_ipv6_hdr_t),
NG_NETTYPE_IPV6);
ipv6 = ng_pktbuf_mark(pkt, sizeof(ng_ipv6_hdr_t), NG_NETTYPE_IPV6);

if (ipv6 == NULL) {
DEBUG("ipv6: error marking IPv6 header, dropping packet\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ bool ng_sixlowpan_iphc_decode(ng_pktsnip_t *pkt)
/* TODO: add next header decoding */

/* remove 6LoWPAN dispatch */
payload = ng_pktbuf_add(pkt, pkt->data, payload_offset, NG_NETTYPE_SIXLOWPAN);
payload = ng_pktbuf_mark(pkt, payload_offset, NG_NETTYPE_SIXLOWPAN);
pkt = ng_pktbuf_remove_snip(pkt, payload);

/* set IPv6 header payload length field to the length of whatever is left
Expand Down
3 changes: 1 addition & 2 deletions sys/net/network_layer/ng_sixlowpan/ng_sixlowpan.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ static void _receive(ng_pktsnip_t *pkt)
}

/* packet is uncompressed: just mark and remove the dispatch */
sixlowpan = ng_pktbuf_add(payload, payload->data, sizeof(uint8_t),
NG_NETTYPE_SIXLOWPAN);
sixlowpan = ng_pktbuf_mark(payload, sizeof(uint8_t), NG_NETTYPE_SIXLOWPAN);

if (sixlowpan == NULL) {
DEBUG("6lo: can not mark 6LoWPAN dispatch\n");
Expand Down
2 changes: 1 addition & 1 deletion sys/net/transport_layer/ng_udp/ng_udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static void _receive(ng_pktsnip_t *pkt)
return;
}
pkt = udp;
udp = ng_pktbuf_add(pkt, pkt->data, sizeof(ng_udp_hdr_t), NG_NETTYPE_UDP);
udp = ng_pktbuf_mark(pkt, sizeof(ng_udp_hdr_t), NG_NETTYPE_UDP);
if (udp == NULL) {
DEBUG("udp: error marking UDP header, dropping packet\n");
ng_pktbuf_release(pkt);
Expand Down

0 comments on commit 3f4b39a

Please sign in to comment.