Skip to content

Commit

Permalink
ipv6_sendto: return the success
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Mehlis committed Jan 14, 2014
1 parent b157304 commit 8cfab9d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
8 changes: 7 additions & 1 deletion sys/net/include/sixlowpan/ip.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/**
Expand Down
6 changes: 4 additions & 2 deletions sys/net/network_layer/sixlowpan/ip.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down
9 changes: 3 additions & 6 deletions sys/net/transport_layer/destiny/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,16 +494,14 @@ int send_tcp(socket_internal_t *current_socket, tcp_hdr_t *current_tcp_packet,
return -1;
}

ipv6_sendto(&current_tcp_socket->foreign_address.sin6_addr,
return ipv6_sendto(&current_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(&current_tcp_socket->foreign_address.sin6_addr,
return ipv6_sendto(&current_tcp_socket->foreign_address.sin6_addr,
IPPROTO_TCP, (uint8_t *)(current_tcp_packet),
header_length * 4 + payload_length);
return 1;
#endif
}

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 8cfab9d

Please sign in to comment.