secure_channel: Use counter module for transaction id

This commit is contained in:
Eishun Kondoh 2018-12-12 01:25:59 +09:00
parent 97b957742f
commit 4ea72c73b4
11 changed files with 74 additions and 45 deletions

View file

@ -10,13 +10,13 @@ defmodule Tres.ExampleHandler do
conn_ref: nil
end
def start_link([datapath, args]) do
def start_link(datapath, args) do
GenServer.start_link(__MODULE__, [datapath, args])
end
def init([{datapath_id, aux_id}, _args]) do
info(
"[#{__MODULE__}] Switch Ready: " <>
"Switch Ready: " <>
"datapath_id: #{datapath_id} " <> "aux_id: #{aux_id} " <> "on #{inspect(self())}"
)
@ -36,14 +36,19 @@ defmodule Tres.ExampleHandler do
{:noreply, state}
end
def handle_info({:switch_disconnected, _reason}, state) do
:ok = warn("Switch disconnected")
{:stop, :normal, state}
end
def handle_info({:switch_hang, _datapath_id}, state) do
:ok = warn("[#{__MODULE__}] Switch possible hang: datapath_id: #{state.datapath_id}")
:ok = warn("Switch possible hang: datapath_id: #{state.datapath_id}")
{:noreply, state}
end
# `Catch all` function is required.
def handle_info(info, state) do
:ok = warn("[#{__MODULE__}] unhandled message #{inspect(info)}: #{state.datapath_id}")
:ok = warn("unhandled message #{inspect(info)}: #{state.datapath_id}")
{:noreply, state}
end
@ -61,7 +66,7 @@ defmodule Tres.ExampleHandler do
defp handle_desc_stats_reply(desc, datapath_id) do
info(
"[#{__MODULE__}] Switch Desc: " <>
"Switch Desc: " <>
"mfr = #{desc.mfr_desc} " <>
"hw = #{desc.hw_desc} " <> "sw = #{desc.sw_desc} " <> "for #{datapath_id}"
)
@ -70,7 +75,7 @@ defmodule Tres.ExampleHandler do
defp handle_port_desc_stats_reply(port_desc, datapath_id) do
for port <- port_desc.ports do
info(
"[#{__MODULE__}] Switch has port: " <>
"Switch has port: " <>
"number = #{port.number} " <>
"hw_addr = #{port.hw_addr} " <>
"name = #{port.name} " <>