ipa_proto.erl: fix IPA IDENTITY REQUEST handling

This commit is contained in:
Vadim Yanitskiy 2019-08-19 23:28:39 +02:00
parent 8397f46969
commit 6cf4161403
1 changed files with 35 additions and 6 deletions

View File

@ -93,7 +93,8 @@ controlling_process(Socket, StreamID, NewPid) ->
% unblock the socket from further processing
unblock(Socket) ->
send_ccm_id_get(Socket),
% FIXME: why are we sending it here?!?
% send_ccm_id_get(Socket),
call_sync_sock(Socket, {ipa_unblock, Socket}).
@ -260,15 +261,43 @@ loop(S, StreamMap) ->
ok
end.
% Length-Tag-Value
gen_ccm_ltv_str(Tag, String) ->
Len = string:len(String) + 1 + 1,
BinString = list_to_binary(String),
<< 16#00, Len, Tag, BinString/binary, 16#00 >>.
% Parse Length-Tag list from the Request
gen_ccm_id_resp(Response, << >>) -> Response;
gen_ccm_id_resp(Response, LTList) ->
<< _Len, Tag, Rest/binary >> = LTList,
case Tag of
% Unit ID
16#08 ->
LTV = gen_ccm_ltv_str(Tag, "0/0/0"),
gen_ccm_id_resp(<< Response/binary, LTV/binary >>, Rest);
% Serial number, Unit name
% FIXME: hard-coded values!
16#00 ->
LTV = gen_ccm_ltv_str(Tag, "EUSE-OsmoSMSC-00-00-00-00-00-00"),
gen_ccm_id_resp(<< Response/binary, LTV/binary >>, Rest);
16#01 ->
LTV = gen_ccm_ltv_str(Tag, "EUSE-OsmoSMSC-00-00-00-00-00-00"),
gen_ccm_id_resp(<< Response/binary, LTV/binary >>, Rest);
_ ->
% HACK: for anything else, just use "00:00:00:00:00:00"
LTV = gen_ccm_ltv_str(Tag, "00:00:00:00:00:00"),
gen_ccm_id_resp(<< Response/binary, LTV/binary >>, Rest)
end.
% Respond with PONG to PING
process_ccm_msg(Socket, StreamID, ?IPAC_MSGT_PING, _) ->
io:format("Socket ~p Stream ~p: PING -> PONG~n", [Socket, StreamID]),
send(Socket, StreamID, <<?IPAC_MSGT_PONG>>);
% Simply respond to ID_ACK with ID_ACK
process_ccm_msg(Socket, StreamID, ?IPAC_MSGT_ID_ACK, _) ->
io:format("Socket ~p Stream ~p: ID_ACK -> ID_ACK~n", [Socket, StreamID]),
send(Socket, StreamID, <<?IPAC_MSGT_ID_ACK>>);
% Simply respond to ID_RESP with ID_ACK
process_ccm_msg(Socket, StreamID, ?IPAC_MSGT_ID_GET, Params) ->
io:format("Socket ~p Stream ~p: ID_GET -> ID_RESP~n", [Socket, StreamID]),
Response = gen_ccm_id_resp(<<?IPAC_MSGT_ID_RESP>>, list_to_binary(Params)),
send(Socket, StreamID, Response);
process_ccm_msg(Socket, StreamID, ?IPAC_MSGT_ID_RESP, _) ->
io:format("Socket ~p Stream ~p: ID_RESP -> ID_ACK~n", [Socket, StreamID]),
send(Socket, StreamID, <<?IPAC_MSGT_ID_ACK>>);