/[lwip]/lwip/src/core/netif.c
ViewVC logotype

Diff of /lwip/src/core/netif.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.17 by likewise, Tue Apr 8 12:19:02 2003 UTC revision 1.18 by likewise, Wed Apr 9 15:17:57 2003 UTC
# Line 42  Line 42 
42  #include "lwip/mem.h"  #include "lwip/mem.h"
43  #include "lwip/netif.h"  #include "lwip/netif.h"
44  #include "lwip/ip_addr.h"  #include "lwip/ip_addr.h"
45    #include "lwip/tcp.h"
46    
47    
48  struct netif *netif_list = NULL;  struct netif *netif_list = NULL;
# Line 179  netif_set_ipaddr(struct netif *netif, st Line 180  netif_set_ipaddr(struct netif *netif, st
180  {  {
181    /* TODO: Handling of obsolete pcbs */    /* TODO: Handling of obsolete pcbs */
182    /* See:  http://mail.gnu.org/archive/html/lwip-users/2003-03/msg00118.html */    /* See:  http://mail.gnu.org/archive/html/lwip-users/2003-03/msg00118.html */
183  #if 0  #if 1
184    struct tcp_pcb *pcb;    struct tcp_pcb *pcb;
185    struct tcp_pcb_listen *lpcb;    struct tcp_pcb_listen *lpcb;
186    
187    /* address has changed? */    /* address has changed? */
188    if ((ip_addr_cmp(&(pcb->local_ip), &(netif->ip_addr))) == 0)    if ((ip_addr_cmp(ipaddr, &(netif->ip_addr))) == 0)
189    {    {
190    pcb = tcp_active_pcbs;      extern struct tcp_pcb *tcp_active_pcbs;
191    while (pcb != NULL) {      DEBUGF(NETIF_DEBUG | 1, ("netif_set_ipaddr: netif address changed\n"));
192      if (ip_addr_cmp(&(pcb->local_ip), &(netif->ip_addr))) {      pcb = tcp_active_pcbs;
193        /* The PCB is connected using the old ipaddr and must be aborted */      while (pcb != NULL) {
194        struct tcp_pcb *next = pcb->next;        if (ip_addr_cmp(&(pcb->local_ip), &(netif->ip_addr))) {
195        tcp_abort(pcb);          /* The PCB is connected using the old ipaddr and must be aborted */
196        pcb = next;          struct tcp_pcb *next = pcb->next;
197      } else {          DEBUGF(NETIF_DEBUG | 1, ("netif_set_ipaddr: aborting pcb %p\n", pcb));
198        pcb=pcb->next;          tcp_abort(pcb);
199            pcb = next;
200          } else {
201            pcb = pcb->next;
202          }
203      }      }
204    }      for (lpcb = tcp_listen_pcbs; lpcb != NULL; lpcb = lpcb->next) {
205    for (lpcb = tcp_listen_pcbs; lpcb != NULL; lpcb = lpcb->next) {        if (ip_addr_cmp(&(lpcb->local_ip), &(netif->ip_addr))) {
206      if (ip_addr_cmp(&(lpcb->local_ip), &(netif->ip_addr))) {          /* The PCB is listening to the old ipaddr and
207        /* The PCB is listening to the old ipaddr and           * is set to listen to the  new one instead */
208         * is set to listen to the  new one instead */          ip_addr_set(&(lpcb->local_ip), ipaddr);
209        ip_addr_set(&(lpcb->local_ip), ipaddr);        }
210      }      }
211    }    }
   }  
212  #endif  #endif
   DEBUGF(NETIF_DEBUG | DBG_TRACE | DBG_STATE, ("netif: setting IP address of interface %c%c%u to %u.%u.%u.%u\n",  
     netif->name[0], netif->name[1], netif->num,  
     (u8_t)(ntohl(ipaddr->addr) >> 24 & 0xff),  
     (u8_t)(ntohl(ipaddr->addr) >> 16 & 0xff),  
     (u8_t)(ntohl(ipaddr->addr) >> 8 & 0xff),  
     (u8_t)(ntohl(ipaddr->addr) & 0xff)));  
213    ip_addr_set(&(netif->ip_addr), ipaddr);    ip_addr_set(&(netif->ip_addr), ipaddr);
214      DEBUGF(NETIF_DEBUG | DBG_TRACE | DBG_STATE, ("netif: new IP address of interface %c%c%u is %u.%u.%u.%u\n",
215        netif->name[0], netif->name[1], netif->num,
216        (u8_t)(ntohl(netif->ip_addr.addr) >> 24 & 0xff),
217        (u8_t)(ntohl(netif->ip_addr.addr) >> 16 & 0xff),
218        (u8_t)(ntohl(netif->ip_addr.addr) >> 8 & 0xff),
219        (u8_t)(ntohl(netif->ip_addr.addr) & 0xff)));
220  }  }
221  /*-----------------------------------------------------------------------------------*/  /*-----------------------------------------------------------------------------------*/
222  void  void

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.18

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26