1
0
Fork 0

fakebts: Make it easy to do a LU and get the current TMSI from it

Tests that require sending a CM Service Request require a TMSI. Add
a selector that helps to get the TMSI so it can be used in tests.
This commit is contained in:
Holger Hans Peter Freyther 2012-11-24 23:34:42 +01:00
parent c5a334ef8b
commit 4aa47e87b7
1 changed files with 52 additions and 0 deletions

View File

@ -97,6 +97,7 @@ Object subclass: OpenBSCTest [
| bts testFailed |
<category: 'OpenBSC-Test'>
<comment: 'I help in dealing with setup and teardown of a test'>
<import: OsmoGSM>
OpenBSCTest class >> initWith: aBTS [
<category: 'creation'>
@ -176,5 +177,56 @@ Object subclass: OpenBSCTest [
<category: 'verifying'>
^ testFailed
]
allocateTmsi: imsi [
| tmsi lchan lu msg |
"Do a LU and get the TMSI."
"2. Get a LCHAN"
lchan := self requireAnyChannel.
"3. Send the LU request"
lu := GSM48LURequest new.
lu lai
mcc: 1;
mnc: 1;
lac: 1.
lu mi imsi: imsi.
lchan sendGSM: lu toMessage.
"Now deal with what the NITB wants"
"4.1 Send the IMEI..."
msg := GSM48MSG decode: lchan nextSapi0Msg readStream.
(msg isKindOf: GSM48IdentityReq)
ifFalse: [^self error: 'Wanted identity request'].
(msg idType isIMEI)
ifFalse: [^self error: 'Wanted IMEI reqest'].
msg := GSM48IdentityResponse new.
msg mi imei: '6666666666666666'.
lchan sendGSM: msg toMessage.
"4.2 LU Accept"
msg := GSM48MSG decode: lchan nextSapi0Msg readStream.
(msg isKindOf: GSM48LUAccept)
ifFalse: [^self error: 'LU failed'].
tmsi := msg mi tmsi.
msg := GSM48TMSIReallocationComplete new.
lchan sendGSM: msg toMessage.
"4.3 MM Information for the time. ignore it"
msg := GSM48MSG decode: lchan nextSapi0Msg readStream.
(msg isKindOf: GSM48MMInformation)
ifFalse: [^self error: 'MM Information'].
"4.4 release.. if we now don't close the LCHAN it will
remain open for a bit. OpenBSC should and will start the
approriate timer soon(tm)"
msg := GSM48MSG decode: lchan nextSapi0Msg readStream.
(msg isKindOf: GSM48RRChannelRelease)
ifFalse: [^self error: 'RR Channel Release'].
"4.5.. be nice... for now and send a disconnect."
lchan releaseAllSapis.
^ tmsi.
]
]