diff options
author | Harald Welte <laforge@gnumonks.org> | 2013-07-15 11:27:10 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2013-08-24 14:06:49 +0200 |
commit | a5dfd5b4491f318db734617024c122f104a28ac5 (patch) | |
tree | b266fd2f8d0ee587b5b1f21bb471881f00d149bd | |
parent | 9b9ec4abb78ad70c74a9a4739ce504bf9f921e8d (diff) |
m3ua_core: handle 'sctp_paddr_change' event
This happens e.g. if the route to the peer STP is lost, and we shouldn't
crash just because that happens, but rather try to reconnect...
-rw-r--r-- | src/m3ua_core.erl | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/m3ua_core.erl b/src/m3ua_core.erl index 9a596e6..1841517 100644 --- a/src/m3ua_core.erl +++ b/src/m3ua_core.erl @@ -171,6 +171,29 @@ handle_info({sctp, Socket, _RemoteIp, _RemotePort, {ANC, SAC}}, inet:setopts(Socket, [{active, once}]), {next_state, asp_down, LoopDat2}; +handle_info({sctp, Socket, _RemoteIp, _RemotePort, {ANC, SPC}}, + State, LoopDat) when is_record(SPC, sctp_paddr_change) -> + io:format("SCTP Peer address change ~p ~p~n", [ANC, SPC]), + {NewState, LoopDat2} = case SPC#sctp_paddr_change.state of + addr_available -> + % we don't care + {State, LoopDat}; + addr_unreachable -> + send_prim_to_user(LoopDat, osmo_util:make_prim('M','SCTP_RELEASE',indication)), + {asp_down, reconnect_sctp(LoopDat)}; + addr_removed -> + % FIXME: what if the last one is removed + {State, LoopDat}; + addr_added -> + % we don't care + {State, LoopDat}; + addr_made_prim -> + % FIXME: do we need to change remote_ip in our LoopDat? + {State, LoopDat} + end, + inet:setopts(Socket, [{active, once}]), + {next_state, NewState, LoopDat2}; + handle_info({sctp, Socket, RemoteIp, RemotePort, {[Anc], Data}}, State, LoopDat) -> io:format("SCTP rx data: ~p ~p~n", [Anc, Data]), % process incoming SCTP data |