dhcp

package
v0.0.0-...-6b04af2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2017 License: Apache-2.0 Imports: 13 Imported by: 0

README

DHCP Server IOModule

This module implements a basic version of a DHCP server in user space.

API

  • ConfigureParameters(...) Configures the parameters required to the operation of the DHCP server. The received arguments are the same used in the YAML configuration file.

How to use

Using iovisor-ovn daemon in standalone mode, the user can deploy and configure a single or a chain of IOModules. The entire setup can be deployed starting from a YAML configuration file.

$GOPATH/bin/iovisorovnd -file <configuration.yaml>

Some examples are available in /examples folder:

YAML Configuration Format

The following is an example of the configuration of a dhcp server:

[...]
  - name: mydhcp
    type: dhcp
    config:
      netmask: 255.255.255.0
      addr_low: 192.168.1.100
      addr_high: 192.168.1.150
      dns: 8.8.8.8
      router: 192.168.1.1
      lease_time: 3600
      server_ip: 192.168.1.250
      server_mac: "b6:87:f8:5a:40:23"
[...]
  • netmask: mask of the network segment where the DHCP server is.
  • addr_low: first ip address that the server can assign.
  • addr_high: last ip address that the server can assign.
  • dns: DNS ip address that the server offers to the clients.
  • router: default gateway assigned to clients.
  • lease_time: default time that an address is leased to a client.
  • server_ip: IP address of the DHCP server.
  • mac_ip: MAC address of the DHCP server.

Limitations

  • This module only can be connected to a single port
  • Packets are always sent to the L2 broadcast address, this is supported by some client implementations but is not full protocol compliant.

Documentation

Overview

Copyright 2017 Politecnico di Torino

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

This file is a slight modified version of https://github.com/krolaw/dhcp4/blob/master/example_test.go

Index

Constants

This section is empty.

Variables

View Source
var DhcpServer = `` /* 3067-byte string literal not displayed */

Functions

This section is empty.

Types

type DHCPHandler

type DHCPHandler struct {
	// contains filtered or unexported fields
}

func (*DHCPHandler) ServeDHCP

func (h *DHCPHandler) ServeDHCP(p dhcp.Packet, msgType dhcp.MessageType, options dhcp.Options) (d dhcp.Packet)

type DhcpModule

type DhcpModule struct {
	ModuleId string
	// contains filtered or unexported fields
}

func Create

func Create(hc *hover.Client) *DhcpModule

func (*DhcpModule) AttachExternalInterface

func (m *DhcpModule) AttachExternalInterface(ifaceName string) (err error)

func (*DhcpModule) AttachToIoModule

func (m *DhcpModule) AttachToIoModule(ifaceId int, ifaceName string) (err error)

func (*DhcpModule) Configure

func (m *DhcpModule) Configure(conf interface{}) (err error)

func (*DhcpModule) ConfigureParameters

func (m *DhcpModule) ConfigureParameters(netmask net.IPMask,
	addr_low net.IP,
	addr_high net.IP,
	dns net.IP,
	router net.IP,
	leaseTime uint32,
	serverMAC net.HardwareAddr,
	serverIP net.IP) (err error)

TODO: this function should be split on smaller pieces.

func (*DhcpModule) Deploy

func (m *DhcpModule) Deploy() (err error)

func (*DhcpModule) Destroy

func (m *DhcpModule) Destroy() (err error)

func (*DhcpModule) DetachExternalInterface

func (m *DhcpModule) DetachExternalInterface(ifaceName string) (err error)

func (*DhcpModule) DetachFromIoModule

func (m *DhcpModule) DetachFromIoModule(ifaceName string) (err error)

func (*DhcpModule) GetModuleId

func (m *DhcpModule) GetModuleId() string

func (*DhcpModule) ProcessPacket

func (m *DhcpModule) ProcessPacket(p *hover.PacketIn) (err error)

func (*DhcpModule) ReadFrom

func (m *DhcpModule) ReadFrom(b []byte) (n int, addr net.Addr, err error)

This function is called from the dhcp library, it waits on a channel until the ProcessPacket function injects new arrived packets there.

func (*DhcpModule) WriteTo

func (m *DhcpModule) WriteTo(b []byte, addr net.Addr) (n int, err error)

WriteTo in this case means send the packet to the dataplane, it requires assemble the whole packet layers

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL