Changes of Revision 4

osmo-diameter2gsup_0.1.3.dsc -> osmo-diameter2gsup_0.2.0.dsc Changed
x
 
1
@@ -2,15 +2,15 @@
2
 Source: osmo-diameter2gsup
3
 Binary: osmo-diameter2gsup
4
 Architecture: any
5
-Version: 0.1.3
6
-Maintainer: Osmocom Community <openbsc@lists.osmocom.org>
7
+Version: 0.2.0
8
+Maintainer: Osmocom team <openbsc@lists.osmocom.org>
9
 Standards-Version: 4.5.0
10
-Build-Depends: erlang-nox, libpcap-dev, rebar3, debhelper
11
+Build-Depends: erlang-nox, libpcap-dev, rebar3, debhelper (>= 10)
12
 Package-List:
13
  osmo-diameter2gsup deb net optional arch=any
14
 Checksums-Sha1:
15
- 3b447bd92d2f43893b6973b14f8fc3e42f2125be 8161884 osmo-diameter2gsup_0.1.3.tar.xz
16
+ 68ca9f96471e45d89fe85940e26381834d8fae50 8277012 osmo-diameter2gsup_0.2.0.tar.xz
17
 Checksums-Sha256:
18
- baebec3f21199ee55bcce07102ce52282337f72644ceff6670d44be69631f6ab 8161884 osmo-diameter2gsup_0.1.3.tar.xz
19
+ 9bd58e7cd1bd2ef76ed79fb892f411452a18560d27eeb059a93b67413c3817d7 8277012 osmo-diameter2gsup_0.2.0.tar.xz
20
 Files:
21
- aaf0c7087a60c4c3db6ef8ea637cc0b7 8161884 osmo-diameter2gsup_0.1.3.tar.xz
22
+ 24539d18ac0f21deb41e3013b75a7d04 8277012 osmo-diameter2gsup_0.2.0.tar.xz
23
osmo-diameter2gsup_0.1.3.tar.xz/.tarball-version -> osmo-diameter2gsup_0.2.0.tar.xz/.tarball-version Changed
4
 
1
@@ -1 +1 @@
2
-0.1.3
3
+0.2.0
4
osmo-diameter2gsup_0.1.3.tar.xz/README.md -> osmo-diameter2gsup_0.2.0.tar.xz/README.md Changed
59
 
1
@@ -1,27 +1,51 @@
2
-= Osmocom DIAMETER -> GSUP translator =
3
+# Osmocom DIAMETER -> GSUP translator
4
 
5
 This project implements a proxy translating Diameter into GSUP, hence allowing
6
 Diameter clients connecting to GSUP server. This allows, for instance, using
7
 OsmoHLR as an HSS used by 4G/5G nodes.
8
 
9
-== Building ==
10
+## Building
11
 
12
 Install erlang and rebar3 packages (not "rebar", that's version 2! You may need
13
 to compile it from source in some distros).
14
 
15
+```
16
 $ rebar3 compile
17
 $ rebar3 escriptize
18
+```
19
 
20
-== Testing ==
21
+## Testing
22
 
23
 Unit tests can be run this way:
24
+```
25
 $ rebar3 eunit
26
+```
27
 
28
-== Running ==
29
+## Running
30
 
31
-Once osmo_dia2gsup is built, you can start it this way:
32
+Once osmo\_dia2gsup is built, you can start it this way:
33
 
34
+```
35
 $ rebar3 shell
36
+1> osmo_dia2gsup:start().
37
+```
38
+
39
+Passing a config file:
40
 
41
-In the erlang shell:
42
+```
43
+$ rebar3 shell --config ./examples/sys.config
44
 1> osmo_dia2gsup:start().
45
+```
46
+
47
+Running it with one shell command:
48
+
49
+```
50
+$ rebar3 shell --config ./examples/sys.config --eval "osmo_dia2gsup:start()."
51
+```
52
+
53
+Running it as an escript:
54
+
55
+```
56
+$ rebar3 escriptize
57
+$ ERL_FLAGS='-config ./examples/sys.config' _build/default/bin/osmo-dia2gsup
58
+```
59
osmo-diameter2gsup_0.1.3.tar.xz/build_dep.tar.gz -> osmo-diameter2gsup_0.2.0.tar.xz/build_dep.tar.gz Changed
osmo-diameter2gsup_0.1.3.tar.xz/contrib/generate_build_dep.sh -> osmo-diameter2gsup_0.2.0.tar.xz/contrib/generate_build_dep.sh Changed
8
 
1
@@ -14,4 +14,6 @@
2
 mkdir _checkouts
3
 mv ./_build/default/lib/* _checkouts/
4
 mv ./_build/default/plugins/* _checkouts/
5
+# delete erlang bytecode
6
+find _checkouts/ -iname '*beam' -delete
7
 tar czf build_dep.tar.gz ./_checkouts
8
osmo-diameter2gsup_0.1.3.tar.xz/debian/changelog -> osmo-diameter2gsup_0.2.0.tar.xz/debian/changelog Changed
42
 
1
@@ -1,8 +1,38 @@
2
-osmo-diameter2gsup (0.1.3) unstable; urgency=medium
3
+osmo-diameter2gsup (0.2.0) unstable; urgency=medium
4
 
5
+   Alexander Couzens 
6
+  * contrib/generate_build_dep.sh: remove erlang bytecode from checkouts
7
+  * docs: add a simple example to use configuration file
8
+
9
+   Oliver Smith 
10
+  * debian: set compat level to 10
11
   * systemd: depend on networking-online.target
12
 
13
- -- Oliver Smith <osmith@sysmocom.de>  Fri, 26 May 2023 14:51:44 +0200
14
+   Alexander Couzens 
15
+  * Use GSUP APN as Service-Selection field
16
+
17
+   Pau Espin Pedrol 
18
+  * rebar3.lock: Update epcap dep to v1.1.1 to fix compilation error
19
+  * README.md: Document how to run escript with config file
20
+
21
+   Oliver Smith 
22
+  * README.md: update
23
+
24
+   Pau Espin Pedrol 
25
+  * cosmetic: Fix typo in comment
26
+  * gsup: Log connect failures
27
+  * gsup: Attempt reconnecting if connect fails
28
+  * Add GMM error cause present in osmo-hlr's gsm48_gmm_cause_vty_names
29
+  * Translate GSUP Auth Info Answer error Cause in Diamater AIA
30
+
31
+   Alexander Couzens 
32
+  * server_cb: use a define for the VENDOR_3GPP code
33
+  * gsup: convert all unknown causes into diameter UNABLE_TO_COMPLY
34
+
35
+   Oliver Smith 
36
+  * debian/rules: extract build_dep.tar.gz first
37
+
38
+ -- Oliver Smith <osmith@sysmocom.de>  Tue, 31 Oct 2023 12:59:24 +0100
39
 
40
 osmo-diameter2gsup (0.1.2) unstable; urgency=medium
41
 
42
osmo-diameter2gsup_0.1.3.tar.xz/debian/control -> osmo-diameter2gsup_0.2.0.tar.xz/debian/control Changed
15
 
1
@@ -1,11 +1,11 @@
2
 Source: osmo-diameter2gsup
3
-Maintainer: Osmocom Community <openbsc@lists.osmocom.org>
4
+Maintainer: Osmocom team <openbsc@lists.osmocom.org>
5
 Section: net
6
 Priority: optional
7
 Build-Depends: erlang-nox,
8
    libpcap-dev,
9
    rebar3,
10
-   debhelper
11
+   debhelper (>= 10)
12
 Standards-Version: 4.5.0
13
 
14
 Package: osmo-diameter2gsup
15
osmo-diameter2gsup_0.1.3.tar.xz/debian/rules -> osmo-diameter2gsup_0.2.0.tar.xz/debian/rules Changed
11
 
1
@@ -8,8 +8,8 @@
2
    dh $@
3
 
4
 override_dh_auto_build:
5
-   dh_auto_build
6
    if  -e build_dep.tar.gz  ; then tar xzf ./build_dep.tar.gz ; fi
7
+   dh_auto_build
8
    rebar3 compile
9
    rebar3 escriptize
10
    rebar3 eunit
11
osmo-diameter2gsup_0.2.0.tar.xz/examples Added
2
 
1
+(directory)
2
osmo-diameter2gsup_0.2.0.tar.xz/examples/sys.config Added
14
 
1
@@ -0,0 +1,12 @@
2
+{osmo_dia2gsup, 
3
+        {hlr_ip, "127.0.0.1"},
4
+        {hlr_port, 4222},
5
+
6
+        {diameter_ip, "127.0.0.4"},
7
+        {diameter_port, 3868},
8
+        {diameter_proto, sctp},
9
+
10
+        {origin_host, "hss.localdomain"},
11
+        {origin_realm, "localdomain"},
12
+        {vendor_id, 0}
13
+}.
14
osmo-diameter2gsup_0.1.3.tar.xz/rebar.lock -> osmo-diameter2gsup_0.2.0.tar.xz/rebar.lock Changed
10
 
1
@@ -1,7 +1,7 @@
2
 {"1.2.0",
3
 {<<"epcap">>,
4
   {git,"https://github.com/msantos/epcap",
5
-       {ref,"8328f8cae4efdeb94642f3b406225a2fa03a5cca"}},
6
+       {ref,"106e763520510afa7b7d8bdfeb0e402a46ea3496"}},
7
   1},
8
  {<<"goldrush">>,{pkg,<<"goldrush">>,<<"0.1.9">>},1},
9
  {<<"lager">>,
10
osmo-diameter2gsup_0.2.0.tar.xz/src/decode_apn.erl Added
53
 
1
@@ -0,0 +1,51 @@
2
+
3
+-module(decode_apn).
4
+
5
+% decode APN Name Encoded Format
6
+% TS 23.003 APN
7
+-export(decode_apn/1, encode_apn/1).
8
+
9
+decode_apn(ApnEnc) ->
10
+   decode_apn("", ApnEnc, 0).
11
+
12
+decode_apn(Result, , 0) ->
13
+   Result;
14
+
15
+decode_apn(Result, << >>, 0) ->
16
+   Result;
17
+
18
+decode_apn("", ApnEnc, 0) ->
19
+   << NewElemLen:8, RemainEnc/bytes >> = ApnEnc,
20
+   case NewElemLen of
21
+       0 -> "";
22
+       _ -> decode_apn("", RemainEnc, NewElemLen)
23
+   end;
24
+
25
+decode_apn(Result, ApnEnc, 0) ->
26
+   << NewElemLen:8, RemainEnc/bytes >> = ApnEnc,
27
+   case NewElemLen of
28
+       0 -> Result;
29
+       _ -> decode_apn(Result ++ ".", RemainEnc, NewElemLen)
30
+   end;
31
+
32
+decode_apn(Result, ApnEnc, RemainLen) when RemainLen > 0 ->
33
+   << Char:8, RemainEnc/bytes >> = ApnEnc,
34
+   decode_apn(Result ++ Char, RemainEnc, RemainLen - 1).
35
+
36
+encode_apn(ApnStr) ->
37
+   encode_apn(<<>>, ApnStr, "", 0).
38
+
39
+encode_apn(ApnEnc, "", "", 0) ->
40
+   ApnEnc;
41
+
42
+encode_apn(ApnEnc, "", CurStr, Len) ->
43
+   CurBin = binary:list_to_bin(CurStr),
44
+   Result = << ApnEnc/binary, Len, CurBin/binary >>,
45
+   Result;
46
+
47
+encode_apn(ApnEnc,  Char | RemainStr , CurStr, Len) ->
48
+   case Char of
49
+       46 -> CurBin = binary:list_to_bin(CurStr),
50
+              encode_apn(<<ApnEnc/binary, Len,  CurBin/binary >>, RemainStr, "", 0);
51
+       _ -> encode_apn(ApnEnc, RemainStr, CurStr ++ Char, Len + 1)
52
+   end.
53
osmo-diameter2gsup_0.1.3.tar.xz/src/gsup_client.erl -> osmo-diameter2gsup_0.2.0.tar.xz/src/gsup_client.erl Changed
52
 
1
@@ -63,19 +63,22 @@
2
 
3
 init(Address, Port, Options) ->
4
    ipa_proto:init(),
5
-   % register the GSUP codec with the IPA core; ignore result as we mgiht be doing this multiple times
6
+   % register the GSUP codec with the IPA core; ignore result as we might be doing this multiple times
7
    ipa_proto:register_codec(?IPAC_PROTO_EXT_GSUP, fun gsup_protocol:encode/1, fun gsup_protocol:decode/1),
8
+   connect(Address, Port, Options).
9
+
10
+connect(Address, Port, Options) ->
11
    lager:info("Connecting to GSUP HLR on IP ~s port ~p~n", Address, Port),
12
-        CcmOptions = #ipa_ccm_options{
13
-                serial_number="HSS-00-00-00-00-00-00",
14
-                unit_id="0/0/0",
15
-                mac_address="00:00:00:00:00:00",
16
-                location="00:00:00:00:00:00",
17
-                unit_type="00:00:00:00:00:00",
18
-                equipment_version="00:00:00:00:00:00",
19
-                sw_version="00:00:00:00:00:00",
20
-                unit_name="HSS-00-00-00-00-00-00"
21
-                },
22
+   CcmOptions = #ipa_ccm_options{
23
+       serial_number="HSS-00-00-00-00-00-00",
24
+       unit_id="0/0/0",
25
+       mac_address="00:00:00:00:00:00",
26
+       location="00:00:00:00:00:00",
27
+       unit_type="00:00:00:00:00:00",
28
+       equipment_version="00:00:00:00:00:00",
29
+       sw_version="00:00:00:00:00:00",
30
+       unit_name="HSS-00-00-00-00-00-00"
31
+       },
32
    case ipa_proto:connect(Address, Port, Options) of
33
        {ok, {Socket, IpaPid}} ->
34
            ipa_proto:set_ccm_options(Socket, CcmOptions),
35
@@ -83,12 +86,13 @@
36
            true = ipa_proto:register_stream(Socket, ?IPAC_PROTO_EXT_GSUP, {process_id, self()}),
37
            ipa_proto:unblock(Socket),
38
            {ok, #gsupc_state{socket=Socket, ipa_pid=IpaPid}};
39
-       {error, econnrefused} ->
40
+       {error, Reason} ->
41
+           lager:error("Connecting to GSUP HLR on IP ~s port ~p failed: ~p~n", Address, Port, Reason),
42
+           lager:info("Reconnecting to GSUP HLR in 5s...~n", ),
43
            timer:sleep(5000),
44
-           {stop, connrefused}
45
+           connect(Address, Port, Options)
46
    end.
47
 
48
-
49
 % send a given GSUP message and synchronously wait for message type ExpRes or ExpErr
50
 handle_call({transceive_gsup, GsupMsgTx, ExpRes, ExpErr}, _From, State) ->
51
    Socket = State#gsupc_state.socket,
52
osmo-diameter2gsup_0.1.3.tar.xz/src/server_cb.erl -> osmo-diameter2gsup_0.2.0.tar.xz/src/server_cb.erl Changed
99
 
1
@@ -6,6 +6,7 @@
2
 -include_lib("diameter_3gpp_ts29_272.hrl").
3
 -include_lib("osmo_gsup/include/gsup_protocol.hrl").
4
 
5
+-define(DIA_VENDOR_3GPP, 10415).
6
 
7
 %% diameter callbacks
8
 -export(peer_up/3, peer_down/3, pick_peer/4, prepare_request/3, prepare_retransmit/3,
9
@@ -123,7 +124,7 @@
10
 gsup_pdp2dia(GsupPdpInfo) ->
11
    #'PDP-Context'{'PDP-Type' = maps:get(pdp_type, GsupPdpInfo, ?PDP_TYPE_DEFAULT),
12
               'Context-Identifier' = maps:get(pdp_context_id, GsupPdpInfo),
13
-              'Service-Selection' = maps:get(access_point_name, GsupPdpInfo),
14
+              'Service-Selection' = decode_apn:decode_apn(maps:get(access_point_name, GsupPdpInfo)),
15
               'QoS-Subscribed' = maps:get(quality_of_service, GsupPdpInfo, ?PDP_QOS_DEFAULT)
16
              }.
17
 
18
@@ -149,7 +150,7 @@
19
                          'Max-Requested-Bandwidth-DL' = 100000000},
20
                 % The default APN Configuration shall not contain the Wildcard APN (see 3GPP TS
21
                 % 23.003 3, clause 9.2); the default APN shall always contain an explicit APN
22
-                'Service-Selection' = "internet"%maps:get(access_point_name, GsupPdpInfo)
23
+                'Service-Selection' = decode_apn:decode_apn(maps:get(access_point_name, GsupPdpInfo))
24
                }.
25
 
26
 % transient (only in Experimental-Result-Code)
27
@@ -157,7 +158,10 @@
28
 -define(DIAMETER_ERROR_CAMEL_SUBSCRIPTION_PRESENT, 4182).
29
 % permanent (only in Experimental-Result-Code)
30
 -define(DIAMETER_ERROR_USER_UNKNOWN,           5001).
31
+-define(DIAMETER_AUTHORIZATION_REJECTED,       5003).
32
 -define(DIAMETER_ERROR_ROAMING_NOT_ALLOWED,        5004).
33
+-define(DIAMETER_MISSING_AVP,              5005).
34
+-define(DIAMETER_UNABLE_TO_COMPLY,         5012).
35
 -define(DIAMETER_ERROR_UNKNOWN_EPS_SUBSCRIPTION,   5420).
36
 -define(DIAMETER_ERROR_RAT_NOT_ALLOWED,            5421).
37
 -define(DIAMETER_ERROR_EQUIPMENT_UNKNOWN,      5422).
38
@@ -165,23 +169,36 @@
39
 
40
 % 10.5.5.14
41
 -define(GMM_CAUSE_IMSI_UNKNOWN,        16#02).
42
--define(GMM_CAUSE_PLMN_NOTALLOWED, 16#0b).
43
+-define(GMM_CAUSE_ILLEGAL_MS,      16#03).
44
 -define(GMM_CAUSE_GPRS_NOTALLOWED, 16#07).
45
--define(GMM_CAUSE_INV_MAND_INFO,   16#60).
46
+-define(GMM_CAUSE_PLMN_NOTALLOWED, 16#0b).
47
+-define(GMM_CAUSE_LA_NOTALLOWED,   16#0c).
48
+-define(GMM_CAUSE_ROAMING_NOTALLOWED,  16#0d).
49
+-define(GMM_CAUSE_NO_SUIT_CELL_IN_LA,  16#0f).
50
 -define(GMM_CAUSE_NET_FAIL,        16#11).
51
-% TODO: more values
52
+-define(GMM_CAUSE_CONGESTION,      16#16).
53
+-define(GMM_CAUSE_GSM_AUTH_UNACCEPT,   16#17).
54
+-define(GMM_CAUSE_INV_MAND_INFO,   16#60).
55
+-define(GMM_CAUSE_PROTO_ERR_UNSPEC,    16#6f).
56
 
57
--define(EXP_RES(Foo),  #'Experimental-Result'{'Vendor-Id'=fixme, 'Experimental-Result-Code'=Foo}).
58
+-define(EXP_RES(Exp),  #'Experimental-Result'{'Vendor-Id'=?DIA_VENDOR_3GPP, 'Experimental-Result-Code'=Exp}).
59
 
60
+%% see 29.272 Annex A/B
61
 -type empty_or_intl() ::  | integer().
62
 -spec gsup_cause2dia(integer()) -> {empty_or_intl(), empty_or_intl()}.
63
 gsup_cause2dia(?GMM_CAUSE_IMSI_UNKNOWN) -> {, ?EXP_RES(?DIAMETER_ERROR_USER_UNKNOWN)};
64
-gsup_cause2dia(?GMM_CAUSE_PLMN_NOTALLOWED) -> {, ?DIAMETER_ERROR_ROAMING_NOT_ALLOWED};
65
-gsup_cause2dia(?GMM_CAUSE_GPRS_NOTALLOWED) -> {, ?DIAMETER_ERROR_RAT_NOT_ALLOWED};
66
-%gsup_cause2dia(?GMM_CAUSE_INV_MAND_INFO) ->
67
-%gsup_cause2dia(?GMM_CAUSE_NET_FAIL) -> 
68
-% TODO: more values
69
-gsup_cause2dia(_) -> {fixme, }.
70
+gsup_cause2dia(?GMM_CAUSE_ILLEGAL_MS) -> {, ?EXP_RES(?DIAMETER_ERROR_USER_UNKNOWN)};
71
+gsup_cause2dia(?GMM_CAUSE_PLMN_NOTALLOWED) -> {, ?EXP_RES(?DIAMETER_ERROR_ROAMING_NOT_ALLOWED)};
72
+gsup_cause2dia(?GMM_CAUSE_GPRS_NOTALLOWED) -> {, ?EXP_RES(?DIAMETER_ERROR_UNKNOWN_EPS_SUBSCRIPTION)};
73
+
74
+gsup_cause2dia(?GMM_CAUSE_LA_NOTALLOWED) -> {?DIAMETER_AUTHORIZATION_REJECTED, };
75
+gsup_cause2dia(?GMM_CAUSE_ROAMING_NOTALLOWED) -> {, ?EXP_RES(?DIAMETER_ERROR_ROAMING_NOT_ALLOWED)};
76
+gsup_cause2dia(?GMM_CAUSE_NO_SUIT_CELL_IN_LA) -> {, ?EXP_RES(?DIAMETER_ERROR_UNKNOWN_EPS_SUBSCRIPTION)};
77
+gsup_cause2dia(?GMM_CAUSE_NET_FAIL) -> {?DIAMETER_UNABLE_TO_COMPLY, };
78
+gsup_cause2dia(?GMM_CAUSE_CONGESTION) -> {?DIAMETER_UNABLE_TO_COMPLY, };
79
+gsup_cause2dia(?GMM_CAUSE_INV_MAND_INFO) -> {?DIAMETER_MISSING_AVP, };
80
+gsup_cause2dia(?GMM_CAUSE_PROTO_ERR_UNSPEC) -> {?DIAMETER_UNABLE_TO_COMPLY, };
81
+gsup_cause2dia(_) -> {?DIAMETER_UNABLE_TO_COMPLY, }.
82
 
83
 % get the value for a tiven key in Map1. If not found, try same key in Map2. If not found, return Default
84
 -spec twomap_get(atom(), map(), map(), any()) -> any().
85
@@ -223,9 +240,11 @@
86
            Resp = #'AIA'{'Session-Id'=SessionId, 'Origin-Host'=OH, 'Origin-Realm'=OR,
87
                      'Result-Code'=2001, 'Auth-Session-State'=1,
88
                      'Authentication-Info'=AuthInfo};
89
-       #{message_type := send_auth_info_err} ->
90
+       #{message_type := send_auth_info_err, cause:=Cause} ->
91
+           {Res, ExpRes} = gsup_cause2dia(Cause),
92
            Resp = #'AIA'{'Session-Id'=SessionId, 'Origin-Host'=OH, 'Origin-Realm'=OR,
93
-                     'Result-Code'=?DIAMETER_ERROR_USER_UNKNOWN,
94
+                     'Result-Code'=Res,
95
+                     'Experimental-Result'=ExpRes,
96
                      'Auth-Session-State'=1};
97
        timeout ->
98
            Resp = #'AIA'{'Session-Id'=SessionId, 'Origin-Host'=OH, 'Origin-Realm'=OR,
99