Add optional RF230BB radio driver
This commit is contained in:
parent
b0930cf2ec
commit
53801ffbb1
|
@ -115,6 +115,10 @@ typedef int32_t s32_t;
|
|||
|
||||
#define UIP_CONF_STATISTICS 1
|
||||
|
||||
#ifdef RF230BB
|
||||
#define SICSLOWPAN_CONF_CONVENTIONAL_MAC 1 //for barebones driver, sicslowpan calls radio->read function
|
||||
//#undef PACKETBUT_CONF_HDR_SIZE //RF230BB takes the packetbuf default for header size
|
||||
#endif
|
||||
|
||||
/* Fragmentation uses queuebuf.c to save packets */
|
||||
#define QUEUEBUF_CONF_NUM 1
|
||||
|
@ -126,6 +130,33 @@ typedef int32_t s32_t;
|
|||
#define UIP_DATA_RUM_OFFSET 5
|
||||
#endif
|
||||
|
||||
#if 0 //xmac protocol
|
||||
#undef UIP_CONF_ROUTER
|
||||
#undef UIP_CONF_LLH_LEN
|
||||
#define UIP_CONF_LLH_LEN 14
|
||||
#undef XMAC_CONF_COMPOWER
|
||||
#define XMAC_CONF_COMPOWER 1
|
||||
#undef XMAC_CONF_ANNOUNCEMENTS
|
||||
#define XMAC_CONF_ANNOUNCEMENTS 0
|
||||
#undef RF_CHANNEL
|
||||
#define RF_CHANNEL 26
|
||||
//#define CC2420_CONF_AUTOACK 0
|
||||
#undef UIP_CONF_BUFFER_SIZE
|
||||
#define UIP_CONF_BUFFER_SIZE 256
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
/* Specifies the default MAC driver */
|
||||
#define MAC_CONF_CSMA 1
|
||||
#define XMAC_CONF_COMPOWER 1
|
||||
#define CXMAC_CONF_COMPOWER 1
|
||||
#define MAC_CONF_DRIVER cxmac_driver
|
||||
#define MAC_CONF_CHANNEL_CHECK_RATE 8
|
||||
#define RIME_CONF_NO_POLITE_ANNOUCEMENTS 0
|
||||
#define CXMAC_CONF_ANNOUNCEMENTS 0
|
||||
#define XMAC_CONF_ANNOUNCEMENTS 0
|
||||
#endif
|
||||
|
||||
typedef unsigned short clock_time_t;
|
||||
typedef unsigned char u8_t;
|
||||
typedef unsigned short u16_t;
|
||||
|
|
|
@ -32,10 +32,12 @@
|
|||
*
|
||||
* @(#)$$
|
||||
*/
|
||||
|
||||
#include "contiki-raven.h"
|
||||
|
||||
#if !RF230BB
|
||||
#include "zmac.h"
|
||||
#else
|
||||
extern uint64_t macLongAddr;
|
||||
#endif
|
||||
#include "sicslowpan.h"
|
||||
extern uint64_t rndis_ethernet_addr;
|
||||
|
||||
|
@ -61,7 +63,8 @@ init_net(void)
|
|||
IPv6 address will be. This will have ff:fe in the middle. */
|
||||
macLongAddr = (macLongAddr & 0xffffff0000ffffffULL) | (0x000000fffe000000ULL);
|
||||
|
||||
#if !RF230BB
|
||||
ieee15_4ManagerAddress.set_long_addr(macLongAddr);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -44,16 +44,44 @@
|
|||
#include <avr/eeprom.h>
|
||||
#include <util/delay.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Set ANNOUNCE to send boot messages to USB serial port */
|
||||
#define ANNOUNCE 1
|
||||
|
||||
#include "lib/mmem.h"
|
||||
#include "loader/symbols-def.h"
|
||||
#include "loader/symtab.h"
|
||||
#if RF230BB //radio driver using contiki core mac
|
||||
#include "radio/rf230bb/rf230bb.h"
|
||||
#include "net/mac/frame802154.h"
|
||||
#include "net/sicslowpan.h"
|
||||
#include "net/uip-netif.h"
|
||||
#include "net/mac/lpp.h"
|
||||
|
||||
#if WITH_NULLMAC
|
||||
#define MAC_DRIVER nullmac_driver
|
||||
#endif /* WITH_NULLMAC */
|
||||
|
||||
#ifndef MAC_DRIVER
|
||||
#ifdef MAC_CONF_DRIVER
|
||||
#define MAC_DRIVER MAC_CONF_DRIVER
|
||||
#else
|
||||
#define MAC_DRIVER sicslowmac_driver
|
||||
//#define MAC_DRIVER cxmac_driver
|
||||
#endif /* MAC_CONF_DRIVER */
|
||||
#endif /* MAC_DRIVER */
|
||||
|
||||
#include "net/mac/sicslowmac.h"
|
||||
#include "net/mac/cxmac.h"
|
||||
#else //radio driver using Atmel/Cisco 802.15.4'ish MAC
|
||||
#include <stdbool.h>
|
||||
#include "mac.h"
|
||||
#include "sicslowmac.h"
|
||||
#include "sicslowpan.h"
|
||||
#include "ieee-15-4-manager.h"
|
||||
#endif /*RF230BB*/
|
||||
|
||||
#include "lib/mmem.h"
|
||||
#include "loader/symbols-def.h"
|
||||
#include "loader/symtab.h"
|
||||
|
||||
#include "contiki.h"
|
||||
#include "contiki-net.h"
|
||||
|
@ -65,6 +93,28 @@
|
|||
#include "rndis/rndis_task.h"
|
||||
#include "storage/storage_task.h"
|
||||
|
||||
#if RF230BB
|
||||
#warning Experimental RF230BB radio selected
|
||||
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
|
||||
extern int rf230_interrupt_flag;
|
||||
extern uint8_t rf230processflag;
|
||||
|
||||
#if 0 //dummy tcpip process not needed?
|
||||
PROCESS(tcpip_process, "tcpip dummy");
|
||||
PROCESS_THREAD(tcpip_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
PROCESS_END();
|
||||
}
|
||||
void
|
||||
tcpip_ipv6_output(void)
|
||||
{
|
||||
printf("tcpipipv6output");
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* RF230BB */
|
||||
|
||||
/*----------------------Configuration of the .elf file---------------------*/
|
||||
typedef struct {unsigned char B2;unsigned char B1;unsigned char B0;} __signature_t;
|
||||
#define SIGNATURE __signature_t __signature __attribute__((section (".signature")))
|
||||
|
@ -82,11 +132,23 @@ uint8_t mac_address[8] EEMEM = {0x02, 0x12, 0x13, 0xff, 0xfe, 0x14, 0x15, 0x16};
|
|||
//uint8_t EEMEM server_name[16];
|
||||
//uint8_t EEMEM domain_name[30];
|
||||
|
||||
#if !RF230BB
|
||||
PROCINIT(&etimer_process, &mac_process);
|
||||
#else
|
||||
rimeaddr_t macLongAddr;
|
||||
//PROCINIT(&etimer_process, &tcpip_process);
|
||||
PROCINIT(&etimer_process);
|
||||
#endif
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
#if ANNOUNCE
|
||||
uint32_t firsttime=0;
|
||||
#endif
|
||||
#if RF230BB
|
||||
rimeaddr_t addr;
|
||||
#endif
|
||||
/*
|
||||
* GCC depends on register r1 set to 0.
|
||||
*/
|
||||
|
@ -94,17 +156,71 @@ main(void)
|
|||
|
||||
/* Initialize hardware */
|
||||
init_lowlevel();
|
||||
|
||||
|
||||
/* Clock */
|
||||
clock_init();
|
||||
|
||||
printf_P(PSTR("\n\n\n********BOOTING CONTIKI*********\n"));
|
||||
// printf_P(PSTR("\n\n\n********BOOTING CONTIKI*********\n"));
|
||||
|
||||
/* Process subsystem */
|
||||
process_init();
|
||||
|
||||
/* Register initial processes */
|
||||
procinit_init();
|
||||
|
||||
#ifdef RF230BB
|
||||
{
|
||||
/* Start radio and radio receive process */
|
||||
/* Note this starts RF230 process, so must be done after process_init */
|
||||
rf230_init();
|
||||
sicslowpan_init(MAC_DRIVER.init(&rf230_driver));
|
||||
// sicslowpan_init(sicslowmac_init(&rf230_driver));
|
||||
// sicslowpan_init(lpp_init(&rf230_driver));
|
||||
// sicslowpan_init(cxmac_init(&rf230_driver));
|
||||
// ctimer_init();
|
||||
rtimer_init();
|
||||
// queuebuf_init();
|
||||
|
||||
|
||||
|
||||
/* Set addresses BEFORE starting tcpip process */
|
||||
|
||||
memset(&addr, 0, sizeof(rimeaddr_t));
|
||||
AVR_ENTER_CRITICAL_REGION();
|
||||
eeprom_read_block ((void *)&addr.u8, &mac_address, 8);
|
||||
AVR_LEAVE_CRITICAL_REGION();
|
||||
//RNDIS needs the mac address in reverse byte order
|
||||
macLongAddr.u8[0]=addr.u8[7];
|
||||
macLongAddr.u8[1]=addr.u8[6];
|
||||
macLongAddr.u8[2]=addr.u8[5];
|
||||
macLongAddr.u8[3]=addr.u8[4];
|
||||
macLongAddr.u8[4]=addr.u8[3];
|
||||
macLongAddr.u8[5]=addr.u8[2];
|
||||
macLongAddr.u8[6]=addr.u8[1];
|
||||
macLongAddr.u8[7]=addr.u8[0];
|
||||
|
||||
sei(); //dak - is this necessary?
|
||||
|
||||
memcpy(&uip_lladdr.addr, &addr.u8, 8);
|
||||
rf230_set_pan_addr(IEEE802154_PANID, 0, (uint8_t *)&addr.u8); //ABCD is default - dak
|
||||
|
||||
rf230_set_channel(24);
|
||||
rimeaddr_set_node_addr(&addr);
|
||||
// printf("MAC address %x:%x:%x:%x:%x:%x:%x:%x\n",addr.u8[0],addr.u8[1],addr.u8[2],addr.u8[3],addr.u8[4],addr.u8[5],addr.u8[6],addr.u8[7]);
|
||||
|
||||
// uip_ip6addr(&ipprefix, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
|
||||
// uip_netif_addr_add(&ipprefix, UIP_DEFAULT_PREFIX_LEN, 0, AUTOCONF);
|
||||
// uip_nd6_prefix_add(&ipprefix, UIP_DEFAULT_PREFIX_LEN, 0);
|
||||
// PRINTF("Prefix %x::/%u\n",ipprefix.u16[0],UIP_DEFAULT_PREFIX_LEN);
|
||||
|
||||
#if UIP_CONF_ROUTER
|
||||
rime_init(rime_udp_init(NULL));
|
||||
uip_router_register(&rimeroute);
|
||||
#endif
|
||||
|
||||
// printf("Driver: %s, Channel: %u\n", sicslowmac_driver.name, rf230_get_channel());
|
||||
}
|
||||
#endif /*RF230BB*/
|
||||
|
||||
/* Setup USB */
|
||||
process_start(&usb_process, NULL);
|
||||
|
@ -112,20 +228,44 @@ main(void)
|
|||
process_start(&rndis_process, NULL);
|
||||
process_start(&storage_process, NULL);
|
||||
|
||||
printf_P(PSTR("System online.\n"));
|
||||
// printf_P(PSTR("System online.\n"));
|
||||
|
||||
//Fix MAC address
|
||||
init_net();
|
||||
|
||||
|
||||
/* Main scheduler loop */
|
||||
while(1) {
|
||||
process_run();
|
||||
|
||||
/* Debugging - allow USB CDC to keep up with printfs */
|
||||
#if ANNOUNCE
|
||||
if (firsttime++==36000){
|
||||
printf_P(PSTR("\n\n\n********BOOTING CONTIKI*********\n\r"));
|
||||
#if RF230BB
|
||||
} else if (firsttime==40000) {
|
||||
printf("MAC address %x:%x:%x:%x:%x:%x:%x:%x\n\r",addr.u8[0],addr.u8[1],addr.u8[2],addr.u8[3],addr.u8[4],addr.u8[5],addr.u8[6],addr.u8[7]);
|
||||
} else if (firsttime==44000) {
|
||||
printf("Driver: %s, Channel: %u\n\r", MAC_DRIVER.name, rf230_get_channel());
|
||||
#endif
|
||||
} else if (firsttime==48000) {
|
||||
printf_P(PSTR("System online.\n\r"));
|
||||
}
|
||||
|
||||
#if DEBUG && 0
|
||||
if (rf230processflag) {
|
||||
printf("**RF230 process flag %u\n\r",rf230processflag);
|
||||
rf230processflag=0;
|
||||
}
|
||||
if (rf230_interrupt_flag) {
|
||||
// if (rf230_interrupt_flag!=11) {
|
||||
printf("**RF230 Interrupt %u\n\r",rf230_interrupt_flag);
|
||||
// }
|
||||
rf230_interrupt_flag=0;
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
#endif /* ANNOUNCE */
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -52,7 +52,11 @@
|
|||
*/
|
||||
|
||||
//TODO: Should be able to always use this SIMPLE mode, hence can remove the 'complex' mode permanently
|
||||
#if !RF230BB
|
||||
#define UIP_CONF_SIMPLE_JACKDAW_ADDR_TRANS 1
|
||||
#else
|
||||
#define UIP_CONF_SIMPLE_JACKDAW_ADDR_TRANS 0
|
||||
#endif
|
||||
|
||||
|
||||
#if UIP_CONF_SIMPLE_JACKDAW_ADDR_TRANS
|
||||
|
@ -218,14 +222,17 @@
|
|||
|
||||
#include "uip.h"
|
||||
#include "uip_arp.h" //For ethernet header structure
|
||||
#include "zmac.h"
|
||||
#include "frame.h"
|
||||
|
||||
#include "net/rime.h"
|
||||
#include "sicslowpan.h"
|
||||
#include "sicslow_ethernet.h"
|
||||
#if !RF230BB
|
||||
#include "zmac.h"
|
||||
#include "frame.h"
|
||||
#include "radio.h"
|
||||
#endif
|
||||
#include "rndis/rndis_protocol.h"
|
||||
#include "rndis/rndis_task.h"
|
||||
#include "radio.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
@ -254,9 +261,11 @@ static uint64_t local_ethernet_addr = 0x3A3B3C3D3E3FULL;
|
|||
extern uint64_t rndis_ethernet_addr;
|
||||
#endif
|
||||
|
||||
#if !RF230BB
|
||||
extern void (*pinput)(const struct mac_driver *r);
|
||||
void (*sicslowinput)(const struct mac_driver *r);
|
||||
parsed_frame_t * parsed_frame;
|
||||
#endif
|
||||
usbstick_mode_t usbstick_mode;
|
||||
|
||||
uint8_t mac_createSicslowpanLongAddr(uint8_t * ethernet, uip_lladdr_t * lowpan);
|
||||
|
@ -284,16 +293,18 @@ uint8_t prefixBuffer[PREFIX_BUFFER_SIZE][3];
|
|||
/* 6lowpan max size + ethernet header size + 1 */
|
||||
uint8_t raw_buf[127+ UIP_LLH_LEN +1];
|
||||
|
||||
|
||||
void tcpip_input( void )
|
||||
{
|
||||
// printf("tcpip_input");
|
||||
mac_LowpanToEthernet();
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Perform any setup needed
|
||||
*/
|
||||
#if !RF230BB
|
||||
struct mac_driver * pmac;
|
||||
#endif
|
||||
void mac_ethernetSetup(void)
|
||||
{
|
||||
usbstick_mode.sicslowpan = 1;
|
||||
|
@ -301,12 +312,13 @@ void mac_ethernetSetup(void)
|
|||
usbstick_mode.translate = 1;
|
||||
usbstick_mode.raw = 1;
|
||||
|
||||
#if !RF230BB
|
||||
sicslowinput = pinput;
|
||||
|
||||
|
||||
pmac = sicslowmac_get_driver();
|
||||
pmac->set_receive_function(mac_ethhijack);
|
||||
sicslowmac_snifferhook = mac_ethhijack_nondata;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -320,7 +332,7 @@ void mac_ethernetToLowpan(uint8_t * ethHeader)
|
|||
uip_lladdr_t destAddr;
|
||||
uip_lladdr_t *destAddrPtr = NULL;
|
||||
|
||||
PRINTF("Packet type: %x\n", ((struct uip_eth_hdr *) ethHeader)->type);
|
||||
PRINTF("Packet type: %x\n\r", ((struct uip_eth_hdr *) ethHeader)->type);
|
||||
|
||||
//RUM doesn't support sending data
|
||||
#if UIP_CONF_USE_RUM
|
||||
|
@ -329,8 +341,11 @@ void mac_ethernetToLowpan(uint8_t * ethHeader)
|
|||
|
||||
//If not IPv6 we don't do anything
|
||||
if (((struct uip_eth_hdr *) ethHeader)->type != HTONS(UIP_ETHTYPE_IPV6)) {
|
||||
printf("eth2low: Packet is not IPv6, dropping\n");
|
||||
PRINTF("eth2low: Packet is not IPv6, dropping\n\r");
|
||||
printf("!ipv6");
|
||||
#if !RF230BB
|
||||
rndis_stat.txbad++;
|
||||
#endif
|
||||
uip_len = 0;
|
||||
return;
|
||||
}
|
||||
|
@ -345,7 +360,7 @@ void mac_ethernetToLowpan(uint8_t * ethHeader)
|
|||
if ( (((struct uip_eth_hdr *) ethHeader)->dest.addr[0] == 0x33) &&
|
||||
(((struct uip_eth_hdr *) ethHeader)->dest.addr[1] == 0x33) )
|
||||
{
|
||||
PRINTF("eth2low: Ethernet multicast packet received\n");
|
||||
PRINTF("eth2low: Ethernet multicast packet received\n\r");
|
||||
;//Do Nothing
|
||||
} else if ( (((struct uip_eth_hdr *) ethHeader)->dest.addr[0] == 0xFF) &&
|
||||
(((struct uip_eth_hdr *) ethHeader)->dest.addr[1] == 0xFF) &&
|
||||
|
@ -354,8 +369,10 @@ void mac_ethernetToLowpan(uint8_t * ethHeader)
|
|||
(((struct uip_eth_hdr *) ethHeader)->dest.addr[4] == 0xFF) &&
|
||||
(((struct uip_eth_hdr *) ethHeader)->dest.addr[5] == 0xFF) ) {
|
||||
/* IPv6 does not use broadcast addresses, hence this should not happen */
|
||||
PRINTF("eth2low: Ethernet broadcast address received, should not happen?\n");
|
||||
PRINTF("eth2low: Ethernet broadcast address received, should not happen?\n\r");
|
||||
#if !RF230BB
|
||||
rndis_stat.txbad++;
|
||||
#endif
|
||||
uip_len = 0;
|
||||
return;
|
||||
} else {
|
||||
|
@ -387,12 +404,14 @@ void mac_ethernetToLowpan(uint8_t * ethHeader)
|
|||
PRINTF("eth2low: Addressed packet received... ");
|
||||
//Check this returns OK
|
||||
if (mac_createSicslowpanLongAddr( &(((struct uip_eth_hdr *) ethHeader)->dest.addr[0]), &destAddr) == 0) {
|
||||
PRINTF(" translation failed\n");
|
||||
PRINTF(" translation failed\n\r");
|
||||
#if !RF230BB
|
||||
rndis_stat.txbad++;
|
||||
#endif
|
||||
uip_len = 0;
|
||||
return;
|
||||
}
|
||||
PRINTF(" translated OK\n");
|
||||
PRINTF(" translated OK\n\r");
|
||||
destAddrPtr = &destAddr;
|
||||
#endif
|
||||
|
||||
|
@ -406,7 +425,7 @@ void mac_ethernetToLowpan(uint8_t * ethHeader)
|
|||
if (usbstick_mode.translate) {
|
||||
#if DEBUG
|
||||
uint8_t transReturn = mac_translateIPLinkLayer(ll_802154_type);
|
||||
PRINTF("IPTranslation: returns %d\n", transReturn);
|
||||
PRINTF("IPTranslation: returns %d\n\r", transReturn);
|
||||
#else
|
||||
mac_translateIPLinkLayer(ll_802154_type);
|
||||
#endif
|
||||
|
@ -414,7 +433,9 @@ void mac_ethernetToLowpan(uint8_t * ethHeader)
|
|||
|
||||
if (usbstick_mode.sendToRf){
|
||||
tcpip_output(destAddrPtr);
|
||||
#if !RF230BB
|
||||
rndis_stat.txok++;
|
||||
#endif
|
||||
}
|
||||
|
||||
uip_len = 0;
|
||||
|
@ -428,15 +449,23 @@ void mac_ethernetToLowpan(uint8_t * ethHeader)
|
|||
*/
|
||||
void mac_LowpanToEthernet(void)
|
||||
{
|
||||
#if !RF230BB
|
||||
parsed_frame = sicslowmac_get_frame();
|
||||
#endif
|
||||
|
||||
//printf("in lowpantoethernet\n\r");
|
||||
//Setup generic ethernet stuff
|
||||
ETHBUF(uip_buf)->type = htons(UIP_ETHTYPE_IPV6);
|
||||
|
||||
//Check for broadcast message
|
||||
//if(rimeaddr_cmp((const rimeaddr_t *)destAddr, &rimeaddr_null)) {
|
||||
|
||||
#if RF230BB
|
||||
if(rimeaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &rimeaddr_null)) {
|
||||
// if(rimeaddr_cmp((const rimeaddr_t *)destAddr, &rimeaddr_null)) {
|
||||
#else
|
||||
if( ( parsed_frame->fcf->destAddrMode == SHORTADDRMODE) &&
|
||||
( parsed_frame->dest_addr->addr16 == 0xffff) ) {
|
||||
#endif
|
||||
ETHBUF(uip_buf)->dest.addr[0] = 0x33;
|
||||
ETHBUF(uip_buf)->dest.addr[1] = 0x33;
|
||||
ETHBUF(uip_buf)->dest.addr[2] = UIP_IP_BUF->destipaddr.u8[12];
|
||||
|
@ -463,12 +492,14 @@ void mac_LowpanToEthernet(void)
|
|||
mac_translateIPLinkLayer(ll_8023_type);
|
||||
}
|
||||
|
||||
PRINTF("Low2Eth: Sending packet to ethernet\n");
|
||||
PRINTF("Low2Eth: Sending packet to ethernet\n\r");
|
||||
|
||||
uip_len += UIP_LLH_LEN;
|
||||
|
||||
usb_eth_send(uip_buf, uip_len, 1);
|
||||
#if !RF230BB
|
||||
rndis_stat.rxok++;
|
||||
#endif
|
||||
uip_len = 0;
|
||||
}
|
||||
|
||||
|
@ -488,7 +519,7 @@ int8_t mac_translateIPLinkLayer(lltype_t target)
|
|||
|
||||
#if UIP_LLADDR_LEN == 8
|
||||
if (UIP_IP_BUF->proto == UIP_PROTO_ICMP6) {
|
||||
PRINTF("eth2low: ICMP Message detected\n");
|
||||
PRINTF("eth2low: ICMP Message detected\n\r");
|
||||
return mac_translateIcmpLinkLayer(target);
|
||||
}
|
||||
return 0;
|
||||
|
@ -537,6 +568,7 @@ int8_t mac_translateIcmpLinkLayer(lltype_t target)
|
|||
uint8_t llbuf[16];
|
||||
|
||||
//Figure out offset to start of options
|
||||
// printf("mac_translateicmplinklayer...");
|
||||
switch(UIP_ICMP_BUF->type) {
|
||||
case ICMP6_NS:
|
||||
case ICMP6_NA:
|
||||
|
@ -553,7 +585,7 @@ int8_t mac_translateIcmpLinkLayer(lltype_t target)
|
|||
|
||||
case ICMP6_REDIRECT:
|
||||
icmp_opt_offset = 40;
|
||||
break;
|
||||
break;
|
||||
|
||||
/** Things without link-layer */
|
||||
case ICMP6_DST_UNREACH:
|
||||
|
@ -608,6 +640,7 @@ int8_t mac_translateIcmpLinkLayer(lltype_t target)
|
|||
|
||||
//Translate addresses
|
||||
if (target == ll_802154_type) {
|
||||
// printf("createsicslowpanlongaddr");
|
||||
mac_createSicslowpanLongAddr(llbuf, (uip_lladdr_t *)UIP_ICMP_OPTS(icmp_opt_offset)->data);
|
||||
} else {
|
||||
if (UIP_CONF_SIMPLE_JACKDAW_ADDR_TRANS) {
|
||||
|
@ -650,7 +683,7 @@ int8_t mac_translateIcmpLinkLayer(lltype_t target)
|
|||
|
||||
//This shouldn't happen!
|
||||
if (UIP_ICMP_OPTS(icmp_opt_offset)->length == 0) {
|
||||
PRINTF("Option in ND packet has length zero, error?\n");
|
||||
PRINTF("Option in ND packet has length zero, error?\n\r");
|
||||
len = 0;
|
||||
}
|
||||
|
||||
|
@ -686,16 +719,21 @@ uint8_t mac_createSicslowpanLongAddr(uint8_t * ethernet, uip_lladdr_t * lowpan)
|
|||
lowpan->addr[7] = ethernet[5];
|
||||
|
||||
#else //!UIP_CONF_SIMPLE_JACKDAW_ADDR_TRANS
|
||||
|
||||
uint8_t index;
|
||||
|
||||
#if UIP_LLADDR_LEN == 8
|
||||
uint8_t index;
|
||||
|
||||
#if UIP_LLADDR_LEN == 8
|
||||
//Special case - if the address is our address, we just copy over what we know to be
|
||||
//our 802.15.4 address
|
||||
|
||||
#if RF230BB
|
||||
if (memcmp((uint8_t *)&uip_lladdr.addr[2], ethernet, 6) == 0) {
|
||||
// printf("here1");
|
||||
memcpy((uint8_t *)lowpan, uip_lladdr.addr, 8);
|
||||
#else
|
||||
if (memcmp_reverse((uint8_t *)&rndis_ethernet_addr, ethernet, 6) == 0) {
|
||||
memcpy((uint8_t *)lowpan, &macLongAddr, 8);
|
||||
byte_reverse((uint8_t *)lowpan, 8);
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -719,6 +757,7 @@ uint8_t mac_createSicslowpanLongAddr(uint8_t * ethernet, uip_lladdr_t * lowpan)
|
|||
//Bit is clear
|
||||
//so we copy all six
|
||||
} else {
|
||||
// printf("here3");
|
||||
lowpan->addr[0] = ethernet[0];
|
||||
lowpan->addr[3] = 0xff;
|
||||
lowpan->addr[4] = 0xfe;
|
||||
|
@ -733,6 +772,7 @@ uint8_t mac_createSicslowpanLongAddr(uint8_t * ethernet, uip_lladdr_t * lowpan)
|
|||
|
||||
#else //UIP_LLADDR != 8
|
||||
uint8_t i;
|
||||
// printf("here4");
|
||||
for(i = 0; i < UIP_LLADDR_LEN; i++) {
|
||||
lowpan->addr[i] = ethernet[i];
|
||||
}
|
||||
|
@ -751,8 +791,6 @@ uint8_t mac_createSicslowpanLongAddr(uint8_t * ethernet, uip_lladdr_t * lowpan)
|
|||
*/
|
||||
uint8_t mac_createEthernetAddr(uint8_t * ethernet, uip_lladdr_t * lowpan)
|
||||
{
|
||||
//uint8_t i,j, match;
|
||||
|
||||
|
||||
#if UIP_CONF_SIMPLE_JACKDAW_ADDR_TRANS
|
||||
|
||||
|
@ -769,13 +807,18 @@ uint8_t mac_createEthernetAddr(uint8_t * ethernet, uip_lladdr_t * lowpan)
|
|||
uint8_t index = 0;
|
||||
uint8_t i;
|
||||
|
||||
#if UIP_LLADDR_LEN == 8
|
||||
#if UIP_LLADDR_LEN == 8
|
||||
|
||||
//Special case - if the address is our address, we just copy over what we know to be
|
||||
//our 802.3 address
|
||||
#if RF230BB
|
||||
if (memcmp(uip_lladdr.addr, (uint8_t *)lowpan, 8) == 0) {
|
||||
memcpy(ethernet, &uip_lladdr.addr[2], 6);
|
||||
#else
|
||||
if (memcmp_reverse((uint8_t *)&macLongAddr, (uint8_t *)lowpan, 8) == 0) {
|
||||
memcpy(ethernet, &rndis_ethernet_addr, 6);
|
||||
byte_reverse(ethernet, 6);
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -853,7 +896,7 @@ uint8_t mac_createEthernetAddr(uint8_t * ethernet, uip_lladdr_t * lowpan)
|
|||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if UIP_CONF_SIMPLE_JACKDAW_ADDR_TRANS
|
||||
/**
|
||||
* \brief Create a 802.3 address (default)
|
||||
* \param ethernet Pointer to ethernet address
|
||||
|
@ -864,7 +907,7 @@ uint8_t mac_createDefaultEthernetAddr(uint8_t * ethernet)
|
|||
byte_reverse(ethernet, 6);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* \brief Slide the pointed to memory up a certain amount,
|
||||
* growing/shrinking a buffer
|
||||
|
@ -897,6 +940,7 @@ void slide(uint8_t * data, uint8_t length, int16_t slide)
|
|||
}
|
||||
}
|
||||
|
||||
#if !RF230BB
|
||||
/*--------------------------------------------------------------------*/
|
||||
/** \brief Process a received 6lowpan packet. Hijack function.
|
||||
* \param r The MAC layer
|
||||
|
@ -985,7 +1029,7 @@ void mac_logTXtoEthernet(frame_create_params_t *p,frame_result_t *frame_result)
|
|||
mac_createEthernetAddr((uint8_t *) &(ETHBUF(raw_buf)->src.addr[0]),
|
||||
(uip_lladdr_t *)&tempaddr);
|
||||
|
||||
PRINTF("Low2Eth: Sending 802.15.4 packet to ethernet\n");
|
||||
PRINTF("Low2Eth: Sending 802.15.4 packet to ethernet\n\r");
|
||||
|
||||
sendlen += UIP_LLH_LEN;
|
||||
|
||||
|
@ -1038,7 +1082,7 @@ void mac_802154raw(const struct mac_driver *r)
|
|||
mac_createEthernetAddr((uint8_t *) &(ETHBUF(raw_buf)->src.addr[0]),
|
||||
(uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_SENDER));
|
||||
|
||||
PRINTF("Low2Eth: Sending 802.15.4 packet to ethernet\n");
|
||||
PRINTF("Low2Eth: Sending 802.15.4 packet to ethernet\n\r");
|
||||
|
||||
sendlen += UIP_LLH_LEN;
|
||||
|
||||
|
@ -1061,7 +1105,7 @@ uint8_t memcmp_reverse(uint8_t * a, uint8_t * b, uint8_t num)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* !RF230BB */
|
||||
/** @} */
|
||||
|
||||
|
||||
|
|
|
@ -48,8 +48,10 @@
|
|||
#ifndef SICSLOW_ETHERNET_H
|
||||
#define SICSLOW_ETHERNET_H
|
||||
|
||||
#if !RF230BB
|
||||
#include "sicslowmac.h"
|
||||
#include "frame.h"
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
ll_802154_type,
|
||||
|
@ -75,8 +77,10 @@ int8_t mac_translateIPLinkLayer(lltype_t target);
|
|||
void mac_LowpanToEthernet(void);
|
||||
void mac_ethernetToLowpan(uint8_t * ethHeader);
|
||||
void mac_ethernetSetup(void);
|
||||
#if !RF230BB
|
||||
void mac_802154raw(const struct mac_driver *r);
|
||||
void mac_logTXtoEthernet(frame_create_params_t *p,frame_result_t *frame_result);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue