/* * TeleStax, Open Source Cloud Communications Copyright 2012. * and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.mobicents.protocols.ss7.map.service.oam; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.ss7.map.MAPDialogImpl; import org.mobicents.protocols.ss7.map.MAPProviderImpl; import org.mobicents.protocols.ss7.map.api.MAPApplicationContext; import org.mobicents.protocols.ss7.map.api.MAPApplicationContextName; import org.mobicents.protocols.ss7.map.api.MAPApplicationContextVersion; import org.mobicents.protocols.ss7.map.api.MAPException; import org.mobicents.protocols.ss7.map.api.MAPOperationCode; import org.mobicents.protocols.ss7.map.api.primitives.AddressString; import org.mobicents.protocols.ss7.map.api.primitives.GSNAddress; import org.mobicents.protocols.ss7.map.api.primitives.IMSI; import org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString; import org.mobicents.protocols.ss7.map.api.primitives.MAPExtensionContainer; import org.mobicents.protocols.ss7.map.api.service.oam.MAPDialogOam; import org.mobicents.protocols.ss7.map.api.service.oam.MAPServiceOam; import org.mobicents.protocols.ss7.map.api.service.oam.MDTConfiguration; import org.mobicents.protocols.ss7.map.api.service.oam.TraceDepthList; import org.mobicents.protocols.ss7.map.api.service.oam.TraceEventList; import org.mobicents.protocols.ss7.map.api.service.oam.TraceInterfaceList; import org.mobicents.protocols.ss7.map.api.service.oam.TraceNETypeList; import org.mobicents.protocols.ss7.map.api.service.oam.TraceReference; import org.mobicents.protocols.ss7.map.api.service.oam.TraceReference2; import org.mobicents.protocols.ss7.map.api.service.oam.TraceType; import org.mobicents.protocols.ss7.tcap.api.TCAPException; import org.mobicents.protocols.ss7.tcap.api.tc.dialog.Dialog; import org.mobicents.protocols.ss7.tcap.asn.comp.Invoke; import org.mobicents.protocols.ss7.tcap.asn.comp.OperationCode; import org.mobicents.protocols.ss7.tcap.asn.comp.Parameter; import org.mobicents.protocols.ss7.tcap.asn.comp.ReturnResultLast; /** * * @author sergey vetyutnev * */ public class MAPDialogOamImpl extends MAPDialogImpl implements MAPDialogOam { protected MAPDialogOamImpl(MAPApplicationContext appCntx, Dialog tcapDialog, MAPProviderImpl mapProviderImpl, MAPServiceOam mapService, AddressString origReference, AddressString destReference) { super(appCntx, tcapDialog, mapProviderImpl, mapService, origReference, destReference); } @Override public Long addActivateTraceModeRequest(IMSI imsi, TraceReference traceReference, TraceType traceType, AddressString omcId, MAPExtensionContainer extensionContainer, TraceReference2 traceReference2, TraceDepthList traceDepthList, TraceNETypeList traceNeTypeList, TraceInterfaceList traceInterfaceList, TraceEventList traceEventList, GSNAddress traceCollectionEntity, MDTConfiguration mdtConfiguration) throws MAPException { return this.addActivateTraceModeRequest(_Timer_Default, imsi, traceReference, traceType, omcId, extensionContainer, traceReference2, traceDepthList, traceNeTypeList, traceInterfaceList, traceEventList, traceCollectionEntity, mdtConfiguration); } @Override public Long addActivateTraceModeRequest(int customInvokeTimeout, IMSI imsi, TraceReference traceReference, TraceType traceType, AddressString omcId, MAPExtensionContainer extensionContainer, TraceReference2 traceReference2, TraceDepthList traceDepthList, TraceNETypeList traceNeTypeList, TraceInterfaceList traceInterfaceList, TraceEventList traceEventList, GSNAddress traceCollectionEntity, MDTConfiguration mdtConfiguration) throws MAPException { boolean isTracingContext = false; boolean isNetworkLocUpContext = false; boolean isGprsLocationUpdateContext = false; if ((this.appCntx.getApplicationContextName() == MAPApplicationContextName.tracingContext) && (this.appCntx.getApplicationContextVersion() == MAPApplicationContextVersion.version1 || this.appCntx.getApplicationContextVersion() == MAPApplicationContextVersion.version2 || this.appCntx.getApplicationContextVersion() == MAPApplicationContextVersion.version3)) isTracingContext = true; if ((this.appCntx.getApplicationContextName() == MAPApplicationContextName.networkLocUpContext) && (this.appCntx.getApplicationContextVersion() == MAPApplicationContextVersion.version1 || this.appCntx.getApplicationContextVersion() == MAPApplicationContextVersion.version2 || this.appCntx.getApplicationContextVersion() == MAPApplicationContextVersion.version3)) isNetworkLocUpContext = true; if ((this.appCntx.getApplicationContextName() == MAPApplicationContextName.gprsLocationUpdateContext) && (this.appCntx.getApplicationContextVersion() == MAPApplicationContextVersion.version3)) isGprsLocationUpdateContext = true; if (!isTracingContext && !isNetworkLocUpContext && !isGprsLocationUpdateContext) throw new MAPException( "Bad application context name for activateTraceModeRequest: must be tracingContext_V1, V2 or V3, networkLocUpContext_V1, V2 or V3 or gprsLocationUpdateContext_V3"); Invoke invoke = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createTCInvokeRequest(); if (customInvokeTimeout == _Timer_Default) invoke.setTimeout(_Timer_m); else invoke.setTimeout(customInvokeTimeout); OperationCode oc = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createOperationCode(); oc.setLocalOperationCode((long) MAPOperationCode.activateTraceMode); invoke.setOperationCode(oc); ActivateTraceModeRequestImpl_Oam req = new ActivateTraceModeRequestImpl_Oam(imsi, traceReference, traceType, omcId, extensionContainer, traceReference2, traceDepthList, traceNeTypeList, traceInterfaceList, traceEventList, traceCollectionEntity, mdtConfiguration); AsnOutputStream aos = new AsnOutputStream(); req.encodeData(aos); Parameter p = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createParameter(); p.setTagClass(req.getTagClass()); p.setPrimitive(req.getIsPrimitive()); p.setTag(req.getTag()); p.setData(aos.toByteArray()); invoke.setParameter(p); Long invokeId; try { invokeId = this.tcapDialog.getNewInvokeId(); invoke.setInvokeId(invokeId); } catch (TCAPException e) { throw new MAPException(e.getMessage(), e); } this.sendInvokeComponent(invoke); return invokeId; } @Override public void addActivateTraceModeResponse(long invokeId, MAPExtensionContainer extensionContainer, boolean traceSupportIndicator) throws MAPException { boolean isTracingContext = false; boolean isNetworkLocUpContext = false; boolean isGprsLocationUpdateContext = false; if ((this.appCntx.getApplicationContextName() == MAPApplicationContextName.tracingContext) && (this.appCntx.getApplicationContextVersion() == MAPApplicationContextVersion.version1 || this.appCntx.getApplicationContextVersion() == MAPApplicationContextVersion.version2 || this.appCntx.getApplicationContextVersion() == MAPApplicationContextVersion.version3)) isTracingContext = true; if ((this.appCntx.getApplicationContextName() == MAPApplicationContextName.networkLocUpContext) && (this.appCntx.getApplicationContextVersion() == MAPApplicationContextVersion.version1 || this.appCntx.getApplicationContextVersion() == MAPApplicationContextVersion.version2 || this.appCntx.getApplicationContextVersion() == MAPApplicationContextVersion.version3)) isNetworkLocUpContext = true; if ((this.appCntx.getApplicationContextName() == MAPApplicationContextName.gprsLocationUpdateContext) && (this.appCntx.getApplicationContextVersion() == MAPApplicationContextVersion.version3)) isGprsLocationUpdateContext = true; if (!isTracingContext && !isNetworkLocUpContext && !isGprsLocationUpdateContext) throw new MAPException( "Bad application context name for activateTraceModeResponse: must be tracingContext_V1, V2 or V3, networkLocUpContext_V1, V2 or V3 or gprsLocationUpdateContext_V3"); ReturnResultLast resultLast = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory() .createTCResultLastRequest(); resultLast.setInvokeId(invokeId); if ((traceSupportIndicator || extensionContainer != null) && this.appCntx.getApplicationContextVersion().getVersion() >= 3) { // Operation Code OperationCode oc = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createOperationCode(); oc.setLocalOperationCode((long) MAPOperationCode.activateTraceMode); resultLast.setOperationCode(oc); ActivateTraceModeResponseImpl_Oam req = new ActivateTraceModeResponseImpl_Oam(extensionContainer, traceSupportIndicator); AsnOutputStream aos = new AsnOutputStream(); req.encodeData(aos); Parameter p = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createParameter(); p.setTagClass(req.getTagClass()); p.setPrimitive(req.getIsPrimitive()); p.setTag(req.getTag()); p.setData(aos.toByteArray()); resultLast.setParameter(p); } this.sendReturnResultLastComponent(resultLast); } @Override public Long addSendImsiRequest(ISDNAddressString msisdn) throws MAPException { return this.addSendImsiRequest(_Timer_Default, msisdn); } @Override public Long addSendImsiRequest(int customInvokeTimeout, ISDNAddressString msisdn) throws MAPException { if ((this.appCntx.getApplicationContextName() != MAPApplicationContextName.imsiRetrievalContext) || (this.appCntx.getApplicationContextVersion() != MAPApplicationContextVersion.version2)) throw new MAPException("Bad application context name for sendImsiRequest: must be imsiRetrievalContext_V2"); Invoke invoke = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createTCInvokeRequest(); if (customInvokeTimeout == _Timer_Default) invoke.setTimeout(_Timer_m); else invoke.setTimeout(customInvokeTimeout); OperationCode oc = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createOperationCode(); oc.setLocalOperationCode((long) MAPOperationCode.sendIMSI); invoke.setOperationCode(oc); SendImsiRequestImpl req = new SendImsiRequestImpl(msisdn); AsnOutputStream aos = new AsnOutputStream(); req.encodeData(aos); Parameter p = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createParameter(); p.setTagClass(req.getTagClass()); p.setPrimitive(req.getIsPrimitive()); p.setTag(req.getTag()); p.setData(aos.toByteArray()); invoke.setParameter(p); Long invokeId; try { invokeId = this.tcapDialog.getNewInvokeId(); invoke.setInvokeId(invokeId); } catch (TCAPException e) { throw new MAPException(e.getMessage(), e); } this.sendInvokeComponent(invoke); return invokeId; } @Override public void addSendImsiResponse(long invokeId, IMSI imsi) throws MAPException { if ((this.appCntx.getApplicationContextName() != MAPApplicationContextName.imsiRetrievalContext) || (this.appCntx.getApplicationContextVersion() != MAPApplicationContextVersion.version2)) throw new MAPException("Bad application context name for addSendImsiResponse: must be imsiRetrievalContext_V2"); ReturnResultLast resultLast = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createTCResultLastRequest(); resultLast.setInvokeId(invokeId); // Operation Code OperationCode oc = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createOperationCode(); oc.setLocalOperationCode((long) MAPOperationCode.sendIMSI); resultLast.setOperationCode(oc); SendImsiResponseImpl req = new SendImsiResponseImpl(imsi); AsnOutputStream aos = new AsnOutputStream(); req.encodeData(aos); Parameter p = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createParameter(); p.setTagClass(req.getTagClass()); p.setPrimitive(req.getIsPrimitive()); p.setTag(req.getTag()); p.setData(aos.toByteArray()); resultLast.setParameter(p); this.sendReturnResultLastComponent(resultLast); } }