Minor coding style changes, added assertion

This commit is contained in:
goldsimon 2010-01-10 13:32:36 +00:00
parent e4d19dc4a0
commit 86f2942c2a

View File

@ -97,6 +97,8 @@ netif_add(struct netif *netif, struct ip_addr *ipaddr, struct ip_addr *netmask,
{ {
static u8_t netifnum = 0; static u8_t netifnum = 0;
LWIP_ASSERT("No init function given", init != NULL);
/* reset new interface configuration state */ /* reset new interface configuration state */
netif->ip_addr.addr = 0; netif->ip_addr.addr = 0;
netif->netmask.addr = 0; netif->netmask.addr = 0;
@ -188,9 +190,12 @@ netif_set_addr(struct netif *netif, struct ip_addr *ipaddr, struct ip_addr *netm
* *
* @param netif the network interface to remove * @param netif the network interface to remove
*/ */
void netif_remove(struct netif * netif) void
netif_remove(struct netif *netif)
{ {
if ( netif == NULL ) return; if (netif == NULL) {
return;
}
#if LWIP_IGMP #if LWIP_IGMP
/* stop IGMP processing */ /* stop IGMP processing */
@ -204,25 +209,24 @@ void netif_remove(struct netif * netif)
/* is it the first netif? */ /* is it the first netif? */
if (netif_list == netif) { if (netif_list == netif) {
netif_list = netif->next; netif_list = netif->next;
snmp_dec_iflist(); } else {
}
else {
/* look for netif further down the list */ /* look for netif further down the list */
struct netif * tmpNetif; struct netif * tmpNetif;
for (tmpNetif = netif_list; tmpNetif != NULL; tmpNetif = tmpNetif->next) { for (tmpNetif = netif_list; tmpNetif != NULL; tmpNetif = tmpNetif->next) {
if (tmpNetif->next == netif) { if (tmpNetif->next == netif) {
tmpNetif->next = netif->next; tmpNetif->next = netif->next;
snmp_dec_iflist();
break; break;
} }
} }
if (tmpNetif == NULL) if (tmpNetif == NULL)
return; /* we didn't find any netif today */ return; /* we didn't find any netif today */
} }
snmp_dec_iflist();
/* this netif is default? */ /* this netif is default? */
if (netif_default == netif) if (netif_default == netif) {
/* reset default netif */ /* reset default netif */
netif_set_default(NULL); netif_set_default(NULL);
}
LWIP_DEBUGF( NETIF_DEBUG, ("netif_remove: removed netif\n") ); LWIP_DEBUGF( NETIF_DEBUG, ("netif_remove: removed netif\n") );
} }
@ -275,8 +279,7 @@ netif_set_ipaddr(struct netif *netif, struct ip_addr *ipaddr)
struct tcp_pcb_listen *lpcb; struct tcp_pcb_listen *lpcb;
/* address is actually being changed? */ /* address is actually being changed? */
if ((ip_addr_cmp(ipaddr, &(netif->ip_addr))) == 0) if ((ip_addr_cmp(ipaddr, &(netif->ip_addr))) == 0) {
{
/* extern struct tcp_pcb *tcp_active_pcbs; defined by tcp.h */ /* extern struct tcp_pcb *tcp_active_pcbs; defined by tcp.h */
LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_STATE, ("netif_set_ipaddr: netif address being changed\n")); LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_STATE, ("netif_set_ipaddr: netif address being changed\n"));
pcb = tcp_active_pcbs; pcb = tcp_active_pcbs;
@ -371,13 +374,10 @@ netif_set_netmask(struct netif *netif, struct ip_addr *netmask)
void void
netif_set_default(struct netif *netif) netif_set_default(struct netif *netif)
{ {
if (netif == NULL) if (netif == NULL) {
{
/* remove default route */ /* remove default route */
snmp_delete_iprteidx_tree(1, netif); snmp_delete_iprteidx_tree(1, netif);
} } else {
else
{
/* install default route */ /* install default route */
snmp_insert_iprteidx_tree(1, netif); snmp_insert_iprteidx_tree(1, netif);
} }
@ -433,8 +433,7 @@ void netif_set_up(struct netif *netif)
*/ */
void netif_set_down(struct netif *netif) void netif_set_down(struct netif *netif)
{ {
if ( netif->flags & NETIF_FLAG_UP ) if (netif->flags & NETIF_FLAG_UP) {
{
netif->flags &= ~NETIF_FLAG_UP; netif->flags &= ~NETIF_FLAG_UP;
#if LWIP_SNMP #if LWIP_SNMP
snmp_get_sysuptime(&netif->ts); snmp_get_sysuptime(&netif->ts);
@ -451,9 +450,10 @@ void netif_set_down(struct netif *netif)
*/ */
void netif_set_status_callback(struct netif *netif, void (* status_callback)(struct netif *netif )) void netif_set_status_callback(struct netif *netif, void (* status_callback)(struct netif *netif ))
{ {
if ( netif ) if (netif) {
netif->status_callback = status_callback; netif->status_callback = status_callback;
} }
}
#endif /* LWIP_NETIF_STATUS_CALLBACK */ #endif /* LWIP_NETIF_STATUS_CALLBACK */
#if LWIP_NETIF_LINK_CALLBACK #if LWIP_NETIF_LINK_CALLBACK