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 4b2badd..8253ac4 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 48679c3..3e18aed 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);
+    }
 }