Skip to content

Commit

Permalink
fix for issue RestComm#192 @github SCCP Relay feature implementation
Browse files Browse the repository at this point in the history
Conflicts:
	cap/cap-api/src/main/java/org/mobicents/protocols/ss7/cap/api/CAPProvider.java
	cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/CAPProviderImpl.java
  • Loading branch information
Marek Pisarski authored and vetss committed May 10, 2017
1 parent 27b9324 commit 2186359
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@
import org.mobicents.protocols.ss7.inap.api.INAPParameterFactory;
import org.mobicents.protocols.ss7.isup.ISUPParameterFactory;
import org.mobicents.protocols.ss7.map.api.MAPParameterFactory;
import org.mobicents.protocols.ss7.sccp.parameter.SccpAddress;

/**
*
* @author sergey vetyutnev
* @author <a href="mailto:[email protected]">ProIDS sp. z o.o.</a>
*
*/
public interface CAPProvider extends Serializable {
Expand Down Expand Up @@ -107,4 +109,19 @@ public interface CAPProvider extends Serializable {
*/
int getCurrentDialogsCount();

/**
* Relay Initial Cap Message to other network node
* @param newServiceKey
* @param capMessage
* @throws CAPException
*/
void relayCapMessage(int newServiceKey, CAPMessage capMessage) throws CAPException;

/**
* Relay Initial Cap Message to other network node
* @param newServiceKey
* @param capMessage
* @throws CAPException
*/
void relayCapMessage(int newServiceKey, SccpAddress origAddress, SccpAddress destAddress, CAPMessage capMessage) throws CAPException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
/**
*
* @author sergey vetyutnev
* @author <a href="mailto:[email protected]">ProIDS sp. z o.o.</a>
*
*/
public interface CAPServiceCircuitSwitchedCall extends CAPServiceBase {
Expand All @@ -44,4 +45,11 @@ CAPDialogCircuitSwitchedCall createNewDialog(CAPApplicationContext appCntx, Sccp

void removeCAPServiceListener(CAPServiceCircuitSwitchedCallListener capServiceListener);

/**
* Create new structured dialog with default TransactionId.
* Used for SCCP relay functionality
* @param relayedLocalTrId
*/
CAPDialogCircuitSwitchedCall createNewRelayedDialog(CAPApplicationContext appCntx, SccpAddress origAddress, SccpAddress destAddress, Long relayedLocalTrId) throws CAPException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.mobicents.protocols.ss7.cap.api.CAPDialog;
import org.mobicents.protocols.ss7.cap.api.CAPDialogListener;
import org.mobicents.protocols.ss7.cap.api.CAPException;
import org.mobicents.protocols.ss7.cap.api.CAPMessage;
import org.mobicents.protocols.ss7.cap.api.CAPParameterFactory;
import org.mobicents.protocols.ss7.cap.api.CAPParsingComponentException;
import org.mobicents.protocols.ss7.cap.api.CAPProvider;
Expand Down Expand Up @@ -69,6 +70,7 @@
import org.mobicents.protocols.ss7.isup.impl.message.parameter.ISUPParameterFactoryImpl;
import org.mobicents.protocols.ss7.map.MAPParameterFactoryImpl;
import org.mobicents.protocols.ss7.map.api.MAPParameterFactory;
import org.mobicents.protocols.ss7.sccp.parameter.SccpAddress;
import org.mobicents.protocols.ss7.tcap.DialogImpl;
import org.mobicents.protocols.ss7.tcap.api.MessageType;
import org.mobicents.protocols.ss7.tcap.api.TCAPProvider;
Expand Down Expand Up @@ -113,6 +115,7 @@
/**
*
* @author sergey vetyutnev
* @author <a href="mailto:[email protected]">ProIDS sp. z o.o.</a>
*
*/
public class CAPProviderImpl implements CAPProvider, TCListener {
Expand Down Expand Up @@ -1302,4 +1305,12 @@ protected void fireTCAbort(Dialog tcapDialog, CAPGeneralAbortReason generalAbort
public int getCurrentDialogsCount() {
return this.tcapProvider.getCurrentDialogsCount();
}

public void relayCapMessage(int newServiceKey, CAPMessage capMessage) throws CAPException {
throw new RuntimeException("NotImplemented");
}

public void relayCapMessage(int newServiceKey, SccpAddress origAddress, SccpAddress destAddress, CAPMessage capMessage) throws CAPException {
throw new RuntimeException("NotImplemented");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
/**
*
* @author sergey vetyutnev
* @author <a href="mailto:[email protected]">ProIDS sp. z o.o.</a>
*
*/
public class CAPServiceCircuitSwitchedCallImpl extends CAPServiceBaseImpl implements CAPServiceCircuitSwitchedCall {
Expand All @@ -69,13 +70,19 @@ public CAPDialogCircuitSwitchedCall createNewDialog(CAPApplicationContext appCnt
@Override
public CAPDialogCircuitSwitchedCall createNewDialog(CAPApplicationContext appCntx, SccpAddress origAddress, SccpAddress destAddress, Long localTrId)
throws CAPException {
return this.createNewDialog(appCntx, origAddress, destAddress, null, null);
}

private CAPDialogCircuitSwitchedCall createNewDialog(CAPApplicationContext appCntx, SccpAddress origAddress, SccpAddress destAddress, Long localTrId, Long relayedLocalTrId)
throws CAPException {

// We cannot create a dialog if the service is not activated
if (!this.isActivated())
throw new CAPException(
"Cannot create CAPDialogCircuitSwitchedCall because CAPServiceCircuitSwitchedCall is not activated");

Dialog tcapDialog = this.createNewTCAPDialog(origAddress, destAddress, localTrId);
tcapDialog.setRelayedLocalDialogId(relayedLocalTrId);
CAPDialogCircuitSwitchedCallImpl dialog = new CAPDialogCircuitSwitchedCallImpl(appCntx, tcapDialog,
this.capProviderImpl, this);

Expand All @@ -84,6 +91,10 @@ public CAPDialogCircuitSwitchedCall createNewDialog(CAPApplicationContext appCnt
return dialog;
}

public CAPDialogCircuitSwitchedCall createNewRelayedDialog(CAPApplicationContext appCntx, SccpAddress origAddress, SccpAddress destAddress, Long relayedLocalTrId) throws CAPException {
return this.createNewDialog(appCntx, origAddress, destAddress, null, relayedLocalTrId);
}

@Override
public void addCAPServiceListener(CAPServiceCircuitSwitchedCallListener capServiceListener) {
super.addCAPServiceListener(capServiceListener);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
*
* @author baranowb
* @author sergey vetyutnev
* @author <a href="mailto:[email protected]">ProIDS sp. z o.o.</a>
*
*/
public interface Dialog extends Serializable {
Expand All @@ -53,6 +54,18 @@ public interface Dialog extends Serializable {
*/
Long getLocalDialogId();

/**
* returns relayed dialog ID.
*
* @return
*/
Long getRelayedLocalDialogId();

/**
* sets relayed dialog ID.
*/
void setRelayedLocalDialogId(Long relayedDialogId);

/**
* return the remote Dialog Id. This will be null if Dialog is locally originated and not confirmed yet
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
* @author baranowb
* @author amit bhayani
* @author sergey vetyutnev
* @author <a href="mailto:[email protected]">ProIDS sp. z o.o.</a>
*
*/
public class DialogImpl implements Dialog {
Expand All @@ -133,6 +134,7 @@ public class DialogImpl implements Dialog {
private long localTransactionId;
private byte[] remoteTransactionId;
private Long remoteTransactionIdObject;
private Long localRelayedTransactionIdObject;

private SccpAddress localAddress;
private SccpAddress remoteAddress;
Expand Down Expand Up @@ -545,7 +547,11 @@ public void send(TCBeginRequest event) throws TCAPSendException {
}

// now comps
tcbm.setOriginatingTransactionId(Utils.encodeTransactionId(this.localTransactionId));
if (this.localRelayedTransactionIdObject!=null) {
tcbm.setOriginatingTransactionId(Utils.encodeTransactionId(this.localRelayedTransactionIdObject));
} else {
tcbm.setOriginatingTransactionId(Utils.encodeTransactionId(this.localTransactionId));
}
if (this.scheduledComponentList.size() > 0) {
Component[] componentsToSend = new Component[this.scheduledComponentList.size()];
this.prepareComponents(componentsToSend);
Expand Down Expand Up @@ -2168,6 +2174,15 @@ public PrevewDialogData getPrevewDialogData() {
return this.prevewDialogData;
}

public Long getRelayedLocalDialogId() {
return this.localRelayedTransactionIdObject;
}

public void setRelayedLocalDialogId(Long relayedDialogId) {
this.localRelayedTransactionIdObject = relayedDialogId;
}


/*
* (non-Javadoc)
*
Expand Down

0 comments on commit 2186359

Please sign in to comment.