Promiscuity can be turned off in CCSPI.
[goodfet] / client / GoodFETCCSPI.py
index fbf944f..5ea56be 100644 (file)
@@ -132,6 +132,11 @@ class GoodFETCCSPI(GoodFET):
         fsctrl=self.peek(0x18);
         mhz=2048+(fsctrl&0x3ff)
         return mhz*1000000;
+    def RF_setchan(self,channel):
+        if channel < 11 and channel > 26:
+            print "Only 802.15.4 channels 11 to 26 are currently supported.";
+        else:
+            self.RF_setfreq( ( (channel-11)*5 + 2405 ) * 1000000 );
     def RF_getsmac(self):
         """Return the source MAC address."""
         return 0xdeadbeef;
@@ -236,9 +241,10 @@ class GoodFETCCSPI(GoodFET):
 
     def RF_promiscuity(self,promiscuous=1):
         mdmctrl0=self.peek(0x11);
-        #print "mdmctrl0 was %04x" % mdmctrl0;
-        mdmctrl0=mdmctrl0&(~0x800);
-        #print "mdmctrl0 is now %04x" % mdmctrl0;
+        if promiscuous>0:
+            mdmctrl0=mdmctrl0&(~0x800);
+        else:
+            mdmctrl0=mdmctrl0|0x800;
         self.poke(0x11,mdmctrl0);
         return;
         
@@ -272,11 +278,16 @@ class GoodFETCCSPI(GoodFET):
         for foo in packet:
             s="%s %02x" % (s,ord(foo));
         print "#%s" % s;
-    def printdisect(self,packet):
+    def printdissect(self,packet):
         try:
             from scapy.all import Dot15d4
         except ImportError:
             print "To use packet disection, Scapy must be installed and have the Dot15d4 extension present."
-        self.printpacket(packet)
-        scapyd = Dot15d4(packet)
-        print scapyd.show()
+            print "try: hg clone http://hg.secdev.org/scapy-com";
+            print "     sudo ./setup.py install";
+        self.printpacket(packet);
+        try:
+            scapyd = Dot15d4(packet[1:]);
+            scapyd.show();
+        except:
+            pass;