Reformat IPv4 code using astylerc

This commit is contained in:
Dirk Ziegelmeier 2017-09-17 20:33:27 +02:00
parent 3ed24085fa
commit 8c59be74c1
8 changed files with 659 additions and 662 deletions

View File

@ -123,7 +123,7 @@ autoip_set_struct(struct netif *netif, struct autoip *autoip)
static void static void
autoip_restart(struct netif *netif) autoip_restart(struct netif *netif)
{ {
struct autoip* autoip = netif_autoip_data(netif); struct autoip *autoip = netif_autoip_data(netif);
autoip->tried_llipaddr++; autoip->tried_llipaddr++;
autoip_start(netif); autoip_start(netif);
} }
@ -134,7 +134,7 @@ autoip_restart(struct netif *netif)
static void static void
autoip_handle_arp_conflict(struct netif *netif) autoip_handle_arp_conflict(struct netif *netif)
{ {
struct autoip* autoip = netif_autoip_data(netif); struct autoip *autoip = netif_autoip_data(netif);
/* RFC3927, 2.5 "Conflict Detection and Defense" allows two options where /* RFC3927, 2.5 "Conflict Detection and Defense" allows two options where
a) means retreat on the first conflict and a) means retreat on the first conflict and
@ -167,7 +167,7 @@ autoip_handle_arp_conflict(struct netif *netif)
static void static void
autoip_create_addr(struct netif *netif, ip4_addr_t *ipaddr) autoip_create_addr(struct netif *netif, ip4_addr_t *ipaddr)
{ {
struct autoip* autoip = netif_autoip_data(netif); struct autoip *autoip = netif_autoip_data(netif);
/* Here we create an IP-Address out of range 169.254.1.0 to 169.254.254.255 /* Here we create an IP-Address out of range 169.254.1.0 to 169.254.254.255
* compliant to RFC 3927 Section 2.1 * compliant to RFC 3927 Section 2.1
@ -202,7 +202,7 @@ autoip_create_addr(struct netif *netif, ip4_addr_t *ipaddr)
static err_t static err_t
autoip_arp_probe(struct netif *netif) autoip_arp_probe(struct netif *netif)
{ {
struct autoip* autoip = netif_autoip_data(netif); struct autoip *autoip = netif_autoip_data(netif);
/* this works because netif->ip_addr is ANY */ /* this works because netif->ip_addr is ANY */
return etharp_request(netif, &autoip->llipaddr); return etharp_request(netif, &autoip->llipaddr);
} }
@ -226,12 +226,12 @@ autoip_arp_announce(struct netif *netif)
static err_t static err_t
autoip_bind(struct netif *netif) autoip_bind(struct netif *netif)
{ {
struct autoip* autoip = netif_autoip_data(netif); struct autoip *autoip = netif_autoip_data(netif);
ip4_addr_t sn_mask, gw_addr; ip4_addr_t sn_mask, gw_addr;
LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE, LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE,
("autoip_bind(netif=%p) %c%c%"U16_F" %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", ("autoip_bind(netif=%p) %c%c%"U16_F" %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
(void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num, (void *)netif, netif->name[0], netif->name[1], (u16_t)netif->num,
ip4_addr1_16(&autoip->llipaddr), ip4_addr2_16(&autoip->llipaddr), ip4_addr1_16(&autoip->llipaddr), ip4_addr2_16(&autoip->llipaddr),
ip4_addr3_16(&autoip->llipaddr), ip4_addr4_16(&autoip->llipaddr))); ip4_addr3_16(&autoip->llipaddr), ip4_addr4_16(&autoip->llipaddr)));
@ -253,7 +253,7 @@ autoip_bind(struct netif *netif)
err_t err_t
autoip_start(struct netif *netif) autoip_start(struct netif *netif)
{ {
struct autoip* autoip = netif_autoip_data(netif); struct autoip *autoip = netif_autoip_data(netif);
err_t result = ERR_OK; err_t result = ERR_OK;
LWIP_ERROR("netif is not up, old style port?", netif_is_up(netif), return ERR_ARG;); LWIP_ERROR("netif is not up, old style port?", netif_is_up(netif), return ERR_ARG;);
@ -264,7 +264,7 @@ autoip_start(struct netif *netif)
netif_set_addr(netif, IP4_ADDR_ANY4, IP4_ADDR_ANY4, IP4_ADDR_ANY4); netif_set_addr(netif, IP4_ADDR_ANY4, IP4_ADDR_ANY4, IP4_ADDR_ANY4);
LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE,
("autoip_start(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0], ("autoip_start(netif=%p) %c%c%"U16_F"\n", (void *)netif, netif->name[0],
netif->name[1], (u16_t)netif->num)); netif->name[1], (u16_t)netif->num));
if (autoip == NULL) { if (autoip == NULL) {
/* no AutoIP client attached yet? */ /* no AutoIP client attached yet? */
@ -296,7 +296,7 @@ autoip_start(struct netif *netif)
static void static void
autoip_start_probing(struct netif *netif) autoip_start_probing(struct netif *netif)
{ {
struct autoip* autoip = netif_autoip_data(netif); struct autoip *autoip = netif_autoip_data(netif);
autoip->state = AUTOIP_STATE_PROBING; autoip->state = AUTOIP_STATE_PROBING;
autoip->sent_num = 0; autoip->sent_num = 0;
@ -330,7 +330,7 @@ autoip_start_probing(struct netif *netif)
void void
autoip_network_changed(struct netif *netif) autoip_network_changed(struct netif *netif)
{ {
struct autoip* autoip = netif_autoip_data(netif); struct autoip *autoip = netif_autoip_data(netif);
if (autoip && (autoip->state != AUTOIP_STATE_OFF)) { if (autoip && (autoip->state != AUTOIP_STATE_OFF)) {
autoip_start_probing(netif); autoip_start_probing(netif);
@ -346,7 +346,7 @@ autoip_network_changed(struct netif *netif)
err_t err_t
autoip_stop(struct netif *netif) autoip_stop(struct netif *netif)
{ {
struct autoip* autoip = netif_autoip_data(netif); struct autoip *autoip = netif_autoip_data(netif);
if (autoip != NULL) { if (autoip != NULL) {
autoip->state = AUTOIP_STATE_OFF; autoip->state = AUTOIP_STATE_OFF;
@ -366,7 +366,7 @@ autoip_tmr(void)
struct netif *netif; struct netif *netif;
/* loop through netif's */ /* loop through netif's */
NETIF_FOREACH(netif) { NETIF_FOREACH(netif) {
struct autoip* autoip = netif_autoip_data(netif); struct autoip *autoip = netif_autoip_data(netif);
/* only act on AutoIP configured interfaces */ /* only act on AutoIP configured interfaces */
if (autoip != NULL) { if (autoip != NULL) {
if (autoip->lastconflict > 0) { if (autoip->lastconflict > 0) {
@ -381,7 +381,7 @@ autoip_tmr(void)
autoip->ttw--; autoip->ttw--;
} }
switch(autoip->state) { switch (autoip->state) {
case AUTOIP_STATE_PROBING: case AUTOIP_STATE_PROBING:
if (autoip->ttw == 0) { if (autoip->ttw == 0) {
if (autoip->sent_num >= PROBE_NUM) { if (autoip->sent_num >= PROBE_NUM) {
@ -449,7 +449,7 @@ autoip_tmr(void)
void void
autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr) autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr)
{ {
struct autoip* autoip = netif_autoip_data(netif); struct autoip *autoip = netif_autoip_data(netif);
LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE, ("autoip_arp_reply()\n")); LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE, ("autoip_arp_reply()\n"));
if ((autoip != NULL) && (autoip->state != AUTOIP_STATE_OFF)) { if ((autoip != NULL) && (autoip->state != AUTOIP_STATE_OFF)) {
@ -508,7 +508,7 @@ u8_t
autoip_supplied_address(const struct netif *netif) autoip_supplied_address(const struct netif *netif)
{ {
if ((netif != NULL) && (netif_autoip_data(netif) != NULL)) { if ((netif != NULL) && (netif_autoip_data(netif) != NULL)) {
struct autoip* autoip = netif_autoip_data(netif); struct autoip *autoip = netif_autoip_data(netif);
return (autoip->state == AUTOIP_STATE_BOUND) || (autoip->state == AUTOIP_STATE_ANNOUNCING); return (autoip->state == AUTOIP_STATE_BOUND) || (autoip->state == AUTOIP_STATE_ANNOUNCING);
} }
return 0; return 0;
@ -517,7 +517,7 @@ autoip_supplied_address(const struct netif *netif)
u8_t u8_t
autoip_accept_packet(struct netif *netif, const ip4_addr_t *addr) autoip_accept_packet(struct netif *netif, const ip4_addr_t *addr)
{ {
struct autoip* autoip = netif_autoip_data(netif); struct autoip *autoip = netif_autoip_data(netif);
return (autoip != NULL) && ip4_addr_cmp(addr, &(autoip->llipaddr)); return (autoip != NULL) && ip4_addr_cmp(addr, &(autoip->llipaddr));
} }

View File

@ -170,7 +170,7 @@ static u8_t dhcp_discover_request_options[] = {
#if LWIP_DHCP_GET_NTP_SRV #if LWIP_DHCP_GET_NTP_SRV
, DHCP_OPTION_NTP , DHCP_OPTION_NTP
#endif /* LWIP_DHCP_GET_NTP_SRV */ #endif /* LWIP_DHCP_GET_NTP_SRV */
}; };
#ifdef DHCP_GLOBAL_XID #ifdef DHCP_GLOBAL_XID
static u32_t xid; static u32_t xid;
@ -279,7 +279,7 @@ dhcp_handle_nak(struct netif *netif)
struct dhcp *dhcp = netif_dhcp_data(netif); struct dhcp *dhcp = netif_dhcp_data(netif);
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_handle_nak(netif=%p) %c%c%"U16_F"\n", LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_handle_nak(netif=%p) %c%c%"U16_F"\n",
(void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num)); (void *)netif, netif->name[0], netif->name[1], (u16_t)netif->num));
/* Change to a defined state - set this before assigning the address /* Change to a defined state - set this before assigning the address
to ensure the callback can use dhcp_supplied_address() */ to ensure the callback can use dhcp_supplied_address() */
dhcp_set_state(dhcp, DHCP_STATE_BACKING_OFF); dhcp_set_state(dhcp, DHCP_STATE_BACKING_OFF);
@ -334,7 +334,7 @@ dhcp_handle_offer(struct netif *netif, struct dhcp_msg *msg_in)
struct dhcp *dhcp = netif_dhcp_data(netif); struct dhcp *dhcp = netif_dhcp_data(netif);
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_handle_offer(netif=%p) %c%c%"U16_F"\n", LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_handle_offer(netif=%p) %c%c%"U16_F"\n",
(void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num)); (void *)netif, netif->name[0], netif->name[1], (u16_t)netif->num));
/* obtain the server address */ /* obtain the server address */
if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_SERVER_ID)) { if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_SERVER_ID)) {
ip_addr_set_ip4_u32(&dhcp->server_ip_addr, lwip_htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_SERVER_ID))); ip_addr_set_ip4_u32(&dhcp->server_ip_addr, lwip_htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_SERVER_ID)));
@ -348,7 +348,7 @@ dhcp_handle_offer(struct netif *netif, struct dhcp_msg *msg_in)
dhcp_select(netif); dhcp_select(netif);
} else { } else {
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS,
("dhcp_handle_offer(netif=%p) did not get server ID!\n", (void*)netif)); ("dhcp_handle_offer(netif=%p) did not get server ID!\n", (void *)netif));
} }
} }
@ -373,7 +373,7 @@ dhcp_select(struct netif *netif)
LWIP_ERROR("dhcp_select: netif != NULL", (netif != NULL), return ERR_ARG;); LWIP_ERROR("dhcp_select: netif != NULL", (netif != NULL), return ERR_ARG;);
LWIP_ERROR("dhcp_select: dhcp != NULL", (dhcp != NULL), return ERR_VAL;); LWIP_ERROR("dhcp_select: dhcp != NULL", (dhcp != NULL), return ERR_VAL;);
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_select(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num)); LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_select(netif=%p) %c%c%"U16_F"\n", (void *)netif, netif->name[0], netif->name[1], (u16_t)netif->num));
dhcp_set_state(dhcp, DHCP_STATE_REQUESTING); dhcp_set_state(dhcp, DHCP_STATE_REQUESTING);
/* create and initialize the DHCP message header */ /* create and initialize the DHCP message header */
@ -473,8 +473,7 @@ dhcp_fine_tmr(void)
/* timer is active (non zero), and is about to trigger now */ /* timer is active (non zero), and is about to trigger now */
if (dhcp->request_timeout > 1) { if (dhcp->request_timeout > 1) {
dhcp->request_timeout--; dhcp->request_timeout--;
} } else if (dhcp->request_timeout == 1) {
else if (dhcp->request_timeout == 1) {
dhcp->request_timeout--; dhcp->request_timeout--;
/* { netif->dhcp->request_timeout == 0 } */ /* { netif->dhcp->request_timeout == 0 } */
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_fine_tmr(): request timeout\n")); LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_fine_tmr(): request timeout\n"));
@ -556,8 +555,7 @@ dhcp_t1_timeout(struct netif *netif)
DHCP_STATE_RENEWING, not DHCP_STATE_BOUND */ DHCP_STATE_RENEWING, not DHCP_STATE_BOUND */
dhcp_renew(netif); dhcp_renew(netif);
/* Calculate next timeout */ /* Calculate next timeout */
if (((dhcp->t2_timeout - dhcp->lease_used) / 2) >= ((60 + DHCP_COARSE_TIMER_SECS / 2) / DHCP_COARSE_TIMER_SECS)) if (((dhcp->t2_timeout - dhcp->lease_used) / 2) >= ((60 + DHCP_COARSE_TIMER_SECS / 2) / DHCP_COARSE_TIMER_SECS)) {
{
dhcp->t1_renew_time = (u16_t)((dhcp->t2_timeout - dhcp->lease_used) / 2); dhcp->t1_renew_time = (u16_t)((dhcp->t2_timeout - dhcp->lease_used) / 2);
} }
} }
@ -583,8 +581,7 @@ dhcp_t2_timeout(struct netif *netif)
DHCP_STATE_REBINDING, not DHCP_STATE_BOUND */ DHCP_STATE_REBINDING, not DHCP_STATE_BOUND */
dhcp_rebind(netif); dhcp_rebind(netif);
/* Calculate next timeout */ /* Calculate next timeout */
if (((dhcp->t0_timeout - dhcp->lease_used) / 2) >= ((60 + DHCP_COARSE_TIMER_SECS / 2) / DHCP_COARSE_TIMER_SECS)) if (((dhcp->t0_timeout - dhcp->lease_used) / 2) >= ((60 + DHCP_COARSE_TIMER_SECS / 2) / DHCP_COARSE_TIMER_SECS)) {
{
dhcp->t2_rebind_time = (u16_t)((dhcp->t0_timeout - dhcp->lease_used) / 2); dhcp->t2_rebind_time = (u16_t)((dhcp->t0_timeout - dhcp->lease_used) / 2);
} }
} }
@ -740,7 +737,7 @@ dhcp_start(struct netif *netif)
LWIP_ERROR("netif != NULL", (netif != NULL), return ERR_ARG;); LWIP_ERROR("netif != NULL", (netif != NULL), return ERR_ARG;);
LWIP_ERROR("netif is not up, old style port?", netif_is_up(netif), return ERR_ARG;); LWIP_ERROR("netif is not up, old style port?", netif_is_up(netif), return ERR_ARG;);
dhcp = netif_dhcp_data(netif); dhcp = netif_dhcp_data(netif);
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_start(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num)); LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_start(netif=%p) %c%c%"U16_F"\n", (void *)netif, netif->name[0], netif->name[1], (u16_t)netif->num));
/* check MTU of the netif */ /* check MTU of the netif */
if (netif->mtu < DHCP_MAX_MSG_LEN_MIN_REQUIRED) { if (netif->mtu < DHCP_MAX_MSG_LEN_MIN_REQUIRED) {
@ -963,7 +960,7 @@ dhcp_decline(struct netif *netif)
if (dhcp->tries < 255) { if (dhcp->tries < 255) {
dhcp->tries++; dhcp->tries++;
} }
msecs = 10*1000; msecs = 10 * 1000;
dhcp->request_timeout = (u16_t)((msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS); dhcp->request_timeout = (u16_t)((msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS);
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_decline(): set request timeout %"U16_F" msecs\n", msecs)); LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_decline(): set request timeout %"U16_F" msecs\n", msecs));
return result; return result;
@ -1044,7 +1041,7 @@ dhcp_bind(struct netif *netif)
LWIP_ERROR("dhcp_bind: netif != NULL", (netif != NULL), return;); LWIP_ERROR("dhcp_bind: netif != NULL", (netif != NULL), return;);
dhcp = netif_dhcp_data(netif); dhcp = netif_dhcp_data(netif);
LWIP_ERROR("dhcp_bind: dhcp != NULL", (dhcp != NULL), return;); LWIP_ERROR("dhcp_bind: dhcp != NULL", (dhcp != NULL), return;);
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_bind(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num)); LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_bind(netif=%p) %c%c%"U16_F"\n", (void *)netif, netif->name[0], netif->name[1], (u16_t)netif->num));
/* reset time used of lease */ /* reset time used of lease */
dhcp->lease_used = 0; dhcp->lease_used = 0;
@ -1060,7 +1057,7 @@ dhcp_bind(struct netif *netif)
if (dhcp->t0_timeout == 0) { if (dhcp->t0_timeout == 0) {
dhcp->t0_timeout = 1; dhcp->t0_timeout = 1;
} }
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_bind(): set request timeout %"U32_F" msecs\n", dhcp->offered_t0_lease*1000)); LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_bind(): set request timeout %"U32_F" msecs\n", dhcp->offered_t0_lease * 1000));
} }
/* temporary DHCP lease? */ /* temporary DHCP lease? */
@ -1075,7 +1072,7 @@ dhcp_bind(struct netif *netif)
if (dhcp->t1_timeout == 0) { if (dhcp->t1_timeout == 0) {
dhcp->t1_timeout = 1; dhcp->t1_timeout = 1;
} }
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_bind(): set request timeout %"U32_F" msecs\n", dhcp->offered_t1_renew*1000)); LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_bind(): set request timeout %"U32_F" msecs\n", dhcp->offered_t1_renew * 1000));
dhcp->t1_renew_time = dhcp->t1_timeout; dhcp->t1_renew_time = dhcp->t1_timeout;
} }
/* set renewal period timer */ /* set renewal period timer */
@ -1089,7 +1086,7 @@ dhcp_bind(struct netif *netif)
if (dhcp->t2_timeout == 0) { if (dhcp->t2_timeout == 0) {
dhcp->t2_timeout = 1; dhcp->t2_timeout = 1;
} }
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_bind(): set request timeout %"U32_F" msecs\n", dhcp->offered_t2_rebind*1000)); LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_bind(): set request timeout %"U32_F" msecs\n", dhcp->offered_t2_rebind * 1000));
dhcp->t2_rebind_time = dhcp->t2_timeout; dhcp->t2_rebind_time = dhcp->t2_timeout;
} }
@ -1540,7 +1537,7 @@ again:
} }
offset = options_idx; offset = options_idx;
offset_max = options_idx_max; offset_max = options_idx_max;
options = (u8_t*)q->payload; options = (u8_t *)q->payload;
/* at least 1 byte to read and no end marker, then at least 3 bytes to read? */ /* at least 1 byte to read and no end marker, then at least 3 bytes to read? */
while ((q != NULL) && (offset < offset_max) && (options[offset] != DHCP_OPTION_END)) { while ((q != NULL) && (offset < offset_max) && (options[offset] != DHCP_OPTION_END)) {
u8_t op = options[offset]; u8_t op = options[offset];
@ -1556,29 +1553,29 @@ again:
if ((offset + 1) < q->len) { if ((offset + 1) < q->len) {
len = options[offset + 1]; len = options[offset + 1];
} else { } else {
len = (q->next != NULL ? ((u8_t*)q->next->payload)[0] : 0); len = (q->next != NULL ? ((u8_t *)q->next->payload)[0] : 0);
} }
/* LWIP_DEBUGF(DHCP_DEBUG, ("msg_offset=%"U16_F", q->len=%"U16_F, msg_offset, q->len)); */ /* LWIP_DEBUGF(DHCP_DEBUG, ("msg_offset=%"U16_F", q->len=%"U16_F, msg_offset, q->len)); */
decode_len = len; decode_len = len;
switch(op) { switch (op) {
/* case(DHCP_OPTION_END): handled above */ /* case(DHCP_OPTION_END): handled above */
case(DHCP_OPTION_PAD): case (DHCP_OPTION_PAD):
/* special option: no len encoded */ /* special option: no len encoded */
decode_len = len = 0; decode_len = len = 0;
/* will be increased below */ /* will be increased below */
offset--; offset--;
break; break;
case(DHCP_OPTION_SUBNET_MASK): case (DHCP_OPTION_SUBNET_MASK):
LWIP_ERROR("len == 4", len == 4, return ERR_VAL;); LWIP_ERROR("len == 4", len == 4, return ERR_VAL;);
decode_idx = DHCP_OPTION_IDX_SUBNET_MASK; decode_idx = DHCP_OPTION_IDX_SUBNET_MASK;
break; break;
case(DHCP_OPTION_ROUTER): case (DHCP_OPTION_ROUTER):
decode_len = 4; /* only copy the first given router */ decode_len = 4; /* only copy the first given router */
LWIP_ERROR("len >= decode_len", len >= decode_len, return ERR_VAL;); LWIP_ERROR("len >= decode_len", len >= decode_len, return ERR_VAL;);
decode_idx = DHCP_OPTION_IDX_ROUTER; decode_idx = DHCP_OPTION_IDX_ROUTER;
break; break;
#if LWIP_DHCP_PROVIDE_DNS_SERVERS #if LWIP_DHCP_PROVIDE_DNS_SERVERS
case(DHCP_OPTION_DNS_SERVER): case (DHCP_OPTION_DNS_SERVER):
/* special case: there might be more than one server */ /* special case: there might be more than one server */
LWIP_ERROR("len %% 4 == 0", len % 4 == 0, return ERR_VAL;); LWIP_ERROR("len %% 4 == 0", len % 4 == 0, return ERR_VAL;);
/* limit number of DNS servers */ /* limit number of DNS servers */
@ -1587,12 +1584,12 @@ again:
decode_idx = DHCP_OPTION_IDX_DNS_SERVER; decode_idx = DHCP_OPTION_IDX_DNS_SERVER;
break; break;
#endif /* LWIP_DHCP_PROVIDE_DNS_SERVERS */ #endif /* LWIP_DHCP_PROVIDE_DNS_SERVERS */
case(DHCP_OPTION_LEASE_TIME): case (DHCP_OPTION_LEASE_TIME):
LWIP_ERROR("len == 4", len == 4, return ERR_VAL;); LWIP_ERROR("len == 4", len == 4, return ERR_VAL;);
decode_idx = DHCP_OPTION_IDX_LEASE_TIME; decode_idx = DHCP_OPTION_IDX_LEASE_TIME;
break; break;
#if LWIP_DHCP_GET_NTP_SRV #if LWIP_DHCP_GET_NTP_SRV
case(DHCP_OPTION_NTP): case (DHCP_OPTION_NTP):
/* special case: there might be more than one server */ /* special case: there might be more than one server */
LWIP_ERROR("len %% 4 == 0", len % 4 == 0, return ERR_VAL;); LWIP_ERROR("len %% 4 == 0", len % 4 == 0, return ERR_VAL;);
/* limit number of NTP servers */ /* limit number of NTP servers */
@ -1601,25 +1598,25 @@ again:
decode_idx = DHCP_OPTION_IDX_NTP_SERVER; decode_idx = DHCP_OPTION_IDX_NTP_SERVER;
break; break;
#endif /* LWIP_DHCP_GET_NTP_SRV*/ #endif /* LWIP_DHCP_GET_NTP_SRV*/
case(DHCP_OPTION_OVERLOAD): case (DHCP_OPTION_OVERLOAD):
LWIP_ERROR("len == 1", len == 1, return ERR_VAL;); LWIP_ERROR("len == 1", len == 1, return ERR_VAL;);
/* decode overload only in options, not in file/sname: invalid packet */ /* decode overload only in options, not in file/sname: invalid packet */
LWIP_ERROR("overload in file/sname", options_idx == DHCP_OPTIONS_OFS, return ERR_VAL;); LWIP_ERROR("overload in file/sname", options_idx == DHCP_OPTIONS_OFS, return ERR_VAL;);
decode_idx = DHCP_OPTION_IDX_OVERLOAD; decode_idx = DHCP_OPTION_IDX_OVERLOAD;
break; break;
case(DHCP_OPTION_MESSAGE_TYPE): case (DHCP_OPTION_MESSAGE_TYPE):
LWIP_ERROR("len == 1", len == 1, return ERR_VAL;); LWIP_ERROR("len == 1", len == 1, return ERR_VAL;);
decode_idx = DHCP_OPTION_IDX_MSG_TYPE; decode_idx = DHCP_OPTION_IDX_MSG_TYPE;
break; break;
case(DHCP_OPTION_SERVER_ID): case (DHCP_OPTION_SERVER_ID):
LWIP_ERROR("len == 4", len == 4, return ERR_VAL;); LWIP_ERROR("len == 4", len == 4, return ERR_VAL;);
decode_idx = DHCP_OPTION_IDX_SERVER_ID; decode_idx = DHCP_OPTION_IDX_SERVER_ID;
break; break;
case(DHCP_OPTION_T1): case (DHCP_OPTION_T1):
LWIP_ERROR("len == 4", len == 4, return ERR_VAL;); LWIP_ERROR("len == 4", len == 4, return ERR_VAL;);
decode_idx = DHCP_OPTION_IDX_T1; decode_idx = DHCP_OPTION_IDX_T1;
break; break;
case(DHCP_OPTION_T2): case (DHCP_OPTION_T2):
LWIP_ERROR("len == 4", len == 4, return ERR_VAL;); LWIP_ERROR("len == 4", len == 4, return ERR_VAL;);
decode_idx = DHCP_OPTION_IDX_T2; decode_idx = DHCP_OPTION_IDX_T2;
break; break;
@ -1665,7 +1662,7 @@ decode_next:
value = lwip_ntohl(value); value = lwip_ntohl(value);
} else { } else {
LWIP_ERROR("invalid decode_len", decode_len == 1, return ERR_VAL;); LWIP_ERROR("invalid decode_len", decode_len == 1, return ERR_VAL;);
value = ((u8_t*)&value)[0]; value = ((u8_t *)&value)[0];
} }
dhcp_got_option(dhcp, decode_idx); dhcp_got_option(dhcp, decode_idx);
dhcp_set_option_value(dhcp, decode_idx, value); dhcp_set_option_value(dhcp, decode_idx, value);
@ -1677,7 +1674,7 @@ decode_next:
if ((offset < offset_max) && offset_max) { if ((offset < offset_max) && offset_max) {
q = q->next; q = q->next;
LWIP_ERROR("next pbuf was null", q != NULL, return ERR_VAL;); LWIP_ERROR("next pbuf was null", q != NULL, return ERR_VAL;);
options = (u8_t*)q->payload; options = (u8_t *)q->payload;
} else { } else {
/* We've run out of bytes, probably no end marker. Don't proceed. */ /* We've run out of bytes, probably no end marker. Don't proceed. */
break; break;
@ -1707,11 +1704,11 @@ decode_next:
if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_MSG_TYPE) && if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_MSG_TYPE) &&
(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_MSG_TYPE) == DHCP_ACK)) (dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_MSG_TYPE) == DHCP_ACK))
/* copy bootp file name, don't care for sname (server hostname) */ /* copy bootp file name, don't care for sname (server hostname) */
if (pbuf_copy_partial(p, dhcp->boot_file_name, DHCP_FILE_LEN-1, DHCP_FILE_OFS) != (DHCP_FILE_LEN-1)) { if (pbuf_copy_partial(p, dhcp->boot_file_name, DHCP_FILE_LEN - 1, DHCP_FILE_OFS) != (DHCP_FILE_LEN - 1)) {
return ERR_BUF; return ERR_BUF;
} }
/* make sure the string is really NULL-terminated */ /* make sure the string is really NULL-terminated */
dhcp->boot_file_name[DHCP_FILE_LEN-1] = 0; dhcp->boot_file_name[DHCP_FILE_LEN - 1] = 0;
} }
#endif /* LWIP_DHCP_BOOTP_FILE */ #endif /* LWIP_DHCP_BOOTP_FILE */
} }
@ -1752,7 +1749,7 @@ dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr,
LWIP_ASSERT("invalid server address type", IP_IS_V4(addr)); LWIP_ASSERT("invalid server address type", IP_IS_V4(addr));
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_recv(pbuf = %p) from DHCP server %"U16_F".%"U16_F".%"U16_F".%"U16_F" port %"U16_F"\n", (void*)p, LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_recv(pbuf = %p) from DHCP server %"U16_F".%"U16_F".%"U16_F".%"U16_F" port %"U16_F"\n", (void *)p,
ip4_addr1_16(ip_2_ip4(addr)), ip4_addr2_16(ip_2_ip4(addr)), ip4_addr3_16(ip_2_ip4(addr)), ip4_addr4_16(ip_2_ip4(addr)), port)); ip4_addr1_16(ip_2_ip4(addr)), ip4_addr2_16(ip_2_ip4(addr)), ip4_addr3_16(ip_2_ip4(addr)), ip4_addr4_16(ip_2_ip4(addr)), port));
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("pbuf->len = %"U16_F"\n", p->len)); LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("pbuf->len = %"U16_F"\n", p->len));
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("pbuf->tot_len = %"U16_F"\n", p->tot_len)); LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("pbuf->tot_len = %"U16_F"\n", p->tot_len));
@ -1782,7 +1779,7 @@ dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr,
/* match transaction ID against what we expected */ /* match transaction ID against what we expected */
if (lwip_ntohl(reply_msg->xid) != dhcp->xid) { if (lwip_ntohl(reply_msg->xid) != dhcp->xid) {
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING, LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING,
("transaction id mismatch reply_msg->xid(%"X32_F")!=dhcp->xid(%"X32_F")\n",lwip_ntohl(reply_msg->xid),dhcp->xid)); ("transaction id mismatch reply_msg->xid(%"X32_F")!=dhcp->xid(%"X32_F")\n", lwip_ntohl(reply_msg->xid), dhcp->xid));
goto free_pbuf_and_return; goto free_pbuf_and_return;
} }
/* option fields could be unfold? */ /* option fields could be unfold? */
@ -1964,7 +1961,7 @@ u8_t
dhcp_supplied_address(const struct netif *netif) dhcp_supplied_address(const struct netif *netif)
{ {
if ((netif != NULL) && (netif_dhcp_data(netif) != NULL)) { if ((netif != NULL) && (netif_dhcp_data(netif) != NULL)) {
struct dhcp* dhcp = netif_dhcp_data(netif); struct dhcp *dhcp = netif_dhcp_data(netif);
return (dhcp->state == DHCP_STATE_BOUND) || (dhcp->state == DHCP_STATE_RENEWING) || return (dhcp->state == DHCP_STATE_BOUND) || (dhcp->state == DHCP_STATE_RENEWING) ||
(dhcp->state == DHCP_STATE_REBINDING); (dhcp->state == DHCP_STATE_REBINDING);
} }

View File

@ -85,7 +85,7 @@ enum etharp_state {
ETHARP_STATE_STABLE_REREQUESTING_1, ETHARP_STATE_STABLE_REREQUESTING_1,
ETHARP_STATE_STABLE_REREQUESTING_2 ETHARP_STATE_STABLE_REREQUESTING_2
#if ETHARP_SUPPORT_STATIC_ENTRIES #if ETHARP_SUPPORT_STATIC_ENTRIES
,ETHARP_STATE_STATIC , ETHARP_STATE_STATIC
#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */ #endif /* ETHARP_SUPPORT_STATIC_ENTRIES */
}; };
@ -128,11 +128,11 @@ static u8_t etharp_cached_entry;
/* Some checks, instead of etharp_init(): */ /* Some checks, instead of etharp_init(): */
#if (LWIP_ARP && (ARP_TABLE_SIZE > 0x7f)) #if (LWIP_ARP && (ARP_TABLE_SIZE > 0x7f))
#error "ARP_TABLE_SIZE must fit in an s8_t, you have to reduce it in your lwipopts.h" #error "ARP_TABLE_SIZE must fit in an s8_t, you have to reduce it in your lwipopts.h"
#endif #endif
static err_t etharp_request_dst(struct netif *netif, const ip4_addr_t *ipaddr, const struct eth_addr* hw_dst_addr); static err_t etharp_request_dst(struct netif *netif, const ip4_addr_t *ipaddr, const struct eth_addr *hw_dst_addr);
static err_t etharp_raw(struct netif *netif, static err_t etharp_raw(struct netif *netif,
const struct eth_addr *ethsrc_addr, const struct eth_addr *ethdst_addr, const struct eth_addr *ethsrc_addr, const struct eth_addr *ethdst_addr,
const struct eth_addr *hwsrc_addr, const ip4_addr_t *ipsrc_addr, const struct eth_addr *hwsrc_addr, const ip4_addr_t *ipsrc_addr,
@ -256,7 +256,7 @@ etharp_tmr(void)
* entry is found or could be recycled. * entry is found or could be recycled.
*/ */
static s8_t static s8_t
etharp_find_entry(const ip4_addr_t *ipaddr, u8_t flags, struct netif* netif) etharp_find_entry(const ip4_addr_t *ipaddr, u8_t flags, struct netif *netif)
{ {
s8_t old_pending = ARP_TABLE_SIZE, old_stable = ARP_TABLE_SIZE; s8_t old_pending = ARP_TABLE_SIZE, old_stable = ARP_TABLE_SIZE;
s8_t empty = ARP_TABLE_SIZE; s8_t empty = ARP_TABLE_SIZE;
@ -486,7 +486,7 @@ etharp_update_arp_entry(struct netif *netif, const ip4_addr_t *ipaddr, struct et
arp_table[i].q = NULL; arp_table[i].q = NULL;
#endif /* ARP_QUEUEING */ #endif /* ARP_QUEUEING */
/* send the queued IP packet */ /* send the queued IP packet */
ethernet_output(netif, p, (struct eth_addr*)(netif->hwaddr), ethaddr, ETHTYPE_IP); ethernet_output(netif, p, (struct eth_addr *)(netif->hwaddr), ethaddr, ETHTYPE_IP);
/* free the queued IP packet */ /* free the queued IP packet */
pbuf_free(p); pbuf_free(p);
} }
@ -616,7 +616,7 @@ etharp_get_entry(u8_t i, ip4_addr_t **ipaddr, struct netif **netif, struct eth_a
LWIP_ASSERT("netif != NULL", netif != NULL); LWIP_ASSERT("netif != NULL", netif != NULL);
LWIP_ASSERT("eth_ret != NULL", eth_ret != NULL); LWIP_ASSERT("eth_ret != NULL", eth_ret != NULL);
if((i < ARP_TABLE_SIZE) && (arp_table[i].state >= ETHARP_STATE_STABLE)) { if ((i < ARP_TABLE_SIZE) && (arp_table[i].state >= ETHARP_STATE_STABLE)) {
*ipaddr = &arp_table[i].ipaddr; *ipaddr = &arp_table[i].ipaddr;
*netif = arp_table[i].netif; *netif = arp_table[i].netif;
*eth_ret = &arp_table[i].ethaddr; *eth_ret = &arp_table[i].ethaddr;
@ -765,7 +765,7 @@ etharp_output_to_arp_index(struct netif *netif, struct pbuf *q, u8_t arp_idx)
} }
} }
return ethernet_output(netif, q, (struct eth_addr*)(netif->hwaddr), &arp_table[arp_idx].ethaddr, ETHTYPE_IP); return ethernet_output(netif, q, (struct eth_addr *)(netif->hwaddr), &arp_table[arp_idx].ethaddr, ETHTYPE_IP);
} }
/** /**
@ -823,7 +823,7 @@ etharp_output(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr)
if (!ip4_addr_netcmp(ipaddr, netif_ip4_addr(netif), netif_ip4_netmask(netif)) && if (!ip4_addr_netcmp(ipaddr, netif_ip4_addr(netif), netif_ip4_netmask(netif)) &&
!ip4_addr_islinklocal(ipaddr)) { !ip4_addr_islinklocal(ipaddr)) {
#if LWIP_AUTOIP #if LWIP_AUTOIP
struct ip_hdr *iphdr = LWIP_ALIGNMENT_CAST(struct ip_hdr*, q->payload); struct ip_hdr *iphdr = LWIP_ALIGNMENT_CAST(struct ip_hdr *, q->payload);
/* According to RFC 3297, chapter 2.6.2 (Forwarding Rules), a packet with /* According to RFC 3297, chapter 2.6.2 (Forwarding Rules), a packet with
a link-local source address must always be "directly to its destination a link-local source address must always be "directly to its destination
on the same physical link. The host MUST NOT send the packet to any on the same physical link. The host MUST NOT send the packet to any
@ -891,7 +891,7 @@ etharp_output(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr)
/* continuation for multicast/broadcast destinations */ /* continuation for multicast/broadcast destinations */
/* obtain source Ethernet address of the given interface */ /* obtain source Ethernet address of the given interface */
/* send packet directly on the link */ /* send packet directly on the link */
return ethernet_output(netif, q, (struct eth_addr*)(netif->hwaddr), dest, ETHTYPE_IP); return ethernet_output(netif, q, (struct eth_addr *)(netif->hwaddr), dest, ETHTYPE_IP);
} }
/** /**
@ -930,7 +930,7 @@ etharp_output(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr)
err_t err_t
etharp_query(struct netif *netif, const ip4_addr_t *ipaddr, struct pbuf *q) etharp_query(struct netif *netif, const ip4_addr_t *ipaddr, struct pbuf *q)
{ {
struct eth_addr * srcaddr = (struct eth_addr *)netif->hwaddr; struct eth_addr *srcaddr = (struct eth_addr *)netif->hwaddr;
err_t result = ERR_MEM; err_t result = ERR_MEM;
int is_new_entry = 0; int is_new_entry = 0;
s8_t i_err; s8_t i_err;
@ -1151,7 +1151,7 @@ etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr,
/* If we are using Link-Local, all ARP packets that contain a Link-Local /* If we are using Link-Local, all ARP packets that contain a Link-Local
* 'sender IP address' MUST be sent using link-layer broadcast instead of * 'sender IP address' MUST be sent using link-layer broadcast instead of
* link-layer unicast. (See RFC3927 Section 2.5, last paragraph) */ * link-layer unicast. (See RFC3927 Section 2.5, last paragraph) */
if(ip4_addr_islinklocal(ipsrc_addr)) { if (ip4_addr_islinklocal(ipsrc_addr)) {
ethernet_output(netif, p, ethsrc_addr, &ethbroadcast, ETHTYPE_ARP); ethernet_output(netif, p, ethsrc_addr, &ethbroadcast, ETHTYPE_ARP);
} else } else
#endif /* LWIP_AUTOIP */ #endif /* LWIP_AUTOIP */
@ -1181,7 +1181,7 @@ etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr,
* any other err_t on failure * any other err_t on failure
*/ */
static err_t static err_t
etharp_request_dst(struct netif *netif, const ip4_addr_t *ipaddr, const struct eth_addr* hw_dst_addr) etharp_request_dst(struct netif *netif, const ip4_addr_t *ipaddr, const struct eth_addr *hw_dst_addr)
{ {
return etharp_raw(netif, (struct eth_addr *)netif->hwaddr, hw_dst_addr, return etharp_raw(netif, (struct eth_addr *)netif->hwaddr, hw_dst_addr,
(struct eth_addr *)netif->hwaddr, netif_ip4_addr(netif), &ethzero, (struct eth_addr *)netif->hwaddr, netif_ip4_addr(netif), &ethzero,

View File

@ -86,7 +86,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
struct icmp_echo_hdr *iecho; struct icmp_echo_hdr *iecho;
const struct ip_hdr *iphdr_in; const struct ip_hdr *iphdr_in;
u16_t hlen; u16_t hlen;
const ip4_addr_t* src; const ip4_addr_t *src;
ICMP_STATS_INC(icmp.recv); ICMP_STATS_INC(icmp.recv);
MIB2_STATS_INC(mib2.icmpinmsgs); MIB2_STATS_INC(mib2.icmpinmsgs);
@ -97,14 +97,14 @@ icmp_input(struct pbuf *p, struct netif *inp)
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: short IP header (%"S16_F" bytes) received\n", hlen)); LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: short IP header (%"S16_F" bytes) received\n", hlen));
goto lenerr; goto lenerr;
} }
if (p->len < sizeof(u16_t)*2) { if (p->len < sizeof(u16_t) * 2) {
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: short ICMP (%"U16_F" bytes) received\n", p->tot_len)); LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: short ICMP (%"U16_F" bytes) received\n", p->tot_len));
goto lenerr; goto lenerr;
} }
type = *((u8_t *)p->payload); type = *((u8_t *)p->payload);
#ifdef LWIP_DEBUG #ifdef LWIP_DEBUG
code = *(((u8_t *)p->payload)+1); code = *(((u8_t *)p->payload) + 1);
/* if debug is enabled but debug statement below is somehow disabled: */ /* if debug is enabled but debug statement below is somehow disabled: */
LWIP_UNUSED_ARG(code); LWIP_UNUSED_ARG(code);
#endif /* LWIP_DEBUG */ #endif /* LWIP_DEBUG */
@ -209,7 +209,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
LWIP_DEBUGF(ICMP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("Can't move over header in packet")); LWIP_DEBUGF(ICMP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("Can't move over header in packet"));
} else { } else {
err_t ret; err_t ret;
struct ip_hdr *iphdr = (struct ip_hdr*)p->payload; struct ip_hdr *iphdr = (struct ip_hdr *)p->payload;
ip4_addr_copy(iphdr->src, *src); ip4_addr_copy(iphdr->src, *src);
ip4_addr_copy(iphdr->dest, *ip4_current_src_addr()); ip4_addr_copy(iphdr->dest, *ip4_current_src_addr());
ICMPH_TYPE_SET(iecho, ICMP_ER); ICMPH_TYPE_SET(iecho, ICMP_ER);

View File

@ -97,7 +97,7 @@ Steve Reynolds
#include "string.h" #include "string.h"
static struct igmp_group *igmp_lookup_group(struct netif *ifp, const ip4_addr_t *addr); static struct igmp_group *igmp_lookup_group(struct netif *ifp, const ip4_addr_t *addr);
static err_t igmp_remove_group(struct netif* netif, struct igmp_group *group); static err_t igmp_remove_group(struct netif *netif, struct igmp_group *group);
static void igmp_timeout(struct netif *netif, struct igmp_group *group); static void igmp_timeout(struct netif *netif, struct igmp_group *group);
static void igmp_start_timer(struct igmp_group *group, u8_t max_time); static void igmp_start_timer(struct igmp_group *group, u8_t max_time);
static void igmp_delaying_member(struct igmp_group *group, u8_t maxresp); static void igmp_delaying_member(struct igmp_group *group, u8_t maxresp);
@ -127,9 +127,9 @@ igmp_init(void)
err_t err_t
igmp_start(struct netif *netif) igmp_start(struct netif *netif)
{ {
struct igmp_group* group; struct igmp_group *group;
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_start: starting IGMP processing on if %p\n", (void*)netif)); LWIP_DEBUGF(IGMP_DEBUG, ("igmp_start: starting IGMP processing on if %p\n", (void *)netif));
group = igmp_lookup_group(netif, &allsystems); group = igmp_lookup_group(netif, &allsystems);
@ -141,7 +141,7 @@ igmp_start(struct netif *netif)
if (netif->igmp_mac_filter != NULL) { if (netif->igmp_mac_filter != NULL) {
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_start: igmp_mac_filter(ADD ")); LWIP_DEBUGF(IGMP_DEBUG, ("igmp_start: igmp_mac_filter(ADD "));
ip4_addr_debug_print_val(IGMP_DEBUG, allsystems); ip4_addr_debug_print_val(IGMP_DEBUG, allsystems);
LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", (void*)netif)); LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", (void *)netif));
netif->igmp_mac_filter(netif, &allsystems, NETIF_ADD_MAC_FILTER); netif->igmp_mac_filter(netif, &allsystems, NETIF_ADD_MAC_FILTER);
} }
@ -170,7 +170,7 @@ igmp_stop(struct netif *netif)
if (netif->igmp_mac_filter != NULL) { if (netif->igmp_mac_filter != NULL) {
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_stop: igmp_mac_filter(DEL ")); LWIP_DEBUGF(IGMP_DEBUG, ("igmp_stop: igmp_mac_filter(DEL "));
ip4_addr_debug_print(IGMP_DEBUG, &group->group_address); ip4_addr_debug_print(IGMP_DEBUG, &group->group_address);
LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", (void*)netif)); LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", (void *)netif));
netif->igmp_mac_filter(netif, &(group->group_address), NETIF_DEL_MAC_FILTER); netif->igmp_mac_filter(netif, &(group->group_address), NETIF_DEL_MAC_FILTER);
} }
@ -193,10 +193,10 @@ igmp_report_groups(struct netif *netif)
{ {
struct igmp_group *group = netif_igmp_data(netif); struct igmp_group *group = netif_igmp_data(netif);
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_report_groups: sending IGMP reports on if %p\n", (void*)netif)); LWIP_DEBUGF(IGMP_DEBUG, ("igmp_report_groups: sending IGMP reports on if %p\n", (void *)netif));
/* Skip the first group in the list, it is always the allsystems group added in igmp_start() */ /* Skip the first group in the list, it is always the allsystems group added in igmp_start() */
if(group != NULL) { if (group != NULL) {
group = group->next; group = group->next;
} }
@ -278,9 +278,9 @@ igmp_lookup_group(struct netif *ifp, const ip4_addr_t *addr)
} }
} }
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_lookup_group: %sallocated a new group with address ", (group?"":"impossible to "))); LWIP_DEBUGF(IGMP_DEBUG, ("igmp_lookup_group: %sallocated a new group with address ", (group ? "" : "impossible to ")));
ip4_addr_debug_print(IGMP_DEBUG, addr); ip4_addr_debug_print(IGMP_DEBUG, addr);
LWIP_DEBUGF(IGMP_DEBUG, (" on if %p\n", (void*)ifp)); LWIP_DEBUGF(IGMP_DEBUG, (" on if %p\n", (void *)ifp));
return group; return group;
} }
@ -292,7 +292,7 @@ igmp_lookup_group(struct netif *ifp, const ip4_addr_t *addr)
* @return ERR_OK if group was removed from the list, an err_t otherwise * @return ERR_OK if group was removed from the list, an err_t otherwise
*/ */
static err_t static err_t
igmp_remove_group(struct netif* netif, struct igmp_group *group) igmp_remove_group(struct netif *netif, struct igmp_group *group)
{ {
err_t err = ERR_OK; err_t err = ERR_OK;
struct igmp_group *tmp_group; struct igmp_group *tmp_group;
@ -322,9 +322,9 @@ igmp_remove_group(struct netif* netif, struct igmp_group *group)
void void
igmp_input(struct pbuf *p, struct netif *inp, const ip4_addr_t *dest) igmp_input(struct pbuf *p, struct netif *inp, const ip4_addr_t *dest)
{ {
struct igmp_msg* igmp; struct igmp_msg *igmp;
struct igmp_group* group; struct igmp_group *group;
struct igmp_group* groupref; struct igmp_group *groupref;
IGMP_STATS_INC(igmp.recv); IGMP_STATS_INC(igmp.recv);
@ -340,7 +340,7 @@ igmp_input(struct pbuf *p, struct netif *inp, const ip4_addr_t *dest)
ip4_addr_debug_print(IGMP_DEBUG, &(ip4_current_header()->src)); ip4_addr_debug_print(IGMP_DEBUG, &(ip4_current_header()->src));
LWIP_DEBUGF(IGMP_DEBUG, (" to address ")); LWIP_DEBUGF(IGMP_DEBUG, (" to address "));
ip4_addr_debug_print(IGMP_DEBUG, &(ip4_current_header()->dest)); ip4_addr_debug_print(IGMP_DEBUG, &(ip4_current_header()->dest));
LWIP_DEBUGF(IGMP_DEBUG, (" on if %p\n", (void*)inp)); LWIP_DEBUGF(IGMP_DEBUG, (" on if %p\n", (void *)inp));
/* Now calculate and check the checksum */ /* Now calculate and check the checksum */
igmp = (struct igmp_msg *)p->payload; igmp = (struct igmp_msg *)p->payload;
@ -382,7 +382,7 @@ igmp_input(struct pbuf *p, struct netif *inp, const ip4_addr_t *dest)
/* Do not send messages on the all systems group address! */ /* Do not send messages on the all systems group address! */
/* Skip the first group in the list, it is always the allsystems group added in igmp_start() */ /* Skip the first group in the list, it is always the allsystems group added in igmp_start() */
if(groupref != NULL) { if (groupref != NULL) {
groupref = groupref->next; groupref = groupref->next;
} }
@ -428,7 +428,7 @@ igmp_input(struct pbuf *p, struct netif *inp, const ip4_addr_t *dest)
break; break;
default: default:
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: unexpected msg %d in state %d on group %p on if %p\n", LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: unexpected msg %d in state %d on group %p on if %p\n",
igmp->igmp_msgtype, group->group_state, (void*)&group, (void*)inp)); igmp->igmp_msgtype, group->group_state, (void *)&group, (void *)inp));
IGMP_STATS_INC(igmp.proterr); IGMP_STATS_INC(igmp.proterr);
break; break;
} }
@ -505,10 +505,10 @@ igmp_joingroup_netif(struct netif *netif, const ip4_addr_t *groupaddr)
LWIP_DEBUGF(IGMP_DEBUG, ("\n")); LWIP_DEBUGF(IGMP_DEBUG, ("\n"));
/* If first use of the group, allow the group at the MAC level */ /* If first use of the group, allow the group at the MAC level */
if ((group->use==0) && (netif->igmp_mac_filter != NULL)) { if ((group->use == 0) && (netif->igmp_mac_filter != NULL)) {
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_joingroup_netif: igmp_mac_filter(ADD ")); LWIP_DEBUGF(IGMP_DEBUG, ("igmp_joingroup_netif: igmp_mac_filter(ADD "));
ip4_addr_debug_print(IGMP_DEBUG, groupaddr); ip4_addr_debug_print(IGMP_DEBUG, groupaddr);
LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", (void*)netif)); LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", (void *)netif));
netif->igmp_mac_filter(netif, groupaddr, NETIF_ADD_MAC_FILTER); netif->igmp_mac_filter(netif, groupaddr, NETIF_ADD_MAC_FILTER);
} }
@ -608,7 +608,7 @@ igmp_leavegroup_netif(struct netif *netif, const ip4_addr_t *groupaddr)
if (netif->igmp_mac_filter != NULL) { if (netif->igmp_mac_filter != NULL) {
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_leavegroup_netif: igmp_mac_filter(DEL ")); LWIP_DEBUGF(IGMP_DEBUG, ("igmp_leavegroup_netif: igmp_mac_filter(DEL "));
ip4_addr_debug_print(IGMP_DEBUG, groupaddr); ip4_addr_debug_print(IGMP_DEBUG, groupaddr);
LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", (void*)netif)); LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", (void *)netif));
netif->igmp_mac_filter(netif, groupaddr, NETIF_DEL_MAC_FILTER); netif->igmp_mac_filter(netif, groupaddr, NETIF_DEL_MAC_FILTER);
} }
@ -664,7 +664,7 @@ igmp_timeout(struct netif *netif, struct igmp_group *group)
(!(ip4_addr_cmp(&(group->group_address), &allsystems)))) { (!(ip4_addr_cmp(&(group->group_address), &allsystems)))) {
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_timeout: report membership for group with address ")); LWIP_DEBUGF(IGMP_DEBUG, ("igmp_timeout: report membership for group with address "));
ip4_addr_debug_print(IGMP_DEBUG, &(group->group_address)); ip4_addr_debug_print(IGMP_DEBUG, &(group->group_address));
LWIP_DEBUGF(IGMP_DEBUG, (" on if %p\n", (void*)netif)); LWIP_DEBUGF(IGMP_DEBUG, (" on if %p\n", (void *)netif));
group->group_state = IGMP_GROUP_IDLE_MEMBER; group->group_state = IGMP_GROUP_IDLE_MEMBER;
@ -749,10 +749,10 @@ igmp_ip_output_if(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest,
static void static void
igmp_send(struct netif *netif, struct igmp_group *group, u8_t type) igmp_send(struct netif *netif, struct igmp_group *group, u8_t type)
{ {
struct pbuf* p = NULL; struct pbuf *p = NULL;
struct igmp_msg* igmp = NULL; struct igmp_msg *igmp = NULL;
ip4_addr_t src = *IP4_ADDR_ANY4; ip4_addr_t src = *IP4_ADDR_ANY4;
ip4_addr_t* dest = NULL; ip4_addr_t *dest = NULL;
/* IP header + "router alert" option + IGMP header */ /* IP header + "router alert" option + IGMP header */
p = pbuf_alloc(PBUF_TRANSPORT, IGMP_MINLEN, PBUF_RAM); p = pbuf_alloc(PBUF_TRANSPORT, IGMP_MINLEN, PBUF_RAM);

View File

@ -108,13 +108,13 @@ static u16_t ip_id;
#if LWIP_MULTICAST_TX_OPTIONS #if LWIP_MULTICAST_TX_OPTIONS
/** The default netif used for multicast */ /** The default netif used for multicast */
static struct netif* ip4_default_multicast_netif; static struct netif *ip4_default_multicast_netif;
/** /**
* @ingroup ip4 * @ingroup ip4
* Set a default netif for IPv4 multicast. */ * Set a default netif for IPv4 multicast. */
void void
ip4_set_default_multicast_netif(struct netif* default_multicast_netif) ip4_set_default_multicast_netif(struct netif *default_multicast_netif)
{ {
ip4_default_multicast_netif = default_multicast_netif; ip4_default_multicast_netif = default_multicast_netif;
} }
@ -621,7 +621,7 @@ ip4_input(struct pbuf *p, struct netif *inp)
if ((IPH_OFFSET(iphdr) & PP_HTONS(IP_OFFMASK | IP_MF)) != 0) { if ((IPH_OFFSET(iphdr) & PP_HTONS(IP_OFFMASK | IP_MF)) != 0) {
#if IP_REASSEMBLY /* packet fragment reassembly code present? */ #if IP_REASSEMBLY /* packet fragment reassembly code present? */
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 ip4_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 ip4_reass()\n",
lwip_ntohs(IPH_ID(iphdr)), p->tot_len, lwip_ntohs(IPH_LEN(iphdr)), (u16_t)!!(IPH_OFFSET(iphdr) & PP_HTONS(IP_MF)), (u16_t)((lwip_ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK)*8))); lwip_ntohs(IPH_ID(iphdr)), p->tot_len, lwip_ntohs(IPH_LEN(iphdr)), (u16_t)!!(IPH_OFFSET(iphdr) & PP_HTONS(IP_MF)), (u16_t)((lwip_ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK) * 8)));
/* reassemble the packet*/ /* reassemble the packet*/
p = ip4_reass(p); p = ip4_reass(p);
/* packet not fully reassembled yet? */ /* packet not fully reassembled yet? */
@ -856,11 +856,11 @@ ip4_output_if_opt_src(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *d
MEMCPY(p->payload, ip_options, optlen); MEMCPY(p->payload, ip_options, optlen);
if (optlen < optlen_aligned) { if (optlen < optlen_aligned) {
/* zero the remaining bytes */ /* zero the remaining bytes */
memset(((char*)p->payload) + optlen, 0, (size_t)(optlen_aligned - optlen)); memset(((char *)p->payload) + optlen, 0, (size_t)(optlen_aligned - optlen));
} }
#if CHECKSUM_GEN_IP_INLINE #if CHECKSUM_GEN_IP_INLINE
for (i = 0; i < optlen_aligned/2; i++) { for (i = 0; i < optlen_aligned / 2; i++) {
chk_sum += ((u16_t*)p->payload)[i]; chk_sum += ((u16_t *)p->payload)[i];
} }
#endif /* CHECKSUM_GEN_IP_INLINE */ #endif /* CHECKSUM_GEN_IP_INLINE */
} }

View File

@ -273,7 +273,7 @@ ip4addr_aton(const char *cp, ip4_addr_t *addr)
* @return pointer to a global static (!) buffer that holds the ASCII * @return pointer to a global static (!) buffer that holds the ASCII
* representation of addr * representation of addr
*/ */
char* char *
ip4addr_ntoa(const ip4_addr_t *addr) ip4addr_ntoa(const ip4_addr_t *addr)
{ {
static char str[IP4ADDR_STRLEN_MAX]; static char str[IP4ADDR_STRLEN_MAX];
@ -289,7 +289,7 @@ ip4addr_ntoa(const ip4_addr_t *addr)
* @return either pointer to buf which now holds the ASCII * @return either pointer to buf which now holds the ASCII
* representation of addr or NULL if buf was too small * representation of addr or NULL if buf was too small
*/ */
char* char *
ip4addr_ntoa_r(const ip4_addr_t *addr, char *buf, int buflen) ip4addr_ntoa_r(const ip4_addr_t *addr, char *buf, int buflen)
{ {
u32_t s_addr; u32_t s_addr;

View File

@ -135,7 +135,7 @@ ip_reass_tmr(void)
* clean up the incomplete fragment assembly */ * clean up the incomplete fragment assembly */
if (r->timer > 0) { if (r->timer > 0) {
r->timer--; r->timer--;
LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass_tmr: timer dec %"U16_F"\n",(u16_t)r->timer)); LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass_tmr: timer dec %"U16_F"\n", (u16_t)r->timer));
prev = r; prev = r;
r = r->next; r = r->next;
} else { } else {
@ -274,10 +274,10 @@ ip_reass_remove_oldest_datagram(struct ip_hdr *fraghdr, int pbufs_needed)
* @param clen number of pbufs needed to enqueue (used for freeing other datagrams if not enough space) * @param clen number of pbufs needed to enqueue (used for freeing other datagrams if not enough space)
* @return A pointer to the queue location into which the fragment was enqueued * @return A pointer to the queue location into which the fragment was enqueued
*/ */
static struct ip_reassdata* static struct ip_reassdata *
ip_reass_enqueue_new_datagram(struct ip_hdr *fraghdr, int clen) ip_reass_enqueue_new_datagram(struct ip_hdr *fraghdr, int clen)
{ {
struct ip_reassdata* ipr; struct ip_reassdata *ipr;
#if ! IP_REASS_FREE_OLDEST #if ! IP_REASS_FREE_OLDEST
LWIP_UNUSED_ARG(clen); LWIP_UNUSED_ARG(clen);
#endif #endif
@ -293,7 +293,7 @@ ip_reass_enqueue_new_datagram(struct ip_hdr *fraghdr, int clen)
#endif /* IP_REASS_FREE_OLDEST */ #endif /* IP_REASS_FREE_OLDEST */
{ {
IPFRAG_STATS_INC(ip_frag.memerr); IPFRAG_STATS_INC(ip_frag.memerr);
LWIP_DEBUGF(IP_REASS_DEBUG,("Failed to alloc reassdata struct\n")); LWIP_DEBUGF(IP_REASS_DEBUG, ("Failed to alloc reassdata struct\n"));
return NULL; return NULL;
} }
} }
@ -343,7 +343,7 @@ ip_reass_dequeue_datagram(struct ip_reassdata *ipr, struct ip_reassdata *prev)
static int static int
ip_reass_chain_frag_into_datagram_and_validate(struct ip_reassdata *ipr, struct pbuf *new_p, int is_last) ip_reass_chain_frag_into_datagram_and_validate(struct ip_reassdata *ipr, struct pbuf *new_p, int is_last)
{ {
struct ip_reass_helper *iprh, *iprh_tmp, *iprh_prev=NULL; struct ip_reass_helper *iprh, *iprh_tmp, *iprh_prev = NULL;
struct pbuf *q; struct pbuf *q;
u16_t offset, len, clen; u16_t offset, len, clen;
u8_t hlen; u8_t hlen;
@ -351,7 +351,7 @@ ip_reass_chain_frag_into_datagram_and_validate(struct ip_reassdata *ipr, struct
int valid = 1; int valid = 1;
/* Extract length and fragment offset from current fragment */ /* Extract length and fragment offset from current fragment */
fraghdr = (struct ip_hdr*)new_p->payload; fraghdr = (struct ip_hdr *)new_p->payload;
len = lwip_ntohs(IPH_LEN(fraghdr)); len = lwip_ntohs(IPH_LEN(fraghdr));
hlen = IPH_HL_BYTES(fraghdr); hlen = IPH_HL_BYTES(fraghdr);
if (hlen > len) { if (hlen > len) {
@ -366,7 +366,7 @@ ip_reass_chain_frag_into_datagram_and_validate(struct ip_reassdata *ipr, struct
/* make sure the struct ip_reass_helper fits into the IP header */ /* make sure the struct ip_reass_helper fits into the IP header */
LWIP_ASSERT("sizeof(struct ip_reass_helper) <= IP_HLEN", LWIP_ASSERT("sizeof(struct ip_reass_helper) <= IP_HLEN",
sizeof(struct ip_reass_helper) <= IP_HLEN); sizeof(struct ip_reass_helper) <= IP_HLEN);
iprh = (struct ip_reass_helper*)new_p->payload; iprh = (struct ip_reass_helper *)new_p->payload;
iprh->next_pbuf = NULL; iprh->next_pbuf = NULL;
iprh->start = offset; iprh->start = offset;
iprh->end = (u16_t)(offset + len); iprh->end = (u16_t)(offset + len);
@ -378,7 +378,7 @@ ip_reass_chain_frag_into_datagram_and_validate(struct ip_reassdata *ipr, struct
/* Iterate through until we either get to the end of the list (append), /* Iterate through until we either get to the end of the list (append),
* or we find one with a larger offset (insert). */ * or we find one with a larger offset (insert). */
for (q = ipr->p; q != NULL;) { for (q = ipr->p; q != NULL;) {
iprh_tmp = (struct ip_reass_helper*)q->payload; iprh_tmp = (struct ip_reass_helper *)q->payload;
if (iprh->start < iprh_tmp->start) { if (iprh->start < iprh_tmp->start) {
/* the new pbuf should be inserted before this */ /* the new pbuf should be inserted before this */
iprh->next_pbuf = q; iprh->next_pbuf = q;
@ -458,14 +458,14 @@ ip_reass_chain_frag_into_datagram_and_validate(struct ip_reassdata *ipr, struct
if (valid) { if (valid) {
/* then check if the rest of the fragments is here */ /* then check if the rest of the fragments is here */
/* Check if the queue starts with the first datagram */ /* Check if the queue starts with the first datagram */
if ((ipr->p == NULL) || (((struct ip_reass_helper*)ipr->p->payload)->start != 0)) { if ((ipr->p == NULL) || (((struct ip_reass_helper *)ipr->p->payload)->start != 0)) {
valid = 0; valid = 0;
} else { } else {
/* and check that there are no holes after this datagram */ /* and check that there are no holes after this datagram */
iprh_prev = iprh; iprh_prev = iprh;
q = iprh->next_pbuf; q = iprh->next_pbuf;
while (q != NULL) { while (q != NULL) {
iprh = (struct ip_reass_helper*)q->payload; iprh = (struct ip_reass_helper *)q->payload;
if (iprh_prev->end != iprh->start) { if (iprh_prev->end != iprh->start) {
valid = 0; valid = 0;
break; break;
@ -478,7 +478,7 @@ ip_reass_chain_frag_into_datagram_and_validate(struct ip_reassdata *ipr, struct
if (valid) { if (valid) {
LWIP_ASSERT("sanity check", ipr->p != NULL); LWIP_ASSERT("sanity check", ipr->p != NULL);
LWIP_ASSERT("sanity check", LWIP_ASSERT("sanity check",
((struct ip_reass_helper*)ipr->p->payload) != iprh); ((struct ip_reass_helper *)ipr->p->payload) != iprh);
LWIP_ASSERT("validate_datagram:next_pbuf!=NULL", LWIP_ASSERT("validate_datagram:next_pbuf!=NULL",
iprh->next_pbuf == NULL); iprh->next_pbuf == NULL);
} }
@ -522,10 +522,10 @@ ip4_reass(struct pbuf *p)
IPFRAG_STATS_INC(ip_frag.recv); IPFRAG_STATS_INC(ip_frag.recv);
MIB2_STATS_INC(mib2.ipreasmreqds); MIB2_STATS_INC(mib2.ipreasmreqds);
fraghdr = (struct ip_hdr*)p->payload; fraghdr = (struct ip_hdr *)p->payload;
if ((IPH_HL(fraghdr) * 4) != IP_HLEN) { if ((IPH_HL(fraghdr) * 4) != IP_HLEN) {
LWIP_DEBUGF(IP_REASS_DEBUG,("ip4_reass: IP options currently not supported!\n")); LWIP_DEBUGF(IP_REASS_DEBUG, ("ip4_reass: IP options currently not supported!\n"));
IPFRAG_STATS_INC(ip_frag.err); IPFRAG_STATS_INC(ip_frag.err);
goto nullreturn; goto nullreturn;
} }
@ -548,7 +548,7 @@ ip4_reass(struct pbuf *p)
#endif /* IP_REASS_FREE_OLDEST */ #endif /* IP_REASS_FREE_OLDEST */
{ {
/* No datagram could be freed and still too many pbufs enqueued */ /* No datagram could be freed and still too many pbufs enqueued */
LWIP_DEBUGF(IP_REASS_DEBUG,("ip4_reass: Overflow condition: pbufct=%d, clen=%d, MAX=%d\n", LWIP_DEBUGF(IP_REASS_DEBUG, ("ip4_reass: Overflow condition: pbufct=%d, clen=%d, MAX=%d\n",
ip_reass_pbufcount, clen, IP_REASS_MAX_PBUFS)); ip_reass_pbufcount, clen, IP_REASS_MAX_PBUFS));
IPFRAG_STATS_INC(ip_frag.memerr); IPFRAG_STATS_INC(ip_frag.memerr);
/* @todo: send ICMP time exceeded here? */ /* @todo: send ICMP time exceeded here? */
@ -629,10 +629,10 @@ ip4_reass(struct pbuf *p)
u16_t datagram_len = (u16_t)(ipr->datagram_len + IP_HLEN); u16_t datagram_len = (u16_t)(ipr->datagram_len + IP_HLEN);
/* save the second pbuf before copying the header over the pointer */ /* save the second pbuf before copying the header over the pointer */
r = ((struct ip_reass_helper*)ipr->p->payload)->next_pbuf; r = ((struct ip_reass_helper *)ipr->p->payload)->next_pbuf;
/* copy the original ip header back to the first pbuf */ /* copy the original ip header back to the first pbuf */
fraghdr = (struct ip_hdr*)(ipr->p->payload); fraghdr = (struct ip_hdr *)(ipr->p->payload);
SMEMCPY(fraghdr, &ipr->iphdr, IP_HLEN); SMEMCPY(fraghdr, &ipr->iphdr, IP_HLEN);
IPH_LEN_SET(fraghdr, lwip_htons(datagram_len)); IPH_LEN_SET(fraghdr, lwip_htons(datagram_len));
IPH_OFFSET_SET(fraghdr, 0); IPH_OFFSET_SET(fraghdr, 0);
@ -648,7 +648,7 @@ ip4_reass(struct pbuf *p)
/* chain together the pbufs contained within the reass_data list. */ /* chain together the pbufs contained within the reass_data list. */
while (r != NULL) { while (r != NULL) {
iprh = (struct ip_reass_helper*)r->payload; iprh = (struct ip_reass_helper *)r->payload;
/* hide the ip header for every succeeding fragment */ /* hide the ip header for every succeeding fragment */
pbuf_remove_header(r, IP_HLEN); pbuf_remove_header(r, IP_HLEN);
@ -681,11 +681,11 @@ ip4_reass(struct pbuf *p)
return p; return p;
} }
/* the datagram is not (yet?) reassembled completely */ /* the datagram is not (yet?) reassembled completely */
LWIP_DEBUGF(IP_REASS_DEBUG,("ip_reass_pbufcount: %d out\n", ip_reass_pbufcount)); LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass_pbufcount: %d out\n", ip_reass_pbufcount));
return NULL; return NULL;
nullreturn: nullreturn:
LWIP_DEBUGF(IP_REASS_DEBUG,("ip4_reass: nullreturn\n")); LWIP_DEBUGF(IP_REASS_DEBUG, ("ip4_reass: nullreturn\n"));
IPFRAG_STATS_INC(ip_frag.drop); IPFRAG_STATS_INC(ip_frag.drop);
pbuf_free(p); pbuf_free(p);
return NULL; return NULL;
@ -695,15 +695,15 @@ nullreturn:
#if IP_FRAG #if IP_FRAG
#if !LWIP_NETIF_TX_SINGLE_PBUF #if !LWIP_NETIF_TX_SINGLE_PBUF
/** Allocate a new struct pbuf_custom_ref */ /** Allocate a new struct pbuf_custom_ref */
static struct pbuf_custom_ref* static struct pbuf_custom_ref *
ip_frag_alloc_pbuf_custom_ref(void) ip_frag_alloc_pbuf_custom_ref(void)
{ {
return (struct pbuf_custom_ref*)memp_malloc(MEMP_FRAG_PBUF); return (struct pbuf_custom_ref *)memp_malloc(MEMP_FRAG_PBUF);
} }
/** Free a struct pbuf_custom_ref */ /** Free a struct pbuf_custom_ref */
static void static void
ip_frag_free_pbuf_custom_ref(struct pbuf_custom_ref* p) ip_frag_free_pbuf_custom_ref(struct pbuf_custom_ref *p)
{ {
LWIP_ASSERT("p != NULL", p != NULL); LWIP_ASSERT("p != NULL", p != NULL);
memp_free(MEMP_FRAG_PBUF, p); memp_free(MEMP_FRAG_PBUF, p);
@ -714,9 +714,9 @@ ip_frag_free_pbuf_custom_ref(struct pbuf_custom_ref* p)
static void static void
ipfrag_free_pbuf_custom(struct pbuf *p) ipfrag_free_pbuf_custom(struct pbuf *p)
{ {
struct pbuf_custom_ref *pcr = (struct pbuf_custom_ref*)p; struct pbuf_custom_ref *pcr = (struct pbuf_custom_ref *)p;
LWIP_ASSERT("pcr != NULL", pcr != NULL); LWIP_ASSERT("pcr != NULL", pcr != NULL);
LWIP_ASSERT("pcr == p", (void*)pcr == (void*)p); LWIP_ASSERT("pcr == p", (void *)pcr == (void *)p);
if (pcr->original != NULL) { if (pcr->original != NULL) {
pbuf_free(pcr->original); pbuf_free(pcr->original);
} }
@ -785,7 +785,7 @@ ip4_frag(struct pbuf *p, struct netif *netif, const ip4_addr_t *dest)
} }
/* fill in the IP header */ /* fill in the IP header */
SMEMCPY(rambuf->payload, original_iphdr, IP_HLEN); SMEMCPY(rambuf->payload, original_iphdr, IP_HLEN);
iphdr = (struct ip_hdr*)rambuf->payload; iphdr = (struct ip_hdr *)rambuf->payload;
#else /* LWIP_NETIF_TX_SINGLE_PBUF */ #else /* LWIP_NETIF_TX_SINGLE_PBUF */
/* When not using a static buffer, create a chain of pbufs. /* When not using a static buffer, create a chain of pbufs.
* The first will be a PBUF_RAM holding the link and IP header. * The first will be a PBUF_RAM holding the link and IP header.
@ -820,7 +820,7 @@ ip4_frag(struct pbuf *p, struct netif *netif, const ip4_addr_t *dest)
} }
/* Mirror this pbuf, although we might not need all of it. */ /* Mirror this pbuf, although we might not need all of it. */
newpbuf = pbuf_alloced_custom(PBUF_RAW, newpbuflen, PBUF_REF, &pcr->pc, newpbuf = pbuf_alloced_custom(PBUF_RAW, newpbuflen, PBUF_REF, &pcr->pc,
(u8_t*)p->payload + poff, newpbuflen); (u8_t *)p->payload + poff, newpbuflen);
if (newpbuf == NULL) { if (newpbuf == NULL) {
ip_frag_free_pbuf_custom_ref(pcr); ip_frag_free_pbuf_custom_ref(pcr);
pbuf_free(rambuf); pbuf_free(rambuf);