diff options
author | Chris Koch <chrisko@google.com> | 2020-09-16 00:27:19 -0700 |
---|---|---|
committer | Chris K <c@chrisko.ch> | 2020-09-16 08:00:50 -0700 |
commit | a0be48d916fffb667bbc621f178d5f8e0a753633 (patch) | |
tree | 02bdda727d79a0e2f06f8e3206820e1106923f6a /dhcpv6/server6/server.go | |
parent | 1301300a8d9b25942cf9c3c4f9f77cb8906d4c49 (diff) |
docs: fix package comments
Signed-off-by: Chris Koch <chrisko@google.com>
Diffstat (limited to 'dhcpv6/server6/server.go')
-rw-r--r-- | dhcpv6/server6/server.go | 105 |
1 files changed, 52 insertions, 53 deletions
diff --git a/dhcpv6/server6/server.go b/dhcpv6/server6/server.go index 058b0af..ca1aa96 100644 --- a/dhcpv6/server6/server.go +++ b/dhcpv6/server6/server.go @@ -1,58 +1,57 @@ +// Package server6 is a basic, extensible DHCPv6 server. +// +// To use the DHCPv6 server code you have to call NewServer with three arguments: +// - an interface to listen on, +// - an address to listen on, and +// - a handler function, that will be called every time a valid DHCPv6 packet is +// received. +// +// The address to listen on is used to know IP address, port and optionally the +// scope to create and UDP socket to listen on for DHCPv6 traffic. +// +// The handler is a function that takes as input a packet connection, that can be +// used to reply to the client; a peer address, that identifies the client sending +// the request, and the DHCPv6 packet itself. Just implement your custom logic in +// the handler. +// +// Optionally, NewServer can receive options that will modify the server object. +// Some options already exist, for example WithConn. If this option is passed with +// a valid connection, the listening address argument is ignored. +// +// Example program: +// +// package main +// +// import ( +// "log" +// "net" +// +// "github.com/insomniacslk/dhcp/dhcpv6" +// "github.com/insomniacslk/dhcp/dhcpv6/server6" +// ) +// +// func handler(conn net.PacketConn, peer net.Addr, m dhcpv6.DHCPv6) { +// // this function will just print the received DHCPv6 message, without replying +// log.Print(m.Summary()) +// } +// +// func main() { +// laddr := net.UDPAddr{ +// IP: net.ParseIP("::1"), +// Port: 547, +// } +// server, err := server6.NewServer("eth0", &laddr, handler) +// if err != nil { +// log.Fatal(err) +// } +// +// // This never returns. If you want to do other stuff, dump it into a +// // goroutine. +// server.Serve() +// } +// package server6 -/* - To use the DHCPv6 server code you have to call NewServer with two arguments: - - an address to listen on, and - - a handler function, that will be called every time a valid DHCPv6 packet is - received. - - The address to listen on is used to know IP address, port and optionally the - scope to create and UDP socket to listen on for DHCPv6 traffic. - - The handler is a function that takes as input a packet connection, that can be - used to reply to the client; a peer address, that identifies the client sending - the request, and the DHCPv6 packet itself. Just implement your custom logic in - the handler. - - Optionally, NewServer can receive options that will modify the server object. - Some options already exist, for example WithConn. If this option is passed with - a valid connection, the listening address argument is ignored. - - Example program: - - -package main - -import ( - "log" - "net" - - "github.com/insomniacslk/dhcp/dhcpv6" - "github.com/insomniacslk/dhcp/dhcpv6/server6" -) - -func handler(conn net.PacketConn, peer net.Addr, m dhcpv6.DHCPv6) { - // this function will just print the received DHCPv6 message, without replying - log.Print(m.Summary()) -} - -func main() { - laddr := net.UDPAddr{ - IP: net.ParseIP("::1"), - Port: 547, - } - server, err := server6.NewServer(&laddr, handler) - if err != nil { - log.Fatal(err) - } - - // This never returns. If you want to do other stuff, dump it into a - // goroutine. - server.Serve() -} - -*/ - import ( "log" "net" |