Revision: b241a855709f
Author: [email protected] <[email protected]>
Date: Fri Aug 17 06:55:25 2012
Log: Issue 111: IndexOutOfBoundsException when using TCP socket for
SCTP
Association
http://code.google.com/p/jss7/source/detail?r=b241a855709f
Modified:
/m3ua/impl/src/main/java/org/mobicents/protocols/ss7/m3ua/impl/message/MessageFactoryImpl.java
/m3ua/impl/src/test/java/org/mobicents/protocols/ss7/m3ua/impl/message/MessageFactoryTest.java
=======================================
---
/m3ua/impl/src/main/java/org/mobicents/protocols/ss7/m3ua/impl/message/MessageFactoryImpl.java
Sun Feb 12 15:07:39 2012
+++
/m3ua/impl/src/main/java/org/mobicents/protocols/ss7/m3ua/impl/message/MessageFactoryImpl.java
Fri Aug 17 06:55:25 2012
@@ -1,6 +1,6 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and individual contributors
+ * TeleStax, Open Source Cloud Communications Copyright 2012.
+ * and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
@@ -152,16 +152,16 @@
if (!isHeaderReady) {
// the amount of data possible to read is determined as
// minimal remainder either of header buffer or of the
input buffer
- int len = Math.min(header.length - pos,
buffer.remaining());
+ int len = Math.min(header.length - this.pos,
buffer.remaining());
- System.out.println(String.format("len=%d, pos=%d, buffer.remaining=%d",
len, pos, buffer.remaining()));
- buffer.get(header, pos, len);
+ System.out.println(String.format("len=%d, pos=%d, buffer.remaining=%d",
len, this.pos, buffer.remaining()));
+ buffer.get(header, this.pos, len);
// update cursor postion in the header's buffer
- pos += len;
+ this.pos += len;
// header completed?
- isHeaderReady = pos == header.length;
+ isHeaderReady = this.pos == header.length;
if (!isHeaderReady) {
// no more data available
@@ -187,7 +187,7 @@
params = new byte[length];
// finally switch cursor position
- pos = 0;
+ this.pos = 0;
}
// at this point we must recheck remainder of the input buffer
@@ -199,14 +199,14 @@
// again, reading all parameters before parsing
// compute available or required data
- int len = Math.min(params.length, buffer.remaining());
- buffer.get(params, pos, len);
+ int len = Math.min(params.length - this.pos,
buffer.remaining());
+ buffer.get(params, this.pos, len);
// update cursor position
- pos += len;
+ this.pos += len;
// end of message not reached
- if (pos < params.length) {
+ if (this.pos < params.length) {
return null;
}
=======================================
---
/m3ua/impl/src/test/java/org/mobicents/protocols/ss7/m3ua/impl/message/MessageFactoryTest.java
Sun Feb 12 15:07:39 2012
+++
/m3ua/impl/src/test/java/org/mobicents/protocols/ss7/m3ua/impl/message/MessageFactoryTest.java
Fri Aug 17 06:55:25 2012
@@ -1,6 +1,6 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and individual contributors
+ * TeleStax, Open Source Cloud Communications Copyright 2012.
+ * and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
@@ -27,6 +27,7 @@
import static org.testng.Assert.assertNull;
import java.io.IOException;
+import java.nio.ByteBuffer;
import org.mobicents.protocols.ss7.m3ua.message.MessageType;
import org.mobicents.protocols.ss7.m3ua.message.transfer.PayloadData;
@@ -37,7 +38,6 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-
/**
* @author amit bhayani
*
@@ -74,17 +74,16 @@
*/
@Test
public void testSst() {
- byte[] data = new byte[] { 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00,
0x3c, 0x02, 0x00, 0x00, 0x08, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x00, 0x00, 0x19, 0x02,
0x10, 0x00, 0x21, 0x00, 0x00, 0x17,
- (byte) 0x9d, 0x00, 0x00, 0x18, 0x1c, 0x03, 0x03, 0x00, 0x02, 0x09,
0x00, 0x03, 0x05, 0x07, 0x02, 0x42,
- 0x01, 0x02, 0x42, 0x01, 0x05, 0x03, (byte) 0xd5, 0x1c, 0x18, 0x00,
0x00, 0x00, 0x00 };
+ byte[] data = new byte[] { 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00,
0x3c, 0x02, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00,
0x08,
+ 0x00, 0x00, 0x00, 0x19, 0x02, 0x10, 0x00, 0x21, 0x00, 0x00, 0x17,
(byte) 0x9d, 0x00, 0x00, 0x18, 0x1c, 0x03, 0x03, 0x00, 0x02, 0x09, 0x00,
+ 0x03, 0x05, 0x07, 0x02, 0x42, 0x01, 0x02, 0x42, 0x01, 0x05, 0x03,
(byte) 0xd5, 0x1c, 0x18, 0x00, 0x00, 0x00, 0x00 };
-// ByteBuffer byteBuffer = ByteBuffer.allocate(256);
-// byteBuffer.put(data);
-// byteBuffer.flip();
-// M3UAMessageImpl messageImpl =
messageFactory.createMessage(byteBuffer);
- M3UAMessageImpl messageImpl =
messageFactory.createSctpMessage(data);
+ ByteBuffer byteBuffer = ByteBuffer.allocate(256);
+ byteBuffer.put(data);
+ byteBuffer.flip();
+ M3UAMessageImpl messageImpl =
messageFactory.createMessage(byteBuffer);
+ // Test with TCP
assertEquals(MessageType.PAYLOAD, messageImpl.getMessageType());
PayloadData payloadData = (PayloadData) messageImpl;
assertEquals(0l,
payloadData.getNetworkAppearance().getNetApp());
@@ -119,35 +118,28 @@
@Test
public void test2() {
- byte[] data = new byte[] { 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01,
0x08, 0x00, 0x06, 0x00, 0x08, 0x00, 0x00,
- 0x00, 0x01, 0x02, 0x10, 0x00, (byte) 0xf8, 0x00, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x01, 0x03, 0x02,
- 0x00, 0x01, 0x09, 0x01, 0x03, 0x10, 0x1d, 0x0d, 0x53, 0x01, 0x00,
(byte) 0x91, 0x00, 0x12, 0x04, 0x19,
- 0x09, 0x31, (byte) 0x91, 0x39, 0x08, 0x0d, 0x53, 0x02, 0x00, (byte)
0x92, 0x00, 0x12, 0x04, 0x19, 0x09,
- 0x31, (byte) 0x91, 0x39, 0x09, (byte) 0xc6, 0x62, (byte) 0x81, (byte)
0xc3, 0x48, 0x04, 0x00, 0x08,
- 0x00, 0x10, 0x6b, 0x1a, 0x28, 0x18, 0x06, 0x07, 0x00, 0x11, (byte)
0x86, 0x05, 0x01, 0x01, 0x01,
- (byte) 0xa0, 0x0d, 0x60, 0x0b, (byte) 0xa1, 0x09, 0x06, 0x07, 0x04,
0x00, 0x00, 0x01, 0x00, 0x32, 0x01,
- 0x6c, (byte) 0x81, (byte) 0x9e, (byte) 0xa1, (byte) 0x81, (byte) 0x9b,
0x02, 0x01, 0x01, 0x02, 0x01,
- 0x00, 0x30, (byte) 0x81, (byte) 0x92, (byte) 0x80, 0x01, 0x0c, (byte)
0x82, 0x09, 0x03, 0x10, 0x13,
- 0x60, (byte) 0x99, (byte) 0x86, 0x00, 0x00, 0x02, (byte) 0x83, 0x08,
0x04, 0x13, 0x19, (byte) 0x89,
- 0x17, (byte) 0x97, 0x31, 0x72, (byte) 0x85, 0x01, 0x0a, (byte) 0x88,
0x01, 0x01, (byte) 0x8a, 0x05,
- 0x04, 0x13, 0x19, (byte) 0x89, (byte) 0x86, (byte) 0xbb, 0x04, (byte)
0x80, 0x02, (byte) 0x80,
- (byte) 0x90, (byte) 0x9c, 0x01, 0x0c, (byte) 0x9f, 0x32, 0x08, 0x04,
0x64, 0x58, 0x05, (byte) 0x94,
- 0x74, 0x34, (byte) 0xf3, (byte) 0xbf, 0x33, 0x02, (byte) 0x80, 0x00,
(byte) 0xbf, 0x34, 0x2b, 0x02,
- 0x01, 0x23, (byte) 0x80, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, (byte) 0x81, 0x07,
- (byte) 0x91, 0x19, (byte) 0x89, (byte) 0x86, (byte) 0x91, 0x01, (byte)
0x82, (byte) 0x82, 0x08, 0x04,
- (byte) 0x97, 0x19, (byte) 0x89, (byte) 0x86, (byte) 0x91, 0x01, (byte)
0x82, (byte) 0xa3, 0x09,
- (byte) 0x80, 0x07, 0x04, (byte) 0xf4, (byte) 0x86, 0x00, 0x65, 0x18,
(byte) 0xd1, (byte) 0xbf, 0x35,
- 0x03, (byte) 0x83, 0x01, 0x11, (byte) 0x9f, 0x36, 0x08, (byte) 0xd2,
0x25, 0x00, 0x00, 0x0d, 0x62,
- 0x0b, (byte) 0x88, (byte) 0x9f, 0x37, 0x07, (byte) 0x91, 0x19, (byte)
0x89, (byte) 0x86, (byte) 0x95,
- (byte) 0x99, (byte) 0x89, (byte) 0x9f, 0x39, 0x08, 0x02, 0x11, 0x20,
0x10, (byte) 0x91, 0x45, 0x51,
- 0x23 };
+ byte[] data = new byte[] { 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01,
0x08, 0x00, 0x06, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x02, 0x10, 0x00,
+ (byte) 0xf8, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x03,
0x02, 0x00, 0x01, 0x09, 0x01, 0x03, 0x10, 0x1d, 0x0d, 0x53, 0x01, 0x00,
+ (byte) 0x91, 0x00, 0x12, 0x04, 0x19, 0x09, 0x31, (byte) 0x91, 0x39,
0x08, 0x0d, 0x53, 0x02, 0x00, (byte) 0x92, 0x00, 0x12, 0x04, 0x19, 0x09,
+ 0x31, (byte) 0x91, 0x39, 0x09, (byte) 0xc6, 0x62, (byte) 0x81, (byte)
0xc3, 0x48, 0x04, 0x00, 0x08, 0x00, 0x10, 0x6b, 0x1a, 0x28, 0x18, 0x06,
+ 0x07, 0x00, 0x11, (byte) 0x86, 0x05, 0x01, 0x01, 0x01, (byte) 0xa0,
0x0d, 0x60, 0x0b, (byte) 0xa1, 0x09, 0x06, 0x07, 0x04, 0x00, 0x00, 0x01,
+ 0x00, 0x32, 0x01, 0x6c, (byte) 0x81, (byte) 0x9e, (byte) 0xa1, (byte)
0x81, (byte) 0x9b, 0x02, 0x01, 0x01, 0x02, 0x01, 0x00, 0x30, (byte) 0x81,
+ (byte) 0x92, (byte) 0x80, 0x01, 0x0c, (byte) 0x82, 0x09, 0x03, 0x10,
0x13, 0x60, (byte) 0x99, (byte) 0x86, 0x00, 0x00, 0x02, (byte) 0x83, 0x08,
+ 0x04, 0x13, 0x19, (byte) 0x89, 0x17, (byte) 0x97, 0x31, 0x72, (byte)
0x85, 0x01, 0x0a, (byte) 0x88, 0x01, 0x01, (byte) 0x8a, 0x05, 0x04, 0x13,
+ 0x19, (byte) 0x89, (byte) 0x86, (byte) 0xbb, 0x04, (byte) 0x80, 0x02,
(byte) 0x80, (byte) 0x90, (byte) 0x9c, 0x01, 0x0c, (byte) 0x9f, 0x32,
+ 0x08, 0x04, 0x64, 0x58, 0x05, (byte) 0x94, 0x74, 0x34, (byte) 0xf3,
(byte) 0xbf, 0x33, 0x02, (byte) 0x80, 0x00, (byte) 0xbf, 0x34, 0x2b, 0x02,
+ 0x01, 0x23, (byte) 0x80, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, (byte) 0x81, 0x07, (byte) 0x91, 0x19, (byte) 0x89, (byte) 0x86,
+ (byte) 0x91, 0x01, (byte) 0x82, (byte) 0x82, 0x08, 0x04, (byte) 0x97,
0x19, (byte) 0x89, (byte) 0x86, (byte) 0x91, 0x01, (byte) 0x82,
+ (byte) 0xa3, 0x09, (byte) 0x80, 0x07, 0x04, (byte) 0xf4, (byte) 0x86,
0x00, 0x65, 0x18, (byte) 0xd1, (byte) 0xbf, 0x35, 0x03, (byte) 0x83,
+ 0x01, 0x11, (byte) 0x9f, 0x36, 0x08, (byte) 0xd2, 0x25, 0x00, 0x00,
0x0d, 0x62, 0x0b, (byte) 0x88, (byte) 0x9f, 0x37, 0x07, (byte) 0x91, 0x19,
+ (byte) 0x89, (byte) 0x86, (byte) 0x95, (byte) 0x99, (byte) 0x89,
(byte) 0x9f, 0x39, 0x08, 0x02, 0x11, 0x20, 0x10, (byte) 0x91, 0x45, 0x51,
0x23 };
- //ByteBuffer byteBuffer = ByteBuffer.allocate(8192);
- //byteBuffer.put(data);
- //byteBuffer.flip();
- //M3UAMessageImpl messageImpl =
messageFactory.createMessage(byteBuffer);
- M3UAMessageImpl messageImpl =
messageFactory.createSctpMessage(data);
+ ByteBuffer byteBuffer = ByteBuffer.allocate(8192);
+ byteBuffer.put(data);
+ byteBuffer.flip();
+ M3UAMessageImpl messageImpl =
messageFactory.createMessage(byteBuffer);
+ // Test with TCP
assertEquals(MessageType.PAYLOAD, messageImpl.getMessageType());
PayloadData payloadData = (PayloadData) messageImpl;
assertNull(payloadData.getNetworkAppearance());
@@ -182,33 +174,59 @@
}
@Test
- public void test3() {
- byte[] data = new byte[] { 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00,
(byte) 0xec, 0x00, 0x06, 0x00, 0x08, 0x00,
- 0x00, 0x00, 0x01, 0x02, 0x10, 0x00, (byte) 0xdc, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x01, 0x03,
- 0x02, 0x00, 0x0f, 0x09, 0x01, 0x03, 0x10, 0x1d, 0x0d, 0x53, 0x01,
0x00, (byte) 0x91, 0x00, 0x12, 0x04,
- 0x19, 0x09, 0x31, (byte) 0x91, 0x39, 0x08, 0x0d, 0x53, 0x02, 0x00,
(byte) 0x92, 0x00, 0x12, 0x04, 0x19,
- 0x09, 0x31, (byte) 0x91, 0x39, 0x09, (byte) 0xaa, 0x62, (byte) 0x81,
(byte) 0xa7, 0x48, 0x04, 0x00,
- 0x07, (byte) 0xff, (byte) 0xf0, 0x6c, (byte) 0x81, (byte) 0x9e, (byte)
0xa1, (byte) 0x81, (byte) 0x9b,
- 0x02, 0x01, 0x01, 0x02, 0x01, 0x00, 0x30, (byte) 0x81, (byte) 0x92,
(byte) 0x80, 0x01, 0x0c,
- (byte) 0x82, 0x09, 0x03, 0x10, 0x13, 0x60, (byte) 0x99, (byte) 0x86,
0x00, 0x00, 0x02, (byte) 0x83,
- 0x08, 0x04, 0x13, 0x19, (byte) 0x89, 0x17, (byte) 0x97, 0x31, 0x72,
(byte) 0x85, 0x01, 0x0a,
- (byte) 0x88, 0x01, 0x01, (byte) 0x8a, 0x05, 0x04, 0x13, 0x19, (byte)
0x89, (byte) 0x86, (byte) 0xbb,
- 0x04, (byte) 0x80, 0x02, (byte) 0x80, (byte) 0x90, (byte) 0x9c, 0x01,
0x0c, (byte) 0x9f, 0x32, 0x08,
- 0x04, 0x64, 0x58, 0x05, (byte) 0x94, 0x74, 0x34, (byte) 0xf3, (byte)
0xbf, 0x33, 0x02, (byte) 0x80,
- 0x00, (byte) 0xbf, 0x34, 0x2b, 0x02, 0x01, 0x23, (byte) 0x80, 0x08,
0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, (byte) 0x81, 0x07, (byte) 0x91, 0x19, (byte) 0x89, (byte)
0x86, (byte) 0x91, 0x01,
- (byte) 0x82, (byte) 0x82, 0x08, 0x04, (byte) 0x97, 0x19, (byte) 0x89,
(byte) 0x86, (byte) 0x91, 0x01,
- (byte) 0x82, (byte) 0xa3, 0x09, (byte) 0x80, 0x07, 0x04, (byte) 0xf4,
(byte) 0x86, 0x00, 0x65, 0x18,
- (byte) 0xd1, (byte) 0xbf, 0x35, 0x03, (byte) 0x83, 0x01, 0x11, (byte)
0x9f, 0x36, 0x08, (byte) 0xd2,
- 0x25, 0x00, 0x00, 0x0d, 0x62, 0x0b, (byte) 0x88, (byte) 0x9f, 0x37,
0x07, (byte) 0x91, 0x19,
- (byte) 0x89, (byte) 0x86, (byte) 0x95, (byte) 0x99, (byte) 0x89,
(byte) 0x9f, 0x39, 0x08, 0x02, 0x11,
- 0x20, 0x10, (byte) 0x91, 0x45, 0x51, 0x23 };
+ public void test2TCPPartial() {
-// ByteBuffer byteBuffer = ByteBuffer.allocate(8192);
-// byteBuffer.put(data);
-// byteBuffer.flip();
-// M3UAMessageImpl messageImpl =
messageFactory.createMessage(byteBuffer);
- M3UAMessageImpl messageImpl =
messageFactory.createSctpMessage(data);
+ // Only header
+ byte[] header = new byte[] { 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01,
0x08 };
+
+ byte[] bodyStart = new byte[] { 0x00, 0x06, 0x00, 0x08, 0x00, 0x00,
0x00, 0x01, 0x02, 0x10, 0x00, (byte) 0xf8, 0x00, 0x00, 0x00, 0x02, 0x00,
0x00,
+ 0x00, 0x01, 0x03, 0x02, 0x00, 0x01, 0x09, 0x01, 0x03, 0x10, 0x1d,
0x0d, 0x53, 0x01, 0x00, (byte) 0x91, 0x00, 0x12, 0x04, 0x19, 0x09, 0x31,
+ (byte) 0x91, 0x39, 0x08, 0x0d, 0x53, 0x02, 0x00, (byte) 0x92, 0x00,
0x12, 0x04, 0x19, 0x09, 0x31, (byte) 0x91, 0x39, 0x09, (byte) 0xc6, 0x62,
+ (byte) 0x81, (byte) 0xc3, 0x48, 0x04, 0x00, 0x08, 0x00, 0x10, 0x6b,
0x1a, 0x28, 0x18, 0x06, 0x07, 0x00, 0x11, (byte) 0x86, 0x05, 0x01, 0x01,
+ 0x01, (byte) 0xa0, 0x0d, 0x60, 0x0b, (byte) 0xa1, 0x09, 0x06, 0x07,
0x04, 0x00, 0x00, 0x01, 0x00, 0x32, 0x01, 0x6c, (byte) 0x81, (byte) 0x9e,
+ (byte) 0xa1, (byte) 0x81, (byte) 0x9b, 0x02, 0x01, 0x01, 0x02, 0x01,
0x00, 0x30, (byte) 0x81, (byte) 0x92, (byte) 0x80, 0x01, 0x0c,
+ (byte) 0x82, 0x09, 0x03, 0x10, 0x13, 0x60, (byte) 0x99, (byte) 0x86,
0x00, 0x00, 0x02, (byte) 0x83, 0x08, 0x04, 0x13, 0x19, (byte) 0x89, 0x17,
+ (byte) 0x97, 0x31, 0x72, (byte) 0x85, 0x01, 0x0a, (byte) 0x88, 0x01,
0x01, (byte) 0x8a, 0x05, 0x04, 0x13, 0x19, (byte) 0x89, (byte) 0x86,
+ (byte) 0xbb, 0x04, (byte) 0x80, 0x02, (byte)
0x80, };
+
+ byte[] bodyEndWithOtherMessage = { (byte) 0x90, (byte) 0x9c, 0x01, 0x0c,
(byte) 0x9f, 0x32, 0x08, 0x04, 0x64, 0x58, 0x05, (byte) 0x94, 0x74, 0x34,
+ (byte) 0xf3, (byte) 0xbf, 0x33, 0x02, (byte) 0x80, 0x00, (byte) 0xbf,
0x34, 0x2b, 0x02, 0x01, 0x23, (byte) 0x80, 0x08, 0x10, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, (byte) 0x81, 0x07, (byte) 0x91, 0x19, (byte)
0x89, (byte) 0x86, (byte) 0x91, 0x01, (byte) 0x82, (byte) 0x82, 0x08,
+ 0x04, (byte) 0x97, 0x19, (byte) 0x89, (byte) 0x86, (byte) 0x91, 0x01,
(byte) 0x82, (byte) 0xa3, 0x09, (byte) 0x80, 0x07, 0x04, (byte) 0xf4,
+ (byte) 0x86, 0x00, 0x65, 0x18, (byte) 0xd1, (byte) 0xbf, 0x35, 0x03,
(byte) 0x83, 0x01, 0x11, (byte) 0x9f, 0x36, 0x08, (byte) 0xd2, 0x25, 0x00,
+ 0x00, 0x0d, 0x62, 0x0b, (byte) 0x88, (byte) 0x9f, 0x37, 0x07, (byte)
0x91, 0x19, (byte) 0x89, (byte) 0x86, (byte) 0x95, (byte) 0x99,
+ (byte) 0x89, (byte) 0x9f, 0x39, 0x08, 0x02, 0x11, 0x20, 0x10, (byte)
0x91, 0x45, 0x51, 0x23, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x08,
+ 0x00, 0x06, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x02, 0x10, 0x00,
(byte) 0xf8, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x03, 0x02,
+ 0x00, 0x01, 0x09, 0x01, 0x03, 0x10, 0x1d, 0x0d, 0x53, 0x01, 0x00,
(byte) 0x91, 0x00, 0x12, 0x04, 0x19, 0x09, 0x31, (byte) 0x91, 0x39, 0x08,
+ 0x0d, 0x53, 0x02, 0x00, (byte) 0x92, 0x00, 0x12, 0x04, 0x19, 0x09,
0x31, (byte) 0x91, 0x39, 0x09, (byte) 0xc6, 0x62, (byte) 0x81, (byte) 0xc3,
+ 0x48, 0x04, 0x00, 0x08, 0x00, 0x10, 0x6b, 0x1a, 0x28, 0x18, 0x06,
0x07, 0x00, 0x11, (byte) 0x86, 0x05, 0x01, 0x01, 0x01, (byte) 0xa0, 0x0d,
+ 0x60, 0x0b, (byte) 0xa1, 0x09, 0x06, 0x07, 0x04, 0x00, 0x00, 0x01,
0x00, 0x32, 0x01, 0x6c, (byte) 0x81, (byte) 0x9e, (byte) 0xa1, (byte) 0x81,
+ (byte) 0x9b, 0x02, 0x01, 0x01, 0x02, 0x01, 0x00, 0x30, (byte) 0x81,
(byte) 0x92, (byte) 0x80, 0x01, 0x0c, (byte) 0x82, 0x09, 0x03, 0x10, 0x13,
+ 0x60, (byte) 0x99, (byte) 0x86, 0x00, 0x00, 0x02, (byte) 0x83, 0x08,
0x04, 0x13, 0x19, (byte) 0x89, 0x17, (byte) 0x97, 0x31, 0x72, (byte) 0x85,
+ 0x01, 0x0a, (byte) 0x88, 0x01, 0x01, (byte) 0x8a, 0x05, 0x04, 0x13,
0x19, (byte) 0x89, (byte) 0x86, (byte) 0xbb, 0x04, (byte) 0x80, 0x02,
+ (byte) 0x80, (byte) 0x90, (byte) 0x9c, 0x01, 0x0c, (byte) 0x9f, 0x32,
0x08, 0x04, 0x64, 0x58, 0x05, (byte) 0x94, 0x74, 0x34, (byte) 0xf3,
+ (byte) 0xbf, 0x33, 0x02, (byte) 0x80, 0x00, (byte) 0xbf, 0x34, 0x2b,
0x02, 0x01, 0x23, (byte) 0x80, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, (byte) 0x81, 0x07, (byte) 0x91, 0x19, (byte) 0x89, (byte)
0x86, (byte) 0x91, 0x01, (byte) 0x82, (byte) 0x82, 0x08, 0x04,
+ (byte) 0x97, 0x19, (byte) 0x89, (byte) 0x86, (byte) 0x91, 0x01, (byte)
0x82, (byte) 0xa3, 0x09, (byte) 0x80, 0x07, 0x04, (byte) 0xf4,
+ (byte) 0x86, 0x00, 0x65, 0x18, (byte) 0xd1, (byte) 0xbf, 0x35, 0x03,
(byte) 0x83, 0x01, 0x11, (byte) 0x9f, 0x36, 0x08, (byte) 0xd2, 0x25, 0x00,
+ 0x00, 0x0d, 0x62, 0x0b, (byte) 0x88, (byte) 0x9f, 0x37, 0x07, (byte)
0x91, 0x19, (byte) 0x89, (byte) 0x86, (byte) 0x95, (byte) 0x99,
+ (byte) 0x89, (byte) 0x9f, 0x39, 0x08, 0x02, 0x11, 0x20, 0x10, (byte)
0x91, 0x45, 0x51, 0x23 };
+
+ ByteBuffer byteBuffer = ByteBuffer.wrap(header);
+ M3UAMessageImpl messageImpl =
messageFactory.createMessage(byteBuffer);
+
+ assertNull(messageImpl);
+
+ // Now lets read only first half of body and yet we have null
+ // messageImpl
+ byteBuffer = ByteBuffer.wrap(bodyStart);
+ messageImpl = messageFactory.createMessage(byteBuffer);
+ assertNull(messageImpl);
+
+ // Now lets read other half
+ byteBuffer = ByteBuffer.wrap(bodyEndWithOtherMessage);
+ messageImpl = messageFactory.createMessage(byteBuffer);
+ assertNotNull(messageImpl);
assertEquals(MessageType.PAYLOAD, messageImpl.getMessageType());
PayloadData payloadData = (PayloadData) messageImpl;
@@ -217,6 +235,62 @@
assertEquals(1l,
payloadData.getRoutingContext().getRoutingContexts()[0]);
ProtocolData protocolData = payloadData.getData();
assertNotNull(protocolData);
+ assertEquals(2, protocolData.getOpc());
+ assertEquals(1, protocolData.getDpc());
+ assertEquals(3, protocolData.getSI());
+ assertEquals(1, protocolData.getSLS());
+ assertEquals(2, protocolData.getNI());
+ assertEquals(0, protocolData.getMP());
+
+ // Now lets re-read same buffer to get 2nd message
+ messageImpl = messageFactory.createMessage(byteBuffer);
+ assertNotNull(messageImpl);
+
+ assertEquals(MessageType.PAYLOAD, messageImpl.getMessageType());
+ payloadData = (PayloadData) messageImpl;
+ assertNull(payloadData.getNetworkAppearance());
+ assertEquals(1,
payloadData.getRoutingContext().getRoutingContexts().length);
+ assertEquals(1l,
payloadData.getRoutingContext().getRoutingContexts()[0]);
+ protocolData = payloadData.getData();
+ assertNotNull(protocolData);
+ assertEquals(2, protocolData.getOpc());
+ assertEquals(1, protocolData.getDpc());
+ assertEquals(3, protocolData.getSI());
+ assertEquals(1, protocolData.getSLS());
+ assertEquals(2, protocolData.getNI());
+ assertEquals(0, protocolData.getMP());
+
+ }
+
+ @Test
+ public void test3() {
+ byte[] data = new byte[] { 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00,
(byte) 0xec, 0x00, 0x06, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x02, 0x10,
0x00,
+ (byte) 0xdc, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x03,
0x02, 0x00, 0x0f, 0x09, 0x01, 0x03, 0x10, 0x1d, 0x0d, 0x53, 0x01, 0x00,
+ (byte) 0x91, 0x00, 0x12, 0x04, 0x19, 0x09, 0x31, (byte) 0x91, 0x39,
0x08, 0x0d, 0x53, 0x02, 0x00, (byte) 0x92, 0x00, 0x12, 0x04, 0x19, 0x09,
+ 0x31, (byte) 0x91, 0x39, 0x09, (byte) 0xaa, 0x62, (byte) 0x81, (byte)
0xa7, 0x48, 0x04, 0x00, 0x07, (byte) 0xff, (byte) 0xf0, 0x6c,
+ (byte) 0x81, (byte) 0x9e, (byte) 0xa1, (byte) 0x81, (byte) 0x9b, 0x02,
0x01, 0x01, 0x02, 0x01, 0x00, 0x30, (byte) 0x81, (byte) 0x92,
+ (byte) 0x80, 0x01, 0x0c, (byte) 0x82, 0x09, 0x03, 0x10, 0x13, 0x60,
(byte) 0x99, (byte) 0x86, 0x00, 0x00, 0x02, (byte) 0x83, 0x08, 0x04, 0x13,
+ 0x19, (byte) 0x89, 0x17, (byte) 0x97, 0x31, 0x72, (byte) 0x85, 0x01,
0x0a, (byte) 0x88, 0x01, 0x01, (byte) 0x8a, 0x05, 0x04, 0x13, 0x19,
+ (byte) 0x89, (byte) 0x86, (byte) 0xbb, 0x04, (byte) 0x80, 0x02, (byte)
0x80, (byte) 0x90, (byte) 0x9c, 0x01, 0x0c, (byte) 0x9f, 0x32, 0x08,
+ 0x04, 0x64, 0x58, 0x05, (byte) 0x94, 0x74, 0x34, (byte) 0xf3, (byte)
0xbf, 0x33, 0x02, (byte) 0x80, 0x00, (byte) 0xbf, 0x34, 0x2b, 0x02, 0x01,
+ 0x23, (byte) 0x80, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, (byte) 0x81, 0x07, (byte) 0x91, 0x19, (byte) 0x89, (byte) 0x86,
+ (byte) 0x91, 0x01, (byte) 0x82, (byte) 0x82, 0x08, 0x04, (byte) 0x97,
0x19, (byte) 0x89, (byte) 0x86, (byte) 0x91, 0x01, (byte) 0x82,
+ (byte) 0xa3, 0x09, (byte) 0x80, 0x07, 0x04, (byte) 0xf4, (byte) 0x86,
0x00, 0x65, 0x18, (byte) 0xd1, (byte) 0xbf, 0x35, 0x03, (byte) 0x83,
+ 0x01, 0x11, (byte) 0x9f, 0x36, 0x08, (byte) 0xd2, 0x25, 0x00, 0x00,
0x0d, 0x62, 0x0b, (byte) 0x88, (byte) 0x9f, 0x37, 0x07, (byte) 0x91, 0x19,
+ (byte) 0x89, (byte) 0x86, (byte) 0x95, (byte) 0x99, (byte) 0x89,
(byte) 0x9f, 0x39, 0x08, 0x02, 0x11, 0x20, 0x10, (byte) 0x91, 0x45, 0x51,
0x23 };
+
+ // Test with TCP
+ ByteBuffer byteBuffer = ByteBuffer.allocate(8192);
+ byteBuffer.put(data);
+ byteBuffer.flip();
+ M3UAMessageImpl messageImpl =
messageFactory.createMessage(byteBuffer);
+ assertEquals(MessageType.PAYLOAD, messageImpl.getMessageType());
+ PayloadData payloadData = (PayloadData) messageImpl;
+ assertNull(payloadData.getNetworkAppearance());
+ assertEquals(1,
payloadData.getRoutingContext().getRoutingContexts().length);
+ assertEquals(1l,
payloadData.getRoutingContext().getRoutingContexts()[0]);
+ ProtocolData protocolData = payloadData.getData();
+ assertNotNull(protocolData);
assertEquals(2, protocolData.getOpc());
assertEquals(1, protocolData.getDpc());
assertEquals(3, protocolData.getSI());
@@ -247,32 +321,35 @@
@Test
public void testUnitDataService() throws IOException {
- byte[] data = new byte[] { 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00,
(byte) 0xB4, 0x02, 0x10, 0x00,
- (byte) 0xA9, 0x00, 0x00, 0x06, (byte) 0xBE, 0x00, 0x00, 0x06, (byte)
0xC5, 0x03, 0x02, 0x00, 0x02,
- 0x0A, 0x00, 0x03, 0x0D, 0x11, 0x0A, 0x52, (byte) 0x92, 0x00, 0x11,
0x04, (byte) 0x99, (byte) 0x99,
- (byte) 0x99, (byte) 0x99, 0x09, 0x04, 0x03, (byte) 0xBE, 0x06, (byte)
0x92, (byte) 0x83, 0x65,
- (byte) 0x81, (byte) 0x80, 0x48, 0x04, 0x00, 0x00, 0x00, 0x01, 0x49,
0x04, 0x00, 0x17, 0x3A, 0x26, 0x6B,
- 0x2A, 0x28, 0x28, 0x06, 0x07, 0x00, 0x11, (byte) 0x86, 0x05, 0x01,
0x01, 0x01, (byte) 0xA0, 0x1D, 0x61,
- 0x1B, (byte) 0x80, 0x02, 0x07, (byte) 0x80, (byte) 0xA1, 0x09, 0x06,
0x07, 0x04, 0x00, 0x00, 0x01,
- 0x00, 0x32, 0x01, (byte) 0xA2, 0x03, 0x02, 0x01, 0x00, (byte) 0xA3,
0x05, (byte) 0xA1, 0x03, 0x02,
- 0x01, 0x00, 0x6C, 0x46, (byte) 0xA1, 0x3C, 0x02, 0x01, 0x02, 0x02,
0x01, 0x17, 0x30, 0x34, (byte) 0xA0,
- 0x32, 0x30, 0x06, (byte) 0x80, 0x01, 0x0E, (byte) 0x81, 0x01, 0x01,
0x30, 0x06, (byte) 0x80, 0x01,
- 0x0D, (byte) 0x81, 0x01, 0x01, 0x30, 0x0B, (byte) 0x80, 0x01, 0x11,
(byte) 0x81, 0x01, 0x01,
- (byte) 0xA2, 0x03, (byte) 0x80, 0x01, 0x01, 0x30, 0x0B, (byte) 0x80,
0x01, 0x11, (byte) 0x81, 0x01,
- 0x01, (byte) 0xA2, 0x03, (byte) 0x80, 0x01, 0x02, 0x30, 0x06, (byte)
0x80, 0x01, 0x12, (byte) 0x81,
- 0x01, 0x01, (byte) 0xA1, 0x06, 0x02, 0x01, 0x03, 0x02, 0x01, 0x1F,
0x00, 0x00, 0x00 };
+ byte[] data = new byte[] { 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00,
(byte) 0xB4, 0x02, 0x10, 0x00, (byte) 0xA9, 0x00, 0x00, 0x06, (byte) 0xBE,
0x00,
+ 0x00, 0x06, (byte) 0xC5, 0x03, 0x02, 0x00, 0x02, 0x0A, 0x00, 0x03,
0x0D, 0x11, 0x0A, 0x52, (byte) 0x92, 0x00, 0x11, 0x04, (byte) 0x99,
+ (byte) 0x99, (byte) 0x99, (byte) 0x99, 0x09, 0x04, 0x03, (byte) 0xBE,
0x06, (byte) 0x92, (byte) 0x83, 0x65, (byte) 0x81, (byte) 0x80, 0x48,
+ 0x04, 0x00, 0x00, 0x00, 0x01, 0x49, 0x04, 0x00, 0x17, 0x3A, 0x26,
0x6B, 0x2A, 0x28, 0x28, 0x06, 0x07, 0x00, 0x11, (byte) 0x86, 0x05, 0x01,
+ 0x01, 0x01, (byte) 0xA0, 0x1D, 0x61, 0x1B, (byte) 0x80, 0x02, 0x07,
(byte) 0x80, (byte) 0xA1, 0x09, 0x06, 0x07, 0x04, 0x00, 0x00, 0x01, 0x00,
+ 0x32, 0x01, (byte) 0xA2, 0x03, 0x02, 0x01, 0x00, (byte) 0xA3, 0x05,
(byte) 0xA1, 0x03, 0x02, 0x01, 0x00, 0x6C, 0x46, (byte) 0xA1, 0x3C, 0x02,
+ 0x01, 0x02, 0x02, 0x01, 0x17, 0x30, 0x34, (byte) 0xA0, 0x32, 0x30,
0x06, (byte) 0x80, 0x01, 0x0E, (byte) 0x81, 0x01, 0x01, 0x30, 0x06,
+ (byte) 0x80, 0x01, 0x0D, (byte) 0x81, 0x01, 0x01, 0x30, 0x0B, (byte)
0x80, 0x01, 0x11, (byte) 0x81, 0x01, 0x01, (byte) 0xA2, 0x03, (byte) 0x80,
+ 0x01, 0x01, 0x30, 0x0B, (byte) 0x80, 0x01, 0x11, (byte) 0x81, 0x01,
0x01, (byte) 0xA2, 0x03, (byte) 0x80, 0x01, 0x02, 0x30, 0x06, (byte) 0x80,
+ 0x01, 0x12, (byte) 0x81, 0x01, 0x01, (byte) 0xA1, 0x06, 0x02, 0x01,
0x03, 0x02, 0x01, 0x1F, 0x00, 0x00, 0x00 };
-// ByteBuffer byteBuffer = ByteBuffer.allocate(8192);
-// byteBuffer.put(data);
-// byteBuffer.flip();
-// M3UAMessageImpl messageImpl =
messageFactory.createMessage(byteBuffer);
- M3UAMessageImpl messageImpl =
messageFactory.createSctpMessage(data);
+ // Test with TCP
+ ByteBuffer byteBuffer = ByteBuffer.allocate(8192);
+ byteBuffer.put(data);
+ byteBuffer.flip();
+ M3UAMessageImpl messageImpl =
messageFactory.createMessage(byteBuffer);
assertEquals(MessageType.PAYLOAD, messageImpl.getMessageType());
PayloadData payloadData = (PayloadData) messageImpl;
ProtocolData protocolData = payloadData.getData();
assertNotNull(protocolData);
-
+
+ // Test with SCTP
+ messageImpl = messageFactory.createSctpMessage(data);
+
+ assertEquals(MessageType.PAYLOAD, messageImpl.getMessageType());
+ payloadData = (PayloadData) messageImpl;
+ protocolData = payloadData.getData();
+ assertNotNull(protocolData);
}