43 #include <avr/pgmspace.h>
47 #include "dev/rs232.h"
55 #include "dev/ds2401.h"
56 #include "sys/node-id.h"
58 #if NETSTACK_CONF_WITH_IPV6
62 #if NETSTACK_CONF_WITH_IPV4
65 #include "net/uip-fw-drv.h"
70 {
UIP_FW_NETIF(172,16,0,0, 255,255,0,0, uip_over_mesh_send)};
72 static uint8_t is_gateway;
76 #define UIP_OVER_MESH_CHANNEL 8
85 memset(&addr, 0,
sizeof(linkaddr_t));
86 #if NETSTACK_CONF_WITH_IPV6
87 memcpy(addr.u8, ds2401_id,
sizeof(addr.u8));
90 for(i = 0; i <
sizeof(linkaddr_t); ++i) {
91 addr.u8[i] = ds2401_id[7 - i];
94 addr.u8[0] = node_id & 0xff;
95 addr.u8[1] = node_id >> 8;
99 printf_P(PSTR(
"Rime started with address "));
100 for(i = 0; i <
sizeof(addr.u8) - 1; i++) {
101 printf_P(PSTR(
"%d."), addr.u8[i]);
103 printf_P(PSTR(
"%d\n"), addr.u8[i]);
107 #if NETSTACK_CONF_WITH_IPV4
113 printf_P(PSTR(
"%d.%d: making myself the IP network gateway.\n\n"),
115 printf_P(PSTR(
"IPv4 address of the gateway: %d.%d.%d.%d\n\n"),
118 uip_over_mesh_make_announced_gateway();
136 memset(longaddr, 0,
sizeof(longaddr));
138 printf_P(PSTR(
"MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n"),
139 longaddr[0], longaddr[1], longaddr[2], longaddr[3],
140 longaddr[4], longaddr[5], longaddr[6], longaddr[7]);
142 cc2420_set_pan_addr(IEEE802154_PANID, shortaddr, longaddr);
145 #if NETSTACK_CONF_WITH_IPV6
155 NETSTACK_NETWORK.init();
157 printf_P(PSTR(
"%s %s, channel check rate %d Hz, radio channel %d\n"),
158 NETSTACK_MAC.name, NETSTACK_RDC.name,
159 CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:
160 NETSTACK_RDC.channel_check_interval()),
161 CC2420_CONF_CHANNEL);
165 printf_P(PSTR(
"Tentative link-local IPv6 address "));
169 lladdr = uip_ds6_get_link_local(-1);
170 for(i = 0; i < 7; ++i) {
171 printf_P(PSTR(
"%02x%02x:"), lladdr->ipaddr.u8[i * 2],
172 lladdr->ipaddr.u8[i * 2 + 1]);
174 printf_P(PSTR(
"%02x%02x\n"), lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);
177 if(!UIP_CONF_IPV6_RPL) {
180 uip_ip6addr(&ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0);
183 printf_P(PSTR(
"Tentative global IPv6 address "));
184 for(i = 0; i < 7; ++i) {
185 printf_P(PSTR(
"%02x%02x:"),
186 ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]);
188 printf_P(PSTR(
"%02x%02x\n"),
189 ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);
196 NETSTACK_NETWORK.init();
198 printf_P(PSTR(
"%s %s, channel check rate %d Hz, radio channel %d\n"),
199 NETSTACK_MAC.name, NETSTACK_RDC.name,
200 CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0? 1:
201 NETSTACK_RDC.channel_check_interval()),
202 CC2420_CONF_CHANNEL);
206 #if NETSTACK_CONF_WITH_IPV4
207 uip_ipaddr_t hostaddr,
netmask;
230 uip_over_mesh_set_net(&hostaddr, &netmask);
234 uip_over_mesh_set_gateway_netif(&slipif);
237 uip_over_mesh_init(UIP_OVER_MESH_CHANNEL);
238 printf_P(PSTR(
"uIP started with IP address %d.%d.%d.%d\n"),
#define uip_sethostaddr(addr)
Set the IP address of this host.
static uip_ipaddr_t ipaddr
Pointer to prefix information option in uip_buf.
#define uip_ipaddr(addr, addr0, addr1, addr2, addr3)
Construct an IP address from four bytes.
static uip_ds6_addr_t * addr
Pointer to a router list entry.
uint8_t slip_send(void)
Send an IP packet from the uIP buffer with SLIP.
Header file for IPv6-related data structures.
uip_ipaddr_t ipaddr
The IP address of this interface.
Header file for tunnelling uIP over Rime mesh
#define uip_ipaddr_copy(dest, src)
Copy an IP address from one place to another.
Header file for the Rime address representation
Unicast address structure.
void uip_fw_init(void)
Initialize the uIP packet forwarding module.
void slip_set_input_callback(void(*c)(void))
Set a function to be called when there is activity on the SLIP interface; used for detecting if a nod...
uip_ipaddr_t netmask
The netmask of the interface.
#define uip_setnetmask(addr)
Set the netmask.
#define NULL
The null pointer.
#define uip_ipaddr_to_quad(a)
Convert an IP address to four bytes separated by commas.
802.15.4 frame creation and parsing functions
uIP packet forwarding header file.
void linkaddr_set_node_addr(linkaddr_t *t)
Set the address of the current node.
#define UIP_FW_NETIF(ip1, ip2, ip3, ip4, nm1, nm2, nm3, nm4, outputfunc)
Instantiating macro for a uIP network interface.
#define ADDR_TENTATIVE
Possible states for the an address (RFC 4862)
#define CLOCK_SECOND
A second, measured in system clock time.
#define uip_ip6addr(addr, addr0, addr1, addr2, addr3, addr4, addr5, addr6, addr7)
Construct an IPv6 address from eight 16-bit words.
Header file for the uIP TCP/IP stack.
void process_start(struct process *p, process_data_t data)
Start a process.
uip_ds6_addr_t * uip_ds6_addr_add(uip_ipaddr_t *ipaddr, unsigned long vlifetime, uint8_t type)
Add a unicast address to the interface.
CCIF uip_lladdr_t uip_lladdr
Host L2 address.
void uip_init(void)
uIP initialization function.
Header file for the Rime queue buffer management
void linkaddr_copy(linkaddr_t *dest, const linkaddr_t *src)
Copy a Rime address.
linkaddr_t linkaddr_node_addr
The Rime address of the node.
Include file for the Contiki low-layer network stack (NETSTACK)
void uip_ds6_set_addr_iid(uip_ipaddr_t *ipaddr, uip_lladdr_t *lladdr)
set the last 64 bits of an IP address based on the MAC address
void uip_fw_default(struct uip_fw_netif *netif)
Register a default network interface.
Representation of a uIP network interface.