aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--BSSMAP.st5
-rw-r--r--Messages.st12
-rw-r--r--Tests.st9
3 files changed, 25 insertions, 1 deletions
diff --git a/BSSMAP.st b/BSSMAP.st
index d0b30df..a18d05d 100644
--- a/BSSMAP.st
+++ b/BSSMAP.st
@@ -1,6 +1,11 @@
Object subclass: GSM0808IE [
<category: 'osmo-message'>
<comment: 'Base class of IEs for GSM0808'>
+
+ type [
+ "Go through the elementId of the class"
+ ^ self class elementId
+ ]
]
Object subclass: GSM0808Helper [
diff --git a/Messages.st b/Messages.st
index 87ffa8c..d3bb805 100644
--- a/Messages.st
+++ b/Messages.st
@@ -96,6 +96,18 @@ Object subclass: IEMessage [
^ ies
]
+ findIE: type ifAbsent: block [
+ "Find the IE with the type"
+ self ies do: [:each |
+ each type = type
+ ifTrue: [
+ ^ each
+ ].
+ ].
+
+ ^ block value.
+ ]
+
writeOn: aMsg [
<category: 'creation'>
aMsg putByte: type.
diff --git a/Tests.st b/Tests.st
index 480bfc2..d5ac5c6 100644
--- a/Tests.st
+++ b/Tests.st
@@ -162,7 +162,7 @@ TestCase subclass: TestMessages [
]
testMsgParser [
- | msg bssap bssmap |
+ | msg bssap bssmap ies l3 |
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
@@ -175,5 +175,12 @@ TestCase subclass: TestMessages [
bssmap := bssap data.
self assert: (bssmap isKindOf: IEMessage).
+
+ ies := bssmap ies.
+ self assert: ies size = 2.
+
+ l3 := bssmap findIE: (GSMLayer3Info elementId) ifAbsent: [
+ self assert: false.
+ ].
]
]