| 1 | package dhcp6serverscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6/dhcp6server`/ |
| 2 | |
| 3 | import ( |
| 4 | "github.com/mdlayher/dhcp6scip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6`/" |
| 5 | ) |
| 6 | |
| 7 | // Handler provides an interface which allows structs to act as DHCPv6 server |
| 8 | // handlers. ServeDHCP implementations receive a copy of the incoming DHCP |
| 9 | // request via the Request parameter, and allow outgoing communication via |
| 10 | // the ResponseSender. |
| 11 | // |
| 12 | // ServeDHCP implementations can choose to write a response packet using the |
| 13 | // ResponseSender interface, or choose to not write anything at all. If no packet |
| 14 | // is sent back to the client, it may choose to back off and retry, or attempt |
| 15 | // to pursue communication with other DHCP servers. |
| 16 | type Handlerscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6/dhcp6server`/Handler# interface { |
| 17 | ServeDHCPscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6/dhcp6server`/Handler#ServeDHCP.(ResponseSenderscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6/dhcp6server`/ResponseSender#, *Requestscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6/dhcp6server`/Request#) |
| 18 | } |
| 19 | |
| 20 | // HandlerFunc is an adapter type which allows the use of normal functions as |
| 21 | // DHCP handlers. If f is a function with the appropriate signature, |
| 22 | // HandlerFunc(f) is a Handler struct that calls f. |
| 23 | type HandlerFuncscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6/dhcp6server`/HandlerFunc# func(ResponseSenderscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6/dhcp6server`/ResponseSender#, *Requestscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6/dhcp6server`/Request#) |
| 24 | |
| 25 | // ServeDHCP calls f(w, r), allowing regular functions to implement Handler. |
| 26 | func (f HandlerFuncscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6/dhcp6server`/HandlerFunc#) ServeDHCPscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6/dhcp6server`/HandlerFunc#ServeDHCP().(w ResponseSenderscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6/dhcp6server`/ResponseSender#, r *Requestscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6/dhcp6server`/Request#) { |
| 27 | f(w, r) |
| 28 | } |
| 29 | |
| 30 | // ResponseSender provides an interface which allows a DHCP handler to construct |
| 31 | // and send a DHCP response packet. In addition, the server automatically handles |
| 32 | // copying certain options from a client Request to a ResponseSender's Options, |
| 33 | // including: |
| 34 | // - Client ID (OptionClientID) |
| 35 | // - Server ID (OptionServerID) |
| 36 | // |
| 37 | // ResponseSender implementations should use the same transaction ID sent in a |
| 38 | // client Request. |
| 39 | type ResponseSenderscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6/dhcp6server`/ResponseSender# interface { |
| 40 | // Options returns the Options map that will be sent to a client |
| 41 | // after a call to Send. |
| 42 | Optionsscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6/dhcp6server`/ResponseSender#Options.() dhcp6scip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6`/.Optionsscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6`/Options# |
| 43 | |
| 44 | // Send generates a DHCP response packet using the input message type |
| 45 | // and any options set by Options. Send returns the number of bytes |
| 46 | // sent and any errors which occurred. |
| 47 | Sendscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6/dhcp6server`/ResponseSender#Send.(dhcp6scip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6`/.MessageTypescip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6`/MessageType#) (int, error) |
| 48 | } |