Hi,
I try to put rssi and lqi informations into ip6_data.
I've began with the PppRouterC.nc and PppRouterP.nc.
According to the ip.h, there is a structure ip6_metadata which contained
the rssi and the lqi of the L2 layer.
To read my datas, I call:
signal IPForward.recv(iph, payload, infoPower);
According to the component IPForward, there is actually a place for the
ip6_metadata *infoPower. It was at NULL into the PppRouter by default :
signal IPForward.recv(iph, payload, NULL);
Finally, I've supposed that those metadatas were at the end of the
addresses given by:
event error_t PppIpv6.receive(const uint8_t* data, unsigned int len)
That's why I've written:
struct ip6_metadata *infoPower = (struct ip6_metadata *) (iph + len
- 3);
With wireshark, I only see 00 at the expected place of the rssi and the
lqi, on the data.
So my questions are :
Where are the addresses of the metadata, when I receive my IP6
Packet with PppIpv6.receive?
Are those metadatas really at the well layer (L2)? Must I code
something with the Radio to have access to the hardware layer?
Must I change something on the command error_t IPForward.send to
have those metadatas?
I've created the function iov_read(*iov, offset, len, *data) into iovec.c
to overwrite a part of the *iov at the offset and the length given, with
*data.
It works well, because the id = 0x0a is well written into my datas (checked
on Wireshark). So I don't think it's my function.
If you can point me or give me a suggestion about this problem, I will
really appreciate.
Many Thanks,
Léo
---------------------------
--- Configuration ---
---------------------------
#include <iprouting.h>
#include "ppp.h"
#include "RssiMessages.h"
#include "message.h"
configuration PppRouterC {
}
implementation {
components PppRouterP;
components MainC;
PppRouterP.Boot -> MainC;
components LedsC as LedsC;
PppRouterP.Leds -> LedsC;
components PppDaemonC;
PppRouterP.PppControl -> PppDaemonC;
components PppIpv6C;
PppDaemonC.PppProtocol[PppIpv6C.ControlProtocol] ->
PppIpv6C.PppControlProtocol;
PppDaemonC.PppProtocol[PppIpv6C.Protocol] -> PppIpv6C.PppProtocol;
PppIpv6C.Ppp -> PppDaemonC;
PppIpv6C.LowerLcpAutomaton -> PppDaemonC;
PppRouterP.Ipv6LcpAutomaton -> PppIpv6C;
PppRouterP.PppIpv6 -> PppIpv6C;
PppRouterP.Ppp -> PppDaemonC;
#if defined(PLATFORM_TELOSB) || defined(PLATFORM_EPIC)
components PlatformHdlcUartC as HdlcUartC;
#else
components DefaultHdlcUartC as HdlcUartC;
#endif
PppDaemonC.HdlcUart -> HdlcUartC;
PppDaemonC.UartControl -> HdlcUartC;
// SDH : don't bother including the PppPrintfC by default
// components PppPrintfC, PppC;;
// PppPrintfC.Ppp -> PppDaemonC;
// PppDaemonC.PppProtocol[PppPrintfC.Protocol] -> PppPrintfC;
// PppPrintfC.Ppp -> PppC;
components IPStackC, IPForwardingEngineP, IPPacketC;
IPForwardingEngineP.IPForward[ROUTE_IFACE_PPP] -> PppRouterP.IPForward;
PppRouterP.IPControl -> IPStackC;
PppRouterP.ForwardingTable -> IPStackC;
PppRouterP.IPPacket -> IPPacketC;
#ifdef RPL_ROUTING
components RPLRoutingC, RplBorderRouterP;
PppRouterP.RootControl -> RPLRoutingC;
RplBorderRouterP.ForwardingEvents ->
IPStackC.ForwardingEvents[ROUTE_IFACE_PPP];
RplBorderRouterP.IPPacket -> IPPacketC;
#endif
// UDP shell on port 2000
components UDPShellC;
// prints the routing table
// components RouteCmdC;
#ifndef IN6_PREFIX
components Dhcp6ClientC;
PppRouterP.Dhcp6Info -> Dhcp6ClientC;
#endif
}
-------------------------------
--- Implementation ---
-------------------------------
#include <stdio.h>
#include <lib6lowpan/ip.h>
#include <lib6lowpan/nwbyte.h>
#include <lib6lowpan/ip_malloc.h>
#include <dhcp6.h>
#include "pppipv6.h"
#include "blip_printf.h"
#include "RssiMessages.h"
module PppRouterP {
provides {
interface IPForward;
}
uses {
interface Boot;
interface Leds;
interface SplitControl as IPControl;
interface SplitControl as PppControl;
interface LcpAutomaton as Ipv6LcpAutomaton;
interface PppIpv6;
interface Ppp;
interface ForwardingTable;
interface RootControl;
interface Dhcp6Info;
interface IPPacket;
}
}
implementation {
uint8_t rssi;
uint8_t lqi;
event void PppIpv6.linkUp() {}
event void PppIpv6.linkDown() {}
event void Ipv6LcpAutomaton.transitionCompleted (LcpAutomatonState_e
state) { }
event void Ipv6LcpAutomaton.thisLayerUp () { }
event void Ipv6LcpAutomaton.thisLayerDown () { }
event void Ipv6LcpAutomaton.thisLayerStarted () { }
event void Ipv6LcpAutomaton.thisLayerFinished () { }
event void PppControl.startDone (error_t error) { }
event void PppControl.stopDone (error_t error) { }
event void IPControl.startDone (error_t error) {
struct in6_addr dhcp6_group;
// add a route to the dhcp group on PPP, not the radio (which is the
default)
inet_pton6(DH6ADDR_ALLAGENT, &dhcp6_group);
call ForwardingTable.addRoute(dhcp6_group.s6_addr, 128, NULL,
ROUTE_IFACE_PPP);
// add a default route through the PPP link
call ForwardingTable.addRoute(NULL, 0, NULL, ROUTE_IFACE_PPP);
}
event void IPControl.stopDone (error_t error) { }
event void Boot.booted() {
error_t rc;
#ifndef PRINTFUART_ENABLED
rc = call Ipv6LcpAutomaton.open();
rc = call PppControl.start();
#endif
#ifdef RPL_ROUTING
call RootControl.setRoot();
#endif
#ifndef IN6_PREFIX
call Dhcp6Info.useUnicast(FALSE);
#endif
call IPControl.start();
}
event error_t PppIpv6.receive(const uint8_t* data,
unsigned int len) {
struct ip6_hdr *iph = (struct ip6_hdr *)data;
void *payload = (iph + 1);
error_t rc;
struct ip6_metadata *infoPower = (struct ip6_metadata *) (iph + len
- 3);
rssi = infoPower->rssi;
lqi = infoPower->lqi;
call Leds.led0Toggle();
signal IPForward.recv(iph, payload, infoPower);
//signal IPForward.recv(iph, payload, NULL);
return SUCCESS;
}
command error_t IPForward.send(struct in6_addr *next_hop,
struct ip6_packet *msg,
void *data) {
// Size (bytes)
// Note there are 8 bytes for the UDP Protocol
size_t len = iov_len(msg->ip6_data) + sizeof(struct ip6_hdr);
size_t offPow = 28;
error_t rc;
frame_key_t key;
const uint8_t* fpe;
uint8_t* fp;
uint8_t id = 0x0a;
if (!call PppIpv6.linkIsUp())
return EOFF;
// get an output frame
fp = call Ppp.getOutputFrame(PppProtocol_Ipv6, &fpe, FALSE, &key);
if ((! fp) || ((fpe - fp) < len)) {
if (fp) {
call Ppp.releaseOutputFrame(key);
}
call Leds.led2Toggle();
return ENOMEM;
}
// copy the header and body into the frame
memcpy(fp, &msg->ip6_hdr, sizeof(struct ip6_hdr));
// modif of the part of the data concerning rssi and lqi
iov_modif(msg->ip6_data, offPow, 1, &id);
iov_modif(msg->ip6_data, offPow + 1, 1, &rssi);
iov_modif(msg->ip6_data, offPow + 2, 1, &lqi);
// reading all the ip6_data after modifications
iov_read(msg->ip6_data, 0, len, fp + sizeof(struct ip6_hdr));
rc = call Ppp.fixOutputFrameLength(key, fp + len);
if (SUCCESS == rc) {
rc = call Ppp.sendOutputFrame(key);
}
call Leds.led1Toggle();
return rc;
}
event void Ppp.outputFrameTransmitted (frame_key_t key,
error_t err) { }
}
<[email protected]>
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help