private void rewriteLocalAddressIfGTPresentAndRouteOnSsn(Dialog d) { SccpAddress localAddress = d.getLocalAddress(); if (localAddress.getGlobalTitle() != null && localAddress.getAddressIndicator().getRoutingIndicator() != RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE) { SccpAddress newLocalAddress = new SccpAddressImpl(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, localAddress.getGlobalTitle(), localAddress.getSignalingPointCode(), localAddress.getSubsystemNumber()); d.setLocalAddress(newLocalAddress); LOGGER.debug("rewriteCalledPartyIfGTPresent from={} to={}", localAddress, newLocalAddress); } }
/** * Checks if SSN matches between rule address pattern and provided destination address. SSN is assumed to always match in * case it has insignificant value or pattern AI SSNPresent flag is set to false. * * @param address - a provided address to match * @param pattern - a rule pattern address * @return true if SSN is present in both pattern and received addresses and they are the same or pattern has SSN flag unset * in AI (bit 7)(isSsnPresent = false for pattern) or pattern SSN value is insignificant */ private boolean isSsnMatch(SccpAddress address, SccpAddress pattern) { if (!isSsnSignificant(pattern.getSubsystemNumber()) || !pattern.getAddressIndicator().isSSNPresent()) { if (logger.isTraceEnabled()) { logger.trace(String.format("SSN is not present or insignificant [%s]. Assume SSN matches. Return True", pattern.getSubsystemNumber())); } return true; } if (pattern.getAddressIndicator().isSSNPresent() && address.getAddressIndicator().isSSNPresent()) { if (address.getSubsystemNumber() == pattern.getSubsystemNumber()) { return true; } } if (logger.isTraceEnabled()) { logger.trace(String.format( "SSN didn't match. Pattern: isSsnPresent=%s, SSN=%s Address: isSsnPresent=%s, SSN=%s Return False", pattern.getAddressIndicator().isSSNPresent(), pattern.getSubsystemNumber(), address.getAddressIndicator() .isSSNPresent(), address.getSubsystemNumber())); } return false; }
public static SccpDialogId extractFromSccpMessage(SccpDataMessage msg, boolean incoming) { String remoteGT; int remoteSSN, localSSN; if (incoming) { // remoteGT may be null in some cases, e.g. ATI request remoteGT = Optional.ofNullable(msg.getCallingPartyAddress().getGlobalTitle()).map(GlobalTitle::getDigits) .orElse(null); remoteSSN = msg.getCallingPartyAddress().getSubsystemNumber(); localSSN = msg.getCalledPartyAddress().getSubsystemNumber(); } else { // outgoing // remoteGT may be null in some cases, e.g. ATI request remoteGT = Optional.ofNullable(msg.getCalledPartyAddress().getGlobalTitle()).map(GlobalTitle::getDigits) .orElse(null); remoteSSN = msg.getCalledPartyAddress().getSubsystemNumber(); localSSN = msg.getCallingPartyAddress().getSubsystemNumber(); } return new SccpDialogId(remoteGT, remoteSSN, localSSN); }
if (!translationAddress.getAddressIndicator().isPCPresent()) { int targetSsn = translationAddress.getSubsystemNumber(); if (targetSsn == 0) targetSsn = msg.getCalledPartyAddress().getSubsystemNumber(); if (this.sccpStackImpl.router.spcIsLocal(translationAddress.getSignalingPointCode())) { translationAddress.getSignalingPointCode()); if (remoteSpc == null) { if (logger.isEnabledFor(Level.WARN)) { logger.warn(String.format( "Received SccpMessage=%s for Translation but no %s Remote Signaling Pointcode = %d resource defined ", msg, destName, translationAddress.getSignalingPointCode())); logger.warn(String.format( "Received SccpMessage=%s for Translation but %s Remote Signaling Pointcode = %d is prohibited ", msg, destName, translationAddress.getSignalingPointCode())); logger.warn(String .format("Received SccpMessage=%s for Translation but %s Remote Signaling Pointcode = %d is congested with level %d ", msg, destName, translationAddress.getSignalingPointCode(), remoteSpc.getCurrentRestrictionLevel())); if (translationAddress.getAddressIndicator().getRoutingIndicator() == RoutingIndicator.ROUTING_BASED_ON_DPC_AND_SSN) { if (targetSsn != 1) { RemoteSubSystem remoteSubSystem = this.sccpStackImpl.getSccpResource().getRemoteSsn( translationAddress.getSignalingPointCode(), targetSsn); if (remoteSubSystem == null) {
SccpAddress locAddr2 = sccpParameterFact.createSccpAddress(locAddr.getAddressIndicator().getRoutingIndicator(), locAddr.getGlobalTitle(), locAddr.getSignalingPointCode(), smscPropertiesManagement.getHlrSsn()); dialog.setLocalAddress(locAddr2);
@Override public String getOriginatorSccpAddress() { if (correlationIdValue.getOriginatorSccpAddress() != null && correlationIdValue.getOriginatorSccpAddress().getGlobalTitle() != null) return correlationIdValue.getOriginatorSccpAddress().getGlobalTitle().getDigits(); else return null; }
private boolean matchGt( SccpAddress address, SccpAddress patternAddress ) { GlobalTitleIndicator gti = address.getAddressIndicator().getGlobalTitleIndicator(); GlobalTitle patternGT = patternAddress.getGlobalTitle(); switch (gti) { case GLOBAL_TITLE_INCLUDES_NATURE_OF_ADDRESS_INDICATOR_ONLY: GlobalTitle0001 gt = (GlobalTitle0001) address.getGlobalTitle(); GlobalTitle0011 gt1 = (GlobalTitle0011) address.getGlobalTitle(); GlobalTitle0100 gt2 = (GlobalTitle0100) address.getGlobalTitle(); if (!matchPattern(gt2.getDigits(), patternAddress.getGlobalTitle().getDigits())) { if (logger.isDebugEnabled()) { logger.debug(String.format("digits didn't match. Pattern digits=%s Address Digits=%s Return False", GlobalTitle0010 gt3 = (GlobalTitle0010) address.getGlobalTitle(); if (!matchPattern(gt3.getDigits(), patternAddress.getGlobalTitle().getDigits())) { if (logger.isDebugEnabled()) { logger.debug(String.format("digits didn't match. Pattern digits=%s Address Digits=%s Return False",
private NetworkIdStateImpl getRoutingAddressStatusForRoutingAddress(SccpAddress routingAddress, int affectedPc) { if (routingAddress != null && routingAddress.getAddressIndicator().isPCPresent()) { boolean affectedByPc = true; if ((affectedPc >= 0 && routingAddress.getSignalingPointCode() != affectedPc)) affectedByPc = false; boolean spcIsLocal = spcIsLocal(routingAddress.getSignalingPointCode()); if (spcIsLocal) { return new NetworkIdStateImpl(affectedByPc); } RemoteSignalingPointCode remoteSpc = sccpStack.getSccpResource().getRemoteSpcByPC( routingAddress.getSignalingPointCode()); if (remoteSpc == null) { return new NetworkIdStateImpl(affectedByPc); } if (remoteSpc.isRemoteSpcProhibited()) { return new NetworkIdStateImpl(false, affectedByPc); } int congLevel = SccpCongestionControl.generateSccpUserCongLevel(remoteSpc.getCurrentRestrictionLevel()); if (congLevel > 0) { return new NetworkIdStateImpl(congLevel, affectedByPc); } return new NetworkIdStateImpl(affectedByPc); } // we return here value that this affectedPc does not affect this rule return new NetworkIdStateImpl(false); }
private int getMaxUserDataLengthForGT(SccpAddress calledPartyAddress, SccpAddress callingPartyAddress, int msgNetworkId) { Rule rule = this.router.findRule(calledPartyAddress, callingPartyAddress, false, msgNetworkId); if (rule == null) { return 0; } SccpAddress translationAddressPri = this.router.getRoutingAddress(rule.getPrimaryAddressId()); if (translationAddressPri == null) { return 0; } return getMaxUserDataLengthForDpc(translationAddressPri.getSignalingPointCode(), calledPartyAddress, callingPartyAddress); }
if (address.getAddressIndicator().getRoutingIndicator() == RoutingIndicator.ROUTING_BASED_ON_DPC_AND_SSN) { if (logger.isDebugEnabled()) { logger.debug("RoutingIndicator == ROUTING_BASED_ON_DPC_AND_SSN. Return");
dm.opc = message.getIncomingOpc(); dm.dpc = message.getIncomingDpc(); dm.callingSsn = message.getCallingPartyAddress().getSubsystemNumber(); dm.calledSsn = message.getCalledPartyAddress().getSubsystemNumber(); GlobalTitle gt = message.getCallingPartyAddress().getGlobalTitle(); if (gt != null) dm.callingPA = gt.getDigits(); gt = message.getCalledPartyAddress().getGlobalTitle(); if (gt != null) dm.calledPA = gt.getDigits();
int ssn = msg.getCalledPartyAddress().getSubsystemNumber(); if (ssn == 1) { return; RoutingIndicator ri = calledPartyAddress.getAddressIndicator().getRoutingIndicator(); switch (ri) { case ROUTING_BASED_ON_DPC_AND_SSN: int ssn = msg.getCalledPartyAddress().getSubsystemNumber(); if (ssn == 1) {
public int compare(RuleImpl o1, RuleImpl o2) { String digits1 = o1.getPattern().getGlobalTitle().getDigits(); String digits2 = o2.getPattern().getGlobalTitle().getDigits(); // Normalize rule. Remove all separator digits1 = digits1.replaceAll(SECTION_SEPARTOR, ""); digits2 = digits2.replaceAll(SECTION_SEPARTOR, ""); // If a rule 1 is not OriginationType.All and rule 2 is OriginationType.All we put rule 1 first if (o1.getOriginationType() != OriginationType.ALL && o2.getOriginationType() == OriginationType.ALL) return -1; if (o1.getOriginationType() == OriginationType.ALL && o2.getOriginationType() != OriginationType.ALL) return 1; // Check if digits are exactly same. In that case we sort based on the callingDigits if ( digits1.equals( digits2 )) { // if rule1 has calling party and rule2 doesn't then we put rule1 first if ( o1.getPatternCallingAddress() != null && o2.getPatternCallingAddress() == null ) { return -1; } else if ( o1.getPatternCallingAddress() == null && o2.getPatternCallingAddress() != null ) { return 1; } else if ( o1.getPatternCallingAddress() != null && o2.getPatternCallingAddress() != null ) { // both have calling party addresses. lets compare these 2 digits1 = o1.getPatternCallingAddress().getGlobalTitle().getDigits(); digits2 = o2.getPatternCallingAddress().getGlobalTitle().getDigits(); // Normalize rule. Remove all separator digits1 = digits1.replaceAll(SECTION_SEPARTOR, ""); digits2 = digits2.replaceAll(SECTION_SEPARTOR, ""); return compareDigits( digits1, digits2 ); } } return compareDigits( digits1, digits2 ); }
protected void sendMessageToMtp(SccpAddressedMessageImpl msg) throws Exception { msg.setOutgoingDpc(msg.getCalledPartyAddress().getSignalingPointCode()); // if (msg.getSccpCreatesSls()) { // msg.setSls(this.sccpStackImpl.newSls()); // } ReturnCauseValue er = this.send(msg); if (er != null) { this.sendSccpError(msg, er); } }
public void write(SccpAddress ai, OutputElement xml) throws XMLStreamException { xml.setAttribute(POINT_CODE, ai.getSignalingPointCode()); xml.setAttribute(SUBSYSTEM_NUMBER, ai.getSubsystemNumber()); xml.add(ai.getAddressIndicator(), AI, AddressIndicator.class); xml.add(ai.getGlobalTitle(), GLOBAL_TITLE); }
&& addr.getAddressIndicator().getRoutingIndicator() == RoutingIndicator.ROUTING_BASED_ON_DPC_AND_SSN) { if (!addr.getAddressIndicator().isPCPresent()) { msgAddr.setCallingPartyAddress(new SccpAddressImpl(RoutingIndicator.ROUTING_BASED_ON_DPC_AND_SSN, null, msgAddr.getIncomingOpc(), addr .getSubsystemNumber()));
int patternNumberOfSecs = (pattern.getGlobalTitle().getDigits().split("/").length - 1); throw new Exception(String.format(SccpOAMMessage.NO_PRIMARY_ADDRESS, pAddressId)); int primAddNumberOfSecs = (pattern.getGlobalTitle().getDigits().split("/").length - 1); if (maskumberOfSecs != primAddNumberOfSecs) { throw new Exception(SccpOAMMessage.SEC_MISMATCH_PRIMADDRESS); throw new Exception(String.format(SccpOAMMessage.NO_BACKUP_ADDRESS, sAddressId)); int secAddNumberOfSecs = (pattern.getGlobalTitle().getDigits().split("/").length - 1); if (maskumberOfSecs != secAddNumberOfSecs) { throw new Exception(SccpOAMMessage.SEC_MISMATCH_SECADDRESS);
private void sendManagementMessage(int dpc, int messageTypeCode, int affectedSsn, int subsystemMultiplicityIndicator) { Mtp3ServiceAccessPoint sap = this.sccpStackImpl.router.findMtp3ServiceAccessPoint(dpc, 0); if (sap == null) { logger.warn(String.format("Failed sendManagementMessage : Mtp3ServiceAccessPoint has not found for dpc=%d", dpc)); return; } int affectedPc; if (messageTypeCode == SST || messageTypeCode == SOG) { affectedPc = dpc; } else { affectedPc = sap.getOpc(); } SccpAddress calledAdd = new SccpAddressImpl(RoutingIndicator.ROUTING_BASED_ON_DPC_AND_SSN, null, dpc, 1); SccpAddress callingAdd = new SccpAddressImpl(RoutingIndicator.ROUTING_BASED_ON_DPC_AND_SSN, null, affectedPc, 1); byte[] data = createManagementMessageBody(messageTypeCode, affectedPc, affectedSsn, subsystemMultiplicityIndicator); SccpDataMessageImpl msg = (SccpDataMessageImpl) sccpProviderImpl.getMessageFactory().createDataMessageClass0(calledAdd, callingAdd, data, -1, false, null, null); if (logger.isDebugEnabled()) { logger.debug(String.format("Tx :SCMG Type=%d, Affected SSN=%d, AffectedPc=%d", messageTypeCode, affectedSsn, affectedPc)); } try { msg.setOutgoingDpc(msg.getCalledPartyAddress().getSignalingPointCode()); this.sccpRoutingControl.sendManagementMessage(msg); // this.sccpRoutingControl.sendMessageToMtp(msg); } catch (Exception e) { logger.error(String.format("Exception while trying to send SSP message=%s", msg), e); } }
String digits = address.getGlobalTitle().getDigits(); String patternDigits = pattern.getGlobalTitle().getDigits(); String primaryDigits = ruleAddress.getGlobalTitle().getDigits(); GlobalTitleIndicator gti = ruleAddress.getAddressIndicator().getGlobalTitleIndicator(); GlobalTitle primaryGt = ruleAddress.getGlobalTitle(); gt = createNewGT(gti, primaryGt, translatedDigits); gt = createNewGT(address.getAddressIndicator().getGlobalTitleIndicator(), address.getGlobalTitle(), translatedDigits); int ssn = address.getSubsystemNumber(); if (ruleAddress.getSubsystemNumber() > 0) ssn = ruleAddress.getSubsystemNumber(); SccpAddress sccpAddress = new SccpAddressImpl(ruleAddress.getAddressIndicator().getRoutingIndicator(), gt,ruleAddress.getSignalingPointCode(), ssn); sccpAddress.setTranslated(true); return sccpAddress;
int patternNumberOfSecs = (pattern.getGlobalTitle().getDigits().split("/").length - 1); int primAddNumberOfSecs = (pAddress.getGlobalTitle().getDigits().split("/").length - 1); if (maskumberOfSecs != primAddNumberOfSecs) { throw new Exception(SccpOAMMessage.SEC_MISMATCH_PRIMADDRESS); int secAddNumberOfSecs = (sAddress.getGlobalTitle().getDigits().split("/").length - 1); if (maskumberOfSecs != secAddNumberOfSecs) { throw new Exception(SccpOAMMessage.SEC_MISMATCH_SECADDRESS);