Rewrote the tcpip_output() and tcpip_set_outputfunc() so that the latter is a proper function (which simplifies debugging) and so that tcpip_output() checks if the output callback function is NULL before calling it
This commit is contained in:
parent
7c86f70573
commit
4ec5167276
2 changed files with 43 additions and 13 deletions
|
@ -29,7 +29,7 @@
|
|||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
*
|
||||
* $Id: tcpip.c,v 1.18 2009/02/20 07:59:36 julienabeille Exp $
|
||||
* $Id: tcpip.c,v 1.19 2009/02/20 21:21:56 adamdunkels Exp $
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
|
@ -107,14 +107,42 @@ enum {
|
|||
|
||||
/* Called on IP packet output. */
|
||||
#if UIP_CONF_IPV6
|
||||
u8_t (* tcpip_output)(uip_lladdr_t *);
|
||||
#else
|
||||
static u8_t dummy_tcpip_output_function(void)
|
||||
|
||||
static u8_t (* outputfunc)(uip_lladdr_t *a);
|
||||
|
||||
u8_t
|
||||
tcpip_output(uip_lladdr_t *a)
|
||||
{
|
||||
UIP_LOG("dummy_tcpip_output_function: Use tcpip_set_outputfunc() to replace this dummy");
|
||||
if(outputfunc != NULL) {
|
||||
return outputfunc(a);
|
||||
}
|
||||
UIP_LOG("tcpip_output: Use tcpip_set_outputfunc() to set an output function");
|
||||
return 0;
|
||||
}
|
||||
u8_t (* tcpip_output)(void) = dummy_tcpip_output_function;
|
||||
|
||||
void
|
||||
tcpip_set_outputfunc(u8_t (*f)(uip_lladdr_t *))
|
||||
{
|
||||
outputfunc = f;
|
||||
}
|
||||
#else
|
||||
|
||||
static u8_t (* outputfunc)(void);
|
||||
u8_t
|
||||
tcpip_output(void)
|
||||
{
|
||||
if(outputfunc != NULL) {
|
||||
return outputfunc();
|
||||
}
|
||||
UIP_LOG("tcpip_output: Use tcpip_set_outputfunc() to set an output function");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
tcpip_set_outputfunc(u8_t (*f)(void))
|
||||
{
|
||||
outputfunc = f;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if UIP_CONF_IP_FORWARD
|
||||
|
@ -685,7 +713,7 @@ PROCESS_THREAD(tcpip_process, ev, data)
|
|||
s.p = PROCESS_CURRENT();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
tcpip_event = process_alloc_event();
|
||||
etimer_set(&periodic, CLOCK_SECOND/2);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue