1
0
Fork 0

sccp: Implement connection refused parsing and handling

The code can not parse the optional elements yet.
This commit is contained in:
Holger Hans Peter Freyther 2014-07-09 13:37:17 +02:00
parent cb55eb5dcf
commit fc6e258ac0
2 changed files with 70 additions and 0 deletions

View File

@ -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 |

View File

@ -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 |