Code Review
/
controller.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
BUG-1393 Fix ignoring module based capabilities in sal-netconf-connector
[controller.git]
/
opendaylight
/
sal
/
api
/
src
/
main
/
java
/
org
/
opendaylight
/
controller
/
sal
/
packet
/
ICMP.java
diff --git
a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/ICMP.java
b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/ICMP.java
index 0429c0dd279e1231ace4a0bfd7c6b880163101ba..35ae71d0019ed2b0b1d4893c7e47901be6e906ea 100644
(file)
--- a/
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/ICMP.java
+++ b/
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/ICMP.java
@@
-68,7
+68,7
@@
public class ICMP extends Packet {
/**
* Sets the type for the current ICMP message
/**
* Sets the type for the current ICMP message
- *
+ *
* @param type
* The ICMP message type
* @return This ICMP object
* @param type
* The ICMP message type
* @return This ICMP object
@@
-79,9
+79,18
@@
public class ICMP extends Packet {
return this;
}
return this;
}
+ /**
+ * Returns the type field of the current ICMP packet
+ *
+ * @return The type code of the current ICMP packet
+ */
+ public byte getType() {
+ return BitBufferHelper.getByte(fieldValues.get(TYPE));
+ }
+
/**
* Sets the ICMP code (type subtype) for the current ICMP object instance
/**
* Sets the ICMP code (type subtype) for the current ICMP object instance
- *
+ *
* @param code
* The ICMP message type subtype
* @return This ICMP object
* @param code
* The ICMP message type subtype
* @return This ICMP object
@@
-92,6
+101,15
@@
public class ICMP extends Packet {
return this;
}
return this;
}
+ /**
+ * Gets the ICMP code (type subtype) for the current ICMP object instance
+ *
+ * @return The ICMP message type subtype
+ */
+ public byte getCode() {
+ return BitBufferHelper.getByte(fieldValues.get(CODE));
+ }
+
/**
* Sets the ICMP checksum for the current ICMP object instance
* @param short - checksum
/**
* Sets the ICMP checksum for the current ICMP object instance
* @param short - checksum
@@
-104,7
+122,7
@@
public class ICMP extends Packet {
}
/**
}
/**
- * Sets the ICMP identifier
for the current ICMP object instance
+ * Sets the ICMP identifier for the current ICMP object instance
* @param short - identifier
* @return ICMP
*/
* @param short - identifier
* @return ICMP
*/
@@
-114,6
+132,16
@@
public class ICMP extends Packet {
return this;
}
return this;
}
+ /**
+ * Gets the ICMP identifier of the current ICMP object instance
+ *
+ * @return short - identifier
+ */
+
+ public short getIdentifier() {
+ return BitBufferHelper.getShort(fieldValues.get(IDENTIFIER));
+ }
+
/**
* Sets the ICMP sequence number for the current ICMP object instance
* @param short - seqNumber
/**
* Sets the ICMP sequence number for the current ICMP object instance
* @param short - seqNumber
@@
-125,6
+153,16
@@
public class ICMP extends Packet {
return this;
}
return this;
}
+ /**
+ * Gets the ICMP sequence number of the current ICMP object instance
+ *
+ * @return short - seqNumber
+ */
+
+ public short getSequenceNumber() {
+ return BitBufferHelper.getShort(fieldValues.get(SEQNUMBER));
+ }
+
/**
* Gets the header size in bits
* @return The ICMP header size in bits
/**
* Gets the header size in bits
* @return The ICMP header size in bits
@@
-136,7
+174,7
@@
public class ICMP extends Packet {
/**
* Computes the ICMP checksum on the serialized ICMP message
/**
* Computes the ICMP checksum on the serialized ICMP message
- *
+ *
* @param serialized
* The data stream
* @param start
* @param serialized
* The data stream
* @param start
@@
-146,22
+184,20
@@
public class ICMP extends Packet {
*/
short computeChecksum(byte[] data, int start) {
int sum = 0, carry = 0, finalSum = 0;
*/
short computeChecksum(byte[] data, int start) {
int sum = 0, carry = 0, finalSum = 0;
- int end = start + this.getHeaderSize() / NetUtils.NumBitsInAByte
- + rawPayload.length;
- int checksumStartByte = start + getfieldOffset(CHECKSUM)
- / NetUtils.NumBitsInAByte;
+ int wordData;
+ int end = start + this.getHeaderSize() / NetUtils.NumBitsInAByte;
+ if (rawPayload != null) {
+ end += rawPayload.length;
+ }
+ int checksumStartByte = start + getfieldOffset(CHECKSUM) / NetUtils.NumBitsInAByte;
for (int i = start; i <= (end - 1); i = i + 2) {
// Skip, if the current bytes are checkSum bytes
if (i == checksumStartByte) {
continue;
}
for (int i = start; i <= (end - 1); i = i + 2) {
// Skip, if the current bytes are checkSum bytes
if (i == checksumStartByte) {
continue;
}
- StringBuffer sbuffer = new StringBuffer();
- sbuffer.append(String.format("%02X", data[i]));
- if (i < (data.length - 1)) {
- sbuffer.append(String.format("%02X", data[i + 1]));
- }
- sum += Integer.valueOf(sbuffer.toString(), 16);
+ wordData = ((data[i] << 8) & 0xFF00) + (data[i + 1] & 0xFF);
+ sum = sum + wordData;
}
carry = (sum >> 16) & 0xFF;
finalSum = (sum & 0xFFFF) + carry;
}
carry = (sum >> 16) & 0xFF;
finalSum = (sum & 0xFFFF) + carry;