Skip to content

Commit

Permalink
ng_{sixlowpan|ipv6}_netif: don't create ng_sixlowpan_netif_ts adhoc
Browse files Browse the repository at this point in the history
  • Loading branch information
miri64 committed Jul 28, 2015
1 parent 529f016 commit 4c395ef
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
15 changes: 13 additions & 2 deletions sys/net/network_layer/ng_ipv6/netif/ng_ipv6_netif.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "net/ng_netapi.h"
#include "net/ng_netif.h"
#include "net/ng_netif/hdr.h"
#include "net/ng_sixlowpan/netif.h"

#include "net/ng_ipv6/netif.h"

Expand Down Expand Up @@ -474,14 +475,24 @@ void ng_ipv6_netif_init_by_dev(void)
sizeof(if_type)) != -ENOTSUP) &&
(if_type == NG_NETTYPE_SIXLOWPAN)) {
uint16_t src_len = 8;
DEBUG("Set 6LoWPAN flag\n");
uint16_t max_frag_size = UINT16_MAX;

DEBUG("ipv6 netif: Set 6LoWPAN flag\n");
ipv6_ifs[i].flags |= NG_IPV6_NETIF_FLAGS_SIXLOWPAN;
/* use EUI-64 (8-byte address) for IID generation and for sending
* packets */
ng_netapi_set(ifs[i], NG_NETOPT_SRC_LEN, 0, &src_len,
sizeof(src_len)); /* don't care for result */
}

if (ng_netapi_get(ifs[i], NG_NETOPT_MAX_PACKET_SIZE,
0, &max_frag_size, sizeof(max_frag_size)) < 0) {
/* if error we assume it works */
DEBUG("ipv6 netif: Can not get max packet size from interface %"
PRIkernel_pid "\n", ifs[i]);
}

ng_sixlowpan_netif_add(ifs[i], max_frag_size);
}
#endif

if ((ng_netapi_get(ifs[i], NG_NETOPT_IPV6_IID, 0, &iid,
Expand Down
27 changes: 8 additions & 19 deletions sys/net/network_layer/ng_sixlowpan/ng_sixlowpan.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ static void _send(ng_pktsnip_t *pkt)
/* cppcheck: datagram_size will be read by frag */
/* cppcheck-suppress unreadVariable */
size_t payload_len, datagram_size;
uint16_t max_frag_size;
/* cppcheck: disp is needed in other build paths on this level already */
/* cppcheck-suppress variableScope */
uint8_t *disp;
Expand Down Expand Up @@ -207,19 +206,9 @@ static void _send(ng_pktsnip_t *pkt)
iface = ng_sixlowpan_netif_get(hdr->if_pid);

if (iface == NULL) {
if (ng_netapi_get(hdr->if_pid, NG_NETOPT_MAX_PACKET_SIZE,
0, &max_frag_size, sizeof(max_frag_size)) < 0) {
/* if error we assume it works */
DEBUG("6lo: can not get max packet size from interface %"
PRIkernel_pid "\n", hdr->if_pid);
max_frag_size = UINT16_MAX;
}

ng_sixlowpan_netif_add(hdr->if_pid, max_frag_size);
iface = ng_sixlowpan_netif_get(hdr->if_pid);
}
else {
max_frag_size = iface->max_frag_size;
DEBUG("6lo: Can not get 6LoWPAN specific interface information.\n");
ng_pktbuf_release(pkt);
return;
}

/* payload length and datagram size are different in that the payload
Expand Down Expand Up @@ -253,12 +242,12 @@ static void _send(ng_pktsnip_t *pkt)
}
#endif

DEBUG("6lo: max_frag_size = %" PRIu16 " for interface %"
PRIkernel_pid "\n", max_frag_size, hdr->if_pid);
DEBUG("6lo: iface->max_frag_size = %" PRIu16 " for interface %"
PRIkernel_pid "\n", iface->max_frag_size, hdr->if_pid);

/* IP should not send anything here if it is not a 6LoWPAN interface,
* so we don't need to check for NULL pointers */
if (payload_len <= max_frag_size) {
if (payload_len <= iface->max_frag_size) {
DEBUG("6lo: Send SND command for %p to %" PRIu16 "\n",
(void *)pkt, hdr->if_pid);
ng_netapi_send(hdr->if_pid, pkt);
Expand All @@ -268,13 +257,13 @@ static void _send(ng_pktsnip_t *pkt)
#ifdef MODULE_NG_SIXLOWPAN_FRAG
else {
DEBUG("6lo: Send fragmented (%u > %" PRIu16 ")\n",
(unsigned int)payload_len, max_frag_size);
(unsigned int)payload_len, iface->max_frag_size);
ng_sixlowpan_frag_send(hdr->if_pid, pkt, payload_len, datagram_size);
}
#else
(void)datagram_size;
DEBUG("6lo: packet too big (%u> %" PRIu16 ")\n",
(unsigned int)payload_len, max_frag_size);
(unsigned int)payload_len, iface->max_frag_size);
#endif
}

Expand Down

0 comments on commit 4c395ef

Please sign in to comment.