Skip to content

Commit

Permalink
Merge branch 'develop' into develop_FW-407
Browse files Browse the repository at this point in the history
Conflicts:
	openstack/03a-IPHC/iphc.c
  • Loading branch information
changtengfei committed Jul 1, 2015
2 parents d4f634c + 6bdb50d commit f55dd78
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 22 deletions.
2 changes: 1 addition & 1 deletion openapps/openapps.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ void openapps_init(void) {
techo_init();
// UDP
uecho_init();
uinject_init();
//uinject_init();
}
30 changes: 16 additions & 14 deletions openstack/02a-MAClow/IEEE802154.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ void ieee802154_prependHeader(OpenQueueEntry_t* msg,
// add termination IE accordingly
if (payloadIEPresent == TRUE) {
ielistpresent = IEEE154_IELIST_YES;
frameVersion = IEEE154_FRAMEVERSION;
//add header termination IE (id=0x7e)
packetfunctions_reserveHeaderSize(msg,TerminationIE_Length);
msg->payload[0] = Header_PayloadIE_TerminationIE & 0xFF;
Expand All @@ -78,7 +77,6 @@ void ieee802154_prependHeader(OpenQueueEntry_t* msg,
// no need for termination IE.
if (headerIEPresent == TRUE){
ielistpresent = IEEE154_IELIST_YES;
frameVersion = IEEE154_FRAMEVERSION;
packetfunctions_reserveHeaderSize(msg,TerminationIE_Length);
msg->payload[0] = Header_Payload_TerminationIE & 0xFF;
msg->payload[1] = (Header_Payload_TerminationIE >> 8) & 0xFF;
Expand All @@ -90,10 +88,8 @@ void ieee802154_prependHeader(OpenQueueEntry_t* msg,
// no payload, termination IE is omitted. check whether timeCorrection IE
// presents.
if (frameType != IEEE154_TYPE_ACK) {
frameVersion = IEEE154_FRAMEVERSION_2006;
} else {
ielistpresent = IEEE154_IELIST_YES; // I will have a timeCorrection IE later
frameVersion = IEEE154_FRAMEVERSION;
}
}
}
Expand Down Expand Up @@ -146,9 +142,9 @@ void ieee802154_prependHeader(OpenQueueEntry_t* msg,
}
// destpan -- se page 41 of 15.4-2011 std. DEST PANID only sent as it is equal to SRC PANID
packetfunctions_writeAddress(msg,idmanager_getMyID(ADDR_PANID),OW_LITTLE_ENDIAN);
//dsn
packetfunctions_reserveHeaderSize(msg,sizeof(uint8_t));
*((uint8_t*)(msg->payload)) = sequenceNumber;

//dsn is suppressed

//fcf (2nd byte)
packetfunctions_reserveHeaderSize(msg,sizeof(uint8_t));
temp_8b = 0;
Expand All @@ -168,7 +164,8 @@ void ieee802154_prependHeader(OpenQueueEntry_t* msg,
temp_8b |= IEEE154_ADDR_EXT << IEEE154_FCF_SRC_ADDR_MODE;
//poipoi xv IE list present
temp_8b |= ielistpresent << IEEE154_FCF_IELIST_PRESENT;
temp_8b |= frameVersion << IEEE154_FCF_FRAME_VERSION;
temp_8b |= IEEE154_FRAMEVERSION_2012 << IEEE154_FCF_FRAME_VERSION;
temp_8b |= IEEE154_DSN_SUPPRESSION_YES << IEEE154_FCF_DSN_SUPPRESSION;

*((uint8_t*)(msg->payload)) = temp_8b;
//fcf (1st byte)
Expand Down Expand Up @@ -223,8 +220,9 @@ void ieee802154_retrieveHeader(OpenQueueEntry_t* msg,
//poipoi xv IE list present
ieee802514_header->ieListPresent = (temp_8b >> IEEE154_FCF_IELIST_PRESENT ) & 0x01;//1b
ieee802514_header->frameVersion = (temp_8b >> IEEE154_FCF_FRAME_VERSION ) & 0x03;//2b
ieee802514_header->dsn_suppressed = (temp_8b >> IEEE154_FCF_DSN_SUPPRESSION ) & 0x01;//1b

if (ieee802514_header->ieListPresent==TRUE && ieee802514_header->frameVersion!=IEEE154_FRAMEVERSION){
if (ieee802514_header->ieListPresent==TRUE && ieee802514_header->frameVersion!=IEEE154_FRAMEVERSION_2012){
return; //invalid packet accordint to p.64 IEEE15.4e
}

Expand Down Expand Up @@ -261,10 +259,14 @@ void ieee802154_retrieveHeader(OpenQueueEntry_t* msg,
return; // this is an invalid packet, return
}
ieee802514_header->headerLength += 1;
// sequenceNumber
if (ieee802514_header->headerLength>msg->length) { return; } // no more to read!
ieee802514_header->dsn = *((uint8_t*)(msg->payload)+ieee802514_header->headerLength);
ieee802514_header->headerLength += 1;

if (ieee802514_header->dsn_suppressed==FALSE) {
// sequenceNumber
if (ieee802514_header->headerLength>msg->length) { return; } // no more to read!
ieee802514_header->dsn = *((uint8_t*)(msg->payload)+ieee802514_header->headerLength);
ieee802514_header->headerLength += 1;
}

// panID
if (ieee802514_header->headerLength>msg->length) { return; } // no more to read!
packetfunctions_readAddress(((uint8_t*)(msg->payload)+ieee802514_header->headerLength),
Expand Down Expand Up @@ -320,7 +322,7 @@ void ieee802154_retrieveHeader(OpenQueueEntry_t* msg,
// no need for a default, since case would have been caught above
}

if (ieee802514_header->ieListPresent==TRUE && ieee802514_header->frameVersion!=IEEE154_FRAMEVERSION){
if (ieee802514_header->ieListPresent==TRUE && ieee802514_header->frameVersion!=IEEE154_FRAMEVERSION_2012){
return; //invalid packet accordint to p.64 IEEE15.4e
}

Expand Down
9 changes: 8 additions & 1 deletion openstack/02a-MAClow/IEEE802154.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ enum IEEE802154_fcf_enums {
IEEE154_FCF_DEST_ADDR_MODE = 2,
IEEE154_FCF_FRAME_VERSION = 4,
IEEE154_FCF_SRC_ADDR_MODE = 6,
IEEE154_FCF_DSN_SUPPRESSION = 0,
};


enum IEEE802154_fcf_frameversion_enums {
IEEE154_FRAMEVERSION_2003 = 0, //ieee154-2003
IEEE154_FRAMEVERSION_2006 = 1, //ieee154-2006
IEEE154_FRAMEVERSION = 2, //ieee154
IEEE154_FRAMEVERSION_2012 = 2, //ieee154e-2012
};

enum IEEE802154_fcf_type_enums {
Expand All @@ -49,6 +50,11 @@ enum IEEE802154_fcf_ielist_enums {
IEEE154_IELIST_YES = 1,
};

enum IEEE802154_fcf_dsn_enums {
IEEE154_DSN_SUPPRESSION_NO = 0,
IEEE154_DSN_SUPPRESSION_YES = 1,
};

enum IEEE802154_fcf_pending_enums {
IEEE154_PENDING_NO_FRAMEPENDING = 0,
IEEE154_PENDING_YES_FRAMEPENDING = 1,
Expand Down Expand Up @@ -118,6 +124,7 @@ typedef struct {
bool ieListPresent;
uint8_t frameVersion;
uint8_t dsn;
bool dsn_suppressed;
open_addr_t panid;
open_addr_t dest;
open_addr_t src;
Expand Down
4 changes: 4 additions & 0 deletions openstack/02b-MAChigh/neighbors.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,12 +435,16 @@ The fields which are updated are:
*/
void neighbors_indicateRxDIO(OpenQueueEntry_t* msg) {
uint8_t i;
uint8_t temp_8b;

// take ownership over the packet
msg->owner = COMPONENT_NEIGHBORS;

// update rank of that neighbor in table
neighbors_vars.dio = (icmpv6rpl_dio_ht*)(msg->payload);
// retrieve rank
temp_8b = *(msg->payload+2);
neighbors_vars.dio->rank = (temp_8b << 8) + *(msg->payload+3);
if (isNeighbor(&(msg->l2_nextORpreviousHop))==TRUE) {
for (i=0;i<MAXNUMNEIGHBORS;i++) {
if (isThisRowMatching(&(msg->l2_nextORpreviousHop),i)) {
Expand Down
8 changes: 4 additions & 4 deletions openstack/03a-IPHC/iphc.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ owerror_t iphc_sendFromForwarding(
}
} else {
//not the same prefix. so the packet travels to another network
//check if this is a source routing pkt. in case it is then the DAM is elided as it is in the SrcRouting header.
if (packetfunctions_isBroadcastMulticast(&(msg->l3_destinationAdd))==FALSE){
//check if this is a source routing pkt. in case it is then the DAM is elided as it is in the SrcRouting header.
if (packetfunctions_isBroadcastMulticast(&(msg->l3_destinationAdd))==FALSE){
if(ipv6_outer_header->next_header!=IANA_IPv6ROUTE){
sam = IPHC_SAM_128B;
dam = IPHC_DAM_128B;
Expand All @@ -145,11 +145,11 @@ owerror_t iphc_sendFromForwarding(
p_dest = NULL;
p_src = &(msg->l3_sourceAdd);
}
} else {
} else {
// this is DIO, source address elided, multicast bit is set
sam = IPHC_SAM_ELIDED;
m = IPHC_M_YES;
dam = IPHC_DAM_ELIDED;
dam = IPHC_DAM_ELIDED;
p_dest = &(msg->l3_destinationAdd);
p_src = &(msg->l3_sourceAdd);
}
Expand Down
4 changes: 4 additions & 0 deletions openstack/03b-IPv6/icmpv6rpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@ void sendDIO() {
sizeof(icmpv6rpl_dio_ht)
);

// reverse the rank bytes order in Big Endian
*(msg->payload+2) = (icmpv6rpl_vars.dio.rank >> 8) & 0xFF;
*(msg->payload+3) = icmpv6rpl_vars.dio.rank & 0xFF;

//===== ICMPv6 header
packetfunctions_reserveHeaderSize(msg,sizeof(ICMPv6_ht));
((ICMPv6_ht*)(msg->payload))->type = msg->l4_sourcePortORicmpv6Type;
Expand Down
7 changes: 5 additions & 2 deletions openstack/03b-IPv6/icmpv6rpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@
#define TIMER_DIO_TIMEOUT 1700
#define TIMER_DAO_TIMEOUT 10000

#define MOP_DIO_A 1<<5
#define MOP_DIO_B 1<<4
// Non-Storing Mode of Operation (1)
#define MOP_DIO_A 0<<5
#define MOP_DIO_B 0<<4
#define MOP_DIO_C 1<<3
// least preferred (0)
#define PRF_DIO_A 0<<2
#define PRF_DIO_B 0<<1
#define PRF_DIO_C 0<<0
// Grounded (1)
#define G_DIO 1<<7

#define FLAG_DAO_A 0<<0
Expand Down

0 comments on commit f55dd78

Please sign in to comment.