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

Messages: Prepare to parse TV and TLV messages

Ask the BSSMAP type for the size of the payload. This does
not include the Tag and the Length field. BSSMAP and GSM48
behave a bit differently here. The support for T might still
be a bit broken.
This commit is contained in:
Holger Hans Peter Freyther 2010-11-27 13:59:16 +01:00
parent 6389190fb6
commit a57c26261c
2 changed files with 15 additions and 9 deletions

View File

@ -1,6 +1,10 @@
IEBase subclass: GSM0808IE [
<category: 'osmo-message'>
<comment: 'Base class of IEs for GSM0808'>
GSM0808IE class >> length: aByteArray [
^ (aByteArray at: 2).
]
]
Object subclass: GSM0808Helper [

View File

@ -30,14 +30,20 @@ Object subclass: IEMessage [
yourself
]
IEMessage class >> findIE: type with: data from: aIEBase [
IEMessage class >> findIE: data from: aIEBase on: aMsg [
"TODO: This needs to move some basic dispatch class"
"Find the IE that handles the type specified"
| type |
type := data at: 1.
aIEBase allSubclassesDo: [:each |
each elementId = type
ifTrue: [
^ each parseFrom: data.
| enc size |
size := each length: data.
enc := data copyFrom: 1 to: 2 + size.
aMsg addIe: (each parseFrom: enc).
^ 2 + size
].
].
@ -50,13 +56,9 @@ Object subclass: IEMessage [
dat := aByteArray copyFrom: 2.
[dat isEmpty not] whileTrue: [
| type size data |
type := dat at: 1.
size := dat at: 2.
data := dat copyFrom: 1 to: 2 + size.
dat := dat copyFrom: 3 + size.
msg addIe: (self findIE: type with: data from: aIEBase).
| consumed |
consumed := self findIE: dat from: aIEBase on: msg.
dat := dat copyFrom: consumed + 1.
].
^ msg