Browse Source

gnrc ipv6: use ipv6_addr_t ptr for hdr_build

pr/gpio
Oleg Hahm 7 years ago
parent
commit
991c71cf27
  1. 2
      examples/gnrc_networking/udp.c
  2. 4
      sys/include/net/gnrc/ipv6/hdr.h
  3. 2
      sys/net/gnrc/application_layer/tftp/gnrc_tftp.c
  4. 2
      sys/net/gnrc/application_layer/zep/gnrc_zep.c
  5. 2
      sys/net/gnrc/conn/ip/gnrc_conn_ip.c
  6. 2
      sys/net/gnrc/conn/udp/gnrc_conn_udp.c
  7. 2
      sys/net/gnrc/netreg/gnrc_netreg.c
  8. 5
      sys/net/gnrc/network_layer/icmpv6/echo/gnrc_icmpv6_echo.c
  9. 4
      sys/net/gnrc/network_layer/ipv6/hdr/gnrc_ipv6_hdr.c
  10. 3
      sys/net/gnrc/network_layer/ndp/internal/gnrc_ndp_internal.c
  11. 2
      sys/net/gnrc/routing/rpl/gnrc_rpl_control_messages.c
  12. 2
      sys/shell/commands/sc_icmpv6_echo.c
  13. 6
      tests/unittests/tests-gnrc_ipv6_hdr/tests-gnrc_ipv6_hdr.c

2
examples/gnrc_networking/udp.c

@ -65,7 +65,7 @@ static void send(char *addr_str, char *port_str, char *data, unsigned int num,
return;
}
/* allocate IPv6 header */
ip = gnrc_ipv6_hdr_build(udp, NULL, (uint8_t *)&addr);
ip = gnrc_ipv6_hdr_build(udp, NULL, &addr);
if (ip == NULL) {
puts("Error: unable to allocate IPv6 header");
gnrc_pktbuf_release(udp);

4
sys/include/net/gnrc/ipv6/hdr.h

@ -43,8 +43,8 @@ extern "C" {
* @return The an IPv6 header in packet buffer on success.
* @return NULL on error.
*/
gnrc_pktsnip_t *gnrc_ipv6_hdr_build(gnrc_pktsnip_t *payload, uint8_t *src,
uint8_t *dst);
gnrc_pktsnip_t *gnrc_ipv6_hdr_build(gnrc_pktsnip_t *payload, ipv6_addr_t *src,
ipv6_addr_t *dst);
#ifdef __cplusplus
}

2
sys/net/gnrc/application_layer/tftp/gnrc_tftp.c

@ -971,7 +971,7 @@ tftp_state _tftp_send(gnrc_pktsnip_t *buf, tftp_context_t *ctxt, size_t len)
}
/* allocate IPv6 header */
ip = gnrc_ipv6_hdr_build(udp, NULL, ctxt->peer.u8);
ip = gnrc_ipv6_hdr_build(udp, NULL, &(ctxt->peer));
if (ip == NULL) {
DEBUG("tftp: error unable to allocate IPv6 header");
gnrc_pktbuf_release(udp);

2
sys/net/gnrc/application_layer/zep/gnrc_zep.c

@ -241,7 +241,7 @@ static int _send(gnrc_netdev_t *netdev, gnrc_pktsnip_t *pkt)
new_pkt = hdr;
hdr = gnrc_ipv6_hdr_build(new_pkt, NULL, (uint8_t *) &(dev->dst));
hdr = gnrc_ipv6_hdr_build(new_pkt, NULL, &(dev->dst));
if (hdr == NULL) {
DEBUG("zep: could not allocate IPv6 header in pktbuf\n");

2
sys/net/gnrc/conn/ip/gnrc_conn_ip.c

@ -99,7 +99,7 @@ int conn_ip_sendto(const void *data, size_t len, const void *src, size_t src_len
return -EINVAL;
}
/* addr will only be copied */
hdr = gnrc_ipv6_hdr_build(pkt, (uint8_t *)src, (uint8_t *)dst);
hdr = gnrc_ipv6_hdr_build(pkt, src, dst);
if (hdr == NULL) {
gnrc_pktbuf_release(pkt);
return -ENOMEM;

2
sys/net/gnrc/conn/udp/gnrc_conn_udp.c

@ -111,7 +111,7 @@ int conn_udp_sendto(const void *data, size_t len, const void *src, size_t src_le
return -EINVAL;
}
/* addr will only be copied */
hdr = gnrc_ipv6_hdr_build(pkt, (uint8_t *)src, (uint8_t *)dst);
hdr = gnrc_ipv6_hdr_build(pkt, src, dst);
if (hdr == NULL) {
gnrc_pktbuf_release(pkt);
return -ENOMEM;

2
sys/net/gnrc/netreg/gnrc_netreg.c

@ -146,7 +146,7 @@ gnrc_pktsnip_t *gnrc_netreg_hdr_build(gnrc_nettype_t type, gnrc_pktsnip_t *paylo
case GNRC_NETTYPE_IPV6:
assert(src_len == sizeof(ipv6_addr_t));
assert(dst_len == sizeof(ipv6_addr_t));
return gnrc_ipv6_hdr_build(payload, src, dst);
return gnrc_ipv6_hdr_build(payload, (ipv6_addr_t*) src, (ipv6_addr_t*) dst);
#endif
#ifdef MODULE_GNRC_TCP

5
sys/net/gnrc/network_layer/icmpv6/echo/gnrc_icmpv6_echo.c

@ -84,11 +84,10 @@ void gnrc_icmpv6_echo_req_handle(kernel_pid_t iface, ipv6_hdr_t *ipv6_hdr,
}
if (ipv6_addr_is_multicast(&ipv6_hdr->dst)) {
hdr = gnrc_ipv6_hdr_build(pkt, NULL, (uint8_t *)&ipv6_hdr->src);
hdr = gnrc_ipv6_hdr_build(pkt, NULL, &ipv6_hdr->src);
}
else {
hdr = gnrc_ipv6_hdr_build(pkt, (uint8_t *)&ipv6_hdr->dst,
(uint8_t *)&ipv6_hdr->src);
hdr = gnrc_ipv6_hdr_build(pkt, &ipv6_hdr->dst, &ipv6_hdr->src);
}
if (hdr == NULL) {

4
sys/net/gnrc/network_layer/ipv6/hdr/gnrc_ipv6_hdr.c

@ -32,8 +32,8 @@ static char addr_str[IPV6_ADDR_MAX_STR_LEN];
#define HDR_NETTYPE (GNRC_NETTYPE_UNDEF)
#endif
gnrc_pktsnip_t *gnrc_ipv6_hdr_build(gnrc_pktsnip_t *payload, uint8_t *src,
uint8_t *dst)
gnrc_pktsnip_t *gnrc_ipv6_hdr_build(gnrc_pktsnip_t *payload, ipv6_addr_t *src,
ipv6_addr_t *dst)
{
gnrc_pktsnip_t *ipv6;
ipv6_hdr_t *hdr;

3
sys/net/gnrc/network_layer/ndp/internal/gnrc_ndp_internal.c

@ -837,8 +837,7 @@ static gnrc_pktsnip_t *_build_headers(kernel_pid_t iface, gnrc_pktsnip_t *payloa
ipv6_addr_t *dst, ipv6_addr_t *src)
{
gnrc_pktsnip_t *l2hdr;
gnrc_pktsnip_t *iphdr = gnrc_ipv6_hdr_build(payload, (uint8_t *)src,
(uint8_t *)dst);
gnrc_pktsnip_t *iphdr = gnrc_ipv6_hdr_build(payload, src, dst);
if (iphdr == NULL) {
DEBUG("ndp internal: error allocating IPv6 header.\n");
return NULL;

2
sys/net/gnrc/routing/rpl/gnrc_rpl_control_messages.c

@ -77,7 +77,7 @@ void gnrc_rpl_send(gnrc_pktsnip_t *pkt, kernel_pid_t iface, ipv6_addr_t *src, ip
dst = (ipv6_addr_t *) &ipv6_addr_all_rpl_nodes;
}
hdr = gnrc_ipv6_hdr_build(pkt, (uint8_t *)src, (uint8_t *)dst);
hdr = gnrc_ipv6_hdr_build(pkt, src, dst);
if (hdr == NULL) {
DEBUG("RPL: Send - no space left in packet buffer\n");

2
sys/shell/commands/sc_icmpv6_echo.c

@ -254,7 +254,7 @@ int _icmpv6_ping(int argc, char **argv)
_set_payload(pkt->data, payload_len);
pkt = gnrc_ipv6_hdr_build(pkt, NULL, addr.u8);
pkt = gnrc_ipv6_hdr_build(pkt, NULL, &addr);
if (pkt == NULL) {
puts("error: packet buffer full");

6
tests/unittests/tests-gnrc_ipv6_hdr/tests-gnrc_ipv6_hdr.c

@ -42,7 +42,7 @@ static void test_gnrc_ipv6_hdr_build__src_NULL(void)
ipv6_hdr_t *hdr;
gnrc_pktbuf_init();
TEST_ASSERT_NOT_NULL(pkt = gnrc_ipv6_hdr_build(NULL, NULL, (uint8_t *)&dst));
TEST_ASSERT_NOT_NULL(pkt = gnrc_ipv6_hdr_build(NULL, NULL, &dst));
hdr = pkt->data;
TEST_ASSERT_NOT_NULL(hdr);
TEST_ASSERT(ipv6_hdr_is(hdr));
@ -61,7 +61,7 @@ static void test_gnrc_ipv6_hdr_build__dst_NULL(void)
ipv6_hdr_t *hdr;
gnrc_pktbuf_init();
TEST_ASSERT_NOT_NULL(pkt = gnrc_ipv6_hdr_build(NULL, (uint8_t *)&src, NULL));
TEST_ASSERT_NOT_NULL(pkt = gnrc_ipv6_hdr_build(NULL, &src, NULL));
hdr = pkt->data;
TEST_ASSERT_NOT_NULL(hdr);
TEST_ASSERT(ipv6_hdr_is(hdr));
@ -81,7 +81,7 @@ static void test_gnrc_ipv6_hdr_build__complete(void)
ipv6_hdr_t *hdr;
gnrc_pktbuf_init();
TEST_ASSERT_NOT_NULL(pkt = gnrc_ipv6_hdr_build(NULL, (uint8_t *)&src, (uint8_t *)&dst));
TEST_ASSERT_NOT_NULL(pkt = gnrc_ipv6_hdr_build(NULL, &src, &dst));
hdr = pkt->data;
TEST_ASSERT_NOT_NULL(hdr);
TEST_ASSERT(ipv6_hdr_is(hdr));

Loading…
Cancel
Save