diff --git a/src/api/api_lib.c b/src/api/api_lib.c index 48d0a384..3d83d1ea 100644 --- a/src/api/api_lib.c +++ b/src/api/api_lib.c @@ -165,7 +165,7 @@ netbuf_copy_partial(struct netbuf *buf, void *dataptr, u16_t len, u16_t offset) offset -= p->len; } else { for(i = offset; i < p->len; ++i) { - ((char *)dataptr)[left] = ((char *)p->payload)[i]; + ((u8_t *)dataptr)[left] = ((u8_t *)p->payload)[i]; if (++left >= len) { return; } @@ -673,7 +673,7 @@ netconn_write(struct netconn *conn, void *dataptr, u16_t size, u8_t copy) api_msg_post(msg); sys_mbox_fetch(conn->mbox, NULL); if (conn->err == ERR_OK) { - dataptr = (void *)((char *)dataptr + len); + dataptr = (void *)((u8_t *)dataptr + len); size -= len; } else if (conn->err == ERR_MEM) { conn->err = ERR_OK; diff --git a/src/core/dhcp.c b/src/core/dhcp.c index 93086867..b688afa1 100644 --- a/src/core/dhcp.c +++ b/src/core/dhcp.c @@ -100,7 +100,7 @@ static void dhcp_check(struct netif *netif); static void dhcp_bind(struct netif *netif); static err_t dhcp_decline(struct netif *netif); static err_t dhcp_rebind(struct netif *netif); -static void dhcp_set_state(struct dhcp *dhcp, unsigned char new_state); +static void dhcp_set_state(struct dhcp *dhcp, u8_t new_state); /** receive, unfold, parse and free incoming messages */ static void dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port); @@ -144,10 +144,10 @@ static void dhcp_option_trailer(struct dhcp *dhcp); static void dhcp_handle_nak(struct netif *netif) { struct dhcp *dhcp = netif->dhcp; u16_t msecs = 10 * 1000; - LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_handle_nak(netif=%p) %c%c%u\n", netif, - netif->name[0], netif->name[1], (unsigned int)netif->num)); + LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_handle_nak(netif=%p) %c%c%"U16_F"\n", + (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num)); dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; - LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_handle_nak(): set request timeout %u msecs\n", msecs)); + LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_handle_nak(): set request timeout %"U16_F" msecs\n", msecs)); dhcp_set_state(dhcp, DHCP_BACKING_OFF); } @@ -163,8 +163,8 @@ static void dhcp_check(struct netif *netif) struct dhcp *dhcp = netif->dhcp; err_t result; u16_t msecs; - LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_check(netif=%p) %c%c\n", (void *)netif, (unsigned int)netif->name[0], - (unsigned int)netif->name[1])); + LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_check(netif=%p) %c%c\n", (void *)netif, (s16_t)netif->name[0], + (s16_t)netif->name[1])); /* create an ARP query for the offered IP address, expecting that no host responds, as the IP address should not be in use. */ result = etharp_query(netif, &dhcp->offered_ip_addr, NULL); @@ -174,7 +174,7 @@ static void dhcp_check(struct netif *netif) dhcp->tries++; msecs = 500; dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; - LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_check(): set request timeout %u msecs\n", msecs)); + LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_check(): set request timeout %"U16_F" msecs\n", msecs)); dhcp_set_state(dhcp, DHCP_CHECKING); } @@ -188,15 +188,15 @@ static void dhcp_handle_offer(struct netif *netif) struct dhcp *dhcp = netif->dhcp; /* obtain the server address */ u8_t *option_ptr = dhcp_get_option_ptr(dhcp, DHCP_OPTION_SERVER_ID); - LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_handle_offer(netif=%p) %c%c%u\n", netif, - netif->name[0], netif->name[1], netif->num)); + LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_handle_offer(netif=%p) %c%c%"U16_F"\n", + (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num)); if (option_ptr != NULL) { dhcp->server_ip_addr.addr = htonl(dhcp_get_option_long(&option_ptr[2])); - LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_handle_offer(): server 0x%08lx\n", dhcp->server_ip_addr.addr)); + LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_handle_offer(): server 0x%08"X32_F"\n", dhcp->server_ip_addr.addr)); /* remember offered address */ ip_addr_set(&dhcp->offered_ip_addr, (struct ip_addr *)&dhcp->msg_in->yiaddr); - LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_handle_offer(): offer for 0x%08lx\n", dhcp->offered_ip_addr.addr)); + LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_handle_offer(): offer for 0x%08"X32_F"\n", dhcp->offered_ip_addr.addr)); dhcp_select(netif); } @@ -215,7 +215,7 @@ static err_t dhcp_select(struct netif *netif) struct dhcp *dhcp = netif->dhcp; err_t result; u32_t msecs; - LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_select(netif=%p) %c%c%u\n", netif, netif->name[0], netif->name[1], netif->num)); + LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_select(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num)); /* create and initialize the DHCP message header */ result = dhcp_create_request(netif); @@ -261,7 +261,7 @@ static err_t dhcp_select(struct netif *netif) dhcp->tries++; msecs = dhcp->tries < 4 ? dhcp->tries * 1000 : 4 * 1000; dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; - LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_select(): set request timeout %u msecs\n", msecs)); + LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_select(): set request timeout %"U32_F" msecs\n", msecs)); return result; } @@ -519,7 +519,7 @@ err_t dhcp_start(struct netif *netif) err_t result = ERR_OK; LWIP_ASSERT("netif != NULL", netif != NULL); - LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_start(netif=%p) %c%c%u\n", netif, netif->name[0], netif->name[1], netif->num)); + LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_start(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num)); netif->flags &= ~NETIF_FLAG_DHCP; /* no DHCP client attached yet? */ @@ -637,7 +637,7 @@ void dhcp_arp_reply(struct netif *netif, struct ip_addr *addr) LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_arp_reply()\n")); /* is a DHCP client doing an ARP check? */ if ((netif->dhcp != NULL) && (netif->dhcp->state == DHCP_CHECKING)) { - LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_arp_reply(): CHECKING, arp reply for 0x%08lx\n", addr->addr)); + LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_arp_reply(): CHECKING, arp reply for 0x%08"X32_F"\n", addr->addr)); /* did a host respond with the address we were offered by the DHCP server? */ if (ip_addr_cmp(addr, &netif->dhcp->offered_ip_addr)) { @@ -692,7 +692,7 @@ static err_t dhcp_decline(struct netif *netif) dhcp->tries++; msecs = 10*1000; dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; - LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_decline(): set request timeout %u msecs\n", msecs)); + LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_decline(): set request timeout %"U16_F" msecs\n", msecs)); return result; } #endif @@ -747,7 +747,7 @@ static err_t dhcp_discover(struct netif *netif) dhcp->tries++; msecs = dhcp->tries < 4 ? (dhcp->tries + 1) * 1000 : 10 * 1000; dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; - LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_discover(): set request timeout %u msecs\n", msecs)); + LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_discover(): set request timeout %"U16_F" msecs\n", msecs)); return result; } @@ -763,22 +763,22 @@ static void dhcp_bind(struct netif *netif) struct ip_addr sn_mask, gw_addr; LWIP_ASSERT("dhcp_bind: netif != NULL", netif != NULL); LWIP_ASSERT("dhcp_bind: dhcp != NULL", dhcp != NULL); - LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_bind(netif=%p) %c%c%u\n", netif, netif->name[0], netif->name[1], netif->num)); + LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_bind(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num)); /* temporary DHCP lease? */ if (dhcp->offered_t1_renew != 0xffffffffUL) { /* set renewal period timer */ - LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_bind(): t1 renewal timer %lu secs\n", dhcp->offered_t1_renew)); + LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_bind(): t1 renewal timer %"U32_F" secs\n", dhcp->offered_t1_renew)); dhcp->t1_timeout = (dhcp->offered_t1_renew + DHCP_COARSE_TIMER_SECS / 2) / DHCP_COARSE_TIMER_SECS; if (dhcp->t1_timeout == 0) dhcp->t1_timeout = 1; - LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_bind(): set request timeout %u msecs\n", dhcp->offered_t1_renew*1000)); + LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_bind(): set request timeout %"U32_F" msecs\n", dhcp->offered_t1_renew*1000)); } /* set renewal period timer */ if (dhcp->offered_t2_rebind != 0xffffffffUL) { - LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_bind(): t2 rebind timer %lu secs\n", dhcp->offered_t2_rebind)); + LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_bind(): t2 rebind timer %"U32_F" secs\n", dhcp->offered_t2_rebind)); dhcp->t2_timeout = (dhcp->offered_t2_rebind + DHCP_COARSE_TIMER_SECS / 2) / DHCP_COARSE_TIMER_SECS; if (dhcp->t2_timeout == 0) dhcp->t2_timeout = 1; - LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_bind(): set request timeout %u msecs\n", dhcp->offered_t2_rebind*1000)); + LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_bind(): set request timeout %"U32_F" msecs\n", dhcp->offered_t2_rebind*1000)); } /* copy offered network mask */ ip_addr_set(&sn_mask, &dhcp->offered_sn_mask); @@ -802,11 +802,11 @@ static void dhcp_bind(struct netif *netif) gw_addr.addr |= htonl(0x00000001); } - LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_bind(): IP: 0x%08lx\n", dhcp->offered_ip_addr.addr)); + LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_bind(): IP: 0x%08"X32_F"\n", dhcp->offered_ip_addr.addr)); netif_set_ipaddr(netif, &dhcp->offered_ip_addr); - LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_bind(): SN: 0x%08lx\n", sn_mask.addr)); + LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_bind(): SN: 0x%08"X32_F"\n", sn_mask.addr)); netif_set_netmask(netif, &sn_mask); - LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_bind(): GW: 0x%08lx\n", gw_addr.addr)); + LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_bind(): GW: 0x%08"X32_F"\n", gw_addr.addr)); netif_set_gw(netif, &gw_addr); /* bring the interface up */ netif_set_up(netif); @@ -865,7 +865,7 @@ err_t dhcp_renew(struct netif *netif) /* back-off on retries, but to a maximum of 20 seconds */ msecs = dhcp->tries < 10 ? dhcp->tries * 2000 : 20 * 1000; dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; - LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_renew(): set request timeout %u msecs\n", msecs)); + LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_renew(): set request timeout %"U16_F" msecs\n", msecs)); return result; } @@ -918,7 +918,7 @@ static err_t dhcp_rebind(struct netif *netif) dhcp->tries++; msecs = dhcp->tries < 10 ? dhcp->tries * 1000 : 10 * 1000; dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; - LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_rebind(): set request timeout %u msecs\n", msecs)); + LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_rebind(): set request timeout %"U16_F" msecs\n", msecs)); return result; } @@ -964,7 +964,7 @@ err_t dhcp_release(struct netif *netif) dhcp->tries++; msecs = dhcp->tries < 10 ? dhcp->tries * 1000 : 10 * 1000; dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; - LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_release(): set request timeout %u msecs\n", msecs)); + LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_release(): set request timeout %"U16_F" msecs\n", msecs)); /* bring the interface down */ netif_set_down(netif); /* remove IP address from interface */ @@ -1013,7 +1013,7 @@ void dhcp_stop(struct netif *netif) * * TODO: we might also want to reset the timeout here? */ -static void dhcp_set_state(struct dhcp *dhcp, unsigned char new_state) +static void dhcp_set_state(struct dhcp *dhcp, u8_t new_state) { if (new_state != dhcp->state) { @@ -1109,7 +1109,7 @@ static err_t dhcp_unfold_reply(struct dhcp *dhcp) j = 0; } } - LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_unfold_reply(): copied %u bytes into dhcp->msg_in[]\n", i)); + LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_unfold_reply(): copied %"U16_F" bytes into dhcp->msg_in[]\n", i)); if (dhcp->options_in != NULL) { ptr = (u8_t *)dhcp->options_in; /* proceed through options */ @@ -1122,7 +1122,7 @@ static err_t dhcp_unfold_reply(struct dhcp *dhcp) j = 0; } } - LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_unfold_reply(): copied %u bytes to dhcp->options_in[]\n", i)); + LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_unfold_reply(): copied %"U16_F" bytes to dhcp->options_in[]\n", i)); } return ERR_OK; } @@ -1158,17 +1158,17 @@ static void dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_ u8_t *options_ptr; u8_t msg_type; u8_t i; - LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_recv(pbuf = %p) from DHCP server %u.%u.%u.%u port %u\n", p, - (unsigned int)(ntohl(addr->addr) >> 24 & 0xff), (unsigned int)(ntohl(addr->addr) >> 16 & 0xff), - (unsigned int)(ntohl(addr->addr) >> 8 & 0xff), (unsigned int)(ntohl(addr->addr) & 0xff), port)); - LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("pbuf->len = %u\n", p->len)); - LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("pbuf->tot_len = %u\n", p->tot_len)); + LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_recv(pbuf = %p) from DHCP server %"U16_F".%"U16_F".%"U16_F".%"U16_F" port %"U16_F"\n", (void*)p, + (u16_t)(ntohl(addr->addr) >> 24 & 0xff), (u16_t)(ntohl(addr->addr) >> 16 & 0xff), + (u16_t)(ntohl(addr->addr) >> 8 & 0xff), (u16_t)(ntohl(addr->addr) & 0xff), port)); + LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("pbuf->len = %"U16_F"\n", p->len)); + LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("pbuf->tot_len = %"U16_F"\n", p->tot_len)); /* prevent warnings about unused arguments */ (void)pcb; (void)addr; (void)port; dhcp->p = p; /* TODO: check packet length before reading them */ if (reply_msg->op != DHCP_BOOTREPLY) { - LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("not a DHCP reply message, but type %u\n", reply_msg->op)); + LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("not a DHCP reply message, but type %"U16_F"\n", (u16_t)reply_msg->op)); pbuf_free(p); dhcp->p = NULL; return; @@ -1176,8 +1176,8 @@ static void dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_ /* iterate through hardware address and match against DHCP message */ for (i = 0; i < netif->hwaddr_len; i++) { if (netif->hwaddr[i] != reply_msg->chaddr[i]) { - LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("netif->hwaddr[%u]==%02x != reply_msg->chaddr[%u]==%02x\n", - i, netif->hwaddr[i], i, reply_msg->chaddr[i])); + LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("netif->hwaddr[%"U16_F"]==%02"X16_F" != reply_msg->chaddr[%"U16_F"]==%02"X16_F"\n", + (u16_t)i, (u16_t)netif->hwaddr[i], (u16_t)i, (u16_t)reply_msg->chaddr[i])); pbuf_free(p); dhcp->p = NULL; return; @@ -1317,7 +1317,7 @@ static void dhcp_option_trailer(struct dhcp *dhcp) dhcp->msg_out->options[dhcp->options_out_len++] = DHCP_OPTION_END; /* packet is too small, or not 4 byte aligned? */ while ((dhcp->options_out_len < DHCP_MIN_OPTIONS_LEN) || (dhcp->options_out_len & 3)) { - /* LWIP_DEBUGF(DHCP_DEBUG, ("dhcp_option_trailer: dhcp->options_out_len=%u, DHCP_OPTIONS_LEN=%u", dhcp->options_out_len, DHCP_OPTIONS_LEN)); */ + /* LWIP_DEBUGF(DHCP_DEBUG,("dhcp_option_trailer:dhcp->options_out_len=%"U16_F", DHCP_OPTIONS_LEN=%"U16_F, dhcp->options_out_len, DHCP_OPTIONS_LEN)); */ LWIP_ASSERT("dhcp_option_trailer: dhcp->options_out_len < DHCP_OPTIONS_LEN\n", dhcp->options_out_len < DHCP_OPTIONS_LEN); /* add a fill/padding byte */ dhcp->msg_out->options[dhcp->options_out_len++] = 0; @@ -1344,7 +1344,7 @@ static u8_t *dhcp_get_option_ptr(struct dhcp *dhcp, u8_t option_type) u16_t offset = 0; /* at least 1 byte to read and no end marker, then at least 3 bytes to read? */ while ((offset < dhcp->options_in_len) && (options[offset] != DHCP_OPTION_END)) { - /* LWIP_DEBUGF(DHCP_DEBUG, ("msg_offset=%u, q->len=%u", msg_offset, q->len)); */ + /* LWIP_DEBUGF(DHCP_DEBUG, ("msg_offset=%"U16_F", q->len=%"U16_F, msg_offset, q->len)); */ /* are the sname and/or file field overloaded with options? */ if (options[offset] == DHCP_OPTION_OVERLOAD) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("overloaded message detected\n")); @@ -1354,11 +1354,11 @@ static u8_t *dhcp_get_option_ptr(struct dhcp *dhcp, u8_t option_type) } /* requested option found */ else if (options[offset] == option_type) { - LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("option found at offset %u in options\n", offset)); + LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("option found at offset %"U16_F" in options\n", offset)); return &options[offset]; /* skip option */ } else { - LWIP_DEBUGF(DHCP_DEBUG, ("skipping option %u in options\n", options[offset])); + LWIP_DEBUGF(DHCP_DEBUG, ("skipping option %"U16_F" in options\n", options[offset])); /* skip option type */ offset++; /* skip option length, and then length bytes */ @@ -1387,11 +1387,11 @@ static u8_t *dhcp_get_option_ptr(struct dhcp *dhcp, u8_t option_type) /* at least 1 byte to read and no end marker */ while ((offset < field_len) && (options[offset] != DHCP_OPTION_END)) { if (options[offset] == option_type) { - LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("option found at offset=%u\n", offset)); + LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("option found at offset=%"U16_F"\n", offset)); return &options[offset]; /* skip option */ } else { - LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("skipping option %u\n", options[offset])); + LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("skipping option %"U16_F"\n", options[offset])); /* skip option type */ offset++; offset += 1 + options[offset]; @@ -1412,7 +1412,7 @@ static u8_t *dhcp_get_option_ptr(struct dhcp *dhcp, u8_t option_type) */ static u8_t dhcp_get_option_byte(u8_t *ptr) { - LWIP_DEBUGF(DHCP_DEBUG, ("option byte value=%u\n", *ptr)); + LWIP_DEBUGF(DHCP_DEBUG, ("option byte value=%"U16_F"\n", (u16_t)(*ptr))); return *ptr; } @@ -1429,7 +1429,7 @@ static u16_t dhcp_get_option_short(u8_t *ptr) u16_t value; value = *ptr++ << 8; value |= *ptr; - LWIP_DEBUGF(DHCP_DEBUG, ("option short value=%u\n", value)); + LWIP_DEBUGF(DHCP_DEBUG, ("option short value=%"U16_F"\n", value)); return value; } @@ -1448,7 +1448,7 @@ static u32_t dhcp_get_option_long(u8_t *ptr) value |= (u32_t)(*ptr++) << 16; value |= (u32_t)(*ptr++) << 8; value |= (u32_t)(*ptr++); - LWIP_DEBUGF(DHCP_DEBUG, ("option long value=%lu\n", value)); + LWIP_DEBUGF(DHCP_DEBUG, ("option long value=%"U32_F"\n", value)); return value; } diff --git a/src/core/inet.c b/src/core/inet.c index 800f96e0..6e280a05 100644 --- a/src/core/inet.c +++ b/src/core/inet.c @@ -64,7 +64,7 @@ static u16_t lwip_standard_chksum(void *dataptr, int len) { u32_t acc; - LWIP_DEBUGF(INET_DEBUG, ("lwip_chksum(%p, %d)\n", (void *)dataptr, len)); + LWIP_DEBUGF(INET_DEBUG, ("lwip_chksum(%p, %"S16_F")\n", (void *)dataptr, len)); /* iterate by two bytes at once */ for(acc = 0; len > 1; len -= 2) { @@ -82,7 +82,7 @@ lwip_standard_chksum(void *dataptr, int len) /* add up any last odd byte */ if (len == 1) { acc += htons((u16_t)((*(u8_t *)dataptr) & 0xff) << 8); - LWIP_DEBUGF(INET_DEBUG, ("inet: chksum: odd byte %d\n", (unsigned int)(*(u8_t *)dataptr))); + LWIP_DEBUGF(INET_DEBUG, ("inet: chksum: odd byte %"U16_F"\n", (u16_t)(*(u8_t *)dataptr))); } else { LWIP_DEBUGF(INET_DEBUG, ("inet: chksum: no odd byte\n")); } @@ -116,7 +116,7 @@ inet_chksum_pseudo(struct pbuf *p, LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): checksumming pbuf %p (has next %p) \n", (void *)q, (void *)q->next)); acc += LWIP_CHKSUM(q->payload, q->len); - /*LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): unwrapped lwip_chksum()=%lx \n", acc));*/ + /*LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): unwrapped lwip_chksum()=%"X32_F" \n", acc));*/ while (acc >> 16) { acc = (acc & 0xffffUL) + (acc >> 16); } @@ -124,7 +124,7 @@ inet_chksum_pseudo(struct pbuf *p, swapped = 1 - swapped; acc = ((acc & 0xff) << 8) | ((acc & 0xff00UL) >> 8); } - /*LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): wrapped lwip_chksum()=%lx \n", acc));*/ + /*LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): wrapped lwip_chksum()=%"X32_F" \n", acc));*/ } if (swapped) { @@ -140,7 +140,7 @@ inet_chksum_pseudo(struct pbuf *p, while (acc >> 16) { acc = (acc & 0xffffUL) + (acc >> 16); } - LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): pbuf chain lwip_chksum()=%lx\n", acc)); + LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): pbuf chain lwip_chksum()=%"X32_F"\n", acc)); return (u16_t)~(acc & 0xffffUL); } @@ -225,10 +225,11 @@ inet_chksum_pbuf(struct pbuf *p) */ /* */ /* inet_aton */ - int inet_aton(const char *cp, struct in_addr *addr) + s8_t + inet_aton(const char *cp, struct in_addr *addr) { u32_t val; - int base, n; + s32_t base, n; char c; u32_t parts[4]; u32_t* pp = parts; @@ -252,11 +253,11 @@ inet_chksum_pbuf(struct pbuf *p) } for (;;) { if (isdigit(c)) { - val = (val * base) + (int)(c - '0'); + val = (val * base) + (s16_t)(c - '0'); c = *++cp; } else if (base == 16 && isxdigit(c)) { val = (val << 4) | - (int)(c + 10 - (islower(c) ? 'a' : 'A')); + (s16_t)(c + 10 - (islower(c) ? 'a' : 'A')); c = *++cp; } else break; diff --git a/src/core/ipv4/icmp.c b/src/core/ipv4/icmp.c index 68441b94..db820148 100644 --- a/src/core/ipv4/icmp.c +++ b/src/core/ipv4/icmp.c @@ -46,8 +46,8 @@ void icmp_input(struct pbuf *p, struct netif *inp) { - unsigned char type; - unsigned char code; + u8_t type; + u8_t code; struct icmp_echo_hdr *iecho; struct ip_hdr *iphdr; struct ip_addr tmpaddr; @@ -60,7 +60,7 @@ icmp_input(struct pbuf *p, struct netif *inp) iphdr = p->payload; hlen = IPH_HL(iphdr) * 4; if (pbuf_header(p, -((s16_t)hlen)) || (p->tot_len < sizeof(u16_t)*2)) { - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: short ICMP (%u bytes) received\n", p->tot_len)); + LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: short ICMP (%"U16_F" bytes) received\n", p->tot_len)); pbuf_free(p); ICMP_STATS_INC(icmp.lenerr); snmp_inc_icmpinerrors(); @@ -116,7 +116,7 @@ icmp_input(struct pbuf *p, struct netif *inp) IPH_TTL(iphdr), 0, IP_PROTO_ICMP, inp); break; default: - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %d code %d not supported.\n", (int)type, (int)code)); + LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %"S16_F" code %"S16_F" not supported.\n", (s16_t)type, (s16_t)code)); ICMP_STATS_INC(icmp.proterr); ICMP_STATS_INC(icmp.drop); } @@ -139,7 +139,7 @@ icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t) ICMPH_TYPE_SET(idur, ICMP_DUR); ICMPH_CODE_SET(idur, t); - memcpy((char *)q->payload + 8, p->payload, IP_HLEN + 8); + memcpy((u8_t *)q->payload + 8, p->payload, IP_HLEN + 8); /* calculate checksum */ idur->chksum = 0; @@ -177,7 +177,7 @@ icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t) ICMPH_CODE_SET(tehdr, t); /* copy fields from original packet */ - memcpy((char *)q->payload + 8, (char *)p->payload, IP_HLEN + 8); + memcpy((u8_t *)q->payload + 8, (u8_t *)p->payload, IP_HLEN + 8); /* calculate checksum */ tehdr->chksum = 0; diff --git a/src/core/ipv4/ip.c b/src/core/ipv4/ip.c index 368d9776..4db68c8e 100644 --- a/src/core/ipv4/ip.c +++ b/src/core/ipv4/ip.c @@ -110,7 +110,7 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp) /* Find network interface where to forward this IP packet to. */ netif = ip_route((struct ip_addr *)&(iphdr->dest)); if (netif == NULL) { - LWIP_DEBUGF(IP_DEBUG, ("ip_forward: no forwarding route for 0x%lx found\n", + LWIP_DEBUGF(IP_DEBUG, ("ip_forward: no forwarding route for 0x%"X32_F" found\n", iphdr->dest.addr)); snmp_inc_ipnoroutes(); return (struct netif *)NULL; @@ -142,7 +142,7 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp) IPH_CHKSUM_SET(iphdr, IPH_CHKSUM(iphdr) + htons(0x100)); } - LWIP_DEBUGF(IP_DEBUG, ("ip_forward: forwarding packet to 0x%lx\n", + LWIP_DEBUGF(IP_DEBUG, ("ip_forward: forwarding packet to 0x%"X32_F"\n", iphdr->dest.addr)); IP_STATS_INC(ip.fw); @@ -181,7 +181,7 @@ ip_input(struct pbuf *p, struct netif *inp) { /* identify the IP header */ iphdr = p->payload; if (IPH_V(iphdr) != 4) { - LWIP_DEBUGF(IP_DEBUG | 1, ("IP packet dropped due to bad version number %u\n", IPH_V(iphdr))); + LWIP_DEBUGF(IP_DEBUG | 1, ("IP packet dropped due to bad version number %"U16_F"\n", IPH_V(iphdr))); ip_debug_print(p); pbuf_free(p); IP_STATS_INC(ip.err); @@ -196,7 +196,7 @@ ip_input(struct pbuf *p, struct netif *inp) { /* header length exceeds first pbuf length? */ if (iphdrlen > p->len) { - LWIP_DEBUGF(IP_DEBUG | 2, ("IP header (len %u) does not fit in first pbuf (len %u), IP packet droppped.\n", + LWIP_DEBUGF(IP_DEBUG | 2, ("IP header (len %"U16_F") does not fit in first pbuf (len %"U16_F"), IP packet droppped.\n", iphdrlen, p->len)); /* free (drop) packet pbufs */ pbuf_free(p); @@ -210,7 +210,7 @@ ip_input(struct pbuf *p, struct netif *inp) { #if CHECKSUM_CHECK_IP if (inet_chksum(iphdr, iphdrlen) != 0) { - LWIP_DEBUGF(IP_DEBUG | 2, ("Checksum (0x%x) failed, IP packet dropped.\n", inet_chksum(iphdr, iphdrlen))); + LWIP_DEBUGF(IP_DEBUG | 2, ("Checksum (0x%"X16_F") failed, IP packet dropped.\n", inet_chksum(iphdr, iphdrlen))); ip_debug_print(p); pbuf_free(p); IP_STATS_INC(ip.chkerr); @@ -227,7 +227,7 @@ ip_input(struct pbuf *p, struct netif *inp) { /* match packet against an interface, i.e. is this packet for us? */ for (netif = netif_list; netif != NULL; netif = netif->next) { - LWIP_DEBUGF(IP_DEBUG, ("ip_input: iphdr->dest 0x%lx netif->ip_addr 0x%lx (0x%lx, 0x%lx, 0x%lx)\n", + LWIP_DEBUGF(IP_DEBUG, ("ip_input: iphdr->dest 0x%"X32_F" netif->ip_addr 0x%"X32_F" (0x%"X32_F", 0x%"X32_F", 0x%"X32_F")\n", iphdr->dest.addr, netif->ip_addr.addr, iphdr->dest.addr & netif->netmask.addr, netif->ip_addr.addr & netif->netmask.addr, @@ -255,7 +255,7 @@ ip_input(struct pbuf *p, struct netif *inp) { if (netif == NULL) { /* remote port is DHCP server? */ if (IPH_PROTO(iphdr) == IP_PROTO_UDP) { - LWIP_DEBUGF(IP_DEBUG | DBG_TRACE | 1, ("ip_input: UDP packet to DHCP client port %u\n", + LWIP_DEBUGF(IP_DEBUG | DBG_TRACE | 1, ("ip_input: UDP packet to DHCP client port %"U16_F"\n", ntohs(((struct udp_hdr *)((u8_t *)iphdr + iphdrlen))->dest))); if (ntohs(((struct udp_hdr *)((u8_t *)iphdr + iphdrlen))->dest) == DHCP_CLIENT_PORT) { LWIP_DEBUGF(IP_DEBUG | DBG_TRACE | 1, ("ip_input: DHCP packet accepted.\n")); @@ -285,7 +285,7 @@ ip_input(struct pbuf *p, struct netif *inp) { /* packet consists of multiple fragments? */ if ((IPH_OFFSET(iphdr) & htons(IP_OFFMASK | IP_MF)) != 0) { #if IP_REASSEMBLY /* packet fragment reassembly code present? */ - LWIP_DEBUGF(IP_DEBUG, ("IP packet is a fragment (id=0x%04x tot_len=%u len=%u MF=%u offset=%u), calling ip_reass()\n", + LWIP_DEBUGF(IP_DEBUG, ("IP packet is a fragment (id=0x%04"X16_F" tot_len=%"U16_F" len=%"U16_F" MF=%"U16_F" offset=%"U16_F"), calling ip_reass()\n", ntohs(IPH_ID(iphdr)), p->tot_len, ntohs(IPH_LEN(iphdr)), !!(IPH_OFFSET(iphdr) & htons(IP_MF)), (ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK)*8)); /* reassemble the packet*/ p = ip_reass(p); @@ -296,7 +296,7 @@ ip_input(struct pbuf *p, struct netif *inp) { iphdr = p->payload; #else /* IP_REASSEMBLY == 0, no packet fragment reassembly code present */ pbuf_free(p); - LWIP_DEBUGF(IP_DEBUG | 2, ("IP packet dropped since it was fragmented (0x%x) (while IP_REASSEMBLY == 0).\n", + LWIP_DEBUGF(IP_DEBUG | 2, ("IP packet dropped since it was fragmented (0x%"X16_F") (while IP_REASSEMBLY == 0).\n", ntohs(IPH_OFFSET(iphdr)))); IP_STATS_INC(ip.opterr); IP_STATS_INC(ip.drop); @@ -319,7 +319,7 @@ ip_input(struct pbuf *p, struct netif *inp) { /* send to upper layers */ LWIP_DEBUGF(IP_DEBUG, ("ip_input: \n")); ip_debug_print(p); - LWIP_DEBUGF(IP_DEBUG, ("ip_input: p->len %d p->tot_len %d\n", p->len, p->tot_len)); + LWIP_DEBUGF(IP_DEBUG, ("ip_input: p->len %"U16_F" p->tot_len %"U16_F"\n", p->len, p->tot_len)); #if LWIP_RAW /* raw input did not eat the packet? */ @@ -353,7 +353,7 @@ ip_input(struct pbuf *p, struct netif *inp) { } pbuf_free(p); - LWIP_DEBUGF(IP_DEBUG | 2, ("Unsupported transport protocol %d\n", IPH_PROTO(iphdr))); + LWIP_DEBUGF(IP_DEBUG | 2, ("Unsupported transport protocol %"U16_F"\n", IPH_PROTO(iphdr))); IP_STATS_INC(ip.proterr); IP_STATS_INC(ip.drop); @@ -427,7 +427,7 @@ ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, IP_STATS_INC(ip.xmit); - LWIP_DEBUGF(IP_DEBUG, ("ip_output_if: %c%c%u\n", netif->name[0], netif->name[1], netif->num)); + LWIP_DEBUGF(IP_DEBUG, ("ip_output_if: %c%c%"U16_F"\n", netif->name[0], netif->name[1], netif->num)); ip_debug_print(p); LWIP_DEBUGF(IP_DEBUG, ("netif->output()")); @@ -447,7 +447,7 @@ ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, struct netif *netif; if ((netif = ip_route(dest)) == NULL) { - LWIP_DEBUGF(IP_DEBUG | 2, ("ip_output: No route to 0x%lx\n", dest->addr)); + LWIP_DEBUGF(IP_DEBUG | 2, ("ip_output: No route to 0x%"X32_F"\n", dest->addr)); IP_STATS_INC(ip.rterr); snmp_inc_ipoutdiscards(); @@ -468,31 +468,31 @@ ip_debug_print(struct pbuf *p) LWIP_DEBUGF(IP_DEBUG, ("IP header:\n")); LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(IP_DEBUG, ("|%2d |%2d | 0x%02x | %5u | (v, hl, tos, len)\n", + LWIP_DEBUGF(IP_DEBUG, ("|%2"S16_F" |%2"S16_F" | 0x%02"X16_F" | %5"U16_F" | (v, hl, tos, len)\n", IPH_V(iphdr), IPH_HL(iphdr), IPH_TOS(iphdr), ntohs(IPH_LEN(iphdr)))); LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(IP_DEBUG, ("| %5u |%u%u%u| %4u | (id, flags, offset)\n", + LWIP_DEBUGF(IP_DEBUG, ("| %5"U16_F" |%"U16_F"%"U16_F"%"U16_F"| %4"U16_F" | (id, flags, offset)\n", ntohs(IPH_ID(iphdr)), ntohs(IPH_OFFSET(iphdr)) >> 15 & 1, ntohs(IPH_OFFSET(iphdr)) >> 14 & 1, ntohs(IPH_OFFSET(iphdr)) >> 13 & 1, ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK)); LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(IP_DEBUG, ("| %3u | %3u | 0x%04x | (ttl, proto, chksum)\n", + LWIP_DEBUGF(IP_DEBUG, ("| %3"U16_F" | %3"U16_F" | 0x%04"X16_F" | (ttl, proto, chksum)\n", IPH_TTL(iphdr), IPH_PROTO(iphdr), ntohs(IPH_CHKSUM(iphdr)))); LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(IP_DEBUG, ("| %3u | %3u | %3u | %3u | (src)\n", + LWIP_DEBUGF(IP_DEBUG, ("| %3"U16_F" | %3"U16_F" | %3"U16_F" | %3"U16_F" | (src)\n", ip4_addr1(&iphdr->src), ip4_addr2(&iphdr->src), ip4_addr3(&iphdr->src), ip4_addr4(&iphdr->src))); LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(IP_DEBUG, ("| %3u | %3u | %3u | %3u | (dest)\n", + LWIP_DEBUGF(IP_DEBUG, ("| %3"U16_F" | %3"U16_F" | %3"U16_F" | %3"U16_F" | (dest)\n", ip4_addr1(&iphdr->dest), ip4_addr2(&iphdr->dest), ip4_addr3(&iphdr->dest), diff --git a/src/core/ipv4/ip_frag.c b/src/core/ipv4/ip_frag.c index c3e30e75..ab577fb1 100644 --- a/src/core/ipv4/ip_frag.c +++ b/src/core/ipv4/ip_frag.c @@ -142,7 +142,7 @@ ip_reass(struct pbuf *p) reassembly buffer, we discard the entire packet. */ if (offset > IP_REASS_BUFSIZE || offset + len > IP_REASS_BUFSIZE) { LWIP_DEBUGF(IP_REASS_DEBUG, - ("ip_reass: fragment outside of buffer (%d:%d/%d).\n", offset, + ("ip_reass: fragment outside of buffer (%"S16_F":%"S16_F"/%"S16_F").\n", offset, offset + len, IP_REASS_BUFSIZE)); sys_untimeout(ip_reass_timer, NULL); ip_reasstmr = 0; @@ -152,7 +152,7 @@ ip_reass(struct pbuf *p) /* Copy the fragment into the reassembly buffer, at the right offset. */ LWIP_DEBUGF(IP_REASS_DEBUG, - ("ip_reass: copying with offset %d into %d:%d\n", offset, + ("ip_reass: copying with offset %"S16_F" into %"S16_F":%"S16_F"\n", offset, IP_HLEN + offset, IP_HLEN + offset + len)); i = IPH_HL(fraghdr) * 4; copy_from_pbuf(p, &i, &ip_reassbuf[IP_HLEN + offset], len); @@ -172,7 +172,7 @@ ip_reass(struct pbuf *p) 0xff. */ ip_reassbitmap[offset / (8 * 8)] |= bitmap_bits[(offset / 8) & 7]; LWIP_DEBUGF(IP_REASS_DEBUG, - ("ip_reass: updating many bytes in bitmap (%d:%d).\n", + ("ip_reass: updating many bytes in bitmap (%"S16_F":%"S16_F").\n", 1 + offset / (8 * 8), (offset + len) / (8 * 8))); for (i = 1 + offset / (8 * 8); i < (offset + len) / (8 * 8); ++i) { ip_reassbitmap[i] = 0xff; @@ -191,7 +191,7 @@ ip_reass(struct pbuf *p) ip_reassflags |= IP_REASS_FLAG_LASTFRAG; ip_reasslen = offset + len; LWIP_DEBUGF(IP_REASS_DEBUG, - ("ip_reass: last fragment seen, total len %d\n", + ("ip_reass: last fragment seen, total len %"S16_F"\n", ip_reasslen)); } @@ -204,7 +204,7 @@ ip_reass(struct pbuf *p) for (i = 0; i < ip_reasslen / (8 * 8) - 1; ++i) { if (ip_reassbitmap[i] != 0xff) { LWIP_DEBUGF(IP_REASS_DEBUG, - ("ip_reass: last fragment seen, bitmap %d/%d failed (%x)\n", + ("ip_reass: last fragment seen, bitmap %"S16_F"/%"S16_F" failed (%"X16_F")\n", i, ip_reasslen / (8 * 8) - 1, ip_reassbitmap[i])); goto nullreturn; } @@ -214,7 +214,7 @@ ip_reass(struct pbuf *p) if (ip_reassbitmap[ip_reasslen / (8 * 8)] != (u8_t) ~ bitmap_bits[ip_reasslen / 8 & 7]) { LWIP_DEBUGF(IP_REASS_DEBUG, - ("ip_reass: last fragment seen, bitmap %d didn't contain %x (%x)\n", + ("ip_reass: last fragment seen, bitmap %"S16_F" didn't contain %"X16_F" (%"X16_F")\n", ip_reasslen / (8 * 8), ~bitmap_bits[ip_reasslen / 8 & 7], ip_reassbitmap[ip_reasslen / (8 * 8)])); goto nullreturn; @@ -243,7 +243,7 @@ ip_reass(struct pbuf *p) available data in the pbuf is given by the q->len variable. */ LWIP_DEBUGF(IP_REASS_DEBUG, - ("ip_reass: memcpy from %p (%d) to %p, %d bytes\n", + ("ip_reass: memcpy from %p (%"S16_F") to %p, %"S16_F" bytes\n", (void *)&ip_reassbuf[i], i, q->payload, q->len > ip_reasslen - i ? ip_reasslen - i : q->len)); memcpy(q->payload, &ip_reassbuf[i], diff --git a/src/core/ipv6/icmp6.c b/src/core/ipv6/icmp6.c index a162758a..10b6903c 100644 --- a/src/core/ipv6/icmp6.c +++ b/src/core/ipv6/icmp6.c @@ -46,7 +46,7 @@ void icmp_input(struct pbuf *p, struct netif *inp) { - unsigned char type; + u8_t type; struct icmp_echo_hdr *iecho; struct ip_hdr *iphdr; struct ip_addr tmpaddr; @@ -57,7 +57,7 @@ icmp_input(struct pbuf *p, struct netif *inp) /* TODO: check length before accessing payload! */ - type = ((char *)p->payload)[0]; + type = ((u8_t *)p->payload)[0]; switch (type) { case ICMP6_ECHO: @@ -74,16 +74,16 @@ icmp_input(struct pbuf *p, struct netif *inp) return; } iecho = p->payload; - iphdr = (struct ip_hdr *)((char *)p->payload - IP_HLEN); + iphdr = (struct ip_hdr *)((u8_t *)p->payload - IP_HLEN); if (inet_chksum_pbuf(p) != 0) { - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo (%x)\n", inet_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest), IP_PROTO_ICMP, p->tot_len))); + LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo (%"X16_F")\n", inet_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest), IP_PROTO_ICMP, p->tot_len))); #ifdef ICMP_STATS ++lwip_stats.icmp.chkerr; #endif /* ICMP_STATS */ /* return;*/ } - LWIP_DEBUGF(ICMP_DEBUG, ("icmp: p->len %d p->tot_len %d\n", p->len, p->tot_len)); + LWIP_DEBUGF(ICMP_DEBUG, ("icmp: p->len %"S16_F" p->tot_len %"S16_F"\n", p->len, p->tot_len)); ip_addr_set(&tmpaddr, &(iphdr->src)); ip_addr_set(&(iphdr->src), &(iphdr->dest)); ip_addr_set(&(iphdr->dest), &tmpaddr); @@ -94,17 +94,17 @@ icmp_input(struct pbuf *p, struct netif *inp) } else { iecho->chksum += htons(ICMP6_ECHO << 8); } - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo (%x)\n", inet_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest), IP_PROTO_ICMP, p->tot_len))); + LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo (%"X16_F")\n", inet_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest), IP_PROTO_ICMP, p->tot_len))); #ifdef ICMP_STATS ++lwip_stats.icmp.xmit; #endif /* ICMP_STATS */ - /* LWIP_DEBUGF("icmp: p->len %u p->tot_len %u\n", p->len, p->tot_len);*/ + /* LWIP_DEBUGF("icmp: p->len %"U16_F" p->tot_len %"U16_F"\n", p->len, p->tot_len);*/ ip_output_if (p, &(iphdr->src), IP_HDRINCL, iphdr->hoplim, IP_PROTO_ICMP, inp); break; default: - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %d not supported.\n", (int)type)); + LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %"S16_F" not supported.\n", (s16_t)type)); #ifdef ICMP_STATS ++lwip_stats.icmp.proterr; ++lwip_stats.icmp.drop; @@ -127,10 +127,10 @@ icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t) iphdr = p->payload; idur = q->payload; - idur->type = (char)ICMP6_DUR; - idur->icode = (char)t; + idur->type = (u8_t)ICMP6_DUR; + idur->icode = (u8_t)t; - memcpy((char *)q->payload + 8, p->payload, IP_HLEN + 8); + memcpy((u8_t *)q->payload + 8, p->payload, IP_HLEN + 8); /* calculate checksum */ idur->chksum = 0; @@ -158,11 +158,11 @@ icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t) iphdr = p->payload; tehdr = q->payload; - tehdr->type = (char)ICMP6_TE; - tehdr->icode = (char)t; + tehdr->type = (u8_t)ICMP6_TE; + tehdr->icode = (u8_t)t; /* copy fields from original packet */ - memcpy((char *)q->payload + 8, (char *)p->payload, IP_HLEN + 8); + memcpy((u8_t *)q->payload + 8, (u8_t *)p->payload, IP_HLEN + 8); /* calculate checksum */ tehdr->chksum = 0; diff --git a/src/core/ipv6/ip6.c b/src/core/ipv6/ip6.c index abce830c..03037c81 100644 --- a/src/core/ipv6/ip6.c +++ b/src/core/ipv6/ip6.c @@ -217,7 +217,7 @@ ip_input(struct pbuf *p, struct netif *inp) { #if IP_DEBUG /* LWIP_DEBUGF("ip_input: \n"); ip_debug_print(p); - LWIP_DEBUGF("ip_input: p->len %u p->tot_len %u\n", p->len, p->tot_len);*/ + LWIP_DEBUGF("ip_input: p->len %"U16_F" p->tot_len %"U16_F"\n", p->len, p->tot_len);*/ #endif /* IP_DEBUG */ @@ -237,7 +237,7 @@ ip_input(struct pbuf *p, struct netif *inp) { /* send ICMP destination protocol unreachable */ icmp_dest_unreach(p, ICMP_DUR_PROTO); pbuf_free(p); - LWIP_DEBUGF(IP_DEBUG, ("Unsupported transport protocol %u\n", + LWIP_DEBUGF(IP_DEBUG, ("Unsupported transport protocol %"U16_F"\n", iphdr->nexthdr)); #ifdef IP_STATS @@ -266,7 +266,7 @@ ip_output_if (struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, PERF_START; - printf("len %u tot_len %u\n", p->len, p->tot_len); + printf("len %"U16_F" tot_len %"U16_F"\n", p->len, p->tot_len); if (pbuf_header(p, IP_HLEN)) { LWIP_DEBUGF(IP_DEBUG, ("ip_output: not enough room for IP header in pbuf\n")); #ifdef IP_STATS @@ -275,7 +275,7 @@ ip_output_if (struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, return ERR_BUF; } - printf("len %u tot_len %u\n", p->len, p->tot_len); + printf("len %"U16_F" tot_len %"U16_F"\n", p->len, p->tot_len); iphdr = p->payload; @@ -303,7 +303,7 @@ ip_output_if (struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, ++lwip_stats.ip.xmit; #endif /* IP_STATS */ - LWIP_DEBUGF(IP_DEBUG, ("ip_output_if: %c%c (len %u)\n", netif->name[0], netif->name[1], p->tot_len)); + LWIP_DEBUGF(IP_DEBUG, ("ip_output_if: %c%c (len %"U16_F")\n", netif->name[0], netif->name[1], p->tot_len)); #if IP_DEBUG ip_debug_print(p); #endif /* IP_DEBUG */ @@ -324,7 +324,7 @@ ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, { struct netif *netif; if ((netif = ip_route(dest)) == NULL) { - LWIP_DEBUGF(IP_DEBUG, ("ip_output: No route to 0x%lx\n", dest->addr)); + LWIP_DEBUGF(IP_DEBUG, ("ip_output: No route to 0x%"X32_F"\n", dest->addr)); #ifdef IP_STATS ++lwip_stats.ip.rterr; #endif /* IP_STATS */ @@ -339,45 +339,45 @@ void ip_debug_print(struct pbuf *p) { struct ip_hdr *iphdr = p->payload; - char *payload; + u8_t *payload; - payload = (char *)iphdr + IP_HLEN; + payload = (u8_t *)iphdr + IP_HLEN; LWIP_DEBUGF(IP_DEBUG, ("IP header:\n")); LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(IP_DEBUG, ("|%2d | %x%x | %x%x | (v, traffic class, flow label)\n", + LWIP_DEBUGF(IP_DEBUG, ("|%2"S16_F" | %"X16_F"%"X16_F" | %"X16_F"%"X16_F" | (v, traffic class, flow label)\n", iphdr->v, iphdr->tclass1, iphdr->tclass2, iphdr->flow1, iphdr->flow2)); LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(IP_DEBUG, ("| %5u | %2u | %2u | (len, nexthdr, hoplim)\n", + LWIP_DEBUGF(IP_DEBUG, ("| %5"U16_F" | %2"U16_F" | %2"U16_F" | (len, nexthdr, hoplim)\n", ntohs(iphdr->len), iphdr->nexthdr, iphdr->hoplim)); LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(IP_DEBUG, ("| %4lx | %4lx | (src)\n", + LWIP_DEBUGF(IP_DEBUG, ("| %4"X32_F" | %4"X32_F" | (src)\n", ntohl(iphdr->src.addr[0]) >> 16 & 0xffff, ntohl(iphdr->src.addr[0]) & 0xffff)); - LWIP_DEBUGF(IP_DEBUG, ("| %4lx | %4lx | (src)\n", + LWIP_DEBUGF(IP_DEBUG, ("| %4"X32_F" | %4"X32_F" | (src)\n", ntohl(iphdr->src.addr[1]) >> 16 & 0xffff, ntohl(iphdr->src.addr[1]) & 0xffff)); - LWIP_DEBUGF(IP_DEBUG, ("| %4lx | %4lx | (src)\n", + LWIP_DEBUGF(IP_DEBUG, ("| %4"X32_F" | %4"X32_F" | (src)\n", ntohl(iphdr->src.addr[2]) >> 16 & 0xffff, ntohl(iphdr->src.addr[2]) & 0xffff)); - LWIP_DEBUGF(IP_DEBUG, ("| %4lx | %4lx | (src)\n", + LWIP_DEBUGF(IP_DEBUG, ("| %4"X32_F" | %4"X32_F" | (src)\n", ntohl(iphdr->src.addr[3]) >> 16 & 0xffff, ntohl(iphdr->src.addr[3]) & 0xffff)); LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(IP_DEBUG, ("| %4lx | %4lx | (dest)\n", + LWIP_DEBUGF(IP_DEBUG, ("| %4"X32_F" | %4"X32_F" | (dest)\n", ntohl(iphdr->dest.addr[0]) >> 16 & 0xffff, ntohl(iphdr->dest.addr[0]) & 0xffff)); - LWIP_DEBUGF(IP_DEBUG, ("| %4lx | %4lx | (dest)\n", + LWIP_DEBUGF(IP_DEBUG, ("| %4"X32_F" | %4"X32_F" | (dest)\n", ntohl(iphdr->dest.addr[1]) >> 16 & 0xffff, ntohl(iphdr->dest.addr[1]) & 0xffff)); - LWIP_DEBUGF(IP_DEBUG, ("| %4lx | %4lx | (dest)\n", + LWIP_DEBUGF(IP_DEBUG, ("| %4"X32_F" | %4"X32_F" | (dest)\n", ntohl(iphdr->dest.addr[2]) >> 16 & 0xffff, ntohl(iphdr->dest.addr[2]) & 0xffff)); - LWIP_DEBUGF(IP_DEBUG, ("| %4lx | %4lx | (dest)\n", + LWIP_DEBUGF(IP_DEBUG, ("| %4"X32_F" | %4"X32_F" | (dest)\n", ntohl(iphdr->dest.addr[3]) >> 16 & 0xffff, ntohl(iphdr->dest.addr[3]) & 0xffff)); LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); diff --git a/src/core/ipv6/ip6_addr.c b/src/core/ipv6/ip6_addr.c index d1bc358a..dcb50785 100644 --- a/src/core/ipv6/ip6_addr.c +++ b/src/core/ipv6/ip6_addr.c @@ -34,7 +34,7 @@ #include "lwip/inet.h" -int +u8_t ip_addr_netcmp(struct ip_addr *addr1, struct ip_addr *addr2, struct ip_addr *mask) { @@ -45,7 +45,7 @@ ip_addr_netcmp(struct ip_addr *addr1, struct ip_addr *addr2, } -int +u8_t ip_addr_cmp(struct ip_addr *addr1, struct ip_addr *addr2) { return(addr1->addr[0] == addr2->addr[0] && @@ -64,7 +64,7 @@ ip_addr_set(struct ip_addr *dest, struct ip_addr *src) dest->addr[3] = src->addr[3];*/ } -int +u8_t ip_addr_isany(struct ip_addr *addr) { if (addr == NULL) return 1; @@ -76,7 +76,7 @@ ip_addr_isany(struct ip_addr *addr) void ip_addr_debug_print(struct ip_addr *addr) { - printf("%lx:%lx:%lx:%lx:%lx:%lx:%lx:%lx", + printf("%"X32_F":%"X32_F":%"X32_F":%"X32_F":%"X32_F":%"X32_F":%"X32_F":%"X32_F", ntohl(addr->addr[0]) >> 16 & 0xffff, ntohl(addr->addr[0]) & 0xffff, ntohl(addr->addr[1]) >> 16 & 0xffff, diff --git a/src/core/mem.c b/src/core/mem.c index aea62963..b38d8f15 100644 --- a/src/core/mem.c +++ b/src/core/mem.c @@ -301,7 +301,7 @@ mem_malloc(mem_size_t size) return (u8_t *)mem + SIZEOF_STRUCT_MEM; } } - LWIP_DEBUGF(MEM_DEBUG | 2, ("mem_malloc: could not allocate %d bytes\n", (int)size)); + LWIP_DEBUGF(MEM_DEBUG | 2, ("mem_malloc: could not allocate %"S16_F" bytes\n", (s16_t)size)); #if MEM_STATS ++lwip_stats.mem.err; #endif /* MEM_STATS */ diff --git a/src/core/memp.c b/src/core/memp.c index c570b7e1..c0cfce29 100644 --- a/src/core/memp.c +++ b/src/core/memp.c @@ -124,7 +124,7 @@ static sys_sem_t mutex; static int memp_sanity(void) { - int i, c; + s16_t i, c; struct memp *m, *n; for(i = 0; i < MEMP_MAX; i++) { @@ -222,7 +222,7 @@ memp_malloc(memp_t type) mem = MEM_ALIGN((u8_t *)memp + sizeof(struct memp)); return mem; } else { - LWIP_DEBUGF(MEMP_DEBUG | 2, ("memp_malloc: out of memory in pool %d\n", type)); + LWIP_DEBUGF(MEMP_DEBUG | 2, ("memp_malloc: out of memory in pool %"S16_F"\n", type)); #if MEMP_STATS ++lwip_stats.memp[type].err; #endif /* MEMP_STATS */ diff --git a/src/core/netif.c b/src/core/netif.c index 32deb8d9..3525089b 100644 --- a/src/core/netif.c +++ b/src/core/netif.c @@ -67,7 +67,7 @@ netif_add(struct netif *netif, struct ip_addr *ipaddr, struct ip_addr *netmask, err_t (* init)(struct netif *netif), err_t (* input)(struct pbuf *p, struct netif *netif)) { - static int netifnum = 0; + static s16_t netifnum = 0; #if LWIP_DHCP /* netif not under DHCP control by default */ @@ -205,7 +205,7 @@ netif_set_ipaddr(struct netif *netif, struct ip_addr *ipaddr) */ etharp_query(netif, ipaddr, NULL); #endif - LWIP_DEBUGF(NETIF_DEBUG | DBG_TRACE | DBG_STATE | 3, ("netif: IP address of interface %c%c set to %u.%u.%u.%u\n", + LWIP_DEBUGF(NETIF_DEBUG | DBG_TRACE | DBG_STATE | 3, ("netif: IP address of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", netif->name[0], netif->name[1], ip4_addr1(&netif->ip_addr), ip4_addr2(&netif->ip_addr), @@ -217,7 +217,7 @@ void netif_set_gw(struct netif *netif, struct ip_addr *gw) { ip_addr_set(&(netif->gw), gw); - LWIP_DEBUGF(NETIF_DEBUG | DBG_TRACE | DBG_STATE | 3, ("netif: GW address of interface %c%c set to %u.%u.%u.%u\n", + LWIP_DEBUGF(NETIF_DEBUG | DBG_TRACE | DBG_STATE | 3, ("netif: GW address of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", netif->name[0], netif->name[1], ip4_addr1(&netif->gw), ip4_addr2(&netif->gw), @@ -229,7 +229,7 @@ void netif_set_netmask(struct netif *netif, struct ip_addr *netmask) { ip_addr_set(&(netif->netmask), netmask); - LWIP_DEBUGF(NETIF_DEBUG | DBG_TRACE | DBG_STATE | 3, ("netif: netmask of interface %c%c set to %u.%u.%u.%u\n", + LWIP_DEBUGF(NETIF_DEBUG | DBG_TRACE | DBG_STATE | 3, ("netif: netmask of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", netif->name[0], netif->name[1], ip4_addr1(&netif->netmask), ip4_addr2(&netif->netmask), diff --git a/src/core/pbuf.c b/src/core/pbuf.c index 47c204ad..388d7527 100644 --- a/src/core/pbuf.c +++ b/src/core/pbuf.c @@ -215,7 +215,7 @@ pbuf_alloc(pbuf_layer l, u16_t length, pbuf_flag flag) struct pbuf *p, *q, *r; u16_t offset; s32_t rem_len; /* remaining length */ - LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_alloc(length=%u)\n", length)); + LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_alloc(length=%"U16_F")\n", length)); /* determine header offset */ offset = 0; @@ -339,7 +339,7 @@ pbuf_alloc(pbuf_layer l, u16_t length, pbuf_flag flag) } /* set reference count */ p->ref = 1; - LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_alloc(length=%u) == %p\n", length, (void *)p)); + LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_alloc(length=%"U16_F") == %p\n", length, (void *)p)); return p; } @@ -503,7 +503,7 @@ pbuf_header(struct pbuf *p, s16_t header_size_increment) p->len += header_size_increment; p->tot_len += header_size_increment; - LWIP_DEBUGF( PBUF_DEBUG, ("pbuf_header: old %p new %p (%d)\n", + LWIP_DEBUGF( PBUF_DEBUG, ("pbuf_header: old %p new %p (%"S16_F")\n", (void *)payload, (void *)p->payload, header_size_increment)); return 0; @@ -598,7 +598,7 @@ pbuf_free(struct pbuf *p) /* p->ref > 0, this pbuf is still referenced to */ /* (and so the remaining pbufs in chain as well) */ } else { - LWIP_DEBUGF( PBUF_DEBUG | 2, ("pbuf_free: %p has ref %u, ending here.\n", (void *)p, (unsigned int)p->ref)); + LWIP_DEBUGF( PBUF_DEBUG | 2, ("pbuf_free: %p has ref %"U16_F", ending here.\n", (void *)p, (u16_t)p->ref)); /* stop walking through the chain */ p = NULL; } diff --git a/src/core/raw.c b/src/core/raw.c index 95f3a5a9..30199804 100644 --- a/src/core/raw.c +++ b/src/core/raw.c @@ -87,7 +87,7 @@ raw_input(struct pbuf *p, struct netif *inp) { struct raw_pcb *pcb; struct ip_hdr *iphdr; - int proto; + s16_t proto; u8_t eaten = 0; iphdr = p->payload; @@ -224,7 +224,7 @@ raw_sendto(struct raw_pcb *pcb, struct pbuf *p, struct ip_addr *ipaddr) } if ((netif = ip_route(ipaddr)) == NULL) { - LWIP_DEBUGF(RAW_DEBUG | 1, ("raw_sendto: No route to 0x%lx\n", ipaddr->addr)); + LWIP_DEBUGF(RAW_DEBUG | 1, ("raw_sendto: No route to 0x%"X32_F"\n", ipaddr->addr)); #if RAW_STATS /* ++lwip_stats.raw.rterr;*/ #endif /* RAW_STATS */ diff --git a/src/core/stats.c b/src/core/stats.c index 56768896..c94623f7 100644 --- a/src/core/stats.c +++ b/src/core/stats.c @@ -53,48 +53,48 @@ void stats_display_proto(struct stats_proto *proto, char *name) { LWIP_PLATFORM_DIAG(("\n%s\n\t", name)); - LWIP_PLATFORM_DIAG(("xmit: %d\n\t", proto->xmit)); - LWIP_PLATFORM_DIAG(("rexmit: %d\n\t", proto->rexmit)); - LWIP_PLATFORM_DIAG(("recv: %d\n\t", proto->recv)); - LWIP_PLATFORM_DIAG(("fw: %d\n\t", proto->fw)); - LWIP_PLATFORM_DIAG(("drop: %d\n\t", proto->drop)); - LWIP_PLATFORM_DIAG(("chkerr: %d\n\t", proto->chkerr)); - LWIP_PLATFORM_DIAG(("lenerr: %d\n\t", proto->lenerr)); - LWIP_PLATFORM_DIAG(("memerr: %d\n\t", proto->memerr)); - LWIP_PLATFORM_DIAG(("rterr: %d\n\t", proto->rterr)); - LWIP_PLATFORM_DIAG(("proterr: %d\n\t", proto->proterr)); - LWIP_PLATFORM_DIAG(("opterr: %d\n\t", proto->opterr)); - LWIP_PLATFORM_DIAG(("err: %d\n\t", proto->err)); - LWIP_PLATFORM_DIAG(("cachehit: %d\n", proto->cachehit)); + LWIP_PLATFORM_DIAG(("xmit: %"S16_F"\n\t", proto->xmit)); + LWIP_PLATFORM_DIAG(("rexmit: %"S16_F"\n\t", proto->rexmit)); + LWIP_PLATFORM_DIAG(("recv: %"S16_F"\n\t", proto->recv)); + LWIP_PLATFORM_DIAG(("fw: %"S16_F"\n\t", proto->fw)); + LWIP_PLATFORM_DIAG(("drop: %"S16_F"\n\t", proto->drop)); + LWIP_PLATFORM_DIAG(("chkerr: %"S16_F"\n\t", proto->chkerr)); + LWIP_PLATFORM_DIAG(("lenerr: %"S16_F"\n\t", proto->lenerr)); + LWIP_PLATFORM_DIAG(("memerr: %"S16_F"\n\t", proto->memerr)); + LWIP_PLATFORM_DIAG(("rterr: %"S16_F"\n\t", proto->rterr)); + LWIP_PLATFORM_DIAG(("proterr: %"S16_F"\n\t", proto->proterr)); + LWIP_PLATFORM_DIAG(("opterr: %"S16_F"\n\t", proto->opterr)); + LWIP_PLATFORM_DIAG(("err: %"S16_F"\n\t", proto->err)); + LWIP_PLATFORM_DIAG(("cachehit: %"S16_F"\n", proto->cachehit)); } void stats_display_pbuf(struct stats_pbuf *pbuf) { LWIP_PLATFORM_DIAG(("\nPBUF\n\t")); - LWIP_PLATFORM_DIAG(("avail: %d\n\t", pbuf->avail)); - LWIP_PLATFORM_DIAG(("used: %d\n\t", pbuf->used)); - LWIP_PLATFORM_DIAG(("max: %d\n\t", pbuf->max)); - LWIP_PLATFORM_DIAG(("err: %d\n\t", pbuf->err)); - LWIP_PLATFORM_DIAG(("alloc_locked: %d\n\t", pbuf->alloc_locked)); - LWIP_PLATFORM_DIAG(("refresh_locked: %d\n", pbuf->refresh_locked)); + LWIP_PLATFORM_DIAG(("avail: %"S16_F"\n\t", pbuf->avail)); + LWIP_PLATFORM_DIAG(("used: %"S16_F"\n\t", pbuf->used)); + LWIP_PLATFORM_DIAG(("max: %"S16_F"\n\t", pbuf->max)); + LWIP_PLATFORM_DIAG(("err: %"S16_F"\n\t", pbuf->err)); + LWIP_PLATFORM_DIAG(("alloc_locked: %"S16_F"\n\t", pbuf->alloc_locked)); + LWIP_PLATFORM_DIAG(("refresh_locked: %"S16_F"\n", pbuf->refresh_locked)); } void stats_display_mem(struct stats_mem *mem, char *name) { LWIP_PLATFORM_DIAG(("\n MEM %s\n\t", name)); - LWIP_PLATFORM_DIAG(("avail: %d\n\t", mem->avail)); - LWIP_PLATFORM_DIAG(("used: %d\n\t", mem->used)); - LWIP_PLATFORM_DIAG(("max: %d\n\t", mem->max)); - LWIP_PLATFORM_DIAG(("err: %d\n", mem->err)); + LWIP_PLATFORM_DIAG(("avail: %"S16_F"\n\t", mem->avail)); + LWIP_PLATFORM_DIAG(("used: %"S16_F"\n\t", mem->used)); + LWIP_PLATFORM_DIAG(("max: %"S16_F"\n\t", mem->max)); + LWIP_PLATFORM_DIAG(("err: %"S16_F"\n", mem->err)); } void stats_display(void) { - int i; + s16_t i; char * memp_names[] = {"PBUF", "RAW_PCB", "UDP_PCB", "TCP_PCB", "TCP_PCB_LISTEN", "TCP_SEG", "NETBUF", "NETCONN", "API_MSG", "TCP_MSG", "TIMEOUT"}; stats_display_proto(&lwip_stats.link, "LINK"); diff --git a/src/core/sys.c b/src/core/sys.c index a07a839a..a7dbf34d 100644 --- a/src/core/sys.c +++ b/src/core/sys.c @@ -39,7 +39,7 @@ struct sswt_cb { - int timeflag; + s16_t timeflag; sys_sem_t *psem; }; @@ -170,7 +170,7 @@ sys_timeout(u32_t msecs, sys_timeout_handler h, void *arg) timeouts = sys_arch_timeouts(); - LWIP_DEBUGF(SYS_DEBUG, ("sys_timeout: %p msecs=%lu h=%p arg=%p\n", + LWIP_DEBUGF(SYS_DEBUG, ("sys_timeout: %p msecs=%"U32_F" h=%p arg=%p\n", (void *)timeout, msecs, (void *)h, (void *)arg)); LWIP_ASSERT("sys_timeout: timeouts != NULL", timeouts != NULL); diff --git a/src/core/tcp.c b/src/core/tcp.c index 28d7b9f4..f07ad06e 100644 --- a/src/core/tcp.c +++ b/src/core/tcp.c @@ -237,14 +237,10 @@ err_t tcp_bind(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port) { struct tcp_pcb *cpcb; -#if SO_REUSE - int reuse_port_all_set = 1; -#endif /* SO_REUSE */ if (port == 0) { port = tcp_new_port(); } -#if SO_REUSE == 0 /* Check if the address already is in use. */ for(cpcb = (struct tcp_pcb *)tcp_listen_pcbs.pcbs; cpcb != NULL; cpcb = cpcb->next) { @@ -266,107 +262,12 @@ tcp_bind(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port) } } } -#else /* SO_REUSE */ - /* Search through list of PCB's in LISTEN state. - - If there is a PCB bound to specified port and IP_ADDR_ANY another PCB can be bound to the interface IP - or to the loopback address on the same port if SOF_REUSEADDR is set. Any combination of PCB's bound to - the same local port, but to one address out of {IP_ADDR_ANY, 127.0.0.1, interface IP} at a time is valid. - But no two PCB's bound to same local port and same local address is valid. - - If SOF_REUSEPORT is set several PCB's can be bound to same local port and same local address also. But then - all PCB's must have the SOF_REUSEPORT option set. - - When the two options aren't set and specified port is already bound, ERR_USE is returned saying that - address is already in use. */ - for(cpcb = (struct tcp_pcb *)tcp_listen_pcbs.pcbs; cpcb != NULL; cpcb = cpcb->next) { - if(cpcb->local_port == port) { - if(ip_addr_cmp(&(cpcb->local_ip), ipaddr)) { - if(pcb->so_options & SOF_REUSEPORT) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_bind: in listening PCB's: SO_REUSEPORT set and same address.\n")); - reuse_port_all_set = (reuse_port_all_set && (cpcb->so_options & SOF_REUSEPORT)); - } - else { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_bind: in listening PCB's: SO_REUSEPORT not set and same address.\n")); - return ERR_USE; - } - } - else if((ip_addr_isany(ipaddr) && !ip_addr_isany(&(cpcb->local_ip))) || - (!ip_addr_isany(ipaddr) && ip_addr_isany(&(cpcb->local_ip)))) { - if(!(pcb->so_options & SOF_REUSEADDR) && !(pcb->so_options & SOF_REUSEPORT)) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_bind: in listening PCB's SO_REUSEPORT or SO_REUSEADDR not set and not the same address.\n")); - return ERR_USE; - } - else { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_bind: in listening PCB's SO_REUSEPORT or SO_REUSEADDR set and not the same address.\n")); - } - } - } - } - - /* Search through list of PCB's in a state in which they can accept or send data. Same decription as for - PCB's in state LISTEN applies to this PCB's regarding the options SOF_REUSEADDR and SOF_REUSEPORT. */ - for(cpcb = tcp_active_pcbs; cpcb != NULL; cpcb = cpcb->next) { - if(cpcb->local_port == port) { - if(ip_addr_cmp(&(cpcb->local_ip), ipaddr)) { - if(pcb->so_options & SOF_REUSEPORT) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_bind: in active PCB's SO_REUSEPORT set and same address.\n")); - reuse_port_all_set = (reuse_port_all_set && (cpcb->so_options & SOF_REUSEPORT)); - } - else { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_bind: in active PCB's SO_REUSEPORT not set and same address.\n")); - return ERR_USE; - } - } - else if((ip_addr_isany(ipaddr) && !ip_addr_isany(&(cpcb->local_ip))) || - (!ip_addr_isany(ipaddr) && ip_addr_isany(&(cpcb->local_ip)))) { - if(!(pcb->so_options & SOF_REUSEADDR) && !(pcb->so_options & SOF_REUSEPORT)) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_bind: in active PCB's SO_REUSEPORT or SO_REUSEADDR not set and not the same address.\n")); - return ERR_USE; - } - else { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_bind: in active PCB's SO_REUSEPORT or SO_REUSEADDR set and not the same address.\n")); - } - } - } - } - - /* Search through list of PCB's in TIME_WAIT state. If SO_REUSEADDR is set a bound combination [IP, port} - can be rebound. The same applies when SOF_REUSEPORT is set. - - If SOF_REUSEPORT is set several PCB's can be bound to same local port and same local address also. But then - all PCB's must have the SOF_REUSEPORT option set. - - When the two options aren't set and specified port is already bound, ERR_USE is returned saying that - address is already in use. */ - for(cpcb = tcp_tw_pcbs; cpcb != NULL; cpcb = cpcb->next) { - if(cpcb->local_port == port) { - if(ip_addr_cmp(&(cpcb->local_ip), ipaddr)) { - if(!(pcb->so_options & SOF_REUSEADDR) && !(pcb->so_options & SOF_REUSEPORT)) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_bind: in TIME_WAIT PCB's SO_REUSEPORT or SO_REUSEADDR not set and same address.\n")); - return ERR_USE; - } - else if(pcb->so_options & SOF_REUSEPORT) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_bind: in TIME_WAIT PCB's SO_REUSEPORT set and same address.\n")); - reuse_port_all_set = (reuse_port_all_set && (cpcb->so_options & SOF_REUSEPORT)); - } - } - } - } - - /* If SOF_REUSEPORT isn't set in all PCB's bound to specified port and local address specified then - {IP, port} can't be reused. */ - if(!reuse_port_all_set) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_bind: not all sockets have SO_REUSEPORT set.\n")); - return ERR_USE; - } -#endif /* SO_REUSE */ if (!ip_addr_isany(ipaddr)) { pcb->local_ip = *ipaddr; } pcb->local_port = port; - LWIP_DEBUGF(TCP_DEBUG, ("tcp_bind: bind to port %u\n", port)); + LWIP_DEBUGF(TCP_DEBUG, ("tcp_bind: bind to port %"U16_F"\n", port)); return ERR_OK; } #if LWIP_CALLBACK_API @@ -456,7 +357,7 @@ tcp_recved(struct tcp_pcb *pcb, u16_t len) tcp_ack_now(pcb); } - LWIP_DEBUGF(TCP_DEBUG, ("tcp_recved: recveived %u bytes, wnd %u (%u).\n", + LWIP_DEBUGF(TCP_DEBUG, ("tcp_recved: recveived %"U16_F" bytes, wnd %"U16_F" (%"U16_F").\n", len, pcb->rcv_wnd, TCP_WND - pcb->rcv_wnd)); } @@ -510,7 +411,7 @@ tcp_connect(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port, err_t ret; u32_t iss; - LWIP_DEBUGF(TCP_DEBUG, ("tcp_connect to port %u\n", port)); + LWIP_DEBUGF(TCP_DEBUG, ("tcp_connect to port %"U16_F"\n", port)); if (ipaddr != NULL) { pcb->remote_ip = *ipaddr; } else { @@ -592,7 +493,7 @@ tcp_slowtmr(void) if (pcb->unacked != NULL && pcb->rtime >= pcb->rto) { /* Time for a retransmission. */ - LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_slowtmr: rtime %u pcb->rto %u\n", + LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_slowtmr: rtime %"U16_F" pcb->rto %"U16_F"\n", pcb->rtime, pcb->rto)); /* Double retransmission time-out unless we are trying to @@ -607,7 +508,7 @@ tcp_slowtmr(void) pcb->ssthresh = pcb->mss * 2; } pcb->cwnd = pcb->mss; - LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_slowtmr: cwnd %u ssthresh %u\n", + LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_slowtmr: cwnd %"U16_F" ssthresh %"U16_F"\n", pcb->cwnd, pcb->ssthresh)); /* The following needs to be called AFTER cwnd is set to one mss - STJ */ @@ -626,7 +527,7 @@ tcp_slowtmr(void) /* Check if KEEPALIVE should be sent */ if((pcb->so_options & SOF_KEEPALIVE) && ((pcb->state == ESTABLISHED) || (pcb->state == CLOSE_WAIT))) { if((u32_t)(tcp_ticks - pcb->tmr) > (pcb->keepalive + TCP_MAXIDLE) / TCP_SLOW_INTERVAL) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: KEEPALIVE timeout. Aborting connection to %u.%u.%u.%u.\n", + LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: KEEPALIVE timeout. Aborting connection to %"U16_F".%"U16_F".%"U16_F".%"U16_F".\n", ip4_addr1(&pcb->remote_ip), ip4_addr2(&pcb->remote_ip), ip4_addr3(&pcb->remote_ip), ip4_addr4(&pcb->remote_ip))); @@ -814,7 +715,7 @@ tcp_seg_copy(struct tcp_seg *seg) if (cseg == NULL) { return NULL; } - memcpy((char *)cseg, (const char *)seg, sizeof(struct tcp_seg)); + memcpy((u8_t *)cseg, (const u8_t *)seg, sizeof(struct tcp_seg)); pbuf_ref(cseg->p); return cseg; } @@ -858,7 +759,7 @@ tcp_kill_prio(u8_t prio) } } if (inactive != NULL) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_kill_prio: killing oldest PCB %p (%ld)\n", + LWIP_DEBUGF(TCP_DEBUG, ("tcp_kill_prio: killing oldest PCB %p (%"S32_F")\n", (void *)inactive, inactivity)); tcp_abort(inactive); } @@ -880,7 +781,7 @@ tcp_kill_timewait(void) } } if (inactive != NULL) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_kill_timewait: killing oldest TIME-WAIT PCB %p (%ld)\n", + LWIP_DEBUGF(TCP_DEBUG, ("tcp_kill_timewait: killing oldest TIME-WAIT PCB %p (%"S32_F")\n", (void *)inactive, inactivity)); tcp_abort(inactive); } @@ -1112,16 +1013,16 @@ tcp_debug_print(struct tcp_hdr *tcphdr) { LWIP_DEBUGF(TCP_DEBUG, ("TCP header:\n")); LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(TCP_DEBUG, ("| %5u | %5u | (src port, dest port)\n", + LWIP_DEBUGF(TCP_DEBUG, ("| %5"U16_F" | %5"U16_F" | (src port, dest port)\n", ntohs(tcphdr->src), ntohs(tcphdr->dest))); LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(TCP_DEBUG, ("| %010lu | (seq no)\n", + LWIP_DEBUGF(TCP_DEBUG, ("| %010"U32_F" | (seq no)\n", ntohl(tcphdr->seqno))); LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(TCP_DEBUG, ("| %010lu | (ack no)\n", + LWIP_DEBUGF(TCP_DEBUG, ("| %010"U32_F" | (ack no)\n", ntohl(tcphdr->ackno))); LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(TCP_DEBUG, ("| %2u | |%u%u%u%u%u%u| %5u | (hdrlen, flags (", + LWIP_DEBUGF(TCP_DEBUG, ("| %2"U16_F" | |%"U16_F"%"U16_F"%"U16_F"%"U16_F"%"U16_F"%"U16_F"| %5"U16_F" | (hdrlen, flags (", TCPH_HDRLEN(tcphdr), TCPH_FLAGS(tcphdr) >> 5 & 1, TCPH_FLAGS(tcphdr) >> 4 & 1, @@ -1133,7 +1034,7 @@ tcp_debug_print(struct tcp_hdr *tcphdr) tcp_debug_print_flags(TCPH_FLAGS(tcphdr)); LWIP_DEBUGF(TCP_DEBUG, ("), win)\n")); LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(TCP_DEBUG, ("| 0x%04x | %5u | (chksum, urgp)\n", + LWIP_DEBUGF(TCP_DEBUG, ("| 0x%04"X16_F" | %5"U16_F" | (chksum, urgp)\n", ntohs(tcphdr->chksum), ntohs(tcphdr->urgp))); LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); } @@ -1214,28 +1115,28 @@ tcp_debug_print_pcbs(void) struct tcp_pcb *pcb; LWIP_DEBUGF(TCP_DEBUG, ("Active PCB states:\n")); for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) { - LWIP_DEBUGF(TCP_DEBUG, ("Local port %u, foreign port %u snd_nxt %lu rcv_nxt %lu ", + LWIP_DEBUGF(TCP_DEBUG, ("Local port %"U16_F", foreign port %"U16_F" snd_nxt %"U32_F" rcv_nxt %"U32_F" ", pcb->local_port, pcb->remote_port, pcb->snd_nxt, pcb->rcv_nxt)); tcp_debug_print_state(pcb->state); } LWIP_DEBUGF(TCP_DEBUG, ("Listen PCB states:\n")); for(pcb = (struct tcp_pcb *)tcp_listen_pcbs.pcbs; pcb != NULL; pcb = pcb->next) { - LWIP_DEBUGF(TCP_DEBUG, ("Local port %u, foreign port %u snd_nxt %lu rcv_nxt %lu ", + LWIP_DEBUGF(TCP_DEBUG, ("Local port %"U16_F", foreign port %"U16_F" snd_nxt %"U32_F" rcv_nxt %"U32_F" ", pcb->local_port, pcb->remote_port, pcb->snd_nxt, pcb->rcv_nxt)); tcp_debug_print_state(pcb->state); } LWIP_DEBUGF(TCP_DEBUG, ("TIME-WAIT PCB states:\n")); for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) { - LWIP_DEBUGF(TCP_DEBUG, ("Local port %u, foreign port %u snd_nxt %lu rcv_nxt %lu ", + LWIP_DEBUGF(TCP_DEBUG, ("Local port %"U16_F", foreign port %"U16_F" snd_nxt %"U32_F" rcv_nxt %"U32_F" ", pcb->local_port, pcb->remote_port, pcb->snd_nxt, pcb->rcv_nxt)); tcp_debug_print_state(pcb->state); } } -int +s16_t tcp_pcbs_sane(void) { struct tcp_pcb *pcb; diff --git a/src/core/tcp_in.c b/src/core/tcp_in.c index 8e06267a..ba4ebf3e 100644 --- a/src/core/tcp_in.c +++ b/src/core/tcp_in.c @@ -97,12 +97,6 @@ tcp_input(struct pbuf *p, struct netif *inp) u8_t hdrlen; err_t err; -#if SO_REUSE - struct tcp_pcb *pcb_temp; - int reuse = 0; - int reuse_port = 0; -#endif /* SO_REUSE */ - PERF_START; TCP_STATS_INC(tcp.recv); @@ -117,7 +111,7 @@ tcp_input(struct pbuf *p, struct netif *inp) /* remove header from payload */ if (pbuf_header(p, -((s16_t)(IPH_HL(iphdr) * 4))) || (p->tot_len < sizeof(struct tcp_hdr))) { /* drop short packets */ - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: short packet (%u bytes) discarded\n", p->tot_len)); + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: short packet (%"U16_F" bytes) discarded\n", p->tot_len)); TCP_STATS_INC(tcp.lenerr); TCP_STATS_INC(tcp.drop); pbuf_free(p); @@ -136,7 +130,7 @@ tcp_input(struct pbuf *p, struct netif *inp) if (inet_chksum_pseudo(p, (struct ip_addr *)&(iphdr->src), (struct ip_addr *)&(iphdr->dest), IP_PROTO_TCP, p->tot_len) != 0) { - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packet discarded due to failing checksum 0x%04x\n", + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packet discarded due to failing checksum 0x%04"X16_F"\n", inet_chksum_pseudo(p, (struct ip_addr *)&(iphdr->src), (struct ip_addr *)&(iphdr->dest), IP_PROTO_TCP, p->tot_len))); #if TCP_DEBUG @@ -169,16 +163,8 @@ tcp_input(struct pbuf *p, struct netif *inp) for an active connection. */ prev = NULL; -#if SO_REUSE - pcb_temp = tcp_active_pcbs; - again_1: - - /* Iterate through the TCP pcb list for a fully matching pcb */ - for(pcb = pcb_temp; pcb != NULL; pcb = pcb->next) { -#else /* SO_REUSE */ for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) { -#endif /* SO_REUSE */ LWIP_ASSERT("tcp_input: active pcb->state != CLOSED", pcb->state != CLOSED); LWIP_ASSERT("tcp_input: active pcb->state != TIME-WAIT", pcb->state != TIME_WAIT); LWIP_ASSERT("tcp_input: active pcb->state != LISTEN", pcb->state != LISTEN); @@ -187,32 +173,6 @@ tcp_input(struct pbuf *p, struct netif *inp) ip_addr_cmp(&(pcb->remote_ip), &(iphdr->src)) && ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest))) { -#if SO_REUSE - if(pcb->so_options & SOF_REUSEPORT) { - if(reuse) { - /* We processed one PCB already */ - LWIP_DEBUGF(TCP_INPUT_DEBUG,("tcp_input: second or later PCB and SOF_REUSEPORT set.\n")); - } else { - /* First PCB with this address */ - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: first PCB and SOF_REUSEPORT set.\n")); - reuse = 1; - } - - reuse_port = 1; - p->ref++; - - /* We want to search on next socket after receiving */ - pcb_temp = pcb->next; - - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: reference counter on PBUF set to %i\n", p->ref)); - } else { - if(reuse) { - /* We processed one PCB already */ - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: second or later PCB but SOF_REUSEPORT not set !\n")); - } - } -#endif /* SO_REUSE */ - /* Move this PCB to the front of the list so that subsequent lookups will be faster (we exploit locality in TCP segment arrivals). */ @@ -357,25 +317,9 @@ tcp_input(struct pbuf *p, struct netif *inp) tcp_debug_print_state(pcb->state); #endif /* TCP_DEBUG */ #endif /* TCP_INPUT_DEBUG */ -#if SO_REUSE - /* First socket should receive now */ - if(reuse_port) { - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: searching next PCB.\n")); - reuse_port = 0; - /* We are searching connected sockets */ - goto again_1; - } -#endif /* SO_REUSE */ - } else { -#if SO_REUSE - if(reuse) { - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: freeing PBUF with reference counter set to %i\n", p->ref)); - pbuf_free(p); - goto end; - } -#endif /* SO_REUSE */ + /* If no matching PCB was found, send a TCP RST (reset) to the sender. */ LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_input: no PCB match found, resetting.\n")); @@ -388,9 +332,7 @@ tcp_input(struct pbuf *p, struct netif *inp) } pbuf_free(p); } -#if SO_REUSE - end: -#endif /* SO_REUSE */ + LWIP_ASSERT("tcp_input: tcp_pcbs_sane()", tcp_pcbs_sane()); PERF_STOP("tcp_input"); } @@ -417,7 +359,7 @@ tcp_listen_input(struct tcp_pcb_listen *pcb) &(iphdr->dest), &(iphdr->src), tcphdr->dest, tcphdr->src); } else if (flags & TCP_SYN) { - LWIP_DEBUGF(TCP_DEBUG, ("TCP connection request %u -> %u.\n", tcphdr->src, tcphdr->dest)); + LWIP_DEBUGF(TCP_DEBUG, ("TCP connection request %"U16_F" -> %"U16_F".\n", tcphdr->src, tcphdr->dest)); npcb = tcp_alloc(pcb->prio); /* If a new PCB could not be created (probably due to lack of memory), we don't do anything, but rely on the sender will retransmit the @@ -521,9 +463,9 @@ tcp_process(struct tcp_pcb *pcb) pcb->flags &= ~TF_ACK_DELAY; return ERR_RST; } else { - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_process: unacceptable reset seqno %lu rcv_nxt %lu\n", + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_process: unacceptable reset seqno %"U32_F" rcv_nxt %"U32_F"\n", seqno, pcb->rcv_nxt)); - LWIP_DEBUGF(TCP_DEBUG, ("tcp_process: unacceptable reset seqno %lu rcv_nxt %lu\n", + LWIP_DEBUGF(TCP_DEBUG, ("tcp_process: unacceptable reset seqno %"U32_F" rcv_nxt %"U32_F"\n", seqno, pcb->rcv_nxt)); return ERR_OK; } @@ -536,7 +478,7 @@ tcp_process(struct tcp_pcb *pcb) /* Do different things depending on the TCP state. */ switch (pcb->state) { case SYN_SENT: - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("SYN-SENT: ackno %lu pcb->snd_nxt %lu unacked %lu\n", ackno, + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("SYN-SENT: ackno %"U32_F" pcb->snd_nxt %"U32_F" unacked %"U32_F"\n", ackno, pcb->snd_nxt, ntohl(pcb->unacked->tcphdr->seqno))); /* received SYN ACK with expected sequence number? */ if ((flags & TCP_ACK) && (flags & TCP_SYN) @@ -549,7 +491,7 @@ tcp_process(struct tcp_pcb *pcb) pcb->state = ESTABLISHED; pcb->cwnd = pcb->mss; --pcb->snd_queuelen; - LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_process: SYN-SENT --queuelen %u\n", (unsigned int)pcb->snd_queuelen)); + LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_process: SYN-SENT --queuelen %"U16_F"\n", (u16_t)pcb->snd_queuelen)); rseg = pcb->unacked; pcb->unacked = rseg->next; tcp_seg_free(rseg); @@ -575,7 +517,7 @@ tcp_process(struct tcp_pcb *pcb) /* expected ACK number? */ if (TCP_SEQ_BETWEEN(ackno, pcb->lastack+1, pcb->snd_nxt)) { pcb->state = ESTABLISHED; - LWIP_DEBUGF(TCP_DEBUG, ("TCP connection established %u -> %u.\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 LWIP_ASSERT("pcb->accept != NULL", pcb->accept != NULL); #endif @@ -614,7 +556,7 @@ tcp_process(struct tcp_pcb *pcb) if (flags & TCP_FIN) { if (flags & TCP_ACK && ackno == pcb->snd_nxt) { LWIP_DEBUGF(TCP_DEBUG, - ("TCP connection closed %d -> %d.\n", inseg.tcphdr->src, inseg.tcphdr->dest)); + ("TCP connection closed %"U16_F" -> %"U16_F".\n", inseg.tcphdr->src, inseg.tcphdr->dest)); tcp_ack_now(pcb); tcp_pcb_purge(pcb); TCP_RMV(&tcp_active_pcbs, pcb); @@ -631,7 +573,7 @@ tcp_process(struct tcp_pcb *pcb) case FIN_WAIT_2: tcp_receive(pcb); if (flags & TCP_FIN) { - LWIP_DEBUGF(TCP_DEBUG, ("TCP connection closed %u -> %u.\n", inseg.tcphdr->src, inseg.tcphdr->dest)); + LWIP_DEBUGF(TCP_DEBUG, ("TCP connection closed %"U16_F" -> %"U16_F".\n", inseg.tcphdr->src, inseg.tcphdr->dest)); tcp_ack_now(pcb); tcp_pcb_purge(pcb); TCP_RMV(&tcp_active_pcbs, pcb); @@ -642,7 +584,7 @@ tcp_process(struct tcp_pcb *pcb) case CLOSING: tcp_receive(pcb); if (flags & TCP_ACK && ackno == pcb->snd_nxt) { - LWIP_DEBUGF(TCP_DEBUG, ("TCP connection closed %u -> %u.\n", inseg.tcphdr->src, inseg.tcphdr->dest)); + LWIP_DEBUGF(TCP_DEBUG, ("TCP connection closed %"U16_F" -> %"U16_F".\n", inseg.tcphdr->src, inseg.tcphdr->dest)); tcp_ack_now(pcb); tcp_pcb_purge(pcb); TCP_RMV(&tcp_active_pcbs, pcb); @@ -653,7 +595,7 @@ tcp_process(struct tcp_pcb *pcb) case LAST_ACK: tcp_receive(pcb); if (flags & TCP_ACK && ackno == pcb->snd_nxt) { - LWIP_DEBUGF(TCP_DEBUG, ("TCP connection closed %u -> %u.\n", inseg.tcphdr->src, inseg.tcphdr->dest)); + LWIP_DEBUGF(TCP_DEBUG, ("TCP connection closed %"U16_F" -> %"U16_F".\n", inseg.tcphdr->src, inseg.tcphdr->dest)); pcb->state = CLOSED; recv_flags = TF_CLOSED; } @@ -685,7 +627,7 @@ tcp_receive(struct tcp_pcb *pcb) #endif struct pbuf *p; s32_t off; - int m; + s16_t m; u32_t right_wnd_edge; u16_t new_tot_len; @@ -700,11 +642,11 @@ tcp_receive(struct tcp_pcb *pcb) pcb->snd_wnd = tcphdr->wnd; pcb->snd_wl1 = seqno; pcb->snd_wl2 = ackno; - LWIP_DEBUGF(TCP_WND_DEBUG, ("tcp_receive: window update %lu\n", pcb->snd_wnd)); + LWIP_DEBUGF(TCP_WND_DEBUG, ("tcp_receive: window update %"U32_F"\n", pcb->snd_wnd)); #if TCP_WND_DEBUG } else { if (pcb->snd_wnd != tcphdr->wnd) { - LWIP_DEBUGF(TCP_WND_DEBUG, ("tcp_receive: no window update lastack %lu snd_max %lu ackno %lu wl1 %lu seqno %lu wl2 %lu\n", + LWIP_DEBUGF(TCP_WND_DEBUG, ("tcp_receive: no window update lastack %"U32_F" snd_max %"U32_F" ackno %"U32_F" wl1 %"U32_F" seqno %"U32_F" wl2 %"U32_F"\n", pcb->lastack, pcb->snd_max, ackno, pcb->snd_wl1, seqno, pcb->snd_wl2)); } #endif /* TCP_WND_DEBUG */ @@ -719,8 +661,8 @@ tcp_receive(struct tcp_pcb *pcb) if (pcb->dupacks >= 3 && pcb->unacked != NULL) { if (!(pcb->flags & TF_INFR)) { /* This is fast retransmit. Retransmit the first unacked segment. */ - LWIP_DEBUGF(TCP_FR_DEBUG, ("tcp_receive: dupacks %u (%lu), fast retransmit %lu\n", - (unsigned int)pcb->dupacks, pcb->lastack, + LWIP_DEBUGF(TCP_FR_DEBUG, ("tcp_receive: dupacks %"U16_F" (%"U32_F"), fast retransmit %"U32_F"\n", + (u16_t)pcb->dupacks, pcb->lastack, ntohl(pcb->unacked->tcphdr->seqno))); tcp_rexmit(pcb); /* Set ssthresh to max (FlightSize / 2, 2*SMSS) */ @@ -744,7 +686,7 @@ tcp_receive(struct tcp_pcb *pcb) } } } else { - LWIP_DEBUGF(TCP_FR_DEBUG, ("tcp_receive: dupack averted %lu %lu\n", + LWIP_DEBUGF(TCP_FR_DEBUG, ("tcp_receive: dupack averted %"U32_F" %"U32_F"\n", pcb->snd_wl1 + pcb->snd_wnd, right_wnd_edge)); } } else @@ -784,16 +726,16 @@ tcp_receive(struct tcp_pcb *pcb) if ((u16_t)(pcb->cwnd + pcb->mss) > pcb->cwnd) { pcb->cwnd += pcb->mss; } - LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_receive: slow start cwnd %u\n", pcb->cwnd)); + LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_receive: slow start cwnd %"U16_F"\n", pcb->cwnd)); } else { u16_t new_cwnd = (pcb->cwnd + pcb->mss * pcb->mss / pcb->cwnd); if (new_cwnd > pcb->cwnd) { pcb->cwnd = new_cwnd; } - LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_receive: congestion avoidance cwnd %u\n", pcb->cwnd)); + LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_receive: congestion avoidance cwnd %"U16_F"\n", pcb->cwnd)); } } - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: ACK for %lu, unacked->seqno %lu:%lu\n", + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: ACK for %"U32_F", unacked->seqno %"U32_F":%"U32_F"\n", ackno, pcb->unacked != NULL? ntohl(pcb->unacked->tcphdr->seqno): 0, @@ -805,7 +747,7 @@ tcp_receive(struct tcp_pcb *pcb) while (pcb->unacked != NULL && TCP_SEQ_LEQ(ntohl(pcb->unacked->tcphdr->seqno) + TCP_TCPLEN(pcb->unacked), ackno)) { - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: removing %lu:%lu from pcb->unacked\n", + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: removing %"U32_F":%"U32_F" from pcb->unacked\n", ntohl(pcb->unacked->tcphdr->seqno), ntohl(pcb->unacked->tcphdr->seqno) + TCP_TCPLEN(pcb->unacked))); @@ -813,11 +755,11 @@ tcp_receive(struct tcp_pcb *pcb) next = pcb->unacked; pcb->unacked = pcb->unacked->next; - LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_receive: queuelen %u ... ", (unsigned int)pcb->snd_queuelen)); + LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_receive: queuelen %"U16_F" ... ", (u16_t)pcb->snd_queuelen)); pcb->snd_queuelen -= pbuf_clen(next->p); tcp_seg_free(next); - LWIP_DEBUGF(TCP_QLEN_DEBUG, ("%u (after freeing unacked)\n", (unsigned int)pcb->snd_queuelen)); + LWIP_DEBUGF(TCP_QLEN_DEBUG, ("%"U16_F" (after freeing unacked)\n", (u16_t)pcb->snd_queuelen)); if (pcb->snd_queuelen != 0) { LWIP_ASSERT("tcp_receive: valid queue length", pcb->unacked != NULL || pcb->unsent != NULL); @@ -837,16 +779,16 @@ tcp_receive(struct tcp_pcb *pcb) TCP_SEQ_LEQ(ackno, pcb->snd_max)*/ TCP_SEQ_BETWEEN(ackno, ntohl(pcb->unsent->tcphdr->seqno) + TCP_TCPLEN(pcb->unsent), pcb->snd_max) ) { - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: removing %lu:%lu from pcb->unsent\n", + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: removing %"U32_F":%"U32_F" from pcb->unsent\n", ntohl(pcb->unsent->tcphdr->seqno), ntohl(pcb->unsent->tcphdr->seqno) + TCP_TCPLEN(pcb->unsent))); next = pcb->unsent; pcb->unsent = pcb->unsent->next; - LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_receive: queuelen %u ... ", (unsigned int)pcb->snd_queuelen)); + LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_receive: queuelen %"U16_F" ... ", (u16_t)pcb->snd_queuelen)); pcb->snd_queuelen -= pbuf_clen(next->p); tcp_seg_free(next); - LWIP_DEBUGF(TCP_QLEN_DEBUG, ("%u (after freeing unsent)\n", (unsigned int)pcb->snd_queuelen)); + LWIP_DEBUGF(TCP_QLEN_DEBUG, ("%"U16_F" (after freeing unsent)\n", (u16_t)pcb->snd_queuelen)); if (pcb->snd_queuelen != 0) { LWIP_ASSERT("tcp_receive: valid queue length", pcb->unacked != NULL || pcb->unsent != NULL); @@ -858,7 +800,7 @@ tcp_receive(struct tcp_pcb *pcb) } /* End of ACK for new data processing. */ - LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_receive: pcb->rttest %u rtseq %lu ackno %lu\n", + LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_receive: pcb->rttest %"U32_F" rtseq %"U32_F" ackno %"U32_F"\n", pcb->rttest, pcb->rtseq, ackno)); /* RTT estimation calculations. This is done by checking if the @@ -867,7 +809,7 @@ tcp_receive(struct tcp_pcb *pcb) if (pcb->rttest && TCP_SEQ_LT(pcb->rtseq, ackno)) { m = tcp_ticks - pcb->rttest; - LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_receive: experienced rtt %u ticks (%u msec).\n", + LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_receive: experienced rtt %"U16_F" ticks (%"U16_F" msec).\n", m, m * TCP_SLOW_INTERVAL)); /* This is taken directly from VJs original code in his paper */ @@ -880,7 +822,7 @@ tcp_receive(struct tcp_pcb *pcb) pcb->sv += m; pcb->rto = (pcb->sa >> 3) + pcb->sv; - LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_receive: RTO %u (%u miliseconds)\n", + LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_receive: RTO %"U16_F" (%"U16_F" miliseconds)\n", pcb->rto, pcb->rto * TCP_SLOW_INTERVAL)); pcb->rttest = 0; @@ -969,7 +911,7 @@ tcp_receive(struct tcp_pcb *pcb) /* the whole segment is < rcv_nxt */ /* must be a duplicate of a packet that has already been correctly handled */ - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: duplicate seqno %lu\n", seqno)); + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: duplicate seqno %"U32_F"\n", seqno)); tcp_ack_now(pcb); } } diff --git a/src/core/tcp_out.c b/src/core/tcp_out.c index de92fba1..f95fbae9 100644 --- a/src/core/tcp_out.c +++ b/src/core/tcp_out.c @@ -80,8 +80,8 @@ tcp_send_ctrl(struct tcp_pcb *pcb, u8_t flags) err_t tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t copy) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_write(pcb=%p, arg=%p, len=%u, copy=%d)\n", (void *)pcb, - arg, len, (unsigned int)copy)); + LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_write(pcb=%p, arg=%p, len=%"U16_F", copy=%"U16_F")\n", (void *)pcb, + arg, len, (u16_t)copy)); /* connection is in valid state for data transmission? */ if (pcb->state == ESTABLISHED || pcb->state == CLOSE_WAIT || @@ -123,15 +123,15 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len, void *ptr; u8_t queuelen; - LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_enqueue(pcb=%p, arg=%p, len=%u, flags=%x, copy=%u)\n", - (void *)pcb, arg, len, (unsigned int)flags, (unsigned int)copy)); + LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_enqueue(pcb=%p, arg=%p, len=%"U16_F", flags=%"X16_F", copy=%"U16_F")\n", + (void *)pcb, arg, len, (u16_t)flags, (u16_t)copy)); LWIP_ASSERT("tcp_enqueue: len == 0 || optlen == 0 (programmer violates API)", len == 0 || optlen == 0); LWIP_ASSERT("tcp_enqueue: arg == NULL || optdata == NULL (programmer violates API)", arg == NULL || optdata == NULL); /* fail on too much data */ if (len > pcb->snd_buf) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 3, ("tcp_enqueue: too much data (len=%u > snd_buf=%u)\n", len, pcb->snd_buf)); + LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 3, ("tcp_enqueue: too much data (len=%"U16_F" > snd_buf=%"U16_F")\n", len, pcb->snd_buf)); return ERR_MEM; } left = len; @@ -141,13 +141,13 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len, * by the call to this function. */ seqno = pcb->snd_lbb; - LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_enqueue: queuelen: %u\n", (unsigned int)pcb->snd_queuelen)); + LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_enqueue: queuelen: %"U16_F"\n", (u16_t)pcb->snd_queuelen)); /* If total number of pbufs on the unsent/unacked queues exceeds the * configured maximum, return an error */ queuelen = pcb->snd_queuelen; if (queuelen >= TCP_SND_QUEUELEN) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 3, ("tcp_enqueue: too long queue %u (max %u)\n", queuelen, TCP_SND_QUEUELEN)); + LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 3, ("tcp_enqueue: too long queue %"U16_F" (max %"U16_F")\n", queuelen, TCP_SND_QUEUELEN)); TCP_STATS_INC(tcp.memerr); return ERR_MEM; } @@ -207,7 +207,7 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len, /* copy from volatile memory? */ else if (copy) { if ((seg->p = pbuf_alloc(PBUF_TRANSPORT, seglen, PBUF_RAM)) == NULL) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue : could not allocate memory for pbuf copy size %u\n", seglen)); + LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue : could not allocate memory for pbuf copy size %"U16_F"\n", seglen)); goto memerr; } ++queuelen; @@ -250,7 +250,7 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len, /* Now that there are more segments queued, we check again if the length of the queue exceeds the configured maximum. */ if (queuelen > TCP_SND_QUEUELEN) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue: queue too long %u (%u)\n", queuelen, TCP_SND_QUEUELEN)); + LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue: queue too long %"U16_F" (%"U16_F")\n", queuelen, TCP_SND_QUEUELEN)); goto memerr; } @@ -281,14 +281,14 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len, segments such as SYN|ACK. */ memcpy(seg->dataptr, optdata, optlen); } - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | DBG_TRACE, ("tcp_enqueue: queueing %lu:%lu (0x%x)\n", + LWIP_DEBUGF(TCP_OUTPUT_DEBUG | DBG_TRACE, ("tcp_enqueue: queueing %"U32_F":%"U32_F" (0x%"X16_F")\n", ntohl(seg->tcphdr->seqno), ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg), - flags)); + (u16_t)flags)); left -= seglen; seqno += seglen; - ptr = (void *)((char *)ptr + seglen); + ptr = (void *)((u8_t *)ptr + seglen); } /* Now that the data to be enqueued has been broken up into TCP @@ -316,7 +316,7 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len, useg->len += queue->len; useg->next = queue->next; - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | DBG_TRACE | DBG_STATE, ("tcp_enqueue: chaining segments, new len %u\n", useg->len)); + LWIP_DEBUGF(TCP_OUTPUT_DEBUG | DBG_TRACE | DBG_STATE, ("tcp_enqueue: chaining segments, new len %"U16_F"\n", useg->len)); if (seg == queue) { seg = NULL; } @@ -343,7 +343,7 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len, /* update number of segments on the queues */ pcb->snd_queuelen = queuelen; - LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_enqueue: %d (after enqueued)\n", pcb->snd_queuelen)); + LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_enqueue: %"S16_F" (after enqueued)\n", pcb->snd_queuelen)); if (pcb->snd_queuelen != 0) { LWIP_ASSERT("tcp_enqueue: valid queue length", pcb->unacked != NULL || pcb->unsent != NULL); @@ -366,7 +366,7 @@ memerr: LWIP_ASSERT("tcp_enqueue: valid queue length", pcb->unacked != NULL || pcb->unsent != NULL); } - LWIP_DEBUGF(TCP_QLEN_DEBUG | DBG_STATE, ("tcp_enqueue: %d (with mem err)\n", pcb->snd_queuelen)); + LWIP_DEBUGF(TCP_QLEN_DEBUG | DBG_STATE, ("tcp_enqueue: %"S16_F" (with mem err)\n", pcb->snd_queuelen)); return ERR_MEM; } @@ -379,7 +379,7 @@ tcp_output(struct tcp_pcb *pcb) struct tcp_seg *seg, *useg; u32_t wnd; #if TCP_CWND_DEBUG - int i = 0; + s16_t i = 0; #endif /* TCP_CWND_DEBUG */ /* First, check if we are invoked by the TCP input processing @@ -414,7 +414,7 @@ tcp_output(struct tcp_pcb *pcb) LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output: (ACK) could not allocate pbuf\n")); return ERR_BUF; } - LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output: sending ACK for %lu\n", pcb->rcv_nxt)); + LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output: sending ACK for %"U32_F"\n", pcb->rcv_nxt)); /* remove ACK flags from the PCB, as we send an empty ACK now */ pcb->flags &= ~(TF_ACK_DELAY | TF_ACK_NOW); @@ -442,16 +442,16 @@ tcp_output(struct tcp_pcb *pcb) #if TCP_OUTPUT_DEBUG if (seg == NULL) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output: nothing to send (%p)\n", pcb->unsent)); + LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output: nothing to send (%p)\n", (void*)pcb->unsent)); } #endif /* TCP_OUTPUT_DEBUG */ #if TCP_CWND_DEBUG if (seg == NULL) { - LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_output: snd_wnd %lu, cwnd %lu, wnd %lu, seg == NULL, ack %lu\n", + LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_output: snd_wnd %"U32_F", cwnd %"U16_F", wnd %"U32_F", seg == NULL, ack %"U32_F"\n", pcb->snd_wnd, pcb->cwnd, wnd, pcb->lastack)); } else { - LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_output: snd_wnd %lu, cwnd %lu, wnd %lu, effwnd %lu, seq %lu, ack %lu\n", + LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_output: snd_wnd %"U32_F", cwnd %"U16_F", wnd %"U32_F", effwnd %"U32_F", seq %"U32_F", ack %"U32_F"\n", pcb->snd_wnd, pcb->cwnd, wnd, ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len, ntohl(seg->tcphdr->seqno), pcb->lastack)); @@ -461,7 +461,7 @@ tcp_output(struct tcp_pcb *pcb) while (seg != NULL && ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len <= wnd) { #if TCP_CWND_DEBUG - LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_output: snd_wnd %lu, cwnd %lu, wnd %lu, effwnd %lu, seq %lu, ack %lu, i%d\n", + LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_output: snd_wnd %"U32_F", cwnd %"U16_F", wnd %"U32_F", effwnd %"U32_F", seq %"U32_F", ack %"U32_F", i %"S16_F"\n", pcb->snd_wnd, pcb->cwnd, wnd, ntohl(seg->tcphdr->seqno) + seg->len - pcb->lastack, @@ -549,9 +549,9 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb) pcb->rttest = tcp_ticks; pcb->rtseq = ntohl(seg->tcphdr->seqno); - LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_output_segment: rtseq %lu\n", pcb->rtseq)); + LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_output_segment: rtseq %"U32_F"\n", pcb->rtseq)); } - LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output_segment: %lu:%lu\n", + LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output_segment: %"U32_F":%"U32_F"\n", htonl(seg->tcphdr->seqno), htonl(seg->tcphdr->seqno) + seg->len)); @@ -607,7 +607,7 @@ tcp_rst(u32_t seqno, u32_t ackno, /* Send output with hardcoded TTL since we have no access to the pcb */ ip_output(p, local_ip, remote_ip, TCP_TTL, 0, IP_PROTO_TCP); pbuf_free(p); - LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_rst: seqno %lu ackno %lu.\n", seqno, ackno)); + LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_rst: seqno %"U32_F" ackno %"U32_F".\n", seqno, ackno)); } /* requeue all unacked segments for retransmission */ @@ -674,11 +674,11 @@ tcp_keepalive(struct tcp_pcb *pcb) struct pbuf *p; struct tcp_hdr *tcphdr; - LWIP_DEBUGF(TCP_DEBUG, ("tcp_keepalive: sending KEEPALIVE probe to %u.%u.%u.%u\n", + LWIP_DEBUGF(TCP_DEBUG, ("tcp_keepalive: sending KEEPALIVE probe to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", ip4_addr1(&pcb->remote_ip), ip4_addr2(&pcb->remote_ip), ip4_addr3(&pcb->remote_ip), ip4_addr4(&pcb->remote_ip))); - LWIP_DEBUGF(TCP_DEBUG, ("tcp_keepalive: tcp_ticks %lu pcb->tmr %lu pcb->keep_cnt %u\n", tcp_ticks, pcb->tmr, pcb->keep_cnt)); + LWIP_DEBUGF(TCP_DEBUG, ("tcp_keepalive: tcp_ticks %"U32_F" pcb->tmr %"U32_F" pcb->keep_cnt %"U16_F"\n", tcp_ticks, pcb->tmr, pcb->keep_cnt)); p = pbuf_alloc(PBUF_IP, TCP_HLEN, PBUF_RAM); @@ -707,7 +707,7 @@ tcp_keepalive(struct tcp_pcb *pcb) pbuf_free(p); - LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_keepalive: seqno %lu ackno %lu.\n", pcb->snd_nxt - 1, pcb->rcv_nxt)); + LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_keepalive: seqno %"U32_F" ackno %"U32_F".\n", pcb->snd_nxt - 1, pcb->rcv_nxt)); } #endif /* LWIP_TCP */ diff --git a/src/core/udp.c b/src/core/udp.c index fcc8e32d..4ccaa913 100644 --- a/src/core/udp.c +++ b/src/core/udp.c @@ -90,13 +90,6 @@ udp_input(struct pbuf *p, struct netif *inp) struct ip_hdr *iphdr; u16_t src, dest; -#if SO_REUSE - struct udp_pcb *pcb_temp; - int reuse = 0; - int reuse_port_1 = 0; - int reuse_port_2 = 0; -#endif /* SO_REUSE */ - PERF_START; UDP_STATS_INC(udp.recv); @@ -105,7 +98,7 @@ udp_input(struct pbuf *p, struct netif *inp) if (pbuf_header(p, -((s16_t)(UDP_HLEN + IPH_HL(iphdr) * 4)))) { /* drop short packets */ - LWIP_DEBUGF(UDP_DEBUG, ("udp_input: short UDP datagram (%u bytes) discarded\n", p->tot_len)); + LWIP_DEBUGF(UDP_DEBUG, ("udp_input: short UDP datagram (%"U16_F" bytes) discarded\n", p->tot_len)); UDP_STATS_INC(udp.lenerr); UDP_STATS_INC(udp.drop); snmp_inc_udpinerrors(); @@ -115,7 +108,7 @@ udp_input(struct pbuf *p, struct netif *inp) udphdr = (struct udp_hdr *)((u8_t *)p->payload - UDP_HLEN); - LWIP_DEBUGF(UDP_DEBUG, ("udp_input: received datagram of length %u\n", p->tot_len)); + LWIP_DEBUGF(UDP_DEBUG, ("udp_input: received datagram of length %"U16_F"\n", p->tot_len)); src = ntohs(udphdr->src); dest = ntohs(udphdr->dest); @@ -123,25 +116,16 @@ udp_input(struct pbuf *p, struct netif *inp) udp_debug_print(udphdr); /* print the UDP source and destination */ - LWIP_DEBUGF(UDP_DEBUG, ("udp (%u.%u.%u.%u, %u) <-- (%u.%u.%u.%u, %u)\n", + LWIP_DEBUGF(UDP_DEBUG, ("udp (%"U16_F".%"U16_F".%"U16_F".%"U16_F", %"U16_F") <-- (%"U16_F".%"U16_F".%"U16_F".%"U16_F", %"U16_F")\n", ip4_addr1(&iphdr->dest), ip4_addr2(&iphdr->dest), ip4_addr3(&iphdr->dest), ip4_addr4(&iphdr->dest), ntohs(udphdr->dest), ip4_addr1(&iphdr->src), ip4_addr2(&iphdr->src), ip4_addr3(&iphdr->src), ip4_addr4(&iphdr->src), ntohs(udphdr->src))); -#if SO_REUSE - pcb_temp = udp_pcbs; - - again_1: - - /* Iterate through the UDP pcb list for a fully matching pcb */ - for (pcb = pcb_temp; pcb != NULL; pcb = pcb->next) { -#else /* SO_REUSE */ /* Iterate through the UDP pcb list for a fully matching pcb */ for (pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) { -#endif /* SO_REUSE */ /* print the PCB local and remote address */ - LWIP_DEBUGF(UDP_DEBUG, ("pcb (%u.%u.%u.%u, %u) --- (%u.%u.%u.%u, %u)\n", + LWIP_DEBUGF(UDP_DEBUG, ("pcb (%"U16_F".%"U16_F".%"U16_F".%"U16_F", %"U16_F") --- (%"U16_F".%"U16_F".%"U16_F".%"U16_F", %"U16_F")\n", ip4_addr1(&pcb->local_ip), ip4_addr2(&pcb->local_ip), ip4_addr3(&pcb->local_ip), ip4_addr4(&pcb->local_ip), pcb->local_port, ip4_addr1(&pcb->remote_ip), ip4_addr2(&pcb->remote_ip), @@ -159,27 +143,6 @@ udp_input(struct pbuf *p, struct netif *inp) (ip_addr_isany(&pcb->local_ip) || /* PCB local IP address matches UDP destination IP address? */ ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest)))) { -#if SO_REUSE - if (pcb->so_options & SOF_REUSEPORT) { - if(reuse) { - /* We processed one PCB already */ - LWIP_DEBUGF(UDP_DEBUG, ("udp_input: second or later PCB and SOF_REUSEPORT set.\n")); - } else { - /* First PCB with this address */ - LWIP_DEBUGF(UDP_DEBUG, ("udp_input: first PCB and SOF_REUSEPORT set.\n")); - reuse = 1; - } - - reuse_port_1 = 1; - p->ref++; - LWIP_DEBUGF(UDP_DEBUG, ("udp_input: reference counter on PBUF set to %i\n", p->ref)); - } else { - if (reuse) { - /* We processed one PCB already */ - LWIP_DEBUGF(UDP_DEBUG, ("udp_input: second or later PCB but SOF_REUSEPORT not set !\n")); - } - } -#endif /* SO_REUSE */ break; } } @@ -188,16 +151,8 @@ udp_input(struct pbuf *p, struct netif *inp) /* Iterate through the UDP PCB list for a pcb that matches the local address. */ -#if SO_REUSE - pcb_temp = udp_pcbs; - - again_2: - - for (pcb = pcb_temp; pcb != NULL; pcb = pcb->next) { -#else /* SO_REUSE */ for (pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) { -#endif /* SO_REUSE */ - LWIP_DEBUGF(UDP_DEBUG, ("pcb (%u.%u.%u.%u, %u) --- (%u.%u.%u.%u, %u)\n", + LWIP_DEBUGF(UDP_DEBUG, ("pcb (%"U16_F".%"U16_F".%"U16_F".%"U16_F", %"U16_F") --- (%"U16_F".%"U16_F".%"U16_F".%"U16_F", %"U16_F")\n", ip4_addr1(&pcb->local_ip), ip4_addr2(&pcb->local_ip), ip4_addr3(&pcb->local_ip), ip4_addr4(&pcb->local_ip), pcb->local_port, ip4_addr1(&pcb->remote_ip), ip4_addr2(&pcb->remote_ip), @@ -210,27 +165,6 @@ udp_input(struct pbuf *p, struct netif *inp) (ip_addr_isany(&pcb->local_ip) || /* ...matching interface address? */ ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest)))) { -#if SO_REUSE - if (pcb->so_options & SOF_REUSEPORT) { - if (reuse) { - /* We processed one PCB already */ - LWIP_DEBUGF(UDP_DEBUG, ("udp_input: second or later PCB and SOF_REUSEPORT set.\n")); - } else { - /* First PCB with this address */ - LWIP_DEBUGF(UDP_DEBUG, ("udp_input: first PCB and SOF_REUSEPORT set.\n")); - reuse = 1; - } - - reuse_port_2 = 1; - p->ref++; - LWIP_DEBUGF(UDP_DEBUG, ("udp_input: reference counter on PBUF set to %i\n", p->ref)); - } else { - if (reuse) { - /* We processed one PCB already */ - LWIP_DEBUGF(UDP_DEBUG, ("udp_input: second or later PCB but SOF_REUSEPORT not set !\n")); - } - } -#endif /* SO_REUSE */ break; } } @@ -284,33 +218,7 @@ udp_input(struct pbuf *p, struct netif *inp) { pcb->recv(pcb->recv_arg, pcb, p, &(iphdr->src), src); } -#if SO_REUSE - /* First socket should receive now */ - if (reuse_port_1 || reuse_port_2) { - /* We want to search on next socket after receiving */ - pcb_temp = pcb->next; - - if (reuse_port_1) { - /* We are searching connected sockets */ - reuse_port_1 = 0; - reuse_port_2 = 0; - goto again_1; } else { - /* We are searching unconnected sockets */ - reuse_port_1 = 0; - reuse_port_2 = 0; - goto again_2; - } - } -#endif /* SO_REUSE */ - } else { -#if SO_REUSE - if(reuse) { - LWIP_DEBUGF(UDP_DEBUG, ("udp_input: freeing PBUF with reference counter set to %i\n", p->ref)); - pbuf_free(p); - goto end; - } -#endif /* SO_REUSE */ LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE, ("udp_input: not for us.\n")); /* No match was found, send ICMP destination port unreachable unless @@ -413,7 +321,7 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p) netif = ip_route(&(pcb->remote_ip)); /* no outgoing network interface could be found? */ if (netif == NULL) { - LWIP_DEBUGF(UDP_DEBUG | 1, ("udp_send: No route to 0x%lx\n", pcb->remote_ip.addr)); + LWIP_DEBUGF(UDP_DEBUG | 1, ("udp_send: No route to 0x%"X32_F"\n", pcb->remote_ip.addr)); UDP_STATS_INC(udp.rterr); return ERR_RTE; } @@ -453,11 +361,11 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p) src_ip = &(pcb->local_ip); } - LWIP_DEBUGF(UDP_DEBUG, ("udp_send: sending datagram of length %u\n", q->tot_len)); + LWIP_DEBUGF(UDP_DEBUG, ("udp_send: sending datagram of length %"U16_F"\n", q->tot_len)); /* UDP Lite protocol? */ if (pcb->flags & UDP_FLAGS_UDPLITE) { - LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP LITE packet length %u\n", q->tot_len)); + LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP LITE packet length %"U16_F"\n", q->tot_len)); /* set UDP message length in UDP header */ udphdr->len = htons(pcb->chksum_len); /* calculate checksum */ @@ -474,7 +382,7 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p) err = ip_output_if (q, src_ip, &pcb->remote_ip, pcb->ttl, pcb->tos, IP_PROTO_UDPLITE, netif); /* UDP */ } else { - LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP packet length %u\n", q->tot_len)); + LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP packet length %"U16_F"\n", q->tot_len)); udphdr->len = htons(q->tot_len); /* calculate checksum */ #if CHECKSUM_GEN_UDP @@ -486,7 +394,7 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p) #else udphdr->chksum = 0x0000; #endif - LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP checksum 0x%04x\n", udphdr->chksum)); + LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP checksum 0x%04"X16_F"\n", udphdr->chksum)); LWIP_DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if (,,,,IP_PROTO_UDP,)\n")); /* output to IP */ err = ip_output_if(q, src_ip, &pcb->remote_ip, pcb->ttl, pcb->tos, IP_PROTO_UDP, netif); @@ -525,12 +433,10 @@ udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port) { struct udp_pcb *ipcb; u8_t rebind; -#if SO_REUSE - int reuse_port_all_set = 1; -#endif /* SO_REUSE */ + LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 3, ("udp_bind(ipaddr = ")); ip_addr_debug_print(UDP_DEBUG, ipaddr); - LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 3, (", port = %u)\n", port)); + LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 3, (", port = %"U16_F")\n", port)); rebind = 0; /* Check for double bind and rebind of the same pcb */ @@ -543,7 +449,6 @@ udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port) rebind = 1; } -#if SO_REUSE == 0 /* this code does not allow upper layer to share a UDP port for listening to broadcast or multicast traffic (See SO_REUSE_ADDR and SO_REUSE_PORT under *BSD). TODO: See where it fits instead, OR @@ -556,56 +461,13 @@ udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port) ip_addr_isany(ipaddr) || ip_addr_cmp(&(ipcb->local_ip), ipaddr))) { /* other PCB already binds to this local IP and port */ - LWIP_DEBUGF(UDP_DEBUG, ("udp_bind: local port %u already bound by another pcb\n", port)); + LWIP_DEBUGF(UDP_DEBUG, ("udp_bind: local port %"U16_F" already bound by another pcb\n", port)); return ERR_USE; } #endif -#else /* SO_REUSE */ - /* Search through list of PCB's. - - If there is a PCB bound to specified port and IP_ADDR_ANY another PCB can be bound to the interface IP - or to the loopback address on the same port if SOF_REUSEADDR is set. Any combination of PCB's bound to - the same local port, but to one address out of {IP_ADDR_ANY, 127.0.0.1, interface IP} at a time is valid. - But no two PCB's bound to same local port and same local address is valid. - - If SOF_REUSEPORT is set several PCB's can be bound to same local port and same local address also. But then - all PCB's must have the SOF_REUSEPORT option set. - - When the two options aren't set and specified port is already bound, ERR_USE is returned saying that - address is already in use. */ - else if (ipcb->local_port == port) { - if(ip_addr_cmp(&(ipcb->local_ip), ipaddr)) { - if(pcb->so_options & SOF_REUSEPORT) { - LWIP_DEBUGF(UDP_DEBUG, ("udp_bind: in UDP PCB's SO_REUSEPORT set and same address.\n")); - reuse_port_all_set = (reuse_port_all_set && (ipcb->so_options & SOF_REUSEPORT)); - } - else { - LWIP_DEBUGF(UDP_DEBUG, ("udp_bind: in UDP PCB's SO_REUSEPORT not set and same address.\n")); - return ERR_USE; - } - } - else if((ip_addr_isany(ipaddr) && !ip_addr_isany(&(ipcb->local_ip))) || - (!ip_addr_isany(ipaddr) && ip_addr_isany(&(ipcb->local_ip)))) { - if(!(pcb->so_options & SOF_REUSEADDR) && !(pcb->so_options & SOF_REUSEPORT)) { - LWIP_DEBUGF(UDP_DEBUG, ("udp_bind: in UDP PCB's SO_REUSEPORT or SO_REUSEADDR not set and not the same address.\n")); - return ERR_USE; - } - } - } -#endif /* SO_REUSE */ - } -#if SO_REUSE - /* If SOF_REUSEPORT isn't set in all PCB's bound to specified port and local address specified then - {IP, port} can't be reused. */ - if(!reuse_port_all_set) { - LWIP_DEBUGF(UDP_DEBUG, ("udp_bind: not all sockets have SO_REUSEPORT set.\n")); - return ERR_USE; - } -#endif /* SO_REUSE */ - ip_addr_set(&pcb->local_ip, ipaddr); /* no port specified? */ if (port == 0) { @@ -635,11 +497,11 @@ udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port) pcb->next = udp_pcbs; udp_pcbs = pcb; } - LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | DBG_STATE, ("udp_bind: bound to %u.%u.%u.%u, port %u\n", - (unsigned int)(ntohl(pcb->local_ip.addr) >> 24 & 0xff), - (unsigned int)(ntohl(pcb->local_ip.addr) >> 16 & 0xff), - (unsigned int)(ntohl(pcb->local_ip.addr) >> 8 & 0xff), - (unsigned int)(ntohl(pcb->local_ip.addr) & 0xff), pcb->local_port)); + LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | DBG_STATE, ("udp_bind: bound to %"U16_F".%"U16_F".%"U16_F".%"U16_F", port %"U16_F"\n", + (u16_t)(ntohl(pcb->local_ip.addr) >> 24 & 0xff), + (u16_t)(ntohl(pcb->local_ip.addr) >> 16 & 0xff), + (u16_t)(ntohl(pcb->local_ip.addr) >> 8 & 0xff), + (u16_t)(ntohl(pcb->local_ip.addr) & 0xff), pcb->local_port)); return ERR_OK; } /** @@ -688,11 +550,11 @@ udp_connect(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port) pcb->local_ip.addr = 0; } #endif - LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | DBG_STATE, ("udp_connect: connected to %u.%u.%u.%u, port %u\n", - (unsigned int)(ntohl(pcb->remote_ip.addr) >> 24 & 0xff), - (unsigned int)(ntohl(pcb->remote_ip.addr) >> 16 & 0xff), - (unsigned int)(ntohl(pcb->remote_ip.addr) >> 8 & 0xff), - (unsigned int)(ntohl(pcb->remote_ip.addr) & 0xff), pcb->remote_port)); + LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | DBG_STATE, ("udp_connect: connected to %"U16_F".%"U16_F".%"U16_F".%"U16_F",port %"U16_F"\n", + (u16_t)(ntohl(pcb->remote_ip.addr) >> 24 & 0xff), + (u16_t)(ntohl(pcb->remote_ip.addr) >> 16 & 0xff), + (u16_t)(ntohl(pcb->remote_ip.addr) >> 8 & 0xff), + (u16_t)(ntohl(pcb->remote_ip.addr) & 0xff), pcb->remote_port)); /* Insert UDP PCB into the list of active UDP PCBs. */ for(ipcb = udp_pcbs; ipcb != NULL; ipcb = ipcb->next) { @@ -777,18 +639,17 @@ udp_new(void) { } #if UDP_DEBUG -int +void udp_debug_print(struct udp_hdr *udphdr) { LWIP_DEBUGF(UDP_DEBUG, ("UDP header:\n")); LWIP_DEBUGF(UDP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(UDP_DEBUG, ("| %5u | %5u | (src port, dest port)\n", + LWIP_DEBUGF(UDP_DEBUG, ("| %5"U16_F" | %5"U16_F" | (src port, dest port)\n", ntohs(udphdr->src), ntohs(udphdr->dest))); LWIP_DEBUGF(UDP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(UDP_DEBUG, ("| %5u | 0x%04x | (len, chksum)\n", + LWIP_DEBUGF(UDP_DEBUG, ("| %5"U16_F" | 0x%04"X16_F" | (len, chksum)\n", ntohs(udphdr->len), ntohs(udphdr->chksum))); LWIP_DEBUGF(UDP_DEBUG, ("+-------------------------------+\n")); - return 0; } #endif /* UDP_DEBUG */ diff --git a/src/include/ipv4/lwip/inet.h b/src/include/ipv4/lwip/inet.h index beab8518..0ae5f698 100644 --- a/src/include/ipv4/lwip/inet.h +++ b/src/include/ipv4/lwip/inet.h @@ -45,7 +45,7 @@ u16_t inet_chksum_pseudo(struct pbuf *p, u8_t proto, u16_t proto_len); u32_t inet_addr(const char *cp); -int inet_aton(const char *cp, struct in_addr *addr); +s8_t inet_aton(const char *cp, struct in_addr *addr); char *inet_ntoa(struct in_addr addr); /* returns ptr to static buffer; not reentrant! */ #ifdef htons diff --git a/src/include/ipv4/lwip/ip_addr.h b/src/include/ipv4/lwip/ip_addr.h index 0ef99937..2819b152 100644 --- a/src/include/ipv4/lwip/ip_addr.h +++ b/src/include/ipv4/lwip/ip_addr.h @@ -138,18 +138,18 @@ u8_t ip_addr_isbroadcast(struct ip_addr *, struct netif *); #define ip_addr_ismulticast(addr1) (((addr1)->addr & ntohl(0xf0000000)) == ntohl(0xe0000000)) -#define ip_addr_debug_print(debug, ipaddr) LWIP_DEBUGF(debug, ("%u.%u.%u.%u", \ - ipaddr?(unsigned int)(ntohl((ipaddr)->addr) >> 24) & 0xff:0, \ - ipaddr?(unsigned int)(ntohl((ipaddr)->addr) >> 16) & 0xff:0, \ - ipaddr?(unsigned int)(ntohl((ipaddr)->addr) >> 8) & 0xff:0, \ - ipaddr?(unsigned int)ntohl((ipaddr)->addr) & 0xff:0U)) +#define ip_addr_debug_print(debug, ipaddr) LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F, \ + ipaddr?(u16_t)(ntohl((ipaddr)->addr) >> 24) & 0xff:0, \ + ipaddr?(u16_t)(ntohl((ipaddr)->addr) >> 16) & 0xff:0, \ + ipaddr?(u16_t)(ntohl((ipaddr)->addr) >> 8) & 0xff:0, \ + ipaddr?(u16_t)ntohl((ipaddr)->addr) & 0xff:0U)) /* cast to unsigned int, as it is used as argument to printf functions - * which expect integer arguments */ -#define ip4_addr1(ipaddr) ((unsigned int)(ntohl((ipaddr)->addr) >> 24) & 0xff) -#define ip4_addr2(ipaddr) ((unsigned int)(ntohl((ipaddr)->addr) >> 16) & 0xff) -#define ip4_addr3(ipaddr) ((unsigned int)(ntohl((ipaddr)->addr) >> 8) & 0xff) -#define ip4_addr4(ipaddr) ((unsigned int)(ntohl((ipaddr)->addr)) & 0xff) + * which expect integer arguments. CSi: use cc.h formatters (conversion chars)! */ +#define ip4_addr1(ipaddr) ((u16_t)(ntohl((ipaddr)->addr) >> 24) & 0xff) +#define ip4_addr2(ipaddr) ((u16_t)(ntohl((ipaddr)->addr) >> 16) & 0xff) +#define ip4_addr3(ipaddr) ((u16_t)(ntohl((ipaddr)->addr) >> 8) & 0xff) +#define ip4_addr4(ipaddr) ((u16_t)(ntohl((ipaddr)->addr)) & 0xff) #endif /* __LWIP_IP_ADDR_H__ */ diff --git a/src/include/ipv6/lwip/inet.h b/src/include/ipv6/lwip/inet.h index 3cdd7407..ae783436 100644 --- a/src/include/ipv6/lwip/inet.h +++ b/src/include/ipv6/lwip/inet.h @@ -45,7 +45,7 @@ u16_t inet_chksum_pseudo(struct pbuf *p, u8_t proto, u32_t proto_len); u32_t inet_addr(const char *cp); -int inet_aton(const char *cp, struct in_addr *addr); +s8_t inet_aton(const char *cp, struct in_addr *addr); #ifndef _MACHINE_ENDIAN_H_ #ifndef _NETINET_IN_H diff --git a/src/include/ipv6/lwip/ip.h b/src/include/ipv6/lwip/ip.h index 432ca36e..f46bf9a8 100644 --- a/src/include/ipv6/lwip/ip.h +++ b/src/include/ipv6/lwip/ip.h @@ -81,10 +81,10 @@ void ip_input(struct pbuf *p, struct netif *inp); /* source and destination addresses in network byte order, please */ err_t ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, - unsigned char ttl, unsigned char proto); + u8_t ttl, u8_t proto); err_t ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, - unsigned char ttl, unsigned char proto, + u8_t ttl, u8_t proto, struct netif *netif); #if IP_DEBUG diff --git a/src/include/ipv6/lwip/ip_addr.h b/src/include/ipv6/lwip/ip_addr.h index 08e962dd..db1f0906 100644 --- a/src/include/ipv6/lwip/ip_addr.h +++ b/src/include/ipv6/lwip/ip_addr.h @@ -45,11 +45,11 @@ struct ip_addr { (ipaddr)->addr[2] = htonl(((e & 0xffff) << 16) | (f & 0xffff)); \ (ipaddr)->addr[3] = htonl(((g & 0xffff) << 16) | (h & 0xffff)); } while(0) -int ip_addr_netcmp(struct ip_addr *addr1, struct ip_addr *addr2, +u8_t ip_addr_netcmp(struct ip_addr *addr1, struct ip_addr *addr2, struct ip_addr *mask); -int ip_addr_cmp(struct ip_addr *addr1, struct ip_addr *addr2); +u8_t ip_addr_cmp(struct ip_addr *addr1, struct ip_addr *addr2); void ip_addr_set(struct ip_addr *dest, struct ip_addr *src); -int ip_addr_isany(struct ip_addr *addr); +u8_t ip_addr_isany(struct ip_addr *addr); #if IP_DEBUG diff --git a/src/include/lwip/api_msg.h b/src/include/lwip/api_msg.h index 1957abc5..3fef3dd0 100644 --- a/src/include/lwip/api_msg.h +++ b/src/include/lwip/api_msg.h @@ -75,7 +75,7 @@ struct api_msg_msg { struct { void *dataptr; u16_t len; - unsigned char copy; + u8_t copy; } w; sys_mbox_t mbox; u16_t len; diff --git a/src/include/lwip/debug.h b/src/include/lwip/debug.h index 4d3425c0..8f63a7b6 100644 --- a/src/include/lwip/debug.h +++ b/src/include/lwip/debug.h @@ -71,7 +71,7 @@ /** print debug message only if debug message type is enabled... * AND is of correct type AND is at least DBG_LEVEL */ -# define LWIP_DEBUGF(debug,x) do { if (((debug) & DBG_ON) && ((debug) & DBG_TYPES_ON) && ((int)((debug) & DBG_MASK_LEVEL) >= DBG_MIN_LEVEL)) { LWIP_PLATFORM_DIAG(x); if ((debug) & DBG_HALT) while(1); } } while(0) +# define LWIP_DEBUGF(debug,x) do { if (((debug) & DBG_ON) && ((debug) & DBG_TYPES_ON) && ((s16_t)((debug) & DBG_MASK_LEVEL) >= DBG_MIN_LEVEL)) { LWIP_PLATFORM_DIAG(x); if ((debug) & DBG_HALT) while(1); } } while(0) # define LWIP_ERROR(x) do { LWIP_PLATFORM_DIAG(x); } while(0) #else /* LWIP_DEBUG */ # define LWIP_DEBUGF(debug,x) diff --git a/src/include/lwip/netif.h b/src/include/lwip/netif.h index d0bda2df..ff50c6f9 100644 --- a/src/include/lwip/netif.h +++ b/src/include/lwip/netif.h @@ -98,9 +98,9 @@ struct netif { struct dhcp *dhcp; #endif /** number of bytes used in hwaddr */ - unsigned char hwaddr_len; + u8_t hwaddr_len; /** link level hardware address of this interface */ - unsigned char hwaddr[NETIF_MAX_HWADDR_LEN]; + u8_t hwaddr[NETIF_MAX_HWADDR_LEN]; /** maximum transfer unit (in bytes) */ u16_t mtu; /** flags (see NETIF_FLAG_ above) */ diff --git a/src/include/lwip/opt.h b/src/include/lwip/opt.h index 8e3910d5..4b855d63 100644 --- a/src/include/lwip/opt.h +++ b/src/include/lwip/opt.h @@ -346,8 +346,10 @@ a lot of data that needs to be copied, this should be set high. */ /* ---------- Socket Options ---------- */ /* Enable SO_REUSEADDR and SO_REUSEPORT options */ -#ifndef SO_REUSE -# define SO_REUSE 0 +#ifdef SO_REUSE +/* I removed the lot since this was an ugly hack. It broke the raw-API. + It also came with many ugly goto's, Christiaan Simons. */ +#error "SO_REUSE currently unavailable, this was a hack" #endif diff --git a/src/include/lwip/tcp.h b/src/include/lwip/tcp.h index 301a3f02..5f968c68 100644 --- a/src/include/lwip/tcp.h +++ b/src/include/lwip/tcp.h @@ -439,7 +439,7 @@ void tcp_debug_print(struct tcp_hdr *tcphdr); void tcp_debug_print_flags(u8_t flags); void tcp_debug_print_state(enum tcp_state s); void tcp_debug_print_pcbs(void); -int tcp_pcbs_sane(void); +s16_t tcp_pcbs_sane(void); #else # define tcp_debug_print(tcphdr) # define tcp_debug_print_flags(flags) diff --git a/src/include/lwip/udp.h b/src/include/lwip/udp.h index c5485947..ede04745 100644 --- a/src/include/lwip/udp.h +++ b/src/include/lwip/udp.h @@ -95,7 +95,7 @@ void udp_input (struct pbuf *p, struct netif *inp); void udp_init (void); #if UDP_DEBUG -int udp_debug_print(struct udp_hdr *udphdr); +void udp_debug_print(struct udp_hdr *udphdr); #else #define udp_debug_print(udphdr) #endif diff --git a/src/netif/etharp.c b/src/netif/etharp.c index 89ee69d1..4ead288d 100644 --- a/src/netif/etharp.c +++ b/src/netif/etharp.c @@ -146,13 +146,13 @@ etharp_tmr(void) if ((arp_table[i].state == ETHARP_STATE_STABLE) && /* entry has become old? */ (arp_table[i].ctime >= ARP_MAXAGE)) { - LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer: expired stable entry %u.\n", i)); + LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer: expired stable entry %"U16_F".\n", (u16_t)i)); arp_table[i].state = ETHARP_STATE_EXPIRED; /* pending entry? */ } else if (arp_table[i].state == ETHARP_STATE_PENDING) { /* entry unresolved/pending for too long? */ if (arp_table[i].ctime >= ARP_MAXPENDING) { - LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer: expired pending entry %u.\n", i)); + LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer: expired pending entry %"U16_F".\n", (u16_t)i)); arp_table[i].state = ETHARP_STATE_EXPIRED; #if ARP_QUEUEING } else if (arp_table[i].p != NULL) { @@ -166,7 +166,7 @@ etharp_tmr(void) /* and empty packet queue */ if (arp_table[i].p != NULL) { /* remove all queued packets */ - LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer: freeing entry %u, packet queue %p.\n", i, (void *)(arp_table[i].p))); + LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer: freeing entry %"U16_F", packet queue %p.\n", (u16_t)i, (void *)(arp_table[i].p))); pbuf_free(arp_table[i].p); arp_table[i].p = NULL; } @@ -229,7 +229,7 @@ static s8_t find_entry(struct ip_addr *ipaddr, u8_t flags) for (i = 0; i < ARP_TABLE_SIZE; ++i) { /* no empty entry found yet and now we do find one? */ if ((empty == ARP_TABLE_SIZE) && (arp_table[i].state == ETHARP_STATE_EMPTY)) { - LWIP_DEBUGF(ETHARP_DEBUG, ("find_entry: found empty entry %d\n", i)); + LWIP_DEBUGF(ETHARP_DEBUG, ("find_entry: found empty entry %"U16_F"\n", (u16_t)i)); /* remember first empty entry */ empty = i; } @@ -237,7 +237,7 @@ static s8_t find_entry(struct ip_addr *ipaddr, u8_t flags) else if (arp_table[i].state == ETHARP_STATE_PENDING) { /* if given, does IP address match IP address in ARP entry? */ if (ipaddr && ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) { - LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: found matching pending entry %d\n", i)); + LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: found matching pending entry %"U16_F"\n", (u16_t)i)); /* found exact IP address match, simply bail out */ return i; #if ARP_QUEUEING @@ -260,7 +260,7 @@ static s8_t find_entry(struct ip_addr *ipaddr, u8_t flags) else if (arp_table[i].state == ETHARP_STATE_STABLE) { /* if given, does IP address match IP address in ARP entry? */ if (ipaddr && ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) { - LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: found matching stable entry %d\n", i)); + LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: found matching stable entry %"U16_F"\n", (u16_t)i)); /* found exact IP address match, simply bail out */ return i; /* remember entry with oldest stable entry in oldest, its age in maxtime */ @@ -290,13 +290,13 @@ static s8_t find_entry(struct ip_addr *ipaddr, u8_t flags) /* 1) empty entry available? */ if (empty < ARP_TABLE_SIZE) { i = empty; - LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: selecting empty entry %d\n", i)); + LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: selecting empty entry %"U16_F"\n", (u16_t)i)); } /* 2) found recyclable stable entry? */ else if (old_stable < ARP_TABLE_SIZE) { /* recycle oldest stable*/ i = old_stable; - LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: selecting oldest stable entry %d\n", i)); + LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: selecting oldest stable entry %"U16_F"\n", (u16_t)i)); #if ARP_QUEUEING /* no queued packets should exist on stable entries */ LWIP_ASSERT("arp_table[i].p == NULL", arp_table[i].p == NULL); @@ -305,13 +305,13 @@ static s8_t find_entry(struct ip_addr *ipaddr, u8_t flags) } else if (old_pending < ARP_TABLE_SIZE) { /* recycle oldest pending */ i = old_pending; - LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: selecting oldest pending entry %d (without queue)\n", i)); + LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: selecting oldest pending entry %"U16_F" (without queue)\n", (u16_t)i)); #if ARP_QUEUEING /* 4) found recyclable pending entry with queued packets? */ } else if (old_queue < ARP_TABLE_SIZE) { /* recycle oldest pending */ i = old_queue; - LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: selecting oldest pending entry %d, freeing packet queue %p\n", i, (void *)(arp_table[i].p))); + LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: selecting oldest pending entry %"U16_F", freeing packet queue %p\n", (u16_t)i, (void *)(arp_table[i].p))); pbuf_free(arp_table[i].p); arp_table[i].p = NULL; #endif @@ -360,7 +360,7 @@ update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *e s8_t i, k; LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | 3, ("update_arp_entry()\n")); LWIP_ASSERT("netif->hwaddr_len != 0", netif->hwaddr_len != 0); - LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: %u.%u.%u.%u - %02x:%02x:%02x:%02x:%02x:%02x\n", + LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: %"U16_F".%"U16_F".%"U16_F".%"U16_F" - %02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F"\n", ip4_addr1(ipaddr), ip4_addr2(ipaddr), ip4_addr3(ipaddr), ip4_addr4(ipaddr), ethaddr->addr[0], ethaddr->addr[1], ethaddr->addr[2], ethaddr->addr[3], ethaddr->addr[4], ethaddr->addr[5])); @@ -379,7 +379,7 @@ update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *e /* mark it stable */ arp_table[i].state = ETHARP_STATE_STABLE; - LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: updating stable entry %u\n", i)); + LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: updating stable entry %"S16_F"\n", (s16_t)i)); /* update address */ for (k = 0; k < netif->hwaddr_len; ++k) { arp_table[i].ethaddr.addr[k] = ethaddr->addr[k]; @@ -477,7 +477,7 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p) /* drop short ARP packets */ if (p->tot_len < sizeof(struct etharp_hdr)) { - LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | 1, ("etharp_arp_input: packet dropped, too short (%d/%d)\n", p->tot_len, sizeof(struct etharp_hdr))); + LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | 1, ("etharp_arp_input: packet dropped, too short (%"S16_F"/%"S16_F")\n", p->tot_len, sizeof(struct etharp_hdr))); pbuf_free(p); return; } @@ -565,7 +565,7 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p) #endif break; default: - LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: ARP unknown opcode type %d\n", htons(hdr->opcode))); + LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: ARP unknown opcode type %"S16_F"\n", htons(hdr->opcode))); break; } /* free ARP packet */ @@ -765,7 +765,7 @@ err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q) pbuf_queue(arp_table[i].p, p); #endif } - LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: queued packet %p on ARP entry %d\n", (void *)q, i)); + LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: queued packet %p on ARP entry %"S16_F"\n", (void *)q, (s16_t)i)); result = ERR_OK; } else { LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: could not queue a copy of PBUF_REF packet %p (out of memory)\n", (void *)q)); diff --git a/src/netif/loopif.c b/src/netif/loopif.c index f5bcc07c..0464cb8e 100644 --- a/src/netif/loopif.c +++ b/src/netif/loopif.c @@ -58,7 +58,7 @@ loopif_output(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr) { struct pbuf *q, *r; - char *ptr; + u8_t *ptr; void **arg; #if defined(LWIP_DEBUG) && defined(LWIP_TCPDUMP) diff --git a/src/netif/slipif.c b/src/netif/slipif.c index d912c4da..dd8db208 100644 --- a/src/netif/slipif.c +++ b/src/netif/slipif.c @@ -60,7 +60,7 @@ err_t slipif_output(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr) { struct pbuf *q; - int i; + u16_t i; u8_t c; /* Send pbuf out on the serial I/O device. */ @@ -100,8 +100,8 @@ slipif_input(struct netif *netif) { u8_t c; struct pbuf *p, *q; - int recved; - int i; + u16_t recved; + u16_t i; q = p = NULL; recved = i = 0; @@ -170,7 +170,7 @@ slipif_input(struct netif *netif) } /** - * The SLIP input thread + * The SLIP input thread. * * Feed the IP layer with incoming packets */ @@ -196,7 +196,7 @@ err_t slipif_init(struct netif *netif) { - LWIP_DEBUGF(SLIP_DEBUG, ("slipif_init: netif->num=%x\n", (int)netif->num)); + LWIP_DEBUGF(SLIP_DEBUG, ("slipif_init: netif->num=%"U16_F"\n", (u16_t)netif->num)); netif->name[0] = 's'; netif->name[1] = 'l';