summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2011-04-04 11:26:11 +0200
committerHarald Welte <laforge@gnumonks.org>2011-04-04 11:26:11 +0200
commitb2d3abfbb141b4e6da45dd9fe9ebba647e8affac (patch)
tree9ba56808bc760bd1a508f01c40c9817d1292ebbe /src
parent6fc5b29c5b8ca4b72294129842faede5bc9c733f (diff)
M3UA: Fix some compiler warnings; add code_change/4 and terminate/3
Diffstat (limited to 'src')
-rw-r--r--src/m3ua_core.erl13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/m3ua_core.erl b/src/m3ua_core.erl
index 03872f7..82ba326 100644
--- a/src/m3ua_core.erl
+++ b/src/m3ua_core.erl
@@ -26,7 +26,7 @@
-export([start_link/1]).
--export([init/1, handle_event/3, handle_info/3]).
+-export([init/1, terminate/3, code_change/4, handle_event/3, handle_info/3]).
% FSM states:
-export([asp_down/2, asp_inactive/2, asp_active/2]).
@@ -79,6 +79,13 @@ init(InitOpts) ->
LoopDat2 = reconnect_sctp(LoopDat),
{ok, asp_down, LoopDat2}.
+terminate(Reason, _State, LoopDat) ->
+ io:format("Terminating ~p (Reason: ~p)~n", [?MODULE, Reason]),
+ gen_sctp:close(LoopDat#m3ua_state.sctp_sock).
+
+code_change(_OldVsn, StateName, StateData, _Extra) ->
+ {ok, StateName, StateData}.
+
% Helper function to send data to the SCTP peer
send_sctp_to_peer(LoopDat, PktData) when is_binary(PktData) ->
#m3ua_state{sctp_sock = Sock, sctp_assoc_id = Assoc} = LoopDat,
@@ -112,7 +119,7 @@ handle_info({sctp, Socket, _RemoteIp, _RemotePort, {ANC, SAC}},
_State, LoopDat) when is_record(SAC, sctp_assoc_change) ->
io:format("SCTP Assoc Change ~p ~p~n", [ANC, SAC]),
#sctp_assoc_change{state = SacState, outbound_streams = _OutStreams,
- inbound_streams = _InStreams, assoc_id = AssocId} = SAC,
+ inbound_streams = _InStreams, assoc_id = _AssocId} = SAC,
case SacState of
comm_up ->
% FIXME: primmitive to the user
@@ -251,7 +258,7 @@ asp_active(M3uaMsg, LoopDat) when is_record(M3uaMsg, m3ua_msg) ->
rx_m3ua(M3uaMsg, asp_active, LoopDat).
-rx_sctp(Anc, Data, State, LoopDat) ->
+rx_sctp(_Anc, Data, State, LoopDat) ->
M3uaMsg = m3ua_codec:parse_m3ua_msg(Data),
gen_fsm:send_event(self(), M3uaMsg),
{next_state, State, LoopDat}.