-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package dhcp | ||
|
||
import ( | ||
"context" | ||
"go.uber.org/zap" | ||
"net" | ||
"time" | ||
) | ||
|
||
const ( | ||
dhcpDiscover = 1 | ||
bootRequest = 1 | ||
ethPAll = 0x0003 | ||
MaxUDPReceivedPacketSize = 8192 | ||
dhcpServerPort = 67 | ||
dhcpClientPort = 68 | ||
dhcpOpCodeReply = 2 | ||
bootpMinLen = 300 | ||
bytesInAddress = 4 // bytes in an ip address | ||
macBytes = 6 // bytes in a mac address | ||
udpProtocol = 17 | ||
|
||
opRequest = 1 | ||
Check failure on line 23 in dhcp/dhcp_windows.go GitHub Actions / Lint (1.21.x, windows-latest)
|
||
htypeEthernet = 1 | ||
Check failure on line 24 in dhcp/dhcp_windows.go GitHub Actions / Lint (1.21.x, windows-latest)
|
||
hlenEthernet = 6 | ||
Check failure on line 25 in dhcp/dhcp_windows.go GitHub Actions / Lint (1.21.x, windows-latest)
|
||
hops = 0 | ||
Check failure on line 26 in dhcp/dhcp_windows.go GitHub Actions / Lint (1.21.x, windows-latest)
|
||
secs = 0 | ||
Check failure on line 27 in dhcp/dhcp_windows.go GitHub Actions / Lint (1.21.x, windows-latest)
|
||
flags = 0x8000 // Broadcast flag | ||
Check failure on line 28 in dhcp/dhcp_windows.go GitHub Actions / Lint (1.21.x, windows-latest)
|
||
) | ||
|
||
// TransactionID represents a 4-byte DHCP transaction ID as defined in RFC 951, | ||
// Section 3. | ||
// | ||
// The TransactionID is used to match DHCP replies to their original request. | ||
type TransactionID [4]byte | ||
|
||
var ( | ||
magicCookie = []byte{0x63, 0x82, 0x53, 0x63} // DHCP magic cookie | ||
Check failure on line 38 in dhcp/dhcp_windows.go GitHub Actions / Lint (1.21.x, windows-latest)
|
||
DefaultReadTimeout = 3 * time.Second | ||
DefaultTimeout = 3 * time.Second | ||
) | ||
|
||
type DHCP struct { | ||
logger *zap.Logger | ||
} | ||
|
||
func New(logger *zap.Logger) *DHCP { | ||
return &DHCP{ | ||
logger: logger, | ||
} | ||
} | ||
|
||
func (c *DHCP) DiscoverRequest(_ context.Context, _ net.HardwareAddr, _ string) error { | ||
return nil | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package network | ||
|
||
import ( | ||
"context" | ||
"net" | ||
) | ||
|
||
type dhcpClient interface { | ||
DiscoverRequest(context.Context, net.HardwareAddr, string) error | ||
} | ||
|
||
type mockDHCP struct { | ||
} | ||
|
||
func (netns *mockDHCP) DiscoverRequest(context.Context, net.HardwareAddr, string) error { | ||
return nil | ||
} |