Merge branch 'master' into ppp-new

This commit is contained in:
Sylvain Rochet 2014-05-05 20:55:18 +02:00
commit d9e2edd1df
8 changed files with 77 additions and 13 deletions

View File

@ -314,7 +314,7 @@ lwip_getaddrinfo(const char *nodename, const char *servname,
total_size <= NETDB_ELEM_SIZE); total_size <= NETDB_ELEM_SIZE);
ai = (struct addrinfo *)memp_malloc(MEMP_NETDB); ai = (struct addrinfo *)memp_malloc(MEMP_NETDB);
if (ai == NULL) { if (ai == NULL) {
goto memerr; return EAI_MEMORY;
} }
memset(ai, 0, total_size); memset(ai, 0, total_size);
sa = (struct sockaddr_in*)((u8_t*)ai + sizeof(struct addrinfo)); sa = (struct sockaddr_in*)((u8_t*)ai + sizeof(struct addrinfo));
@ -343,11 +343,6 @@ lwip_getaddrinfo(const char *nodename, const char *servname,
*res = ai; *res = ai;
return 0; return 0;
memerr:
if (ai != NULL) {
memp_free(MEMP_NETDB, ai);
}
return EAI_MEMORY;
} }
#endif /* LWIP_DNS && LWIP_SOCKET */ #endif /* LWIP_DNS && LWIP_SOCKET */

View File

@ -704,6 +704,9 @@ igmp_start_timer(struct igmp_group *group, u8_t max_time)
} }
/* ensure the random value is > 0 */ /* ensure the random value is > 0 */
group->timer = (LWIP_RAND() % max_time); group->timer = (LWIP_RAND() % max_time);
if (group->timer == 0) {
group->timer = 1;
}
#else /* LWIP_RAND */ #else /* LWIP_RAND */
/* ATTENTION: use this only if absolutely necessary! */ /* ATTENTION: use this only if absolutely necessary! */
group->timer = max_time / 2; group->timer = max_time / 2;

View File

@ -496,7 +496,10 @@ mld6_delayed_report(struct mld_group *group, u16_t maxresp)
#ifdef LWIP_RAND #ifdef LWIP_RAND
/* Randomize maxresp. (if LWIP_RAND is supported) */ /* Randomize maxresp. (if LWIP_RAND is supported) */
maxresp = (LWIP_RAND() % (maxresp - 1)) + 1; maxresp = LWIP_RAND() % maxresp;
if (maxresp == 0) {
maxresp = 1;
}
#endif /* LWIP_RAND */ #endif /* LWIP_RAND */
/* Apply timer value if no report has been scheduled already. */ /* Apply timer value if no report has been scheduled already. */

View File

@ -455,24 +455,25 @@ nd6_input(struct pbuf *p, struct netif *inp)
if (prefix_opt->flags & ND6_PREFIX_FLAG_ON_LINK) { if (prefix_opt->flags & ND6_PREFIX_FLAG_ON_LINK) {
/* Add to on-link prefix list. */ /* Add to on-link prefix list. */
s8_t prefix;
/* Get a memory-aligned copy of the prefix. */ /* Get a memory-aligned copy of the prefix. */
ip6_addr_set(ip6_current_dest_addr(), &(prefix_opt->prefix)); ip6_addr_set(ip6_current_dest_addr(), &(prefix_opt->prefix));
/* find cache entry for this prefix. */ /* find cache entry for this prefix. */
i = nd6_get_onlink_prefix(ip6_current_dest_addr(), inp); prefix = nd6_get_onlink_prefix(ip6_current_dest_addr(), inp);
if (i < 0) { if (prefix < 0) {
/* Create a new cache entry. */ /* Create a new cache entry. */
i = nd6_new_onlink_prefix(ip6_current_dest_addr(), inp); prefix = nd6_new_onlink_prefix(ip6_current_dest_addr(), inp);
} }
if (i >= 0) { if (prefix >= 0) {
prefix_list[i].invalidation_timer = prefix_opt->valid_lifetime; prefix_list[prefix].invalidation_timer = prefix_opt->valid_lifetime;
#if LWIP_IPV6_AUTOCONFIG #if LWIP_IPV6_AUTOCONFIG
if (prefix_opt->flags & ND6_PREFIX_FLAG_AUTONOMOUS) { if (prefix_opt->flags & ND6_PREFIX_FLAG_AUTONOMOUS) {
/* Mark prefix as autonomous, so that address autoconfiguration can take place. /* Mark prefix as autonomous, so that address autoconfiguration can take place.
* Only OR flag, so that we don't over-write other flags (such as ADDRESS_DUPLICATE)*/ * Only OR flag, so that we don't over-write other flags (such as ADDRESS_DUPLICATE)*/
prefix_list[i].flags |= ND6_PREFIX_AUTOCONFIG_AUTONOMOUS; prefix_list[prefix].flags |= ND6_PREFIX_AUTOCONFIG_AUTONOMOUS;
} }
#endif /* LWIP_IPV6_AUTOCONFIG */ #endif /* LWIP_IPV6_AUTOCONFIG */
} }

View File

@ -2198,6 +2198,9 @@ system_get_value(struct obj_def *od, u16_t len, void *value)
*sint_ptr = sysservices; *sint_ptr = sysservices;
} }
break; break;
default:
LWIP_DEBUGF(SNMP_MIB_DEBUG,("system_get_value(): unknown id: %d\n", id));
break;
}; };
} }
@ -2233,6 +2236,9 @@ system_set_test(struct obj_def *od, u16_t len, void *value)
set_ok = 1; set_ok = 1;
} }
break; break;
default:
LWIP_DEBUGF(SNMP_MIB_DEBUG,("system_set_test(): unknown id: %d\n", id));
break;
}; };
return set_ok; return set_ok;
} }
@ -2259,6 +2265,9 @@ system_set_value(struct obj_def *od, u16_t len, void *value)
MEMCPY(syslocation_ptr, value, len); MEMCPY(syslocation_ptr, value, len);
*syslocation_len_ptr = (u8_t)len; *syslocation_len_ptr = (u8_t)len;
break; break;
default:
LWIP_DEBUGF(SNMP_MIB_DEBUG,("system_set_value(): unknown id: %d\n", id));
break;
}; };
} }
@ -2579,6 +2588,9 @@ ifentry_get_value(struct obj_def *od, u16_t len, void *value)
case 22: /* ifSpecific */ case 22: /* ifSpecific */
MEMCPY(value, ifspecific.id, len); MEMCPY(value, ifspecific.id, len);
break; break;
default:
LWIP_DEBUGF(SNMP_MIB_DEBUG,("ifentry_get_value(): unknown id: %d\n", id));
break;
}; };
} }
@ -2730,6 +2742,9 @@ atentry_get_value(struct obj_def *od, u16_t len, void *value)
*dst = *ipaddr_ret; *dst = *ipaddr_ret;
} }
break; break;
default:
LWIP_DEBUGF(SNMP_MIB_DEBUG,("atentry_get_value(): unknown id: %d\n", id));
break;
} }
} }
#endif /* LWIP_ARP */ #endif /* LWIP_ARP */
@ -2942,6 +2957,9 @@ ip_get_value(struct obj_def *od, u16_t len, void *value)
*uint_ptr = iproutingdiscards; *uint_ptr = iproutingdiscards;
} }
break; break;
default:
LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_get_value(): unknown id: %d\n", id));
break;
}; };
} }
@ -2985,6 +3003,9 @@ ip_set_test(struct obj_def *od, u16_t len, void *value)
set_ok = 1; set_ok = 1;
} }
break; break;
default:
LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_set_test(): unknown id: %d\n", id));
break;
}; };
return set_ok; return set_ok;
} }
@ -3102,6 +3123,9 @@ ip_addrentry_get_value(struct obj_def *od, u16_t len, void *value)
#endif #endif
} }
break; break;
default:
LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_addrentry_get_value(): unknown id: %d\n", id));
break;
} }
} }
} }
@ -3323,6 +3347,9 @@ ip_rteentry_get_value(struct obj_def *od, u16_t len, void *value)
case 13: /* ipRouteInfo */ case 13: /* ipRouteInfo */
MEMCPY(value, iprouteinfo.id, len); MEMCPY(value, iprouteinfo.id, len);
break; break;
default:
LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_rteentry_get_value(): unknown id: %d\n", id));
break;
} }
} }
} }
@ -3428,6 +3455,9 @@ ip_ntomentry_get_value(struct obj_def *od, u16_t len, void *value)
*sint_ptr = 3; *sint_ptr = 3;
} }
break; break;
default:
LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_ntomentry_get_value(): unknown id: %d\n", id));
break;
} }
} }
#endif /* LWIP_ARP */ #endif /* LWIP_ARP */
@ -3546,6 +3576,9 @@ icmp_get_value(struct obj_def *od, u16_t len, void *value)
case 26: /* icmpOutAddrMaskReps */ case 26: /* icmpOutAddrMaskReps */
*uint_ptr = icmpoutaddrmaskreps; *uint_ptr = icmpoutaddrmaskreps;
break; break;
default:
LWIP_DEBUGF(SNMP_MIB_DEBUG,("icmp_get_value(): unknown id: %d\n", id));
break;
} }
} }
@ -3683,6 +3716,9 @@ tcp_get_value(struct obj_def *od, u16_t len, void *value)
case 15: /* tcpOutRsts */ case 15: /* tcpOutRsts */
*uint_ptr = tcpoutrsts; *uint_ptr = tcpoutrsts;
break; break;
default:
LWIP_DEBUGF(SNMP_MIB_DEBUG,("tcp_get_value(): unknown id: %d\n", id));
break;
} }
} }
#ifdef THIS_SEEMS_UNUSED #ifdef THIS_SEEMS_UNUSED
@ -3803,6 +3839,9 @@ udp_get_value(struct obj_def *od, u16_t len, void *value)
case 4: /* udpOutDatagrams */ case 4: /* udpOutDatagrams */
*uint_ptr = udpoutdatagrams; *uint_ptr = udpoutdatagrams;
break; break;
default:
LWIP_DEBUGF(SNMP_MIB_DEBUG,("udp_get_value(): unknown id: %d\n", id));
break;
} }
} }
@ -3884,6 +3923,9 @@ udpentry_get_value(struct obj_def *od, u16_t len, void *value)
*sint_ptr = pcb->local_port; *sint_ptr = pcb->local_port;
} }
break; break;
default:
LWIP_DEBUGF(SNMP_MIB_DEBUG,("udpentry_get_value(): unknown id: %d\n", id));
break;
} }
} }
} }
@ -4051,6 +4093,9 @@ snmp_get_value(struct obj_def *od, u16_t len, void *value)
case 30: /* snmpEnableAuthenTraps */ case 30: /* snmpEnableAuthenTraps */
*uint_ptr = *snmpenableauthentraps_ptr; *uint_ptr = *snmpenableauthentraps_ptr;
break; break;
default:
LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_get_value(): unknown id: %d\n", id));
break;
}; };
} }

View File

@ -63,6 +63,11 @@ static struct nse node_stack[NODE_STACK_SIZE];
static void static void
push_node(struct nse* node) push_node(struct nse* node)
{ {
if (node->r_ptr == NULL) {
/* set uninitialized fields to known values */
node->r_id = 0;
node->r_nl = 0;
}
LWIP_ASSERT("node_stack_cnt < NODE_STACK_SIZE",node_stack_cnt < NODE_STACK_SIZE); LWIP_ASSERT("node_stack_cnt < NODE_STACK_SIZE",node_stack_cnt < NODE_STACK_SIZE);
LWIP_DEBUGF(SNMP_MIB_DEBUG,("push_node() node=%p id=%"S32_F"\n",(void*)(node->r_ptr),node->r_id)); LWIP_DEBUGF(SNMP_MIB_DEBUG,("push_node() node=%p id=%"S32_F"\n",(void*)(node->r_ptr),node->r_id));
if (node_stack_cnt < NODE_STACK_SIZE) if (node_stack_cnt < NODE_STACK_SIZE)

View File

@ -1067,6 +1067,9 @@ snmp_pdu_header_check(struct pbuf *p, u16_t ofs, u16_t pdu_len, u16_t *ofs_ret,
} }
switch (m_stat->error_status) switch (m_stat->error_status)
{ {
case SNMP_ES_NOERROR:
/* nothing to do */
break;
case SNMP_ES_TOOBIG: case SNMP_ES_TOOBIG:
snmp_inc_snmpintoobigs(); snmp_inc_snmpintoobigs();
break; break;
@ -1082,6 +1085,9 @@ snmp_pdu_header_check(struct pbuf *p, u16_t ofs, u16_t pdu_len, u16_t *ofs_ret,
case SNMP_ES_GENERROR: case SNMP_ES_GENERROR:
snmp_inc_snmpingenerrs(); snmp_inc_snmpingenerrs();
break; break;
default:
LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_pdu_header_check(): unknown error_status: %d\n", m_stat->error_status));
break;
} }
ofs += (1 + len_octets + len); ofs += (1 + len_octets + len);
snmp_asn1_dec_type(p, ofs, &type); snmp_asn1_dec_type(p, ofs, &type);

View File

@ -149,6 +149,9 @@ snmp_send_response(struct snmp_msg_pstat *m_stat)
switch (m_stat->error_status) switch (m_stat->error_status)
{ {
case SNMP_ES_NOERROR:
/* nothing to do */
break;
case SNMP_ES_TOOBIG: case SNMP_ES_TOOBIG:
snmp_inc_snmpouttoobigs(); snmp_inc_snmpouttoobigs();
break; break;
@ -161,6 +164,9 @@ snmp_send_response(struct snmp_msg_pstat *m_stat)
case SNMP_ES_GENERROR: case SNMP_ES_GENERROR:
snmp_inc_snmpoutgenerrs(); snmp_inc_snmpoutgenerrs();
break; break;
default:
LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_send_response(): unknown error_status: %d\n", m_stat->error_status));
break;
} }
snmp_inc_snmpoutgetresponses(); snmp_inc_snmpoutgetresponses();
snmp_inc_snmpoutpkts(); snmp_inc_snmpoutpkts();