From 56afaf688acc769c382b04725f279e926a2fe53e Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 8 Sep 2013 19:37:22 +0200 Subject: sctp_handler: Fix sctp_local_out() for packet injection When we call gen_sctp:send(), erlang is quite picky about which fields are permitted to be set or not in #sctp_sndrcvsinfo{} so rather than passing one through we received from the stack, we create a new one and fill in only stream, ppid and assoc_id. --- src/sctp_handler.erl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/sctp_handler.erl b/src/sctp_handler.erl index 64eac7e..f0a6b50 100644 --- a/src/sctp_handler.erl +++ b/src/sctp_handler.erl @@ -195,8 +195,8 @@ handle_rx_data(_Mod, _L, From, SRInfo, Data) when is_binary(Data) -> io:format("Unhandled Rx Data from SCTP from ~p: ~p, ~p~n", [From, SRInfo, Data]). -sctp_local_out(L, From, OutData, SRInf) when is_record(L, loop_data), - is_record(SRInf, sctp_sndrcvinfo) -> +sctp_local_out(L, From, OutData, SRInf = #sctp_sndrcvinfo{ppid = 2, stream = Stream}) + when is_record(L, loop_data) -> case From of from_msc -> Sock = L#loop_data.stp_sock, @@ -205,4 +205,5 @@ sctp_local_out(L, From, OutData, SRInf) when is_record(L, loop_data), Sock = L#loop_data.msc_sock, AssocId = L#loop_data.msc_assoc_id end, - gen_sctp:send(Sock, SRInf#sctp_sndrcvinfo{assoc_id = AssocId}, OutData). + SRInf2 = #sctp_sndrcvinfo{ppid = 2, stream = Stream, assoc_id = AssocId}, + ok = gen_sctp:send(Sock, SRInf2, OutData). -- cgit v1.2.3