ipv6_sendto: return the success
This commit is contained in:
parent
b157304481
commit
8cfab9d014
@ -84,8 +84,14 @@ ipv6_hdr_t *ipv6_get_buf(void);
|
|||||||
* @param[in] next_header Next header ID of payload.
|
* @param[in] next_header Next header ID of payload.
|
||||||
* @param[in] payload Payload of the packet.
|
* @param[in] payload Payload of the packet.
|
||||||
* @param[in] payload_length Length of payload.
|
* @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);
|
const uint8_t *payload, uint16_t payload_length);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -99,7 +99,7 @@ uint8_t *get_payload_buf(uint8_t ext_len)
|
|||||||
return &(buffer[LLHDR_IPV6HDR_LEN + 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)
|
const uint8_t *payload, uint16_t payload_length)
|
||||||
{
|
{
|
||||||
uint8_t *p_ptr;
|
uint8_t *p_ptr;
|
||||||
@ -137,11 +137,13 @@ void ipv6_sendto(const ipv6_addr_t *dest, uint8_t next_header,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dest == NULL) {
|
if (dest == NULL) {
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sixlowpan_lowpan_sendto((ieee_802154_long_t *) &dest->uint16[4],
|
sixlowpan_lowpan_sendto((ieee_802154_long_t *) &dest->uint16[4],
|
||||||
(uint8_t *)ipv6_buf, packet_length);
|
(uint8_t *)ipv6_buf, packet_length);
|
||||||
|
|
||||||
|
return payload_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Register an upper layer thread */
|
/* Register an upper layer thread */
|
||||||
|
|||||||
@ -494,16 +494,14 @@ int send_tcp(socket_internal_t *current_socket, tcp_hdr_t *current_tcp_packet,
|
|||||||
return -1;
|
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),
|
IPPROTO_TCP, (uint8_t *)(current_tcp_packet),
|
||||||
compressed_size);
|
compressed_size);
|
||||||
return 1;
|
|
||||||
#else
|
#else
|
||||||
switch_tcp_packet_byte_order(current_tcp_packet);
|
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),
|
IPPROTO_TCP, (uint8_t *)(current_tcp_packet),
|
||||||
header_length * 4 + payload_length);
|
header_length * 4 + payload_length);
|
||||||
return 1;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1030,10 +1028,9 @@ int32_t destiny_socket_sendto(int s, const void *buf, uint32_t len, int flags,
|
|||||||
UDP_HDR_LEN + len,
|
UDP_HDR_LEN + len,
|
||||||
IPPROTO_UDP);
|
IPPROTO_UDP);
|
||||||
|
|
||||||
ipv6_sendto(&to->sin6_addr, IPPROTO_UDP,
|
return ipv6_sendto(&to->sin6_addr, IPPROTO_UDP,
|
||||||
(uint8_t *)(current_udp_packet),
|
(uint8_t *)(current_udp_packet),
|
||||||
NTOHS(current_udp_packet->length));
|
NTOHS(current_udp_packet->length));
|
||||||
return NTOHS(current_udp_packet->length);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user