summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2019-08-22 17:58:21 +0200
committerHarald Welte <laforge@gnumonks.org>2019-08-22 18:12:54 +0200
commit0b68059468026d6ac62429d91c43394b91b0dd47 (patch)
treec9737efa451b03c15b2abce949fc413917dcc488
parent22362cfc10146d0f4ffaea5ee4bb983b736f2dd1 (diff)
ipa_proto: Hook ipa_proto_ccm into the handling of CCM messages
-rw-r--r--src/ipa_proto.erl13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/ipa_proto.erl b/src/ipa_proto.erl
index fbe3623..b28b5cd 100644
--- a/src/ipa_proto.erl
+++ b/src/ipa_proto.erl
@@ -261,17 +261,22 @@ loop(S, StreamMap) ->
end.
% Respond with PONG to PING
-process_ccm_msg(Socket, StreamID, ?IPAC_MSGT_PING, _) ->
+process_ccm_msg(Socket, StreamID, 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, _) ->
+process_ccm_msg(Socket, StreamID, 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_RESP, _) ->
+process_ccm_msg(Socket, StreamID, id_resp, _) ->
io:format("Socket ~p Stream ~p: ID_RESP -> ID_ACK~n", [Socket, StreamID]),
send(Socket, StreamID, <<?IPAC_MSGT_ID_ACK>>);
+% Simply respond to ID_GET with ID_RESP
+process_ccm_msg(Socket, StreamID, id_req, _) ->
+ io:format("Socket ~p Stream ~p: ID_GET -> ID_RESP~n", [Socket, StreamID]),
+ CcmBin = ipa_proto_ccm:encode({id_resp, [{string,serial_nr,"MME-00-00-00-00-00-00"}]}),
+ send(Socket, StreamID, CcmBin);
% Default message handler for unknown messages
process_ccm_msg(Socket, StreamID, MsgType, Opts) ->
io:format("Socket ~p Stream ~p: Unknown CCM message type ~p Opts ~p~n",
@@ -279,7 +284,7 @@ process_ccm_msg(Socket, StreamID, MsgType, Opts) ->
% process an incoming CCM message (Stream ID 254)
process_rx_ccm_msg(Socket, StreamID, PayloadBin) ->
- [MsgType|Opts] = binary:bin_to_list(PayloadBin),
+ {MsgType, Opts} = ipa_proto_ccm:decode(PayloadBin),
process_ccm_msg(Socket, StreamID, MsgType, Opts).
send_ccm_id_get(Socket) ->