summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorPablo Mazzini <pmazzini@gmail.com>2023-03-27 14:43:31 +0100
committerGitHub <noreply@github.com>2023-03-27 14:43:31 +0100
commit26f85b3754c8b6bcc087d38e52012461f7f133e2 (patch)
tree3cbb6f46621fd63d91a2b1f60456be16598665d6
parent94cdde992d5661bda1c88769d0a4319f3037c81e (diff)
parentb11966a48d46d5e73271cfe3ab0a5cd5cf21d1a8 (diff)
Merge branch 'master' into renew-from-ack
-rw-r--r--dhcpv4/nclient4/client.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/dhcpv4/nclient4/client.go b/dhcpv4/nclient4/client.go
index d40e1a9..b4e4b56 100644
--- a/dhcpv4/nclient4/client.go
+++ b/dhcpv4/nclient4/client.go
@@ -478,6 +478,25 @@ func (c *Client) Request(ctx context.Context, modifiers ...dhcpv4.Modifier) (lea
return c.RequestFromOffer(ctx, offer, modifiers...)
}
+// Inform sends an INFORM request using the given local IP.
+// Returns the ACK response from the server on success.
+func (c *Client) Inform(ctx context.Context, localIP net.IP, modifiers ...dhcpv4.Modifier) (*dhcpv4.DHCPv4, error) {
+ request, err := dhcpv4.NewInform(c.ifaceHWAddr, localIP, modifiers...)
+ if err != nil {
+ return nil, err
+ }
+
+ // DHCP clients must not fill in the server identifier in an INFORM request as per RFC 2131 Section 4.4.1 Table 5,
+ // however, they may still unicast the request to the target server if the address is known (c.serverAddr), as per
+ // Section 4.4.3. The server must then respond with an ACK, as per Section 4.3.5.
+ response, err := c.SendAndRead(ctx, c.serverAddr, request, IsMessageType(dhcpv4.MessageTypeAck))
+ if err != nil {
+ return nil, fmt.Errorf("got an error while processing the request: %w", err)
+ }
+
+ return response, nil
+}
+
// ErrNak is returned if a DHCP server rejected our Request.
type ErrNak struct {
Offer *dhcpv4.DHCPv4