aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2012-03-25 18:35:42 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2012-03-25 18:52:54 +0200
commit7b43f3eed2aac68e46edda2506e5be012ed76546 (patch)
tree3bce7b9a93cdc8c19d19b1408cd93bf78935ed6b
parent73f8b9a05cc3d40169877f450b943db340cf7653 (diff)
streams: IEMessage is now working on streams all the way.zecke/use-streams
-rw-r--r--Messages.st15
-rw-r--r--SCCPHandler.st6
-rw-r--r--Tests.st2
3 files changed, 10 insertions, 13 deletions
diff --git a/Messages.st b/Messages.st
index a85d940..82d4bfc 100644
--- a/Messages.st
+++ b/Messages.st
@@ -68,15 +68,12 @@ Object subclass: IEMessage [
^ Exception signal: 'Unsupported IE type: ', type asString.
]
- IEMessage class >> decode: aByteArray with: aIEBase [
- | msg dat |
- msg := IEMessage initWith: (aByteArray at: 1).
-
- dat := aByteArray copyFrom: 2.
- [dat isEmpty not] whileTrue: [
- | consumed |
- consumed := self findIE: dat readStream from: aIEBase on: msg.
- dat := dat copyFrom: consumed + 1.
+ IEMessage class >> decode: aStream with: aIEBase [
+ | msg |
+ msg := IEMessage initWith: aStream next.
+
+ [aStream atEnd] whileFalse: [
+ self findIE: aStream from: aIEBase on: msg.
].
^ msg
diff --git a/SCCPHandler.st b/SCCPHandler.st
index ef75745..06ec21d 100644
--- a/SCCPHandler.st
+++ b/SCCPHandler.st
@@ -348,15 +348,15 @@ Object subclass: MSGParser [
bssap data: (GSM48MSG decode: bssap data)
]
ifFalse: [
- bssap data: (self decodeBSSMAP: bssap data).
+ bssap data: (self decodeBSSMAP: bssap data readStream).
].
^ bssap
]
- MSGParser class >> decodeBSSMAP: aData [
+ MSGParser class >> decodeBSSMAP: aStream [
| bssmap |
- bssmap := IEMessage decode: aData with: GSM0808IE.
+ bssmap := IEMessage decode: aStream with: GSM0808IE.
bssmap findIE: (GSMLayer3Info elementId) ifPresent: [:each |
each data: (GSM48MSG decode: each data).
].
diff --git a/Tests.st b/Tests.st
index 6197604..86e2683 100644
--- a/Tests.st
+++ b/Tests.st
@@ -91,7 +91,7 @@ TestCase subclass: GSM0808Test [
inp := #(16r57 16r05 16r08 16r00 16r72 16rF4 16r80 16r20 16r12
16r75 16r30 16r17 16r03 16r01 16r02 16r03) asByteArray.
- res := IEMessage decode: inp with: GSM0808IE.
+ res := IEMessage decode: inp readStream with: GSM0808IE.
self assert: res type = GSM0808Helper msgComplL3.
self assert: res ies size = 2.
]