VintageNet.OSEventDispatcher.UdhcpcHandler behaviour (vintage_net v0.11.3) View Source

A behaviour for handling notifications from udhcpc

Example

defmodule MyApp.UdhcpcHandler do
  @behaviour VintageNet.OSEventDispatcher.UdhcpcHandler

  @impl VintageNet.OSEventDispatcher.UdhcpcHandler
  def deconfig(ifname, data) do
    ...
  end
end

To have VintageNet invoke it, add the following to your config.exs:

config :vintage_net, udhcpc_handler: MyApp.UdhcpcHandler

Link to this section Summary

Types

Update data is the unmodified environment variable strings from udhcpc

Callbacks

Handle an assignment from the DHCP server

Deconfigure the specified interface

Handle a failure to get a lease

Handle a DHCP NAK

Handle the renewal of a DHCP lease

Link to this section Types

Specs

update_data() :: %{required(String.t()) => String.t()}

Update data is the unmodified environment variable strings from udhcpc

The following is an example of update data, but it really depends on what udhcpc wants to send:

%{
  "broadcast" => "192.168.7.255",
  "dns" => "192.168.7.1",
  "domain" => "hunleth.lan",
  "hostname" => "nerves-9780",
  "interface" => "eth0",
  "ip" => "192.168.7.190",
  "lease" => "86400",
  "mask" => "24",
  "opt53" => "05",
  "opt58" => "0000a8c0",
  "opt59" => "00012750",
  "router" => "192.168.7.1",
  "serverid" => "192.168.7.1",
  "siaddr" => "192.168.7.1",
  "subnet" => "255.255.255.0"
}

Link to this section Callbacks

Link to this callback

bound(ifname, update_data)

View Source

Specs

bound(VintageNet.ifname(), update_data()) :: :ok

Handle an assignment from the DHCP server

Link to this callback

deconfig(ifname, update_data)

View Source

Specs

deconfig(VintageNet.ifname(), update_data()) :: :ok

Deconfigure the specified interface

Link to this callback

leasefail(ifname, update_data)

View Source

Specs

leasefail(VintageNet.ifname(), update_data()) :: :ok

Handle a failure to get a lease

Link to this callback

nak(ifname, update_data)

View Source

Specs

nak(VintageNet.ifname(), update_data()) :: :ok

Handle a DHCP NAK

Link to this callback

renew(ifname, update_data)

View Source

Specs

renew(VintageNet.ifname(), update_data()) :: :ok

Handle the renewal of a DHCP lease