summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2019-08-19 23:28:39 +0200
committerVadim Yanitskiy <axilirator@gmail.com>2019-12-25 17:25:11 +0100
commit6cf416140345bdf8f1d1fb9cfdf7be95779cafdf (patch)
tree57ec2424fd7c99d79d264f9be3631c11f0818325 /src
parent8397f4696947628807cb4b6872c7453c480e707a (diff)
ipa_proto.erl: fix IPA IDENTITY REQUEST handling
Diffstat (limited to 'src')
-rw-r--r--src/ipa_proto.erl41
1 files changed, 35 insertions, 6 deletions
diff --git a/src/ipa_proto.erl b/src/ipa_proto.erl
index 9a3f3d0..8904072 100644
--- a/src/ipa_proto.erl
+++ b/src/ipa_proto.erl
@@ -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>>);