Changed packet forwarding from a runtime option to a compiletime option. This avoids pulling in uip-fw.o if forwarding isn't required (saves > 1400 bytes on 6502 targets).

*** This change breaks all platforms calling tcpip_set_forwarding() ! These calls were intentionally not removed as they need to be replaced by setting the new compiletime option UIP_CONF_TCP_FORWARD - which should be done by the platform owners. ***
This commit is contained in:
oliverschmidt 2008-03-29 15:19:25 +00:00
parent 6deed3d9aa
commit 59145615b0
2 changed files with 25 additions and 34 deletions

View file

@ -30,7 +30,7 @@
* *
* Author: Adam Dunkels <adam@sics.se> * Author: Adam Dunkels <adam@sics.se>
* *
* $Id: tcpip.c,v 1.10 2007/12/08 23:06:02 oliverschmidt Exp $ * $Id: tcpip.c,v 1.11 2008/03/29 15:19:25 oliverschmidt Exp $
*/ */
#include "contiki-net.h" #include "contiki-net.h"
@ -66,8 +66,9 @@ enum {
u8_t (* tcpip_output)(void); /* Called on IP packet output. */ u8_t (* tcpip_output)(void); /* Called on IP packet output. */
unsigned char tcpip_do_forwarding; /* Forwarding enabled. */ #if UIP_CONF_TCP_FORWARD
unsigned char tcpip_is_forwarding; /* Forwarding right now? */ unsigned char tcpip_is_forwarding; /* Forwarding right now? */
#endif /* UIP_CONF_TCP_FORWARD */
PROCESS(tcpip_process, "TCP/IP stack"); PROCESS(tcpip_process, "TCP/IP stack");
@ -75,32 +76,34 @@ PROCESS(tcpip_process, "TCP/IP stack");
static void static void
packet_input(void) packet_input(void)
{ {
#if UIP_CONF_TCP_FORWARD
if(uip_len > 0) { if(uip_len > 0) {
if(tcpip_do_forwarding) { tcpip_is_forwarding = 1;
tcpip_is_forwarding = 1; if(uip_fw_forward() == UIP_FW_LOCAL) {
if(uip_fw_forward() == UIP_FW_LOCAL) {
tcpip_is_forwarding = 0;
uip_input();
if(uip_len > 0) {
#if UIP_CONF_TCP_SPLIT
uip_split_output();
#else
tcpip_output();
#endif
}
}
tcpip_is_forwarding = 0; tcpip_is_forwarding = 0;
} else {
uip_input(); uip_input();
if(uip_len > 0) { if(uip_len > 0) {
#if UIP_CONF_TCP_SPLIT #if UIP_CONF_TCP_SPLIT
uip_split_output(); uip_split_output();
#else #else /* UIP_CONF_TCP_SPLIT */
tcpip_output(); tcpip_output();
#endif #endif /* UIP_CONF_TCP_SPLIT */
} }
} }
tcpip_is_forwarding = 0;
} }
#else /* UIP_CONF_TCP_FORWARD */
if(uip_len > 0) {
uip_input();
if(uip_len > 0) {
#if UIP_CONF_TCP_SPLIT
uip_split_output();
#else /* UIP_CONF_TCP_SPLIT */
tcpip_output();
#endif /* UIP_CONF_TCP_SPLIT */
}
}
#endif /* UIP_CONF_TCP_FORWARD */
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#if UIP_ACTIVE_OPEN #if UIP_ACTIVE_OPEN
@ -284,14 +287,9 @@ eventhandler(process_event_t ev, process_data_t data)
} }
} }
} }
#if UIP_CONF_TCP_FORWARD
/* for(i = 0; i < UIP_UDP_CONNS; i++) {
uip_udp_periodic(i);
if(uip_len > 0) {
tcpip_output();
}
}*/
uip_fw_periodic(); uip_fw_periodic();
#endif /* UIP_CONF_TCP_FORWARD */
} }
} }
break; break;

View file

@ -60,7 +60,7 @@
* *
* Author: Adam Dunkels <adam@sics.se> * Author: Adam Dunkels <adam@sics.se>
* *
* $Id: tcpip.h,v 1.10 2007/05/20 21:29:40 oliverschmidt Exp $ * $Id: tcpip.h,v 1.11 2008/03/29 15:19:25 oliverschmidt Exp $
*/ */
#ifndef __TCPIP_H__ #ifndef __TCPIP_H__
#define __TCPIP_H__ #define __TCPIP_H__
@ -300,20 +300,13 @@ CCIF void tcpip_input(void);
* This function is called on IP packet output. * This function is called on IP packet output.
*/ */
extern u8_t (* tcpip_output)(void); extern u8_t (* tcpip_output)(void);
#define tcpip_set_outputfunc(outputfunc) tcpip_output = (outputfunc)
/*
* Is forwarding generally enabled?
*/
extern unsigned char tcpip_do_forwarding;
/* /*
* Are we at the moment forwarding the contents of uip_buf[]? * Are we at the moment forwarding the contents of uip_buf[]?
*/ */
extern unsigned char tcpip_is_forwarding; extern unsigned char tcpip_is_forwarding;
#define tcpip_set_outputfunc(outputfunc) tcpip_output = (outputfunc)
#define tcpip_set_forwarding(forwarding) tcpip_do_forwarding = (forwarding)
/** @} */ /** @} */
PROCESS_NAME(tcpip_process); PROCESS_NAME(tcpip_process);