changed cooja platform default uip4 configuration to use uip_over_mesh with a slip gateway
This commit is contained in:
parent
3bd07ea55a
commit
c2354a5797
2 changed files with 46 additions and 17 deletions
|
@ -27,7 +27,7 @@
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id: contiki-conf.h,v 1.15 2010/03/23 13:34:00 fros4943 Exp $
|
* $Id: contiki-conf.h,v 1.16 2010/03/31 09:39:46 fros4943 Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@
|
||||||
#if WITH_UIP
|
#if WITH_UIP
|
||||||
|
|
||||||
/* Network setup for IPv4 */
|
/* Network setup for IPv4 */
|
||||||
#define NETSTACK_CONF_NETWORK uip_driver
|
#define NETSTACK_CONF_NETWORK rime_driver /* NOTE: uip_over_mesh. else: uip_driver */
|
||||||
#define NETSTACK_CONF_MAC nullmac_driver
|
#define NETSTACK_CONF_MAC nullmac_driver
|
||||||
#define NETSTACK_CONF_RDC nullrdc_driver
|
#define NETSTACK_CONF_RDC nullrdc_driver
|
||||||
#define NETSTACK_CONF_RADIO cooja_radio_driver
|
#define NETSTACK_CONF_RADIO cooja_radio_driver
|
||||||
|
@ -124,7 +124,7 @@ typedef unsigned long rtimer_clock_t;
|
||||||
#define UIP_CONF_MAX_CONNECTIONS 40
|
#define UIP_CONF_MAX_CONNECTIONS 40
|
||||||
#define UIP_CONF_BYTE_ORDER UIP_LITTLE_ENDIAN
|
#define UIP_CONF_BYTE_ORDER UIP_LITTLE_ENDIAN
|
||||||
#define UIP_CONF_TCP_SPLIT 0
|
#define UIP_CONF_TCP_SPLIT 0
|
||||||
#define UIP_CONF_IP_FORWARD 0
|
#define UIP_CONF_IP_FORWARD 1
|
||||||
#define UIP_CONF_LOGGING 0
|
#define UIP_CONF_LOGGING 0
|
||||||
#define UIP_CONF_UDP_CHECKSUMS 0
|
#define UIP_CONF_UDP_CHECKSUMS 0
|
||||||
#define UIP_CONF_BROADCAST 1
|
#define UIP_CONF_BROADCAST 1
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id: contiki-cooja-main.c,v 1.6 2010/03/29 11:52:08 fros4943 Exp $
|
* $Id: contiki-cooja-main.c,v 1.7 2010/03/31 09:39:46 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,15 +79,19 @@
|
||||||
#define WITH_UIP 0
|
#define WITH_UIP 0
|
||||||
#endif
|
#endif
|
||||||
#if WITH_UIP
|
#if WITH_UIP
|
||||||
|
#include "dev/rs232.h"
|
||||||
|
#include "dev/slip.h"
|
||||||
#include "net/uip.h"
|
#include "net/uip.h"
|
||||||
#include "net/uip-fw.h"
|
#include "net/uip-fw.h"
|
||||||
#include "net/uip-fw-drv.h"
|
#include "net/uip-fw-drv.h"
|
||||||
#include "net/uip-driver.h"
|
#include "net/uip-over-mesh.h"
|
||||||
#include "dev/slip.h"
|
static struct uip_fw_netif slipif =
|
||||||
static struct uip_fw_netif wsn_if =
|
{UIP_FW_NETIF(0,0,0,0, 255,255,255,255, slip_send)};
|
||||||
{UIP_FW_NETIF(172,16,0,0, 255,255,0,0, uip_driver_send)};
|
static struct uip_fw_netif meshif =
|
||||||
static struct uip_fw_netif slip_if =
|
{UIP_FW_NETIF(172,16,0,0, 255,255,0,0, uip_over_mesh_send)};
|
||||||
{UIP_FW_NETIF(0,0,0,0, 0,0,0,0, slip_send)};
|
|
||||||
|
#define UIP_OVER_MESH_CHANNEL 8
|
||||||
|
static uint8_t is_gateway;
|
||||||
#endif /* WITH_UIP */
|
#endif /* WITH_UIP */
|
||||||
|
|
||||||
#ifndef WITH_UIP6
|
#ifndef WITH_UIP6
|
||||||
|
@ -132,6 +136,22 @@ static struct cooja_mt_thread process_run_thread;
|
||||||
|
|
||||||
#define MIN(a, b) ( (a)<(b) ? (a) : (b) )
|
#define MIN(a, b) ( (a)<(b) ? (a) : (b) )
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
#if WITH_UIP
|
||||||
|
static void
|
||||||
|
set_gateway(void)
|
||||||
|
{
|
||||||
|
if(!is_gateway) {
|
||||||
|
printf("%d.%d: making myself the IP network gateway.\n\n",
|
||||||
|
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1]);
|
||||||
|
printf("IPv4 address of the gateway: %d.%d.%d.%d\n\n",
|
||||||
|
uip_ipaddr_to_quad(&uip_hostaddr));
|
||||||
|
uip_over_mesh_set_gateway(&rimeaddr_node_addr);
|
||||||
|
uip_over_mesh_make_announced_gateway();
|
||||||
|
is_gateway = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* WITH_UIP */
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void
|
static void
|
||||||
print_processes(struct process * const processes[])
|
print_processes(struct process * const processes[])
|
||||||
|
@ -200,21 +220,34 @@ process_run_thread_loop(void *data)
|
||||||
|
|
||||||
queuebuf_init();
|
queuebuf_init();
|
||||||
|
|
||||||
|
/* Initialize communication stack */
|
||||||
|
netstack_init();
|
||||||
|
printf("MAC %s RDC %s\n", NETSTACK_MAC.name, NETSTACK_RDC.name);
|
||||||
|
|
||||||
#if WITH_UIP
|
#if WITH_UIP
|
||||||
/* IPv4 CONFIGURATION */
|
/* IPv4 CONFIGURATION */
|
||||||
{
|
{
|
||||||
uip_ipaddr_t hostaddr, netmask;
|
uip_ipaddr_t hostaddr, netmask;
|
||||||
|
|
||||||
process_start(&tcpip_process, NULL);
|
process_start(&tcpip_process, NULL);
|
||||||
process_start(&uip_fw_process, NULL);
|
process_start(&uip_fw_process, NULL);
|
||||||
process_start(&slip_process, NULL);
|
process_start(&slip_process, NULL);
|
||||||
|
|
||||||
|
slip_set_input_callback(set_gateway);
|
||||||
|
|
||||||
uip_init();
|
uip_init();
|
||||||
uip_fw_init();
|
uip_fw_init();
|
||||||
uip_ipaddr(&hostaddr, 172, 16, rimeaddr_node_addr.u8[1], rimeaddr_node_addr.u8[0]);
|
uip_ipaddr(&hostaddr, 172,16,rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1]);
|
||||||
uip_ipaddr(&netmask, 255,255,0,0);
|
uip_ipaddr(&netmask, 255,255,0,0);
|
||||||
|
uip_ipaddr_copy(&meshif.ipaddr, &hostaddr);
|
||||||
|
|
||||||
uip_sethostaddr(&hostaddr);
|
uip_sethostaddr(&hostaddr);
|
||||||
uip_setnetmask(&netmask);
|
uip_setnetmask(&netmask);
|
||||||
uip_fw_register(&wsn_if);
|
uip_over_mesh_set_net(&hostaddr, &netmask);
|
||||||
uip_fw_default(&slip_if);
|
uip_over_mesh_set_gateway_netif(&slipif);
|
||||||
|
uip_fw_default(&meshif);
|
||||||
|
uip_over_mesh_init(UIP_OVER_MESH_CHANNEL);
|
||||||
|
|
||||||
rs232_set_input(slip_input_byte);
|
rs232_set_input(slip_input_byte);
|
||||||
printf("IPv4 address: %d.%d.%d.%d\n", uip_ipaddr_to_quad(&hostaddr));
|
printf("IPv4 address: %d.%d.%d.%d\n", uip_ipaddr_to_quad(&hostaddr));
|
||||||
}
|
}
|
||||||
|
@ -265,10 +298,6 @@ process_run_thread_loop(void *data)
|
||||||
}
|
}
|
||||||
#endif /* WITH_UIP6 */
|
#endif /* WITH_UIP6 */
|
||||||
|
|
||||||
/* Initialize communication stack */
|
|
||||||
netstack_init();
|
|
||||||
printf("MAC %s RDC %s\n", NETSTACK_MAC.name, NETSTACK_RDC.name);
|
|
||||||
|
|
||||||
/* Start serial process */
|
/* Start serial process */
|
||||||
serial_line_init();
|
serial_line_init();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue