smalltalk
/
osmo-st-gsm
Archived
1
0
Fork 0

Decode: Create a MSGParser that recursively parses a message..

This commit is contained in:
Holger Hans Peter Freyther 2010-11-22 17:13:26 +01:00
parent c28b116689
commit f429cd36bb
2 changed files with 49 additions and 0 deletions

View File

@ -15,6 +15,42 @@ Object subclass: SCCPConnection [
]
]
Object subclass: MSGParser [
<comment: 'I take a SCCP message and recursively parse all the data'>
MSGParser class >> parse: aByteArray [
| sccp |
"Return a completely decoded subtree"
sccp := Osmo.SCCPMessage decode: aByteArray.
(sccp respondsTo: #data)
ifTrue: [
sccp data: (self decodeBSSAP: sccp data).
].
^ sccp
]
MSGParser class >> decodeBSSAP: aData [
| bssap |
bssap := BSSAPMessage decode: aData.
(bssap respondsTo: #data)
ifTrue: [
bssap data: (self decodeBSSMAP: bssap data).
].
^ bssap
]
MSGParser class >> decodeBSSMAP: aData [
| bssmap |
bssmap := IEMessage decode: aData with: GSM0808IE.
^ bssmap
]
]
Object subclass: SCCPHadler [
| connections last_ref |
<comment: 'I handle SCCP messages'>

View File

@ -151,4 +151,17 @@ TestCase subclass: TestMessages [
sccp := MessageTests createLU: handler.
self assert: sccp = #(1 154 2 0 2 2 4 2 66 254 15 32 0 30 87 5 8 0 114 244 128 16 3 156 64 23 17 5 8 112 0 240 0 0 0 51 7 97 102 102 102 102 102 246 0 ) asByteArray.
]
testMsgParser [
| msg bssap |
msg := MSGParser parse: #(1 154 2 0 2 2 4 2 66 254 15 32 0 30 87
5 8 0 114 244 128 16 3 156 64 23 17 5 8
112 0 240 0 0 0 51 7 97 102 102 102 102
102 246 0 ) asByteArray.
self assert: (msg isKindOf: Osmo.SCCPConnectionRequest).
bssap := msg data.
self assert: (bssap isKindOf: BSSAPManagement).
]
]