fixeria has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/38681?usp=email )


Change subject: s1ap_proxy: merge process_pdu_safe() with process_pdu()
......................................................................

s1ap_proxy: merge process_pdu_safe() with process_pdu()

We always use the _safe() variant, so it makes no sense to
expose the "unsafe" variant as public API.

Change-Id: I91092625ae577d17a1f96db79804c813b878abfc
---
M src/s1ap_proxy.erl
M src/sctp_proxy.erl
2 files changed, 4 insertions(+), 13 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-s1gw 
refs/changes/81/38681/1

diff --git a/src/s1ap_proxy.erl b/src/s1ap_proxy.erl
index 6ec3d10..17ae7d4 100644
--- a/src/s1ap_proxy.erl
+++ b/src/s1ap_proxy.erl
@@ -37,7 +37,6 @@
 -export([init/0,
          deinit/1,
          process_pdu/2,
-         process_pdu_safe/2,
          handle_exit/2,
          encode_pdu/1,
          decode_pdu/1]).
@@ -95,7 +94,7 @@
 -spec process_pdu(binary(), proxy_state()) -> process_pdu_result().
 process_pdu(OrigData, S0) ->
     s1gw_metrics:ctr_inc(?S1GW_CTR_S1AP_PROXY_IN_PKT_ALL),
-    case decode_pdu(OrigData) of
+    try decode_pdu(OrigData) of
         {ok, PDU} ->
             ?LOG_DEBUG("Rx S1AP PDU: ~p", [PDU]),
             case handle_pdu(PDU, S0) of
@@ -121,20 +120,12 @@
             s1gw_metrics:ctr_inc(?S1GW_CTR_S1AP_PROXY_IN_PKT_DECODE_ERROR),
             s1gw_metrics:ctr_inc(?S1GW_CTR_S1AP_PROXY_OUT_PKT_FWD_UNMODIFIED),
             {{forward, OrigData}, S0} %% XXX: forward as-is or drop?
-    end.
-
-
-%% A safe wrapper for proc/2
--spec process_pdu_safe(binary(), proxy_state()) -> process_pdu_result().
-process_pdu_safe(OrigData, S) ->
-    try process_pdu(OrigData, S) of
-        Result -> Result
     catch
         Exception:Reason:StackTrace ->
             ?LOG_ERROR("An exception occurred: ~p, ~p, ~p", [Exception, 
Reason, StackTrace]),
             s1gw_metrics:ctr_inc(?S1GW_CTR_S1AP_PROXY_EXCEPTION),
             s1gw_metrics:ctr_inc(?S1GW_CTR_S1AP_PROXY_OUT_PKT_FWD_UNMODIFIED),
-            {{forward, OrigData}, S} %% XXX: proxy as-is or drop?
+            {{forward, OrigData}, S0} %% XXX: proxy as-is or drop?
     end.


diff --git a/src/sctp_proxy.erl b/src/sctp_proxy.erl
index 9bec272..d0bdf08 100644
--- a/src/sctp_proxy.erl
+++ b/src/sctp_proxy.erl
@@ -171,7 +171,7 @@
             priv := Priv} = S) ->
     ?LOG_DEBUG("MME connection (id=~p, ~p:~p) -> eNB: ~p",
                [Aid, MmeAddr, MmePort, Data]),
-    {Action, NewPriv} = s1ap_proxy:process_pdu_safe(Data, Priv),
+    {Action, NewPriv} = s1ap_proxy:process_pdu(Data, Priv),
     case Action of
         {forward, FwdData} ->
             sctp_server:send_data(EnbAid, FwdData);
@@ -230,7 +230,7 @@
             enb_aid := EnbAid,
             mme_aid := Aid,
             priv := Priv} = S) ->
-    {Action, NewPriv} = s1ap_proxy:process_pdu_safe(Data, Priv),
+    {Action, NewPriv} = s1ap_proxy:process_pdu(Data, Priv),
     case Action of
         {forward, FwdData} ->
             ok = sctp_client:send_data({Sock, Aid}, FwdData);

--
To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/38681?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: erlang/osmo-s1gw
Gerrit-Branch: master
Gerrit-Change-Id: I91092625ae577d17a1f96db79804c813b878abfc
Gerrit-Change-Number: 38681
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <[email protected]>

Reply via email to