Reformat core code using astylerc

This commit is contained in:
Dirk Ziegelmeier 2017-09-17 20:38:38 +02:00
parent 8c59be74c1
commit 931b5e643c
16 changed files with 901 additions and 911 deletions

View File

@ -494,7 +494,7 @@ const struct altcp_functions altcp_tcp_functions = {
altcp_tcp_get_ip, altcp_tcp_get_ip,
altcp_tcp_get_port altcp_tcp_get_port
#ifdef LWIP_DEBUG #ifdef LWIP_DEBUG
,altcp_tcp_dbg_get_tcp_state , altcp_tcp_dbg_get_tcp_state
#endif #endif
}; };

View File

@ -101,10 +101,10 @@ lwip_htonl(u32_t n)
* lwIP default implementation for strnstr() non-standard function. * lwIP default implementation for strnstr() non-standard function.
* This can be \#defined to strnstr() depending on your platform port. * This can be \#defined to strnstr() depending on your platform port.
*/ */
char* char *
lwip_strnstr(const char* buffer, const char* token, size_t n) lwip_strnstr(const char *buffer, const char *token, size_t n)
{ {
const char* p; const char *p;
size_t tokenlen = strlen(token); size_t tokenlen = strlen(token);
if (tokenlen == 0) { if (tokenlen == 0) {
return LWIP_CONST_CAST(char *, buffer); return LWIP_CONST_CAST(char *, buffer);
@ -125,7 +125,7 @@ lwip_strnstr(const char* buffer, const char* token, size_t n)
* This can be \#defined to stricmp() depending on your platform port. * This can be \#defined to stricmp() depending on your platform port.
*/ */
int int
lwip_stricmp(const char* str1, const char* str2) lwip_stricmp(const char *str1, const char *str2)
{ {
char c1, c2; char c1, c2;
@ -160,7 +160,7 @@ lwip_stricmp(const char* str1, const char* str2)
* This can be \#defined to strnicmp() depending on your platform port. * This can be \#defined to strnicmp() depending on your platform port.
*/ */
int int
lwip_strnicmp(const char* str1, const char* str2, size_t len) lwip_strnicmp(const char *str1, const char *str2, size_t len)
{ {
char c1, c2; char c1, c2;
@ -195,7 +195,7 @@ lwip_strnicmp(const char* str1, const char* str2, size_t len)
* This can be \#defined to itoa() or snprintf(result, bufsize, "%d", number) depending on your platform port. * This can be \#defined to itoa() or snprintf(result, bufsize, "%d", number) depending on your platform port.
*/ */
void void
lwip_itoa(char* result, size_t bufsize, int number) lwip_itoa(char *result, size_t bufsize, int number)
{ {
char *res = result; char *res = result;
char *tmp = result; char *tmp = result;
@ -212,11 +212,11 @@ lwip_itoa(char* result, size_t bufsize, int number)
} }
/* ensure output string is zero terminated */ /* ensure output string is zero terminated */
result[bufsize-1] = 0; result[bufsize - 1] = 0;
result_len = 1; result_len = 1;
/* create the string in a temporary buffer since we don't know how long /* create the string in a temporary buffer since we don't know how long
it will get */ it will get */
tmp = &result[bufsize-2]; tmp = &result[bufsize - 2];
if (n == 0) { if (n == 0) {
*tmp = '0'; *tmp = '0';
tmp--; tmp--;
@ -243,6 +243,6 @@ lwip_itoa(char* result, size_t bufsize, int number)
return; return;
} }
/* copy from temporary buffer to output buffer */ /* copy from temporary buffer to output buffer */
memmove(res, tmp+1, result_len); memmove(res, tmp + 1, result_len);
} }
#endif #endif

View File

@ -287,7 +287,7 @@ static err_t dns_lookup_local(const char *hostname, ip_addr_t *addr LWIP_DNS_ADD
/* forward declarations */ /* forward declarations */
static void dns_recv(void *s, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port); static void dns_recv(void *s, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port);
static void dns_check_entries(void); static void dns_check_entries(void);
static void dns_call_found(u8_t idx, ip_addr_t* addr); static void dns_call_found(u8_t idx, ip_addr_t *addr);
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
* Globals * Globals
@ -380,7 +380,7 @@ dns_setserver(u8_t numdns, const ip_addr_t *dnsserver)
* @return IP address of the indexed DNS server or "ip_addr_any" if the DNS * @return IP address of the indexed DNS server or "ip_addr_any" if the DNS
* server has not been configured. * server has not been configured.
*/ */
const ip_addr_t* const ip_addr_t *
dns_getserver(u8_t numdns) dns_getserver(u8_t numdns)
{ {
if (numdns < DNS_MAX_SERVERS) { if (numdns < DNS_MAX_SERVERS) {
@ -419,7 +419,7 @@ dns_init_local(void)
entry = (struct local_hostlist_entry *)memp_malloc(MEMP_LOCALHOSTLIST); entry = (struct local_hostlist_entry *)memp_malloc(MEMP_LOCALHOSTLIST);
LWIP_ASSERT("mem-error in dns_init_local", entry != NULL); LWIP_ASSERT("mem-error in dns_init_local", entry != NULL);
if (entry != NULL) { if (entry != NULL) {
char* entry_name = (char*)entry + sizeof(struct local_hostlist_entry); char *entry_name = (char *)entry + sizeof(struct local_hostlist_entry);
MEMCPY(entry_name, init_entry->name, namelen); MEMCPY(entry_name, init_entry->name, namelen);
entry_name[namelen] = 0; entry_name[namelen] = 0;
entry->name = entry_name; entry->name = entry_name;
@ -566,7 +566,7 @@ dns_local_addhost(const char *hostname, const ip_addr_t *addr)
{ {
struct local_hostlist_entry *entry; struct local_hostlist_entry *entry;
size_t namelen; size_t namelen;
char* entry_name; char *entry_name;
LWIP_ASSERT("invalid host name (NULL)", hostname != NULL); LWIP_ASSERT("invalid host name (NULL)", hostname != NULL);
namelen = strlen(hostname); namelen = strlen(hostname);
LWIP_ASSERT("namelen <= DNS_LOCAL_HOSTLIST_MAX_NAMELEN", namelen <= DNS_LOCAL_HOSTLIST_MAX_NAMELEN); LWIP_ASSERT("namelen <= DNS_LOCAL_HOSTLIST_MAX_NAMELEN", namelen <= DNS_LOCAL_HOSTLIST_MAX_NAMELEN);
@ -574,7 +574,7 @@ dns_local_addhost(const char *hostname, const ip_addr_t *addr)
if (entry == NULL) { if (entry == NULL) {
return ERR_MEM; return ERR_MEM;
} }
entry_name = (char*)entry + sizeof(struct local_hostlist_entry); entry_name = (char *)entry + sizeof(struct local_hostlist_entry);
MEMCPY(entry_name, hostname, namelen); MEMCPY(entry_name, hostname, namelen);
entry_name[namelen] = 0; entry_name[namelen] = 0;
entry->name = entry_name; entry->name = entry_name;
@ -646,7 +646,7 @@ dns_lookup(const char *name, ip_addr_t *addr LWIP_DNS_ADDRTYPE_ARG(u8_t dns_addr
* @return 0xFFFF: names differ, other: names equal -> offset behind name * @return 0xFFFF: names differ, other: names equal -> offset behind name
*/ */
static u16_t static u16_t
dns_compare_name(const char *query, struct pbuf* p, u16_t start_offset) dns_compare_name(const char *query, struct pbuf *p, u16_t start_offset)
{ {
int n; int n;
u16_t response_offset = start_offset; u16_t response_offset = start_offset;
@ -699,7 +699,7 @@ dns_compare_name(const char *query, struct pbuf* p, u16_t start_offset)
* @return index to end of the name * @return index to end of the name
*/ */
static u16_t static u16_t
dns_skip_name(struct pbuf* p, u16_t query_idx) dns_skip_name(struct pbuf *p, u16_t query_idx)
{ {
int n; int n;
u16_t offset = query_idx; u16_t offset = query_idx;
@ -749,7 +749,7 @@ dns_send(u8_t idx)
const char *hostname, *hostname_part; const char *hostname, *hostname_part;
u8_t n; u8_t n;
u8_t pcb_idx; u8_t pcb_idx;
struct dns_table_entry* entry = &dns_table[idx]; struct dns_table_entry *entry = &dns_table[idx];
LWIP_DEBUGF(DNS_DEBUG, ("dns_send: dns_servers[%"U16_F"] \"%s\": request\n", LWIP_DEBUGF(DNS_DEBUG, ("dns_send: dns_servers[%"U16_F"] \"%s\": request\n",
(u16_t)(entry->server_idx), entry->name)); (u16_t)(entry->server_idx), entry->name));
@ -771,7 +771,7 @@ dns_send(u8_t idx)
p = pbuf_alloc(PBUF_TRANSPORT, (u16_t)(SIZEOF_DNS_HDR + strlen(entry->name) + 2 + p = pbuf_alloc(PBUF_TRANSPORT, (u16_t)(SIZEOF_DNS_HDR + strlen(entry->name) + 2 +
SIZEOF_DNS_QUERY), PBUF_RAM); SIZEOF_DNS_QUERY), PBUF_RAM);
if (p != NULL) { if (p != NULL) {
const ip_addr_t* dst; const ip_addr_t *dst;
u16_t dst_port; u16_t dst_port;
/* fill dns header */ /* fill dns header */
memset(&hdr, 0, SIZEOF_DNS_HDR); memset(&hdr, 0, SIZEOF_DNS_HDR);
@ -823,8 +823,7 @@ dns_send(u8_t idx)
if (entry->is_mdns) { if (entry->is_mdns) {
dst_port = DNS_MQUERY_PORT; dst_port = DNS_MQUERY_PORT;
#if LWIP_IPV6 #if LWIP_IPV6
if (LWIP_DNS_ADDRTYPE_IS_IPV6(entry->reqaddrtype)) if (LWIP_DNS_ADDRTYPE_IS_IPV6(entry->reqaddrtype)) {
{
dst = &dns_mquery_v6group; dst = &dns_mquery_v6group;
} }
#endif #endif
@ -857,11 +856,11 @@ overflow_return:
} }
#if ((LWIP_DNS_SECURE & LWIP_DNS_SECURE_RAND_SRC_PORT) != 0) #if ((LWIP_DNS_SECURE & LWIP_DNS_SECURE_RAND_SRC_PORT) != 0)
static struct udp_pcb* static struct udp_pcb *
dns_alloc_random_port(void) dns_alloc_random_port(void)
{ {
err_t err; err_t err;
struct udp_pcb* pcb; struct udp_pcb *pcb;
pcb = udp_new_ip_type(IPADDR_TYPE_ANY); pcb = udp_new_ip_type(IPADDR_TYPE_ANY);
if (pcb == NULL) { if (pcb == NULL) {
@ -934,7 +933,7 @@ dns_alloc_pcb(void)
* @param addr IP address for the hostname (or NULL on error or memory shortage) * @param addr IP address for the hostname (or NULL on error or memory shortage)
*/ */
static void static void
dns_call_found(u8_t idx, ip_addr_t* addr) dns_call_found(u8_t idx, ip_addr_t *addr)
{ {
#if ((LWIP_DNS_SECURE & (LWIP_DNS_SECURE_NO_MULTIPLE_OUTSTANDING | LWIP_DNS_SECURE_RAND_SRC_PORT)) != 0) #if ((LWIP_DNS_SECURE & (LWIP_DNS_SECURE_NO_MULTIPLE_OUTSTANDING | LWIP_DNS_SECURE_RAND_SRC_PORT)) != 0)
u8_t i; u8_t i;
@ -1342,7 +1341,7 @@ dns_enqueue(const char *name, size_t hostnamelen, dns_found_callback found,
u8_t lseq, lseqi; u8_t lseq, lseqi;
struct dns_table_entry *entry = NULL; struct dns_table_entry *entry = NULL;
size_t namelen; size_t namelen;
struct dns_req_entry* req; struct dns_req_entry *req;
#if ((LWIP_DNS_SECURE & LWIP_DNS_SECURE_NO_MULTIPLE_OUTSTANDING) != 0) #if ((LWIP_DNS_SECURE & LWIP_DNS_SECURE_NO_MULTIPLE_OUTSTANDING) != 0)
u8_t r; u8_t r;
@ -1436,7 +1435,7 @@ dns_enqueue(const char *name, size_t hostnamelen, dns_found_callback found,
LWIP_DNS_SET_ADDRTYPE(req->reqaddrtype, dns_addrtype); LWIP_DNS_SET_ADDRTYPE(req->reqaddrtype, dns_addrtype);
req->found = found; req->found = found;
req->arg = callback_arg; req->arg = callback_arg;
namelen = LWIP_MIN(hostnamelen, DNS_MAX_NAME_LENGTH-1); namelen = LWIP_MIN(hostnamelen, DNS_MAX_NAME_LENGTH - 1);
MEMCPY(entry->name, name, namelen); MEMCPY(entry->name, name, namelen);
entry->name[namelen] = 0; entry->name[namelen] = 0;

View File

@ -85,7 +85,7 @@ lwip_standard_chksum(const void *dataptr, int len)
acc = 0; acc = 0;
/* dataptr may be at odd or even addresses */ /* dataptr may be at odd or even addresses */
octetptr = (const u8_t*)dataptr; octetptr = (const u8_t *)dataptr;
while (len > 1) { while (len > 1) {
/* declare first octet as most significant /* declare first octet as most significant
thus assume network order, ignoring host order */ thus assume network order, ignoring host order */
@ -201,14 +201,14 @@ lwip_standard_chksum(const void *dataptr, int len)
len--; len--;
} }
ps = (const u16_t *)(const void*)pb; ps = (const u16_t *)(const void *)pb;
if (((mem_ptr_t)ps & 3) && len > 1) { if (((mem_ptr_t)ps & 3) && len > 1) {
sum += *ps++; sum += *ps++;
len -= 2; len -= 2;
} }
pl = (const u32_t *)(const void*)ps; pl = (const u32_t *)(const void *)ps;
while (len > 7) { while (len > 7) {
tmp = sum + *pl++; /* ping */ tmp = sum + *pl++; /* ping */

View File

@ -67,8 +67,7 @@
# include "arch/bpstruct.h" # include "arch/bpstruct.h"
#endif #endif
PACK_STRUCT_BEGIN PACK_STRUCT_BEGIN
struct packed_struct_test struct packed_struct_test {
{
PACK_STRUCT_FLD_8(u8_t dummy1); PACK_STRUCT_FLD_8(u8_t dummy1);
PACK_STRUCT_FIELD(u32_t dummy2); PACK_STRUCT_FIELD(u32_t dummy2);
} PACK_STRUCT_STRUCT; } PACK_STRUCT_STRUCT;
@ -84,85 +83,85 @@ PACK_STRUCT_END
* These can be done independently of LWIP_DEBUG, without penalty. * These can be done independently of LWIP_DEBUG, without penalty.
*/ */
#ifndef BYTE_ORDER #ifndef BYTE_ORDER
#error "BYTE_ORDER is not defined, you have to define it in your cc.h" #error "BYTE_ORDER is not defined, you have to define it in your cc.h"
#endif #endif
#if (!IP_SOF_BROADCAST && IP_SOF_BROADCAST_RECV) #if (!IP_SOF_BROADCAST && IP_SOF_BROADCAST_RECV)
#error "If you want to use broadcast filter per pcb on recv operations, you have to define IP_SOF_BROADCAST=1 in your lwipopts.h" #error "If you want to use broadcast filter per pcb on recv operations, you have to define IP_SOF_BROADCAST=1 in your lwipopts.h"
#endif #endif
#if (!LWIP_UDP && LWIP_UDPLITE) #if (!LWIP_UDP && LWIP_UDPLITE)
#error "If you want to use UDP Lite, you have to define LWIP_UDP=1 in your lwipopts.h" #error "If you want to use UDP Lite, you have to define LWIP_UDP=1 in your lwipopts.h"
#endif #endif
#if (!LWIP_UDP && LWIP_DHCP) #if (!LWIP_UDP && LWIP_DHCP)
#error "If you want to use DHCP, you have to define LWIP_UDP=1 in your lwipopts.h" #error "If you want to use DHCP, you have to define LWIP_UDP=1 in your lwipopts.h"
#endif #endif
#if (!LWIP_UDP && !LWIP_RAW && LWIP_MULTICAST_TX_OPTIONS) #if (!LWIP_UDP && !LWIP_RAW && LWIP_MULTICAST_TX_OPTIONS)
#error "If you want to use LWIP_MULTICAST_TX_OPTIONS, you have to define LWIP_UDP=1 and/or LWIP_RAW=1 in your lwipopts.h" #error "If you want to use LWIP_MULTICAST_TX_OPTIONS, you have to define LWIP_UDP=1 and/or LWIP_RAW=1 in your lwipopts.h"
#endif #endif
#if (!LWIP_UDP && LWIP_DNS) #if (!LWIP_UDP && LWIP_DNS)
#error "If you want to use DNS, you have to define LWIP_UDP=1 in your lwipopts.h" #error "If you want to use DNS, you have to define LWIP_UDP=1 in your lwipopts.h"
#endif #endif
#if !MEMP_MEM_MALLOC /* MEMP_NUM_* checks are disabled when not using the pool allocator */ #if !MEMP_MEM_MALLOC /* MEMP_NUM_* checks are disabled when not using the pool allocator */
#if (LWIP_ARP && ARP_QUEUEING && (MEMP_NUM_ARP_QUEUE<=0)) #if (LWIP_ARP && ARP_QUEUEING && (MEMP_NUM_ARP_QUEUE<=0))
#error "If you want to use ARP Queueing, you have to define MEMP_NUM_ARP_QUEUE>=1 in your lwipopts.h" #error "If you want to use ARP Queueing, you have to define MEMP_NUM_ARP_QUEUE>=1 in your lwipopts.h"
#endif #endif
#if (LWIP_RAW && (MEMP_NUM_RAW_PCB<=0)) #if (LWIP_RAW && (MEMP_NUM_RAW_PCB<=0))
#error "If you want to use RAW, you have to define MEMP_NUM_RAW_PCB>=1 in your lwipopts.h" #error "If you want to use RAW, you have to define MEMP_NUM_RAW_PCB>=1 in your lwipopts.h"
#endif #endif
#if (LWIP_UDP && (MEMP_NUM_UDP_PCB<=0)) #if (LWIP_UDP && (MEMP_NUM_UDP_PCB<=0))
#error "If you want to use UDP, you have to define MEMP_NUM_UDP_PCB>=1 in your lwipopts.h" #error "If you want to use UDP, you have to define MEMP_NUM_UDP_PCB>=1 in your lwipopts.h"
#endif #endif
#if (LWIP_TCP && (MEMP_NUM_TCP_PCB<=0)) #if (LWIP_TCP && (MEMP_NUM_TCP_PCB<=0))
#error "If you want to use TCP, you have to define MEMP_NUM_TCP_PCB>=1 in your lwipopts.h" #error "If you want to use TCP, you have to define MEMP_NUM_TCP_PCB>=1 in your lwipopts.h"
#endif #endif
#if (LWIP_IGMP && (MEMP_NUM_IGMP_GROUP<=1)) #if (LWIP_IGMP && (MEMP_NUM_IGMP_GROUP<=1))
#error "If you want to use IGMP, you have to define MEMP_NUM_IGMP_GROUP>1 in your lwipopts.h" #error "If you want to use IGMP, you have to define MEMP_NUM_IGMP_GROUP>1 in your lwipopts.h"
#endif #endif
#if (LWIP_IGMP && !LWIP_MULTICAST_TX_OPTIONS) #if (LWIP_IGMP && !LWIP_MULTICAST_TX_OPTIONS)
#error "If you want to use IGMP, you have to define LWIP_MULTICAST_TX_OPTIONS==1 in your lwipopts.h" #error "If you want to use IGMP, you have to define LWIP_MULTICAST_TX_OPTIONS==1 in your lwipopts.h"
#endif #endif
#if (LWIP_IGMP && !LWIP_IPV4) #if (LWIP_IGMP && !LWIP_IPV4)
#error "IGMP needs LWIP_IPV4 enabled in your lwipopts.h" #error "IGMP needs LWIP_IPV4 enabled in your lwipopts.h"
#endif #endif
#if ((LWIP_NETCONN || LWIP_SOCKET) && (MEMP_NUM_TCPIP_MSG_API<=0)) #if ((LWIP_NETCONN || LWIP_SOCKET) && (MEMP_NUM_TCPIP_MSG_API<=0))
#error "If you want to use Sequential API, you have to define MEMP_NUM_TCPIP_MSG_API>=1 in your lwipopts.h" #error "If you want to use Sequential API, you have to define MEMP_NUM_TCPIP_MSG_API>=1 in your lwipopts.h"
#endif #endif
/* There must be sufficient timeouts, taking into account requirements of the subsystems. */ /* There must be sufficient timeouts, taking into account requirements of the subsystems. */
#if LWIP_TIMERS && (MEMP_NUM_SYS_TIMEOUT < LWIP_NUM_SYS_TIMEOUT_INTERNAL) #if LWIP_TIMERS && (MEMP_NUM_SYS_TIMEOUT < LWIP_NUM_SYS_TIMEOUT_INTERNAL)
#error "MEMP_NUM_SYS_TIMEOUT is too low to accomodate all required timeouts" #error "MEMP_NUM_SYS_TIMEOUT is too low to accomodate all required timeouts"
#endif #endif
#if (IP_REASSEMBLY && (MEMP_NUM_REASSDATA > IP_REASS_MAX_PBUFS)) #if (IP_REASSEMBLY && (MEMP_NUM_REASSDATA > IP_REASS_MAX_PBUFS))
#error "MEMP_NUM_REASSDATA > IP_REASS_MAX_PBUFS doesn't make sense since each struct ip_reassdata must hold 2 pbufs at least!" #error "MEMP_NUM_REASSDATA > IP_REASS_MAX_PBUFS doesn't make sense since each struct ip_reassdata must hold 2 pbufs at least!"
#endif #endif
#endif /* !MEMP_MEM_MALLOC */ #endif /* !MEMP_MEM_MALLOC */
#if LWIP_WND_SCALE #if LWIP_WND_SCALE
#if (LWIP_TCP && (TCP_WND > 0xffffffff)) #if (LWIP_TCP && (TCP_WND > 0xffffffff))
#error "If you want to use TCP, TCP_WND must fit in an u32_t, so, you have to reduce it in your lwipopts.h" #error "If you want to use TCP, TCP_WND must fit in an u32_t, so, you have to reduce it in your lwipopts.h"
#endif #endif
#if (LWIP_TCP && (TCP_RCV_SCALE > 14)) #if (LWIP_TCP && (TCP_RCV_SCALE > 14))
#error "The maximum valid window scale value is 14!" #error "The maximum valid window scale value is 14!"
#endif #endif
#if (LWIP_TCP && (TCP_WND > (0xFFFFU << TCP_RCV_SCALE))) #if (LWIP_TCP && (TCP_WND > (0xFFFFU << TCP_RCV_SCALE)))
#error "TCP_WND is bigger than the configured LWIP_WND_SCALE allows!" #error "TCP_WND is bigger than the configured LWIP_WND_SCALE allows!"
#endif #endif
#if (LWIP_TCP && ((TCP_WND >> TCP_RCV_SCALE) == 0)) #if (LWIP_TCP && ((TCP_WND >> TCP_RCV_SCALE) == 0))
#error "TCP_WND is too small for the configured LWIP_WND_SCALE (results in zero window)!" #error "TCP_WND is too small for the configured LWIP_WND_SCALE (results in zero window)!"
#endif #endif
#else /* LWIP_WND_SCALE */ #else /* LWIP_WND_SCALE */
#if (LWIP_TCP && (TCP_WND > 0xffff)) #if (LWIP_TCP && (TCP_WND > 0xffff))
#error "If you want to use TCP, TCP_WND must fit in an u16_t, so, you have to reduce it in your lwipopts.h (or enable window scaling)" #error "If you want to use TCP, TCP_WND must fit in an u16_t, so, you have to reduce it in your lwipopts.h (or enable window scaling)"
#endif #endif
#endif /* LWIP_WND_SCALE */ #endif /* LWIP_WND_SCALE */
#if (LWIP_TCP && (TCP_SND_QUEUELEN > 0xffff)) #if (LWIP_TCP && (TCP_SND_QUEUELEN > 0xffff))
#error "If you want to use TCP, TCP_SND_QUEUELEN must fit in an u16_t, so, you have to reduce it in your lwipopts.h" #error "If you want to use TCP, TCP_SND_QUEUELEN must fit in an u16_t, so, you have to reduce it in your lwipopts.h"
#endif #endif
#if (LWIP_TCP && (TCP_SND_QUEUELEN < 2)) #if (LWIP_TCP && (TCP_SND_QUEUELEN < 2))
#error "TCP_SND_QUEUELEN must be at least 2 for no-copy TCP writes to work" #error "TCP_SND_QUEUELEN must be at least 2 for no-copy TCP writes to work"
#endif #endif
#if (LWIP_TCP && ((TCP_MAXRTX > 12) || (TCP_SYNMAXRTX > 12))) #if (LWIP_TCP && ((TCP_MAXRTX > 12) || (TCP_SYNMAXRTX > 12)))
#error "If you want to use TCP, TCP_MAXRTX and TCP_SYNMAXRTX must less or equal to 12 (due to tcp_backoff table), so, you have to reduce them in your lwipopts.h" #error "If you want to use TCP, TCP_MAXRTX and TCP_SYNMAXRTX must less or equal to 12 (due to tcp_backoff table), so, you have to reduce them in your lwipopts.h"
#endif #endif
#if (LWIP_TCP && TCP_LISTEN_BACKLOG && ((TCP_DEFAULT_LISTEN_BACKLOG < 0) || (TCP_DEFAULT_LISTEN_BACKLOG > 0xff))) #if (LWIP_TCP && TCP_LISTEN_BACKLOG && ((TCP_DEFAULT_LISTEN_BACKLOG < 0) || (TCP_DEFAULT_LISTEN_BACKLOG > 0xff)))
#error "If you want to use TCP backlog, TCP_DEFAULT_LISTEN_BACKLOG must fit into an u8_t" #error "If you want to use TCP backlog, TCP_DEFAULT_LISTEN_BACKLOG must fit into an u8_t"
#endif #endif
#if (LWIP_TCP && LWIP_TCP_SACK_OUT && !TCP_QUEUE_OOSEQ) #if (LWIP_TCP && LWIP_TCP_SACK_OUT && !TCP_QUEUE_OOSEQ)
#error "To use LWIP_TCP_SACK_OUT, TCP_QUEUE_OOSEQ needs to be enabled" #error "To use LWIP_TCP_SACK_OUT, TCP_QUEUE_OOSEQ needs to be enabled"
@ -171,80 +170,80 @@ PACK_STRUCT_END
#error "LWIP_TCP_MAX_SACK_NUM must be greater than 0" #error "LWIP_TCP_MAX_SACK_NUM must be greater than 0"
#endif #endif
#if (LWIP_NETIF_API && (NO_SYS==1)) #if (LWIP_NETIF_API && (NO_SYS==1))
#error "If you want to use NETIF API, you have to define NO_SYS=0 in your lwipopts.h" #error "If you want to use NETIF API, you have to define NO_SYS=0 in your lwipopts.h"
#endif #endif
#if ((LWIP_SOCKET || LWIP_NETCONN) && (NO_SYS==1)) #if ((LWIP_SOCKET || LWIP_NETCONN) && (NO_SYS==1))
#error "If you want to use Sequential API, you have to define NO_SYS=0 in your lwipopts.h" #error "If you want to use Sequential API, you have to define NO_SYS=0 in your lwipopts.h"
#endif #endif
#if (LWIP_PPP_API && (NO_SYS==1)) #if (LWIP_PPP_API && (NO_SYS==1))
#error "If you want to use PPP API, you have to define NO_SYS=0 in your lwipopts.h" #error "If you want to use PPP API, you have to define NO_SYS=0 in your lwipopts.h"
#endif #endif
#if (LWIP_PPP_API && (PPP_SUPPORT==0)) #if (LWIP_PPP_API && (PPP_SUPPORT==0))
#error "If you want to use PPP API, you have to enable PPP_SUPPORT in your lwipopts.h" #error "If you want to use PPP API, you have to enable PPP_SUPPORT in your lwipopts.h"
#endif #endif
#if (((!LWIP_DHCP) || (!LWIP_AUTOIP)) && LWIP_DHCP_AUTOIP_COOP) #if (((!LWIP_DHCP) || (!LWIP_AUTOIP)) && LWIP_DHCP_AUTOIP_COOP)
#error "If you want to use DHCP/AUTOIP cooperation mode, you have to define LWIP_DHCP=1 and LWIP_AUTOIP=1 in your lwipopts.h" #error "If you want to use DHCP/AUTOIP cooperation mode, you have to define LWIP_DHCP=1 and LWIP_AUTOIP=1 in your lwipopts.h"
#endif #endif
#if (((!LWIP_DHCP) || (!LWIP_ARP)) && DHCP_DOES_ARP_CHECK) #if (((!LWIP_DHCP) || (!LWIP_ARP)) && DHCP_DOES_ARP_CHECK)
#error "If you want to use DHCP ARP checking, you have to define LWIP_DHCP=1 and LWIP_ARP=1 in your lwipopts.h" #error "If you want to use DHCP ARP checking, you have to define LWIP_DHCP=1 and LWIP_ARP=1 in your lwipopts.h"
#endif #endif
#if (!LWIP_ARP && LWIP_AUTOIP) #if (!LWIP_ARP && LWIP_AUTOIP)
#error "If you want to use AUTOIP, you have to define LWIP_ARP=1 in your lwipopts.h" #error "If you want to use AUTOIP, you have to define LWIP_ARP=1 in your lwipopts.h"
#endif #endif
#if (LWIP_TCP && ((LWIP_EVENT_API && LWIP_CALLBACK_API) || (!LWIP_EVENT_API && !LWIP_CALLBACK_API))) #if (LWIP_TCP && ((LWIP_EVENT_API && LWIP_CALLBACK_API) || (!LWIP_EVENT_API && !LWIP_CALLBACK_API)))
#error "One and exactly one of LWIP_EVENT_API and LWIP_CALLBACK_API has to be enabled in your lwipopts.h" #error "One and exactly one of LWIP_EVENT_API and LWIP_CALLBACK_API has to be enabled in your lwipopts.h"
#endif #endif
#if (MEM_LIBC_MALLOC && MEM_USE_POOLS) #if (MEM_LIBC_MALLOC && MEM_USE_POOLS)
#error "MEM_LIBC_MALLOC and MEM_USE_POOLS may not both be simultaneously enabled in your lwipopts.h" #error "MEM_LIBC_MALLOC and MEM_USE_POOLS may not both be simultaneously enabled in your lwipopts.h"
#endif #endif
#if (MEM_USE_POOLS && !MEMP_USE_CUSTOM_POOLS) #if (MEM_USE_POOLS && !MEMP_USE_CUSTOM_POOLS)
#error "MEM_USE_POOLS requires custom pools (MEMP_USE_CUSTOM_POOLS) to be enabled in your lwipopts.h" #error "MEM_USE_POOLS requires custom pools (MEMP_USE_CUSTOM_POOLS) to be enabled in your lwipopts.h"
#endif #endif
#if (PBUF_POOL_BUFSIZE <= MEM_ALIGNMENT) #if (PBUF_POOL_BUFSIZE <= MEM_ALIGNMENT)
#error "PBUF_POOL_BUFSIZE must be greater than MEM_ALIGNMENT or the offset may take the full first pbuf" #error "PBUF_POOL_BUFSIZE must be greater than MEM_ALIGNMENT or the offset may take the full first pbuf"
#endif #endif
#if (DNS_LOCAL_HOSTLIST && !DNS_LOCAL_HOSTLIST_IS_DYNAMIC && !(defined(DNS_LOCAL_HOSTLIST_INIT))) #if (DNS_LOCAL_HOSTLIST && !DNS_LOCAL_HOSTLIST_IS_DYNAMIC && !(defined(DNS_LOCAL_HOSTLIST_INIT)))
#error "you have to define define DNS_LOCAL_HOSTLIST_INIT {{'host1', 0x123}, {'host2', 0x234}} to initialize DNS_LOCAL_HOSTLIST" #error "you have to define define DNS_LOCAL_HOSTLIST_INIT {{'host1', 0x123}, {'host2', 0x234}} to initialize DNS_LOCAL_HOSTLIST"
#endif #endif
#if PPP_SUPPORT && !PPPOS_SUPPORT && !PPPOE_SUPPORT && !PPPOL2TP_SUPPORT #if PPP_SUPPORT && !PPPOS_SUPPORT && !PPPOE_SUPPORT && !PPPOL2TP_SUPPORT
#error "PPP_SUPPORT needs at least one of PPPOS_SUPPORT, PPPOE_SUPPORT or PPPOL2TP_SUPPORT turned on" #error "PPP_SUPPORT needs at least one of PPPOS_SUPPORT, PPPOE_SUPPORT or PPPOL2TP_SUPPORT turned on"
#endif #endif
#if PPP_SUPPORT && !PPP_IPV4_SUPPORT && !PPP_IPV6_SUPPORT #if PPP_SUPPORT && !PPP_IPV4_SUPPORT && !PPP_IPV6_SUPPORT
#error "PPP_SUPPORT needs PPP_IPV4_SUPPORT and/or PPP_IPV6_SUPPORT turned on" #error "PPP_SUPPORT needs PPP_IPV4_SUPPORT and/or PPP_IPV6_SUPPORT turned on"
#endif #endif
#if PPP_SUPPORT && PPP_IPV4_SUPPORT && !LWIP_IPV4 #if PPP_SUPPORT && PPP_IPV4_SUPPORT && !LWIP_IPV4
#error "PPP_IPV4_SUPPORT needs LWIP_IPV4 turned on" #error "PPP_IPV4_SUPPORT needs LWIP_IPV4 turned on"
#endif #endif
#if PPP_SUPPORT && PPP_IPV6_SUPPORT && !LWIP_IPV6 #if PPP_SUPPORT && PPP_IPV6_SUPPORT && !LWIP_IPV6
#error "PPP_IPV6_SUPPORT needs LWIP_IPV6 turned on" #error "PPP_IPV6_SUPPORT needs LWIP_IPV6 turned on"
#endif #endif
#if !LWIP_ETHERNET && (LWIP_ARP || PPPOE_SUPPORT) #if !LWIP_ETHERNET && (LWIP_ARP || PPPOE_SUPPORT)
#error "LWIP_ETHERNET needs to be turned on for LWIP_ARP or PPPOE_SUPPORT" #error "LWIP_ETHERNET needs to be turned on for LWIP_ARP or PPPOE_SUPPORT"
#endif #endif
#if LWIP_TCPIP_CORE_LOCKING_INPUT && !LWIP_TCPIP_CORE_LOCKING #if LWIP_TCPIP_CORE_LOCKING_INPUT && !LWIP_TCPIP_CORE_LOCKING
#error "When using LWIP_TCPIP_CORE_LOCKING_INPUT, LWIP_TCPIP_CORE_LOCKING must be enabled, too" #error "When using LWIP_TCPIP_CORE_LOCKING_INPUT, LWIP_TCPIP_CORE_LOCKING must be enabled, too"
#endif #endif
#if LWIP_TCP && LWIP_NETIF_TX_SINGLE_PBUF && !TCP_OVERSIZE #if LWIP_TCP && LWIP_NETIF_TX_SINGLE_PBUF && !TCP_OVERSIZE
#error "LWIP_NETIF_TX_SINGLE_PBUF needs TCP_OVERSIZE enabled to create single-pbuf TCP packets" #error "LWIP_NETIF_TX_SINGLE_PBUF needs TCP_OVERSIZE enabled to create single-pbuf TCP packets"
#endif #endif
#if LWIP_NETCONN && LWIP_TCP #if LWIP_NETCONN && LWIP_TCP
#if NETCONN_COPY != TCP_WRITE_FLAG_COPY #if NETCONN_COPY != TCP_WRITE_FLAG_COPY
#error "NETCONN_COPY != TCP_WRITE_FLAG_COPY" #error "NETCONN_COPY != TCP_WRITE_FLAG_COPY"
#endif #endif
#if NETCONN_MORE != TCP_WRITE_FLAG_MORE #if NETCONN_MORE != TCP_WRITE_FLAG_MORE
#error "NETCONN_MORE != TCP_WRITE_FLAG_MORE" #error "NETCONN_MORE != TCP_WRITE_FLAG_MORE"
#endif #endif
#endif /* LWIP_NETCONN && LWIP_TCP */ #endif /* LWIP_NETCONN && LWIP_TCP */
#if LWIP_SOCKET #if LWIP_SOCKET
/* Check that the SO_* socket options and SOF_* lwIP-internal flags match */ /* Check that the SO_* socket options and SOF_* lwIP-internal flags match */
#if SO_REUSEADDR != SOF_REUSEADDR #if SO_REUSEADDR != SOF_REUSEADDR
#error "WARNING: SO_REUSEADDR != SOF_REUSEADDR" #error "WARNING: SO_REUSEADDR != SOF_REUSEADDR"
#endif #endif
#if SO_KEEPALIVE != SOF_KEEPALIVE #if SO_KEEPALIVE != SOF_KEEPALIVE
#error "WARNING: SO_KEEPALIVE != SOF_KEEPALIVE" #error "WARNING: SO_KEEPALIVE != SOF_KEEPALIVE"
#endif #endif
#if SO_BROADCAST != SOF_BROADCAST #if SO_BROADCAST != SOF_BROADCAST
#error "WARNING: SO_BROADCAST != SOF_BROADCAST" #error "WARNING: SO_BROADCAST != SOF_BROADCAST"
#endif #endif
#endif /* LWIP_SOCKET */ #endif /* LWIP_SOCKET */
@ -252,22 +251,22 @@ PACK_STRUCT_END
/* Compile-time checks for deprecated options. /* Compile-time checks for deprecated options.
*/ */
#ifdef MEMP_NUM_TCPIP_MSG #ifdef MEMP_NUM_TCPIP_MSG
#error "MEMP_NUM_TCPIP_MSG option is deprecated. Remove it from your lwipopts.h." #error "MEMP_NUM_TCPIP_MSG option is deprecated. Remove it from your lwipopts.h."
#endif #endif
#ifdef TCP_REXMIT_DEBUG #ifdef TCP_REXMIT_DEBUG
#error "TCP_REXMIT_DEBUG option is deprecated. Remove it from your lwipopts.h." #error "TCP_REXMIT_DEBUG option is deprecated. Remove it from your lwipopts.h."
#endif #endif
#ifdef RAW_STATS #ifdef RAW_STATS
#error "RAW_STATS option is deprecated. Remove it from your lwipopts.h." #error "RAW_STATS option is deprecated. Remove it from your lwipopts.h."
#endif #endif
#ifdef ETHARP_QUEUE_FIRST #ifdef ETHARP_QUEUE_FIRST
#error "ETHARP_QUEUE_FIRST option is deprecated. Remove it from your lwipopts.h." #error "ETHARP_QUEUE_FIRST option is deprecated. Remove it from your lwipopts.h."
#endif #endif
#ifdef ETHARP_ALWAYS_INSERT #ifdef ETHARP_ALWAYS_INSERT
#error "ETHARP_ALWAYS_INSERT option is deprecated. Remove it from your lwipopts.h." #error "ETHARP_ALWAYS_INSERT option is deprecated. Remove it from your lwipopts.h."
#endif #endif
#if !NO_SYS && LWIP_TCPIP_CORE_LOCKING && LWIP_COMPAT_MUTEX && !defined(LWIP_COMPAT_MUTEX_ALLOWED) #if !NO_SYS && LWIP_TCPIP_CORE_LOCKING && LWIP_COMPAT_MUTEX && !defined(LWIP_COMPAT_MUTEX_ALLOWED)
#error "LWIP_COMPAT_MUTEX cannot prevent priority inversion. It is recommended to implement priority-aware mutexes. (Define LWIP_COMPAT_MUTEX_ALLOWED to disable this error.)" #error "LWIP_COMPAT_MUTEX cannot prevent priority inversion. It is recommended to implement priority-aware mutexes. (Define LWIP_COMPAT_MUTEX_ALLOWED to disable this error.)"
#endif #endif
#ifndef LWIP_DISABLE_TCP_SANITY_CHECKS #ifndef LWIP_DISABLE_TCP_SANITY_CHECKS
@ -302,31 +301,31 @@ PACK_STRUCT_END
#if !LWIP_DISABLE_TCP_SANITY_CHECKS #if !LWIP_DISABLE_TCP_SANITY_CHECKS
#if LWIP_TCP #if LWIP_TCP
#if !MEMP_MEM_MALLOC && (MEMP_NUM_TCP_SEG < TCP_SND_QUEUELEN) #if !MEMP_MEM_MALLOC && (MEMP_NUM_TCP_SEG < TCP_SND_QUEUELEN)
#error "lwip_sanity_check: WARNING: MEMP_NUM_TCP_SEG should be at least as big as TCP_SND_QUEUELEN. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." #error "lwip_sanity_check: WARNING: MEMP_NUM_TCP_SEG should be at least as big as TCP_SND_QUEUELEN. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error."
#endif #endif
#if TCP_SND_BUF < (2 * TCP_MSS) #if TCP_SND_BUF < (2 * TCP_MSS)
#error "lwip_sanity_check: WARNING: TCP_SND_BUF must be at least as much as (2 * TCP_MSS) for things to work smoothly. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." #error "lwip_sanity_check: WARNING: TCP_SND_BUF must be at least as much as (2 * TCP_MSS) for things to work smoothly. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error."
#endif #endif
#if TCP_SND_QUEUELEN < (2 * (TCP_SND_BUF / TCP_MSS)) #if TCP_SND_QUEUELEN < (2 * (TCP_SND_BUF / TCP_MSS))
#error "lwip_sanity_check: WARNING: TCP_SND_QUEUELEN must be at least as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." #error "lwip_sanity_check: WARNING: TCP_SND_QUEUELEN must be at least as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error."
#endif #endif
#if TCP_SNDLOWAT >= TCP_SND_BUF #if TCP_SNDLOWAT >= TCP_SND_BUF
#error "lwip_sanity_check: WARNING: TCP_SNDLOWAT must be less than TCP_SND_BUF. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." #error "lwip_sanity_check: WARNING: TCP_SNDLOWAT must be less than TCP_SND_BUF. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error."
#endif #endif
#if TCP_SNDLOWAT >= (0xFFFF - (4 * TCP_MSS)) #if TCP_SNDLOWAT >= (0xFFFF - (4 * TCP_MSS))
#error "lwip_sanity_check: WARNING: TCP_SNDLOWAT must at least be 4*MSS below u16_t overflow!" #error "lwip_sanity_check: WARNING: TCP_SNDLOWAT must at least be 4*MSS below u16_t overflow!"
#endif #endif
#if TCP_SNDQUEUELOWAT >= TCP_SND_QUEUELEN #if TCP_SNDQUEUELOWAT >= TCP_SND_QUEUELEN
#error "lwip_sanity_check: WARNING: TCP_SNDQUEUELOWAT must be less than TCP_SND_QUEUELEN. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." #error "lwip_sanity_check: WARNING: TCP_SNDQUEUELOWAT must be less than TCP_SND_QUEUELEN. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error."
#endif #endif
#if !MEMP_MEM_MALLOC && PBUF_POOL_SIZE && (PBUF_POOL_BUFSIZE <= (PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN)) #if !MEMP_MEM_MALLOC && PBUF_POOL_SIZE && (PBUF_POOL_BUFSIZE <= (PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN))
#error "lwip_sanity_check: WARNING: PBUF_POOL_BUFSIZE does not provide enough space for protocol headers. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." #error "lwip_sanity_check: WARNING: PBUF_POOL_BUFSIZE does not provide enough space for protocol headers. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error."
#endif #endif
#if !MEMP_MEM_MALLOC && PBUF_POOL_SIZE && (TCP_WND > (PBUF_POOL_SIZE * (PBUF_POOL_BUFSIZE - (PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN)))) #if !MEMP_MEM_MALLOC && PBUF_POOL_SIZE && (TCP_WND > (PBUF_POOL_SIZE * (PBUF_POOL_BUFSIZE - (PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN))))
#error "lwip_sanity_check: WARNING: TCP_WND is larger than space provided by PBUF_POOL_SIZE * (PBUF_POOL_BUFSIZE - protocol headers). If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." #error "lwip_sanity_check: WARNING: TCP_WND is larger than space provided by PBUF_POOL_SIZE * (PBUF_POOL_BUFSIZE - protocol headers). If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error."
#endif #endif
#if TCP_WND < TCP_MSS #if TCP_WND < TCP_MSS
#error "lwip_sanity_check: WARNING: TCP_WND is smaller than MSS. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." #error "lwip_sanity_check: WARNING: TCP_WND is smaller than MSS. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error."
#endif #endif
#endif /* LWIP_TCP */ #endif /* LWIP_TCP */
#endif /* !LWIP_DISABLE_TCP_SANITY_CHECKS */ #endif /* !LWIP_DISABLE_TCP_SANITY_CHECKS */
@ -342,7 +341,7 @@ lwip_init(void)
#ifndef LWIP_SKIP_CONST_CHECK #ifndef LWIP_SKIP_CONST_CHECK
int a = 0; int a = 0;
LWIP_UNUSED_ARG(a); LWIP_UNUSED_ARG(a);
LWIP_ASSERT("LWIP_CONST_CAST not implemented correctly. Check your lwIP port.", LWIP_CONST_CAST(void*, &a) == &a); LWIP_ASSERT("LWIP_CONST_CAST not implemented correctly. Check your lwIP port.", LWIP_CONST_CAST(void *, &a) == &a);
#endif #endif
#ifndef LWIP_SKIP_PACKING_CHECK #ifndef LWIP_SKIP_PACKING_CHECK
LWIP_ASSERT("Struct packing not implemented correctly. Check your lwIP port.", sizeof(struct packed_struct_test) == PACKED_STRUCT_TEST_EXPECTED_SIZE); LWIP_ASSERT("Struct packing not implemented correctly. Check your lwIP port.", sizeof(struct packed_struct_test) == PACKED_STRUCT_TEST_EXPECTED_SIZE);

View File

@ -123,7 +123,7 @@ int
ipaddr_aton(const char *cp, ip_addr_t *addr) ipaddr_aton(const char *cp, ip_addr_t *addr)
{ {
if (cp != NULL) { if (cp != NULL) {
const char* c; const char *c;
for (c = cp; *c != 0; c++) { for (c = cp; *c != 0; c++) {
if (*c == ':') { if (*c == ':') {
/* contains a colon: IPv6 address */ /* contains a colon: IPv6 address */

View File

@ -84,7 +84,7 @@ mem_init(void)
* C library malloc(): we can't free part of a pool element and the stack * C library malloc(): we can't free part of a pool element and the stack
* support mem_trim() to return a different pointer * support mem_trim() to return a different pointer
*/ */
void* void *
mem_trim(void *mem, mem_size_t size) mem_trim(void *mem, mem_size_t size)
{ {
LWIP_UNUSED_ARG(size); LWIP_UNUSED_ARG(size);
@ -125,14 +125,14 @@ mem_trim(void *mem, mem_size_t size)
void * void *
mem_malloc(mem_size_t size) mem_malloc(mem_size_t size)
{ {
void* ret = mem_clib_malloc(size + MEM_LIBC_STATSHELPER_SIZE); void *ret = mem_clib_malloc(size + MEM_LIBC_STATSHELPER_SIZE);
if (ret == NULL) { if (ret == NULL) {
MEM_STATS_INC_LOCKED(err); MEM_STATS_INC_LOCKED(err);
} else { } else {
LWIP_ASSERT("malloc() must return aligned memory", LWIP_MEM_ALIGN(ret) == ret); LWIP_ASSERT("malloc() must return aligned memory", LWIP_MEM_ALIGN(ret) == ret);
#if LWIP_STATS && MEM_STATS #if LWIP_STATS && MEM_STATS
*(mem_size_t*)ret = size; *(mem_size_t *)ret = size;
ret = (u8_t*)ret + MEM_LIBC_STATSHELPER_SIZE; ret = (u8_t *)ret + MEM_LIBC_STATSHELPER_SIZE;
MEM_STATS_INC_USED_LOCKED(used, size); MEM_STATS_INC_USED_LOCKED(used, size);
#endif #endif
} }
@ -149,8 +149,8 @@ mem_free(void *rmem)
LWIP_ASSERT("rmem != NULL", (rmem != NULL)); LWIP_ASSERT("rmem != NULL", (rmem != NULL));
LWIP_ASSERT("rmem == MEM_ALIGN(rmem)", (rmem == LWIP_MEM_ALIGN(rmem))); LWIP_ASSERT("rmem == MEM_ALIGN(rmem)", (rmem == LWIP_MEM_ALIGN(rmem)));
#if LWIP_STATS && MEM_STATS #if LWIP_STATS && MEM_STATS
rmem = (u8_t*)rmem - MEM_LIBC_STATSHELPER_SIZE; rmem = (u8_t *)rmem - MEM_LIBC_STATSHELPER_SIZE;
MEM_STATS_DEC_USED_LOCKED(used, *(mem_size_t*)rmem); MEM_STATS_DEC_USED_LOCKED(used, *(mem_size_t *)rmem);
#endif #endif
mem_clib_free(rmem); mem_clib_free(rmem);
} }
@ -178,7 +178,7 @@ mem_malloc(mem_size_t size)
/* is this pool big enough to hold an element of the required size /* is this pool big enough to hold an element of the required size
plus a struct memp_malloc_helper that saves the pool this element came from? */ plus a struct memp_malloc_helper that saves the pool this element came from? */
if (required_size <= memp_pools[poolnr]->size) { if (required_size <= memp_pools[poolnr]->size) {
element = (struct memp_malloc_helper*)memp_malloc(poolnr); element = (struct memp_malloc_helper *)memp_malloc(poolnr);
if (element == NULL) { if (element == NULL) {
/* No need to DEBUGF or ASSERT: This error is already taken care of in memp.c */ /* No need to DEBUGF or ASSERT: This error is already taken care of in memp.c */
#if MEM_USE_POOLS_TRY_BIGGER_POOL #if MEM_USE_POOLS_TRY_BIGGER_POOL
@ -202,7 +202,7 @@ mem_malloc(mem_size_t size)
/* save the pool number this element came from */ /* save the pool number this element came from */
element->poolnr = poolnr; element->poolnr = poolnr;
/* and return a pointer to the memory directly after the struct memp_malloc_helper */ /* and return a pointer to the memory directly after the struct memp_malloc_helper */
ret = (u8_t*)element + LWIP_MEM_ALIGN_SIZE(sizeof(struct memp_malloc_helper)); ret = (u8_t *)element + LWIP_MEM_ALIGN_SIZE(sizeof(struct memp_malloc_helper));
#if MEMP_OVERFLOW_CHECK || (LWIP_STATS && MEM_STATS) #if MEMP_OVERFLOW_CHECK || (LWIP_STATS && MEM_STATS)
/* truncating to u16_t is safe because struct memp_desc::size is u16_t */ /* truncating to u16_t is safe because struct memp_desc::size is u16_t */
@ -211,7 +211,7 @@ mem_malloc(mem_size_t size)
#endif /* MEMP_OVERFLOW_CHECK || (LWIP_STATS && MEM_STATS) */ #endif /* MEMP_OVERFLOW_CHECK || (LWIP_STATS && MEM_STATS) */
#if MEMP_OVERFLOW_CHECK #if MEMP_OVERFLOW_CHECK
/* initialize unused memory (diff between requested size and selected pool's size) */ /* initialize unused memory (diff between requested size and selected pool's size) */
memset((u8_t*)ret + size, 0xcd, memp_pools[poolnr]->size - size); memset((u8_t *)ret + size, 0xcd, memp_pools[poolnr]->size - size);
#endif /* MEMP_OVERFLOW_CHECK */ #endif /* MEMP_OVERFLOW_CHECK */
return ret; return ret;
} }
@ -233,7 +233,7 @@ mem_free(void *rmem)
/* get the original struct memp_malloc_helper */ /* get the original struct memp_malloc_helper */
/* cast through void* to get rid of alignment warnings */ /* cast through void* to get rid of alignment warnings */
hmem = (struct memp_malloc_helper*)(void*)((u8_t*)rmem - LWIP_MEM_ALIGN_SIZE(sizeof(struct memp_malloc_helper))); hmem = (struct memp_malloc_helper *)(void *)((u8_t *)rmem - LWIP_MEM_ALIGN_SIZE(sizeof(struct memp_malloc_helper)));
LWIP_ASSERT("hmem != NULL", (hmem != NULL)); LWIP_ASSERT("hmem != NULL", (hmem != NULL));
LWIP_ASSERT("hmem == MEM_ALIGN(hmem)", (hmem == LWIP_MEM_ALIGN(hmem))); LWIP_ASSERT("hmem == MEM_ALIGN(hmem)", (hmem == LWIP_MEM_ALIGN(hmem)));
@ -247,7 +247,7 @@ mem_free(void *rmem)
hmem->size <= memp_pools[hmem->poolnr]->size); hmem->size <= memp_pools[hmem->poolnr]->size);
/* check that unused memory remained untouched (diff between requested size and selected pool's size) */ /* check that unused memory remained untouched (diff between requested size and selected pool's size) */
for (i = hmem->size; i < memp_pools[hmem->poolnr]->size; i++) { for (i = hmem->size; i < memp_pools[hmem->poolnr]->size; i++) {
u8_t data = *((u8_t*)rmem + i); u8_t data = *((u8_t *)rmem + i);
LWIP_ASSERT("MEM_USE_POOLS: mem overflow detected", data == 0xcd); LWIP_ASSERT("MEM_USE_POOLS: mem overflow detected", data == 0xcd);
} }
} }
@ -291,7 +291,7 @@ struct mem {
* how that space is calculated). */ * how that space is calculated). */
#ifndef LWIP_RAM_HEAP_POINTER #ifndef LWIP_RAM_HEAP_POINTER
/** the heap. we need one struct mem at the end and some room for alignment */ /** the heap. we need one struct mem at the end and some room for alignment */
LWIP_DECLARE_MEMORY_ALIGNED(ram_heap, MEM_SIZE_ALIGNED + (2U*SIZEOF_STRUCT_MEM)); LWIP_DECLARE_MEMORY_ALIGNED(ram_heap, MEM_SIZE_ALIGNED + (2U * SIZEOF_STRUCT_MEM));
#define LWIP_RAM_HEAP_POINTER ram_heap #define LWIP_RAM_HEAP_POINTER ram_heap
#endif /* LWIP_RAM_HEAP_POINTER */ #endif /* LWIP_RAM_HEAP_POINTER */
@ -388,7 +388,7 @@ mem_init(void)
struct mem *mem; struct mem *mem;
LWIP_ASSERT("Sanity check alignment", LWIP_ASSERT("Sanity check alignment",
(SIZEOF_STRUCT_MEM & (MEM_ALIGNMENT-1)) == 0); (SIZEOF_STRUCT_MEM & (MEM_ALIGNMENT - 1)) == 0);
/* align the heap */ /* align the heap */
ram = (u8_t *)LWIP_MEM_ALIGN(LWIP_RAM_HEAP_POINTER); ram = (u8_t *)LWIP_MEM_ALIGN(LWIP_RAM_HEAP_POINTER);
@ -429,7 +429,7 @@ mem_free(void *rmem)
LWIP_DEBUGF(MEM_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("mem_free(p == NULL) was called.\n")); LWIP_DEBUGF(MEM_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("mem_free(p == NULL) was called.\n"));
return; return;
} }
LWIP_ASSERT("mem_free: sanity check alignment", (((mem_ptr_t)rmem) & (MEM_ALIGNMENT-1)) == 0); LWIP_ASSERT("mem_free: sanity check alignment", (((mem_ptr_t)rmem) & (MEM_ALIGNMENT - 1)) == 0);
LWIP_ASSERT("mem_free: legal memory", (u8_t *)rmem >= (u8_t *)ram && LWIP_ASSERT("mem_free: legal memory", (u8_t *)rmem >= (u8_t *)ram &&
(u8_t *)rmem < (u8_t *)ram_end); (u8_t *)rmem < (u8_t *)ram_end);
@ -722,7 +722,7 @@ mem_malloc_adjust_lfree:
LWIP_ASSERT("mem_malloc: allocated memory properly aligned.", LWIP_ASSERT("mem_malloc: allocated memory properly aligned.",
((mem_ptr_t)mem + SIZEOF_STRUCT_MEM) % MEM_ALIGNMENT == 0); ((mem_ptr_t)mem + SIZEOF_STRUCT_MEM) % MEM_ALIGNMENT == 0);
LWIP_ASSERT("mem_malloc: sanity check alignment", LWIP_ASSERT("mem_malloc: sanity check alignment",
(((mem_ptr_t)mem) & (MEM_ALIGNMENT-1)) == 0); (((mem_ptr_t)mem) & (MEM_ALIGNMENT - 1)) == 0);
return (u8_t *)mem + SIZEOF_STRUCT_MEM; return (u8_t *)mem + SIZEOF_STRUCT_MEM;
} }

View File

@ -80,7 +80,7 @@
#define LWIP_MEMPOOL(name,num,size,desc) LWIP_MEMPOOL_DECLARE(name,num,size,desc) #define LWIP_MEMPOOL(name,num,size,desc) LWIP_MEMPOOL_DECLARE(name,num,size,desc)
#include "lwip/priv/memp_std.h" #include "lwip/priv/memp_std.h"
const struct memp_desc* const memp_pools[MEMP_MAX] = { const struct memp_desc *const memp_pools[MEMP_MAX] = {
#define LWIP_MEMPOOL(name,num,size,desc) &memp_ ## name, #define LWIP_MEMPOOL(name,num,size,desc) &memp_ ## name,
#include "lwip/priv/memp_std.h" #include "lwip/priv/memp_std.h"
}; };
@ -132,7 +132,7 @@ memp_overflow_check_element_overflow(struct memp *p, const struct memp_desc *des
#if MEMP_SANITY_REGION_AFTER_ALIGNED > 0 #if MEMP_SANITY_REGION_AFTER_ALIGNED > 0
u16_t k; u16_t k;
u8_t *m; u8_t *m;
m = (u8_t*)p + MEMP_SIZE + desc->size; m = (u8_t *)p + MEMP_SIZE + desc->size;
for (k = 0; k < MEMP_SANITY_REGION_AFTER_ALIGNED; k++) { for (k = 0; k < MEMP_SANITY_REGION_AFTER_ALIGNED; k++) {
if (m[k] != 0xcd) { if (m[k] != 0xcd) {
char errstr[128] = "detected memp overflow in pool "; char errstr[128] = "detected memp overflow in pool ";
@ -159,7 +159,7 @@ memp_overflow_check_element_underflow(struct memp *p, const struct memp_desc *de
#if MEMP_SANITY_REGION_BEFORE_ALIGNED > 0 #if MEMP_SANITY_REGION_BEFORE_ALIGNED > 0
u16_t k; u16_t k;
u8_t *m; u8_t *m;
m = (u8_t*)p + MEMP_SIZE - MEMP_SANITY_REGION_BEFORE_ALIGNED; m = (u8_t *)p + MEMP_SIZE - MEMP_SANITY_REGION_BEFORE_ALIGNED;
for (k = 0; k < MEMP_SANITY_REGION_BEFORE_ALIGNED; k++) { for (k = 0; k < MEMP_SANITY_REGION_BEFORE_ALIGNED; k++) {
if (m[k] != 0xcd) { if (m[k] != 0xcd) {
char errstr[128] = "detected memp underflow in pool "; char errstr[128] = "detected memp underflow in pool ";
@ -182,11 +182,11 @@ memp_overflow_init_element(struct memp *p, const struct memp_desc *desc)
#if MEMP_SANITY_REGION_BEFORE_ALIGNED > 0 || MEMP_SANITY_REGION_AFTER_ALIGNED > 0 #if MEMP_SANITY_REGION_BEFORE_ALIGNED > 0 || MEMP_SANITY_REGION_AFTER_ALIGNED > 0
u8_t *m; u8_t *m;
#if MEMP_SANITY_REGION_BEFORE_ALIGNED > 0 #if MEMP_SANITY_REGION_BEFORE_ALIGNED > 0
m = (u8_t*)p + MEMP_SIZE - MEMP_SANITY_REGION_BEFORE_ALIGNED; m = (u8_t *)p + MEMP_SIZE - MEMP_SANITY_REGION_BEFORE_ALIGNED;
memset(m, 0xcd, MEMP_SANITY_REGION_BEFORE_ALIGNED); memset(m, 0xcd, MEMP_SANITY_REGION_BEFORE_ALIGNED);
#endif #endif
#if MEMP_SANITY_REGION_AFTER_ALIGNED > 0 #if MEMP_SANITY_REGION_AFTER_ALIGNED > 0
m = (u8_t*)p + MEMP_SIZE + desc->size; m = (u8_t *)p + MEMP_SIZE + desc->size;
memset(m, 0xcd, MEMP_SANITY_REGION_AFTER_ALIGNED); memset(m, 0xcd, MEMP_SANITY_REGION_AFTER_ALIGNED);
#endif #endif
#else /* MEMP_SANITY_REGION_BEFORE_ALIGNED > 0 || MEMP_SANITY_REGION_AFTER_ALIGNED > 0 */ #else /* MEMP_SANITY_REGION_BEFORE_ALIGNED > 0 || MEMP_SANITY_REGION_AFTER_ALIGNED > 0 */
@ -210,11 +210,11 @@ memp_overflow_check_all(void)
SYS_ARCH_PROTECT(old_level); SYS_ARCH_PROTECT(old_level);
for (i = 0; i < MEMP_MAX; ++i) { for (i = 0; i < MEMP_MAX; ++i) {
p = (struct memp*)LWIP_MEM_ALIGN(memp_pools[i]->base); p = (struct memp *)LWIP_MEM_ALIGN(memp_pools[i]->base);
for (j = 0; j < memp_pools[i]->num; ++j) { for (j = 0; j < memp_pools[i]->num; ++j) {
memp_overflow_check_element_overflow(p, memp_pools[i]); memp_overflow_check_element_overflow(p, memp_pools[i]);
memp_overflow_check_element_underflow(p, memp_pools[i]); memp_overflow_check_element_underflow(p, memp_pools[i]);
p = LWIP_ALIGNMENT_CAST(struct memp*, ((u8_t*)p + MEMP_SIZE + memp_pools[i]->size + MEMP_SANITY_REGION_AFTER_ALIGNED)); p = LWIP_ALIGNMENT_CAST(struct memp *, ((u8_t *)p + MEMP_SIZE + memp_pools[i]->size + MEMP_SANITY_REGION_AFTER_ALIGNED));
} }
} }
SYS_ARCH_UNPROTECT(old_level); SYS_ARCH_UNPROTECT(old_level);
@ -238,7 +238,7 @@ memp_init_pool(const struct memp_desc *desc)
struct memp *memp; struct memp *memp;
*desc->tab = NULL; *desc->tab = NULL;
memp = (struct memp*)LWIP_MEM_ALIGN(desc->base); memp = (struct memp *)LWIP_MEM_ALIGN(desc->base);
#if MEMP_MEM_INIT #if MEMP_MEM_INIT
/* force memset on pool memory */ /* force memset on pool memory */
memset(memp, 0, (size_t)desc->num * (MEMP_SIZE + desc->size memset(memp, 0, (size_t)desc->num * (MEMP_SIZE + desc->size
@ -297,11 +297,11 @@ memp_init(void)
#endif /* MEMP_OVERFLOW_CHECK >= 2 */ #endif /* MEMP_OVERFLOW_CHECK >= 2 */
} }
static void* static void *
#if !MEMP_OVERFLOW_CHECK #if !MEMP_OVERFLOW_CHECK
do_memp_malloc_pool(const struct memp_desc *desc) do_memp_malloc_pool(const struct memp_desc *desc)
#else #else
do_memp_malloc_pool_fn(const struct memp_desc *desc, const char* file, const int line) do_memp_malloc_pool_fn(const struct memp_desc *desc, const char *file, const int line)
#endif #endif
{ {
struct memp *memp; struct memp *memp;
@ -345,7 +345,7 @@ do_memp_malloc_pool_fn(const struct memp_desc *desc, const char* file, const int
#endif #endif
SYS_ARCH_UNPROTECT(old_level); SYS_ARCH_UNPROTECT(old_level);
/* cast through u8_t* to get rid of alignment warnings */ /* cast through u8_t* to get rid of alignment warnings */
return ((u8_t*)memp + MEMP_SIZE); return ((u8_t *)memp + MEMP_SIZE);
} else { } else {
#if MEMP_STATS #if MEMP_STATS
desc->stats->err++; desc->stats->err++;
@ -368,7 +368,7 @@ void *
#if !MEMP_OVERFLOW_CHECK #if !MEMP_OVERFLOW_CHECK
memp_malloc_pool(const struct memp_desc *desc) memp_malloc_pool(const struct memp_desc *desc)
#else #else
memp_malloc_pool_fn(const struct memp_desc *desc, const char* file, const int line) memp_malloc_pool_fn(const struct memp_desc *desc, const char *file, const int line)
#endif #endif
{ {
LWIP_ASSERT("invalid pool desc", desc != NULL); LWIP_ASSERT("invalid pool desc", desc != NULL);
@ -394,7 +394,7 @@ void *
#if !MEMP_OVERFLOW_CHECK #if !MEMP_OVERFLOW_CHECK
memp_malloc(memp_t type) memp_malloc(memp_t type)
#else #else
memp_malloc_fn(memp_t type, const char* file, const int line) memp_malloc_fn(memp_t type, const char *file, const int line)
#endif #endif
{ {
void *memp; void *memp;
@ -414,7 +414,7 @@ memp_malloc_fn(memp_t type, const char* file, const int line)
} }
static void static void
do_memp_free_pool(const struct memp_desc* desc, void *mem) do_memp_free_pool(const struct memp_desc *desc, void *mem)
{ {
struct memp *memp; struct memp *memp;
SYS_ARCH_DECL_PROTECT(old_level); SYS_ARCH_DECL_PROTECT(old_level);
@ -423,7 +423,7 @@ do_memp_free_pool(const struct memp_desc* desc, void *mem)
((mem_ptr_t)mem % MEM_ALIGNMENT) == 0); ((mem_ptr_t)mem % MEM_ALIGNMENT) == 0);
/* cast through void* to get rid of alignment warnings */ /* cast through void* to get rid of alignment warnings */
memp = (struct memp *)(void *)((u8_t*)mem - MEMP_SIZE); memp = (struct memp *)(void *)((u8_t *)mem - MEMP_SIZE);
SYS_ARCH_PROTECT(old_level); SYS_ARCH_PROTECT(old_level);
@ -459,7 +459,7 @@ do_memp_free_pool(const struct memp_desc* desc, void *mem)
* @param mem the memp element to free * @param mem the memp element to free
*/ */
void void
memp_free_pool(const struct memp_desc* desc, void *mem) memp_free_pool(const struct memp_desc *desc, void *mem)
{ {
LWIP_ASSERT("invalid pool desc", desc != NULL); LWIP_ASSERT("invalid pool desc", desc != NULL);
if ((desc == NULL) || (mem == NULL)) { if ((desc == NULL) || (mem == NULL)) {

View File

@ -103,7 +103,7 @@
#endif /* LWIP_NETIF_LINK_CALLBACK */ #endif /* LWIP_NETIF_LINK_CALLBACK */
#if LWIP_NETIF_EXT_STATUS_CALLBACK #if LWIP_NETIF_EXT_STATUS_CALLBACK
static netif_ext_callback_t* ext_callback; static netif_ext_callback_t *ext_callback;
#endif #endif
#if !LWIP_SINGLE_NETIF #if !LWIP_SINGLE_NETIF
@ -120,7 +120,7 @@ static u8_t netif_client_id;
#define NETIF_REPORT_TYPE_IPV4 0x01 #define NETIF_REPORT_TYPE_IPV4 0x01
#define NETIF_REPORT_TYPE_IPV6 0x02 #define NETIF_REPORT_TYPE_IPV6 0x02
static void netif_issue_reports(struct netif* netif, u8_t report_type); static void netif_issue_reports(struct netif *netif, u8_t report_type);
#if LWIP_IPV6 #if LWIP_IPV6
static err_t netif_null_output_ip6(struct netif *netif, struct pbuf *p, const ip6_addr_t *ipaddr); static err_t netif_null_output_ip6(struct netif *netif, struct pbuf *p, const ip6_addr_t *ipaddr);
@ -128,10 +128,10 @@ static err_t netif_null_output_ip6(struct netif *netif, struct pbuf *p, const ip
#if LWIP_HAVE_LOOPIF #if LWIP_HAVE_LOOPIF
#if LWIP_IPV4 #if LWIP_IPV4
static err_t netif_loop_output_ipv4(struct netif *netif, struct pbuf *p, const ip4_addr_t* addr); static err_t netif_loop_output_ipv4(struct netif *netif, struct pbuf *p, const ip4_addr_t *addr);
#endif #endif
#if LWIP_IPV6 #if LWIP_IPV6
static err_t netif_loop_output_ipv6(struct netif *netif, struct pbuf *p, const ip6_addr_t* addr); static err_t netif_loop_output_ipv6(struct netif *netif, struct pbuf *p, const ip6_addr_t *addr);
#endif #endif
@ -174,9 +174,9 @@ netif_init(void)
#if LWIP_IPV4 #if LWIP_IPV4
#define LOOPIF_ADDRINIT &loop_ipaddr, &loop_netmask, &loop_gw, #define LOOPIF_ADDRINIT &loop_ipaddr, &loop_netmask, &loop_gw,
ip4_addr_t loop_ipaddr, loop_netmask, loop_gw; ip4_addr_t loop_ipaddr, loop_netmask, loop_gw;
IP4_ADDR(&loop_gw, 127,0,0,1); IP4_ADDR(&loop_gw, 127, 0, 0, 1);
IP4_ADDR(&loop_ipaddr, 127,0,0,1); IP4_ADDR(&loop_ipaddr, 127, 0, 0, 1);
IP4_ADDR(&loop_netmask, 255,0,0,0); IP4_ADDR(&loop_netmask, 255, 0, 0, 0);
#else /* LWIP_IPV4 */ #else /* LWIP_IPV4 */
#define LOOPIF_ADDRINIT #define LOOPIF_ADDRINIT
#endif /* LWIP_IPV4 */ #endif /* LWIP_IPV4 */
@ -539,7 +539,7 @@ netif_remove(struct netif *netif)
netif_list = netif->next; netif_list = netif->next;
} else { } else {
/* look for netif further down the list */ /* look for netif further down the list */
struct netif * tmp_netif; struct netif *tmp_netif;
for (tmp_netif = netif_list; tmp_netif != NULL; tmp_netif = tmp_netif->next) { for (tmp_netif = netif_list; tmp_netif != NULL; tmp_netif = tmp_netif->next) {
if (tmp_netif->next == netif) { if (tmp_netif->next == netif) {
tmp_netif->next = netif->next; tmp_netif->next = netif->next;
@ -743,7 +743,7 @@ netif_set_up(struct netif *netif)
#endif #endif
if (netif->flags & NETIF_FLAG_LINK_UP) { if (netif->flags & NETIF_FLAG_LINK_UP) {
netif_issue_reports(netif, NETIF_REPORT_TYPE_IPV4|NETIF_REPORT_TYPE_IPV6); netif_issue_reports(netif, NETIF_REPORT_TYPE_IPV4 | NETIF_REPORT_TYPE_IPV6);
} }
} }
} }
@ -751,7 +751,7 @@ netif_set_up(struct netif *netif)
/** Send ARP/IGMP/MLD/RS events, e.g. on link-up/netif-up or addr-change /** Send ARP/IGMP/MLD/RS events, e.g. on link-up/netif-up or addr-change
*/ */
static void static void
netif_issue_reports(struct netif* netif, u8_t report_type) netif_issue_reports(struct netif *netif, u8_t report_type)
{ {
#if LWIP_IPV4 #if LWIP_IPV4
if ((report_type & NETIF_REPORT_TYPE_IPV4) && if ((report_type & NETIF_REPORT_TYPE_IPV4) &&
@ -866,7 +866,7 @@ netif_set_link_up(struct netif *netif)
#endif /* LWIP_AUTOIP */ #endif /* LWIP_AUTOIP */
if (netif->flags & NETIF_FLAG_UP) { if (netif->flags & NETIF_FLAG_UP) {
netif_issue_reports(netif, NETIF_REPORT_TYPE_IPV4|NETIF_REPORT_TYPE_IPV6); netif_issue_reports(netif, NETIF_REPORT_TYPE_IPV4 | NETIF_REPORT_TYPE_IPV6);
} }
NETIF_LINK_CALLBACK(netif); NETIF_LINK_CALLBACK(netif);
#if LWIP_NETIF_EXT_STATUS_CALLBACK #if LWIP_NETIF_EXT_STATUS_CALLBACK
@ -1013,7 +1013,7 @@ netif_loop_output(struct netif *netif, struct pbuf *p)
#if LWIP_HAVE_LOOPIF #if LWIP_HAVE_LOOPIF
#if LWIP_IPV4 #if LWIP_IPV4
static err_t static err_t
netif_loop_output_ipv4(struct netif *netif, struct pbuf *p, const ip4_addr_t* addr) netif_loop_output_ipv4(struct netif *netif, struct pbuf *p, const ip4_addr_t *addr)
{ {
LWIP_UNUSED_ARG(addr); LWIP_UNUSED_ARG(addr);
return netif_loop_output(netif, p); return netif_loop_output(netif, p);
@ -1022,7 +1022,7 @@ netif_loop_output_ipv4(struct netif *netif, struct pbuf *p, const ip4_addr_t* ad
#if LWIP_IPV6 #if LWIP_IPV6
static err_t static err_t
netif_loop_output_ipv6(struct netif *netif, struct pbuf *p, const ip6_addr_t* addr) netif_loop_output_ipv6(struct netif *netif, struct pbuf *p, const ip6_addr_t *addr)
{ {
LWIP_UNUSED_ARG(addr); LWIP_UNUSED_ARG(addr);
return netif_loop_output(netif, p); return netif_loop_output(netif, p);
@ -1232,7 +1232,7 @@ netif_ip6_addr_set_parts(struct netif *netif, s8_t addr_idx, u32_t i0, u32_t i1,
* @param state the new IPv6 address state * @param state the new IPv6 address state
*/ */
void void
netif_ip6_addr_set_state(struct netif* netif, s8_t addr_idx, u8_t state) netif_ip6_addr_set_state(struct netif *netif, s8_t addr_idx, u8_t state)
{ {
u8_t old_state; u8_t old_state;
LWIP_ASSERT("netif != NULL", netif != NULL); LWIP_ASSERT("netif != NULL", netif != NULL);
@ -1493,10 +1493,10 @@ netif_index_to_name(u8_t idx, char *name)
* *
* @param idx index of netif to find * @param idx index of netif to find
*/ */
struct netif* struct netif *
netif_get_by_index(u8_t idx) netif_get_by_index(u8_t idx)
{ {
struct netif* netif; struct netif *netif;
if (idx != NETIF_NO_INDEX) { if (idx != NETIF_NO_INDEX) {
NETIF_FOREACH(netif) { NETIF_FOREACH(netif) {
@ -1547,7 +1547,7 @@ netif_find(const char *name)
* @param callback pointer to listener structure * @param callback pointer to listener structure
* @param fn callback function * @param fn callback function
*/ */
void netif_add_ext_callback(netif_ext_callback_t* callback, netif_ext_callback_fn fn) void netif_add_ext_callback(netif_ext_callback_t *callback, netif_ext_callback_fn fn)
{ {
LWIP_ASSERT("callback must be != NULL", callback != NULL); LWIP_ASSERT("callback must be != NULL", callback != NULL);
LWIP_ASSERT("fn must be != NULL", fn != NULL); LWIP_ASSERT("fn must be != NULL", fn != NULL);
@ -1563,9 +1563,9 @@ void netif_add_ext_callback(netif_ext_callback_t* callback, netif_ext_callback_f
* @param reason change reason * @param reason change reason
* @param args depends on reason, see reason description * @param args depends on reason, see reason description
*/ */
void netif_invoke_ext_callback(struct netif* netif, netif_nsc_reason_t reason, const netif_ext_callback_args_t* args) void netif_invoke_ext_callback(struct netif *netif, netif_nsc_reason_t reason, const netif_ext_callback_args_t *args)
{ {
netif_ext_callback_t* callback = ext_callback; netif_ext_callback_t *callback = ext_callback;
LWIP_ASSERT("netif must be != NULL", netif != NULL); LWIP_ASSERT("netif must be != NULL", netif != NULL);

View File

@ -124,7 +124,7 @@ static
void void
pbuf_free_ooseq(void) pbuf_free_ooseq(void)
{ {
struct tcp_pcb* pcb; struct tcp_pcb *pcb;
SYS_ARCH_SET(pbuf_free_ooseq_pending, 0); SYS_ARCH_SET(pbuf_free_ooseq_pending, 0);
for (pcb = tcp_active_pcbs; NULL != pcb; pcb = pcb->next) { for (pcb = tcp_active_pcbs; NULL != pcb; pcb = pcb->next) {
@ -173,7 +173,7 @@ pbuf_pool_is_empty(void)
/* Initialize members of struct pbuf after allocation */ /* Initialize members of struct pbuf after allocation */
static void static void
pbuf_init_alloced_pbuf(struct pbuf *p, void* payload, u16_t tot_len, u16_t len, pbuf_type type, u8_t flags) pbuf_init_alloced_pbuf(struct pbuf *p, void *payload, u16_t tot_len, u16_t len, pbuf_type type, u8_t flags)
{ {
p->next = NULL; p->next = NULL;
p->payload = payload; p->payload = payload;
@ -229,8 +229,7 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
case PBUF_ROM: case PBUF_ROM:
p = pbuf_alloc_reference(NULL, length, type); p = pbuf_alloc_reference(NULL, length, type);
break; break;
case PBUF_POOL: case PBUF_POOL: {
{
struct pbuf *q, *last; struct pbuf *q, *last;
u16_t rem_len; /* remaining length */ u16_t rem_len; /* remaining length */
p = NULL; p = NULL;
@ -268,8 +267,7 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
} while (rem_len > 0); } while (rem_len > 0);
break; break;
} }
case PBUF_RAM: case PBUF_RAM: {
{
u16_t payload_len = (u16_t)(LWIP_MEM_ALIGN_SIZE(offset) + LWIP_MEM_ALIGN_SIZE(length)); u16_t payload_len = (u16_t)(LWIP_MEM_ALIGN_SIZE(offset) + LWIP_MEM_ALIGN_SIZE(length));
mem_size_t alloc_len = (mem_size_t)(LWIP_MEM_ALIGN_SIZE(SIZEOF_STRUCT_PBUF) + payload_len); mem_size_t alloc_len = (mem_size_t)(LWIP_MEM_ALIGN_SIZE(SIZEOF_STRUCT_PBUF) + payload_len);
@ -280,7 +278,7 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
} }
/* If pbuf is to be allocated in RAM, allocate memory for it. */ /* If pbuf is to be allocated in RAM, allocate memory for it. */
p = (struct pbuf*)mem_malloc(alloc_len); p = (struct pbuf *)mem_malloc(alloc_len);
if (p == NULL) { if (p == NULL) {
return NULL; return NULL;
} }
@ -358,7 +356,7 @@ pbuf_alloc_reference(void *payload, u16_t length, pbuf_type type)
* @param payload_mem_len the size of the 'payload_mem' buffer, must be at least * @param payload_mem_len the size of the 'payload_mem' buffer, must be at least
* big enough to hold 'length' plus the header size * big enough to hold 'length' plus the header size
*/ */
struct pbuf* struct pbuf *
pbuf_alloced_custom(pbuf_layer l, u16_t length, pbuf_type type, struct pbuf_custom *p, pbuf_alloced_custom(pbuf_layer l, u16_t length, pbuf_type type, struct pbuf_custom *p,
void *payload_mem, u16_t payload_mem_len) void *payload_mem, u16_t payload_mem_len)
{ {
@ -609,7 +607,7 @@ static u8_t
pbuf_header_impl(struct pbuf *p, s16_t header_size_increment, u8_t force) pbuf_header_impl(struct pbuf *p, s16_t header_size_increment, u8_t force)
{ {
if (header_size_increment < 0) { if (header_size_increment < 0) {
return pbuf_remove_header(p, (size_t)-header_size_increment); return pbuf_remove_header(p, (size_t) - header_size_increment);
} else { } else {
return pbuf_add_header_impl(p, (size_t)header_size_increment, force); return pbuf_add_header_impl(p, (size_t)header_size_increment, force);
} }
@ -660,7 +658,7 @@ pbuf_header_force(struct pbuf *p, s16_t header_size_increment)
* takes an u16_t not s16_t! * takes an u16_t not s16_t!
* @return the new head pbuf * @return the new head pbuf
*/ */
struct pbuf* struct pbuf *
pbuf_free_header(struct pbuf *q, u16_t size) pbuf_free_header(struct pbuf *q, u16_t size)
{ {
struct pbuf *p = q; struct pbuf *p = q;
@ -756,7 +754,7 @@ pbuf_free(struct pbuf *p)
#if LWIP_SUPPORT_CUSTOM_PBUF #if LWIP_SUPPORT_CUSTOM_PBUF
/* is this a custom pbuf? */ /* is this a custom pbuf? */
if ((p->flags & PBUF_FLAG_IS_CUSTOM) != 0) { if ((p->flags & PBUF_FLAG_IS_CUSTOM) != 0) {
struct pbuf_custom *pc = (struct pbuf_custom*)p; struct pbuf_custom *pc = (struct pbuf_custom *)p;
LWIP_ASSERT("pc->custom_free_function != NULL", pc->custom_free_function != NULL); LWIP_ASSERT("pc->custom_free_function != NULL", pc->custom_free_function != NULL);
pc->custom_free_function(p); pc->custom_free_function(p);
} else } else
@ -956,15 +954,14 @@ pbuf_copy(struct pbuf *p_to, const struct pbuf *p_from)
size_t offset_to = 0, offset_from = 0, len; size_t offset_to = 0, offset_from = 0, len;
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_copy(%p, %p)\n", LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_copy(%p, %p)\n",
(const void*)p_to, (const void*)p_from)); (const void *)p_to, (const void *)p_from));
/* is the target big enough to hold the source? */ /* is the target big enough to hold the source? */
LWIP_ERROR("pbuf_copy: target not big enough to hold source", ((p_to != NULL) && LWIP_ERROR("pbuf_copy: target not big enough to hold source", ((p_to != NULL) &&
(p_from != NULL) && (p_to->tot_len >= p_from->tot_len)), return ERR_ARG;); (p_from != NULL) && (p_to->tot_len >= p_from->tot_len)), return ERR_ARG;);
/* iterate through pbuf chain */ /* iterate through pbuf chain */
do do {
{
/* copy one part of the original chain */ /* copy one part of the original chain */
if ((p_to->len - offset_to) >= (p_from->len - offset_from)) { if ((p_to->len - offset_to) >= (p_from->len - offset_from)) {
/* complete current p_from fits into current p_to */ /* complete current p_from fits into current p_to */
@ -973,7 +970,7 @@ pbuf_copy(struct pbuf *p_to, const struct pbuf *p_from)
/* current p_from does not fit into current p_to */ /* current p_from does not fit into current p_to */
len = p_to->len - offset_to; len = p_to->len - offset_to;
} }
MEMCPY((u8_t*)p_to->payload + offset_to, (u8_t*)p_from->payload + offset_from, len); MEMCPY((u8_t *)p_to->payload + offset_to, (u8_t *)p_from->payload + offset_from, len);
offset_to += len; offset_to += len;
offset_from += len; offset_from += len;
LWIP_ASSERT("offset_to <= p_to->len", offset_to <= p_to->len); LWIP_ASSERT("offset_to <= p_to->len", offset_to <= p_to->len);
@ -987,7 +984,7 @@ pbuf_copy(struct pbuf *p_to, const struct pbuf *p_from)
/* on to next p_to (if any) */ /* on to next p_to (if any) */
offset_to = 0; offset_to = 0;
p_to = p_to->next; p_to = p_to->next;
LWIP_ERROR("p_to != NULL", (p_to != NULL) || (p_from == NULL) , return ERR_ARG;); 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)) {
@ -1040,7 +1037,7 @@ pbuf_copy_partial(const struct pbuf *buf, void *dataptr, u16_t len, u16_t offset
buf_copy_len = len; buf_copy_len = len;
} }
/* copy the necessary parts of the buffer */ /* copy the necessary parts of the buffer */
MEMCPY(&((char*)dataptr)[left], &((char*)p->payload)[offset], buf_copy_len); MEMCPY(&((char *)dataptr)[left], &((char *)p->payload)[offset], buf_copy_len);
copied_total = (u16_t)(copied_total + buf_copy_len); copied_total = (u16_t)(copied_total + buf_copy_len);
left = (u16_t)(left + buf_copy_len); left = (u16_t)(left + buf_copy_len);
len = (u16_t)(len - buf_copy_len); len = (u16_t)(len - buf_copy_len);
@ -1080,7 +1077,7 @@ pbuf_get_contiguous(const struct pbuf *p, void *buffer, size_t bufsize, u16_t le
} else { } else {
if (q->len >= (offset + len)) { if (q->len >= (offset + len)) {
/* all data in this pbuf, return zero-copy */ /* all data in this pbuf, return zero-copy */
return (u8_t*)q->payload + offset; return (u8_t *)q->payload + offset;
} }
/* need to copy */ /* need to copy */
if (pbuf_copy_partial(q, buffer, len, offset) != len) { if (pbuf_copy_partial(q, buffer, len, offset) != len) {
@ -1145,11 +1142,11 @@ void pbuf_split_64k(struct pbuf *p, struct pbuf **rest)
#endif /* LWIP_TCP && TCP_QUEUE_OOSEQ && LWIP_WND_SCALE */ #endif /* LWIP_TCP && TCP_QUEUE_OOSEQ && LWIP_WND_SCALE */
/* Actual implementation of pbuf_skip() but returning const pointer... */ /* Actual implementation of pbuf_skip() but returning const pointer... */
static const struct pbuf* static const struct pbuf *
pbuf_skip_const(const struct pbuf* in, u16_t in_offset, u16_t* out_offset) pbuf_skip_const(const struct pbuf *in, u16_t in_offset, u16_t *out_offset)
{ {
u16_t offset_left = in_offset; u16_t offset_left = in_offset;
const struct pbuf* q = in; const struct pbuf *q = in;
/* get the correct pbuf */ /* get the correct pbuf */
while ((q != NULL) && (q->len <= offset_left)) { while ((q != NULL) && (q->len <= offset_left)) {
@ -1171,11 +1168,11 @@ pbuf_skip_const(const struct pbuf* in, u16_t in_offset, u16_t* out_offset)
* @param out_offset resulting offset in the returned pbuf * @param out_offset resulting offset in the returned pbuf
* @return the pbuf in the queue where the offset is * @return the pbuf in the queue where the offset is
*/ */
struct pbuf* struct pbuf *
pbuf_skip(struct pbuf* in, u16_t in_offset, u16_t* out_offset) pbuf_skip(struct pbuf *in, u16_t in_offset, u16_t *out_offset)
{ {
const struct pbuf* out = pbuf_skip_const(in, in_offset, out_offset); const struct pbuf *out = pbuf_skip_const(in, in_offset, out_offset);
return LWIP_CONST_CAST(struct pbuf*, out); return LWIP_CONST_CAST(struct pbuf *, out);
} }
/** /**
@ -1214,7 +1211,7 @@ pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len)
buf_copy_len = p->len; buf_copy_len = p->len;
} }
/* copy the necessary parts of the buffer */ /* copy the necessary parts of the buffer */
MEMCPY(p->payload, &((const char*)dataptr)[copied_total], buf_copy_len); MEMCPY(p->payload, &((const char *)dataptr)[copied_total], buf_copy_len);
total_copy_len -= buf_copy_len; total_copy_len -= buf_copy_len;
copied_total += buf_copy_len; copied_total += buf_copy_len;
} }
@ -1237,17 +1234,17 @@ err_t
pbuf_take_at(struct pbuf *buf, const void *dataptr, u16_t len, u16_t offset) pbuf_take_at(struct pbuf *buf, const void *dataptr, u16_t len, u16_t offset)
{ {
u16_t target_offset; u16_t target_offset;
struct pbuf* q = pbuf_skip(buf, offset, &target_offset); struct pbuf *q = pbuf_skip(buf, offset, &target_offset);
/* return requested data if pbuf is OK */ /* return requested data if pbuf is OK */
if ((q != NULL) && (q->tot_len >= target_offset + len)) { if ((q != NULL) && (q->tot_len >= target_offset + len)) {
u16_t remaining_len = len; u16_t remaining_len = len;
const u8_t* src_ptr = (const u8_t*)dataptr; const u8_t *src_ptr = (const u8_t *)dataptr;
/* copy the part that goes into the first pbuf */ /* copy the part that goes into the first pbuf */
u16_t first_copy_len; u16_t first_copy_len;
LWIP_ASSERT("chekc pbuf_skip result", target_offset < q->len); LWIP_ASSERT("chekc pbuf_skip result", target_offset < q->len);
first_copy_len = (u16_t)LWIP_MIN(q->len - target_offset, len); first_copy_len = (u16_t)LWIP_MIN(q->len - target_offset, len);
MEMCPY(((u8_t*)q->payload) + target_offset, dataptr, first_copy_len); MEMCPY(((u8_t *)q->payload) + target_offset, dataptr, first_copy_len);
remaining_len = (u16_t)(remaining_len - first_copy_len); remaining_len = (u16_t)(remaining_len - first_copy_len);
src_ptr += first_copy_len; src_ptr += first_copy_len;
if (remaining_len > 0) { if (remaining_len > 0) {
@ -1271,7 +1268,7 @@ pbuf_take_at(struct pbuf *buf, const void *dataptr, u16_t len, u16_t offset)
* @return a new, single pbuf (p->next is NULL) * @return a new, single pbuf (p->next is NULL)
* or the old pbuf if allocation fails * or the old pbuf if allocation fails
*/ */
struct pbuf* struct pbuf *
pbuf_coalesce(struct pbuf *p, pbuf_layer layer) pbuf_coalesce(struct pbuf *p, pbuf_layer layer)
{ {
struct pbuf *q; struct pbuf *q;
@ -1343,7 +1340,7 @@ pbuf_fill_chksum(struct pbuf *p, u16_t start_offset, const void *dataptr,
return ERR_ARG; return ERR_ARG;
} }
dst_ptr = ((char*)p->payload) + start_offset; dst_ptr = ((char *)p->payload) + start_offset;
copy_chksum = LWIP_CHKSUM_COPY(dst_ptr, dataptr, len); copy_chksum = LWIP_CHKSUM_COPY(dst_ptr, dataptr, len);
if ((start_offset & 1) != 0) { if ((start_offset & 1) != 0) {
copy_chksum = SWAP_BYTES_IN_WORD(copy_chksum); copy_chksum = SWAP_BYTES_IN_WORD(copy_chksum);
@ -1365,7 +1362,7 @@ pbuf_fill_chksum(struct pbuf *p, u16_t start_offset, const void *dataptr,
* @return byte at an offset into p OR ZERO IF 'offset' >= p->tot_len * @return byte at an offset into p OR ZERO IF 'offset' >= p->tot_len
*/ */
u8_t u8_t
pbuf_get_at(const struct pbuf* p, u16_t offset) pbuf_get_at(const struct pbuf *p, u16_t offset)
{ {
int ret = pbuf_try_get_at(p, offset); int ret = pbuf_try_get_at(p, offset);
if (ret >= 0) { if (ret >= 0) {
@ -1383,14 +1380,14 @@ pbuf_get_at(const struct pbuf* p, u16_t offset)
* @return byte at an offset into p [0..0xFF] OR negative if 'offset' >= p->tot_len * @return byte at an offset into p [0..0xFF] OR negative if 'offset' >= p->tot_len
*/ */
int int
pbuf_try_get_at(const struct pbuf* p, u16_t offset) pbuf_try_get_at(const struct pbuf *p, u16_t offset)
{ {
u16_t q_idx; u16_t q_idx;
const struct pbuf* q = pbuf_skip_const(p, offset, &q_idx); const struct pbuf *q = pbuf_skip_const(p, offset, &q_idx);
/* return requested data if pbuf is OK */ /* return requested data if pbuf is OK */
if ((q != NULL) && (q->len > q_idx)) { if ((q != NULL) && (q->len > q_idx)) {
return ((u8_t*)q->payload)[q_idx]; return ((u8_t *)q->payload)[q_idx];
} }
return -1; return -1;
} }
@ -1405,14 +1402,14 @@ pbuf_try_get_at(const struct pbuf* p, u16_t offset)
* @param data byte to write at an offset into p * @param data byte to write at an offset into p
*/ */
void void
pbuf_put_at(struct pbuf* p, u16_t offset, u8_t data) pbuf_put_at(struct pbuf *p, u16_t offset, u8_t data)
{ {
u16_t q_idx; u16_t q_idx;
struct pbuf* q = pbuf_skip(p, offset, &q_idx); struct pbuf *q = pbuf_skip(p, offset, &q_idx);
/* write requested data if pbuf is OK */ /* write requested data if pbuf is OK */
if ((q != NULL) && (q->len > q_idx)) { if ((q != NULL) && (q->len > q_idx)) {
((u8_t*)q->payload)[q_idx] = data; ((u8_t *)q->payload)[q_idx] = data;
} }
} }
@ -1428,14 +1425,14 @@ pbuf_put_at(struct pbuf* p, u16_t offset, u8_t data)
* (0xffff if p is too short, diffoffset+1 otherwise) * (0xffff if p is too short, diffoffset+1 otherwise)
*/ */
u16_t u16_t
pbuf_memcmp(const struct pbuf* p, u16_t offset, const void* s2, u16_t n) pbuf_memcmp(const struct pbuf *p, u16_t offset, const void *s2, u16_t n)
{ {
u16_t start = offset; u16_t start = offset;
const struct pbuf* q = p; const struct pbuf *q = p;
u16_t i; u16_t i;
/* pbuf long enough to perform check? */ /* pbuf long enough to perform check? */
if(p->tot_len < (offset + n)) { if (p->tot_len < (offset + n)) {
return 0xffff; return 0xffff;
} }
@ -1449,9 +1446,9 @@ pbuf_memcmp(const struct pbuf* p, u16_t offset, const void* s2, u16_t n)
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
/* We know pbuf_get_at() succeeds because of p->tot_len check above. */ /* We know pbuf_get_at() succeeds because of p->tot_len check above. */
u8_t a = pbuf_get_at(q, (u16_t)(start + i)); u8_t a = pbuf_get_at(q, (u16_t)(start + i));
u8_t b = ((const u8_t*)s2)[i]; u8_t b = ((const u8_t *)s2)[i];
if (a != b) { if (a != b) {
return (u16_t)LWIP_MIN(i+1, 0xFFFF); return (u16_t)LWIP_MIN(i + 1, 0xFFFF);
} }
} }
return 0; return 0;
@ -1470,7 +1467,7 @@ pbuf_memcmp(const struct pbuf* p, u16_t offset, const void* s2, u16_t n)
* @return 0xFFFF if substr was not found in p or the index where it was found * @return 0xFFFF if substr was not found in p or the index where it was found
*/ */
u16_t u16_t
pbuf_memfind(const struct pbuf* p, const void* mem, u16_t mem_len, u16_t start_offset) pbuf_memfind(const struct pbuf *p, const void *mem, u16_t mem_len, u16_t start_offset)
{ {
u16_t i; u16_t i;
u16_t max_cmp_start = (u16_t)(p->tot_len - mem_len); u16_t max_cmp_start = (u16_t)(p->tot_len - mem_len);
@ -1497,7 +1494,7 @@ pbuf_memfind(const struct pbuf* p, const void* mem, u16_t mem_len, u16_t start_o
* @return 0xFFFF if substr was not found in p or the index where it was found * @return 0xFFFF if substr was not found in p or the index where it was found
*/ */
u16_t u16_t
pbuf_strstr(const struct pbuf* p, const char* substr) pbuf_strstr(const struct pbuf *p, const char *substr)
{ {
size_t substr_len; size_t substr_len;
if ((substr == NULL) || (substr[0] == 0) || (p->tot_len == 0xFFFF)) { if ((substr == NULL) || (substr[0] == 0) || (p->tot_len == 0xFFFF)) {

View File

@ -169,7 +169,7 @@ raw_input(struct pbuf *p, struct netif *inp)
/* receive callback function available? */ /* receive callback function available? */
if (pcb->recv != NULL) { if (pcb->recv != NULL) {
#ifndef LWIP_NOASSERT #ifndef LWIP_NOASSERT
void* old_payload = p->payload; void *old_payload = p->payload;
#endif #endif
/* the receive callback function did not eat the packet? */ /* the receive callback function did not eat the packet? */
eaten = pcb->recv(pcb->recv_arg, pcb, p, ip_current_src_addr()); eaten = pcb->recv(pcb->recv_arg, pcb, p, ip_current_src_addr());
@ -475,8 +475,7 @@ raw_sendto_if_src(struct raw_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_ip,
} }
#if IP_SOF_BROADCAST #if IP_SOF_BROADCAST
if (IP_IS_V4(dst_ip)) if (IP_IS_V4(dst_ip)) {
{
/* broadcast filter? */ /* broadcast filter? */
if (!ip_get_option(pcb, SOF_BROADCAST) && ip_addr_isbroadcast(dst_ip, netif)) { if (!ip_get_option(pcb, SOF_BROADCAST) && ip_addr_isbroadcast(dst_ip, netif)) {
LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_LEVEL_WARNING, ("raw_sendto: SOF_BROADCAST not enabled on pcb %p\n", (void *)pcb)); LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_LEVEL_WARNING, ("raw_sendto: SOF_BROADCAST not enabled on pcb %p\n", (void *)pcb));
@ -640,9 +639,9 @@ raw_new_ip_type(u8_t type, u8_t proto)
* @param old_addr IP address of the netif before change * @param old_addr IP address of the netif before change
* @param new_addr IP address of the netif after change * @param new_addr IP address of the netif after change
*/ */
void raw_netif_ip_addr_changed(const ip_addr_t* old_addr, const ip_addr_t* new_addr) void raw_netif_ip_addr_changed(const ip_addr_t *old_addr, const ip_addr_t *new_addr)
{ {
struct raw_pcb* rpcb; struct raw_pcb *rpcb;
if (!ip_addr_isany(old_addr) && !ip_addr_isany(new_addr)) { if (!ip_addr_isany(old_addr) && !ip_addr_isany(new_addr)) {
for (rpcb = raw_pcbs; rpcb != NULL; rpcb = rpcb->next) { for (rpcb = raw_pcbs; rpcb != NULL; rpcb = rpcb->next) {

View File

@ -89,7 +89,7 @@
#define INITIAL_MSS TCP_MSS #define INITIAL_MSS TCP_MSS
#endif #endif
static const char * const tcp_state_str[] = { static const char *const tcp_state_str[] = {
"CLOSED", "CLOSED",
"LISTEN", "LISTEN",
"SYN_SENT", "SYN_SENT",
@ -109,8 +109,8 @@ static u16_t tcp_port = TCP_LOCAL_PORT_RANGE_START;
/* Incremented every coarse grained timer shot (typically every 500 ms). */ /* Incremented every coarse grained timer shot (typically every 500 ms). */
u32_t tcp_ticks; u32_t tcp_ticks;
static const u8_t tcp_backoff[13] = static const u8_t tcp_backoff[13] =
{ 1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 7, 7}; { 1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 7, 7};
/* Times per slowtmr hits */ /* Times per slowtmr hits */
static const u8_t tcp_persist_backoff[7] = { 3, 6, 12, 24, 48, 96, 120 }; static const u8_t tcp_persist_backoff[7] = { 3, 6, 12, 24, 48, 96, 120 };
/* The TCP PCB lists. */ /* The TCP PCB lists. */
@ -126,8 +126,9 @@ struct tcp_pcb *tcp_active_pcbs;
struct tcp_pcb *tcp_tw_pcbs; struct tcp_pcb *tcp_tw_pcbs;
/** An array with all (non-temporary) PCB lists, mainly used for smaller code size */ /** An array with all (non-temporary) PCB lists, mainly used for smaller code size */
struct tcp_pcb ** const tcp_pcb_lists[] = {&tcp_listen_pcbs.pcbs, &tcp_bound_pcbs, struct tcp_pcb **const tcp_pcb_lists[] = {&tcp_listen_pcbs.pcbs, &tcp_bound_pcbs,
&tcp_active_pcbs, &tcp_tw_pcbs}; &tcp_active_pcbs, &tcp_tw_pcbs
};
u8_t tcp_active_pcbs_changed; u8_t tcp_active_pcbs_changed;
@ -192,7 +193,7 @@ tcp_listen_closed(struct tcp_pcb *pcb)
LWIP_ASSERT("pcb != NULL", pcb != NULL); LWIP_ASSERT("pcb != NULL", pcb != NULL);
LWIP_ASSERT("pcb->state == LISTEN", pcb->state == LISTEN); LWIP_ASSERT("pcb->state == LISTEN", pcb->state == LISTEN);
for (i = 1; i < LWIP_ARRAYSIZE(tcp_pcb_lists); i++) { for (i = 1; i < LWIP_ARRAYSIZE(tcp_pcb_lists); i++) {
tcp_remove_listener(*tcp_pcb_lists[i], (struct tcp_pcb_listen*)pcb); tcp_remove_listener(*tcp_pcb_lists[i], (struct tcp_pcb_listen *)pcb);
} }
#endif #endif
LWIP_UNUSED_ARG(pcb); LWIP_UNUSED_ARG(pcb);
@ -210,7 +211,7 @@ tcp_listen_closed(struct tcp_pcb *pcb)
* @param pcb the connection pcb which is not fully accepted yet * @param pcb the connection pcb which is not fully accepted yet
*/ */
void void
tcp_backlog_delayed(struct tcp_pcb* pcb) tcp_backlog_delayed(struct tcp_pcb *pcb)
{ {
LWIP_ASSERT("pcb != NULL", pcb != NULL); LWIP_ASSERT("pcb != NULL", pcb != NULL);
if ((pcb->flags & TF_BACKLOGPEND) == 0) { if ((pcb->flags & TF_BACKLOGPEND) == 0) {
@ -232,7 +233,7 @@ tcp_backlog_delayed(struct tcp_pcb* pcb)
* @param pcb the connection pcb which is now fully accepted (or closed/aborted) * @param pcb the connection pcb which is now fully accepted (or closed/aborted)
*/ */
void void
tcp_backlog_accepted(struct tcp_pcb* pcb) tcp_backlog_accepted(struct tcp_pcb *pcb)
{ {
LWIP_ASSERT("pcb != NULL", pcb != NULL); LWIP_ASSERT("pcb != NULL", pcb != NULL);
if ((pcb->flags & TF_BACKLOGPEND) != 0) { if ((pcb->flags & TF_BACKLOGPEND) != 0) {
@ -729,7 +730,7 @@ tcp_listen_with_backlog_and_err(struct tcp_pcb *pcb, u8_t backlog, err_t *err)
/* already listening? */ /* already listening? */
if (pcb->state == LISTEN) { if (pcb->state == LISTEN) {
lpcb = (struct tcp_pcb_listen*)pcb; lpcb = (struct tcp_pcb_listen *)pcb;
res = ERR_ALREADY; res = ERR_ALREADY;
goto done; goto done;
} }
@ -1075,8 +1076,7 @@ tcp_slowtmr_start:
if (pcb->state == SYN_SENT && pcb->nrtx >= TCP_SYNMAXRTX) { if (pcb->state == SYN_SENT && pcb->nrtx >= TCP_SYNMAXRTX) {
++pcb_remove; ++pcb_remove;
LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: max SYN retries reached\n")); LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: max SYN retries reached\n"));
} } else if (pcb->nrtx >= TCP_MAXRTX) {
else if (pcb->nrtx >= TCP_MAXRTX) {
++pcb_remove; ++pcb_remove;
LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: max DATA retries reached\n")); LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: max DATA retries reached\n"));
} else { } else {
@ -1086,7 +1086,7 @@ tcp_slowtmr_start:
if (pcb->persist_probe >= TCP_MAXRTX) { if (pcb->persist_probe >= TCP_MAXRTX) {
++pcb_remove; /* max probes reached */ ++pcb_remove; /* max probes reached */
} else { } else {
u8_t backoff_cnt = tcp_persist_backoff[pcb->persist_backoff-1]; u8_t backoff_cnt = tcp_persist_backoff[pcb->persist_backoff - 1];
if (pcb->persist_cnt < backoff_cnt) { if (pcb->persist_cnt < backoff_cnt) {
pcb->persist_cnt++; pcb->persist_cnt++;
} }
@ -1129,7 +1129,7 @@ tcp_slowtmr_start:
/* Double retransmission time-out unless we are trying to /* Double retransmission time-out unless we are trying to
* connect to somebody (i.e., we are in SYN_SENT). */ * connect to somebody (i.e., we are in SYN_SENT). */
if (pcb->state != SYN_SENT) { if (pcb->state != SYN_SENT) {
u8_t backoff_idx = LWIP_MIN(pcb->nrtx, sizeof(tcp_backoff)-1); u8_t backoff_idx = LWIP_MIN(pcb->nrtx, sizeof(tcp_backoff) - 1);
int calc_rto = ((pcb->sa >> 3) + pcb->sv) << tcp_backoff[backoff_idx]; int calc_rto = ((pcb->sa >> 3) + pcb->sv) << tcp_backoff[backoff_idx];
pcb->rto = (s16_t)LWIP_MIN(calc_rto, 0x7FFF); pcb->rto = (s16_t)LWIP_MIN(calc_rto, 0x7FFF);
} }
@ -1175,8 +1175,7 @@ tcp_slowtmr_start:
((pcb->state == ESTABLISHED) || ((pcb->state == ESTABLISHED) ||
(pcb->state == CLOSE_WAIT))) { (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) (pcb->keep_idle + TCP_KEEP_DUR(pcb)) / TCP_SLOW_INTERVAL) {
{
LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: KEEPALIVE timeout. Aborting connection to ")); LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: KEEPALIVE timeout. Aborting connection to "));
ip_addr_debug_print_val(TCP_DEBUG, pcb->remote_ip); ip_addr_debug_print_val(TCP_DEBUG, pcb->remote_ip);
LWIP_DEBUGF(TCP_DEBUG, ("\n")); LWIP_DEBUGF(TCP_DEBUG, ("\n"));
@ -1185,8 +1184,7 @@ tcp_slowtmr_start:
++pcb_reset; ++pcb_reset;
} else if ((u32_t)(tcp_ticks - pcb->tmr) > } else if ((u32_t)(tcp_ticks - pcb->tmr) >
(pcb->keep_idle + pcb->keep_cnt_sent * TCP_KEEP_INTVL(pcb)) (pcb->keep_idle + pcb->keep_cnt_sent * TCP_KEEP_INTVL(pcb))
/ TCP_SLOW_INTERVAL) / TCP_SLOW_INTERVAL) {
{
err = tcp_keepalive(pcb); err = tcp_keepalive(pcb);
if (err == ERR_OK) { if (err == ERR_OK) {
pcb->keep_cnt_sent++; pcb->keep_cnt_sent++;
@ -1752,7 +1750,7 @@ tcp_new(void)
struct tcp_pcb * struct tcp_pcb *
tcp_new_ip_type(u8_t type) tcp_new_ip_type(u8_t type)
{ {
struct tcp_pcb * pcb; struct tcp_pcb *pcb;
pcb = tcp_alloc(TCP_PRIO_NORMAL); pcb = tcp_alloc(TCP_PRIO_NORMAL);
#if LWIP_IPV4 && LWIP_IPV6 #if LWIP_IPV4 && LWIP_IPV6
if (pcb != NULL) { if (pcb != NULL) {
@ -1851,7 +1849,7 @@ void
tcp_accept(struct tcp_pcb *pcb, tcp_accept_fn accept) tcp_accept(struct tcp_pcb *pcb, tcp_accept_fn accept)
{ {
if ((pcb != NULL) && (pcb->state == LISTEN)) { if ((pcb != NULL) && (pcb->state == LISTEN)) {
struct tcp_pcb_listen *lpcb = (struct tcp_pcb_listen*)pcb; struct tcp_pcb_listen *lpcb = (struct tcp_pcb_listen *)pcb;
lpcb->accept = accept; lpcb->accept = accept;
} }
} }
@ -2047,7 +2045,7 @@ tcp_eff_send_mss_netif(u16_t sendmss, struct netif *outif, const ip_addr_t *dest
/** Helper function for tcp_netif_ip_addr_changed() that iterates a pcb list */ /** Helper function for tcp_netif_ip_addr_changed() that iterates a pcb list */
static void static void
tcp_netif_ip_addr_changed_pcblist(const ip_addr_t* old_addr, struct tcp_pcb* pcb_list) tcp_netif_ip_addr_changed_pcblist(const ip_addr_t *old_addr, struct tcp_pcb *pcb_list)
{ {
struct tcp_pcb *pcb; struct tcp_pcb *pcb;
pcb = pcb_list; pcb = pcb_list;
@ -2076,7 +2074,7 @@ tcp_netif_ip_addr_changed_pcblist(const ip_addr_t* old_addr, struct tcp_pcb* pcb
* @param new_addr IP address of the netif after change or NULL if netif has been removed * @param new_addr IP address of the netif after change or NULL if netif has been removed
*/ */
void void
tcp_netif_ip_addr_changed(const ip_addr_t* old_addr, const ip_addr_t* new_addr) tcp_netif_ip_addr_changed(const ip_addr_t *old_addr, const ip_addr_t *new_addr)
{ {
struct tcp_pcb_listen *lpcb, *next; struct tcp_pcb_listen *lpcb, *next;
@ -2099,7 +2097,7 @@ tcp_netif_ip_addr_changed(const ip_addr_t* old_addr, const ip_addr_t* new_addr)
} }
} }
const char* const char *
tcp_debug_state_str(enum tcp_state s) tcp_debug_state_str(enum tcp_state s)
{ {
return tcp_state_str[s]; return tcp_state_str[s];

View File

@ -71,7 +71,7 @@ static struct tcp_seg inseg;
static struct tcp_hdr *tcphdr; static struct tcp_hdr *tcphdr;
static u16_t tcphdr_optlen; static u16_t tcphdr_optlen;
static u16_t tcphdr_opt1len; static u16_t tcphdr_opt1len;
static u8_t* tcphdr_opt2; static u8_t *tcphdr_opt2;
static u16_t tcp_optidx; static u16_t tcp_optidx;
static u32_t seqno, ackno; static u32_t seqno, ackno;
static tcpwnd_size_t recv_acked; static tcpwnd_size_t recv_acked;
@ -207,7 +207,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
} }
/* remember the pointer to the second part of the options */ /* remember the pointer to the second part of the options */
tcphdr_opt2 = (u8_t*)p->next->payload; tcphdr_opt2 = (u8_t *)p->next->payload;
/* advance p->next to point after the options, and manually /* advance p->next to point after the options, and manually
adjust p->tot_len to keep it consistent with the changed p->next */ adjust p->tot_len to keep it consistent with the changed p->next */
@ -540,8 +540,7 @@ aborted:
recv_data = NULL; recv_data = NULL;
/* give up our reference to inseg.p */ /* give up our reference to inseg.p */
if (inseg.p != NULL) if (inseg.p != NULL) {
{
pbuf_free(inseg.p); pbuf_free(inseg.p);
inseg.p = NULL; inseg.p = NULL;
} }
@ -618,7 +617,7 @@ tcp_listen_input(struct tcp_pcb_listen *pcb)
/* For incoming segments with the ACK flag set, respond with a /* For incoming segments with the ACK flag set, respond with a
RST. */ RST. */
LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_listen_input: ACK in LISTEN, sending reset\n")); LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_listen_input: ACK in LISTEN, sending reset\n"));
tcp_rst((const struct tcp_pcb*)pcb, ackno, seqno + tcplen, ip_current_dest_addr(), tcp_rst((const struct tcp_pcb *)pcb, ackno, seqno + tcplen, ip_current_dest_addr(),
ip_current_src_addr(), tcphdr->dest, tcphdr->src); ip_current_src_addr(), tcphdr->dest, tcphdr->src);
} else if (flags & TCP_SYN) { } else if (flags & TCP_SYN) {
LWIP_DEBUGF(TCP_DEBUG, ("TCP connection request %"U16_F" -> %"U16_F".\n", tcphdr->src, tcphdr->dest)); LWIP_DEBUGF(TCP_DEBUG, ("TCP connection request %"U16_F" -> %"U16_F".\n", tcphdr->src, tcphdr->dest));
@ -882,7 +881,7 @@ tcp_process(struct tcp_pcb *pcb)
case SYN_RCVD: case SYN_RCVD:
if (flags & TCP_ACK) { if (flags & TCP_ACK) {
/* expected ACK number? */ /* expected ACK number? */
if (TCP_SEQ_BETWEEN(ackno, pcb->lastack+1, pcb->snd_nxt)) { if (TCP_SEQ_BETWEEN(ackno, pcb->lastack + 1, pcb->snd_nxt)) {
pcb->state = ESTABLISHED; pcb->state = ESTABLISHED;
LWIP_DEBUGF(TCP_DEBUG, ("TCP connection established %"U16_F" -> %"U16_F".\n", inseg.tcphdr->src, inseg.tcphdr->dest)); LWIP_DEBUGF(TCP_DEBUG, ("TCP connection established %"U16_F" -> %"U16_F".\n", inseg.tcphdr->src, inseg.tcphdr->dest));
#if LWIP_CALLBACK_API || TCP_LISTEN_BACKLOG #if LWIP_CALLBACK_API || TCP_LISTEN_BACKLOG
@ -1043,7 +1042,7 @@ tcp_oos_insert_segment(struct tcp_seg *cseg, struct tcp_seg *next)
/** Remove segments from a list if the incoming ACK acknowledges them */ /** Remove segments from a list if the incoming ACK acknowledges them */
static struct tcp_seg * static struct tcp_seg *
tcp_free_acked_segments(struct tcp_pcb *pcb, struct tcp_seg *seg_list, const char* dbg_list_name, tcp_free_acked_segments(struct tcp_pcb *pcb, struct tcp_seg *seg_list, const char *dbg_list_name,
struct tcp_seg *dbg_other_seg_list) struct tcp_seg *dbg_other_seg_list)
{ {
struct tcp_seg *next; struct tcp_seg *next;
@ -1192,7 +1191,7 @@ tcp_receive(struct tcp_pcb *pcb)
if (!found_dupack) { if (!found_dupack) {
pcb->dupacks = 0; 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. */ /* We come here when the ACK acknowledges new data. */
tcpwnd_size_t acked; tcpwnd_size_t acked;
@ -1241,10 +1240,10 @@ tcp_receive(struct tcp_pcb *pcb)
} }
LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: ACK for %"U32_F", unacked->seqno %"U32_F":%"U32_F"\n", LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: ACK for %"U32_F", unacked->seqno %"U32_F":%"U32_F"\n",
ackno, ackno,
pcb->unacked != NULL? pcb->unacked != NULL ?
lwip_ntohl(pcb->unacked->tcphdr->seqno): 0, lwip_ntohl(pcb->unacked->tcphdr->seqno) : 0,
pcb->unacked != NULL? pcb->unacked != NULL ?
lwip_ntohl(pcb->unacked->tcphdr->seqno) + TCP_TCPLEN(pcb->unacked): 0)); lwip_ntohl(pcb->unacked->tcphdr->seqno) + TCP_TCPLEN(pcb->unacked) : 0));
/* Remove segment from the unacknowledged list if the incoming /* Remove segment from the unacknowledged list if the incoming
ACK acknowledges them. */ ACK acknowledges them. */
@ -1320,7 +1319,7 @@ tcp_receive(struct tcp_pcb *pcb)
m = (s16_t)(m - (pcb->sa >> 3)); m = (s16_t)(m - (pcb->sa >> 3));
pcb->sa = (s16_t)(pcb->sa + m); pcb->sa = (s16_t)(pcb->sa + m);
if (m < 0) { if (m < 0) {
m = (s16_t)-m; m = (s16_t) - m;
} }
m = (s16_t)(m - (pcb->sv >> 2)); m = (s16_t)(m - (pcb->sv >> 2));
pcb->sv = (s16_t)(pcb->sv + m); pcb->sv = (s16_t)(pcb->sv + m);
@ -1408,8 +1407,7 @@ tcp_receive(struct tcp_pcb *pcb)
/* cannot fail... */ /* cannot fail... */
pbuf_remove_header(p, off); pbuf_remove_header(p, off);
inseg.tcphdr->seqno = seqno = pcb->rcv_nxt; inseg.tcphdr->seqno = seqno = pcb->rcv_nxt;
} } else {
else {
if (TCP_SEQ_LT(seqno, pcb->rcv_nxt)) { if (TCP_SEQ_LT(seqno, pcb->rcv_nxt)) {
/* the whole segment is < rcv_nxt */ /* the whole segment is < rcv_nxt */
/* must be a duplicate of a packet that has already been correctly handled */ /* must be a duplicate of a packet that has already been correctly handled */
@ -1684,7 +1682,7 @@ tcp_receive(struct tcp_pcb *pcb)
} else { } else {
/*if (TCP_SEQ_LT(prev->tcphdr->seqno, seqno) && /*if (TCP_SEQ_LT(prev->tcphdr->seqno, seqno) &&
TCP_SEQ_LT(seqno, next->tcphdr->seqno)) {*/ TCP_SEQ_LT(seqno, next->tcphdr->seqno)) {*/
if (TCP_SEQ_BETWEEN(seqno, prev->tcphdr->seqno+1, next->tcphdr->seqno-1)) { if (TCP_SEQ_BETWEEN(seqno, prev->tcphdr->seqno + 1, next->tcphdr->seqno - 1)) {
/* The sequence number of the incoming segment is in /* The sequence number of the incoming segment is in
between the sequence numbers of the previous and between the sequence numbers of the previous and
the next segment on ->ooseq. We trim trim the previous the next segment on ->ooseq. We trim trim the previous
@ -1838,7 +1836,7 @@ tcp_get_next_optbyte(void)
{ {
u16_t optidx = tcp_optidx++; u16_t optidx = tcp_optidx++;
if ((tcphdr_opt2 == NULL) || (optidx < tcphdr_opt1len)) { if ((tcphdr_opt2 == NULL) || (optidx < tcphdr_opt1len)) {
u8_t* opts = (u8_t *)tcphdr + TCP_HLEN; u8_t *opts = (u8_t *)tcphdr + TCP_HLEN;
return opts[optidx]; return opts[optidx];
} else { } else {
u8_t idx = (u8_t)(optidx - tcphdr_opt1len); u8_t idx = (u8_t)(optidx - tcphdr_opt1len);
@ -1933,7 +1931,7 @@ tcp_parseopt(struct tcp_pcb *pcb)
/* Enable sending timestamps in every segment now that we know /* Enable sending timestamps in every segment now that we know
the remote host supports it. */ the remote host supports it. */
tcp_set_flags(pcb, TF_TIMESTAMP); tcp_set_flags(pcb, TF_TIMESTAMP);
} else if (TCP_SEQ_BETWEEN(pcb->ts_lastacksent, seqno, seqno+tcplen)) { } else if (TCP_SEQ_BETWEEN(pcb->ts_lastacksent, seqno, seqno + tcplen)) {
pcb->ts_recent = lwip_ntohl(tsval); pcb->ts_recent = lwip_ntohl(tsval);
} }
/* Advance to next option (6 bytes already read) */ /* Advance to next option (6 bytes already read) */
@ -2027,11 +2025,11 @@ tcp_add_sack(struct tcp_pcb *pcb, u32_t left, u32_t right)
for (i = LWIP_TCP_MAX_SACK_NUM - 1; i > 0; --i) { for (i = LWIP_TCP_MAX_SACK_NUM - 1; i > 0; --i) {
/* [i] is the index we are setting, and the value should be at index [i-1], /* [i] is the index we are setting, and the value should be at index [i-1],
or 0 if that index is unused (>= unused_idx). */ or 0 if that index is unused (>= unused_idx). */
if (i-1 >= unused_idx) { if (i - 1 >= unused_idx) {
/* [i-1] is unused. Let's clear [i]. */ /* [i-1] is unused. Let's clear [i]. */
pcb->rcv_sacks[i].left = pcb->rcv_sacks[i].right = 0; pcb->rcv_sacks[i].left = pcb->rcv_sacks[i].right = 0;
} else { } else {
pcb->rcv_sacks[i] = pcb->rcv_sacks[i-1]; pcb->rcv_sacks[i] = pcb->rcv_sacks[i - 1];
} }
} }

View File

@ -401,7 +401,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
#endif /* TCP_CHECKSUM_ON_COPY */ #endif /* TCP_CHECKSUM_ON_COPY */
err_t err; err_t err;
/* don't allocate segments bigger than half the maximum window we ever received */ /* don't allocate segments bigger than half the maximum window we ever received */
u16_t mss_local = LWIP_MIN(pcb->mss, TCPWND_MIN16(pcb->snd_wnd_max/2)); u16_t mss_local = LWIP_MIN(pcb->mss, TCPWND_MIN16(pcb->snd_wnd_max / 2));
mss_local = mss_local ? mss_local : pcb->mss; mss_local = mss_local ? mss_local : pcb->mss;
#if LWIP_NETIF_TX_SINGLE_PBUF #if LWIP_NETIF_TX_SINGLE_PBUF
@ -528,7 +528,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
#if TCP_OVERSIZE_DBGCHECK #if TCP_OVERSIZE_DBGCHECK
oversize_add = oversize; oversize_add = oversize;
#endif /* TCP_OVERSIZE_DBGCHECK */ #endif /* TCP_OVERSIZE_DBGCHECK */
TCP_DATA_COPY2(concat_p->payload, (const u8_t*)arg + pos, seglen, &concat_chksum, &concat_chksum_swapped); TCP_DATA_COPY2(concat_p->payload, (const u8_t *)arg + pos, seglen, &concat_chksum, &concat_chksum_swapped);
#if TCP_CHECKSUM_ON_COPY #if TCP_CHECKSUM_ON_COPY
concat_chksummed += seglen; concat_chksummed += seglen;
#endif /* TCP_CHECKSUM_ON_COPY */ #endif /* TCP_CHECKSUM_ON_COPY */
@ -538,7 +538,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
/* If the last unsent pbuf is of type PBUF_ROM, try to extend it. */ /* If the last unsent pbuf is of type PBUF_ROM, try to extend it. */
struct pbuf *p; struct pbuf *p;
for (p = last_unsent->p; p->next != NULL; p = p->next); for (p = last_unsent->p; p->next != NULL; p = p->next);
if (((p->type_internal & (PBUF_TYPE_FLAG_STRUCT_DATA_CONTIGUOUS|PBUF_TYPE_FLAG_DATA_VOLATILE)) == 0) && if (((p->type_internal & (PBUF_TYPE_FLAG_STRUCT_DATA_CONTIGUOUS | PBUF_TYPE_FLAG_DATA_VOLATILE)) == 0) &&
(const u8_t *)p->payload + p->len == (const u8_t *)arg) { (const u8_t *)p->payload + p->len == (const u8_t *)arg) {
LWIP_ASSERT("tcp_write: ROM pbufs cannot be oversized", pos == 0); LWIP_ASSERT("tcp_write: ROM pbufs cannot be oversized", pos == 0);
extendlen = seglen; extendlen = seglen;
@ -549,12 +549,12 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
goto memerr; goto memerr;
} }
/* reference the non-volatile payload data */ /* reference the non-volatile payload data */
((struct pbuf_rom*)concat_p)->payload = (const u8_t*)arg + pos; ((struct pbuf_rom *)concat_p)->payload = (const u8_t *)arg + pos;
queuelen += pbuf_clen(concat_p); queuelen += pbuf_clen(concat_p);
} }
#if TCP_CHECKSUM_ON_COPY #if TCP_CHECKSUM_ON_COPY
/* calculate the checksum of nocopy-data */ /* calculate the checksum of nocopy-data */
tcp_seg_add_chksum(~inet_chksum((const u8_t*)arg + pos, seglen), seglen, tcp_seg_add_chksum(~inet_chksum((const u8_t *)arg + pos, seglen), seglen,
&concat_chksum, &concat_chksum_swapped); &concat_chksum, &concat_chksum_swapped);
concat_chksummed += seglen; concat_chksummed += seglen;
#endif /* TCP_CHECKSUM_ON_COPY */ #endif /* TCP_CHECKSUM_ON_COPY */
@ -595,7 +595,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
} }
LWIP_ASSERT("tcp_write: check that first pbuf can hold the complete seglen", LWIP_ASSERT("tcp_write: check that first pbuf can hold the complete seglen",
(p->len >= seglen)); (p->len >= seglen));
TCP_DATA_COPY2((char *)p->payload + optlen, (const u8_t*)arg + pos, seglen, &chksum, &chksum_swapped); TCP_DATA_COPY2((char *)p->payload + optlen, (const u8_t *)arg + pos, seglen, &chksum, &chksum_swapped);
} else { } else {
/* Copy is not set: First allocate a pbuf for holding the data. /* Copy is not set: First allocate a pbuf for holding the data.
* Since the referenced data is available at least until it is * Since the referenced data is available at least until it is
@ -612,14 +612,14 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
} }
#if TCP_CHECKSUM_ON_COPY #if TCP_CHECKSUM_ON_COPY
/* calculate the checksum of nocopy-data */ /* calculate the checksum of nocopy-data */
chksum = ~inet_chksum((const u8_t*)arg + pos, seglen); chksum = ~inet_chksum((const u8_t *)arg + pos, seglen);
if (seglen & 1) { if (seglen & 1) {
chksum_swapped = 1; chksum_swapped = 1;
chksum = SWAP_BYTES_IN_WORD(chksum); chksum = SWAP_BYTES_IN_WORD(chksum);
} }
#endif /* TCP_CHECKSUM_ON_COPY */ #endif /* TCP_CHECKSUM_ON_COPY */
/* reference the non-volatile payload data */ /* reference the non-volatile payload data */
((struct pbuf_rom*)p2)->payload = (const u8_t*)arg + pos; ((struct pbuf_rom *)p2)->payload = (const u8_t *)arg + pos;
/* Second, allocate a pbuf for the headers. */ /* Second, allocate a pbuf for the headers. */
if ((p = pbuf_alloc(PBUF_TRANSPORT, optlen, PBUF_RAM)) == NULL) { if ((p = pbuf_alloc(PBUF_TRANSPORT, optlen, PBUF_RAM)) == NULL) {
@ -770,7 +770,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
} }
/* Set the PSH flag in the last segment that we enqueued. */ /* Set the PSH flag in the last segment that we enqueued. */
if (seg != NULL && seg->tcphdr != NULL && ((apiflags & TCP_WRITE_FLAG_MORE)==0)) { if (seg != NULL && seg->tcphdr != NULL && ((apiflags & TCP_WRITE_FLAG_MORE) == 0)) {
TCPH_SET_FLAG(seg->tcphdr, TCP_PSH); TCPH_SET_FLAG(seg->tcphdr, TCP_PSH);
} }
@ -1129,7 +1129,7 @@ tcp_output(struct tcp_pcb *pcb)
if (seg == NULL) { if (seg == NULL) {
LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output: nothing to send (%p)\n", LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output: nothing to send (%p)\n",
(void*)pcb->unsent)); (void *)pcb->unsent));
LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_output: snd_wnd %"TCPWNDSIZE_F LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_output: snd_wnd %"TCPWNDSIZE_F
", cwnd %"TCPWNDSIZE_F", wnd %"U32_F ", cwnd %"TCPWNDSIZE_F", wnd %"U32_F
", seg == NULL, ack %"U32_F"\n", ", seg == NULL, ack %"U32_F"\n",
@ -1323,7 +1323,7 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb, struct netif *netif
if (tcp_output_segment_busy(seg)) { if (tcp_output_segment_busy(seg)) {
/* This should not happen: rexmit functions should have checked this. /* This should not happen: rexmit functions should have checked this.
However, since this function modifies p->len, we must not continue in this case. */ However, since this function modifies p->len, we must not continue in this case. */
LWIP_DEBUGF(TCP_RTO_DEBUG|LWIP_DBG_LEVEL_SERIOUS, ("tcp_output_segment: segment busy\n")); LWIP_DEBUGF(TCP_RTO_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("tcp_output_segment: segment busy\n"));
return ERR_OK; return ERR_OK;
} }
@ -1500,7 +1500,7 @@ tcp_rst(const struct tcp_pcb *pcb, u32_t seqno, u32_t ackno,
tcphdr->dest = lwip_htons(remote_port); tcphdr->dest = lwip_htons(remote_port);
tcphdr->seqno = lwip_htonl(seqno); tcphdr->seqno = lwip_htonl(seqno);
tcphdr->ackno = lwip_htonl(ackno); tcphdr->ackno = lwip_htonl(ackno);
TCPH_HDRLEN_FLAGS_SET(tcphdr, TCP_HLEN/4, TCP_RST | TCP_ACK); TCPH_HDRLEN_FLAGS_SET(tcphdr, TCP_HLEN / 4, TCP_RST | TCP_ACK);
#if LWIP_WND_SCALE #if LWIP_WND_SCALE
tcphdr->wnd = PP_HTONS(((TCP_WND >> TCP_RCV_SCALE) & 0xFFFF)); tcphdr->wnd = PP_HTONS(((TCP_WND >> TCP_RCV_SCALE) & 0xFFFF));
#else #else
@ -1697,7 +1697,7 @@ tcp_rexmit_fast(struct tcp_pcb *pcb)
LWIP_DEBUGF(TCP_FR_DEBUG, LWIP_DEBUGF(TCP_FR_DEBUG,
("tcp_receive: The minimum value for ssthresh %"TCPWNDSIZE_F ("tcp_receive: The minimum value for ssthresh %"TCPWNDSIZE_F
" should be min 2 mss %"U16_F"...\n", " should be min 2 mss %"U16_F"...\n",
pcb->ssthresh, (u16_t)(2*pcb->mss))); pcb->ssthresh, (u16_t)(2 * pcb->mss)));
pcb->ssthresh = 2 * pcb->mss; pcb->ssthresh = 2 * pcb->mss;
} }
@ -1835,14 +1835,14 @@ tcp_split_unsent_seg(struct tcp_pcb *pcb, u16_t split)
/* Offset into the original pbuf is past TCP/IP headers, options, and split amount */ /* Offset into the original pbuf is past TCP/IP headers, options, and split amount */
offset = useg->p->tot_len - useg->len + split; offset = useg->p->tot_len - useg->len + split;
/* Copy remainder into new pbuf, headers and options will not be filled out */ /* Copy remainder into new pbuf, headers and options will not be filled out */
if (pbuf_copy_partial(useg->p, (u8_t*)p->payload + optlen, remainder, offset ) != remainder) { if (pbuf_copy_partial(useg->p, (u8_t *)p->payload + optlen, remainder, offset ) != remainder) {
LWIP_DEBUGF(TCP_OUTPUT_DEBUG | LWIP_DBG_LEVEL_SERIOUS, LWIP_DEBUGF(TCP_OUTPUT_DEBUG | LWIP_DBG_LEVEL_SERIOUS,
("tcp_split_unsent_seg: could not copy pbuf remainder %u\n", remainder)); ("tcp_split_unsent_seg: could not copy pbuf remainder %u\n", remainder));
goto memerr; goto memerr;
} }
#if TCP_CHECKSUM_ON_COPY #if TCP_CHECKSUM_ON_COPY
/* calculate the checksum on remainder data */ /* calculate the checksum on remainder data */
tcp_seg_add_chksum(~inet_chksum((const u8_t*)p->payload + optlen, remainder), remainder, tcp_seg_add_chksum(~inet_chksum((const u8_t *)p->payload + optlen, remainder), remainder,
&chksum, &chksum_swapped); &chksum, &chksum_swapped);
#endif /* TCP_CHECKSUM_ON_COPY */ #endif /* TCP_CHECKSUM_ON_COPY */
@ -1896,7 +1896,7 @@ tcp_split_unsent_seg(struct tcp_pcb *pcb, u16_t split)
LWIP_ASSERT("Found start of payload pbuf", q != NULL); LWIP_ASSERT("Found start of payload pbuf", q != NULL);
/* Checksum the first payload pbuf accounting for offset, then other pbufs are all payload */ /* Checksum the first payload pbuf accounting for offset, then other pbufs are all payload */
for (; q != NULL; offset = 0, q = q->next) { for (; q != NULL; offset = 0, q = q->next) {
tcp_seg_add_chksum(~inet_chksum((const u8_t*)q->payload + offset, q->len - offset), q->len - offset, tcp_seg_add_chksum(~inet_chksum((const u8_t *)q->payload + offset, q->len - offset), q->len - offset,
&useg->chksum, &useg->chksum_swapped); &useg->chksum, &useg->chksum_swapped);
} }
#endif /* TCP_CHECKSUM_ON_COPY */ #endif /* TCP_CHECKSUM_ON_COPY */

View File

@ -164,7 +164,7 @@ tcp_timer_needed(void)
static void static void
cyclic_timer(void *arg) cyclic_timer(void *arg)
{ {
const struct lwip_cyclic_timer* cyclic = (const struct lwip_cyclic_timer*)arg; const struct lwip_cyclic_timer *cyclic = (const struct lwip_cyclic_timer *)arg;
#if LWIP_DEBUG_TIMERNAMES #if LWIP_DEBUG_TIMERNAMES
LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: %s()\n", cyclic->handler_name)); LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: %s()\n", cyclic->handler_name));
#endif #endif
@ -180,7 +180,7 @@ void sys_timeouts_init(void)
for (i = (LWIP_TCP ? 1 : 0); i < LWIP_ARRAYSIZE(lwip_cyclic_timers); i++) { for (i = (LWIP_TCP ? 1 : 0); i < LWIP_ARRAYSIZE(lwip_cyclic_timers); i++) {
/* we have to cast via size_t to get rid of const warning /* we have to cast via size_t to get rid of const warning
(this is OK as cyclic_timer() casts back to const* */ (this is OK as cyclic_timer() casts back to const* */
sys_timeout(lwip_cyclic_timers[i].interval_ms, cyclic_timer, LWIP_CONST_CAST(void*, &lwip_cyclic_timers[i])); sys_timeout(lwip_cyclic_timers[i].interval_ms, cyclic_timer, LWIP_CONST_CAST(void *, &lwip_cyclic_timers[i]));
} }
/* Initialise timestamp for sys_check_timeouts */ /* Initialise timestamp for sys_check_timeouts */
@ -199,7 +199,7 @@ void sys_timeouts_init(void)
*/ */
#if LWIP_DEBUG_TIMERNAMES #if LWIP_DEBUG_TIMERNAMES
void void
sys_timeout_debug(u32_t msecs, sys_timeout_handler handler, void *arg, const char* handler_name) sys_timeout_debug(u32_t msecs, sys_timeout_handler handler, void *arg, const char *handler_name)
#else /* LWIP_DEBUG_TIMERNAMES */ #else /* LWIP_DEBUG_TIMERNAMES */
void void
sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg) sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg)

View File

@ -1204,9 +1204,9 @@ udp_new_ip_type(u8_t type)
* @param old_addr IP address of the netif before change * @param old_addr IP address of the netif before change
* @param new_addr IP address of the netif after change * @param new_addr IP address of the netif after change
*/ */
void udp_netif_ip_addr_changed(const ip_addr_t* old_addr, const ip_addr_t* new_addr) void udp_netif_ip_addr_changed(const ip_addr_t *old_addr, const ip_addr_t *new_addr)
{ {
struct udp_pcb* upcb; struct udp_pcb *upcb;
if (!ip_addr_isany(old_addr) && !ip_addr_isany(new_addr)) { if (!ip_addr_isany(old_addr) && !ip_addr_isany(new_addr)) {
for (upcb = udp_pcbs; upcb != NULL; upcb = upcb->next) { for (upcb = udp_pcbs; upcb != NULL; upcb = upcb->next) {