Skip to content

Commit

Permalink
issue #293 implemented flag, for disabling TCAP TxId byte swaping
Browse files Browse the repository at this point in the history
  • Loading branch information
kostyantynnosach-mobius committed May 24, 2018
1 parent b273a76 commit 66b6686
Show file tree
Hide file tree
Showing 19 changed files with 315 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,48 @@ EXAMPLES
On TCAP management page, click on pencil against the 'Statistics Enabled' property and text box becomes editable.
Change value and save.

[[_tcap_property_swaptcapidbytes]]
=== Swap TCAP id bytes Enabled

[[_tcap_property_swaptcapidbytes_cli]]
==== Using CLI

You can set the 'swaptcapidbytes' by issuing the command `tcap set swaptcapidbytes` with appropriate parameters as described below.
You can verify this by issuing the command `tcap get swaptcapidbytes` which will display the value set for this property.

----
Name
tcap set swaptcapidbytes
SYNOPSIS
tcap set swaptcapidbytes <true | false> stackname <stack-name>
DESCRIPTION
If set to true, swap tcap id bytes is enabled..
PARAMETERS
Standard Parameters
<swaptcapidbytes> - If true, swap tcap id bytes is enabled
Optional Parameters
<stack-name> - Name of the stack on which this command is executed.
If not passed, the first stack configured in ShellExecutor
will be used.
EXAMPLES
tcap set swaptcapidbytes false
----

[[_tcap_property_swaptcapidbytes_gui]]
==== Using GUI

On TCAP management page, click on pencil against the 'Swap tcapid bytes Enabled' property and text box becomes editable.
Change value and save.

[[_tcap_property_executordelaythreshold]]
=== Thresholds for Executors congestion control

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,47 @@ EXAMPLES
</section>
</section>

<section id="tcap_property_swaptcapidbytes">
<title>Swap TCAP id bytes Enabled</title>

<section id="tcap_property_swaptcapidbytes_CLI">
<title>Using CLI</title>
<para>
You can set the 'swaptcapidbytes' by issuing the command <command>tcap set swaptcapidbytes</command> with appropriate parameters as described below.
You can verify this by issuing the command <command>tcap get swaptcapidbytes</command> which will display the value set for this property.
</para>
<screen><![CDATA[
Name
tcap set swaptcapidbytes
SYNOPSIS
tcap set swaptcapidbytes <true | false> stackname <stack-name>
DESCRIPTION
If set to true, swap tcap id bytes is enabled.
PARAMETERS
Standard Parameters
<swaptcapidbytes> - If true, swap tcap id bytes is enabled
Optional Parameters
<stack-name> - Name of the stack on which this command is executed.
If not passed, the first stack configured in ShellExecutor
will be used.
EXAMPLES
tcap set swaptcapidbytes false
]]></screen>
</section>
<section id="tcap_property_swaptcapidbytes_GUI">
<title>Using GUI</title>
<para>On TCAP management page, click on pencil against the 'Swap tcapid bytes Enabled' property and text box becomes editable. Change value and save. </para>
</section>
</section>

</section>

</section>
Original file line number Diff line number Diff line change
Expand Up @@ -369,5 +369,18 @@ public interface TCAPStack {
*/
String getSlsRange();

/**
* Returns true if there is need to swap bytes for Txid
*
* @return
*/
boolean isSwapTcapIdBytes();

/**
* Set is there need to swap bytes for Txid
*
* @return
*/
void setSwapTcapIdBytes(boolean isSwapTcapIdBytes);

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class TcapAnsiCommandHandler extends CommandHandlerWithHelp {
set.addChild("dialogidrangeend");
// set.addChild("previewmode");
set.addChild("statisticsenabled");
set.addChild("swaptcapidbytes");
set.addChild("slsrange");

Node get = parent.addChild("get");
Expand All @@ -52,6 +53,7 @@ public class TcapAnsiCommandHandler extends CommandHandlerWithHelp {
get.addChild("dialogidrangeend");
get.addChild("previewmode");
get.addChild("statisticsenabled");
get.addChild("swaptcapidbytes");
get.addChild("slsrange");

};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public class DialogImpl implements Dialog {
protected PreviewDialogData prevewDialogData;
private long startDialogTime;
private int networkId;
private boolean isSwapTcapIdBytes;

private static int getIndexFromInvokeId(Long l) {
int tmp = l.intValue();
Expand Down Expand Up @@ -196,6 +197,7 @@ protected DialogImpl(SccpAddress localAddress, SccpAddress remoteAddress, Long o

TCAPStack stack = this.provider.getStack();
this.idleTaskTimeout = stack.getDialogIdleTimeout();
this.isSwapTcapIdBytes = stack.isSwapTcapIdBytes();

startDialogTime = System.currentTimeMillis();

Expand Down Expand Up @@ -287,7 +289,7 @@ public Long getLocalDialogId() {
*/
public Long getRemoteDialogId() {
if (this.remoteTransactionId != null && this.remoteTransactionIdObject == null) {
this.remoteTransactionIdObject = Utils.decodeTransactionId(this.remoteTransactionId);
this.remoteTransactionIdObject = Utils.decodeTransactionId(this.remoteTransactionId, this.isSwapTcapIdBytes);
}

return this.remoteTransactionIdObject;
Expand Down Expand Up @@ -515,7 +517,7 @@ public void send(TCQueryRequest event) throws TCAPSendException {

// build DP
tcbm.setDialogTermitationPermission(event.getDialogTermitationPermission());
tcbm.setOriginatingTransactionId(Utils.encodeTransactionId(this.localTransactionId));
tcbm.setOriginatingTransactionId(Utils.encodeTransactionId(this.localTransactionId, this.isSwapTcapIdBytes));

if (event.getApplicationContextName() != null || event.getConfidentiality() != null
|| event.getSecurityContext() != null || event.getUserInformation() != null) {
Expand Down Expand Up @@ -595,7 +597,7 @@ public void send(TCConversationRequest event) throws TCAPSendException {
TCConversationMessageImpl tcbm = (TCConversationMessageImpl) TcapFactory.createTCConversationMessage();

tcbm.setDialogTermitationPermission(event.getDialogTermitationPermission());
tcbm.setOriginatingTransactionId(Utils.encodeTransactionId(this.localTransactionId));
tcbm.setOriginatingTransactionId(Utils.encodeTransactionId(this.localTransactionId, this.isSwapTcapIdBytes));
tcbm.setDestinationTransactionId(this.remoteTransactionId);
// local address may change, lets check it;
if (event.getOriginatingAddress() != null && !event.getOriginatingAddress().equals(this.localAddress)) {
Expand Down Expand Up @@ -646,7 +648,7 @@ public void send(TCConversationRequest event) throws TCAPSendException {
TCConversationMessageImpl tcbm = (TCConversationMessageImpl) TcapFactory.createTCConversationMessage();

tcbm.setDialogTermitationPermission(event.getDialogTermitationPermission());
tcbm.setOriginatingTransactionId(Utils.encodeTransactionId(this.localTransactionId));
tcbm.setOriginatingTransactionId(Utils.encodeTransactionId(this.localTransactionId, this.isSwapTcapIdBytes));
tcbm.setDestinationTransactionId(this.remoteTransactionId);
if (this.scheduledComponentList.size() > 0) {
Component[] componentsToSend = new Component[this.scheduledComponentList.size()];
Expand Down Expand Up @@ -1025,7 +1027,7 @@ public int getDataLength(TCQueryRequest event) throws TCAPSendException {

TCQueryMessageImpl tcbm = (TCQueryMessageImpl) TcapFactory.createTCQueryMessage();
tcbm.setDialogTermitationPermission(event.getDialogTermitationPermission());
tcbm.setOriginatingTransactionId(Utils.encodeTransactionId(this.localTransactionId));
tcbm.setOriginatingTransactionId(Utils.encodeTransactionId(this.localTransactionId, this.isSwapTcapIdBytes));

if (event.getApplicationContextName() != null || event.getConfidentiality() != null
|| event.getSecurityContext() != null || event.getUserInformation() != null) {
Expand Down Expand Up @@ -1064,7 +1066,7 @@ public int getDataLength(TCConversationRequest event) throws TCAPSendException {

TCConversationMessageImpl tcbm = (TCConversationMessageImpl) TcapFactory.createTCConversationMessage();
tcbm.setDialogTermitationPermission(event.getDialogTermitationPermission());
tcbm.setOriginatingTransactionId(Utils.encodeTransactionId(this.localTransactionId));
tcbm.setOriginatingTransactionId(Utils.encodeTransactionId(this.localTransactionId, this.isSwapTcapIdBytes));
tcbm.setDestinationTransactionId(this.remoteTransactionId);

if (event.getApplicationContextName() != null || event.getConfidentiality() != null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ public void onMessage(SccpDataMessage message) {
} else {
Dialog ddi = null;
if (tcUnidentified.getDestinationTransactionId() != null) {
long dialogId = Utils.decodeTransactionId(tcUnidentified.getDestinationTransactionId());
long dialogId = Utils.decodeTransactionId(tcUnidentified.getDestinationTransactionId(), this.stack.isSwapTcapIdBytes());
ddi = this.dialogs.get(dialogId);
}
if (ddi != null && ddi.getProtocolVersion() != null)
Expand Down Expand Up @@ -770,14 +770,14 @@ public void onMessage(SccpDataMessage message) {
return;
}

long dialogId = Utils.decodeTransactionId(tcm.getDestinationTransactionId());
long dialogId = Utils.decodeTransactionId(tcm.getDestinationTransactionId(), this.stack.isSwapTcapIdBytes());
DialogImpl di;
if (this.stack.getPreviewMode()) {
PreviewDialogDataKey ky1 = new PreviewDialogDataKey(message.getIncomingDpc(), (message
.getCalledPartyAddress().getGlobalTitle() != null ? message.getCalledPartyAddress()
.getGlobalTitle().getDigits() : null), message.getCalledPartyAddress().getSubsystemNumber(),
dialogId);
long dId = Utils.decodeTransactionId(tcm.getOriginatingTransactionId());
long dId = Utils.decodeTransactionId(tcm.getOriginatingTransactionId(), this.stack.isSwapTcapIdBytes());
PreviewDialogDataKey ky2 = new PreviewDialogDataKey(message.getIncomingOpc(), (message
.getCallingPartyAddress().getGlobalTitle() != null ? message.getCallingPartyAddress()
.getGlobalTitle().getDigits() : null), message.getCallingPartyAddress().getSubsystemNumber(),
Expand Down Expand Up @@ -854,7 +854,7 @@ public void onMessage(SccpDataMessage message) {
di = null;
try {
if (this.stack.getPreviewMode()) {
long dId = Utils.decodeTransactionId(tcb.getOriginatingTransactionId());
long dId = Utils.decodeTransactionId(tcb.getOriginatingTransactionId(), this.stack.isSwapTcapIdBytes());
PreviewDialogDataKey ky = new PreviewDialogDataKey(message.getIncomingOpc(), (message
.getCallingPartyAddress().getGlobalTitle() != null ? message.getCallingPartyAddress()
.getGlobalTitle().getDigits() : null), message.getCallingPartyAddress()
Expand Down Expand Up @@ -916,7 +916,7 @@ public void onMessage(SccpDataMessage message) {
return;
}

dialogId = Utils.decodeTransactionId(teb.getDestinationTransactionId());
dialogId = Utils.decodeTransactionId(teb.getDestinationTransactionId(), this.stack.isSwapTcapIdBytes());
if (this.stack.getPreviewMode()) {
PreviewDialogDataKey ky = new PreviewDialogDataKey(message.getIncomingDpc(), (message
.getCalledPartyAddress().getGlobalTitle() != null ? message.getCalledPartyAddress()
Expand Down Expand Up @@ -952,9 +952,9 @@ public void onMessage(SccpDataMessage message) {
return;
}

dialogId = Utils.decodeTransactionId(tub.getDestinationTransactionId());
dialogId = Utils.decodeTransactionId(tub.getDestinationTransactionId(), this.stack.isSwapTcapIdBytes());
if (this.stack.getPreviewMode()) {
long dId = Utils.decodeTransactionId(tub.getDestinationTransactionId());
long dId = Utils.decodeTransactionId(tub.getDestinationTransactionId(), this.stack.isSwapTcapIdBytes());
PreviewDialogDataKey ky = new PreviewDialogDataKey(message.getIncomingDpc(), (message
.getCalledPartyAddress().getGlobalTitle() != null ? message.getCalledPartyAddress()
.getGlobalTitle().getDigits() : null), message.getCalledPartyAddress().getSubsystemNumber(),
Expand Down Expand Up @@ -1022,7 +1022,7 @@ private void unrecognizedPackageType(SccpDataMessage message, SccpAddress localA
byte[] otid = tcUnidentified.getOriginatingTransactionId();

if (tcUnidentified.getDestinationTransactionId() != null) {
Long dtid = Utils.decodeTransactionId(tcUnidentified.getDestinationTransactionId());
Long dtid = Utils.decodeTransactionId(tcUnidentified.getDestinationTransactionId(), this.stack.isSwapTcapIdBytes());
this.sendProviderAbort(PAbortCause.UnrecognizedPackageType, otid, remoteAddress, localAddress, message.getSls(), networkId);
} else {
this.sendProviderAbort(PAbortCause.UnrecognizedPackageType, otid, remoteAddress, localAddress, message.getSls(), networkId);
Expand Down Expand Up @@ -1051,7 +1051,7 @@ public void onNotice(SccpNoticeMessage msg) {
tcUnidentified.decode(ais);

if (tcUnidentified.getOriginatingTransactionId() != null) {
long otid = Utils.decodeTransactionId(tcUnidentified.getOriginatingTransactionId());
long otid = Utils.decodeTransactionId(tcUnidentified.getOriginatingTransactionId(), this.stack.isSwapTcapIdBytes());
dialog = this.dialogs.get(otid);
}
} catch (Exception e) {
Expand Down Expand Up @@ -1248,10 +1248,10 @@ public DraftParsedMessage parseMessageDraft(byte[] data) {
return res;
}
byte[] originatingTransactionId = tid.getFirstElem();
res.setOriginationDialogId(Utils.decodeTransactionId(originatingTransactionId));
res.setOriginationDialogId(Utils.decodeTransactionId(originatingTransactionId, this.stack.isSwapTcapIdBytes()));

byte[] destinationTransactionId = tid.getSecondElem();
res.setDestinationDialogId(Utils.decodeTransactionId(destinationTransactionId));
res.setDestinationDialogId(Utils.decodeTransactionId(destinationTransactionId, this.stack.isSwapTcapIdBytes()));

if (tag == TCConversationMessage._TAG_CONVERSATION_WITH_PERM)
res.setMessageType(MessageType.ConversationWithPerm);
Expand All @@ -1270,7 +1270,7 @@ public DraftParsedMessage parseMessageDraft(byte[] data) {
return res;
}
originatingTransactionId = tid.getFirstElem();
res.setOriginationDialogId(Utils.decodeTransactionId(originatingTransactionId));
res.setOriginationDialogId(Utils.decodeTransactionId(originatingTransactionId, this.stack.isSwapTcapIdBytes()));

if (tag == TCQueryMessage._TAG_QUERY_WITH_PERM)
res.setMessageType(MessageType.QueryWithPerm);
Expand All @@ -1288,7 +1288,7 @@ public DraftParsedMessage parseMessageDraft(byte[] data) {
return res;
}
destinationTransactionId = tid.getFirstElem();
res.setDestinationDialogId(Utils.decodeTransactionId(destinationTransactionId));
res.setDestinationDialogId(Utils.decodeTransactionId(destinationTransactionId, this.stack.isSwapTcapIdBytes()));

res.setMessageType(MessageType.Response);
break;
Expand All @@ -1303,7 +1303,7 @@ public DraftParsedMessage parseMessageDraft(byte[] data) {
return res;
}
destinationTransactionId = tid.getFirstElem();
res.setDestinationDialogId(Utils.decodeTransactionId(destinationTransactionId));
res.setDestinationDialogId(Utils.decodeTransactionId(destinationTransactionId, this.stack.isSwapTcapIdBytes()));

res.setMessageType(MessageType.Abort);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class TCAPStackImpl implements TCAPStack {
private static final String PREVIEW_MODE = "previewmode";
private static final String STATISTICS_ENABLED = "statisticsenabled";
private static final String SLS_RANGE = "slsrange";

private static final String SWAP_TCAP_ID_BYTES = "swaptcapidbytes";

private static final String CONG_CONTROL_BLOCKING_INCOMING_TCAP_MESSAGES = "congControl_blockingIncomingTcapMessages";
private static final String CONG_CONTROL_EXECUTOR_DELAY_THRESHOLD_1 = "congControl_ExecutorDelayThreshold_1";
Expand Down Expand Up @@ -135,6 +135,8 @@ public class TCAPStackImpl implements TCAPStack {
// congestion level 0, 1 or 2
private double[] congControl_BackToNormalMemoryThreshold = new double[] { 72, 82, 92 };

private boolean isSwapTcapIdBytes = true; // for now configurable only via XML file

private int ssn = -1;

// SLS value
Expand Down Expand Up @@ -448,6 +450,16 @@ public String getSlsRange() {
return this.slsRange.toString();
}

@Override
public boolean isSwapTcapIdBytes() {
return isSwapTcapIdBytes;
}

@Override
public void setSwapTcapIdBytes(boolean isSwapTcapIdBytes) {
this.isSwapTcapIdBytes = isSwapTcapIdBytes;
}

public SlsRangeType getSlsRangeType() {
return this.slsRange;
}
Expand Down Expand Up @@ -717,6 +729,8 @@ public void store() {

writer.write(this.statisticsEnabled, STATISTICS_ENABLED, Boolean.class);

writer.write(this.isSwapTcapIdBytes, SWAP_TCAP_ID_BYTES, Boolean.class);

writer.close();
} catch (Exception e) {
this.logger.error(
Expand Down Expand Up @@ -793,6 +807,10 @@ protected void load() throws FileNotFoundException {
if (volb != null)
this.statisticsEnabled = volb;

volb = reader.read(SWAP_TCAP_ID_BYTES, Boolean.class);
if (volb != null)
this.isSwapTcapIdBytes = volb;

reader.close();
} catch (XMLStreamException ex) {
// this.logger.info(
Expand Down
Loading

0 comments on commit 66b6686

Please sign in to comment.