diff options
author | Anders Svensson <[email protected]> | 2017-04-24 18:02:49 +0200 |
---|---|---|
committer | Anders Svensson <[email protected]> | 2017-06-13 13:50:06 +0200 |
commit | 80b0a39add59ee0dda0927ffabfef46677b9e65a (patch) | |
tree | 694bd42f093d92f75b1f5b5a0f302a87b8235e2a /lib/diameter | |
parent | f489c0d5f2b5fbb2e40bfacd9981d5515d375e98 (diff) | |
download | otp-80b0a39add59ee0dda0927ffabfef46677b9e65a.tar.gz otp-80b0a39add59ee0dda0927ffabfef46677b9e65a.tar.bz2 otp-80b0a39add59ee0dda0927ffabfef46677b9e65a.zip |
Don't compute URI defaults unnecessarily
Diffstat (limited to 'lib/diameter')
-rw-r--r-- | lib/diameter/src/base/diameter_types.erl | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/lib/diameter/src/base/diameter_types.erl b/lib/diameter/src/base/diameter_types.erl index 17164ec89a..86b674dd48 100644 --- a/lib/diameter/src/base/diameter_types.erl +++ b/lib/diameter/src/base/diameter_types.erl @@ -523,28 +523,30 @@ scan_uri(Bin, Opts) -> RE, [{capture, [1,2,4,6,8], binary}]), Type = to_atom(A), - {PN0, T0} = defaults(Opts, Type), - PortNr = to_int(PN, PN0), - 0 = PortNr bsr 16, %% assert #diameter_uri{type = Type, fqdn = 'OctetString'(decode, DN, Opts), - port = PortNr, - transport = to_atom(T, T0), + port = portnr(PN, Type, Opts), + transport = transport(T, Opts), protocol = to_atom(P, diameter)}. %% Choose defaults based on the RFC, since 6733 has changed them. -defaults(#{rfc := 3588}, _) -> - {3868, sctp}; -defaults(#{rfc := 6733}, aaa) -> - {3868, tcp}; -defaults(#{rfc := 6733}, aaas) -> - {5658, tcp}. - -to_int(<<>>, N) -> - N; -to_int(B, _) -> + +portnr(<<>>, aaa, #{rfc := 6733}) -> + 3868; +portnr(<<>>, aaas, #{rfc := 6733}) -> + 5868; +portnr(<<>>, _, #{rfc := 3588}) -> + 3868; +portnr(B, _, _) -> binary_to_integer(B). +transport(<<>>, #{rfc := 6733}) -> + tcp; +transport(<<>>, #{rfc := 3588}) -> + sctp; +transport(B, _) -> + to_atom(B). + to_atom(<<>>, A) -> A; to_atom(B, _) -> |