blob: d0dcb49ca90be9228f5e20c186d2467007de37b8 [file] [log] [blame]
Harald Welte61276c42019-08-10 22:14:50 +02001-module(server_cb).
2
3
4-include_lib("diameter/include/diameter.hrl").
5-include_lib("diameter/include/diameter_gen_base_rfc6733.hrl").
6-include_lib("diameter_3gpp_ts29_272.hrl").
Harald Welte44da7d72019-08-14 13:28:08 +02007-include_lib("osmo_gsup/include/gsup_protocol.hrl").
Harald Welte61276c42019-08-10 22:14:50 +02008
Alexander Couzens6ba22c22023-09-01 15:42:18 +02009-define(DIA_VENDOR_3GPP, 10415).
Harald Welte61276c42019-08-10 22:14:50 +020010
11%% diameter callbacks
12-export([peer_up/3, peer_down/3, pick_peer/4, prepare_request/3, prepare_retransmit/3,
13 handle_answer/4, handle_error/4, handle_request/3]).
14
15-define(UNEXPECTED, erlang:error({unexpected, ?MODULE, ?LINE})).
16
17peer_up(_SvcName, {PeerRef, Caps}, State) ->
18 lager:info("Peer up ~p - ~p~n", [PeerRef, lager:pr(Caps, ?MODULE)]),
19 State.
20
21peer_down(_SvcName, {PeerRef, Caps}, State) ->
22 lager:info("Peer down ~p - ~p~n", [PeerRef, lager:pr(Caps, ?MODULE)]),
23 State.
24
25pick_peer(_, _, _SvcName, _State) ->
26 ?UNEXPECTED.
27
28prepare_request(_, _SvcName, _Peer) ->
29 ?UNEXPECTED.
30
31prepare_retransmit(_Packet, _SvcName, _Peer) ->
32 ?UNEXPECTED.
33
34handle_answer(_Packet, _Request, _SvcName, _Peer) ->
35 ?UNEXPECTED.
36
37handle_error(_Reason, _Request, _SvcName, _Peer) ->
38 lager:error("Request error: ~p~n", [_Reason]),
39 ?UNEXPECTED.
40
Harald Welte44da7d72019-08-14 13:28:08 +020041% generate Diameter E-UTRAN / UTRAN / GERAN Vectors from GSUP tuple input
42-spec gsup_tuple2dia_eutran('GSUPAuthTuple'(), binary(), integer()) -> #'E-UTRAN-Vector'{}.
43gsup_tuple2dia_eutran(#{autn:=Autn, ck:=Ck, ik:=Ik, rand:=Rand, res:=Res}, Vplmn, Idx) ->
44 #'E-UTRAN-Vector'{'Item-Number'=Idx, 'RAND'=Rand, 'XRES'=Res , 'AUTN'=Autn,
45 'KASME'=compute_kasme(Ck, Ik, Vplmn, Autn)}.
46
47-spec gsup_tuple2dia_utran('GSUPAuthTuple'()) -> #'UTRAN-Vector'{}.
48gsup_tuple2dia_utran(#{autn:=Autn, ck:=Ck, ik:=Ik, rand:=Rand, res:=Res}) ->
49 #'UTRAN-Vector'{'RAND'=Rand, 'XRES'=Res, 'AUTN'=Autn, 'Confidentiality-Key'=Ck, 'Integrity-Key'=Ik}.
50
51-spec gsup_tuple2dia_geran('GSUPAuthTuple'()) -> #'GERAN-Vector'{}.
52gsup_tuple2dia_geran(#{rand:=Rand, sres:=Sres, kc:=Kc}) ->
53 #'GERAN-Vector'{'RAND'=Rand, 'SRES'=Sres, 'Kc'=Kc}.
54
55-spec gsup_tuples2dia_eutran(['GSUPAuthTuple'()], binary()) -> [#'E-UTRAN-Vector'{}].
56gsup_tuples2dia_eutran(List, Vplmn) -> gsup_tuples2dia_eutran(List, Vplmn, [], 1).
57gsup_tuples2dia_eutran([], _Vplmn, Out, _Idx) -> Out;
58gsup_tuples2dia_eutran([Head|Tail], Vplmn, Out, Ctr) ->
59 Dia = gsup_tuple2dia_eutran(Head, Vplmn, Ctr),
60 gsup_tuples2dia_eutran(Tail, Vplmn, [Dia|Out], Ctr+1).
61
62-type int_or_false() :: false | integer().
63-spec gsup_tuples2dia(['GSUPAuthTuple'()], binary(), int_or_false(), int_or_false(), int_or_false()) -> #'Authentication-Info'{}.
64gsup_tuples2dia(Tuples, Vplmn, NumEutran, NumUtran, NumGeran) ->
65 case NumEutran of
66 false -> EutranVecs = [];
67 0 -> EutranVecs = [];
68 _ -> EutranVecs = gsup_tuples2dia_eutran(lists:sublist(Tuples,NumEutran), Vplmn)
69 end,
70 case NumUtran of
71 false -> UtranVecs = [];
72 0 -> UtranVecs = [];
73 _ -> UtranVecs = lists:map(fun gsup_tuple2dia_utran/1, lists:sublist(Tuples,NumUtran))
74 end,
75 case NumGeran of
76 false -> GeranVecs = [];
77 0 -> GeranVecs = [];
78 _ -> GeranVecs = lists:map(fun gsup_tuple2dia_geran/1, lists:sublist(Tuples,NumGeran))
79 end,
80 #'Authentication-Info'{'E-UTRAN-Vector'=EutranVecs, 'UTRAN-Vector'=UtranVecs,
81 'GERAN-Vector'=GeranVecs}.
82
83
84-spec compute_kasme(<<_:16>>, <<_:16>>, <<_:3>>, <<_:16>>) -> <<_:32>>.
85compute_kasme(Ck, Ik, VplmnId, Autn) ->
86 Autn6 = binary_part(Autn, 0, 6),
87 K = <<Ck:16/binary, Ik:16/binary>>,
88 S = <<16, VplmnId:3/binary, 0, 3, Autn6:6/binary, 0, 6>>,
Daniel Willmann592cc8b2022-04-22 16:08:48 +020089 Release = erlang:system_info(otp_release),
90 if
91 Release >= "24" ->
92 crypto:macN(hmac, sha256, K, S, 32);
93 true ->
94 crypto:hmac(sha256, K, S, 32)
95 end.
Harald Welte44da7d72019-08-14 13:28:08 +020096
97-spec req_num_of_vec([tuple()]) -> int_or_false().
98req_num_of_vec([#'Requested-EUTRAN-Authentication-Info'{'Number-Of-Requested-Vectors'=[]}]) -> false;
99req_num_of_vec([#'Requested-EUTRAN-Authentication-Info'{'Number-Of-Requested-Vectors'=[Num]}]) -> Num;
100req_num_of_vec([#'Requested-UTRAN-GERAN-Authentication-Info'{'Number-Of-Requested-Vectors'=[]}]) -> false;
101req_num_of_vec([#'Requested-UTRAN-GERAN-Authentication-Info'{'Number-Of-Requested-Vectors'=[Num]}]) -> Num;
102req_num_of_vec(_) -> false.
103
Matt Johnson9e0bd802020-08-21 17:31:57 -0700104
105-type binary_or_false() :: false | binary().
106-spec req_resynchronization_info([tuple()]) -> binary_or_false().
107req_resynchronization_info([#'Requested-EUTRAN-Authentication-Info'{'Re-Synchronization-Info'=[]}]) ->
108 false;
109req_resynchronization_info([#'Requested-EUTRAN-Authentication-Info'{'Re-Synchronization-Info'=[Info]}]) ->
110 list_to_binary(Info);
111
112req_resynchronization_info([#'Requested-UTRAN-GERAN-Authentication-Info'{'Re-Synchronization-Info'=[]}]) ->
113 false;
114req_resynchronization_info([#'Requested-UTRAN-GERAN-Authentication-Info'{'Re-Synchronization-Info'=[Info]}]) ->
115 list_to_binary(Info);
116
117req_resynchronization_info(_) ->
118 false.
119
Harald Welte299ba932019-08-15 18:31:12 +0200120-define(PDP_TYPE_DEFAULT, <<0,0,0,16#21>>). % IPv4
121-define(PDP_QOS_DEFAULT, <<0,0,0,0,0,0,0,0,0,0,0,0,0,0>>). % fixme
122
Harald Welte44da7d72019-08-14 13:28:08 +0200123-spec gsup_pdp2dia('GSUPPdpInfo'()) -> #'PDP-Context'{}.
124gsup_pdp2dia(GsupPdpInfo) ->
Harald Welte299ba932019-08-15 18:31:12 +0200125 #'PDP-Context'{'PDP-Type' = maps:get(pdp_type, GsupPdpInfo, ?PDP_TYPE_DEFAULT),
Harald Welte44da7d72019-08-14 13:28:08 +0200126 'Context-Identifier' = maps:get(pdp_context_id, GsupPdpInfo),
Alexander Couzens7c912ff2023-04-26 17:58:00 +0000127 'Service-Selection' = decode_apn:decode_apn(maps:get(access_point_name, GsupPdpInfo)),
Harald Welte299ba932019-08-15 18:31:12 +0200128 'QoS-Subscribed' = maps:get(quality_of_service, GsupPdpInfo, ?PDP_QOS_DEFAULT)
Harald Welte44da7d72019-08-14 13:28:08 +0200129 }.
130
Harald Welte299ba932019-08-15 18:31:12 +0200131-define(PDN_TYPE_DEFAULT, 0). % IPv4
132-define(EPS_QOS_DEFAULT,
133 #'EPS-Subscribed-QoS-Profile'{'QoS-Class-Identifier'=9,
134 'Allocation-Retention-Priority'=
135 #'Allocation-Retention-Priority'{'Priority-Level'=8,
136 'Pre-emption-Capability'=1,
137 'Pre-emption-Vulnerability'=1}
138 }).
139
140-spec gsup_pdp2dia_apn('GSUPPdpInfo'()) -> #'APN-Configuration'{}.
141gsup_pdp2dia_apn(GsupPdpInfo) ->
142 #'APN-Configuration'{'Context-Identifier' = maps:get(pdp_context_id, GsupPdpInfo),
143 'PDN-Type' = maps:get(pdp_type, GsupPdpInfo, ?PDN_TYPE_DEFAULT),
144 % The EPS-Subscribed-QoS-Profile AVP and the AMBR AVP shall be present in the
145 % APN-Configuration AVP when the APN-Configuration AVP is sent in the
146 % APN-Configuration-Profile AVP and when the APN-Configuration-Profile AVP is
147 % sent within a ULA (as part of the Subscription-Data AVP).
148 'EPS-Subscribed-QoS-Profile' = ?EPS_QOS_DEFAULT,
149 'AMBR' = #'AMBR'{'Max-Requested-Bandwidth-UL' = 100000000,
150 'Max-Requested-Bandwidth-DL' = 100000000},
151 % The default APN Configuration shall not contain the Wildcard APN (see 3GPP TS
152 % 23.003 [3], clause 9.2); the default APN shall always contain an explicit APN
Alexander Couzens7c912ff2023-04-26 17:58:00 +0000153 'Service-Selection' = decode_apn:decode_apn(maps:get(access_point_name, GsupPdpInfo))
Harald Welte299ba932019-08-15 18:31:12 +0200154 }.
155
Harald Welte44da7d72019-08-14 13:28:08 +0200156% transient (only in Experimental-Result-Code)
157-define(DIAMETER_AUTHENTICATION_DATA_UNAVAILABLE, 4181).
158-define(DIAMETER_ERROR_CAMEL_SUBSCRIPTION_PRESENT, 4182).
159% permanent (only in Experimental-Result-Code)
160-define(DIAMETER_ERROR_USER_UNKNOWN, 5001).
Pau Espin Pedrolb524e242023-08-30 16:33:55 +0200161-define(DIAMETER_AUTHORIZATION_REJECTED, 5003).
Harald Welte44da7d72019-08-14 13:28:08 +0200162-define(DIAMETER_ERROR_ROAMING_NOT_ALLOWED, 5004).
Pau Espin Pedrolb524e242023-08-30 16:33:55 +0200163-define(DIAMETER_MISSING_AVP, 5005).
164-define(DIAMETER_UNABLE_TO_COMPLY, 5012).
Harald Welte44da7d72019-08-14 13:28:08 +0200165-define(DIAMETER_ERROR_UNKNOWN_EPS_SUBSCRIPTION, 5420).
166-define(DIAMETER_ERROR_RAT_NOT_ALLOWED, 5421).
167-define(DIAMETER_ERROR_EQUIPMENT_UNKNOWN, 5422).
168-define(DIAMETER_ERROR_UNKOWN_SERVING_NODE, 5423).
169
170% 10.5.5.14
171-define(GMM_CAUSE_IMSI_UNKNOWN, 16#02).
Pau Espin Pedrol5e11d282023-08-30 16:27:42 +0200172-define(GMM_CAUSE_ILLEGAL_MS, 16#03).
Harald Welte44da7d72019-08-14 13:28:08 +0200173-define(GMM_CAUSE_GPRS_NOTALLOWED, 16#07).
Pau Espin Pedrol5e11d282023-08-30 16:27:42 +0200174-define(GMM_CAUSE_PLMN_NOTALLOWED, 16#0b).
175-define(GMM_CAUSE_LA_NOTALLOWED, 16#0c).
176-define(GMM_CAUSE_ROAMING_NOTALLOWED, 16#0d).
177-define(GMM_CAUSE_NO_SUIT_CELL_IN_LA, 16#0f).
Harald Welte44da7d72019-08-14 13:28:08 +0200178-define(GMM_CAUSE_NET_FAIL, 16#11).
Pau Espin Pedrol5e11d282023-08-30 16:27:42 +0200179-define(GMM_CAUSE_CONGESTION, 16#16).
180-define(GMM_CAUSE_GSM_AUTH_UNACCEPT, 16#17).
181-define(GMM_CAUSE_INV_MAND_INFO, 16#60).
182-define(GMM_CAUSE_PROTO_ERR_UNSPEC, 16#6f).
Harald Welte44da7d72019-08-14 13:28:08 +0200183
Alexander Couzens6ba22c22023-09-01 15:42:18 +0200184-define(EXP_RES(Exp), #'Experimental-Result'{'Vendor-Id'=?DIA_VENDOR_3GPP, 'Experimental-Result-Code'=Exp}).
Harald Welte44da7d72019-08-14 13:28:08 +0200185
Pau Espin Pedrolb524e242023-08-30 16:33:55 +0200186%% see 29.272 Annex A/B
Harald Welte44da7d72019-08-14 13:28:08 +0200187-type empty_or_intl() :: [] | [integer()].
188-spec gsup_cause2dia(integer()) -> {empty_or_intl(), empty_or_intl()}.
189gsup_cause2dia(?GMM_CAUSE_IMSI_UNKNOWN) -> {[], [?EXP_RES(?DIAMETER_ERROR_USER_UNKNOWN)]};
Pau Espin Pedrolb524e242023-08-30 16:33:55 +0200190gsup_cause2dia(?GMM_CAUSE_ILLEGAL_MS) -> {[], [?EXP_RES(?DIAMETER_ERROR_USER_UNKNOWN)]};
191gsup_cause2dia(?GMM_CAUSE_PLMN_NOTALLOWED) -> {[], [?EXP_RES(?DIAMETER_ERROR_ROAMING_NOT_ALLOWED)]};
192gsup_cause2dia(?GMM_CAUSE_GPRS_NOTALLOWED) -> {[], [?EXP_RES(?DIAMETER_ERROR_UNKNOWN_EPS_SUBSCRIPTION)]};
193
194gsup_cause2dia(?GMM_CAUSE_LA_NOTALLOWED) -> {[?DIAMETER_AUTHORIZATION_REJECTED], []};
195gsup_cause2dia(?GMM_CAUSE_ROAMING_NOTALLOWED) -> {[], [?EXP_RES(?DIAMETER_ERROR_ROAMING_NOT_ALLOWED)]};
196gsup_cause2dia(?GMM_CAUSE_NO_SUIT_CELL_IN_LA) -> {[], [?EXP_RES(?DIAMETER_ERROR_UNKNOWN_EPS_SUBSCRIPTION)]};
197gsup_cause2dia(?GMM_CAUSE_NET_FAIL) -> {[?DIAMETER_UNABLE_TO_COMPLY], []};
198gsup_cause2dia(?GMM_CAUSE_CONGESTION) -> {[?DIAMETER_UNABLE_TO_COMPLY], []};
199gsup_cause2dia(?GMM_CAUSE_INV_MAND_INFO) -> {[?DIAMETER_MISSING_AVP], []};
200gsup_cause2dia(?GMM_CAUSE_PROTO_ERR_UNSPEC) -> {[?DIAMETER_UNABLE_TO_COMPLY], []};
Alexander Couzensb8aef302023-09-01 15:44:58 +0200201gsup_cause2dia(_) -> {[?DIAMETER_UNABLE_TO_COMPLY], []}.
Harald Welte44da7d72019-08-14 13:28:08 +0200202
203% get the value for a tiven key in Map1. If not found, try same key in Map2. If not found, return Default
204-spec twomap_get(atom(), map(), map(), any()) -> any().
205twomap_get(Key, Map1, Map2, Default) ->
206 maps:get(Key, Map1, maps:get(Key, Map2, Default)).
207
208handle_request(#diameter_packet{msg = Req, errors = []}, _SvcName, {_, Caps}) when is_record(Req, 'AIR') ->
209 lager:info("AIR: ~p~n", [Req]),
210 % extract relevant fields from DIAMETER AIR
211 #diameter_caps{origin_host = {OH,_}, origin_realm = {OR,_}} = Caps,
212 #'AIR'{'Session-Id' = SessionId,
213 'User-Name' = UserName,
214 'Visited-PLMN-Id' = VplmnId,
215 'Requested-EUTRAN-Authentication-Info' = ReqEU,
216 'Requested-UTRAN-GERAN-Authentication-Info' = ReqUG} = Req,
217 VplmnIdBin = list_to_binary(VplmnId),
218 NumEutran = req_num_of_vec(ReqEU),
219 NumUgran = req_num_of_vec(ReqUG),
220 lager:info("Num EUTRAN=~p, UTRAN=~p~n", [NumEutran, NumUgran]),
221 % construct GSUP request to HLR and transceive it
Harald Welte388d3872019-12-01 17:03:15 +0100222 GsupTx1 = #{message_type => send_auth_info_req, imsi => list_to_binary(UserName),
223 supported_rat_types => [rat_eutran_sgs], current_rat_type => rat_eutran_sgs},
Matt Johnson9e0bd802020-08-21 17:31:57 -0700224 ResyncInfo = req_resynchronization_info(ReqEU),
225 case ResyncInfo of
226 false ->
227 GsupTx2 = #{};
228 ValidResyncInfo ->
229 lager:info("ResyncInfo is valid ~p", [ResyncInfo]),
230 GsupTx2 = #{rand => binary:part(ValidResyncInfo, 0, 16),
231 auts => binary:part(ValidResyncInfo, 16, 14)}
Harald Welte332fe7f2019-08-20 22:36:50 +0200232 end,
233 GsupTx = maps:merge(GsupTx1, GsupTx2),
Harald Welte44da7d72019-08-14 13:28:08 +0200234 GsupRx = gen_server:call(gsup_client, {transceive_gsup, GsupTx, send_auth_info_res, send_auth_info_err}),
235 lager:info("GsupRx: ~p~n", [GsupRx]),
236 % construct DIAMETER AIA response
237 case GsupRx of
238 #{message_type:=send_auth_info_res, auth_tuples:=GsupAuthTuples} ->
239 AuthInfo = gsup_tuples2dia(GsupAuthTuples, VplmnIdBin, NumEutran, NumUgran, NumUgran),
240 Resp = #'AIA'{'Session-Id'=SessionId, 'Origin-Host'=OH, 'Origin-Realm'=OR,
241 'Result-Code'=2001, 'Auth-Session-State'=1,
242 'Authentication-Info'=AuthInfo};
Pau Espin Pedrolb524e242023-08-30 16:33:55 +0200243 #{message_type := send_auth_info_err, cause:=Cause} ->
244 {Res, ExpRes} = gsup_cause2dia(Cause),
Harald Welte44da7d72019-08-14 13:28:08 +0200245 Resp = #'AIA'{'Session-Id'=SessionId, 'Origin-Host'=OH, 'Origin-Realm'=OR,
Pau Espin Pedrolb524e242023-08-30 16:33:55 +0200246 'Result-Code'=Res,
247 'Experimental-Result'=ExpRes,
Harald Welte44da7d72019-08-14 13:28:08 +0200248 'Auth-Session-State'=1};
249 timeout ->
250 Resp = #'AIA'{'Session-Id'=SessionId, 'Origin-Host'=OH, 'Origin-Realm'=OR,
251 'Result-Code'=4181, 'Auth-Session-State'=1}
252 end,
253 lager:info("Resp: ~p~n", [Resp]),
254 {reply, Resp};
255
256handle_request(#diameter_packet{msg = Req, errors = []}, _SvcName, {_, Caps}) when is_record(Req, 'ULR') ->
Harald Welte6f529082019-08-21 14:54:27 +0200257 % extract relevant fields from DIAMETER ULR
Harald Welte44da7d72019-08-14 13:28:08 +0200258 #diameter_caps{origin_host = {OH,_}, origin_realm = {OR,_}} = Caps,
259 #'ULR'{'Session-Id' = SessionId,
260 'RAT-Type' = RatType,
261 'ULR-Flags' = UlrFlags,
262 'User-Name' = UserName} = Req,
263
264 % construct GSUP UpdateLocation request to HLR and transceive it; expect InsertSubscrDataReq
Harald Welte299ba932019-08-15 18:31:12 +0200265 GsupTxUlReq = #{message_type => location_upd_req, imsi => list_to_binary(UserName),
266 cn_domain => 1},
Harald Welte44da7d72019-08-14 13:28:08 +0200267 GsupRxIsdReq = gen_server:call(gsup_client,
268 {transceive_gsup, GsupTxUlReq, insert_sub_data_req, location_upd_err}),
269 lager:info("GsupRxIsdReq: ~p~n", [GsupRxIsdReq]),
270 case GsupRxIsdReq of
271 #{message_type:=location_upd_err, cause:=Cause} ->
272 {Res, ExpRes} = gsup_cause2dia(Cause),
273 Resp = #'ULA'{'Session-Id'= SessionId, 'Auth-Session-State'=1,
274 'Origin-Host'=OH, 'Origin-Realm'=OR,
275 'Result-Code'=Res, 'Experimental-Result'=ExpRes};
276 #{message_type:=insert_sub_data_req} ->
277 % construct GSUP InsertSubscrData response to HLR and transceive it; expect
278 % UpdateLocationRes
Harald Welte299ba932019-08-15 18:31:12 +0200279 GsupTxIsdRes = #{message_type => insert_sub_data_res,
280 imsi => list_to_binary(UserName)},
Harald Welte44da7d72019-08-14 13:28:08 +0200281 GsupRxUlRes = gen_server:call(gsup_client,
282 {transceive_gsup, GsupTxIsdRes, location_upd_res, location_upd_err}),
283 lager:info("GsupRxUlRes: ~p~n", [GsupRxUlRes]),
284
285 case GsupRxUlRes of
286 #{message_type:=location_upd_res} ->
287 Msisdn = twomap_get(msisdn, GsupRxIsdReq, GsupRxUlRes, []),
Harald Welte299ba932019-08-15 18:31:12 +0200288 Compl = twomap_get(pdp_info_complete, GsupRxIsdReq, GsupRxUlRes, 0),
289
290 % build the GPRS Subscription Data
Harald Welte44da7d72019-08-14 13:28:08 +0200291 PdpInfoList = twomap_get(pdp_info_list, GsupRxIsdReq, GsupRxUlRes, []),
Harald Welte299ba932019-08-15 18:31:12 +0200292 PdpContexts = lists:map(fun gsup_pdp2dia/1, PdpInfoList),
293 GSubD = #'GPRS-Subscription-Data'{'Complete-Data-List-Included-Indicator'=Compl,
Harald Welte44da7d72019-08-14 13:28:08 +0200294 'PDP-Context'=PdpContexts},
Harald Welte299ba932019-08-15 18:31:12 +0200295
296 % build the APN-Configuration-Profile
297 ApnCfgList = lists:map(fun gsup_pdp2dia_apn/1, PdpInfoList),
298 FirstApn = lists:nth(1, ApnCfgList),
299 DefaultCtxId = FirstApn#'APN-Configuration'.'Context-Identifier',
300 ApnCfgProf = #'APN-Configuration-Profile'{'Context-Identifier' = DefaultCtxId,
301 'All-APN-Configurations-Included-Indicator'=Compl,
302 'APN-Configuration' = ApnCfgList},
303
304 % put together the Subscription-Data and finally the ULA response
305 SubscrData = #'Subscription-Data'{'MSISDN' = Msisdn,
306
307 'Network-Access-Mode' = 0, % PACKET_AND_CIRCUIT
308 'GPRS-Subscription-Data' = GSubD,
309 % Subscriber-Status must be present in ULA
310 'Subscriber-Status' = 0,
311 % AMBR must be present if this is an ULA; let's permit 100MBps UL + DL
312 'AMBR' = #'AMBR'{'Max-Requested-Bandwidth-UL' = 100000000,
313 'Max-Requested-Bandwidth-DL' = 100000000},
314 'APN-Configuration-Profile' = ApnCfgProf},
315 Resp = #'ULA'{'Session-Id' = SessionId, 'Auth-Session-State' = 1,
316 'Origin-Host' = OH, 'Origin-Realm' = OR,
317 'Result-Code' = 2001,
318 'Subscription-Data' = SubscrData, 'ULA-Flags' = 0};
Harald Welte44da7d72019-08-14 13:28:08 +0200319 #{message_type:=location_upd_err, cause:=Cause} ->
320 {Res, ExpRes} = gsup_cause2dia(Cause),
321 Resp = #'ULA'{'Session-Id'= SessionId, 'Auth-Session-State'=1,
322 'Origin-Host'=OH, 'Origin-Realm'=OR,
323 'Result-Code'=Res, 'Experimental-Result'=ExpRes};
324 _ ->
325 Resp = #'ULA'{'Session-Id'= SessionId, 'Auth-Session-State'=1,
326 'Origin-Host'=OH, 'Origin-Realm'=OR,
327 'Result-Code'=fixme}
328 end
329 end,
Harald Welte299ba932019-08-15 18:31:12 +0200330 lager:info("ULR Resp: ~p~n", [Resp]),
Harald Welte44da7d72019-08-14 13:28:08 +0200331 {reply, Resp};
332
333handle_request(Packet, _SvcName, {_,_}) ->
334 lager:error("Unsuppoerted message: ~p~n", [Packet]),
Harald Welte61276c42019-08-10 22:14:50 +0200335 discard.