Index: core/dhcp.c
===================================================================
RCS file: /sources/lwip/lwip/src/core/dhcp.c,v
retrieving revision 1.121
diff -u -r1.121 dhcp.c
--- core/dhcp.c	12 Feb 2010 16:42:02 -0000	1.121
+++ core/dhcp.c	13 Feb 2010 19:53:38 -0000
@@ -246,7 +246,7 @@
     LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_handle_offer(): server 0x%08"X32_F"\n",
       ip4_addr_get_u32(&dhcp->server_ip_addr)));
     /* remember offered address */
-    ip_addr_set(&dhcp->offered_ip_addr, &dhcp->msg_in->yiaddr);
+    ip_addr_copy(&dhcp->offered_ip_addr, &dhcp->msg_in->yiaddr);
     LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_handle_offer(): offer for 0x%08"X32_F"\n",
       ip4_addr_get_u32(&dhcp->offered_ip_addr)));
 
@@ -535,12 +535,12 @@
   }
 
   /* (y)our internet address */
-  ip_addr_set(&dhcp->offered_ip_addr, &dhcp->msg_in->yiaddr);
+  ip_addr_copy(&dhcp->offered_ip_addr, &dhcp->msg_in->yiaddr);
 
 #if LWIP_DHCP_BOOTP_FILE
   /* copy boot server address,
      boot file name copied in dhcp_parse_reply if not overloaded */
-  ip_addr_set(&dhcp->offered_si_addr, &dhcp->msg_in->siaddr);
+  ip_addr_copy(&dhcp->offered_si_addr, &dhcp->msg_in->siaddr);
 #endif /* LWIP_DHCP_BOOTP_FILE */
 
   /* subnet mask given? */
@@ -942,10 +942,10 @@
 
   if (dhcp->subnet_mask_given) {
     /* copy offered network mask */
-    ip_addr_set(&sn_mask, &dhcp->offered_sn_mask);
+    ip_addr_copy(&sn_mask, &dhcp->offered_sn_mask);
   } else {
     /* subnet mask not given, choose a safe subnet mask given the network class */
-    u8_t first_octet = (u8_t)ip4_addr1_16(&dhcp->offered_ip_addr);
+    u8_t first_octet = ip4_addr1(&dhcp->offered_ip_addr);
     if (first_octet <= 127) {
       ip4_addr_set_u32(&sn_mask, htonl(0xff000000));
     } else if (first_octet >= 192) {
@@ -955,7 +955,7 @@
     }
   }
 
-  ip_addr_set(&gw_addr, &dhcp->offered_gw_addr);
+  ip_addr_copy(&gw_addr, &dhcp->offered_gw_addr);
   /* gateway address not given? */
   if (ip_addr_isany(&gw_addr)) {
     /* copy network address */
@@ -1665,7 +1665,7 @@
   dhcp->msg_out->flags = 0;
   ip_addr_set_zero(&dhcp->msg_out->ciaddr);
   if (dhcp->state==DHCP_BOUND || dhcp->state==DHCP_RENEWING || dhcp->state==DHCP_REBINDING) {
-    ip_addr_set(&dhcp->msg_out->ciaddr, &netif->ip_addr);
+    ip_addr_copy(&dhcp->msg_out->ciaddr, &netif->ip_addr);
   }
   ip_addr_set_zero(&dhcp->msg_out->yiaddr);
   ip_addr_set_zero(&dhcp->msg_out->siaddr);
Index: core/dns.c
===================================================================
RCS file: /sources/lwip/lwip/src/core/dns.c,v
retrieving revision 1.37
diff -u -r1.37 dns.c
--- core/dns.c	13 Feb 2010 14:51:46 -0000	1.37
+++ core/dns.c	13 Feb 2010 19:53:59 -0000
@@ -443,7 +443,7 @@
   entry->name = (char*)entry + sizeof(struct local_hostlist_entry);
   MEMCPY((char*)entry->name, hostname, namelen);
   ((char*)entry->name)[namelen] = 0;
-  ip_addr_set(&entry->addr, addr);
+  ip_addr_copy(&entry->addr, addr);
   entry->next = local_hostlist_dynamic;
   local_hostlist_dynamic = entry;
   return ERR_OK;
Index: core/netif.c
===================================================================
RCS file: /sources/lwip/lwip/src/core/netif.c,v
retrieving revision 1.85
diff -u -r1.85 netif.c
--- core/netif.c	12 Feb 2010 16:50:23 -0000	1.85
+++ core/netif.c	13 Feb 2010 19:54:13 -0000
@@ -347,7 +347,7 @@
           (ip_addr_cmp(&(lpcb->local_ip), &(netif->ip_addr)))) {
         /* The PCB is listening to the old ipaddr and
          * is set to listen to the new one instead */
-        ip_addr_set(&(lpcb->local_ip), ipaddr);
+        ip_addr_copy(&(lpcb->local_ip), ipaddr);
       }
     }
   }
@@ -355,7 +355,7 @@
   snmp_delete_ipaddridx_tree(netif);
   snmp_delete_iprteidx_tree(0,netif);
   /* set new IP address to netif */
-  ip_addr_set(&(netif->ip_addr), ipaddr);
+  ip_addr_copy(&(netif->ip_addr), ipaddr);
   snmp_insert_ipaddridx_tree(netif);
   snmp_insert_iprteidx_tree(0,netif);
 
@@ -378,7 +378,7 @@
 void
 netif_set_gw(struct netif *netif, ip_addr_t *gw)
 {
-  ip_addr_set(&(netif->gw), gw);
+  ip_addr_set_safe(&(netif->gw), gw);
   LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("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_16(&netif->gw),
@@ -401,7 +401,7 @@
 {
   snmp_delete_iprteidx_tree(0, netif);
   /* set new netmask to netif */
-  ip_addr_set(&(netif->netmask), netmask);
+  ip_addr_copy(&(netif->netmask), netmask);
   snmp_insert_iprteidx_tree(0, netif);
   LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("netif: netmask of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
     netif->name[0], netif->name[1],
Index: core/raw.c
===================================================================
RCS file: /sources/lwip/lwip/src/core/raw.c,v
retrieving revision 1.28
diff -u -r1.28 raw.c
--- core/raw.c	4 Feb 2010 18:47:44 -0000	1.28
+++ core/raw.c	13 Feb 2010 19:54:22 -0000
@@ -101,7 +101,9 @@
         /* receive callback function available? */
         if (pcb->recv != NULL) {
           /* the receive callback function did not eat the packet? */
-          if (pcb->recv(pcb->recv_arg, pcb, p, &(iphdr->src)) != 0) {
+          ip_addr_t src;
+          ip_addr_copy(&src, &(iphdr->src));
+          if (pcb->recv(pcb->recv_arg, pcb, p, &src) != 0) {
             /* receive function ate the packet */
             p = NULL;
             eaten = 1;
@@ -141,7 +143,7 @@
 err_t
 raw_bind(struct raw_pcb *pcb, ip_addr_t *ipaddr)
 {
-  ip_addr_set(&pcb->local_ip, ipaddr);
+  ip_addr_set_safe(&pcb->local_ip, ipaddr);
   return ERR_OK;
 }
 
@@ -161,7 +163,7 @@
 err_t
 raw_connect(struct raw_pcb *pcb, ip_addr_t *ipaddr)
 {
-  ip_addr_set(&pcb->remote_ip, ipaddr);
+  ip_addr_set_safe(&pcb->remote_ip, ipaddr);
   return ERR_OK;
 }
 
Index: core/tcp.c
===================================================================
RCS file: /sources/lwip/lwip/src/core/tcp.c,v
retrieving revision 1.116
diff -u -r1.116 tcp.c
--- core/tcp.c	12 Feb 2010 16:32:31 -0000	1.116
+++ core/tcp.c	13 Feb 2010 19:54:45 -0000
@@ -232,8 +232,8 @@
   } else {
     seqno = pcb->snd_nxt;
     ackno = pcb->rcv_nxt;
-    ip_addr_set(&local_ip, &(pcb->local_ip));
-    ip_addr_set(&remote_ip, &(pcb->remote_ip));
+    ip_addr_copy(&local_ip, &(pcb->local_ip));
+    ip_addr_copy(&remote_ip, &(pcb->remote_ip));
     local_port = pcb->local_port;
     remote_port = pcb->remote_port;
 #if LWIP_CALLBACK_API
@@ -391,7 +391,7 @@
   lpcb->so_options |= SOF_ACCEPTCONN;
   lpcb->ttl = pcb->ttl;
   lpcb->tos = pcb->tos;
-  ip_addr_set(&lpcb->local_ip, &pcb->local_ip);
+  ip_addr_copy(&lpcb->local_ip, &pcb->local_ip);
   TCP_RMV(&tcp_bound_pcbs, pcb);
   memp_free(MEMP_TCP_PCB, pcb);
 #if LWIP_CALLBACK_API
Index: core/tcp_in.c
===================================================================
RCS file: /sources/lwip/lwip/src/core/tcp_in.c,v
retrieving revision 1.134
diff -u -r1.134 tcp_in.c
--- core/tcp_in.c	10 Feb 2010 07:58:01 -0000	1.134
+++ core/tcp_in.c	13 Feb 2010 19:55:25 -0000
@@ -131,11 +131,11 @@
 
 #if CHECKSUM_CHECK_TCP
   /* Verify TCP checksum. */
-  if (inet_chksum_pseudo(p, &iphdr->src, &iphdr->dest,
-      IP_PROTO_TCP, p->tot_len) != 0) {
+  if (inet_chksum_pseudo(p, ip4_addr_get_u32(&iphdr->src), ip4_addr_get_u32(&iphdr->dest),
+      htons(IP_PROTO_TCP), p->tot_len) != 0) {
       LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packet discarded due to failing checksum 0x%04"X16_F"\n",
-        inet_chksum_pseudo(p, &iphdr->src, &iphdr->dest,
-      IP_PROTO_TCP, p->tot_len)));
+        inet_chksum_pseudo(p, ip4_addr_get_u32(&iphdr->src), ip4_addr_get_u32(&iphdr->dest),
+      htons(IP_PROTO_TCP), p->tot_len)));
 #if TCP_DEBUG
     tcp_debug_print(tcphdr);
 #endif /* TCP_DEBUG */
@@ -372,11 +372,12 @@
        sender. */
     LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_input: no PCB match found, resetting.\n"));
     if (!(TCPH_FLAGS(tcphdr) & TCP_RST)) {
+      ip_addr_t local_ip, remote_ip;
+      ip_addr_copy(&local_ip, &(iphdr->dest));	/* can we use pcb addresses ? */
+      ip_addr_copy(&remote_ip, &(iphdr->src));
       TCP_STATS_INC(tcp.proterr);
       TCP_STATS_INC(tcp.drop);
-      tcp_rst(ackno, seqno + tcplen,
-        &(iphdr->dest), &(iphdr->src),
-        tcphdr->dest, tcphdr->src);
+      tcp_rst(ackno, seqno + tcplen, &local_ip, &remote_ip, tcphdr->dest, tcphdr->src);
     }
     pbuf_free(p);
   }
@@ -408,10 +409,11 @@
   if (flags & TCP_ACK) {
     /* For incoming segments with the ACK flag set, respond with a
        RST. */
+    ip_addr_t local_ip, remote_ip;
+    ip_addr_copy(&local_ip, &(iphdr->dest));	/* can we use pcb addresses ? */
+    ip_addr_copy(&remote_ip, &(iphdr->src));
     LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_listen_input: ACK in LISTEN, sending reset\n"));
-    tcp_rst(ackno + 1, seqno + tcplen,
-      &(iphdr->dest), &(iphdr->src),
-      tcphdr->dest, tcphdr->src);
+    tcp_rst(ackno + 1, seqno + tcplen, &local_ip, &remote_ip, tcphdr->dest, tcphdr->src);
   } else if (flags & TCP_SYN) {
     LWIP_DEBUGF(TCP_DEBUG, ("TCP connection request %"U16_F" -> %"U16_F".\n", tcphdr->src, tcphdr->dest));
 #if TCP_LISTEN_BACKLOG
@@ -433,9 +435,9 @@
     pcb->accepts_pending++;
 #endif /* TCP_LISTEN_BACKLOG */
     /* Set up the new PCB. */
-    ip_addr_set(&(npcb->local_ip), &(iphdr->dest));
+    ip_addr_copy(&(npcb->local_ip), &(iphdr->dest));
     npcb->local_port = pcb->local_port;
-    ip_addr_set(&(npcb->remote_ip), &(iphdr->src));
+    ip_addr_copy(&(npcb->remote_ip), &(iphdr->src));
     npcb->remote_port = tcphdr->src;
     npcb->state = SYN_RCVD;
     npcb->rcv_nxt = seqno + 1;
@@ -503,8 +505,10 @@
        should be sent in reply */
     if (TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt, pcb->rcv_nxt+pcb->rcv_wnd)) {
       /* If the SYN is in the window it is an error, send a reset */
-      tcp_rst(ackno, seqno + tcplen, &(iphdr->dest), &(iphdr->src),
-        tcphdr->dest, tcphdr->src);
+      ip_addr_t local_ip, remote_ip;
+      ip_addr_copy(&local_ip, &(iphdr->dest));	/* can we use pcb addresses ? */
+      ip_addr_copy(&remote_ip, &(iphdr->src));
+      tcp_rst(ackno, seqno + tcplen, &local_ip, &remote_ip, tcphdr->dest, tcphdr->src);
       return ERR_OK;
     }
   } else if (flags & TCP_FIN) {
@@ -635,8 +639,10 @@
     /* received ACK? possibly a half-open connection */
     else if (flags & TCP_ACK) {
       /* send a RST to bring the other side in a non-synchronized state. */
-      tcp_rst(ackno, seqno + tcplen, &(iphdr->dest), &(iphdr->src),
-        tcphdr->dest, tcphdr->src);
+      ip_addr_t local_ip, remote_ip;
+      ip_addr_copy(&local_ip, &(iphdr->dest));	/* can we use pcb addresses ? */
+      ip_addr_copy(&remote_ip, &(iphdr->src));
+      tcp_rst(ackno, seqno + tcplen, &local_ip, &remote_ip, tcphdr->dest, tcphdr->src);
     }
     break;
   case SYN_RCVD:
@@ -680,8 +686,10 @@
       /* incorrect ACK number */
       else {
         /* send RST */
-        tcp_rst(ackno, seqno + tcplen, &(iphdr->dest), &(iphdr->src),
-                tcphdr->dest, tcphdr->src);
+        ip_addr_t local_ip, remote_ip;
+        ip_addr_copy(&local_ip, &(iphdr->dest));	/* can we use pcb addresses ? */
+        ip_addr_copy(&remote_ip, &(iphdr->src));
+        tcp_rst(ackno, seqno + tcplen, &local_ip, &remote_ip, tcphdr->dest, tcphdr->src);
       }
     } else if ((flags & TCP_SYN) && (seqno == pcb->rcv_nxt - 1)) {
       /* Looks like another copy of the SYN - retransmit our SYN-ACK */
Index: core/tcp_out.c
===================================================================
RCS file: /sources/lwip/lwip/src/core/tcp_out.c,v
retrieving revision 1.96
diff -u -r1.96 tcp_out.c
--- core/tcp_out.c	4 Feb 2010 18:47:44 -0000	1.96
+++ core/tcp_out.c	13 Feb 2010 19:56:06 -0000
@@ -491,8 +491,8 @@
 #endif 
 
 #if CHECKSUM_GEN_TCP
-  tcphdr->chksum = inet_chksum_pseudo(p, &(pcb->local_ip), &(pcb->remote_ip),
-        IP_PROTO_TCP, p->tot_len);
+  tcphdr->chksum = inet_chksum_pseudo(p, ip4_addr_get_u32(&(pcb->local_ip)), ip4_addr_get_u32(&(pcb->remote_ip)),
+        htons(IP_PROTO_TCP), p->tot_len);
 #endif
 #if LWIP_NETIF_HWADDRHINT
   ip_output_hinted(p, &(pcb->local_ip), &(pcb->remote_ip), pcb->ttl, pcb->tos,
@@ -703,7 +703,7 @@
     if (netif == NULL) {
       return;
     }
-    ip_addr_set(&(pcb->local_ip), &(netif->ip_addr));
+    ip_addr_copy(&(pcb->local_ip), &(netif->ip_addr));
   }
 
   /* Set retransmission timer running if it is not currently enabled */
@@ -730,9 +730,9 @@
   seg->tcphdr->chksum = 0;
 #if CHECKSUM_GEN_TCP
   seg->tcphdr->chksum = inet_chksum_pseudo(seg->p,
-             &(pcb->local_ip),
-             &(pcb->remote_ip),
-             IP_PROTO_TCP, seg->p->tot_len);
+             ip4_addr_get_u32(&(pcb->local_ip)),
+             ip4_addr_get_u32(&(pcb->remote_ip)),
+             htons(IP_PROTO_TCP), seg->p->tot_len);
 #endif
   TCP_STATS_INC(tcp.xmit);
 
@@ -792,8 +792,8 @@
 
   tcphdr->chksum = 0;
 #if CHECKSUM_GEN_TCP
-  tcphdr->chksum = inet_chksum_pseudo(p, local_ip, remote_ip,
-              IP_PROTO_TCP, p->tot_len);
+  tcphdr->chksum = inet_chksum_pseudo(p, ip4_addr_get_u32(local_ip), ip4_addr_get_u32(remote_ip),
+              htons(IP_PROTO_TCP), p->tot_len);
 #endif
   TCP_STATS_INC(tcp.xmit);
   snmp_inc_tcpoutrsts();
@@ -953,8 +953,8 @@
   tcphdr = tcp_output_set_header(pcb, p, 0, htonl(pcb->snd_nxt - 1));
 
 #if CHECKSUM_GEN_TCP
-  tcphdr->chksum = inet_chksum_pseudo(p, &pcb->local_ip, &pcb->remote_ip,
-                                      IP_PROTO_TCP, p->tot_len);
+  tcphdr->chksum = inet_chksum_pseudo(p, ip4_addr_get_u32(&pcb->local_ip), ip4_addr_get_u32(&pcb->remote_ip),
+                                      htons(IP_PROTO_TCP), p->tot_len);
 #endif
   TCP_STATS_INC(tcp.xmit);
 
@@ -1031,8 +1031,8 @@
   }
 
 #if CHECKSUM_GEN_TCP
-  tcphdr->chksum = inet_chksum_pseudo(p, &pcb->local_ip, &pcb->remote_ip,
-                                      IP_PROTO_TCP, p->tot_len);
+  tcphdr->chksum = inet_chksum_pseudo(p, ip4_addr_get_u32(&pcb->local_ip), ip4_addr_get_u32(&pcb->remote_ip),
+                                      htons(IP_PROTO_TCP), p->tot_len);
 #endif
   TCP_STATS_INC(tcp.xmit);
 
Index: core/udp.c
===================================================================
RCS file: /sources/lwip/lwip/src/core/udp.c,v
retrieving revision 1.120
diff -u -r1.120 udp.c
--- core/udp.c	12 Feb 2010 16:30:58 -0000	1.120
+++ core/udp.c	13 Feb 2010 19:56:42 -0000
@@ -237,8 +237,8 @@
           goto end;
         }
       }
-      if (inet_chksum_pseudo_partial(p, &iphdr->src, &iphdr->dest,
-                             IP_PROTO_UDPLITE, p->tot_len, chklen) != 0) {
+      if (inet_chksum_pseudo_partial(p, ip4_addr_get_u32(&iphdr->src), ip4_addr_get_u32(&iphdr->dest),
+                             htons(IP_PROTO_UDPLITE), p->tot_len, chklen) != 0) {
        LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_LEVEL_SERIOUS,
                    ("udp_input: UDP Lite datagram discarded due to failing checksum\n"));
         UDP_STATS_INC(udp.chkerr);
@@ -253,8 +253,8 @@
     {
 #if CHECKSUM_CHECK_UDP
       if (udphdr->chksum != 0) {
-        if (inet_chksum_pseudo(p, &iphdr->src, &iphdr->dest,
-                               IP_PROTO_UDP, p->tot_len) != 0) {
+        if (inet_chksum_pseudo(p, ip4_addr_get_u32(&iphdr->src), ip4_addr_get_u32(&iphdr->dest),
+                               htons(IP_PROTO_UDP), p->tot_len) != 0) {
           LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_LEVEL_SERIOUS,
                       ("udp_input: UDP datagram discarded due to failing checksum\n"));
           UDP_STATS_INC(udp.chkerr);
@@ -279,7 +279,9 @@
       /* callback */
       if (pcb->recv != NULL) {
         /* now the recv function is responsible for freeing p */
-        pcb->recv(pcb->recv_arg, pcb, p, &iphdr->src, src);
+        ip_addr_t srcip;
+        ip_addr_copy(&srcip, &iphdr->src);
+        pcb->recv(pcb->recv_arg, pcb, p, &srcip, src);
       } else {
         /* no recv function registered? then we have to free the pbuf! */
         pbuf_free(p);
@@ -618,7 +620,7 @@
 #endif
   }
 
-  ip_addr_set(&pcb->local_ip, ipaddr);
+  ip_addr_set_safe(&pcb->local_ip, ipaddr);
 
   /* no port specified? */
   if (port == 0) {
@@ -689,7 +691,7 @@
     }
   }
 
-  ip_addr_set(&pcb->remote_ip, ipaddr);
+  ip_addr_set_safe(&pcb->remote_ip, ipaddr);
   pcb->remote_port = port;
   pcb->flags |= UDP_FLAGS_CONNECTED;
 /** TODO: this functionality belongs in upper layers */
Index: core/ipv4/icmp.c
===================================================================
RCS file: /sources/lwip/lwip/src/core/ipv4/icmp.c,v
retrieving revision 1.49
diff -u -r1.49 icmp.c
--- core/ipv4/icmp.c	4 Feb 2010 18:47:44 -0000	1.49
+++ core/ipv4/icmp.c	13 Feb 2010 19:57:38 -0000
@@ -184,9 +184,9 @@
     /* We generate an answer by switching the dest and src ip addresses,
      * setting the icmp type to ECHO_RESPONSE and updating the checksum. */
     iecho = (struct icmp_echo_hdr *)p->payload;
-    ip_addr_set(&tmpaddr, &iphdr->src);
-    ip_addr_set(&iphdr->src, &iphdr->dest);
-    ip_addr_set(&iphdr->dest, &tmpaddr);
+    ip_addr_copy(&tmpaddr, &iphdr->src);
+    ip_addr_copy(&iphdr->src, &iphdr->dest);
+    ip_addr_copy(&iphdr->dest, &tmpaddr);
     ICMPH_TYPE_SET(iecho, ICMP_ER);
     /* adjust the checksum */
     if (iecho->chksum >= htons(0xffff - (ICMP_ECHO << 8))) {
@@ -212,7 +212,9 @@
       LWIP_ASSERT("Can't move over header in packet", 0);
     } else {
       err_t ret;
-      ret = ip_output_if(p, &(iphdr->src), IP_HDRINCL,
+      ip_addr_t src;
+      ip_addr_copy(&src, &(iphdr->src));
+      ret = ip_output_if(p, &src, IP_HDRINCL,
                    ICMP_TTL, 0, IP_PROTO_ICMP, inp);
       if (ret != ERR_OK) {
         LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ip_output_if returned an error: %c.\n", ret));
@@ -287,6 +289,7 @@
   struct ip_hdr *iphdr;
   /* we can use the echo header here */
   struct icmp_echo_hdr *icmphdr;
+  ip_addr_t src;
 
   /* ICMP header + IP header + 8 bytes of data */
   q = pbuf_alloc(PBUF_IP, sizeof(struct icmp_echo_hdr) + IP_HLEN + ICMP_DEST_UNREACH_DATASIZE,
@@ -323,7 +326,8 @@
   snmp_inc_icmpoutmsgs();
   /* increase number of destination unreachable messages attempted to send */
   snmp_inc_icmpouttimeexcds();
-  ip_output(q, NULL, &(iphdr->src), ICMP_TTL, 0, IP_PROTO_ICMP);
+  ip_addr_copy(&src, &(iphdr->src));
+  ip_output(q, NULL, &src, ICMP_TTL, 0, IP_PROTO_ICMP);
   pbuf_free(q);
 }
 
Index: core/ipv4/igmp.c
===================================================================
RCS file: /sources/lwip/lwip/src/core/ipv4/igmp.c,v
retrieving revision 1.38
diff -u -r1.38 igmp.c
--- core/ipv4/igmp.c	8 Feb 2010 19:50:49 -0000	1.38
+++ core/ipv4/igmp.c	13 Feb 2010 19:58:09 -0000
@@ -329,7 +329,7 @@
   group = memp_malloc(MEMP_IGMP_GROUP);
   if (group != NULL) {
     group->netif              = ifp;
-    ip_addr_set(&(group->group_address), addr);
+    ip_addr_copy(&(group->group_address), addr);
     group->timer              = 0; /* Not running */
     group->group_state        = IGMP_GROUP_NON_MEMBER;
     group->last_reporter_flag = 0;
@@ -462,9 +462,11 @@
          LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: IGMP_MEMB_QUERY to a specific group "));
          ip_addr_debug_print(IGMP_DEBUG, &igmp->igmp_group_address);
          if (ip_addr_cmp(dest, &allsystems)) {
+           ip_addr_t groupaddr;
            LWIP_DEBUGF(IGMP_DEBUG, (" using \"ALL SYSTEMS\" address (224.0.0.1) [igmp_maxresp=%i]\n", (int)(igmp->igmp_maxresp)));
            /* we first need to re-lookfor the group since we used dest last time */
-           group = igmp_lookfor_group(inp, &igmp->igmp_group_address);
+           ip_addr_copy(&groupaddr, &igmp->igmp_group_address);
+           group = igmp_lookfor_group(inp, &groupaddr);
          } else {
            LWIP_DEBUGF(IGMP_DEBUG, (" with the group address as destination [igmp_maxresp=%i]\n", (int)(igmp->igmp_maxresp)));
          }
@@ -774,10 +776,10 @@
 static void
 igmp_send(struct igmp_group *group, u8_t type)
 {
-  struct pbuf*     p    = NULL;
-  struct igmp_msg* igmp = NULL;
-  ip_addr_t   src  = {0};
-  ip_addr_t*  dest = NULL;
+  struct pbuf*     p;
+  struct igmp_msg* igmp;
+  ip_addr_t   src;
+  ip_addr_t   dest;
 
   /* IP header + "router alert" option + IGMP header */
   p = pbuf_alloc(PBUF_TRANSPORT, IGMP_MINLEN, PBUF_RAM);
@@ -786,16 +788,16 @@
     igmp = p->payload;
     LWIP_ASSERT("igmp_send: check that first pbuf can hold struct igmp_msg",
                (p->len >= sizeof(struct igmp_msg)));
-    ip_addr_set(&src, &((group->netif)->ip_addr));
+    ip_addr_copy(&src, &((group->netif)->ip_addr));
      
     if (type == IGMP_V2_MEMB_REPORT) {
-      dest = &(group->group_address);
-      ip_addr_set(&(igmp->igmp_group_address), &(group->group_address));
+      ip_addr_copy(&dest, &(group->group_address));
+      ip_addr_copy(&(igmp->igmp_group_address), &(group->group_address));
       group->last_reporter_flag = 1; /* Remember we were the last to report */
     } else {
       if (type == IGMP_LEAVE_GROUP) {
-        dest = &allrouters;
-        ip_addr_set(&(igmp->igmp_group_address), &(group->group_address));
+        ip_addr_copy(&dest, &allrouters);
+        ip_addr_copy(&(igmp->igmp_group_address), &(group->group_address));
       }
     }
 
@@ -805,7 +807,7 @@
       igmp->igmp_checksum = 0;
       igmp->igmp_checksum = inet_chksum(igmp, IGMP_MINLEN);
 
-      igmp_ip_output_if(p, &src, dest, group->netif);
+      igmp_ip_output_if(p, &src, &dest, group->netif);
     }
 
     pbuf_free(p);
Index: core/ipv4/inet_chksum.c
===================================================================
RCS file: /sources/lwip/lwip/src/core/ipv4/inet_chksum.c,v
retrieving revision 1.14
diff -u -r1.14 inet_chksum.c
--- core/ipv4/inet_chksum.c	4 Feb 2010 18:47:44 -0000	1.14
+++ core/ipv4/inet_chksum.c	13 Feb 2010 19:58:30 -0000
@@ -275,13 +275,13 @@
  * @param p chain of pbufs over that a checksum should be calculated (ip data part)
  * @param src source ip address (used for checksum of pseudo header)
  * @param dst destination ip address (used for checksum of pseudo header)
- * @param proto ip protocol (used for checksum of pseudo header)
+ * @param proto ip protocol, in network byte order (used for checksum of pseudo header)
  * @param proto_len length of the ip data part (used for checksum of pseudo header)
  * @return checksum (as u16_t) to be saved directly in the protocol header
  */
 u16_t
 inet_chksum_pseudo(struct pbuf *p,
-       ip_addr_t *src, ip_addr_t *dest,
+       u32_t src, u32_t dest,
        u8_t proto, u16_t proto_len)
 {
   u32_t acc;
@@ -310,13 +310,11 @@
   if (swapped) {
     acc = SWAP_BYTES_IN_WORD(acc);
   }
-  addr = ip4_addr_get_u32(src);
-  acc += (addr & 0xffffUL);
-  acc += ((addr >> 16) & 0xffffUL);
-  addr = ip4_addr_get_u32(dest);
-  acc += (addr & 0xffffUL);
-  acc += ((addr >> 16) & 0xffffUL);
-  acc += (u32_t)htons((u16_t)proto);
+  acc += (src & 0xffffUL);
+  acc += ((src >> 16) & 0xffffUL);
+  acc += (dest & 0xffffUL);
+  acc += ((dest >> 16) & 0xffffUL);
+  acc += proto;
   acc += (u32_t)htons(proto_len);
 
   /* Fold 32-bit sum to 16 bits
@@ -335,7 +333,7 @@
  * @param p chain of pbufs over that a checksum should be calculated (ip data part)
  * @param src source ip address (used for checksum of pseudo header)
  * @param dst destination ip address (used for checksum of pseudo header)
- * @param proto ip protocol (used for checksum of pseudo header)
+ * @param proto ip protocol, in network byte order (used for checksum of pseudo header)
  * @param proto_len length of the ip data part (used for checksum of pseudo header)
  * @return checksum (as u16_t) to be saved directly in the protocol header
  */
@@ -343,7 +341,7 @@
 #if LWIP_UDPLITE
 u16_t
 inet_chksum_pseudo_partial(struct pbuf *p,
-       ip_addr_t *src, ip_addr_t *dest,
+       u32_t src, u32_t dest,
        u8_t proto, u16_t proto_len, u16_t chksum_len)
 {
   u32_t acc;
@@ -378,13 +376,11 @@
   if (swapped) {
     acc = SWAP_BYTES_IN_WORD(acc);
   }
-  addr = ip4_addr_get_u32(src);
-  acc += (addr & 0xffffUL);
-  acc += ((addr >> 16) & 0xffffUL);
-  addr = ip4_addr_get_u32(dest);
-  acc += (addr & 0xffffUL);
-  acc += ((addr >> 16) & 0xffffUL);
-  acc += (u32_t)htons((u16_t)proto);
+  acc += (src & 0xffffUL);
+  acc += ((src >> 16) & 0xffffUL);
+  acc += (dest & 0xffffUL);
+  acc += ((dest >> 16) & 0xffffUL);
+  acc += proto;
   acc += (u32_t)htons(proto_len);
 
   /* Fold 32-bit sum to 16 bits
Index: core/ipv4/ip.c
===================================================================
RCS file: /sources/lwip/lwip/src/core/ipv4/ip.c,v
retrieving revision 1.83
diff -u -r1.83 ip.c
--- core/ipv4/ip.c	4 Feb 2010 18:47:44 -0000	1.83
+++ core/ipv4/ip.c	13 Feb 2010 19:59:14 -0000
@@ -197,6 +197,9 @@
 #if LWIP_DHCP
   int check_ip_src=1;
 #endif /* LWIP_DHCP */
+#if LWIP_IGMP
+  	ip_addr_t dst;
+#endif /* LWIP_IGMP */
 
   IP_STATS_INC(ip.recv);
   snmp_inc_ipinreceives();
@@ -261,8 +264,9 @@
 
   /* match packet against an interface, i.e. is this packet for us? */
 #if LWIP_IGMP
-  if (ip_addr_ismulticast(&(iphdr->dest))) {
-    if ((inp->flags & NETIF_FLAG_IGMP) && (igmp_lookfor_group(inp, &(iphdr->dest)))) {
+  ip_addr_copy(&dst, &(iphdr->dest));
+  if (ip_addr_ismulticast(&dst)) {
+    if ((inp->flags & NETIF_FLAG_IGMP) && (igmp_lookfor_group(inp, &dst))) {
       netif = inp;
     } else {
       netif = NULL;
@@ -441,7 +445,7 @@
 #endif /* LWIP_ICMP */
 #if LWIP_IGMP
     case IP_PROTO_IGMP:
-      igmp_input(p,inp,&(iphdr->dest));
+      igmp_input(p, inp, &dst);
       break;
 #endif /* LWIP_IGMP */
     default:
@@ -516,6 +520,7 @@
 #endif /* IP_OPTIONS_SEND */
   struct ip_hdr *iphdr;
   static u16_t ip_id = 0;
+  ip_addr_t dst2;
 
   snmp_inc_ipoutrequests();
 
@@ -557,7 +562,7 @@
 
     IPH_TTL_PROTO_SET(iphdr, ttl, proto);
 
-    ip_addr_set(&(iphdr->dest), dest);
+    ip_addr_copy(&(iphdr->dest), dest);
 
     IPH_VHLTOS_SET(iphdr, 4, ip_hlen / 4, tos);
     IPH_LEN_SET(iphdr, htons(p->tot_len));
@@ -566,9 +571,9 @@
     ++ip_id;
 
     if (ip_addr_isany(src)) {
-      ip_addr_set(&(iphdr->src), &(netif->ip_addr));
+      ip_addr_copy(&(iphdr->src), &(netif->ip_addr));
     } else {
-      ip_addr_set(&(iphdr->src), src);
+      ip_addr_copy(&(iphdr->src), src);
     }
 
     IPH_CHKSUM_SET(iphdr, 0);
@@ -578,7 +583,8 @@
   } else {
     /* IP header already included in p */
     iphdr = (struct ip_hdr *)p->payload;
-    dest = &(iphdr->dest);
+    ip_addr_copy(&dst2, &(iphdr->dest));
+    dest = &dst2;
   }
 
   IP_STATS_INC(ip.xmit);
@@ -596,7 +602,7 @@
 #if IP_FRAG
   /* don't fragment if interface has mtu set to 0 [loopif] */
   if (netif->mtu && (p->tot_len > netif->mtu)) {
-    return ip_frag(p,netif,dest);
+    return ip_frag(p, netif, dest);
   }
 #endif
 
Index: core/ipv4/ip_addr.c
===================================================================
RCS file: /sources/lwip/lwip/src/core/ipv4/ip_addr.c,v
retrieving revision 1.30
diff -u -r1.30 ip_addr.c
--- core/ipv4/ip_addr.c	8 Feb 2010 20:14:21 -0000	1.30
+++ core/ipv4/ip_addr.c	13 Feb 2010 19:59:23 -0000
@@ -44,41 +44,6 @@
 const ip_addr_t ip_addr_any = { IPADDR_ANY };
 const ip_addr_t ip_addr_broadcast = { IPADDR_BROADCAST };
 
-/**
- * Determine if an address is a broadcast address on a network interface 
- * 
- * @param addr address to be checked
- * @param netif the network interface against which the address is checked
- * @return returns non-zero if the address is a broadcast address
- */
-u8_t ip_addr_isbroadcast(ip_addr_t *addr, struct netif *netif)
-{
-  u32_t addr2test;
-
-  addr2test = ip4_addr_get_u32(addr);
-  /* all ones (broadcast) or all zeroes (old skool broadcast) */
-  if ((~addr2test == IPADDR_ANY) ||
-      (addr2test == IPADDR_ANY))
-    return 1;
-  /* no broadcast support on this network interface? */
-  else if ((netif->flags & NETIF_FLAG_BROADCAST) == 0)
-    /* the given address cannot be a broadcast address
-     * nor can we check against any broadcast addresses */
-    return 0;
-  /* address matches network interface address exactly? => no broadcast */
-  else if (addr2test == ip4_addr_get_u32(&netif->ip_addr))
-    return 0;
-  /*  on the same (sub) network... */
-  else if (ip_addr_netcmp(addr, &(netif->ip_addr), &(netif->netmask))
-         /* ...and host identifier bits are all ones? =>... */
-          && ((addr2test & ~ip4_addr_get_u32(&netif->netmask)) ==
-           (IPADDR_BROADCAST & ~ip4_addr_get_u32(&netif->netmask))))
-    /* => network broadcast address */
-    return 1;
-  else
-    return 0;
-}
-
 /* Here for now until needed in other places in lwIP */
 #ifndef isprint
 #define in_range(c, lo, up)  ((u8_t)c >= lo && (u8_t)c <= up)
Index: core/snmp/msg_out.c
===================================================================
RCS file: /sources/lwip/lwip/src/core/snmp/msg_out.c,v
retrieving revision 1.18
diff -u -r1.18 msg_out.c
--- core/snmp/msg_out.c	4 Feb 2010 18:47:47 -0000	1.18
+++ core/snmp/msg_out.c	13 Feb 2010 19:57:06 -0000
@@ -230,10 +230,10 @@
     if ((td->enable != 0) && !ip_addr_isany(&td->dip))
     {
       /* network order trap destination */
-      ip_addr_set(&trap_msg.dip, &td->dip);
+      ip_addr_copy(&trap_msg.dip, &td->dip);
       /* lookup current source address for this dst */
       dst_if = ip_route(&td->dip);
-      ip_addr_set(&dst_ip, &dst_if->ip_addr);
+      ip_addr_copy(&dst_ip, &dst_if->ip_addr);
       /* @todo: what about IPv6? */
       trap_msg.sip_raw[0] = ip4_addr1(&dst_ip);
       trap_msg.sip_raw[1] = ip4_addr2(&dst_ip);
Index: include/ipv4/lwip/inet_chksum.h
===================================================================
RCS file: /sources/lwip/lwip/src/include/ipv4/lwip/inet_chksum.h,v
retrieving revision 1.3
diff -u -r1.3 inet_chksum.h
--- include/ipv4/lwip/inet_chksum.h	4 Feb 2010 18:47:48 -0000	1.3
+++ include/ipv4/lwip/inet_chksum.h	13 Feb 2010 20:00:38 -0000
@@ -44,11 +44,11 @@
 u16_t inet_chksum(void *dataptr, u16_t len);
 u16_t inet_chksum_pbuf(struct pbuf *p);
 u16_t inet_chksum_pseudo(struct pbuf *p,
-       ip_addr_t *src, ip_addr_t *dest,
+       u32_t src, u32_t dest,
        u8_t proto, u16_t proto_len);
 #if LWIP_UDPLITE
 u16_t inet_chksum_pseudo_partial(struct pbuf *p,
-       ip_addr_t *src, ip_addr_t *dest,
+       u32_t src, u32_t dest,
        u8_t proto, u16_t proto_len, u16_t chksum_len);
 #endif
 
Index: include/ipv4/lwip/ip_addr.h
===================================================================
RCS file: /sources/lwip/lwip/src/include/ipv4/lwip/ip_addr.h,v
retrieving revision 1.47
diff -u -r1.47 ip_addr.h
--- include/ipv4/lwip/ip_addr.h	8 Feb 2010 20:14:21 -0000	1.47
+++ include/ipv4/lwip/ip_addr.h	13 Feb 2010 20:01:00 -0000
@@ -39,17 +39,9 @@
 extern "C" {
 #endif
 
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/bpstruct.h"
-#endif
-PACK_STRUCT_BEGIN
 struct _ip_addr {
-  PACK_STRUCT_FIELD(u32_t addr);
-} PACK_STRUCT_STRUCT;
-PACK_STRUCT_END
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/epstruct.h"
-#endif
+  u32_t addr;
+};
 
 typedef struct _ip_addr ip_addr_t;
 
@@ -123,16 +115,26 @@
 #define IP_LOOPBACKNET      127                 /* official! */
 
 
+#if BYTE_ORDER == BIG_ENDIAN
 #define IP4_ADDR(ipaddr, a,b,c,d) \
-        (ipaddr)->addr = htonl(((u32_t)((a) & 0xff) << 24) | \
-                               ((u32_t)((b) & 0xff) << 16) | \
-                               ((u32_t)((c) & 0xff) << 8) | \
-                                (u32_t)((d) & 0xff))
+        (ipaddr)->addr = ((u32_t)((a) & 0xff) << 24) | \
+                         ((u32_t)((b) & 0xff) << 16) | \
+                         ((u32_t)((c) & 0xff) << 8)  | \
+                          (u32_t)((d) & 0xff)
+#else
+#define IP4_ADDR(ipaddr, a,b,c,d) \
+        (ipaddr)->addr = ((u32_t)((d) & 0xff) << 24) | \
+                         ((u32_t)((c) & 0xff) << 16) | \
+                         ((u32_t)((b) & 0xff) << 8)  | \
+                          (u32_t)((a) & 0xff)
+#endif
 
+/** Copy adress */
+#define ip_addr_copy(dest, src) ((dest)->addr = (src)->addr)
 /** Safely copy one IP address to another (src may be NULL) */
-#define ip_addr_set(dest, src) ((dest)->addr = \
-                               ((src) == NULL ? 0:\
-                               (src)->addr))
+#define ip_addr_set_safe(dest, src) ((dest)->addr = \
+                                    ((src) == NULL ? 0:\
+                                    (src)->addr))
 /** Set complete address to zero */
 #define ip_addr_set_zero(ipaddr)      ((ipaddr)->addr = 0)
 /** Set address to IPADDR_ANY (no need for htonl()) */
@@ -166,30 +168,28 @@
                                               (mask)->addr))
 #define ip_addr_cmp(addr1, addr2) ((addr1)->addr == (addr2)->addr)
 
-#define ip_addr_isany(addr1) ((addr1) == NULL || (addr1)->addr == 0)
+#define ip_addr_isany(addr1) ((addr1) == NULL || (addr1)->addr == IPADDR_ANY)
 
-u8_t ip_addr_isbroadcast(ip_addr_t *, struct netif *);
+#define ip_addr_isbroadcast(addr1, netif) ((addr1)->addr == IPADDR_BROADCAST || \
+                                          ((netif->flags & NETIF_FLAG_BROADCAST) && \
+                                           (addr1)->addr == (netif->ip_addr.addr|(~netif->netmask.addr)) ) )
 
 #define ip_addr_ismulticast(addr1) (((addr1)->addr & ntohl(0xf0000000UL)) == ntohl(0xe0000000UL))
 
 #define ip_addr_islinklocal(addr1) (((addr1)->addr & ntohl(0xffff0000UL)) == ntohl(0xa9fe0000UL))
 
 #define ip_addr_debug_print(debug, ipaddr) \
-  LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F,              \
-                      ipaddr != NULL ?                                  \
-                      (u16_t)(ntohl((ipaddr)->addr) >> 24) & 0xff : 0,  \
-                      ipaddr != NULL ?                                  \
-                      (u16_t)(ntohl((ipaddr)->addr) >> 16) & 0xff : 0,  \
-                      ipaddr != NULL ?                                  \
-                      (u16_t)(ntohl((ipaddr)->addr) >> 8) & 0xff : 0,   \
-                      ipaddr != NULL ?                                  \
-                      (u16_t)ntohl((ipaddr)->addr) & 0xff : 0))
+  LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F,             \
+                      ipaddr != NULL ? ip4_addr1_16(ipaddr) : 0,       \
+                      ipaddr != NULL ? ip4_addr2_16(ipaddr) : 0,       \
+                      ipaddr != NULL ? ip4_addr3_16(ipaddr) : 0,       \
+                      ipaddr != NULL ? ip4_addr4_16(ipaddr) : 0))
 
 /* Get one byte from the 4-byte address */
-#define ip4_addr1(ipaddr) ((u8_t)(ntohl((ipaddr)->addr) >> 24) & 0xff)
-#define ip4_addr2(ipaddr) ((u8_t)(ntohl((ipaddr)->addr) >> 16) & 0xff)
-#define ip4_addr3(ipaddr) ((u8_t)(ntohl((ipaddr)->addr) >> 8) & 0xff)
-#define ip4_addr4(ipaddr) ((u8_t)(ntohl((ipaddr)->addr)) & 0xff)
+#define ip4_addr1(ipaddr) (((u8_t*)(ipaddr))[0])
+#define ip4_addr2(ipaddr) (((u8_t*)(ipaddr))[1])
+#define ip4_addr3(ipaddr) (((u8_t*)(ipaddr))[2])
+#define ip4_addr4(ipaddr) (((u8_t*)(ipaddr))[3])
 /* These are cast to u16_t, with the intent that they are often arguments
  * to printf using the U16_F format from cc.h. */
 #define ip4_addr1_16(ipaddr) ((u16_t)ip4_addr1(ipaddr))
Index: netif/etharp.c
===================================================================
RCS file: /sources/lwip/lwip/src/netif/etharp.c,v
retrieving revision 1.159
diff -u -r1.159 etharp.c
--- netif/etharp.c	9 Feb 2010 11:38:00 -0000	1.159
+++ netif/etharp.c	13 Feb 2010 20:00:07 -0000
@@ -407,7 +407,7 @@
   /* IP address given? */
   if (ipaddr != NULL) {
     /* set IP address */
-    ip_addr_set(&arp_table[i].ipaddr, ipaddr);
+    ip_addr_copy(&arp_table[i].ipaddr, ipaddr);
   }
   arp_table[i].ctime = 0;
 #if LWIP_NETIF_HWADDRHINT
@@ -585,6 +585,8 @@
 {
   struct eth_hdr *ethhdr;
   struct ip_hdr *iphdr;
+  ip_addr_t src;
+
   LWIP_ERROR("netif != NULL", (netif != NULL), return;);
   /* Only insert an entry if the source IP address of the
      incoming IP packet comes from a host on the local network. */
@@ -606,7 +608,8 @@
   /* update ARP table */
   /* @todo We could use ETHARP_TRY_HARD if we think we are going to talk
    * back soon (for example, if the destination IP address is ours. */
-  update_arp_entry(netif, &(iphdr->src), &(ethhdr->src), 0);
+  ip_addr_copy(&src, &(iphdr->src));
+  update_arp_entry(netif, &src, &(ethhdr->src), 0);
 }
 
 

