aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2010-08-05 17:21:55 +0200
committerHarald Welte <laforge@gnumonks.org>2010-08-05 17:21:55 +0200
commit27f9a6e8284ae612de0bdac5a6562cf880161dd8 (patch)
treef83d274e39c62ac2b1edf07f8ed52050974a2215
parent7faf5a725c3c525a61ce95f3ed6aeded29bba222 (diff)
[IPA] fix compiler warnings
-rw-r--r--src/ipa_proto.erl16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/ipa_proto.erl b/src/ipa_proto.erl
index 4e7e668..9b7f75a 100644
--- a/src/ipa_proto.erl
+++ b/src/ipa_proto.erl
@@ -139,7 +139,7 @@ reply({From, Ref}, Reply) ->
init() ->
case ets:new(ipa_sockets, [named_table, set, public, {keypos, #ipa_socket.socket}]) of
ipa_sockets ->
- {ok};
+ ok;
_ ->
{error, ets_new_ipa_sockets}
end.
@@ -169,19 +169,25 @@ loop(S, StreamMap) ->
ok
end.
-process_ccm_msg(Socket, StreamID, ?IPAC_MSGT_PING, Opts) ->
+% Respond with PONG to PING
+process_ccm_msg(Socket, StreamID, ?IPAC_MSGT_PING, _) ->
send(Socket, StreamID, <<?IPAC_MSGT_PONG>>);
-process_ccm_msg(Socket, StreamID, ?IPAC_MSGT_ID_ACK, Opts) ->
+% Simply respond to ID_ACK with ID_ACK
+process_ccm_msg(Socket, StreamID, ?IPAC_MSGT_ID_ACK, _) ->
send(Socket, StreamID, <<?IPAC_MSGT_ID_ACK>>);
+% Default message handler for unknown messages
process_ccm_msg(Socket, StreamID, MsgType, Opts) ->
- io:format("Unknown CCM message type ~p~n", [MsgType]).
+ io:format("Socket ~p Stream ~p: Unknown CCM message type ~p Opts ~p~n",
+ [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),
process_ccm_msg(Socket, StreamID, MsgType, Opts).
+% convenience wrapper for interactive use / debugging from the shell
listen_accept_handle(LPort, Opts) ->
- case gen_tcp:listen(LPort, Opts) of
+ case gen_tcp:listen(LPort, [binary, {packet, 0}, {reuseaddr, true}] ++ Opts) of
{ok, ListenSock} ->
{ok, Port} = inet:port(ListenSock),
{ok, Sock} = gen_tcp:accept(ListenSock),