tres/secure_channel: Improved HELLO handler
This commit is contained in:
parent
45768a6625
commit
dbfadf5cf1
3 changed files with 5 additions and 4 deletions
BIN
bin/enum_gen
BIN
bin/enum_gen
Binary file not shown.
|
|
@ -23,8 +23,9 @@ defmodule Openflow.Hello do
|
||||||
def supported_version?(%Hello{elements: []}), do: false
|
def supported_version?(%Hello{elements: []}), do: false
|
||||||
|
|
||||||
def supported_version?(%Hello{elements: elements}) do
|
def supported_version?(%Hello{elements: elements}) do
|
||||||
versionbitmaps = for {:versionbitmap, versions} <- elements, do: versions
|
elements
|
||||||
Enum.any?(versionbitmaps, fn versions -> 4 in versions end)
|
|> Enum.reduce([], fn({:versionbitmap, versions}, acc) -> acc ++ versions end)
|
||||||
|
|> Enum.any?(fn(version) -> version == 4 end)
|
||||||
end
|
end
|
||||||
|
|
||||||
def read(binary), do: %Hello{elements: decode([], binary)}
|
def read(binary), do: %Hello{elements: decode([], binary)}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ defmodule Tres.SecureChannel do
|
||||||
|
|
||||||
@supported_version 4
|
@supported_version 4
|
||||||
|
|
||||||
@hello_handshake_timeout 1000
|
@hello_handshake_timeout 3000
|
||||||
@features_handshake_timeout 1000
|
@features_handshake_timeout 1000
|
||||||
@ping_timeout 5000
|
@ping_timeout 5000
|
||||||
# @transaction_timeout 5000
|
# @transaction_timeout 5000
|
||||||
|
|
@ -402,10 +402,10 @@ defmodule Tres.SecureChannel do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp handle_hello_handshake_1(hello, state_data) do
|
defp handle_hello_handshake_1(hello, state_data) do
|
||||||
maybe_cancel_timer(state_data.timer_ref)
|
|
||||||
State.set_transaction_id(state_data.xid, hello.xid)
|
State.set_transaction_id(state_data.xid, hello.xid)
|
||||||
|
|
||||||
if Openflow.Hello.supported_version?(hello) do
|
if Openflow.Hello.supported_version?(hello) do
|
||||||
|
:ok = maybe_cancel_timer(state_data.timer_ref)
|
||||||
{:next_state, :CONNECTING, %{state_data | timer_ref: nil}}
|
{:next_state, :CONNECTING, %{state_data | timer_ref: nil}}
|
||||||
else
|
else
|
||||||
close_connection(:failed_version_negotiation, state_data)
|
close_connection(:failed_version_negotiation, state_data)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue