diff --git a/BSCIPAConnection.st b/BSCIPAConnection.st index de7ef98..1ffe48b 100644 --- a/BSCIPAConnection.st +++ b/BSCIPAConnection.st @@ -18,8 +18,25 @@ PackageLoader fileInPackage: 'OsmoNetwork'. +OsmoGSM.SCCPHandler subclass: BSCSCCPHandler [ + | bsc | + + + BSCSCCPHandler class >> initWith: aBSC [ + ^ self new + instVarNamed: #bsc put: aBSC; yourself + ] + + newConnection: aConnection [ + self logNotice: 'New incoming SCCP connection %1 on the BSC %2' + % {aConnection srcRef. bsc lac} area: #bsc. + + aConnection release. + ] +] + Object subclass: BSCIPAConnection [ - | socket config demuxer writeQueue muxer dispatcher | + | socket config demuxer writeQueue muxer dispatcher sccp tx | @@ -31,6 +48,15 @@ Object subclass: BSCIPAConnection [ yourself ] + BSCIPAConnection class >> terminate: aProc [ + "Make sure it is dead!" + aProc ifNil: [^true]. + + [aProc isTerminated] whileFalse: [aProc terminate]. + ] + + lac [ ^ config lac ] + socket: aSocket [ socket := aSocket. writeQueue := SharedQueue new. @@ -40,16 +66,47 @@ Object subclass: BSCIPAConnection [ dispatcher := Osmo.IPADispatcher new. dispatcher initialize. + + sccp := BSCSCCPHandler initWith: self. + sccp registerOn: dispatcher. + sccp connection: self. + + "Drain the send queue in a new process" + tx := [ + [[ + | msg | + msg := writeQueue next. + socket nextPutAllFlush: msg. + ] repeat. + ] ensure: [ + self logNotice: 'BSC TX queue lac: %1 finished' % {self lac} area: #bsc] + ] fork. + + ] + + send: aMsg with: aType [ + muxer nextPut: aMsg with: aType. ] process [ "Drive the BSC process. This will send/queue messages" - socket logNotice: 'closing down' area: #bsc. + + socket logNotice: 'Processing for lac %1' % {self lac} area: #bsc. + + [ + | msg | + msg := demuxer next. + dispatcher dispatch: msg first with: msg second. + ] repeat. + + socket close. ] terminateAll [ "Bring down everything that happens for this BSC. This is a reset" - self logNotice: 'BSC lac: %1 terminating.' % {config lac} area: #bsc. + self logNotice: 'BSC lac: %1 terminating.' % {self lac} area: #bsc. + + self class terminate: tx. ] ] diff --git a/MSC.st b/MSC.st index 628410c..8b0d10c 100644 --- a/MSC.st +++ b/MSC.st @@ -67,6 +67,7 @@ Object subclass: MSCBSCConnectionHandler [ ] on: Exception do: [:ex | self logError: 'Unexpected exception for lac: %1' % {aConfig lac} area: #bsc. + thisContext backtraceOn: Transcript. ]] ensure: [ self logNotice: 'BSC being disconnected for lac: %1' % {aConfig lac} area: #bsc. diff --git a/package.xml b/package.xml index d3bb7ea..96696b3 100644 --- a/package.xml +++ b/package.xml @@ -3,6 +3,7 @@ OsmoMSC OsmoLogging OsmoNetwork + OsmoGSM Logging.st VLR.st