[Tinyos-beta-commits] CVS: tinyos-1.x/beta/Deluge/delugetools
DelugeCrc.java, 1.1, 1.2 Downloader.java, 1.1,
1.2 ImageInjector.java, 1.7, 1.8 TOSBootImage.java, 1.5, 1.6
Jonathan Hui
jwhui at users.sourceforge.net
Tue Jun 28 18:21:22 PDT 2005
Update of /cvsroot/tinyos/tinyos-1.x/beta/Deluge/delugetools
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5225
Modified Files:
DelugeCrc.java Downloader.java ImageInjector.java
TOSBootImage.java
Log Message:
Include unique identifier for program image in image
descriptor. Allows the PC-side tools to determine if an image is
identical to another. Of course, there is a slight chance for false
positives but worst case scenario is to submit a Deluge erase command
to the network. The previous method to identifiy images required the
first page of the image to be disseminated had a race condition where
an injection could happen after the image descriptor is disseminated
but before the first page of the image.
Index: DelugeCrc.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/delugetools/DelugeCrc.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** DelugeCrc.java 17 Jan 2005 19:48:17 -0000 1.1
--- DelugeCrc.java 29 Jun 2005 01:21:20 -0000 1.2
***************
*** 62,66 ****
advMsg.set_nodeDesc_crc(crc);
! start = DelugeAdvMsg.offset_imgDesc_vNum();
stop = DelugeAdvMsg.offset_imgDesc_crc();
--- 62,66 ----
advMsg.set_nodeDesc_crc(crc);
! start = DelugeAdvMsg.offset_imgDesc_uid();
stop = DelugeAdvMsg.offset_imgDesc_crc();
Index: Downloader.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/delugetools/Downloader.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Downloader.java 21 Jun 2005 23:38:12 -0000 1.1
--- Downloader.java 29 Jun 2005 01:21:20 -0000 1.2
***************
*** 128,131 ****
--- 128,132 ----
out.write(" <hostname>" + receivedImage.getHostname() + "</hostname>\n");
out.write(" <user_hash>" + Long.toHexString(receivedImage.getUserHash()).toUpperCase() + "L</user_hash>\n");
+ out.write(" <uid_hash>" + Long.toHexString(receivedImage.getUIDHash()).toUpperCase() + "L</uid_hash>\n");
out.write(" </ident>\n");
out.write(" <image format=\"ihex\">\n");
Index: ImageInjector.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/delugetools/ImageInjector.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** ImageInjector.java 27 Jun 2005 22:38:18 -0000 1.7
--- ImageInjector.java 29 Jun 2005 01:21:20 -0000 1.8
***************
*** 82,85 ****
--- 82,86 ----
advMsg.set_sourceAddr(pinger.getPCAddr());
advMsg.set_type(DelugeConsts.DELUGE_ADV_PC);
+ advMsg.set_imgDesc_uid(newTOSBootImage.getUIDHash());
advMsg.set_imgDesc_vNum(DelugeConsts.DELUGE_INVALID_VNUM);
advMsg.set_imgDesc_numPgs(delugeImage.getNumPages());
***************
*** 103,107 ****
}
! if (pingReply.get_imgDesc_numPgsComplete() == 0) {
System.out.println("Replace empty image with:");
System.out.println(" Image: " + pingReply.get_imgDesc_imgNum());
--- 104,108 ----
}
! if (pingReply.get_imgDesc_numPgs() == 0) {
System.out.println("Replace empty image with:");
System.out.println(" Image: " + pingReply.get_imgDesc_imgNum());
***************
*** 111,115 ****
newVersion = 0;
}
! else if (oldTOSBootImage.equalTo(newTOSBootImage)) {
if (pingReply.get_imgDesc_numPgsComplete() == pingReply.get_imgDesc_numPgs()) {
System.out.println("ERROR: Image already injected:");
--- 112,116 ----
newVersion = 0;
}
! else if (pingReply.get_imgDesc_uid() == newTOSBootImage.getUIDHash()) {
if (pingReply.get_imgDesc_numPgsComplete() == pingReply.get_imgDesc_numPgs()) {
System.out.println("ERROR: Image already injected:");
***************
*** 121,125 ****
System.out.println("Resume injection of image:");
System.out.println(" Image: " + pingReply.get_imgDesc_imgNum());
! System.out.println(oldTOSBootImage);
newVersion = pingReply.get_imgDesc_vNum();
}
--- 122,126 ----
System.out.println("Resume injection of image:");
System.out.println(" Image: " + pingReply.get_imgDesc_imgNum());
! System.out.println(newTOSBootImage);
newVersion = pingReply.get_imgDesc_vNum();
}
Index: TOSBootImage.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/delugetools/TOSBootImage.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** TOSBootImage.java 27 Jun 2005 22:38:19 -0000 1.5
--- TOSBootImage.java 29 Jun 2005 01:21:20 -0000 1.6
***************
*** 44,47 ****
--- 44,48 ----
private final static int UNIX_TIME_SIZE = 4;
private final static int USER_HASH_SIZE = 4;
+ private final static int UID_HASH_SIZE = 4;
private String name; // 16
***************
*** 52,55 ****
--- 53,57 ----
private long unixTime; // 4
private long userHash; // 4
+ private long uidHash; // 4
private boolean delugeSupport = false;
***************
*** 67,71 ****
File file = new File(filename);
if (!file.exists()) {
! throw new IllegalArgumentException( "no such file "+filename );
}
--- 69,73 ----
File file = new File(filename);
if (!file.exists()) {
! throw new IllegalArgumentException( "no such file " + filename );
}
***************
*** 94,97 ****
--- 96,103 ----
userHash = Long.parseLong(tmp.substring(0,tmp.indexOf('L')),16);
+ nlist=doc.getElementsByTagName("uid_hash");
+ tmp = nlist.item(0).getFirstChild().getNodeValue();
+ uidHash = Long.parseLong(tmp.substring(0,tmp.indexOf('L')),16);
+
nlist=doc.getElementsByTagName("platform");
tmp = nlist.item(0).getFirstChild().getNodeValue();
***************
*** 178,181 ****
--- 184,191 ----
userHash |= (long)(bytes[curOffset++] & 0xff) << (i*8);
+ uidHash = 0;
+ for ( int i = 0; i < UID_HASH_SIZE; i++ )
+ uidHash |= (long)(bytes[curOffset++] & 0xff) << (i*8);
+
delugeSupport = ( bytes[curOffset++] != 0 ) ? true : false;
***************
*** 214,217 ****
--- 224,230 ----
bytes[curOffset++] = (byte)((userHash >> (8*i)) & 0xff);
+ for ( int i = 0; i < 4; i++ )
+ bytes[curOffset++] = (byte)((uidHash >> (8*i)) & 0xff);
+
bytes[curOffset++] = (byte)((delugeSupport) ? 0x1 : 0x0);
***************
*** 236,245 ****
}
- public boolean equalTo(TOSBootImage cmp) {
- return (name.compareTo(cmp.getName()) == 0
- && unixTime == cmp.getUnixTime()
- && userHash == cmp.getUserHash());
- }
-
public String toString() {
Date date = new Date(unixTime*1000);
--- 249,252 ----
***************
*** 259,262 ****
--- 266,270 ----
public long getUnixTime() { return unixTime; }
public long getUserHash() { return userHash; }
+ public long getUIDHash() { return uidHash; }
public boolean getDelugeSupport() { return delugeSupport; }
More information about the Tinyos-beta-commits
mailing list