aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/src/base/diameter_session.erl
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2012-10-05 11:13:11 +0200
committerAnders Svensson <[email protected]>2012-11-05 11:53:44 +0100
commitbc87eb33f3878051b1d757710b4aa58136169c3a (patch)
tree43c07cb563bbe2921902cfa3305dbf665fe9c943 /lib/diameter/src/base/diameter_session.erl
parent2ba65b0d81b6a047bed3babf5371e500c1a72541 (diff)
downloadotp-bc87eb33f3878051b1d757710b4aa58136169c3a.tar.gz
otp-bc87eb33f3878051b1d757710b4aa58136169c3a.tar.bz2
otp-bc87eb33f3878051b1d757710b4aa58136169c3a.zip
Implement sequence masks
Code should be loaded in this order: diameter_session (sequence/1) diameter_peer_fsm (calls to sequence/1) diameter_service (sequence config, mask in receive_message/3) diameter_watchdog (mask in peer start and receive_message/3) diameter_config (accept sequence config) Order of diameter and diameter_peer doesn't matter.
Diffstat (limited to 'lib/diameter/src/base/diameter_session.erl')
-rw-r--r--lib/diameter/src/base/diameter_session.erl14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/diameter/src/base/diameter_session.erl b/lib/diameter/src/base/diameter_session.erl
index 4c468f207c..3b236f109a 100644
--- a/lib/diameter/src/base/diameter_session.erl
+++ b/lib/diameter/src/base/diameter_session.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2010-2011. All Rights Reserved.
+%% Copyright Ericsson AB 2010-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -20,6 +20,7 @@
-module(diameter_session).
-export([sequence/0,
+ sequence/1,
session_id/1,
origin_state_id/0]).
@@ -30,7 +31,7 @@
-define(INT32, 16#FFFFFFFF).
%% ---------------------------------------------------------------------------
-%% # sequence/0
+%% # sequence/0-1
%%
%% Output: 32-bit
%% ---------------------------------------------------------------------------
@@ -77,6 +78,15 @@ sequence() ->
Instr = {_Pos = 2, _Incr = 1, _Threshold = ?INT32, _SetVal = 0},
ets:update_counter(diameter_sequence, sequence, Instr).
+-spec sequence(diameter:sequence())
+ -> diameter:'Unsigned32'().
+
+sequence({_,32}) ->
+ sequence();
+
+sequence({H,N}) ->
+ (H bsl N) bor (sequence() band (1 bsl N - 1)).
+
%% ---------------------------------------------------------------------------
%% # origin_state_id/0
%% ---------------------------------------------------------------------------