Moving the avr-rss2 platform examples to the global examples
location as suggested by the maintainers.
This commit is contained in:
parent
39094e3c41
commit
3c19e870f1
47 changed files with 0 additions and 0 deletions
55
examples/avr-rss2/ipv6/rpl-border-router/Makefile
Normal file
55
examples/avr-rss2/ipv6/rpl-border-router/Makefile
Normal file
|
@ -0,0 +1,55 @@
|
|||
CONTIKI_PROJECT=border-router
|
||||
all: $(CONTIKI_PROJECT)
|
||||
|
||||
CONTIKI=../../../../..
|
||||
|
||||
#linker optimizations
|
||||
SMALL=1
|
||||
|
||||
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
|
||||
PROJECT_SOURCEFILES += eth-bridge.c
|
||||
#PROJECT_SOURCEFILES += enc28j60.c
|
||||
PROJECT_SOURCEFILES += enc28j60-ip64-driver.c
|
||||
|
||||
APPS += ping6
|
||||
|
||||
MODULES += dev/enc28j60 core/net/ip64
|
||||
|
||||
#Simple built-in webserver is the default.
|
||||
#Override with make WITH_WEBSERVER=0 for no webserver.
|
||||
#WITH_WEBSERVER=webserver-name will use /apps/webserver-name if it can be
|
||||
#found in the /apps, /platform/$(TARGET)/apps/, or current directory (in that order).
|
||||
# WITH_WEBSERVER=webserver for /apps/webserver
|
||||
# WITH_WEBSERVER=raven-webserver for /platform/avr-raven/apps/raven-webserver/
|
||||
#make clean before changing webservers!
|
||||
|
||||
#Note /apps/webserver contains a 2500 byte style sheet which is a severe test
|
||||
#of the slip connection. Large MSS together with low baud rates without flow
|
||||
#control will overrun the transmit buffer when the style sheet is requested.
|
||||
|
||||
WITH_WEBSERVER=1
|
||||
ifeq ($(WITH_WEBSERVER),1)
|
||||
CFLAGS += -DUIP_CONF_TCP=1
|
||||
CFLAGS += -DWEBSERVER=1
|
||||
PROJECT_SOURCEFILES += httpd-simple.c
|
||||
else ifneq ($(WITH_WEBSERVER), 0)
|
||||
APPS += $(WITH_WEBSERVER)
|
||||
CFLAGS += -DUIP_CONF_TCP=1
|
||||
CFLAGS += -DWEBSERVER=2
|
||||
endif
|
||||
|
||||
ifeq ($(PREFIX),)
|
||||
PREFIX = aaaa::1/64
|
||||
endif
|
||||
|
||||
CONTIKI_WITH_IPV6 = 1
|
||||
include $(CONTIKI)/Makefile.include
|
||||
|
||||
$(CONTIKI)/tools/tunslip6: $(CONTIKI)/tools/tunslip6.c
|
||||
(cd $(CONTIKI)/tools && $(MAKE) tunslip6)
|
||||
|
||||
connect-router: $(CONTIKI)/tools/tunslip6
|
||||
sudo $(CONTIKI)/tools/tunslip6 $(PREFIX)
|
||||
|
||||
connect-router-cooja: $(CONTIKI)/tools/tunslip6
|
||||
sudo $(CONTIKI)/tools/tunslip6 -a 127.0.0.1 $(PREFIX)
|
66
examples/avr-rss2/ipv6/rpl-border-router/README.ETHERNET.md
Normal file
66
examples/avr-rss2/ipv6/rpl-border-router/README.ETHERNET.md
Normal file
|
@ -0,0 +1,66 @@
|
|||
Document version: 2015-12-29
|
||||
|
||||
HOWTO connect the Microchip enc28j60 module
|
||||
===========================================
|
||||
|
||||
It's possible to to add Ethernet to most microcontrollers having a SPI inter-
|
||||
face. In the Atmel world the SPI pins are used for the ISP programming. Usually
|
||||
a 6-pin header. Named MOSI, MISO, SCK, CS (Chup Select), Vcc, GND
|
||||
|
||||
One popular Ethernet chip is Microchip ENC28J60. It been used for quite some
|
||||
time and is easy to program and are also supported by many platforms and
|
||||
projects. Contiki has files under:
|
||||
|
||||
Most focus fon AVR platforms. The SPI is used by Atmel ISP-progammings
|
||||
interface. In addition to those pins you to selects a pin for chip
|
||||
select (CS).
|
||||
|
||||
dev/enc28j60/
|
||||
The low-level SPI drives is platform or rather CPU-specific. The avr-rss2
|
||||
platform adds the low-level drivers for Atmel.
|
||||
|
||||
platform/avr-rss2/enc28j60_avr.[ch]
|
||||
This should be usable on most 8-bit avr platforms.
|
||||
|
||||
The power consumption might be a problem. The enc28j60 consumes 160mA at 3.3V
|
||||
when transmitting. The LDO (voltage reg. LP2950) on the mote can only handle
|
||||
100mA. So external power is needed. Below is a description of a prototype.
|
||||
|
||||
Used components:
|
||||
----------------
|
||||
Externel power supply 5V.
|
||||
Small breadboard
|
||||
DC-jack
|
||||
Voltage Reg. LCP1700 3.3V
|
||||
Capacitor 4.7uF
|
||||
enc28j60 (From Ebay)
|
||||
Pin-headers
|
||||
Cables 2x5 (enc28j60) 2x3 SPI (AtMega node)
|
||||
|
||||
Used colors:
|
||||
Black GND
|
||||
Red VCC 3.3V
|
||||
Yellow SCK
|
||||
Green MISO
|
||||
White MOSI
|
||||
Blue CS (Chip select)
|
||||
|
||||
SPI (Connector view)
|
||||
--------------------
|
||||
GREEN YELLOW NC
|
||||
RED WHITE BLACK
|
||||
|
||||
CS is connected to external temp sensor middle pin. Consequently the
|
||||
external temp sensor can not be used in this application.
|
||||
|
||||
Pictures
|
||||
--------
|
||||
![Module] ( http://www.radio-sensors.com/pictures/enc28j60.jpg)
|
||||
![Connector] (http://www.radio-sensors.com/pictures/enc28c60-cable.jpg)
|
||||
|
||||
|
||||
References
|
||||
-----------
|
||||
|
||||
|
||||
|
17
examples/avr-rss2/ipv6/rpl-border-router/README.md
Normal file
17
examples/avr-rss2/ipv6/rpl-border-router/README.md
Normal file
|
@ -0,0 +1,17 @@
|
|||
Document version: 2016-02-22
|
||||
|
||||
An ethernet-to-802.15.4 NAT/GW IP64
|
||||
===================================
|
||||
|
||||
This project is heavily based on the rpl-border-router in the example directory
|
||||
using the IP64 framework. This work is done Contiki/Thingsquare as the driver
|
||||
for enc28j60.
|
||||
|
||||
But rather than using slip as in the original example an ethernet interface
|
||||
the Microchip enc28j60 is used. The needed SPI-glue for AtMega's is added by
|
||||
this platform. (avr-rss2)
|
||||
|
||||
See the README.ETHERNET.md for ethernet module info.
|
||||
|
||||
|
||||
|
388
examples/avr-rss2/ipv6/rpl-border-router/border-router.c
Normal file
388
examples/avr-rss2/ipv6/rpl-border-router/border-router.c
Normal file
|
@ -0,0 +1,388 @@
|
|||
/*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
* border-router
|
||||
* \author
|
||||
* Niclas Finne <nfi@sics.se>
|
||||
* Joakim Eriksson <joakime@sics.se>
|
||||
* Nicolas Tsiftes <nvt@sics.se>
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
#include "contiki-lib.h"
|
||||
#include "contiki-net.h"
|
||||
#include "net/ip/uip.h"
|
||||
#include "net/ipv6/uip-ds6.h"
|
||||
#include "ip64.h"
|
||||
#include "net/rpl/rpl.h"
|
||||
#include "enc28j60.h"
|
||||
#include "enc28j60-ip64-driver.h"
|
||||
#include "net/netstack.h"
|
||||
#include "dev/button-sensor.h"
|
||||
#include "dev/slip.h"
|
||||
#include "dev/leds.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define DEBUG DEBUG_PRINT
|
||||
#include "net/ip/uip-debug.h"
|
||||
|
||||
static uip_ipaddr_t prefix;
|
||||
static uint8_t prefix_set;
|
||||
|
||||
PROCESS(border_router_process, "Border router process");
|
||||
|
||||
#if WEBSERVER==0
|
||||
/* No webserver */
|
||||
AUTOSTART_PROCESSES(&border_router_process);
|
||||
#elif WEBSERVER>1
|
||||
/* Use an external webserver application */
|
||||
#include "webserver-nogui.h"
|
||||
AUTOSTART_PROCESSES(&border_router_process,&webserver_nogui_process);
|
||||
#else
|
||||
/* Use simple webserver with only one page for minimum footprint.
|
||||
* Multiple connections can result in interleaved tcp segments since
|
||||
* a single static buffer is used for all segments.
|
||||
*/
|
||||
#include "httpd-simple.h"
|
||||
/* The internal webserver can provide additional information if
|
||||
* enough program flash is available.
|
||||
*/
|
||||
#define WEBSERVER_CONF_LOADTIME 1
|
||||
#define WEBSERVER_CONF_FILESTATS 1
|
||||
#define WEBSERVER_CONF_NEIGHBOR_STATUS 1
|
||||
/* Adding links requires a larger RAM buffer. To avoid static allocation
|
||||
* the stack can be used for formatting; however tcp retransmissions
|
||||
* and multiple connections can result in garbled segments.
|
||||
* TODO:use PSOCk_GENERATOR_SEND and tcp state storage to fix this.
|
||||
*/
|
||||
#define WEBSERVER_CONF_ROUTE_LINKS 1
|
||||
#if WEBSERVER_CONF_ROUTE_LINKS
|
||||
#define BUF_USES_STACK 1
|
||||
#endif
|
||||
|
||||
PROCESS(webserver_nogui_process, "Web server");
|
||||
PROCESS_THREAD(webserver_nogui_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
|
||||
httpd_init();
|
||||
|
||||
while(1) {
|
||||
PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event);
|
||||
httpd_appcall(data);
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
AUTOSTART_PROCESSES(&border_router_process,&webserver_nogui_process);
|
||||
|
||||
static const char *TOP = "<html><head><title>ContikiRPL</title></head><body>\n";
|
||||
static const char *BOTTOM = "</body></html>\n";
|
||||
#if BUF_USES_STACK
|
||||
static char *bufptr, *bufend;
|
||||
#define ADD(...) do { \
|
||||
bufptr += snprintf(bufptr, bufend - bufptr, __VA_ARGS__); \
|
||||
} while(0)
|
||||
#else
|
||||
static char buf[256];
|
||||
static int blen;
|
||||
#define ADD(...) do { \
|
||||
blen += snprintf(&buf[blen], sizeof(buf) - blen, __VA_ARGS__); \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
ipaddr_add(const uip_ipaddr_t *addr)
|
||||
{
|
||||
uint16_t a;
|
||||
int i, f;
|
||||
for(i = 0, f = 0; i < sizeof(uip_ipaddr_t); i += 2) {
|
||||
a = (addr->u8[i] << 8) + addr->u8[i + 1];
|
||||
if(a == 0 && f >= 0) {
|
||||
if(f++ == 0) ADD("::");
|
||||
} else {
|
||||
if(f > 0) {
|
||||
f = -1;
|
||||
} else if(i > 0) {
|
||||
ADD(":");
|
||||
}
|
||||
ADD("%x", a);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(generate_routes(struct httpd_state *s))
|
||||
{
|
||||
static uip_ds6_route_t *r;
|
||||
static uip_ds6_nbr_t *nbr;
|
||||
#if BUF_USES_STACK
|
||||
char buf[256];
|
||||
#endif
|
||||
#if WEBSERVER_CONF_LOADTIME
|
||||
static clock_time_t numticks;
|
||||
numticks = clock_time();
|
||||
#endif
|
||||
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
SEND_STRING(&s->sout, TOP);
|
||||
#if BUF_USES_STACK
|
||||
bufptr = buf;bufend=bufptr+sizeof(buf);
|
||||
#else
|
||||
blen = 0;
|
||||
#endif
|
||||
ADD("Neighbors<pre>");
|
||||
|
||||
for(nbr = nbr_table_head(ds6_neighbors);
|
||||
nbr != NULL;
|
||||
nbr = nbr_table_next(ds6_neighbors, nbr)) {
|
||||
|
||||
#if WEBSERVER_CONF_NEIGHBOR_STATUS
|
||||
#if BUF_USES_STACK
|
||||
{char* j=bufptr+25;
|
||||
ipaddr_add(&nbr->ipaddr);
|
||||
while (bufptr < j) ADD(" ");
|
||||
switch (nbr->state) {
|
||||
case NBR_INCOMPLETE: ADD(" INCOMPLETE");break;
|
||||
case NBR_REACHABLE: ADD(" REACHABLE");break;
|
||||
case NBR_STALE: ADD(" STALE");break;
|
||||
case NBR_DELAY: ADD(" DELAY");break;
|
||||
case NBR_PROBE: ADD(" NBR_PROBE");break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
{uint8_t j=blen+25;
|
||||
ipaddr_add(&nbr->ipaddr);
|
||||
while (blen < j) ADD(" ");
|
||||
switch (nbr->state) {
|
||||
case NBR_INCOMPLETE: ADD(" INCOMPLETE");break;
|
||||
case NBR_REACHABLE: ADD(" REACHABLE");break;
|
||||
case NBR_STALE: ADD(" STALE");break;
|
||||
case NBR_DELAY: ADD(" DELAY");break;
|
||||
case NBR_PROBE: ADD(" NBR_PROBE");break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
ipaddr_add(&nbr->ipaddr);
|
||||
#endif
|
||||
|
||||
ADD("\n");
|
||||
#if BUF_USES_STACK
|
||||
if(bufptr > bufend - 45) {
|
||||
SEND_STRING(&s->sout, buf);
|
||||
bufptr = buf; bufend = bufptr + sizeof(buf);
|
||||
}
|
||||
#else
|
||||
if(blen > sizeof(buf) - 45) {
|
||||
SEND_STRING(&s->sout, buf);
|
||||
blen = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
ADD("</pre>Routes<pre>");
|
||||
SEND_STRING(&s->sout, buf);
|
||||
#if BUF_USES_STACK
|
||||
bufptr = buf; bufend = bufptr + sizeof(buf);
|
||||
#else
|
||||
blen = 0;
|
||||
#endif
|
||||
|
||||
for(r = uip_ds6_route_head(); r != NULL; r = uip_ds6_route_next(r)) {
|
||||
|
||||
#if BUF_USES_STACK
|
||||
#if WEBSERVER_CONF_ROUTE_LINKS
|
||||
ADD("<a href=http://[");
|
||||
ipaddr_add(&r->ipaddr);
|
||||
ADD("]/status.shtml>");
|
||||
ipaddr_add(&r->ipaddr);
|
||||
ADD("</a>");
|
||||
#else
|
||||
ipaddr_add(&r->ipaddr);
|
||||
#endif
|
||||
#else
|
||||
#if WEBSERVER_CONF_ROUTE_LINKS
|
||||
ADD("<a href=http://[");
|
||||
ipaddr_add(&r->ipaddr);
|
||||
ADD("]/status.shtml>");
|
||||
SEND_STRING(&s->sout, buf); //TODO: why tunslip6 needs an output here, wpcapslip does not
|
||||
blen = 0;
|
||||
ipaddr_add(&r->ipaddr);
|
||||
ADD("</a>");
|
||||
#else
|
||||
ipaddr_add(&r->ipaddr);
|
||||
#endif
|
||||
#endif
|
||||
ADD("/%u (via ", r->length);
|
||||
ipaddr_add(uip_ds6_route_nexthop(r));
|
||||
if(1 || (r->state.lifetime < 600)) {
|
||||
ADD(") %lus\n", (unsigned long)r->state.lifetime);
|
||||
} else {
|
||||
ADD(")\n");
|
||||
}
|
||||
SEND_STRING(&s->sout, buf);
|
||||
#if BUF_USES_STACK
|
||||
bufptr = buf; bufend = bufptr + sizeof(buf);
|
||||
#else
|
||||
blen = 0;
|
||||
#endif
|
||||
}
|
||||
ADD("</pre>");
|
||||
|
||||
#if WEBSERVER_CONF_FILESTATS
|
||||
static uint16_t numtimes;
|
||||
ADD("<br><i>This page sent %u times</i>",++numtimes);
|
||||
#endif
|
||||
|
||||
#if WEBSERVER_CONF_LOADTIME
|
||||
numticks = clock_time() - numticks + 1;
|
||||
ADD(" <i>(%lu.%02lu sec)</i>",numticks/CLOCK_SECOND,((100*(numticks%CLOCK_SECOND))/CLOCK_SECOND));
|
||||
#endif
|
||||
|
||||
|
||||
SEND_STRING(&s->sout, buf);
|
||||
SEND_STRING(&s->sout, BOTTOM);
|
||||
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
httpd_simple_script_t
|
||||
httpd_simple_get_script(const char *name)
|
||||
{
|
||||
return generate_routes;
|
||||
}
|
||||
|
||||
#endif /* WEBSERVER */
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
print_local_addresses(void)
|
||||
{
|
||||
int i;
|
||||
uint8_t state;
|
||||
|
||||
PRINTA("Server IPv6 addresses:\n");
|
||||
for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
|
||||
state = uip_ds6_if.addr_list[i].state;
|
||||
if(uip_ds6_if.addr_list[i].isused &&
|
||||
(state == ADDR_TENTATIVE || state == ADDR_PREFERRED)) {
|
||||
PRINTA(" ");
|
||||
uip_debug_ipaddr_print(&uip_ds6_if.addr_list[i].ipaddr);
|
||||
PRINTA("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
request_prefix(void)
|
||||
{
|
||||
/* mess up uip_buf with a dirty request... */
|
||||
uip_buf[0] = '?';
|
||||
uip_buf[1] = 'P';
|
||||
uip_len = 2;
|
||||
//slip_send();
|
||||
uip_clear_buf();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
set_prefix_64(uip_ipaddr_t *prefix_64)
|
||||
{
|
||||
rpl_dag_t *dag;
|
||||
uip_ipaddr_t ipaddr;
|
||||
memcpy(&prefix, prefix_64, 16);
|
||||
memcpy(&ipaddr, prefix_64, 16);
|
||||
prefix_set = 1;
|
||||
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
|
||||
uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
|
||||
|
||||
dag = rpl_set_root(RPL_DEFAULT_INSTANCE, &ipaddr);
|
||||
if(dag != NULL) {
|
||||
rpl_set_prefix(dag, &prefix, 64);
|
||||
PRINTF("created a new RPL dag\n");
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(border_router_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
uip_ipaddr_t ipaddr;
|
||||
|
||||
/* While waiting for the prefix to be sent through the SLIP connection, the future
|
||||
* border router can join an existing DAG as a parent or child, or acquire a default
|
||||
* router that will later take precedence over the SLIP fallback interface.
|
||||
* Prevent that by turning the radio off until we are initialized as a DAG root.
|
||||
*/
|
||||
prefix_set = 0;
|
||||
NETSTACK_MAC.off(0);
|
||||
|
||||
PROCESS_PAUSE();
|
||||
|
||||
SENSORS_ACTIVATE(button_sensor);
|
||||
leds_init();
|
||||
ip64_init();
|
||||
|
||||
PRINTF("RPL-Border router started\n");
|
||||
#if 0
|
||||
/* The border router runs with a 100% duty cycle in order to ensure high
|
||||
packet reception rates.
|
||||
Note if the MAC RDC is not turned off now, aggressive power management of the
|
||||
cpu will interfere with establishing the SLIP connection */
|
||||
NETSTACK_MAC.off(1);
|
||||
#endif
|
||||
|
||||
/* Now turn the radio on, but disable radio duty cycling.
|
||||
* Since we are the DAG root, reception delays would constrain mesh throughbut.
|
||||
*/
|
||||
NETSTACK_MAC.off(1);
|
||||
|
||||
/* Derived from link local (MAC) address */
|
||||
uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
|
||||
set_prefix_64(&ipaddr);
|
||||
print_local_addresses();
|
||||
|
||||
while(1) {
|
||||
PROCESS_YIELD();
|
||||
leds_on(LEDS_YELLOW);
|
||||
if (ev == sensors_event && data == &button_sensor) {
|
||||
PRINTF("Initiating global repair\n");
|
||||
rpl_repair_root(RPL_DEFAULT_INSTANCE);
|
||||
}
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
104
examples/avr-rss2/ipv6/rpl-border-router/enc28j60-ip64-driver.c
Normal file
104
examples/avr-rss2/ipv6/rpl-border-router/enc28j60-ip64-driver.c
Normal file
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2013, Thingsquare, http://www.thingsquare.com/.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
#include "enc28j60.h"
|
||||
#include "enc28j60-ip64-driver.h"
|
||||
#include "net/linkaddr.h"
|
||||
|
||||
#include "ip64.h"
|
||||
#include "ip64-eth.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
PROCESS(enc28j60_ip64_driver_process, "ENC28J60 IP64 driver");
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
uint8_t eui64[8];
|
||||
uint8_t macaddr[6];
|
||||
|
||||
/* Assume that linkaddr_node_addr holds the EUI64 of this device. */
|
||||
memcpy(eui64, &linkaddr_node_addr, sizeof(eui64));
|
||||
|
||||
/* Mangle the EUI64 into a 48-bit Ethernet address. */
|
||||
memcpy(&macaddr[0], &eui64[0], 3);
|
||||
memcpy(&macaddr[3], &eui64[5], 3);
|
||||
|
||||
/* In case the OUI happens to contain a broadcast bit, we mask that
|
||||
out here. */
|
||||
macaddr[0] = (macaddr[0] & 0xfe);
|
||||
|
||||
/* Set the U/L bit, in order to create a locally administered MAC address */
|
||||
macaddr[0] = (macaddr[0] | 0x02);
|
||||
|
||||
memcpy(ip64_eth_addr.addr, macaddr, sizeof(macaddr));
|
||||
|
||||
printf("MAC addr %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
macaddr[0], macaddr[1], macaddr[2],
|
||||
macaddr[3], macaddr[4], macaddr[5]);
|
||||
enc28j60_init(macaddr);
|
||||
process_start(&enc28j60_ip64_driver_process, NULL);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
output(uint8_t *packet, uint16_t len)
|
||||
{
|
||||
enc28j60_send(packet, len);
|
||||
return len;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(enc28j60_ip64_driver_process, ev, data)
|
||||
{
|
||||
static int len;
|
||||
static struct etimer e;
|
||||
PROCESS_BEGIN();
|
||||
|
||||
while(1) {
|
||||
etimer_set(&e, 1);
|
||||
PROCESS_WAIT_EVENT();
|
||||
len = enc28j60_read(ip64_packet_buffer, ip64_packet_buffer_maxlen);
|
||||
if(len > 0) {
|
||||
IP64_INPUT(ip64_packet_buffer, len);
|
||||
}
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
const struct ip64_driver enc28j60_ip64_driver = {
|
||||
init,
|
||||
output
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2013, Thingsquare, http://www.thingsquare.com/.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ENC28J60_IP64_DRIVER_H
|
||||
#define ENC28J60_IP64_DRIVER_H
|
||||
|
||||
#include "ip64-driver.h"
|
||||
extern const struct ip64_driver enc28j60_ip64_driver;
|
||||
|
||||
#endif /* ENC28J60_IP64_DRIVER_H */
|
33
examples/avr-rss2/ipv6/rpl-border-router/eth-bridge.c
Normal file
33
examples/avr-rss2/ipv6/rpl-border-router/eth-bridge.c
Normal file
|
@ -0,0 +1,33 @@
|
|||
#include "net/ip/uip.h"
|
||||
#include "net/ipv6/uip-ds6.h"
|
||||
#include <string.h>
|
||||
#include "ip64-eth-interface.h"
|
||||
|
||||
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
|
||||
|
||||
#define DEBUG DEBUG_NONE
|
||||
#include "net/ip/uip-debug.h"
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
PRINTF("eth-bridge: init\n");
|
||||
ip64_eth_interface.init();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
output()
|
||||
{
|
||||
PRINTF("eth-bridge: src=");
|
||||
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
|
||||
PRINTF(" dst=");
|
||||
PRINT6ADDR(&UIP_IP_BUF->destipaddr);
|
||||
PRINTF("\n");
|
||||
ip64_eth_interface.output();
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
const struct uip_fallback_interface rpl_interface = {
|
||||
init, output
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
261
examples/avr-rss2/ipv6/rpl-border-router/httpd-simple.c
Normal file
261
examples/avr-rss2/ipv6/rpl-border-router/httpd-simple.c
Normal file
|
@ -0,0 +1,261 @@
|
|||
/*
|
||||
* Copyright (c) 2010, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* A simple web server forwarding page generation to a protothread
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
* Niclas Finne <nfi@sics.se>
|
||||
* Joakim Eriksson <joakime@sics.se>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "contiki-net.h"
|
||||
|
||||
//#include "urlconv.h"
|
||||
|
||||
#include "httpd-simple.h"
|
||||
#define webserver_log_file(...)
|
||||
#define webserver_log(...)
|
||||
|
||||
#ifndef WEBSERVER_CONF_CFS_CONNS
|
||||
#define CONNS UIP_CONNS
|
||||
#else /* WEBSERVER_CONF_CFS_CONNS */
|
||||
#define CONNS WEBSERVER_CONF_CFS_CONNS
|
||||
#endif /* WEBSERVER_CONF_CFS_CONNS */
|
||||
|
||||
#ifndef WEBSERVER_CONF_CFS_URLCONV
|
||||
#define URLCONV 0
|
||||
#else /* WEBSERVER_CONF_CFS_URLCONV */
|
||||
#define URLCONV WEBSERVER_CONF_CFS_URLCONV
|
||||
#endif /* WEBSERVER_CONF_CFS_URLCONV */
|
||||
|
||||
#define STATE_WAITING 0
|
||||
#define STATE_OUTPUT 1
|
||||
|
||||
MEMB(conns, struct httpd_state, CONNS);
|
||||
|
||||
#define ISO_nl 0x0a
|
||||
#define ISO_space 0x20
|
||||
#define ISO_period 0x2e
|
||||
#define ISO_slash 0x2f
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static const char *NOT_FOUND = "<html><body bgcolor=\"white\">"
|
||||
"<center>"
|
||||
"<h1>404 - file not found</h1>"
|
||||
"</center>"
|
||||
"</body>"
|
||||
"</html>";
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(send_string(struct httpd_state *s, const char *str))
|
||||
{
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
SEND_STRING(&s->sout, str);
|
||||
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
const char http_content_type_html[] = "Content-type: text/html\r\n\r\n";
|
||||
static
|
||||
PT_THREAD(send_headers(struct httpd_state *s, const char *statushdr))
|
||||
{
|
||||
/* char *ptr; */
|
||||
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
SEND_STRING(&s->sout, statushdr);
|
||||
|
||||
/* ptr = strrchr(s->filename, ISO_period); */
|
||||
/* if(ptr == NULL) { */
|
||||
/* s->ptr = http_content_type_plain; */
|
||||
/* } else if(strcmp(http_html, ptr) == 0) { */
|
||||
/* s->ptr = http_content_type_html; */
|
||||
/* } else if(strcmp(http_css, ptr) == 0) { */
|
||||
/* s->ptr = http_content_type_css; */
|
||||
/* } else if(strcmp(http_png, ptr) == 0) { */
|
||||
/* s->ptr = http_content_type_png; */
|
||||
/* } else if(strcmp(http_gif, ptr) == 0) { */
|
||||
/* s->ptr = http_content_type_gif; */
|
||||
/* } else if(strcmp(http_jpg, ptr) == 0) { */
|
||||
/* s->ptr = http_content_type_jpg; */
|
||||
/* } else { */
|
||||
/* s->ptr = http_content_type_binary; */
|
||||
/* } */
|
||||
/* SEND_STRING(&s->sout, s->ptr); */
|
||||
SEND_STRING(&s->sout, http_content_type_html);
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
const char http_header_200[] = "HTTP/1.0 200 OK\r\nServer: Contiki/2.4 http://www.sics.se/contiki/\r\nConnection: close\r\n";
|
||||
const char http_header_404[] = "HTTP/1.0 404 Not found\r\nServer: Contiki/2.4 http://www.sics.se/contiki/\r\nConnection: close\r\n";
|
||||
static
|
||||
PT_THREAD(handle_output(struct httpd_state *s))
|
||||
{
|
||||
PT_BEGIN(&s->outputpt);
|
||||
|
||||
s->script = NULL;
|
||||
s->script = httpd_simple_get_script(&s->filename[1]);
|
||||
if(s->script == NULL) {
|
||||
strncpy(s->filename, "/notfound.html", sizeof(s->filename));
|
||||
PT_WAIT_THREAD(&s->outputpt,
|
||||
send_headers(s, http_header_404));
|
||||
PT_WAIT_THREAD(&s->outputpt,
|
||||
send_string(s, NOT_FOUND));
|
||||
uip_close();
|
||||
webserver_log_file(&uip_conn->ripaddr, "404 - not found");
|
||||
PT_EXIT(&s->outputpt);
|
||||
} else {
|
||||
PT_WAIT_THREAD(&s->outputpt,
|
||||
send_headers(s, http_header_200));
|
||||
PT_WAIT_THREAD(&s->outputpt, s->script(s));
|
||||
}
|
||||
s->script = NULL;
|
||||
PSOCK_CLOSE(&s->sout);
|
||||
PT_END(&s->outputpt);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
const char http_get[] = "GET ";
|
||||
const char http_index_html[] = "/index.html";
|
||||
//const char http_referer[] = "Referer:"
|
||||
static
|
||||
PT_THREAD(handle_input(struct httpd_state *s))
|
||||
{
|
||||
PSOCK_BEGIN(&s->sin);
|
||||
|
||||
PSOCK_READTO(&s->sin, ISO_space);
|
||||
|
||||
if(strncmp(s->inputbuf, http_get, 4) != 0) {
|
||||
PSOCK_CLOSE_EXIT(&s->sin);
|
||||
}
|
||||
PSOCK_READTO(&s->sin, ISO_space);
|
||||
|
||||
if(s->inputbuf[0] != ISO_slash) {
|
||||
PSOCK_CLOSE_EXIT(&s->sin);
|
||||
}
|
||||
|
||||
#if URLCONV
|
||||
s->inputbuf[PSOCK_DATALEN(&s->sin) - 1] = 0;
|
||||
urlconv_tofilename(s->filename, s->inputbuf, sizeof(s->filename));
|
||||
#else /* URLCONV */
|
||||
if(s->inputbuf[1] == ISO_space) {
|
||||
strncpy(s->filename, http_index_html, sizeof(s->filename));
|
||||
} else {
|
||||
s->inputbuf[PSOCK_DATALEN(&s->sin) - 1] = 0;
|
||||
strncpy(s->filename, s->inputbuf, sizeof(s->filename));
|
||||
}
|
||||
#endif /* URLCONV */
|
||||
|
||||
webserver_log_file(&uip_conn->ripaddr, s->filename);
|
||||
|
||||
s->state = STATE_OUTPUT;
|
||||
|
||||
while(1) {
|
||||
PSOCK_READTO(&s->sin, ISO_nl);
|
||||
#if 0
|
||||
if(strncmp(s->inputbuf, http_referer, 8) == 0) {
|
||||
s->inputbuf[PSOCK_DATALEN(&s->sin) - 2] = 0;
|
||||
webserver_log(s->inputbuf);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
PSOCK_END(&s->sin);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
handle_connection(struct httpd_state *s)
|
||||
{
|
||||
handle_input(s);
|
||||
if(s->state == STATE_OUTPUT) {
|
||||
handle_output(s);
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
httpd_appcall(void *state)
|
||||
{
|
||||
struct httpd_state *s = (struct httpd_state *)state;
|
||||
|
||||
if(uip_closed() || uip_aborted() || uip_timedout()) {
|
||||
if(s != NULL) {
|
||||
s->script = NULL;
|
||||
memb_free(&conns, s);
|
||||
}
|
||||
} else if(uip_connected()) {
|
||||
s = (struct httpd_state *)memb_alloc(&conns);
|
||||
if(s == NULL) {
|
||||
uip_abort();
|
||||
webserver_log_file(&uip_conn->ripaddr, "reset (no memory block)");
|
||||
return;
|
||||
}
|
||||
tcp_markconn(uip_conn, s);
|
||||
PSOCK_INIT(&s->sin, (uint8_t *)s->inputbuf, sizeof(s->inputbuf) - 1);
|
||||
PSOCK_INIT(&s->sout, (uint8_t *)s->inputbuf, sizeof(s->inputbuf) - 1);
|
||||
PT_INIT(&s->outputpt);
|
||||
s->script = NULL;
|
||||
s->state = STATE_WAITING;
|
||||
timer_set(&s->timer, CLOCK_SECOND * 10);
|
||||
handle_connection(s);
|
||||
} else if(s != NULL) {
|
||||
if(uip_poll()) {
|
||||
if(timer_expired(&s->timer)) {
|
||||
uip_abort();
|
||||
s->script = NULL;
|
||||
memb_free(&conns, s);
|
||||
webserver_log_file(&uip_conn->ripaddr, "reset (timeout)");
|
||||
}
|
||||
} else {
|
||||
timer_restart(&s->timer);
|
||||
}
|
||||
handle_connection(s);
|
||||
} else {
|
||||
uip_abort();
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
httpd_init(void)
|
||||
{
|
||||
|
||||
tcp_listen(UIP_HTONS(80));
|
||||
memb_init(&conns);
|
||||
#if URLCONV
|
||||
urlconv_init();
|
||||
#endif /* URLCONV */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
74
examples/avr-rss2/ipv6/rpl-border-router/httpd-simple.h
Normal file
74
examples/avr-rss2/ipv6/rpl-border-router/httpd-simple.h
Normal file
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* Copyright (c) 2010, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* A simple webserver
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
* Niclas Finne <nfi@sics.se>
|
||||
* Joakim Eriksson <joakime@sics.se>
|
||||
*/
|
||||
|
||||
#ifndef HTTPD_SIMPLE_H_
|
||||
#define HTTPD_SIMPLE_H_
|
||||
|
||||
#include "contiki-net.h"
|
||||
|
||||
/* The current internal border router webserver ignores the requested file name */
|
||||
/* and needs no per-connection output buffer, so save some RAM */
|
||||
#ifndef WEBSERVER_CONF_CFS_PATHLEN
|
||||
#define HTTPD_PATHLEN 2
|
||||
#else /* WEBSERVER_CONF_CFS_CONNS */
|
||||
#define HTTPD_PATHLEN WEBSERVER_CONF_CFS_PATHLEN
|
||||
#endif /* WEBSERVER_CONF_CFS_CONNS */
|
||||
|
||||
struct httpd_state;
|
||||
typedef char (* httpd_simple_script_t)(struct httpd_state *s);
|
||||
|
||||
struct httpd_state {
|
||||
struct timer timer;
|
||||
struct psock sin, sout;
|
||||
struct pt outputpt;
|
||||
char inputbuf[HTTPD_PATHLEN + 24];
|
||||
/*char outputbuf[UIP_TCP_MSS]; */
|
||||
char filename[HTTPD_PATHLEN];
|
||||
httpd_simple_script_t script;
|
||||
char state;
|
||||
};
|
||||
|
||||
void httpd_init(void);
|
||||
void httpd_appcall(void *state);
|
||||
|
||||
httpd_simple_script_t httpd_simple_get_script(const char *name);
|
||||
|
||||
#define SEND_STRING(s, str) PSOCK_SEND(s, (uint8_t *)str, strlen(str))
|
||||
|
||||
#endif /* HTTPD_SIMPLE_H_ */
|
57
examples/avr-rss2/ipv6/rpl-border-router/project-conf.h
Normal file
57
examples/avr-rss2/ipv6/rpl-border-router/project-conf.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright (c) 2010, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PROJECT_ROUTER_CONF_H_
|
||||
#define PROJECT_ROUTER_CONF_H_
|
||||
|
||||
#define NETSTACK_CONF_RDC nullrdc_driver
|
||||
#define NETSTACK_CONF_MAC nullmac_driver
|
||||
|
||||
#ifndef UIP_FALLBACK_INTERFACE
|
||||
#define UIP_FALLBACK_INTERFACE rpl_interface
|
||||
#endif
|
||||
|
||||
#ifndef QUEUEBUF_CONF_NUM
|
||||
#define QUEUEBUF_CONF_NUM 4
|
||||
#endif
|
||||
|
||||
#ifndef UIP_CONF_BUFFER_SIZE
|
||||
#define UIP_CONF_BUFFER_SIZE 600
|
||||
#endif
|
||||
|
||||
#ifndef UIP_CONF_RECEIVE_WINDOW
|
||||
#define UIP_CONF_RECEIVE_WINDOW 60
|
||||
#endif
|
||||
|
||||
#ifndef WEBSERVER_CONF_CFS_CONNS
|
||||
#define WEBSERVER_CONF_CFS_CONNS 2
|
||||
#endif
|
||||
|
||||
#endif /* PROJECT_ROUTER_CONF_H_ */
|
Loading…
Add table
Add a link
Reference in a new issue