1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

implemented 48bit mac to eui64 conversion

This commit is contained in:
Stephan Zeisberg 2010-10-06 17:15:05 +02:00
parent 668eb658d0
commit bba315e93f
4 changed files with 64 additions and 1 deletions

20
sys/net/sixlowmac.c Normal file
View File

@ -0,0 +1,20 @@
/* 6LoWPAN MAC - layer 2 implementations */
#include "sixlowmac.h"
#include "drivers/cc110x/cc1100.h"
#include <stdio.h>
#include <stdint.h>
static void init_msba2_mac(mac_addr addr){
addr.oui1 = MSBA2_OUI >> 8;
addr.oui2 = 0x0 | MSBA2_OUI;
addr.ext_ident = MSBA2_R8BIT;
addr.ext_ident = cc1100_get_address();
}
static void init_mac_address(mac_addr addr){
#ifdef SIXLOWPAN_MSBA2
init_msba2_mac(addr);
#endif
}

11
sys/net/sixlowmac.h Normal file
View File

@ -0,0 +1,11 @@
/* 6LoWPAN MAC header file */
#define MSBA2_OUI 0x005BA2 // 24bit OUI
#define MSBA2_R8BIT 0xA2 // random 8bit
typedef struct mac_addr{
uint16_t oui_1;
uint8_t oui_2;
uint8_t ext_ident_1; // MSBA2_R8BIT
uint16_t ext_ident_2; // radio address
} mac_addr;

View File

@ -1,5 +1,9 @@
/* 6LoWPAN layer 3 implementation */
#include <stdio.h>
#include "drivers/cc110x/cc1100.h"
#include "sixlowmac.h"
static void output(void){
@ -14,3 +18,20 @@ static void output(void){
// fragn dispatch
// set fragments into queue and send it
}
/* convert 48-bit MAC address to IPv6 modified EUI-64 Identifier*/
static eui64 get_eui64_from_mac(void){
mac_addr maddr;
eui64 ident;
init_mac_address(maddr);
/* change bit 7 from oui1 to 1 */
ident.oui1 = (maddr.oui_1 >> 8) | 0x2;
ident.oui2 = (maddr.oui_1 << 8) | maddr.oui_2;
ident.pattern = MAC_TO_EUI64_PTRN;
ident.ext_ident_1 = maddr.ext_ident_1;
ident.ext_ident_2 = maddr.ext_ident_1;
return ident;
}

View File

@ -2,4 +2,15 @@
#define FRAG1_HDR_LEN 32 // in bit
#define FRAGN_HDR_LEN 40 // in bit
#define FRAG1_DISPATCH 0xC0 // 11000000
#define FRAGN_DISPATCH 0xE0 // 11100000
#define FRAGN_DISPATCH 0xE0 // 11100000
/* 48-bit MAC to EUI64 pattern */
#define MAC_TO_EUI64_PTRN 0xFFFE
typedef struct eui64{
uint8_t oui_1;
uint16_t oui_2;
uint16_t pattern;
uint8_t ext_ident_1;
uint16_t ext_ident_2;
} eui64;