smalltalk
/
osmo-st-all
Archived
1
0
Fork 0
This repository has been archived on 2022-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
osmo-st-all/TestPhone.st

104 lines
2.4 KiB
Smalltalk
Raw Normal View History

2010-11-14 21:37:50 +00:00
PackageLoader fileInPackage: 'OsmoNetwork'.
Object subclass: IPAConnection [
| socket demuxer queue muxer dispatcher sccp ipa |
IPAConnection class >> initWith: anAddr port: aPort token: aToken [
^ (self new)
socket: (Sockets.Socket remote: anAddr port: aPort);
setup: aToken;
yourself
]
socket: aSocket [
socket := aSocket.
]
setup: aToken [
demuxer := Osmo.IPADemuxer initOn: socket.
queue := SharedQueue new.
muxer := Osmo.IPAMuxer initOn: queue.
dispatcher := Osmo.IPADispatcher new.
dispatcher initialize.
sccp := SCCPHadler new.
sccp registerOn: dispatcher.
ipa := Osmo.IPAProtoHandler new.
ipa registerOn: dispatcher.
ipa muxer: muxer.
ipa token: aToken
]
serve [
[true] whileTrue: [
[
| data |
data := demuxer next.
dispatcher dispatch: data first with: data second.
self drainSendQueue.
] on: SystemExceptions.EndOfStream do: [:e | ^ false ]
]
]
drainSendQueue [
[queue isEmpty] whileFalse: [
| msg |
msg := queue next.
socket nextPutAllFlush: msg.
]
]
]
Object subclass: IPAConfig [
| socket addr port token connection sem |
2010-11-14 21:37:50 +00:00
addr: anAddr port: aPort [
addr := anAddr.
port := aPort.
]
token: aToken [
token := aToken.
]
connect [
sem := Semaphore new.
2010-11-14 21:37:50 +00:00
connection := IPAConnection initWith: addr port: port token: token.
]
connection [
^ connection
]
serve [
[
connection serve.
'Connection disconnected' printNl.
sem signal.
] fork.
]
2010-11-14 21:37:50 +00:00
semaphore [ ^ sem ]
2010-11-14 21:37:50 +00:00
]
Object subclass: MessageTests [
MessageTests class >> createLU [
| lu bssap msg sccp |
lu := LocationUpdatingRequest new.
lu mi imsi: '666666666666'.
msg := IEMessage initWith: GSM0808Helper msgComplL3.
msg addIe: (GSMCellIdentifier initWith: 274 mnc: 8 lac: 4099 ci: 40000).
msg addIe: (GSMLayer3Info initWith: lu).
bssap := BSSAPManagement initWith: msg.
sccp := Osmo.SCCPHelper createCR: 666 dest: (Osmo.SCCPAddress createWith: 254) data: bssap.
sccp asByteArray printNl.
^ sccp asByteArray.
]
]