Add support NXT_RESUME (#7)

* Add support NXT_RESUME
This commit is contained in:
Eishun Kondoh 2018-08-29 00:00:53 +09:00 committed by GitHub
parent 2c4d247a2f
commit 95d2f2e87c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 735 additions and 71 deletions

View file

@ -15,22 +15,23 @@ defmodule Openflow do
end
def read(<<ver::8, type::8, len::16, xid::32, binary2::bytes>>) do
try do
body_len = len - @ofp_header_size
<<body_bin::bytes-size(body_len), rest::bytes>> = binary2
try do
body_len = len - @ofp_header_size
<<body_bin::bytes-size(body_len), rest::bytes>> = binary2
result = type
result =
type
|> Openflow.Enums.to_atom(:openflow_codec)
|> do_read(body_bin)
case result do
{:ok, struct} -> {:ok, %{struct | version: ver, xid: xid}, rest}
{:error, reason} -> {:error, reason}
end
catch
_c, _e ->
{:error, :malformed_packet}
case result do
{:ok, struct} -> {:ok, %{struct | version: ver, xid: xid}, rest}
{:error, reason} -> {:error, reason}
end
catch
_c, reason ->
{:error, {:malformed_packet, {reason, __STACKTRACE__}}}
end
end
def to_binary(messages) when is_list(messages) do