From 8cfab9d014075a649b8f559d3f5f20ee94b1decf Mon Sep 17 00:00:00 2001 From: Christian Mehlis Date: Tue, 14 Jan 2014 07:29:28 +0100 Subject: [PATCH] ipv6_sendto: return the success --- sys/net/include/sixlowpan/ip.h | 8 +++++++- sys/net/network_layer/sixlowpan/ip.c | 6 ++++-- sys/net/transport_layer/destiny/socket.c | 9 +++------ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/sys/net/include/sixlowpan/ip.h b/sys/net/include/sixlowpan/ip.h index 56ac1c180f..6f231a0c93 100644 --- a/sys/net/include/sixlowpan/ip.h +++ b/sys/net/include/sixlowpan/ip.h @@ -84,8 +84,14 @@ ipv6_hdr_t *ipv6_get_buf(void); * @param[in] next_header Next header ID of payload. * @param[in] payload Payload of the packet. * @param[in] payload_length Length of payload. + * + * @return payload_length : on success + * -1 : if no route to the given dest could be obtained + * Packet is dropped + * In case of reactive routing: routing + * is going to try to find a route */ -void ipv6_sendto(const ipv6_addr_t *dest, uint8_t next_header, +int ipv6_sendto(const ipv6_addr_t *dest, uint8_t next_header, const uint8_t *payload, uint16_t payload_length); /** diff --git a/sys/net/network_layer/sixlowpan/ip.c b/sys/net/network_layer/sixlowpan/ip.c index d2f595d774..fb89018551 100644 --- a/sys/net/network_layer/sixlowpan/ip.c +++ b/sys/net/network_layer/sixlowpan/ip.c @@ -99,7 +99,7 @@ uint8_t *get_payload_buf(uint8_t ext_len) return &(buffer[LLHDR_IPV6HDR_LEN + ext_len]); } -void ipv6_sendto(const ipv6_addr_t *dest, uint8_t next_header, +int ipv6_sendto(const ipv6_addr_t *dest, uint8_t next_header, const uint8_t *payload, uint16_t payload_length) { uint8_t *p_ptr; @@ -137,11 +137,13 @@ void ipv6_sendto(const ipv6_addr_t *dest, uint8_t next_header, } if (dest == NULL) { - return; + return -1; } sixlowpan_lowpan_sendto((ieee_802154_long_t *) &dest->uint16[4], (uint8_t *)ipv6_buf, packet_length); + + return payload_length; } /* Register an upper layer thread */ diff --git a/sys/net/transport_layer/destiny/socket.c b/sys/net/transport_layer/destiny/socket.c index 0a0594f2e8..ceb63d4314 100644 --- a/sys/net/transport_layer/destiny/socket.c +++ b/sys/net/transport_layer/destiny/socket.c @@ -494,16 +494,14 @@ int send_tcp(socket_internal_t *current_socket, tcp_hdr_t *current_tcp_packet, return -1; } - ipv6_sendto(¤t_tcp_socket->foreign_address.sin6_addr, + return ipv6_sendto(¤t_tcp_socket->foreign_address.sin6_addr, IPPROTO_TCP, (uint8_t *)(current_tcp_packet), compressed_size); - return 1; #else switch_tcp_packet_byte_order(current_tcp_packet); - ipv6_sendto(¤t_tcp_socket->foreign_address.sin6_addr, + return ipv6_sendto(¤t_tcp_socket->foreign_address.sin6_addr, IPPROTO_TCP, (uint8_t *)(current_tcp_packet), header_length * 4 + payload_length); - return 1; #endif } @@ -1030,10 +1028,9 @@ int32_t destiny_socket_sendto(int s, const void *buf, uint32_t len, int flags, UDP_HDR_LEN + len, IPPROTO_UDP); - ipv6_sendto(&to->sin6_addr, IPPROTO_UDP, + return ipv6_sendto(&to->sin6_addr, IPPROTO_UDP, (uint8_t *)(current_udp_packet), NTOHS(current_udp_packet->length)); - return NTOHS(current_udp_packet->length); } else { return -1;