1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

gnrc ipv6: use ipv6_addr_t ptr for hdr_build

This commit is contained in:
Oleg Hahm 2016-03-21 16:24:40 +01:00
parent fc919ea28e
commit 991c71cf27
13 changed files with 18 additions and 20 deletions

View File

@ -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);

View File

@ -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
}

View File

@ -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);

View File

@ -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");

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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) {

View File

@ -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;

View File

@ -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;

View File

@ -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");

View File

@ -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");

View File

@ -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));