aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-07-09 13:37:17 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-07-09 13:37:17 +0200
commitfc6e258ac0909d1e8ba93a2031459f7f755e15b4 (patch)
treeaf321bbaf83124af0611466b4c2c58e8fe560443
parentcb55eb5dcf67fbe1ca02e12cd3ccc25df4847ee2 (diff)
sccp: Implement connection refused parsing and handling
The code can not parse the optional elements yet.
-rw-r--r--Tests.st14
-rw-r--r--sccp/SCCP.st56
2 files changed, 70 insertions, 0 deletions
diff --git a/Tests.st b/Tests.st
index e395745..57898b2 100644
--- a/Tests.st
+++ b/Tests.st
@@ -105,6 +105,20 @@ TestCase subclass: SCCPTests [
self assert: cc toMessage asByteArray = target.
]
+ testCREF [
+ | target cref |
+
+ target := #[16r03 16r1A 16r00 16r03 16r00 16r01 16r00].
+
+ cref := SCCPConnectionRefused
+ initWithDst: 16r03001A cause: 16r00.
+ self assert: cref toMessage asByteArray = target.
+
+ cref := SCCPMessage decode: target.
+ self assert: (cref isKindOf: SCCPConnectionRefused).
+ self assert: cref dst = 16r03001A.
+ ]
+
testRlsd [
| target rlsd |
diff --git a/sccp/SCCP.st b/sccp/SCCP.st
index 9f16a98..e9862da 100644
--- a/sccp/SCCP.st
+++ b/sccp/SCCP.st
@@ -364,6 +364,62 @@ SCCPMessage subclass: SCCPConnectionConfirm [
]
]
+SCCPMessage subclass: SCCPConnectionRefused [
+ | dst cause |
+
+ <category: 'OsmoNetwork-SCCP'>
+ <comment: 'I hold the data of a connection refused.'>
+
+ SCCPConnectionRefused class >> msgType [
+ <category: 'factory'>
+ ^SCCPHelper msgCref
+ ]
+
+ SCCPConnectionRefused class >> initWithDst: aDst cause: aCause [
+ <category: 'creation'>
+ ^self new
+ dst: aDst;
+ cause: aCause;
+ yourself
+ ]
+
+ SCCPConnectionRefused class >> parseFrom: aMsg [
+ | dst cause |
+ <category: 'parsing'>
+
+ dst := SCCPAddrReference fromByteArray: (aMsg copyFrom: 2 to: 4).
+ cause := aMsg at: 5.
+ ^self initWithDst: dst cause: cause.
+ ]
+
+ dst: aDst [
+ dst := aDst
+ ]
+
+ dst [
+ ^dst
+ ]
+
+ cause: aCause [
+ cause := aCause
+ ]
+
+ cause [
+ ^cause
+ ]
+
+ writeOn: aMsg [
+ <category: 'encoding'>
+
+ aMsg putByte: self class msgType.
+ SCCPAddrReference store: dst on: aMsg.
+ aMsg putByte: cause.
+
+ "End of optional?"
+ aMsg putByte: 1; putByte: 0.
+ ]
+]
+
SCCPMessage subclass: SCCPConnectionData [
| dst data |