]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Commit changes to remove warnings in TestSecurity/ and solve functioning issues with...
authorjgko <jgko>
Wed, 28 Oct 2009 21:09:52 +0000 (21:09 +0000)
committerjgko <jgko>
Wed, 28 Oct 2009 21:09:52 +0000 (21:09 +0000)
tos/chips/cc2420/receive/CC2420ReceiveP.nc
tos/chips/cc2420/transmit/CC2420TransmitP.nc

index b69cd577d72207d88faf032f777e0b9d88c3189f..4d9c055508a397292798b0fefba7a86af54b3c09 100644 (file)
@@ -468,9 +468,9 @@ implementation {
 
          call CSN.clr();
 #ifndef TFRAMES_ENABLED
-         atomic call SECCTRL1.write(skip+11+sizeof(security_header_t))+((skip+11+sizeof(security_header_t))<<8);
+         atomic call SECCTRL1.write(skip+11+sizeof(security_header_t)+((skip+11+sizeof(security_header_t))<<8));
 #else
-         atomic call SECCTRL1.write(skip+10+sizeof(security_header_t))+((skip+10+sizeof(security_header_t))<<8);
+         atomic call SECCTRL1.write(skip+10+sizeof(security_header_t)+((skip+10+sizeof(security_header_t))<<8));
 #endif
          call CSN.set();
 
index 09917c96f38e5541fdaa7113df3fe5e5859669bd..87898e2c5d759adf32ad320a21f17b3b93db7571 100644 (file)
@@ -601,13 +601,6 @@ implementation {
   }
 #ifdef CC2420_HW_SECURITY
 
-  /*
-  inline void uwait(uint16_t u) {
-    uint16_t t0 = TAR;
-    while((TAR - t0) <= u);
-  }
-  */
-
   task void waitTask(){
     call Leds.led2Toggle();
     if(SECURITYLOCK == 1){
@@ -625,11 +618,21 @@ implementation {
     uint8_t mode;
     uint8_t key;
     uint8_t micLength;
-    uint16_t currentStatus;
 
     msg_header = call CC2420PacketBody.getHeader( m_msg );
 
     if(!(msg_header->fcf & (1 << IEEE154_FCF_SECURITY_ENABLED))){
+      // Security is not used for this packet
+      // Make sure to set mode to 0 and the others to the default values
+      CTR_SECCTRL0 = ((0 << CC2420_SECCTRL0_SEC_MODE) |
+                     (1 << CC2420_SECCTRL0_SEC_M) |
+                     (1 << CC2420_SECCTRL0_SEC_TXKEYSEL) |
+                     (1 << CC2420_SECCTRL0_SEC_CBC_HEAD)) ;
+      
+      call CSN.clr();
+      call SECCTRL0.write(CTR_SECCTRL0);
+      call CSN.set();
+
       return;
     }
 
@@ -678,9 +681,9 @@ implementation {
                      (key << CC2420_SECCTRL0_SEC_TXKEYSEL) |
                      (1 << CC2420_SECCTRL0_SEC_CBC_HEAD)) ;
 #ifndef TFRAMES_ENABLED
-      CTR_SECCTRL1 = (skip+11+sizeof(security_header_t))+((skip+11+sizeof(security_header_t))<<8);
+      CTR_SECCTRL1 = (skip+11+sizeof(security_header_t)+((skip+11+sizeof(security_header_t))<<8));
 #else
-      CTR_SECCTRL1 = (skip+10+sizeof(security_header_t))+((skip+10+sizeof(security_header_t))<<8);
+      CTR_SECCTRL1 = (skip+10+sizeof(security_header_t)+((skip+10+sizeof(security_header_t))<<8));
 #endif
 
       call CSN.clr();
@@ -700,23 +703,12 @@ implementation {
       call CSN.set();
 
       while(status & CC2420_STATUS_ENC_BUSY){
-       //uwait(1*1024);
        call CSN.clr();
        status = call SNOP.strobe();
        call CSN.set();
       }
-
-      call CSN.clr();
-      call STXENC.strobe();
-      call CSN.set();
-
-      call CSN.clr();
-      call SECCTRL0.read(&currentStatus);
-      call CSN.set();
-
-      call CSN.clr();
-      call SECCTRL0.write(currentStatus && ~(3 << CC2420_SECCTRL0_SEC_MODE));
-      call CSN.set();
+      
+      // Inline security will be activated by STXON or STXONCCA strobes
 
       atomic SECURITYLOCK = 0;
 
@@ -736,6 +728,9 @@ implementation {
    *
    * If the packet got sent, we should expect an SFD interrupt to take
    * over, signifying the packet is getting sent.
+   * 
+   * If security is enabled, STXONCCA or STXON will perform inline security
+   * options before transmitting the packet.
    */
   void attemptSend() {
     uint8_t status;