Add getChecksum() to the AD-SAL TCP class 48/7748/2
authorColin Dixon <colin@colindixon.com>
Thu, 5 Jun 2014 16:41:24 +0000 (11:41 -0500)
committerColin Dixon <colin@colindixon.com>
Thu, 5 Jun 2014 17:17:10 +0000 (12:17 -0500)
Fixing Bug 1145

Change-Id: I62b29ecd0bb640632146b93c97250ba00afbe2fa
Signed-off-by: Colin Dixon <colin@colindixon.com>
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/TCP.java
opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/TCPTest.java

index 4b2badd92db8baa5cde25a3dbb8a7e2f40d9967a..8253ac46d3f5405ace57da8022be90a183645a68 100644 (file)
@@ -230,4 +230,12 @@ public class TCP extends Packet {
         return (BitBufferHelper.getShort(fieldValues.get(DESTPORT)));
     }
 
+    /**
+     * Get the stored checksum value of the TCP header
+     * @return short - the checksum
+     */
+    public short getChecksum() {
+        return (BitBufferHelper.getShort(fieldValues.get(CHECKSUM)));
+    }
+
 }
index 48679c33f287ced6dab0d97141acd4b40d077a4c..3e18aedfdb38b7238ef9a72c9d49bff151aec685 100644 (file)
@@ -104,4 +104,13 @@ public class TCPTest {
         Assert.assertTrue(urgentPointer[1] == 10);
 
     }
+
+    @Test
+    public void testGetChecksum() {
+        TCP tcp = new TCP();
+        byte[] udpChecksum = { 0, -56 };
+        tcp.hdrFieldsMap.put("Checksum", udpChecksum);
+        short checksum = tcp.getChecksum();
+        Assert.assertTrue(checksum == 200);
+    }
 }