aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel <0xc0decafe@users.noreply.github.com>2016-10-17 13:30:41 +0200
committerDaniel <0xc0decafe@users.noreply.github.com>2016-10-17 13:30:41 +0200
commit46192a325a70dde853460db9c10954a2e0db4161 (patch)
treeb9476340a184898f8161fe85a7b397ee5bd78c0b
parentb10dee82bf48d4c45f1200b18770755219eeb0a3 (diff)
added processUnstructuredSS, unencoded IMSI in cfg
-rw-r--r--config.example2
-rw-r--r--src/map_msgs.erl135
-rw-r--r--src/map_tests.erl89
-rw-r--r--src/ss7MAPer.erl20
-rw-r--r--src/ss7_helper.erl11
5 files changed, 214 insertions, 43 deletions
diff --git a/config.example b/config.example
index a688bb3..dfd2432 100644
--- a/config.example
+++ b/config.example
@@ -23,7 +23,7 @@
{gt_gmsc, [1,2,3,4,5,6,7,8,9,4]},
{gt_smsc, [1,2,3,4,5,6,7,8,9,5]},
{msisdn, [0,9,8,7,6,5,4,3,2,1]},
- {imsi, "01020304050607f8"},
+ {imsi, [1,2,3,4,5,6,7,8]"},
{service_center, [9,8,7,6,5,4,3,2,1]},
{forward_number, [9,8,7,6,5,4,3,2,0]}
]}.
diff --git a/src/map_msgs.erl b/src/map_msgs.erl
index 56c320c..3ee6e5d 100644
--- a/src/map_msgs.erl
+++ b/src/map_msgs.erl
@@ -111,8 +111,10 @@ create_mt_forwardSM_v2() ->
create_mt_forwardSM_v2(create_testSMSPDU_mt(), ?IMSI, ?SERVICE_CENTER_ADDRESS_DA).
create_mt_forwardSM_v2(SMSPDU, Imsi, Scada) ->
MapData = { 'ForwardSM-Arg',
- {imsi, Imsi},
- {serviceCentreAddressOA, Scada},
+ {imsi, ss7_helper:encode_imsi(Imsi)},
+ {serviceCentreAddressOA, ss7_helper:encode_msisdn(?NUMBER_EXTENSION_NONE,
+ ?NUMBER_NATURE_INTERNATIONAL, ?NUMBER_PLAN_ISDN,
+ Scada)},
SMSPDU,
asn1_NOVALUE, asn1_NOVALUE},
Dialog = build_dialog_request({0,4,0,0,1,0,25,2}),
@@ -123,7 +125,9 @@ create_mt_forwardSM() ->
create_mt_forwardSM(SMSPDU) ->
MapData = {'MT-ForwardSM-Arg',
{serviceCentreAddressDA, ?SERVICE_CENTER_ADDRESS_DA},
- {msisdn, ?SOURCE_ADDRESS},
+ {msisdn, ss7_helper:encode_msisdn(?NUMBER_EXTENSION_NONE,
+ ?NUMBER_NATURE_INTERNATIONAL, ?NUMBER_PLAN_ISDN,
+ ?SOURCE_ADDRESS)},
SMSPDU,
asn1_NOVALUE, %moreMessagesToSend
asn1_NOVALUE %extensionContainer
@@ -135,8 +139,12 @@ create_mo_forwardSM_v2() ->
create_mo_forwardSM_v2(create_testSMSPDU_mo(), ?SERVICE_CENTER_ADDRESS_DA, ?MSISDN).
create_mo_forwardSM_v2(SMSPDU, Scada, Msisdn) ->
MapData = { 'ForwardSM-Arg',
- {serviceCentreAddressDA, Scada},
- {msisdn, Msisdn},
+ {serviceCentreAddressDA, ss7_helper:encode_msisdn(?NUMBER_EXTENSION_NONE,
+ ?NUMBER_NATURE_INTERNATIONAL, ?NUMBER_PLAN_ISDN,
+ Scada)},
+ {msisdn, ss7_helper:encode_msisdn(?NUMBER_EXTENSION_NONE,
+ ?NUMBER_NATURE_INTERNATIONAL, ?NUMBER_PLAN_ISDN,
+ Msisdn)},
SMSPDU,
asn1_NOVALUE, asn1_NOVALUE},
Dialog = build_dialog_request({0,4,0,0,1,0,21,2}),
@@ -147,7 +155,9 @@ create_mo_forwardSM() ->
create_mo_forwardSM(SMSPDU) ->
MapData = {'MO-ForwardSM-Arg',
{serviceCentreAddressDA, ?SERVICE_CENTER_ADDRESS_DA},
- {msisdn, ?MSISDN},
+ {msisdn, ss7_helper:encode_msisdn(?NUMBER_EXTENSION_NONE,
+ ?NUMBER_NATURE_INTERNATIONAL, ?NUMBER_PLAN_ISDN,
+ ?MSISDN)},
SMSPDU,
asn1_NOVALUE,
asn1_NOVALUE % ?IMSI_FROM
@@ -162,9 +172,13 @@ create_sendRoutingInfoForSM() ->
create_sendRoutingInfoForSM(?MSISDN, ?SERVICE_CENTER_ADDRESS).
create_sendRoutingInfoForSM(Msisdn, Ssaddr) ->
MapData = { 'send-routing-info-for-sm-arg',
- Msisdn,
+ ss7_helper:encode_msisdn(?NUMBER_EXTENSION_NONE,
+ ?NUMBER_NATURE_INTERNATIONAL, ?NUMBER_PLAN_ISDN,
+ Msisdn),
false,
- Ssaddr,
+ ss7_helper:encode_msisdn(?NUMBER_EXTENSION_NONE,
+ ?NUMBER_NATURE_INTERNATIONAL, ?NUMBER_PLAN_ISDN,
+ Ssaddr),
asn1_NOVALUE,
asn1_NOVALUE, %true,
asn1_NOVALUE, %0,
@@ -192,7 +206,9 @@ create_sendRoutingInfo() ->
create_sendRoutingInfo(?MSISDN, ?LOCAL_GLOBAL_TITLE).
create_sendRoutingInfo(Msisdn, OrGsmSCF) ->
MapData = {'SendRoutingInfoArg',
- Msisdn,
+ ss7_helper:encode_msisdn(?NUMBER_EXTENSION_NONE,
+ ?NUMBER_NATURE_INTERNATIONAL, ?NUMBER_PLAN_ISDN,
+ Msisdn),
asn1_NOVALUE,
asn1_NOVALUE,
basicCall,
@@ -273,7 +289,9 @@ create_registerSS(Imsi, Origin, DestinationNumber) ->
MapData = {'RegisterSS-Arg',
?allForwardingSS, %ss-Code
asn1_NOVALUE,
- DestinationNumber, %forwardedToNumber
+ ss7_helper:encode_msisdn(?NUMBER_EXTENSION_NONE,
+ ?NUMBER_NATURE_INTERNATIONAL, ?NUMBER_PLAN_ISDN,
+ DestinationNumber), %forwardedToNumber
asn1_NOVALUE,
asn1_NOVALUE,
asn1_NOVALUE,
@@ -346,7 +364,7 @@ create_updateLocation() ->
create_updateLocation(?IMSI, ?LOCAL_GLOBAL_TITLE, ?LOCAL_GLOBAL_TITLE).
create_updateLocation(Imsi, MscNr, VlrNr) ->
MapData = {'UpdateLocationArg',
- Imsi,
+ ss7_helper:encode_imsi(Imsi),
ss7_helper:encode_msisdn(?NUMBER_EXTENSION_NONE,
?NUMBER_NATURE_INTERNATIONAL, ?NUMBER_PLAN_ISDN,
MscNr), %msc-Number
@@ -383,11 +401,11 @@ create_updateLocation(Imsi, MscNr, VlrNr) ->
{ok, EncMapPDU} = map:encode('MapSpecificPDUs', MapPDU),
EncMapPDU.
-create_anyTimeInerrogation() ->
- create_anyTimeInerrogation(?IMSI, ?LOCAL_GLOBAL_TITLE).
-create_anyTimeInerrogation(Imsi, GsmSCF) ->
+create_anyTimeInterrogation() ->
+ create_anyTimeInterrogation(?IMSI, ?LOCAL_GLOBAL_TITLE).
+create_anyTimeInterrogation(Imsi, GsmSCF) ->
MapData = {'AnyTimeInterrogationArg',
- {imsi, Imsi}, %{msisdn,?MSISDN},
+ {imsi, ss7_helper:encode_imsi(Imsi)}, %{msisdn,?MSISDN},
{'RequestedInfoMAP-MS-DataTypes',asn1_NOVALUE,
'NULL',asn1_NOVALUE,asn1_NOVALUE,
asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,
@@ -405,7 +423,7 @@ create_sendAuthenticationInfo(Imsi) ->
create_sendAuthenticationInfo(Imsi, 5).
create_sendAuthenticationInfo(Imsi, Nr) ->
MapData = { 'SendAuthenticationInfoArg',
- Imsi,
+ ss7_helper:encode_imsi(Imsi),
Nr,
asn1_NOVALUE,
asn1_NOVALUE,
@@ -435,7 +453,9 @@ create_sendAuthenticationInfo(Imsi, Nr) ->
create_sendImsi() ->
create_sendImsi(?MSISDN).
create_sendImsi(Msisdn) ->
- MapData = Msisdn,
+ MapData = ss7_helper:encode_msisdn(?NUMBER_EXTENSION_NONE,
+ ?NUMBER_NATURE_INTERNATIONAL, ?NUMBER_PLAN_ISDN,
+ Msisdn),
Dialog = build_dialog_request(?'imsiRetrievalContext-v2'),
encode_map_pdu(Dialog, 58, MapData).
@@ -443,7 +463,7 @@ create_purgeMs() ->
create_purgeMs(?IMSI, ?LOCAL_GLOBAL_TITLE).
create_purgeMs(Imsi, VlrNr) ->
MapData = {'PurgeMs-Arg',
- Imsi,
+ ss7_helper:encode_imsi(Imsi),
ss7_helper:encode_msisdn(?NUMBER_EXTENSION_NONE,
?NUMBER_NATURE_INTERNATIONAL, ?NUMBER_PLAN_ISDN,
VlrNr), %VLR number
@@ -452,6 +472,36 @@ create_purgeMs(Imsi, VlrNr) ->
Dialog = build_dialog_request(?'msPurgingContext-v3'),
encode_map_pdu(Dialog, 67, MapData).
+% gsm_map and tcap.localValue == 59
+create_processUnstructuredSS() ->
+ create_processUnstructuredSS(?IMSI, ?MSISDN, "*100#").
+create_processUnstructuredSS(Imsi, Msisdn, UssdString) ->
+ MapDialoguePDU = {'map-open',
+ {'MAP-OpenInfo',
+ ss7_helper:encode_msisdn(?NUMBER_EXTENSION_NONE,
+ ?NUMBER_NATURE_INTERNATIONAL, ?NUMBER_LAND_MOBILE,
+ Imsi), %destinationReference
+ ss7_helper:encode_msisdn(?NUMBER_EXTENSION_NONE,
+ ?NUMBER_NATURE_INTERNATIONAL, ?NUMBER_PLAN_ISDN,
+ Msisdn), %originationReference
+ asn1_NOVALUE }},
+ {ok, EncMapDialoguePDU} = map:encode('MAP-DialoguePDU', MapDialoguePDU),
+ DialoguePDU = {'dialogueRequest',
+ {'AARQ-apdu',
+ [version1],
+ ?'networkUnstructuredSsContext-v2',
+ [{'EXTERNAL',
+ ?'map-DialogueAS',
+ asn1_NOVALUE,asn1_NOVALUE,
+ {'single-ASN1-type',
+ EncMapDialoguePDU}}]}},
+ {ok, EncDialoguePDU} = map:encode('DialoguePDU', DialoguePDU),
+ MapData = {'USSD-Arg',
+ <<15>>, %ussd-DataCodingScheme; 0x0f = 15 == Coding Group 0 [gsm 7bit]; Language unspecified
+ 'sms_7bit_encoding':to_7bit(UssdString), %<<170,152,12,54,2>>, %ussd-String
+ asn1_NOVALUE,asn1_NOVALUE},
+ encode_map_pdu(EncDialoguePDU, 59, MapData).
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% to MSC/VLR
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -460,7 +510,7 @@ create_provideSubscriberInfo() ->
create_provideSubscriberInfo(?IMSI).
create_provideSubscriberInfo(Imsi) ->
MapData = {'ProvideSubscriberInfoArg',
- Imsi,
+ ss7_helper:encode_imsi(Imsi),
asn1_NOVALUE,
{'RequestedInfoMAP-MS-DataTypes',
'NULL', %locationInformation
@@ -479,9 +529,46 @@ create_provideSubscriberInfo(Imsi) ->
Dialog = build_dialog_request(?'subscriberInfoEnquiryContext-v3'),
encode_map_pdu(Dialog, 70, MapData).
+create_provideSubscriberLocation() ->
+ create_provideSubscriberLocation(?IMSI).
+create_provideSubscriberLocation(Imsi) ->
+ MapData = {'ProvideSubscriberLocationArg'
+ %~ locationType LocationType,
+ %~ mlc-Number ISDN-AddressString,
+ %~ lcs-ClientID [0] LCS-ClientID OPTIONAL,
+ %~ privacyOverride [1] NULL OPTIONAL,
+ %~ imsi [2] IMSI OPTIONAL,
+ %~ msisdn [3] ISDN-AddressString OPTIONAL,
+ %~ lmsi [4] LMSI OPTIONAL,
+ %~ imei [5] IMEI OPTIONAL,
+ %~ lcs-Priority [6] LCS-Priority OPTIONAL,
+ %~ lcs-QoS [7] LCS-QoS OPTIONAL,
+ %~ extensionContainer [8] ExtensionContainer OPTIONAL,
+ %~ ...,
+ %~ supportedGADShapes [9] SupportedGADShapes OPTIONAL,
+ %~ lcs-ReferenceNumber [10] LCS-ReferenceNumber OPTIONAL,
+ %~ lcsServiceTypeID [11] LCSServiceTypeID OPTIONAL,
+ %~ lcsCodeword [12] LCSCodeword OPTIONAL
+ %~ -- one of imsi or msisdn is mandatory
+ %~ -- If a location estimate type indicates activate deferred location or cancel deferred
+ %~ -- location, a lcs-Reference number shall be included.
+ %~ LocationType ::= SEQUENCE {
+ %~ locationEstimateType [0] LocationEstimateType,
+ %~ ...,
+ %~ deferredLocationEventType [1] DeferredLocationEventType OPTIONAL}
+
+ %~ LocationEstimateType ::= ENUMERATED {
+ %~ currentLocation(0), currentOrLastKnownLocation(1), initialLocation(2), ...,
+ %~ activateDeferredLocation(3), cancelDeferredLocation(4)}
+ },
+ Dialog = build_dialog_request(?'locationInfoRetrievalContext-v3'),
+ encode_map_pdu(Dialog, 83, MapData).
+
create_sendIdentification() ->
+ create_sendIdentification(?TMSI).
+create_sendIdentification(Tmsi) ->
MapData = { 'SendIdentificationArg',
- ?TMSI,
+ Tmsi,
5, %NumberOfRequestedVectors
asn1_NOVALUE, %segmentationProhibited
asn1_NOVALUE, %ExtensionContainer
@@ -496,11 +583,13 @@ create_provideRoamingNumber() ->
create_provideRoamingNumber(?IMSI, ?MSISDN, ?LOCAL_GLOBAL_TITLE, ?LOCAL_GLOBAL_TITLE).
create_provideRoamingNumber(Imsi, Msisdn, MscNr, GmscNr) ->
MapData = {'ProvideRoamingNumberArg',
- Imsi,
+ ss7_helper:encode_imsi(Imsi),
ss7_helper:encode_msisdn(?NUMBER_EXTENSION_NONE,
?NUMBER_NATURE_INTERNATIONAL, ?NUMBER_PLAN_ISDN,
MscNr), %msc-Number
- Msisdn,
+ ss7_helper:encode_msisdn(?NUMBER_EXTENSION_NONE,
+ ?NUMBER_NATURE_INTERNATIONAL, ?NUMBER_PLAN_ISDN,
+ Msisdn),
asn1_NOVALUE,
{'ExternalSignalInfo','gsm-0408',
<<4,1,160>>,
@@ -523,7 +612,7 @@ create_cancelLocation() ->
create_cancelLocation(?IMSI).
create_cancelLocation(Imsi) ->
MapData = {'CancelLocationArg',
- {imsi,Imsi},
+ {imsi, ss7_helper:encode_imsi(Imsi)},
updateProcedure,
asn1_NOVALUE,
asn1_NOVALUE},
diff --git a/src/map_tests.erl b/src/map_tests.erl
index b3fddb9..77a8224 100644
--- a/src/map_tests.erl
+++ b/src/map_tests.erl
@@ -25,6 +25,7 @@ test_hlr(L) ->
test_ul(Gts, L2),
test_ati(Gts, L2),
test_pms(Gts, L2),
+ test_pus(Gts, L2),
ok = sccp_user:unbind_ssn(LocalSsn, undefined),
L2.
@@ -123,8 +124,9 @@ test_si(Gts, L) ->
{'MapSpecificPDUs_end_components_SEQOF_basicROS_returnResult_result',
{local,58},
Imsi }}}}|_] ->
- io:format("\e[91;1mReceived IMSI ~w~n\e[39;49;0m", [ss7_helper:decode_imsi(Imsi)]),
- L#loop_dat{imsi = Imsi}
+ ImsiDec = ss7_helper:decode_imsi(Imsi),
+ io:format("\e[91;1mReceived IMSI ~w~n\e[39;49;0m", [ImsiDec]),
+ L#loop_dat{imsi = ImsiDec}
end;
_->
io:format("\e[91;1mError decoding sendImsi\n\e[39;49;0m"),
@@ -193,7 +195,7 @@ test_rss(Gts, L) ->
%~ registerSS
%~ ========
io:format("~n\e[93;1m# Testing registerSS...\n\e[39;49;0m"),
- tcap:send_tcap(L, Gts, {?SCCP_SSN_MSC, ?SCCP_SSN_HLR}, map_msgs:create_registerSS(ss7_helper:decode_imsi(L#loop_dat.imsi), L#loop_dat.gt_vlr, L#loop_dat.fnumber)),
+ tcap:send_tcap(L, Gts, {?SCCP_SSN_MSC, ?SCCP_SSN_HLR}, map_msgs:create_registerSS(L#loop_dat.imsi, L#loop_dat.gt_vlr, L#loop_dat.fnumber)),
receive
{sccp, {primitive, 'N', 'UNITDATA', indication, Data}} ->
case tcap:decode_tcap(Data) of
@@ -226,7 +228,7 @@ test_ess(Gts, L) ->
%~ eraseSS
%~ ========
io:format("~n\e[93;1m# Testing eraseSS...\n\e[39;49;0m"),
- tcap:send_tcap(L, Gts, {?SCCP_SSN_MSC, ?SCCP_SSN_HLR}, map_msgs:create_eraseSS(ss7_helper:decode_imsi(L#loop_dat.imsi), L#loop_dat.gt_vlr)),
+ tcap:send_tcap(L, Gts, {?SCCP_SSN_MSC, ?SCCP_SSN_HLR}, map_msgs:create_eraseSS(L#loop_dat.imsi, L#loop_dat.gt_vlr)),
receive
{sccp, {primitive, 'N', 'UNITDATA', indication, Data}} ->
case tcap:decode_tcap(Data) of
@@ -288,12 +290,12 @@ test_ati(Gts, L) ->
%~ anyTimeInterrogation
%~ ========
io:format("~n\e[93;1m# Testing anyTimeInterrogation...\n\e[39;49;0m"),
- tcap:send_tcap(L, Gts, {?SCCP_SSN_MSC, ?SCCP_SSN_HLR}, map_msgs:create_anyTimeInerrogation(L#loop_dat.imsi, L#loop_dat.gt_local)),
+ tcap:send_tcap(L, Gts, {?SCCP_SSN_MSC, ?SCCP_SSN_HLR}, map_msgs:create_anyTimeInterrogation(L#loop_dat.imsi, L#loop_dat.gt_local)),
receive
{sccp, {primitive, 'N', 'UNITDATA', indication, Data}} ->
case tcap:decode_tcap(Data) of
{ok, Results} ->
- io:format("\e[97;1mGot answer for anyTimeInerrogation\n~w\n\e[39;49;0m", [Results]),
+ io:format("\e[97;1mGot answer for anyTimeInterrogation\n~w\n\e[39;49;0m", [Results]),
case Results of
[{basicROS, {returnError, {_, {present, Present}, {local, Local}, _}}}] ->
case {Present, Local} of
@@ -306,12 +308,12 @@ test_ati(Gts, L) ->
io:format("\e[93;1mNo Error.~n\e[39;49;0m")
end;
_->
- io:format("\e[91;1mError decoding anyTimeInerrogation\n\e[39;49;0m")
+ io:format("\e[91;1mError decoding anyTimeInterrogation\n\e[39;49;0m")
end;
_->
- io:format("\e[91;1mError no data received for anyTimeInerrogation\n\e[39;49;0m")
+ io:format("\e[91;1mError no data received for anyTimeInterrogation\n\e[39;49;0m")
after 2000 ->
- io:format("\e[91;1mError timeout on receiving anyTimeInerrogation\n\e[39;49;0m")
+ io:format("\e[91;1mError timeout on receiving anyTimeInterrogation\n\e[39;49;0m")
end,
L.
@@ -348,6 +350,41 @@ test_pms(Gts, L) ->
end,
L.
+test_pus(Gts, L) ->
+ %~ ========
+ %~ processUnstructuredSS
+ %~ ========
+ io:format("~n\e[93;1m# Testing processUnstructuredSS...\n\e[39;49;0m"),
+ tcap:send_tcap(L, Gts, {?SCCP_SSN_MSC, ?SCCP_SSN_HLR}, map_msgs:create_processUnstructuredSS(L#loop_dat.imsi, L#loop_dat.msisdn, "*100#")),
+ receive
+ {sccp, {primitive, 'N', 'UNITDATA', indication, Data}} ->
+ case tcap:decode_tcap(Data) of
+ {ok, Results} ->
+ io:format("\e[97;1mGot answer for processUnstructuredSS\n~w\n\e[39;49;0m", [Results]),
+ case Results of
+ [{basicROS, {returnError, {_, {present, Present}, {local, Local}, _}}}] ->
+ io:format("\e[91;1mReceived Error: Present ~w, Local ~w~n\e[39;49;0m", [Present, Local]);
+ [{basicROS,
+ {returnResult,
+ {'MapSpecificPDUs_end_components_SEQOF_basicROS_returnResult',
+ {present,0},
+ {'MapSpecificPDUs_end_components_SEQOF_basicROS_returnResult_result',
+ {local,59},
+ {'USSD-Res', _, ResString}}}}}|_] ->
+ io:format("\e[91;1mReceived processUnstructuredSS-Res '~p', processUnstructuredSS is working~n\e[39;49;0m", ['sms_7bit_encoding':from_7bit(ResString)]);
+ _ ->
+ io:format("\e[93;1mNo Error.~n\e[39;49;0m")
+ end;
+ _->
+ io:format("\e[91;1mError decoding processUnstructuredSS\n\e[39;49;0m")
+ end;
+ _->
+ io:format("\e[91;1mError no data received for processUnstructuredSS\n\e[39;49;0m")
+ after 2000 ->
+ io:format("\e[91;1mError timeout on receiving processUnstructuredSS\n\e[39;49;0m")
+ end,
+ L.
+
%~ =========
%~ MSC TESTS
%~ =========
@@ -360,6 +397,7 @@ test_msc(L) ->
test_cl(Gts, L),
ok = sccp_user:unbind_ssn(?SCCP_SSN_HLR, undefined),
ok = sccp_user:bind_ssn(?SCCP_SSN_MSC),
+ test_sid(Gts, L),
test_mt_fsm(Gts, L),
ok = sccp_user:unbind_ssn(?SCCP_SSN_MSC, undefined),
L.
@@ -463,6 +501,39 @@ test_cl(Gts, L) ->
end,
L.
+test_sid(Gts, L) ->
+ %~ ========
+ %~ sendIdentification
+ %~ ========
+ io:format("~n\e[93;1m# Testing sendIdentification...\n\e[39;49;0m"),
+ tcap:send_tcap(L, Gts, {?SCCP_SSN_HLR, ?SCCP_SSN_SGSN}, map_msgs:create_sendIdentification()), %L#loop_dat.tmsi
+ receive
+ {sccp, {primitive, 'N', 'UNITDATA', indication, Data}} ->
+ case tcap:decode_tcap(Data) of
+ {ok, Results} ->
+ io:format("\e[97;1mGot answer for sendIdentification~n~w~n\e[39;49;0m", [Results]),
+ case Results of
+ [{basicROS, {returnError, {_, {present, Present}, {local, Local}, _}}}] ->
+ io:format("\e[91;1mReceived Error: Present ~w, Local ~w~n\e[39;49;0m", [Present, Local]);
+ %~ [{basicROS,
+ %~ {returnResult,
+ %~ {'MapSpecificPDUs_end_components_SEQOF_basicROS_returnResult',
+ %~ {present,1},{'MapSpecificPDUs_end_components_SEQOF_basicROS_returnResult_result',
+ %~ {local,70},_}}}}|_] ->
+ %~ io:format("\e[91;1mReceived cancelLocationRes~n\e[39;49;0m");
+ _ ->
+ io:format("\e[93;1mNo Error.~n\e[39;49;0m")
+ end;
+ _->
+ io:format("\e[91;1mError decoding sendIdentification\n\e[39;49;0m")
+ end;
+ _->
+ io:format("\e[91;1mError no data received for sendIdentification\n\e[39;49;0m")
+ after 2000 ->
+ io:format("\e[91;1mError timeout on receiving sendIdentification\n\e[39;49;0m")
+ end,
+ L.
+
test_mt_fsm(Gts, L) ->
%~ ========
%~ mt_forwardSM
diff --git a/src/ss7MAPer.erl b/src/ss7MAPer.erl
index 39268b7..585bc71 100644
--- a/src/ss7MAPer.erl
+++ b/src/ss7MAPer.erl
@@ -47,17 +47,17 @@ connect(Configfile) ->
{gt_smsc, GT_Smsc} = lists:keyfind(gt_smsc, 1, Target),
{msisdn, Msisdn} = lists:keyfind(msisdn, 1, Target),
{imsi, Imsi} = lists:keyfind(imsi, 1, Target),
- Msisdn_enc = ss7_helper:encode_msisdn(?NUMBER_EXTENSION_NONE,
- ?NUMBER_NATURE_INTERNATIONAL, ?NUMBER_PLAN_ISDN,
- Msisdn),
+ %~ Msisdn_enc = ss7_helper:encode_msisdn(?NUMBER_EXTENSION_NONE,
+ %~ ?NUMBER_NATURE_INTERNATIONAL, ?NUMBER_PLAN_ISDN,
+ %~ Msisdn),
{service_center, SCenter} = lists:keyfind(service_center, 1, Target),
- SCenter_enc = ss7_helper:encode_msisdn(?NUMBER_EXTENSION_NONE,
- ?NUMBER_NATURE_INTERNATIONAL, ?NUMBER_PLAN_ISDN,
- SCenter),
+ %~ SCenter_enc = ss7_helper:encode_msisdn(?NUMBER_EXTENSION_NONE,
+ %~ ?NUMBER_NATURE_INTERNATIONAL, ?NUMBER_PLAN_ISDN,
+ %~ SCenter),
{forward_number, FNumber} = lists:keyfind(forward_number, 1, Target),
- FNumber_enc = ss7_helper:encode_msisdn(?NUMBER_EXTENSION_NONE,
- ?NUMBER_NATURE_INTERNATIONAL, ?NUMBER_PLAN_ISDN,
- FNumber),
+ %~ FNumber_enc = ss7_helper:encode_msisdn(?NUMBER_EXTENSION_NONE,
+ %~ ?NUMBER_NATURE_INTERNATIONAL, ?NUMBER_PLAN_ISDN,
+ %~ FNumber),
%~ error_logger:tty(false),
% start link server and create linkset
{ok, SS7linksPid} = ss7_links:start_link(),
@@ -96,7 +96,7 @@ connect(Configfile) ->
wait_for_link(Link),
#loop_dat{m3ua_pid = M3uaPid, scrc_pid = ScrcPid, ss7links_pid = SS7linksPid, ss7routes_pid = SS7routesPid, link = Link,
local_pc = Local_PC, remote_pc = Remote_PC, gt_local = GT_Local, gt_hlr = GT_Hlr, gt_vlr = GT_Vlr, gt_msc = GT_Msc,
- gt_sgsn = GT_Sgsn, gt_gmsc = GT_Gmsc, gt_smsc = GT_Smsc, msisdn = Msisdn_enc, imsi = hex:hexstr_to_bin(Imsi), scenter = SCenter_enc, fnumber = FNumber_enc}.
+ gt_sgsn = GT_Sgsn, gt_gmsc = GT_Gmsc, gt_smsc = GT_Smsc, msisdn = Msisdn, imsi = Imsi, scenter = SCenter, fnumber = FNumber}.
wait_for_link(Link) ->
case ss7_link_m3ua:get_link_state(Link) of
diff --git a/src/ss7_helper.erl b/src/ss7_helper.erl
index 194cbad..1c02b89 100644
--- a/src/ss7_helper.erl
+++ b/src/ss7_helper.erl
@@ -1,10 +1,13 @@
-module(ss7_helper).
-author('Daniel Mende <mail@c0decafe.de>').
+-include("ss7MAPer.hrl").
+
-export([encode_phonenumber/4,
decode_phonenumber/1,
encode_msisdn/4,
decode_imsi/1,
+ encode_imsi/1,
remove_firstN/2,
tup2bin/1]).
@@ -18,6 +21,14 @@ decode_imsi(Imsi) ->
true -> lists:append([Second,First], Dec)
end.
+encode_imsi([]) ->
+ <<>>;
+encode_imsi([Last]) ->
+ <<15:4, Last:4>>;
+encode_imsi([First,Second|Tail]) ->
+ EncImsi = encode_imsi(Tail),
+ <<Second:4, First:4, EncImsi/binary>>.
+
%% ===================================================================
%% Phone Number helper
%% ===================================================================