updated picoTCP to 1.4.0, lowered build optimization levels to -O2, improved selftest
This commit is contained in:
@@ -27,7 +27,24 @@ struct pico_socket *pico_socket_udp_open(void)
|
||||
}
|
||||
|
||||
|
||||
#if defined (PICO_SUPPORT_IPV4) || defined (PICO_SUPPORT_IPV6)
|
||||
static int pico_enqueue_and_wakeup_if_needed(struct pico_queue *q_in, struct pico_socket* s, struct pico_frame* cpy)
|
||||
{
|
||||
if (pico_enqueue(q_in, cpy) > 0) {
|
||||
if (s->wakeup){
|
||||
s->wakeup(PICO_SOCK_EV_RD, s);
|
||||
}
|
||||
}
|
||||
else {
|
||||
pico_frame_discard(cpy);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PICO_SUPPORT_IPV4
|
||||
#ifdef PICO_SUPPORT_MCAST
|
||||
static inline int pico_socket_udp_deliver_ipv4_mcast_initial_checks(struct pico_socket *s, struct pico_frame *f)
|
||||
{
|
||||
struct pico_ip4 p_dst;
|
||||
@@ -65,17 +82,12 @@ static int pico_socket_udp_deliver_ipv4_mcast(struct pico_socket *s, struct pico
|
||||
if (!cpy)
|
||||
return -1;
|
||||
|
||||
if (pico_enqueue(&s->q_in, cpy) > 0) {
|
||||
if (s->wakeup)
|
||||
s->wakeup(PICO_SOCK_EV_RD, s);
|
||||
}
|
||||
else
|
||||
pico_frame_discard(cpy);
|
||||
pico_enqueue_and_wakeup_if_needed(&s->q_in, s, cpy);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
static int pico_socket_udp_deliver_ipv4_unicast(struct pico_socket *s, struct pico_frame *f)
|
||||
{
|
||||
struct pico_frame *cpy;
|
||||
@@ -84,12 +96,7 @@ static int pico_socket_udp_deliver_ipv4_unicast(struct pico_socket *s, struct pi
|
||||
if (!cpy)
|
||||
return -1;
|
||||
|
||||
if (pico_enqueue(&s->q_in, cpy) > 0) {
|
||||
if (s->wakeup)
|
||||
s->wakeup(PICO_SOCK_EV_RD, s);
|
||||
} else {
|
||||
pico_frame_discard(cpy);
|
||||
}
|
||||
pico_enqueue_and_wakeup_if_needed(&s->q_in, s, cpy);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -104,7 +111,9 @@ static int pico_socket_udp_deliver_ipv4(struct pico_socket *s, struct pico_frame
|
||||
s_local.addr = s->local_addr.ip4.addr;
|
||||
p_dst.addr = ip4hdr->dst.addr;
|
||||
if ((pico_ipv4_is_broadcast(p_dst.addr)) || pico_ipv4_is_multicast(p_dst.addr)) {
|
||||
#ifdef PICO_SUPPORT_MCAST
|
||||
ret = pico_socket_udp_deliver_ipv4_mcast(s, f);
|
||||
#endif
|
||||
} else if ((s_local.addr == PICO_IPV4_INADDR_ANY) || (s_local.addr == p_dst.addr)) {
|
||||
ret = pico_socket_udp_deliver_ipv4_unicast(s, f);
|
||||
}
|
||||
@@ -115,6 +124,7 @@ static int pico_socket_udp_deliver_ipv4(struct pico_socket *s, struct pico_frame
|
||||
#endif
|
||||
|
||||
#ifdef PICO_SUPPORT_IPV6
|
||||
#ifdef PICO_SUPPORT_MCAST
|
||||
static inline int pico_socket_udp_deliver_ipv6_mcast(struct pico_socket *s, struct pico_frame *f)
|
||||
{
|
||||
struct pico_ipv6_hdr *ip6hdr;
|
||||
@@ -137,17 +147,12 @@ static inline int pico_socket_udp_deliver_ipv6_mcast(struct pico_socket *s, stru
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pico_enqueue(&s->q_in, cpy) > 0) {
|
||||
if (s->wakeup)
|
||||
s->wakeup(PICO_SOCK_EV_RD, s);
|
||||
}
|
||||
else
|
||||
pico_frame_discard(cpy);
|
||||
pico_enqueue_and_wakeup_if_needed(&s->q_in, s, cpy);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
static int pico_socket_udp_deliver_ipv6(struct pico_socket *s, struct pico_frame *f)
|
||||
{
|
||||
struct pico_ip6 s_local, p_dst;
|
||||
@@ -157,10 +162,12 @@ static int pico_socket_udp_deliver_ipv6(struct pico_socket *s, struct pico_frame
|
||||
s_local = s->local_addr.ip6;
|
||||
p_dst = ip6hdr->dst;
|
||||
if ((pico_ipv6_is_multicast(p_dst.addr))) {
|
||||
#ifdef PICO_SUPPORT_MCAST
|
||||
int retval = pico_socket_udp_deliver_ipv6_mcast(s, f);
|
||||
pico_frame_discard(f);
|
||||
return retval;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (pico_ipv6_is_unspecified(s->local_addr.ip6.addr) || (pico_ipv6_compare(&s_local, &p_dst) == 0))
|
||||
{ /* Either local socket is ANY, or matches dst */
|
||||
cpy = pico_frame_copy(f);
|
||||
@@ -170,10 +177,7 @@ static int pico_socket_udp_deliver_ipv6(struct pico_socket *s, struct pico_frame
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pico_enqueue(&s->q_in, cpy) > 0) {
|
||||
if (s->wakeup)
|
||||
s->wakeup(PICO_SOCK_EV_RD, s);
|
||||
}
|
||||
pico_enqueue_and_wakeup_if_needed(&s->q_in, s, cpy);
|
||||
}
|
||||
|
||||
pico_frame_discard(f);
|
||||
|
||||
Reference in New Issue
Block a user