diff options
author | Sean Karlage <skarlage@fb.com> | 2018-10-07 00:13:46 -0700 |
---|---|---|
committer | insomniac <insomniacslk@users.noreply.github.com> | 2018-10-07 06:50:11 -0700 |
commit | 4eedccfd12105dbcde88298e87bbbcf41aa7c1df (patch) | |
tree | a6e822b763e4a16f3947b6856683b27c0697e912 /dhcpv4/bsdp/vendor_class_identifier_darwin.go | |
parent | c3fc64094fbed445c0d131b77fcc13e56da991e7 (diff) |
DHCPv4: syscall -> x/sys/unix
Fixes #156
Build a simple client like so:
```
package main
import (
"fmt"
"time"
"github.com/insomniacslk/dhcp/dhcpv4"
)
func main() {
client := dhcpv4.Client{ReadTimeout: 5 * time.Second, WriteTimeout: 5 * time.Second}
conversation, err := client.Exchange("en0", nil)
if err != nil {
fmt.Println(err)
}
for _, m := range conversation {
fmt.Println(m.Summary())
}
}
```
and run:
```
$ sudo ./main
Password:
DHCPv4
opcode=BootRequest
hwtype=Ethernet
hwaddrlen=6
hopcount=0
transactionid=0xabfad715
numseconds=0
flags=Broadcast (0x8000)
clientipaddr=0.0.0.0
youripaddr=0.0.0.0
serveripaddr=0.0.0.0
gatewayipaddr=0.0.0.0
clienthwaddr=8c:85:90:20:2e:33
serverhostname=
bootfilename=
options=
DHCP Message Type -> DISCOVER
Parameter Request List -> [Subnet Mask, Router, Domain Name, Domain Name Server]
End -> []
DHCPv4
opcode=BootReply
hwtype=Ethernet
hwaddrlen=6
hopcount=0
transactionid=0xabfad715
numseconds=0
flags=Broadcast (0x8000)
clientipaddr=0.0.0.0
youripaddr=192.168.0.105
serveripaddr=0.0.0.0
gatewayipaddr=0.0.0.0
clienthwaddr=8c:85:90:20:2e:33
serverhostname=
bootfilename=
options=
DHCP Message Type -> OFFER
Server Identifier -> 192.168.0.1
IP Addresses Lease Time -> 5648
Subnet Mask -> ffffff00
Routers -> 192.168.0.1
Domain Name Servers -> 8.8.8.8, 8.8.4.4
End -> []
DHCPv4
opcode=BootRequest
hwtype=Ethernet
hwaddrlen=6
hopcount=0
transactionid=0xabfad715
numseconds=0
flags=Broadcast (0x8000)
clientipaddr=0.0.0.0
youripaddr=0.0.0.0
serveripaddr=192.168.0.1
gatewayipaddr=0.0.0.0
clienthwaddr=8c:85:90:20:2e:33
serverhostname=
bootfilename=
options=
DHCP Message Type -> REQUEST
Requested IP Address -> 192.168.0.105
Server Identifier -> 192.168.0.1
End -> []
DHCPv4
opcode=BootReply
hwtype=Ethernet
hwaddrlen=6
hopcount=0
transactionid=0xabfad715
numseconds=0
flags=Broadcast (0x8000)
clientipaddr=0.0.0.0
youripaddr=192.168.0.105
serveripaddr=0.0.0.0
gatewayipaddr=0.0.0.0
clienthwaddr=8c:85:90:20:2e:33
serverhostname=
bootfilename=
options=
DHCP Message Type -> ACK
Server Identifier -> 192.168.0.1
IP Addresses Lease Time -> 7200
Subnet Mask -> ffffff00
Routers -> 192.168.0.1
Domain Name Servers -> 8.8.8.8, 8.8.4.4
End -> []
```
Diffstat (limited to 'dhcpv4/bsdp/vendor_class_identifier_darwin.go')
-rw-r--r-- | dhcpv4/bsdp/vendor_class_identifier_darwin.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/dhcpv4/bsdp/vendor_class_identifier_darwin.go b/dhcpv4/bsdp/vendor_class_identifier_darwin.go index d1b4c2b..46ef656 100644 --- a/dhcpv4/bsdp/vendor_class_identifier_darwin.go +++ b/dhcpv4/bsdp/vendor_class_identifier_darwin.go @@ -2,14 +2,15 @@ package bsdp import ( "fmt" - "syscall" + + "golang.org/x/sys/unix" ) // MakeVendorClassIdentifier calls the sysctl syscall on macOS to get the // platform model. func MakeVendorClassIdentifier() (string, error) { // Fetch hardware model for class ID. - hwModel, err := syscall.Sysctl("hw.model") + hwModel, err := unix.Sysctl("hw.model") if err != nil { return "", err } |