addressed some of the suggestions on the PR - naming and netstack MAC

This commit is contained in:
Joakim Eriksson 2017-10-07 16:46:21 +02:00
parent 761d19dafc
commit 1143d6f5aa
9 changed files with 28 additions and 27 deletions

View File

@ -208,8 +208,9 @@ tun_init()
PRINTF("Initializing tun interface\n");
tunfd = tun_alloc(config_tundev);
if(tunfd == -1) err(1, "main: open");
if(tunfd == -1) {
err(1, "failed to allocate tun device ``%s''", config_tundev);
}
PRINTF("Tun open:%d\n", tunfd);

View File

@ -17,8 +17,6 @@ CFLAGS += -DWEBSERVER=2
endif
MAKE_NET = MAKE_NET_IPV6
# Custom MAC layer (border_router_mac_driver)
MAKE_MAC = MAKE_MAC_OTHER
include $(CONTIKI)/Makefile.include
connect-router: border-router.native

View File

@ -33,9 +33,15 @@
#undef UIP_FALLBACK_INTERFACE
#define UIP_FALLBACK_INTERFACE rpl_interface
/* use a non-default network driver */
#undef NETSTACK_CONF_NETWORK
#define NETSTACK_CONF_NETWORK sicslowpan_driver
/* use a non-default MAC driver */
#undef NETSTACK_CONF_MAC
#define NETSTACK_CONF_MAC border_router_mac_driver
#define SLIP_DEV_CONF_SEND_DELAY (CLOCK_SECOND / 32)
#undef WEBSERVER_CONF_CFS_CONNS
@ -46,8 +52,6 @@
#define CMD_CONF_OUTPUT border_router_cmd_output
/* Selected in netstack.h because our Makefile sets MAKE_MAC = MAKE_MAC_OTHER */
#define NETSTACK_CONF_OTHER_MAC border_router_mac_driver
/* used by wpcap (see /cpu/native/net/wpcap-drv.c) */
#define SELECT_CALLBACK 1

View File

@ -29,12 +29,12 @@
#include "contiki.h"
#include "lib/random.h"
#include "sys/ctimer.h"
#include "net/ip/uip.h"
#include "net/ipv6/uip.h"
#include "net/ipv6/uip-ds6.h"
#include "net/ip/uip-udp-packet.h"
#include "net/ipv6/uip-udp-packet.h"
#include "sys/ctimer.h"
#include "rpl.h"
#include "uipbuf.h"
#include "net/ipv6/uipbuf.h"
#include <stdio.h>
#include <string.h>
@ -47,7 +47,7 @@
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
#define DEBUG DEBUG_FULL
#include "net/ip/uip-debug.h"
#include "net/ipv6/uip-debug.h"
#ifndef PERIOD
#define PERIOD 60

View File

@ -121,19 +121,15 @@ uint8_t
tcpip_output(const uip_lladdr_t *a)
{
int ret;
if(NETSTACK_NETWORK.output != NULL) {
if(netstack_do_ip_callback(NETSTACK_IP_OUTPUT, (const linkaddr_t *)a) ==
NETSTACK_IP_PROCESS) {
ret = NETSTACK_NETWORK.output((const linkaddr_t *) a);
return ret;
} else {
/* Ok, ignore and drop... */
uip_clear_buf();
return 0;
}
if(netstack_process_ip_callback(NETSTACK_IP_OUTPUT, (const linkaddr_t *)a) ==
NETSTACK_IP_PROCESS) {
ret = NETSTACK_NETWORK.output((const linkaddr_t *) a);
return ret;
} else {
/* Ok, ignore and drop... */
uip_clear_buf();
return 0;
}
LOG_INFO("output: NETSTACK_NETWORK needs to be set to an output function");
return 0;
}
PROCESS(tcpip_process, "TCP/IP stack");
@ -435,7 +431,7 @@ eventhandler(process_event_t ev, process_data_t data)
void
tcpip_input(void)
{
if(netstack_do_ip_callback(NETSTACK_IP_INPUT, NULL) ==
if(netstack_process_ip_callback(NETSTACK_IP_INPUT, NULL) ==
NETSTACK_IP_PROCESS) {
process_post_synch(&tcpip_process, PACKET_INPUT, NULL);
} /* else - do nothing and drop */

View File

@ -45,7 +45,7 @@ LIST(ip_processor_list);
/* Note: localdest is only used for the output callback */
enum netstack_ip_action
netstack_do_ip_callback(uint8_t type, const linkaddr_t *localdest)
netstack_process_ip_callback(uint8_t type, const linkaddr_t *localdest)
{
enum netstack_ip_action action = NETSTACK_IP_PROCESS;
struct netstack_ip_packet_processor *p;

View File

@ -59,17 +59,19 @@
/* MAC layer configuration. The MAC layer is configured through the Makefile,
via the flag MAKE_MAC */
#ifdef NETSTACK_CONF_MAC
#define NETSTACK_MAC NETSTACK_CONF_MAC
#else
#if MAC_CONF_WITH_NULLMAC
#define NETSTACK_MAC nullmac_driver
#elif MAC_CONF_WITH_CSMA
#define NETSTACK_MAC csma_driver
#elif MAC_CONF_WITH_TSCH
#define NETSTACK_MAC tschmac_driver
#elif MAC_CONF_WITH_OTHER
#define NETSTACK_MAC NETSTACK_CONF_OTHER_MAC
#else
#error Unknown MAC configuration
#endif
#endif /* NETSTACK_CONF_MAC */
/* Radio driver configuration. Most often set by the platform. */
#ifdef NETSTACK_CONF_RADIO
@ -137,7 +139,7 @@ struct netstack_ip_packet_processor {
/* This function is intended for the IP stack to call whenever input/output
callback needs to be called */
enum netstack_ip_action netstack_do_ip_callback(uint8_t type, const linkaddr_t *localdest);
enum netstack_ip_action netstack_process_ip_callback(uint8_t type, const linkaddr_t *localdest);
void netstack_ip_packet_processor_add(struct netstack_ip_packet_processor *p);
void netstack_ip_packet_processor_remove(struct netstack_ip_packet_processor *p);