fixeria submitted this change.
pfcp_peer: wrap seq_nr at 24-bit boundary
PFCP sequence numbers are 24-bit (3GPP TS 29.244 section 7.2.2.2), but
the counter was incremented without wrapping, eventually exceeding the
type spec after 16,777,215 requests. Introduce PFCP_SEQ_NR_MAX and use
it in the type spec and in the increment expression.
Change-Id: Ie269894add9a82c36698320379df3aca3f7ffea8
---
M src/pfcp_peer.erl
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/pfcp_peer.erl b/src/pfcp_peer.erl
index f6e9c7d..a4cc2d5 100644
--- a/src/pfcp_peer.erl
+++ b/src/pfcp_peer.erl
@@ -57,13 +57,14 @@
%% 3GPP TS 29.244, section 4.2 "UDP Header and Port Numbers"
-define(PFCP_PORT, 8805).
+-define(PFCP_SEQ_NR_MAX, 16#ffffff).
-define(PFCP_SEID_MAX, 16#ffffffffffffffff).
-define(PFCP_HEARTBEAT_REQ_TIMEOUT, 2000).
-type pfcp_session_rsp() :: ok | {error, term()}.
-type pfcp_msg_type() :: atom().
--type pfcp_seq_nr() :: 0..16#ffffff.
+-type pfcp_seq_nr() :: 0..?PFCP_SEQ_NR_MAX.
-type pfcp_seid() :: 0..?PFCP_SEID_MAX.
-type pfcp_f_seid() :: #f_seid{}.
-type pfcp_ies() :: [term()] | map() | binary().
@@ -462,7 +463,8 @@
Data = pfcp_packet:encode(PDU),
case send_data(Data, S) of
ok ->
- {ok, S#peer_state{seq_nr = SeqNr + 1}};
+ NextSeqNr = (SeqNr + 1) band ?PFCP_SEQ_NR_MAX,
+ {ok, S#peer_state{seq_nr = NextSeqNr}};
{error, Error} ->
{{error, Error}, S}
end.
To view, visit change 42291. To unsubscribe, or for help writing mail filters, visit settings.