From fc6e258ac0909d1e8ba93a2031459f7f755e15b4 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Wed, 9 Jul 2014 13:37:17 +0200 Subject: [PATCH] sccp: Implement connection refused parsing and handling The code can not parse the optional elements yet. --- Tests.st | 14 +++++++++++++ sccp/SCCP.st | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) 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 | + + + + + SCCPConnectionRefused class >> msgType [ + + ^SCCPHelper msgCref + ] + + SCCPConnectionRefused class >> initWithDst: aDst cause: aCause [ + + ^self new + dst: aDst; + cause: aCause; + yourself + ] + + SCCPConnectionRefused class >> parseFrom: aMsg [ + | dst cause | + + + 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 [ + + + 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 |