Skip to content
This repository has been archived by the owner on Dec 3, 2019. It is now read-only.

Latest commit

 

History

History
50 lines (41 loc) · 1.24 KB

README.md

File metadata and controls

50 lines (41 loc) · 1.24 KB

CircleCI Hex version

DHCPServer

Installation

The package can be installed by adding dhcp_server to your list of dependencies in mix.exs:

def deps do
  [{:dhcp_server, "~> 0.7"}]
end

Usage

Start and Stop a one off server

iex(1)> {:ok, dhcp_server} = DHCPServer.start_link("usb0", [])
{:ok, dhcp_server}
# Plug device in or something?
# Get ip address?
# Do some local work?
# Profit?
iex(2)> DHCPServer.stop(dhcp_server)
:ok

As part of an application startup

def start(_type, _args) do
  dhcp_options = [
    gateway: "192.168.254.1",
    netmask: "255.255.255.0",
    range: {"192.168.254.10", "192.168.254.99"},
    domain_servers: ["192.168.254.1"]
  ]

  children = [
    {DHCPServer, ["eth0", dhcp_options]}
  ]

  opts = [strategy: :one_for_one, name: MyApp.Supervisor]
  Supervisor.start_link(children, opts)
end

License

This project is originally located here and is licensed under GPLv2. See COPYING for more details.