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

extended ip.h function and router solicitation send method

This commit is contained in:
Stephan Zeisberg 2010-10-14 13:10:52 +02:00
parent e118393cc2
commit 1c343bf186
2 changed files with 53 additions and 8 deletions

View File

@ -2,22 +2,57 @@
#include <stdint.h>
/* set maximum transmission unit */
#ifdef MSBA2_SENSOR_NODE
#define MTU 0x3A
#else
#define MTU 0x0
#endif
#define IPV6_VERSION 0x60
#define ICMP_NEXTHEADER 0x3A
#define NEIGHBOR_DISCOVERY_HOPLIMIT 255
#define NEIGHBOR_DISCOVERY_HOPLIMIT 0xFF
#define ICMP_HEADER_LENGTH 0x4
#define IPV6_HEADER_LENGTH 0x28
/* link layer protocol control information length*/
#ifdef MSBA2_SENSOR_NODE
#define LL_HEADER_LENGTH 0x4
#else
#define LL_HEADER_LENGTH 0x0
#endif
#define BUFFER_SIZE (LL_HEADER_LENGTH + MTU)
uint8_t ipv6_ext_hdr_len = 0;
#define LLHDR_IPV6HDR_LENGTH (LL_HEADER_LENGTH + IPV6_HEADER_LENGTH + ipv6_ext_hdr_len)
/* global buffer*/
uint8_t[BUFFER_SIZE] buffer;
typedef struct icmp_hdr{
/* ipv6 extension header length */
typedef union ipv6_addr{
uint8_t uint8[16];
uint16_t uint16[8];
} ipv6_addr;
struct icmpv6_hdr{
uint8_t type;
uint8_t code;
uint16_t checksum;
} icmp_hdr;
};
typedef struct ip_hdr{
struct ipv6_hdr{
uint8_t version_trafficclass;
uint8_t trafficclass_flowlabel;
uint16_t flowlabel;
uint16_t length;
uint8_t nextheader;
uint8_t hoplimit;
} ip_hdr;
ipv6_addr srcaddr;
ipv6_addr destaddr;
};

View File

@ -1,11 +1,14 @@
/* 6LoWPAN/IPv6 Neighbor Discovery implementation*/
#include "sixlowip.h"
#include "sixlownd.h"
#include <stdio.h>
#define (struct *ipv6_hdr)&buffer[LL_HEADER_LENGTH]
/* send router solicitation message - RFC4861 section 4.1 */
void send_rs(icmp_hdr *icmphdr, ip_hdr *iphdr){
create_all_routers_multicast_addr();
void send_rs(icmpv6_hdr *icmphdr, ipv6_hdr *iphdr){
create_all_routers_multicast_addr(iphdr->destaddr);
icmphdr->type = ICMP_ROUTER_SOLICITATION;
icmphdr->code = 0;
@ -16,7 +19,14 @@ void send_rs(icmp_hdr *icmphdr, ip_hdr *iphdr){
iphdr->flowlabel = 0;
iphdr->nextheader = ICMP_NEXTHEADER;
iphdr->hoplimit = NEIGHBOR_DISCOVERY_HOPLIMIT;
/* icmp header len + rs header len + slla option len*/
iphdr->length = ICMP_HEADER_LEN + RS_LEN + LLOA_OPT_LEN;
set_llao();
}
void set_llao(void){
}
void recv_rs(void){