gsm48: Start parsing the GSM Immediate Assign Command
Introduce some pragmas to reduce the amount of code to write, parse the immediate assign command. The restoctet parsing and writing is a bit odd as this element consumes up to 11 bytes.
This commit is contained in:
parent
e180b60385
commit
8ae28306b1
150
GSM48.st
150
GSM48.st
|
@ -25,11 +25,34 @@ IEBase subclass: GSM48IE [
|
|||
<category: 'OsmoGSM'>
|
||||
<comment: 'I am a Information Element for GSM48'>
|
||||
|
||||
GSM48IE class [
|
||||
| gsmName gsmElementId gsmIeMask |
|
||||
gsmName: aName [
|
||||
<category: 'gsm-pragma'>
|
||||
gsmName := aName asSymbol
|
||||
]
|
||||
|
||||
gsmElementId: anId [
|
||||
<category: 'gsm-pragma'>
|
||||
gsmElementId := anId
|
||||
]
|
||||
|
||||
gsmIeMask: aMask [
|
||||
<category: 'gsm-pragma'>
|
||||
gsmIeMask := aMask
|
||||
]
|
||||
]
|
||||
|
||||
GSM48IE class >> ieMask [
|
||||
"Some IEs encode the IE and the value into one. Return the mask to be used
|
||||
to determine the IE and see if it is matching."
|
||||
^ 16rFF
|
||||
]
|
||||
|
||||
GSM48IE class >> elementId [
|
||||
<category: 'gsm-pragma'>
|
||||
^ gsmElementId
|
||||
]
|
||||
]
|
||||
|
||||
GSM48IE subclass: GSM48SimpleTag [
|
||||
|
@ -88,6 +111,7 @@ GSM48IE subclass: GSM48DataHolder [
|
|||
^ Osmo.TLVDescription new
|
||||
parseClass: self; beTLV;
|
||||
minSize: self validSizes first maxSize: self validSizes last;
|
||||
instVarName: gsmName;
|
||||
yourself
|
||||
]
|
||||
|
||||
|
@ -150,11 +174,25 @@ GSM48IE subclass: GSM48SimpleData [
|
|||
<category: 'OsmoGSM'>
|
||||
<comment: 'I am the base for some simple data encapsulated'>
|
||||
|
||||
GSM48SimpleData class [
|
||||
| gsmLength |
|
||||
|
||||
gsmLength: aLength [
|
||||
<category: 'gsm-ie'>
|
||||
gsmLength := aLength
|
||||
]
|
||||
|
||||
length [
|
||||
<category: 'gsm-ie'>
|
||||
^ gsmLength
|
||||
]
|
||||
]
|
||||
|
||||
GSM48SimpleData class >> asTLVDescription [
|
||||
<category: 'parsing'>
|
||||
^ Osmo.TLVDescription new
|
||||
valueSize: self length; beTV;
|
||||
parseClass: self; yourself
|
||||
instVarName: gsmName; parseClass: self; yourself
|
||||
]
|
||||
|
||||
GSM48SimpleData class >> initWithData: aData [
|
||||
|
@ -211,10 +249,92 @@ GSM48IE subclass: GSM48SimpleData [
|
|||
]
|
||||
]
|
||||
|
||||
GSM48SimpleData subclass: GSM48PageAndDedicatedMode [
|
||||
<category: 'OsmoGSM'>
|
||||
<comment: 'I represent IE 10.5.2.26 and 10.5.2.25b'>
|
||||
|
||||
<gsmName: 'pageAndDedicatedMode'>
|
||||
<gsmLength: 1>
|
||||
]
|
||||
|
||||
GSM48SimpleData subclass: GSM48ChannelOrPacketDescription [
|
||||
<category: 'OsmoGSM'>
|
||||
<comment: 'I represent a 10.5.2.5 or 10.5.2.25a. Conditionals
|
||||
can not be easily expressed yet.'>
|
||||
|
||||
<gsmName: 'channelOrPacketDescription'>
|
||||
<gsmLength: 3>
|
||||
]
|
||||
|
||||
GSM48SimpleData subclass: GSM48TimingAdvance [
|
||||
<category: 'OsmoGSM'>
|
||||
<comment: 'I represent a 10.5.2.40'>
|
||||
|
||||
<gsmName: 'timingAdvance'>
|
||||
<gsmLength: 1>
|
||||
]
|
||||
|
||||
GSM48SimpleData subclass: GSM48StartingTime [
|
||||
<category: 'OsmoGSM'>
|
||||
<comment: 'I represent a 10.5.2.38'>
|
||||
|
||||
<gsmName: 'startingTime'>
|
||||
<gsmLength: 3>
|
||||
<gsmElementId: 16r7C>
|
||||
]
|
||||
|
||||
GSM48SimpleData subclass: GSM48RequestReference [
|
||||
<category: 'OsmoGSM'>
|
||||
<comment: 'I represent a 10.5.2.30 Request Reference'>
|
||||
|
||||
<gsmName: 'requestReference'>
|
||||
<gsmLength: 3>
|
||||
]
|
||||
|
||||
GSM48DataHolder subclass: GSM48IARestOctets [
|
||||
<category: 'OsmoGSM'>
|
||||
<comment: 'I represent a GSM 04.08 IA Rest Octets as of 10.5.2.16'>
|
||||
|
||||
<gsmName: 'rest_octets'>
|
||||
|
||||
GSM48IARestOctets class >> validSizes [ <category: 'parsing'> ^ 0 to: 11 ]
|
||||
GSM48IARestOctets class >> length: aStream [
|
||||
<category: 'parsing'>
|
||||
self shouldNotImplement
|
||||
]
|
||||
|
||||
GSM48IARestOctets class >> asTLVDescription [
|
||||
<category: 'parsing'>
|
||||
^ super asTLVDescription beTV; yourself
|
||||
]
|
||||
|
||||
GSM48IARestOctets class >> parseFrom: aStream [
|
||||
<category: 'parsing'>
|
||||
"Consume the rest of the stream. There is no length for the octets"
|
||||
^ self initWithData: (aStream upToEnd)
|
||||
]
|
||||
|
||||
writeOn: aMsg [
|
||||
<category: 'serialization'>
|
||||
^ self shouldNotImplement
|
||||
]
|
||||
|
||||
writeOnDirect: aMsg [
|
||||
<category: 'serialization'>
|
||||
aMsg putByteArray: self data
|
||||
]
|
||||
]
|
||||
|
||||
GSM48DataHolder subclass: GSM48MobileAllocation [
|
||||
<category: 'OsmoGSM'>
|
||||
<comment: 'I represent a GSM 04.08 Mobile Allocation as of 10.5.2.21'>
|
||||
|
||||
<gsmName: 'mobileAllocation'>
|
||||
|
||||
GSM48MobileAllocation class >> validSizes [ ^ 0 to: 8 ]
|
||||
]
|
||||
|
||||
GSM48SimpleData subclass: GSM48KeySeqLuType [
|
||||
| val |
|
||||
|
||||
<category: 'OsmoGSM'>
|
||||
<comment: 'This byte is shared for two things'>
|
||||
|
||||
|
@ -2249,6 +2369,29 @@ GSM48RRMessage subclass: GSM48RRAssignmentComplete [
|
|||
]
|
||||
]
|
||||
|
||||
GSM48RRMessage subclass: GSM48RRImmediateAssignCommand [
|
||||
<category: 'OsmoGSM'>
|
||||
<comment: 'I represent a GSM 04.08 9.1.18 Immediate assignment'>
|
||||
|
||||
GSM48RRImmediateAssignCommand class [
|
||||
messageType [ <category: 'parsing'> ^ self msgImmAssignment ]
|
||||
]
|
||||
|
||||
GSM48RRImmediateAssignCommand class >> tlvDescription [
|
||||
<category: 'parsing'>
|
||||
^ OrderedCollection new
|
||||
add: GSM48PageAndDedicatedMode asTLVDescription;
|
||||
"TODO: properly handle conditionals"
|
||||
add: GSM48ChannelOrPacketDescription asTLVDescription;
|
||||
add: GSM48RequestReference asTLVDescription;
|
||||
add: GSM48TimingAdvance asTLVDescription;
|
||||
add: GSM48MobileAllocation asTLVDescription;
|
||||
add: (GSM48StartingTime asTLVDescription beOptional; yourself);
|
||||
add: GSM48IARestOctets asTLVDescription;
|
||||
yourself
|
||||
]
|
||||
]
|
||||
|
||||
GSM48SSMessage subclass: GSM48SSFacility [
|
||||
<category: 'OsmoGSM'>
|
||||
|
||||
|
@ -2312,6 +2455,7 @@ Eval [
|
|||
GSM48CCStatus initialize.
|
||||
|
||||
GSM48RRAssignmentComplete initialize.
|
||||
GSM48RRImmediateAssignCommand initialize.
|
||||
|
||||
GSM48SSFacility initialize.
|
||||
GSM48SSRegister initialize.
|
||||
|
|
11
Tests.st
11
Tests.st
|
@ -290,6 +290,17 @@ TestCase subclass: GSM48Test [
|
|||
self assert: GSM48AuthRej new toMessage asByteArray = inp.
|
||||
]
|
||||
|
||||
testImmediateAssignment [
|
||||
| inp dec |
|
||||
"Without 2D for the L2 pseudo length"
|
||||
inp := #(16r06 16r3F 16r03 16r20 16rE0 16r03 16r1A 16r0A 16r2F
|
||||
16r00 16r00 16r2B 16r2B 16r2B 16r2B 16r2B 16r2B 16r2B
|
||||
16r2B 16r2B 16r2B 16r2B) asByteArray.
|
||||
dec := GSM48MSG decode: inp readStream.
|
||||
self assert: dec type = GSM48RRImmediateAssignCommand messageType.
|
||||
self assert: dec toMessage asByteArray = inp.
|
||||
]
|
||||
|
||||
testCalledBCDNumber [
|
||||
| dec |
|
||||
dec := GSMCalledBCDNumber initWithData: #(145 51 83 102 246) asByteArray.
|
||||
|
|
Reference in New Issue