mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-04-17 02:42:29 +00:00
minor: coding style
This commit is contained in:
parent
22df34fc70
commit
2b971400fa
@ -883,7 +883,8 @@ netconn_gethostbyname(const char *name, ip_addr_t *addr)
|
||||
#endif /* LWIP_DNS*/
|
||||
|
||||
#if LWIP_NETCONN_SEM_PER_THREAD
|
||||
void netconn_thread_init(void)
|
||||
void
|
||||
netconn_thread_init(void)
|
||||
{
|
||||
sys_sem_t *sem = LWIP_NETCONN_THREAD_SEM_GET();
|
||||
if ((sem == NULL) || !sys_sem_valid(sem)) {
|
||||
@ -893,7 +894,8 @@ void netconn_thread_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
void netconn_thread_cleanup(void)
|
||||
void
|
||||
netconn_thread_cleanup(void)
|
||||
{
|
||||
sys_sem_t *sem = LWIP_NETCONN_THREAD_SEM_GET();
|
||||
if ((sem != NULL) && sys_sem_valid(sem)) {
|
||||
|
@ -58,7 +58,7 @@
|
||||
/* netconns are polled once per second (e.g. continue write on memory error) */
|
||||
#define NETCONN_TCP_POLL_INTERVAL 2
|
||||
|
||||
#define SET_NONBLOCKING_CONNECT(conn, val) do { if(val) { \
|
||||
#define SET_NONBLOCKING_CONNECT(conn, val) do { if (val) { \
|
||||
(conn)->flags |= NETCONN_FLAG_IN_NONBLOCKING_CONNECT; \
|
||||
} else { \
|
||||
(conn)->flags &= ~ NETCONN_FLAG_IN_NONBLOCKING_CONNECT; }} while(0)
|
||||
@ -106,7 +106,7 @@ recv_raw(void *arg, struct raw_pcb *pcb, struct pbuf *p,
|
||||
#endif /* LWIP_SO_RCVBUF */
|
||||
/* copy the whole packet into new pbufs */
|
||||
q = pbuf_alloc(PBUF_RAW, p->tot_len, PBUF_RAM);
|
||||
if(q != NULL) {
|
||||
if (q != NULL) {
|
||||
if (pbuf_copy(q, p) != ERR_OK) {
|
||||
pbuf_free(q);
|
||||
q = NULL;
|
||||
@ -519,7 +519,7 @@ pcb_new(struct api_msg_msg *msg)
|
||||
#if LWIP_RAW
|
||||
case NETCONN_RAW:
|
||||
msg->conn->pcb.raw = raw_new(msg->msg.n.proto);
|
||||
if(msg->conn->pcb.raw != NULL) {
|
||||
if (msg->conn->pcb.raw != NULL) {
|
||||
raw_recv(msg->conn->pcb.raw, recv_raw, msg->conn);
|
||||
}
|
||||
break;
|
||||
@ -527,7 +527,7 @@ pcb_new(struct api_msg_msg *msg)
|
||||
#if LWIP_UDP
|
||||
case NETCONN_UDP:
|
||||
msg->conn->pcb.udp = udp_new();
|
||||
if(msg->conn->pcb.udp != NULL) {
|
||||
if (msg->conn->pcb.udp != NULL) {
|
||||
#if LWIP_UDPLITE
|
||||
if (NETCONNTYPE_ISUDPLITE(msg->conn->type)) {
|
||||
udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_UDPLITE);
|
||||
@ -543,7 +543,7 @@ pcb_new(struct api_msg_msg *msg)
|
||||
#if LWIP_TCP
|
||||
case NETCONN_TCP:
|
||||
msg->conn->pcb.tcp = tcp_new();
|
||||
if(msg->conn->pcb.tcp != NULL) {
|
||||
if (msg->conn->pcb.tcp != NULL) {
|
||||
setup_tcp(msg->conn);
|
||||
}
|
||||
break;
|
||||
@ -723,7 +723,7 @@ netconn_drain(struct netconn *conn)
|
||||
while (sys_mbox_tryfetch(&conn->recvmbox, &mem) != SYS_MBOX_EMPTY) {
|
||||
#if LWIP_TCP
|
||||
if (NETCONNTYPE_GROUP(conn->type) == NETCONN_TCP) {
|
||||
if(mem != NULL) {
|
||||
if (mem != NULL) {
|
||||
p = (struct pbuf*)mem;
|
||||
/* pcb might be set to NULL already by err_tcp() */
|
||||
if (conn->pcb.tcp != NULL) {
|
||||
@ -876,7 +876,7 @@ lwip_netconn_do_close_internal(struct netconn *conn WRITE_DELAYED_PARAM)
|
||||
}
|
||||
#endif /* LWIP_SO_LINGER */
|
||||
} else {
|
||||
if(err == ERR_MEM) {
|
||||
if (err == ERR_MEM) {
|
||||
/* Closing failed because of memory shortage */
|
||||
if (netconn_is_nonblocking(conn)) {
|
||||
/* Nonblocking close failed */
|
||||
|
@ -313,7 +313,7 @@ lwip_getaddrinfo(const char *nodename, const char *servname,
|
||||
/* service location specified, try to resolve */
|
||||
if ((hints != NULL) && (hints->ai_flags & AI_NUMERICHOST)) {
|
||||
/* no DNS lookup, just parse for an address string */
|
||||
if(!ipaddr_aton(nodename, &addr)) {
|
||||
if (!ipaddr_aton(nodename, &addr)) {
|
||||
return EAI_NONAME;
|
||||
}
|
||||
#if LWIP_IPV4 && LWIP_IPV6
|
||||
@ -328,7 +328,7 @@ lwip_getaddrinfo(const char *nodename, const char *servname,
|
||||
u8_t type = NETCONN_DNS_IPV4_IPV6;
|
||||
if (ai_family == AF_INET) {
|
||||
type = NETCONN_DNS_IPV4;
|
||||
} else if(ai_family == AF_INET6) {
|
||||
} else if (ai_family == AF_INET6) {
|
||||
type = NETCONN_DNS_IPV6;
|
||||
}
|
||||
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
||||
|
@ -142,7 +142,7 @@ static void sockaddr_to_ipaddr_port(const struct sockaddr* sockaddr, ip_addr_t*
|
||||
#define IS_SOCK_ADDR_ALIGNED(name) ((((mem_ptr_t)(name)) % 4) == 0)
|
||||
|
||||
|
||||
#define LWIP_SOCKOPT_CHECK_OPTLEN(optlen, opttype) do { if((optlen) < sizeof(opttype)) { return EINVAL; }}while(0)
|
||||
#define LWIP_SOCKOPT_CHECK_OPTLEN(optlen, opttype) do { if ((optlen) < sizeof(opttype)) { return EINVAL; }}while(0)
|
||||
#define LWIP_SOCKOPT_CHECK_OPTLEN_CONN(sock, optlen, opttype) do { \
|
||||
LWIP_SOCKOPT_CHECK_OPTLEN(optlen, opttype); \
|
||||
if ((sock)->conn == NULL) { return EINVAL; } }while(0)
|
||||
@ -635,7 +635,7 @@ lwip_close(int s)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(sock->conn != NULL) {
|
||||
if (sock->conn != NULL) {
|
||||
is_tcp = NETCONNTYPE_GROUP(netconn_type(sock->conn)) == NETCONN_TCP;
|
||||
} else {
|
||||
LWIP_ASSERT("sock->lastdata == NULL", sock->lastdata == NULL);
|
||||
@ -1702,7 +1702,7 @@ lwip_shutdown(int s, int how)
|
||||
shut_rx = 1;
|
||||
} else if (how == SHUT_WR) {
|
||||
shut_tx = 1;
|
||||
} else if(how == SHUT_RDWR) {
|
||||
} else if (how == SHUT_RDWR) {
|
||||
shut_rx = 1;
|
||||
shut_tx = 1;
|
||||
} else {
|
||||
@ -2391,7 +2391,7 @@ lwip_setsockopt_impl(int s, int level, int optname, const void *optval, socklen_
|
||||
LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock, optlen, struct ip_mreq, NETCONN_UDP);
|
||||
inet_addr_to_ipaddr(&if_addr, &imr->imr_interface);
|
||||
inet_addr_to_ipaddr(&multi_addr, &imr->imr_multiaddr);
|
||||
if(optname == IP_ADD_MEMBERSHIP) {
|
||||
if (optname == IP_ADD_MEMBERSHIP) {
|
||||
if (!lwip_socket_register_membership(s, &if_addr, &multi_addr)) {
|
||||
/* cannot track membership (out of memory) */
|
||||
err = ENOMEM;
|
||||
|
@ -559,11 +559,11 @@ tcpip_init(tcpip_init_done_fn initfunc, void *arg)
|
||||
|
||||
tcpip_init_done = initfunc;
|
||||
tcpip_init_done_arg = arg;
|
||||
if(sys_mbox_new(&mbox, TCPIP_MBOX_SIZE) != ERR_OK) {
|
||||
if (sys_mbox_new(&mbox, TCPIP_MBOX_SIZE) != ERR_OK) {
|
||||
LWIP_ASSERT("failed to create tcpip_thread mbox", 0);
|
||||
}
|
||||
#if LWIP_TCPIP_CORE_LOCKING
|
||||
if(sys_mutex_new(&lock_tcpip_core) != ERR_OK) {
|
||||
if (sys_mutex_new(&lock_tcpip_core) != ERR_OK) {
|
||||
LWIP_ASSERT("failed to create lock_tcpip_core", 0);
|
||||
}
|
||||
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
||||
|
@ -86,7 +86,7 @@
|
||||
* LWIP_RAND() (this overrides DHCP_GLOBAL_XID)
|
||||
*/
|
||||
#ifndef DHCP_CREATE_RAND_XID
|
||||
#define DHCP_CREATE_RAND_XID 1
|
||||
#define DHCP_CREATE_RAND_XID 1
|
||||
#endif
|
||||
|
||||
/** Default for DHCP_GLOBAL_XID is 0xABCD0000
|
||||
@ -105,7 +105,7 @@
|
||||
/** Minimum length for reply before packet is parsed */
|
||||
#define DHCP_MIN_REPLY_LEN 44
|
||||
|
||||
#define REBOOT_TRIES 2
|
||||
#define REBOOT_TRIES 2
|
||||
|
||||
/** Option handling: options are parsed in dhcp_parse_reply
|
||||
* and saved in an array where other functions can load them from.
|
||||
@ -812,7 +812,7 @@ dhcp_network_changed(struct netif *netif)
|
||||
state changes, SELECTING: continue with current 'rid' as we stay in the
|
||||
same state */
|
||||
#if LWIP_DHCP_AUTOIP_COOP
|
||||
if(dhcp->autoip_coop_state == DHCP_AUTOIP_COOP_STATE_ON) {
|
||||
if (dhcp->autoip_coop_state == DHCP_AUTOIP_COOP_STATE_ON) {
|
||||
autoip_stop(netif);
|
||||
dhcp->autoip_coop_state = DHCP_AUTOIP_COOP_STATE_OFF;
|
||||
}
|
||||
@ -940,7 +940,7 @@ dhcp_discover(struct netif *netif)
|
||||
dhcp->tries++;
|
||||
}
|
||||
#if LWIP_DHCP_AUTOIP_COOP
|
||||
if(dhcp->tries >= LWIP_DHCP_AUTOIP_COOP_TRIES && dhcp->autoip_coop_state == DHCP_AUTOIP_COOP_STATE_OFF) {
|
||||
if (dhcp->tries >= LWIP_DHCP_AUTOIP_COOP_TRIES && dhcp->autoip_coop_state == DHCP_AUTOIP_COOP_STATE_OFF) {
|
||||
dhcp->autoip_coop_state = DHCP_AUTOIP_COOP_STATE_ON;
|
||||
autoip_start(netif);
|
||||
}
|
||||
@ -975,7 +975,7 @@ dhcp_bind(struct netif *netif)
|
||||
/* set renewal period timer */
|
||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_bind(): t0 renewal timer %"U32_F" secs\n", dhcp->offered_t0_lease));
|
||||
timeout = (dhcp->offered_t0_lease + DHCP_COARSE_TIMER_SECS / 2) / DHCP_COARSE_TIMER_SECS;
|
||||
if(timeout > 0xffff) {
|
||||
if (timeout > 0xffff) {
|
||||
timeout = 0xffff;
|
||||
}
|
||||
dhcp->t0_timeout = (u16_t)timeout;
|
||||
@ -990,7 +990,7 @@ dhcp_bind(struct netif *netif)
|
||||
/* set renewal period timer */
|
||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_bind(): t1 renewal timer %"U32_F" secs\n", dhcp->offered_t1_renew));
|
||||
timeout = (dhcp->offered_t1_renew + DHCP_COARSE_TIMER_SECS / 2) / DHCP_COARSE_TIMER_SECS;
|
||||
if(timeout > 0xffff) {
|
||||
if (timeout > 0xffff) {
|
||||
timeout = 0xffff;
|
||||
}
|
||||
dhcp->t1_timeout = (u16_t)timeout;
|
||||
@ -1004,7 +1004,7 @@ dhcp_bind(struct netif *netif)
|
||||
if (dhcp->offered_t2_rebind != 0xffffffffUL) {
|
||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_bind(): t2 rebind timer %"U32_F" secs\n", dhcp->offered_t2_rebind));
|
||||
timeout = (dhcp->offered_t2_rebind + DHCP_COARSE_TIMER_SECS / 2) / DHCP_COARSE_TIMER_SECS;
|
||||
if(timeout > 0xffff) {
|
||||
if (timeout > 0xffff) {
|
||||
timeout = 0xffff;
|
||||
}
|
||||
dhcp->t2_timeout = (u16_t)timeout;
|
||||
@ -1045,7 +1045,7 @@ dhcp_bind(struct netif *netif)
|
||||
}
|
||||
|
||||
#if LWIP_DHCP_AUTOIP_COOP
|
||||
if(dhcp->autoip_coop_state == DHCP_AUTOIP_COOP_STATE_ON) {
|
||||
if (dhcp->autoip_coop_state == DHCP_AUTOIP_COOP_STATE_ON) {
|
||||
autoip_stop(netif);
|
||||
dhcp->autoip_coop_state = DHCP_AUTOIP_COOP_STATE_OFF;
|
||||
}
|
||||
@ -1268,7 +1268,7 @@ dhcp_stop(struct netif *netif)
|
||||
/* netif is DHCP configured? */
|
||||
if (dhcp != NULL) {
|
||||
#if LWIP_DHCP_AUTOIP_COOP
|
||||
if(dhcp->autoip_coop_state == DHCP_AUTOIP_COOP_STATE_ON) {
|
||||
if (dhcp->autoip_coop_state == DHCP_AUTOIP_COOP_STATE_ON) {
|
||||
autoip_stop(netif);
|
||||
dhcp->autoip_coop_state = DHCP_AUTOIP_COOP_STATE_OFF;
|
||||
}
|
||||
|
@ -1120,7 +1120,7 @@ dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr,
|
||||
|
||||
/* check if "question" part matches the request */
|
||||
pbuf_copy_partial(p, &qry, SIZEOF_DNS_QUERY, res_idx);
|
||||
if((qry.cls != PP_HTONS(DNS_RRCLASS_IN)) ||
|
||||
if ((qry.cls != PP_HTONS(DNS_RRCLASS_IN)) ||
|
||||
(LWIP_DNS_ADDRTYPE_IS_IPV6(entry->reqaddrtype) && (qry.type != PP_HTONS(DNS_RRTYPE_AAAA))) ||
|
||||
(!LWIP_DNS_ADDRTYPE_IS_IPV6(entry->reqaddrtype) && (qry.type != PP_HTONS(DNS_RRTYPE_A)))) {
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: \"%s\": response not match to query\n", entry->name));
|
||||
@ -1138,7 +1138,7 @@ dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr,
|
||||
pbuf_copy_partial(p, &ans, SIZEOF_DNS_ANSWER, res_idx);
|
||||
if (ans.cls == PP_HTONS(DNS_RRCLASS_IN)) {
|
||||
#if LWIP_IPV4
|
||||
if((ans.type == PP_HTONS(DNS_RRTYPE_A)) && (ans.len == PP_HTONS(sizeof(ip4_addr_t)))) {
|
||||
if ((ans.type == PP_HTONS(DNS_RRTYPE_A)) && (ans.len == PP_HTONS(sizeof(ip4_addr_t)))) {
|
||||
#if LWIP_IPV4 && LWIP_IPV6
|
||||
if (!LWIP_DNS_ADDRTYPE_IS_IPV6(entry->reqaddrtype))
|
||||
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
||||
@ -1171,7 +1171,7 @@ dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr,
|
||||
}
|
||||
#endif /* LWIP_IPV4 */
|
||||
#if LWIP_IPV6
|
||||
if((ans.type == PP_HTONS(DNS_RRTYPE_AAAA)) && (ans.len == PP_HTONS(sizeof(ip6_addr_t)))) {
|
||||
if ((ans.type == PP_HTONS(DNS_RRTYPE_AAAA)) && (ans.len == PP_HTONS(sizeof(ip6_addr_t)))) {
|
||||
#if LWIP_IPV4 && LWIP_IPV6
|
||||
if (LWIP_DNS_ADDRTYPE_IS_IPV6(entry->reqaddrtype))
|
||||
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
||||
@ -1457,7 +1457,7 @@ dns_gethostbyname_addrtype(const char *hostname, ip_addr_t *addr, dns_found_call
|
||||
}
|
||||
}
|
||||
/* already have this address cached? */
|
||||
if(dns_lookup(hostname, addr LWIP_DNS_ADDRTYPE_ARG(dns_addrtype)) == ERR_OK) {
|
||||
if (dns_lookup(hostname, addr LWIP_DNS_ADDRTYPE_ARG(dns_addrtype)) == ERR_OK) {
|
||||
return ERR_OK;
|
||||
}
|
||||
#if LWIP_IPV4 && LWIP_IPV6
|
||||
@ -1469,7 +1469,7 @@ dns_gethostbyname_addrtype(const char *hostname, ip_addr_t *addr, dns_found_call
|
||||
} else {
|
||||
fallback = LWIP_DNS_ADDRTYPE_IPV4;
|
||||
}
|
||||
if(dns_lookup(hostname, addr LWIP_DNS_ADDRTYPE_ARG(fallback)) == ERR_OK) {
|
||||
if (dns_lookup(hostname, addr LWIP_DNS_ADDRTYPE_ARG(fallback)) == ERR_OK) {
|
||||
return ERR_OK;
|
||||
}
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
||||
/* We generate an answer by switching the dest and src ip addresses,
|
||||
* setting the icmp type to ECHO_RESPONSE and updating the checksum. */
|
||||
iecho = (struct icmp_echo_hdr *)p->payload;
|
||||
if(pbuf_header(p, hlen)) {
|
||||
if (pbuf_header(p, hlen)) {
|
||||
LWIP_ASSERT("Can't move over header in packet", 0);
|
||||
} else {
|
||||
err_t ret;
|
||||
@ -239,21 +239,21 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
||||
default:
|
||||
if (type == ICMP_DUR) {
|
||||
MIB2_STATS_INC(mib2.icmpindestunreachs);
|
||||
} else if(type == ICMP_TE) {
|
||||
} else if (type == ICMP_TE) {
|
||||
MIB2_STATS_INC(mib2.icmpindestunreachs);
|
||||
} else if(type == ICMP_PP) {
|
||||
} else if (type == ICMP_PP) {
|
||||
MIB2_STATS_INC(mib2.icmpinparmprobs);
|
||||
} else if(type == ICMP_SQ) {
|
||||
} else if (type == ICMP_SQ) {
|
||||
MIB2_STATS_INC(mib2.icmpinsrcquenchs);
|
||||
} else if(type == ICMP_RD) {
|
||||
} else if (type == ICMP_RD) {
|
||||
MIB2_STATS_INC(mib2.icmpinredirects);
|
||||
} else if(type == ICMP_TS) {
|
||||
} else if (type == ICMP_TS) {
|
||||
MIB2_STATS_INC(mib2.icmpintimestamps);
|
||||
} else if(type == ICMP_TSR) {
|
||||
} else if (type == ICMP_TSR) {
|
||||
MIB2_STATS_INC(mib2.icmpintimestampreps);
|
||||
} else if(type == ICMP_AM) {
|
||||
} else if (type == ICMP_AM) {
|
||||
MIB2_STATS_INC(mib2.icmpinaddrmasks);
|
||||
} else if(type == ICMP_AMR) {
|
||||
} else if (type == ICMP_AMR) {
|
||||
MIB2_STATS_INC(mib2.icmpinaddrmaskreps);
|
||||
}
|
||||
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %"S16_F" code %"S16_F" not supported.\n",
|
||||
|
@ -575,8 +575,9 @@ ip4_input(struct pbuf *p, struct netif *inp)
|
||||
#endif /* IP_ACCEPT_LINK_LAYER_ADDRESSING */
|
||||
)
|
||||
#endif /* LWIP_IGMP || IP_ACCEPT_LINK_LAYER_ADDRESSING */
|
||||
{ if ((ip_addr_isbroadcast(ip_current_src_addr(), inp)) ||
|
||||
(ip_addr_ismulticast(ip_current_src_addr()))) {
|
||||
{
|
||||
if ((ip_addr_isbroadcast(ip_current_src_addr(), inp)) ||
|
||||
(ip_addr_ismulticast(ip_current_src_addr()))) {
|
||||
/* packet source is not valid */
|
||||
LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING, ("ip_input: packet source is not valid.\n"));
|
||||
/* free (drop) packet pbufs */
|
||||
@ -634,7 +635,7 @@ ip4_input(struct pbuf *p, struct netif *inp)
|
||||
|
||||
#if LWIP_IGMP
|
||||
/* there is an extra "router alert" option in IGMP messages which we allow for but do not police */
|
||||
if((iphdr_hlen > IP_HLEN) && (IPH_PROTO(iphdr) != IP_PROTO_IGMP)) {
|
||||
if ((iphdr_hlen > IP_HLEN) && (IPH_PROTO(iphdr) != IP_PROTO_IGMP)) {
|
||||
#else
|
||||
if (iphdr_hlen > IP_HLEN) {
|
||||
#endif /* LWIP_IGMP */
|
||||
|
@ -376,11 +376,11 @@ ip_reass_chain_frag_into_datagram_and_validate(struct ip_reassdata *ipr, struct
|
||||
ipr->p = new_p;
|
||||
}
|
||||
break;
|
||||
} else if(iprh->start == iprh_tmp->start) {
|
||||
} else if (iprh->start == iprh_tmp->start) {
|
||||
/* received the same datagram twice: no need to keep the datagram */
|
||||
goto freepbuf;
|
||||
#if IP_REASS_CHECK_OVERLAP
|
||||
} else if(iprh->start < iprh_tmp->end) {
|
||||
} else if (iprh->start < iprh_tmp->end) {
|
||||
/* overlap: no need to keep the new datagram */
|
||||
goto freepbuf;
|
||||
#endif /* IP_REASS_CHECK_OVERLAP */
|
||||
@ -536,7 +536,7 @@ ip4_reass(struct pbuf *p)
|
||||
/* Enqueue a new datagram into the datagram queue */
|
||||
ipr = ip_reass_enqueue_new_datagram(fraghdr, clen);
|
||||
/* Bail if unable to enqueue */
|
||||
if(ipr == NULL) {
|
||||
if (ipr == NULL) {
|
||||
goto nullreturn;
|
||||
}
|
||||
} else {
|
||||
@ -764,7 +764,7 @@ ip4_frag(struct pbuf *p, struct netif *netif, const ip4_addr_t *dest)
|
||||
(rambuf->len == rambuf->tot_len) && (rambuf->next == NULL));
|
||||
poff += pbuf_copy_partial(p, rambuf->payload, cop, poff);
|
||||
/* make room for the IP header */
|
||||
if(pbuf_header(rambuf, IP_HLEN)) {
|
||||
if (pbuf_header(rambuf, IP_HLEN)) {
|
||||
pbuf_free(rambuf);
|
||||
goto memerr;
|
||||
}
|
||||
|
@ -497,8 +497,7 @@ ip6_input(struct pbuf *p, struct netif *inp)
|
||||
else {
|
||||
netif = NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/* start trying with inp. if that's not acceptable, start walking the
|
||||
list of configured netifs.
|
||||
'first' is used as a boolean to mark whether we started walking the list */
|
||||
|
@ -210,7 +210,9 @@ ip6addr_ntoa_r(const ip6_addr_t *addr, char *buf, int buflen)
|
||||
if (current_block_index == 7) {
|
||||
/* special case, we must render a ':' for the last block. */
|
||||
buf[i++] = ':';
|
||||
if (i >= buflen) return NULL;
|
||||
if (i >= buflen) {
|
||||
return NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (empty_block_flag == 0) {
|
||||
@ -224,41 +226,45 @@ ip6addr_ntoa_r(const ip6_addr_t *addr, char *buf, int buflen)
|
||||
if (next_block_value == 0) {
|
||||
empty_block_flag = 1;
|
||||
buf[i++] = ':';
|
||||
if (i >= buflen) return NULL;
|
||||
if (i >= buflen) {
|
||||
return NULL;
|
||||
}
|
||||
continue; /* move on to next block. */
|
||||
}
|
||||
}
|
||||
else if (empty_block_flag == 1) {
|
||||
} else if (empty_block_flag == 1) {
|
||||
/* move on to next block. */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (empty_block_flag == 1) {
|
||||
} else if (empty_block_flag == 1) {
|
||||
/* Set this flag value so we don't produce multiple empty blocks. */
|
||||
empty_block_flag = 2;
|
||||
}
|
||||
|
||||
if (current_block_index > 0) {
|
||||
buf[i++] = ':';
|
||||
if (i >= buflen) return NULL;
|
||||
if (i >= buflen) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if ((current_block_value & 0xf000) == 0) {
|
||||
zero_flag = 1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
buf[i++] = xchar(((current_block_value & 0xf000) >> 12));
|
||||
zero_flag = 0;
|
||||
if (i >= buflen) return NULL;
|
||||
if (i >= buflen) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (((current_block_value & 0xf00) == 0) && (zero_flag)) {
|
||||
/* do nothing */
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
buf[i++] = xchar(((current_block_value & 0xf00) >> 8));
|
||||
zero_flag = 0;
|
||||
if (i >= buflen) return NULL;
|
||||
if (i >= buflen) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (((current_block_value & 0xf0) == 0) && (zero_flag)) {
|
||||
@ -267,11 +273,15 @@ ip6addr_ntoa_r(const ip6_addr_t *addr, char *buf, int buflen)
|
||||
else {
|
||||
buf[i++] = xchar(((current_block_value & 0xf0) >> 4));
|
||||
zero_flag = 0;
|
||||
if (i >= buflen) return NULL;
|
||||
if (i >= buflen) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
buf[i++] = xchar((current_block_value & 0xf));
|
||||
if (i >= buflen) return NULL;
|
||||
if (i >= buflen) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
buf[i] = 0;
|
||||
|
@ -418,12 +418,12 @@ ip6_reass(struct pbuf *p)
|
||||
ipr->p = p;
|
||||
}
|
||||
break;
|
||||
} else if(iprh->start == iprh_tmp->start) {
|
||||
} else if (iprh->start == iprh_tmp->start) {
|
||||
/* received the same datagram twice: no need to keep the datagram */
|
||||
IP6_FRAG_STATS_INC(ip6_frag.drop);
|
||||
goto nullreturn;
|
||||
#if IP_REASS_CHECK_OVERLAP
|
||||
} else if(iprh->start < iprh_tmp->end) {
|
||||
} else if (iprh->start < iprh_tmp->end) {
|
||||
/* overlap: no need to keep the new datagram */
|
||||
IP6_FRAG_STATS_INC(ip6_frag.proterr);
|
||||
IP6_FRAG_STATS_INC(ip6_frag.drop);
|
||||
|
@ -183,9 +183,6 @@ nd6_input(struct pbuf *p, struct netif *inp)
|
||||
mld6_leavegroup(netif_ip6_addr(inp, i), &multicast_address);
|
||||
#endif /* LWIP_IPV6_MLD */
|
||||
|
||||
|
||||
|
||||
|
||||
#if LWIP_IPV6_AUTOCONFIG
|
||||
/* Check to see if this address was autoconfigured. */
|
||||
if (!ip6_addr_islinklocal(ip6_current_dest_addr())) {
|
||||
@ -211,8 +208,7 @@ nd6_input(struct pbuf *p, struct netif *inp)
|
||||
MEMCPY(neighbor_cache[i].lladdr, lladdr_opt->addr, inp->hwaddr_len);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/* This is a solicited NA.
|
||||
* neighbor address resolution response?
|
||||
* neighbor unreachability detection response? */
|
||||
@ -287,8 +283,7 @@ nd6_input(struct pbuf *p, struct netif *inp)
|
||||
if (p->len < (sizeof(struct ns_header) + (lladdr_opt->length << 3))) {
|
||||
lladdr_opt = NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
lladdr_opt = NULL;
|
||||
}
|
||||
|
||||
@ -324,8 +319,7 @@ nd6_input(struct pbuf *p, struct netif *inp)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/* Sender is trying to resolve our address. */
|
||||
/* Verify that they included their own link-layer address. */
|
||||
if (lladdr_opt == NULL) {
|
||||
@ -347,9 +341,7 @@ nd6_input(struct pbuf *p, struct netif *inp)
|
||||
neighbor_cache[i].state = ND6_DELAY;
|
||||
neighbor_cache[i].counter.delay_time = LWIP_ND6_DELAY_FIRST_PROBE_TIME;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/* Add their IPv6 address and link-layer address to neighbor cache.
|
||||
* We will need it at least to send a unicast NA message, but most
|
||||
* likely we will also be communicating with this node soon. */
|
||||
@ -509,13 +501,11 @@ nd6_input(struct pbuf *p, struct netif *inp)
|
||||
break;
|
||||
}
|
||||
case ND6_OPTION_TYPE_ROUTE_INFO:
|
||||
{
|
||||
/* TODO implement preferred routes.
|
||||
struct route_option * route_opt;
|
||||
route_opt = (struct route_option *)buffer;*/
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
/* Unrecognized option, abort. */
|
||||
ND6_STATS_INC(nd6.proterr);
|
||||
@ -547,8 +537,7 @@ nd6_input(struct pbuf *p, struct netif *inp)
|
||||
if (p->len < (sizeof(struct redirect_header) + (lladdr_opt->length << 3))) {
|
||||
lladdr_opt = NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
lladdr_opt = NULL;
|
||||
}
|
||||
|
||||
@ -667,8 +656,7 @@ nd6_tmr(void)
|
||||
if (neighbor_cache[i].counter.probes_sent >= LWIP_ND6_MAX_MULTICAST_SOLICIT) {
|
||||
/* Retries exceeded. */
|
||||
nd6_free_neighbor_cache_entry(i);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/* Send a NS for this entry. */
|
||||
neighbor_cache[i].counter.probes_sent++;
|
||||
nd6_send_ns(neighbor_cache[i].netif, &(neighbor_cache[i].next_hop_address), ND6_SEND_FLAG_MULTICAST_DEST);
|
||||
@ -683,8 +671,7 @@ nd6_tmr(void)
|
||||
/* Change to stale state. */
|
||||
neighbor_cache[i].state = ND6_STALE;
|
||||
neighbor_cache[i].counter.stale_time = 0;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
neighbor_cache[i].counter.reachable_time -= ND6_TMR_INTERVAL;
|
||||
}
|
||||
break;
|
||||
@ -696,8 +683,7 @@ nd6_tmr(void)
|
||||
/* Change to PROBE state. */
|
||||
neighbor_cache[i].state = ND6_PROBE;
|
||||
neighbor_cache[i].counter.probes_sent = 0;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
neighbor_cache[i].counter.delay_time -= ND6_TMR_INTERVAL;
|
||||
}
|
||||
break;
|
||||
@ -705,8 +691,7 @@ nd6_tmr(void)
|
||||
if (neighbor_cache[i].counter.probes_sent >= LWIP_ND6_MAX_MULTICAST_SOLICIT) {
|
||||
/* Retries exceeded. */
|
||||
nd6_free_neighbor_cache_entry(i);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/* Send a NS for this entry. */
|
||||
neighbor_cache[i].counter.probes_sent++;
|
||||
nd6_send_ns(neighbor_cache[i].netif, &(neighbor_cache[i].next_hop_address), 0);
|
||||
@ -769,8 +754,7 @@ nd6_tmr(void)
|
||||
|
||||
prefix_list[i].netif = NULL;
|
||||
prefix_list[i].flags = 0;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
prefix_list[i].invalidation_timer -= ND6_TMR_INTERVAL / 1000;
|
||||
|
||||
#if LWIP_IPV6_AUTOCONFIG
|
||||
@ -813,8 +797,7 @@ nd6_tmr(void)
|
||||
/* No NA received in response. Mark address as valid. */
|
||||
netif->ip6_addr_state[i] = IP6_ADDR_PREFERRED;
|
||||
/* TODO implement preferred and valid lifetimes. */
|
||||
}
|
||||
else if (netif->flags & NETIF_FLAG_UP) {
|
||||
} else if (netif->flags & NETIF_FLAG_UP) {
|
||||
#if LWIP_IPV6_MLD
|
||||
if ((netif->ip6_addr_state[i] & 0x07) == 0) {
|
||||
/* Join solicited node multicast group. */
|
||||
@ -970,12 +953,10 @@ nd6_send_na(struct netif * netif, const ip6_addr_t * target_addr, u8_t flags)
|
||||
if (flags & ND6_SEND_FLAG_MULTICAST_DEST) {
|
||||
ip6_addr_set_solicitednode(&multicast_address, target_addr->addr[3]);
|
||||
dest_addr = &multicast_address;
|
||||
}
|
||||
else if (flags & ND6_SEND_FLAG_ALLNODES_DEST) {
|
||||
} else if (flags & ND6_SEND_FLAG_ALLNODES_DEST) {
|
||||
ip6_addr_set_allnodes_linklocal(&multicast_address);
|
||||
dest_addr = &multicast_address;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
dest_addr = ip6_current_src_addr();
|
||||
}
|
||||
|
||||
@ -1012,8 +993,7 @@ nd6_send_rs(struct netif * netif)
|
||||
/* Link-local source address, or unspecified address? */
|
||||
if (ip6_addr_isvalid(netif_ip6_addr_state(netif, 0))) {
|
||||
src_addr = netif_ip6_addr(netif, 0);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
src_addr = IP6_ADDR_ANY6;
|
||||
}
|
||||
|
||||
@ -1527,8 +1507,7 @@ nd6_get_next_hop_entry(const ip6_addr_t * ip6addr, struct netif * netif)
|
||||
if (i >= 0) {
|
||||
/* found destination entry. make it our new cached index. */
|
||||
nd6_cached_destination_index = i;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/* Not found. Create a new destination entry. */
|
||||
i = nd6_new_destination_cache_entry();
|
||||
if (i >= 0) {
|
||||
@ -1548,8 +1527,7 @@ nd6_get_next_hop_entry(const ip6_addr_t * ip6addr, struct netif * netif)
|
||||
/* Destination in local link. */
|
||||
destination_cache[nd6_cached_destination_index].pmtu = netif->mtu;
|
||||
ip6_addr_copy(destination_cache[nd6_cached_destination_index].next_hop_addr, destination_cache[nd6_cached_destination_index].destination_addr);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/* We need to select a router. */
|
||||
i = nd6_select_router(ip6addr, netif);
|
||||
if (i < 0) {
|
||||
@ -1581,8 +1559,7 @@ nd6_get_next_hop_entry(const ip6_addr_t * ip6addr, struct netif * netif)
|
||||
if (i >= 0) {
|
||||
/* Found a matching record, make it new cached entry. */
|
||||
nd6_cached_neighbor_index = i;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/* Neighbor not in cache. Make a new entry. */
|
||||
i = nd6_new_neighbor_cache_entry();
|
||||
if (i >= 0) {
|
||||
@ -1635,13 +1612,13 @@ nd6_queue_packet(s8_t neighbor_index, struct pbuf * q)
|
||||
* PBUF_ROMs can be left as they are, since ROM must not get changed. */
|
||||
p = q;
|
||||
while (p) {
|
||||
if(p->type != PBUF_ROM) {
|
||||
if (p->type != PBUF_ROM) {
|
||||
copy_needed = 1;
|
||||
break;
|
||||
}
|
||||
p = p->next;
|
||||
}
|
||||
if(copy_needed) {
|
||||
if (copy_needed) {
|
||||
/* copy the whole packet into new pbufs */
|
||||
p = pbuf_alloc(PBUF_LINK, q->tot_len, PBUF_RAM);
|
||||
while ((p == NULL) && (neighbor_cache[neighbor_index].q != NULL)) {
|
||||
@ -1657,7 +1634,7 @@ nd6_queue_packet(s8_t neighbor_index, struct pbuf * q)
|
||||
#endif /* LWIP_ND6_QUEUEING */
|
||||
p = pbuf_alloc(PBUF_LINK, q->tot_len, PBUF_RAM);
|
||||
}
|
||||
if(p != NULL) {
|
||||
if (p != NULL) {
|
||||
if (pbuf_copy(p, q) != ERR_OK) {
|
||||
pbuf_free(p);
|
||||
p = NULL;
|
||||
@ -1685,7 +1662,7 @@ nd6_queue_packet(s8_t neighbor_index, struct pbuf * q)
|
||||
if (new_entry != NULL) {
|
||||
new_entry->next = NULL;
|
||||
new_entry->p = p;
|
||||
if(neighbor_cache[neighbor_index].q != NULL) {
|
||||
if (neighbor_cache[neighbor_index].q != NULL) {
|
||||
/* queue was already existent, append the new entry to the end */
|
||||
r = neighbor_cache[neighbor_index].q;
|
||||
while (r->next != NULL) {
|
||||
@ -1839,8 +1816,7 @@ nd6_reachability_hint(const ip6_addr_t * ip6addr)
|
||||
if (ip6_addr_cmp(ip6addr, &(destination_cache[nd6_cached_destination_index].destination_addr))) {
|
||||
i = nd6_cached_destination_index;
|
||||
ND6_STATS_INC(nd6.cachehit);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
i = nd6_find_destination_cache_entry(ip6addr);
|
||||
}
|
||||
if (i < 0) {
|
||||
@ -1851,8 +1827,7 @@ nd6_reachability_hint(const ip6_addr_t * ip6addr)
|
||||
if (ip6_addr_cmp(&(destination_cache[i].next_hop_addr), &(neighbor_cache[nd6_cached_neighbor_index].next_hop_address))) {
|
||||
i = nd6_cached_neighbor_index;
|
||||
ND6_STATS_INC(nd6.cachehit);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
i = nd6_find_neighbor_cache_entry(&(destination_cache[i].next_hop_addr));
|
||||
}
|
||||
if (i < 0) {
|
||||
|
@ -314,7 +314,7 @@ mem_init(void)
|
||||
|
||||
MEM_STATS_AVAIL(avail, MEM_SIZE_ALIGNED);
|
||||
|
||||
if(sys_mutex_new(&mem_mutex) != ERR_OK) {
|
||||
if (sys_mutex_new(&mem_mutex) != ERR_OK) {
|
||||
LWIP_ASSERT("failed to create mem_mutex", 0);
|
||||
}
|
||||
}
|
||||
@ -396,7 +396,7 @@ mem_trim(void *rmem, mem_size_t newsize)
|
||||
adjust for alignment. */
|
||||
newsize = LWIP_MEM_ALIGN_SIZE(newsize);
|
||||
|
||||
if(newsize < MIN_SIZE_ALIGNED) {
|
||||
if (newsize < MIN_SIZE_ALIGNED) {
|
||||
/* every data block must be at least MIN_SIZE_ALIGNED long */
|
||||
newsize = MIN_SIZE_ALIGNED;
|
||||
}
|
||||
@ -437,7 +437,7 @@ mem_trim(void *rmem, mem_size_t newsize)
|
||||
LWIP_MEM_FREE_PROTECT();
|
||||
|
||||
mem2 = (struct mem *)(void *)&ram[mem->next];
|
||||
if(mem2->used == 0) {
|
||||
if (mem2->used == 0) {
|
||||
/* The next struct is unused, we can simply move it at little */
|
||||
mem_size_t next;
|
||||
/* remember the old next pointer */
|
||||
@ -526,7 +526,7 @@ mem_malloc(mem_size_t size)
|
||||
adjust for alignment. */
|
||||
size = LWIP_MEM_ALIGN_SIZE(size);
|
||||
|
||||
if(size < MIN_SIZE_ALIGNED) {
|
||||
if (size < MIN_SIZE_ALIGNED) {
|
||||
/* every data block must be at least MIN_SIZE_ALIGNED long */
|
||||
size = MIN_SIZE_ALIGNED;
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ memp_sanity(void)
|
||||
|
||||
for (i = 0; i < MEMP_MAX; i++) {
|
||||
t = memp_tab[i];
|
||||
if(t != NULL) {
|
||||
if (t != NULL) {
|
||||
for (h = t->next; (t != NULL) && (h != NULL); t = t->next,
|
||||
h = (((h->next != NULL) && (h->next->next != NULL)) ? h->next->next : NULL)) {
|
||||
if (t == h) {
|
||||
@ -232,7 +232,7 @@ memp_overflow_check_element_overflow(struct memp *p, u16_t memp_type)
|
||||
if (m[k] != 0xcd) {
|
||||
char errstr[128] = "detected memp overflow in pool ";
|
||||
char digit[] = "0";
|
||||
if(memp_type >= 10) {
|
||||
if (memp_type >= 10) {
|
||||
digit[0] = '0' + (memp_type/10);
|
||||
strcat(errstr, digit);
|
||||
}
|
||||
@ -265,7 +265,7 @@ memp_overflow_check_element_underflow(struct memp *p, u16_t memp_type)
|
||||
if (m[k] != 0xcd) {
|
||||
char errstr[128] = "detected memp underflow in pool ";
|
||||
char digit[] = "0";
|
||||
if(memp_type >= 10) {
|
||||
if (memp_type >= 10) {
|
||||
digit[0] = '0' + (memp_type/10);
|
||||
strcat(errstr, digit);
|
||||
}
|
||||
|
@ -525,7 +525,8 @@ netif_set_default(struct netif *netif)
|
||||
* Bring an interface up, available for processing
|
||||
* traffic.
|
||||
*/
|
||||
void netif_set_up(struct netif *netif)
|
||||
void
|
||||
netif_set_up(struct netif *netif)
|
||||
{
|
||||
if (!(netif->flags & NETIF_FLAG_UP)) {
|
||||
netif->flags |= NETIF_FLAG_UP;
|
||||
@ -581,7 +582,8 @@ netif_issue_reports(struct netif* netif, u8_t report_type)
|
||||
/**
|
||||
* Bring an interface down, disabling any traffic processing.
|
||||
*/
|
||||
void netif_set_down(struct netif *netif)
|
||||
void
|
||||
netif_set_down(struct netif *netif)
|
||||
{
|
||||
if (netif->flags & NETIF_FLAG_UP) {
|
||||
netif->flags &= ~NETIF_FLAG_UP;
|
||||
@ -600,7 +602,8 @@ void netif_set_down(struct netif *netif)
|
||||
/**
|
||||
* Set callback to be called when interface is brought up/down or address is changed while up
|
||||
*/
|
||||
void netif_set_status_callback(struct netif *netif, netif_status_callback_fn status_callback)
|
||||
void
|
||||
netif_set_status_callback(struct netif *netif, netif_status_callback_fn status_callback)
|
||||
{
|
||||
if (netif) {
|
||||
netif->status_callback = status_callback;
|
||||
@ -652,7 +655,8 @@ netif_set_link_up(struct netif *netif)
|
||||
/**
|
||||
* Called by a driver when its link goes down
|
||||
*/
|
||||
void netif_set_link_down(struct netif *netif )
|
||||
void
|
||||
netif_set_link_down(struct netif *netif )
|
||||
{
|
||||
if (netif->flags & NETIF_FLAG_LINK_UP) {
|
||||
netif->flags &= ~NETIF_FLAG_LINK_UP;
|
||||
@ -664,7 +668,8 @@ void netif_set_link_down(struct netif *netif )
|
||||
/**
|
||||
* Set callback to be called when link is brought up/down
|
||||
*/
|
||||
void netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_callback)
|
||||
void
|
||||
netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_callback)
|
||||
{
|
||||
if (netif) {
|
||||
netif->link_callback = link_callback;
|
||||
|
@ -91,7 +91,7 @@
|
||||
#ifndef PBUF_POOL_FREE_OOSEQ_QUEUE_CALL
|
||||
#include "lwip/tcpip.h"
|
||||
#define PBUF_POOL_FREE_OOSEQ_QUEUE_CALL() do { \
|
||||
if(tcpip_callback_with_block(pbuf_free_ooseq_callback, NULL, 0) != ERR_OK) { \
|
||||
if (tcpip_callback_with_block(pbuf_free_ooseq_callback, NULL, 0) != ERR_OK) { \
|
||||
SYS_ARCH_PROTECT(old_level); \
|
||||
pbuf_free_ooseq_pending = 0; \
|
||||
SYS_ARCH_UNPROTECT(old_level); \
|
||||
@ -163,7 +163,7 @@ pbuf_pool_is_empty(void)
|
||||
pbuf_free_ooseq_pending = 1;
|
||||
SYS_ARCH_UNPROTECT(old_level);
|
||||
|
||||
if(!queued) {
|
||||
if (!queued) {
|
||||
/* queue a call to pbuf_free_ooseq if not already queued */
|
||||
PBUF_POOL_FREE_OOSEQ_QUEUE_CALL();
|
||||
}
|
||||
@ -522,7 +522,7 @@ pbuf_header_impl(struct pbuf *p, s16_t header_size_increment, u8_t force)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (header_size_increment < 0){
|
||||
if (header_size_increment < 0) {
|
||||
increment_magnitude = -header_size_increment;
|
||||
/* Check that we aren't going to move off the end of the pbuf */
|
||||
LWIP_ERROR("increment_magnitude <= p->len", (increment_magnitude <= p->len), return 1;);
|
||||
@ -929,12 +929,12 @@ pbuf_copy(struct pbuf *p_to, struct pbuf *p_from)
|
||||
LWIP_ERROR("p_to != NULL", (p_to != NULL) || (p_from == NULL) , return ERR_ARG;);
|
||||
}
|
||||
|
||||
if((p_from != NULL) && (p_from->len == p_from->tot_len)) {
|
||||
if ((p_from != NULL) && (p_from->len == p_from->tot_len)) {
|
||||
/* don't copy more than one packet! */
|
||||
LWIP_ERROR("pbuf_copy() does not allow packet queues!",
|
||||
(p_from->next == NULL), return ERR_VAL;);
|
||||
}
|
||||
if((p_to != NULL) && (p_to->len == p_to->tot_len)) {
|
||||
if ((p_to != NULL) && (p_to->len == p_to->tot_len)) {
|
||||
/* don't copy more than one packet! */
|
||||
LWIP_ERROR("pbuf_copy() does not allow packet queues!",
|
||||
(p_to->next == NULL), return ERR_VAL;);
|
||||
@ -968,7 +968,7 @@ pbuf_copy_partial(struct pbuf *buf, void *dataptr, u16_t len, u16_t offset)
|
||||
|
||||
left = 0;
|
||||
|
||||
if((buf == NULL) || (dataptr == NULL)) {
|
||||
if ((buf == NULL) || (dataptr == NULL)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -272,10 +272,10 @@ raw_sendto(struct raw_pcb *pcb, struct pbuf *p, const ip_addr_t *ipaddr)
|
||||
}
|
||||
/* { first pbuf q points to header pbuf } */
|
||||
LWIP_DEBUGF(RAW_DEBUG, ("raw_sendto: added header pbuf %p before given pbuf %p\n", (void *)q, (void *)p));
|
||||
} else {
|
||||
} else {
|
||||
/* first pbuf q equals given pbuf */
|
||||
q = p;
|
||||
if(pbuf_header(q, -header_size)) {
|
||||
if (pbuf_header(q, -header_size)) {
|
||||
LWIP_ASSERT("Can't restore header we just removed!", 0);
|
||||
return ERR_MEM;
|
||||
}
|
||||
|
@ -49,7 +49,8 @@
|
||||
|
||||
struct stats_ lwip_stats;
|
||||
|
||||
void stats_init(void)
|
||||
void
|
||||
stats_init(void)
|
||||
{
|
||||
#ifdef LWIP_DEBUG
|
||||
#if MEMP_STATS
|
||||
@ -128,7 +129,7 @@ stats_display_memp(struct stats_mem *mem, int index)
|
||||
#define LWIP_MEMPOOL(name,num,size,desc) desc,
|
||||
#include "lwip/memp_std.h"
|
||||
};
|
||||
if(index < MEMP_MAX) {
|
||||
if (index < MEMP_MAX) {
|
||||
stats_display_mem(mem, memp_names[index]);
|
||||
}
|
||||
}
|
||||
|
@ -678,7 +678,7 @@ tcp_recved(struct tcp_pcb *pcb, u16_t len)
|
||||
pcb->rcv_wnd += len;
|
||||
if (pcb->rcv_wnd > TCP_WND_MAX(pcb)) {
|
||||
pcb->rcv_wnd = TCP_WND_MAX(pcb);
|
||||
} else if(pcb->rcv_wnd == 0) {
|
||||
} else if (pcb->rcv_wnd == 0) {
|
||||
/* rcv_wnd overflowed */
|
||||
if ((pcb->state == CLOSE_WAIT) || (pcb->state == LAST_ACK)) {
|
||||
/* In passive close, we allow this, since the FIN bit is added to rcv_wnd
|
||||
@ -921,7 +921,7 @@ tcp_slowtmr_start:
|
||||
}
|
||||
} else {
|
||||
/* Increase the retransmission timer if it is running */
|
||||
if(pcb->rtime >= 0) {
|
||||
if (pcb->rtime >= 0) {
|
||||
++pcb->rtime;
|
||||
}
|
||||
|
||||
@ -972,10 +972,10 @@ tcp_slowtmr_start:
|
||||
}
|
||||
|
||||
/* Check if KEEPALIVE should be sent */
|
||||
if(ip_get_option(pcb, SOF_KEEPALIVE) &&
|
||||
if (ip_get_option(pcb, SOF_KEEPALIVE) &&
|
||||
((pcb->state == ESTABLISHED) ||
|
||||
(pcb->state == CLOSE_WAIT))) {
|
||||
if((u32_t)(tcp_ticks - pcb->tmr) >
|
||||
if ((u32_t)(tcp_ticks - pcb->tmr) >
|
||||
(pcb->keep_idle + TCP_KEEP_DUR(pcb)) / TCP_SLOW_INTERVAL)
|
||||
{
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: KEEPALIVE timeout. Aborting connection to "));
|
||||
@ -984,10 +984,9 @@ tcp_slowtmr_start:
|
||||
|
||||
++pcb_remove;
|
||||
++pcb_reset;
|
||||
}
|
||||
else if((u32_t)(tcp_ticks - pcb->tmr) >
|
||||
(pcb->keep_idle + pcb->keep_cnt_sent * TCP_KEEP_INTVL(pcb))
|
||||
/ TCP_SLOW_INTERVAL)
|
||||
} else if ((u32_t)(tcp_ticks - pcb->tmr) >
|
||||
(pcb->keep_idle + pcb->keep_cnt_sent * TCP_KEEP_INTVL(pcb))
|
||||
/ TCP_SLOW_INTERVAL)
|
||||
{
|
||||
err = tcp_keepalive(pcb);
|
||||
if (err == ERR_OK) {
|
||||
@ -1894,7 +1893,7 @@ void tcp_netif_ipv4_addr_changed(const ip4_addr_t* old_addr, const ip4_addr_t* n
|
||||
* is set to listen to the new one instead */
|
||||
ip_addr_copy_from_ip4(lpcb->local_ip, *new_addr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -761,9 +761,9 @@ tcp_process(struct tcp_pcb *pcb)
|
||||
|
||||
/* If there's nothing left to acknowledge, stop the retransmit
|
||||
timer, otherwise reset it to start again */
|
||||
if(pcb->unacked == NULL)
|
||||
if (pcb->unacked == NULL) {
|
||||
pcb->rtime = -1;
|
||||
else {
|
||||
} else {
|
||||
pcb->rtime = 0;
|
||||
pcb->nrtx = 0;
|
||||
}
|
||||
@ -914,8 +914,7 @@ tcp_oos_insert_segment(struct tcp_seg *cseg, struct tcp_seg *next)
|
||||
/* received segment overlaps all following segments */
|
||||
tcp_segs_free(next);
|
||||
next = NULL;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/* delete some following segments
|
||||
oos queue may have segments with FIN flag */
|
||||
while (next &&
|
||||
@ -1035,7 +1034,7 @@ tcp_receive(struct tcp_pcb *pcb)
|
||||
/* Clause 2 */
|
||||
if (tcplen == 0) {
|
||||
/* Clause 3 */
|
||||
if (pcb->snd_wl2 + pcb->snd_wnd == right_wnd_edge){
|
||||
if (pcb->snd_wl2 + pcb->snd_wnd == right_wnd_edge) {
|
||||
/* Clause 4 */
|
||||
if (pcb->rtime >= 0) {
|
||||
/* Clause 5 */
|
||||
@ -1063,7 +1062,7 @@ tcp_receive(struct tcp_pcb *pcb)
|
||||
if (!found_dupack) {
|
||||
pcb->dupacks = 0;
|
||||
}
|
||||
} else if (TCP_SEQ_BETWEEN(ackno, pcb->lastack+1, pcb->snd_nxt)){
|
||||
} else if (TCP_SEQ_BETWEEN(ackno, pcb->lastack+1, pcb->snd_nxt)) {
|
||||
/* We come here when the ACK acknowledges new data. */
|
||||
|
||||
/* Reset the "IN Fast Retransmit" flag, since we are no longer
|
||||
@ -1265,9 +1264,9 @@ tcp_receive(struct tcp_pcb *pcb)
|
||||
this if the sequence number of the incoming segment is less
|
||||
than rcv_nxt, and the sequence number plus the length of the
|
||||
segment is larger than rcv_nxt. */
|
||||
/* if (TCP_SEQ_LT(seqno, pcb->rcv_nxt)){
|
||||
/* if (TCP_SEQ_LT(seqno, pcb->rcv_nxt)) {
|
||||
if (TCP_SEQ_LT(pcb->rcv_nxt, seqno + tcplen)) {*/
|
||||
if (TCP_SEQ_BETWEEN(pcb->rcv_nxt, seqno + 1, seqno + tcplen - 1)){
|
||||
if (TCP_SEQ_BETWEEN(pcb->rcv_nxt, seqno + 1, seqno + tcplen - 1)) {
|
||||
/* Trimming the first edge is done by pushing the payload
|
||||
pointer in the pbuf downwards. This is somewhat tricky since
|
||||
we do not want to discard the full contents of the pbuf up to
|
||||
@ -1304,12 +1303,12 @@ tcp_receive(struct tcp_pcb *pcb)
|
||||
p->len = 0;
|
||||
p = p->next;
|
||||
}
|
||||
if(pbuf_header(p, (s16_t)-off)) {
|
||||
if (pbuf_header(p, (s16_t)-off)) {
|
||||
/* Do we need to cope with this failing? Assert for now */
|
||||
LWIP_ASSERT("pbuf_header failed", 0);
|
||||
}
|
||||
} else {
|
||||
if(pbuf_header(inseg.p, (s16_t)-off)) {
|
||||
if (pbuf_header(inseg.p, (s16_t)-off)) {
|
||||
/* Do we need to cope with this failing? Assert for now */
|
||||
LWIP_ASSERT("pbuf_header failed", 0);
|
||||
}
|
||||
@ -1331,7 +1330,7 @@ tcp_receive(struct tcp_pcb *pcb)
|
||||
and below rcv_nxt + rcv_wnd) in order to be further
|
||||
processed. */
|
||||
if (TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt,
|
||||
pcb->rcv_nxt + pcb->rcv_wnd - 1)){
|
||||
pcb->rcv_nxt + pcb->rcv_wnd - 1)) {
|
||||
if (pcb->rcv_nxt == seqno) {
|
||||
/* The incoming segment is the next in sequence. We check if
|
||||
we have to trim the end of the segment and update rcv_nxt
|
||||
@ -1652,13 +1651,14 @@ tcp_receive(struct tcp_pcb *pcb)
|
||||
} else {
|
||||
/* Segments with length 0 is taken care of here. Segments that
|
||||
fall out of the window are ACKed. */
|
||||
if(!TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt, pcb->rcv_nxt + pcb->rcv_wnd - 1)){
|
||||
if (!TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt, pcb->rcv_nxt + pcb->rcv_wnd - 1)) {
|
||||
tcp_ack_now(pcb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static u8_t tcp_getoptbyte(void)
|
||||
static u8_t
|
||||
tcp_getoptbyte(void)
|
||||
{
|
||||
if ((tcphdr_opt2 == NULL) || (tcp_optidx < tcphdr_opt1len)) {
|
||||
u8_t* opts = (u8_t *)tcphdr + TCP_HLEN;
|
||||
|
@ -680,7 +680,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
|
||||
#if TCP_CHECKSUM_ON_COPY
|
||||
if (concat_chksummed) {
|
||||
/*if concat checksumm swapped - swap it back */
|
||||
if (concat_chksum_swapped){
|
||||
if (concat_chksum_swapped) {
|
||||
concat_chksum = SWAP_BYTES_IN_WORD(concat_chksum);
|
||||
}
|
||||
tcp_seg_add_chksum(concat_chksum, concat_chksummed, &last_unsent->chksum,
|
||||
@ -1043,7 +1043,7 @@ tcp_output(struct tcp_pcb *pcb)
|
||||
* RST is no sent using tcp_write/tcp_output.
|
||||
*/
|
||||
if((tcp_do_output_nagle(pcb) == 0) &&
|
||||
((pcb->flags & (TF_NAGLEMEMERR | TF_FIN)) == 0)){
|
||||
((pcb->flags & (TF_NAGLEMEMERR | TF_FIN)) == 0)) {
|
||||
break;
|
||||
}
|
||||
#if TCP_CWND_DEBUG
|
||||
@ -1298,8 +1298,8 @@ tcp_rst(u32_t seqno, u32_t ackno,
|
||||
struct netif *netif;
|
||||
p = pbuf_alloc(PBUF_IP, TCP_HLEN, PBUF_RAM);
|
||||
if (p == NULL) {
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("tcp_rst: could not allocate memory for pbuf\n"));
|
||||
return;
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("tcp_rst: could not allocate memory for pbuf\n"));
|
||||
return;
|
||||
}
|
||||
LWIP_ASSERT("check that first pbuf can hold struct tcp_hdr",
|
||||
(p->len >= sizeof(struct tcp_hdr)));
|
||||
@ -1488,7 +1488,7 @@ tcp_keepalive(struct tcp_pcb *pcb)
|
||||
tcp_ticks, pcb->tmr, pcb->keep_cnt_sent));
|
||||
|
||||
p = tcp_output_alloc_header(pcb, 0, 0, htonl(pcb->snd_nxt - 1));
|
||||
if(p == NULL) {
|
||||
if (p == NULL) {
|
||||
LWIP_DEBUGF(TCP_DEBUG,
|
||||
("tcp_keepalive: could not allocate memory for pbuf\n"));
|
||||
return ERR_MEM;
|
||||
@ -1550,10 +1550,10 @@ tcp_zero_window_probe(struct tcp_pcb *pcb)
|
||||
|
||||
seg = pcb->unacked;
|
||||
|
||||
if(seg == NULL) {
|
||||
if (seg == NULL) {
|
||||
seg = pcb->unsent;
|
||||
}
|
||||
if(seg == NULL) {
|
||||
if (seg == NULL) {
|
||||
/* nothing to send, zero window probe not needed */
|
||||
return ERR_OK;
|
||||
}
|
||||
@ -1563,7 +1563,7 @@ tcp_zero_window_probe(struct tcp_pcb *pcb)
|
||||
len = is_fin ? 0 : 1;
|
||||
|
||||
p = tcp_output_alloc_header(pcb, 0, len, seg->tcphdr->seqno);
|
||||
if(p == NULL) {
|
||||
if (p == NULL) {
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("tcp_zero_window_probe: no memory for pbuf\n"));
|
||||
return ERR_MEM;
|
||||
}
|
||||
|
@ -447,8 +447,7 @@ sys_check_timeouts(void)
|
||||
now = sys_now();
|
||||
/* this cares for wraparounds */
|
||||
diff = now - timeouts_last_time;
|
||||
do
|
||||
{
|
||||
do {
|
||||
#if PBUF_POOL_FREE_OOSEQ
|
||||
PBUF_CHECK_FREE_OOSEQ();
|
||||
#endif /* PBUF_POOL_FREE_OOSEQ */
|
||||
|
@ -363,7 +363,7 @@ udp_input(struct pbuf *p, struct netif *inp)
|
||||
}
|
||||
}
|
||||
#endif /* CHECKSUM_CHECK_UDP */
|
||||
if(pbuf_header(p, -UDP_HLEN)) {
|
||||
if (pbuf_header(p, -UDP_HLEN)) {
|
||||
/* Can we cope with this failing? Just assert for now */
|
||||
LWIP_ASSERT("pbuf_header failed\n", 0);
|
||||
UDP_STATS_INC(udp.drop);
|
||||
|
@ -642,7 +642,7 @@ etharp_find_addr(struct netif *netif, const ip4_addr_t *ipaddr,
|
||||
LWIP_UNUSED_ARG(netif);
|
||||
|
||||
i = etharp_find_entry(ipaddr, ETHARP_FLAG_FIND_ONLY, netif);
|
||||
if((i >= 0) && (arp_table[i].state >= ETHARP_STATE_STABLE)) {
|
||||
if ((i >= 0) && (arp_table[i].state >= ETHARP_STATE_STABLE)) {
|
||||
*eth_ret = &arp_table[i].ethaddr;
|
||||
*ip_ret = &arp_table[i].ipaddr;
|
||||
return i;
|
||||
@ -979,7 +979,7 @@ etharp_output(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr)
|
||||
/* For advanced routing, a single default gateway might not be enough, so get
|
||||
the IP address of the gateway to handle the current destination address. */
|
||||
dst_addr = LWIP_HOOK_ETHARP_GET_GW(netif, ipaddr);
|
||||
if(dst_addr == NULL)
|
||||
if (dst_addr == NULL)
|
||||
#endif /* LWIP_HOOK_ETHARP_GET_GW */
|
||||
{
|
||||
/* interface has default gateway? */
|
||||
@ -1141,16 +1141,16 @@ etharp_query(struct netif *netif, const ip4_addr_t *ipaddr, struct pbuf *q)
|
||||
p = q;
|
||||
while (p) {
|
||||
LWIP_ASSERT("no packet queues allowed!", (p->len != p->tot_len) || (p->next == 0));
|
||||
if(p->type != PBUF_ROM) {
|
||||
if (p->type != PBUF_ROM) {
|
||||
copy_needed = 1;
|
||||
break;
|
||||
}
|
||||
p = p->next;
|
||||
}
|
||||
if(copy_needed) {
|
||||
if (copy_needed) {
|
||||
/* copy the whole packet into new pbufs */
|
||||
p = pbuf_alloc(PBUF_RAW_TX, p->tot_len, PBUF_RAM);
|
||||
if(p != NULL) {
|
||||
if (p != NULL) {
|
||||
if (pbuf_copy(p, q) != ERR_OK) {
|
||||
pbuf_free(p);
|
||||
p = NULL;
|
||||
@ -1172,7 +1172,7 @@ etharp_query(struct netif *netif, const ip4_addr_t *ipaddr, struct pbuf *q)
|
||||
unsigned int qlen = 0;
|
||||
new_entry->next = 0;
|
||||
new_entry->p = p;
|
||||
if(arp_table[i].q != NULL) {
|
||||
if (arp_table[i].q != NULL) {
|
||||
/* queue was already existent, append the new entry to the end */
|
||||
struct etharp_q_entry *r;
|
||||
r = arp_table[i].q;
|
||||
@ -1501,7 +1501,7 @@ ethernet_input(struct pbuf *p, struct netif *netif)
|
||||
#if LWIP_IPV6
|
||||
case PP_HTONS(ETHTYPE_IPV6): /* IPv6 */
|
||||
/* skip Ethernet header */
|
||||
if((p->len < ip_hdr_offset) || pbuf_header(p, (s16_t)-ip_hdr_offset)) {
|
||||
if ((p->len < ip_hdr_offset) || pbuf_header(p, (s16_t)-ip_hdr_offset)) {
|
||||
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING,
|
||||
("ethernet_input: IPv6 packet dropped, too short (%"S16_F"/%"S16_F")\n",
|
||||
p->tot_len, ip_hdr_offset));
|
||||
|
Loading…
x
Reference in New Issue
Block a user