mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-23 01:29:33 +00:00
Added some defensive programming
This commit is contained in:
parent
2b245cf850
commit
81e098d2da
@ -46,23 +46,25 @@ extern u16_t uip_slen;
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
uip_udp_packet_send(struct uip_udp_conn *c, const void *data, int len)
|
||||
{
|
||||
#if UIP_UDP
|
||||
if(data != NULL) {
|
||||
uip_udp_conn = c;
|
||||
uip_slen = len;
|
||||
memcpy(&uip_buf[UIP_LLH_LEN + UIP_IPUDPH_LEN], data, len > UIP_BUFSIZE? UIP_BUFSIZE: len);
|
||||
memcpy(&uip_buf[UIP_LLH_LEN + UIP_IPUDPH_LEN], data,
|
||||
len > UIP_BUFSIZE? UIP_BUFSIZE: len);
|
||||
uip_process(UIP_UDP_SEND_CONN);
|
||||
#if UIP_CONF_IPV6 //math
|
||||
#if UIP_CONF_IPV6
|
||||
tcpip_ipv6_output();
|
||||
#else
|
||||
if(uip_len > 0) {
|
||||
tcpip_output();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
uip_slen = 0;
|
||||
#endif /* UIP_UDP */
|
||||
}
|
||||
@ -74,6 +76,7 @@ uip_udp_packet_sendto(struct uip_udp_conn *c, const void *data, int len,
|
||||
uip_ipaddr_t curaddr;
|
||||
uint16_t curport;
|
||||
|
||||
if(toaddr != NULL) {
|
||||
/* Save current IP addr/port. */
|
||||
uip_ipaddr_copy(&curaddr, &c->ripaddr);
|
||||
curport = c->rport;
|
||||
@ -88,4 +91,5 @@ uip_udp_packet_sendto(struct uip_udp_conn *c, const void *data, int len,
|
||||
uip_ipaddr_copy(&c->ripaddr, &curaddr);
|
||||
c->rport = curport;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
Loading…
Reference in New Issue
Block a user