dhcp: Can't build/run on macOS due to client.go code

go build
# github.com/insomniacslk/dhcp/dhcpv4
../../insomniacslk/dhcp/dhcpv4/client.go:125:25: undefined: unix.AF_PACKET
../../insomniacslk/dhcp/dhcpv4/client.go:125:68: undefined: unix.ETH_P_IP
../../insomniacslk/dhcp/dhcpv4/client.go:133:12: undefined: unix.SockaddrLinklayer

There are no constants in package golang.org/x/sys/unix for darwin_amd64

grep AF_PACKET *
grep: linux: Is a directory
syscall_linux.go:// SockaddrLinklayer implements the Sockaddr interface for AF_PACKET type sockets.
syscall_linux.go:	sa.raw.Family = AF_PACKET
syscall_linux.go:	case AF_PACKET:
zerrors_linux_386.go:	AF_PACKET                            = 0x11
zerrors_linux_amd64.go:	AF_PACKET                            = 0x11
zerrors_linux_arm.go:	AF_PACKET                            = 0x11
zerrors_linux_arm64.go:	AF_PACKET                            = 0x11
zerrors_linux_mips.go:	AF_PACKET                            = 0x11
zerrors_linux_mips64.go:	AF_PACKET                            = 0x11
zerrors_linux_mips64le.go:	AF_PACKET                            = 0x11
zerrors_linux_mipsle.go:	AF_PACKET                            = 0x11
zerrors_linux_ppc64.go:	AF_PACKET                            = 0x11
zerrors_linux_ppc64le.go:	AF_PACKET                            = 0x11
zerrors_linux_riscv64.go:	AF_PACKET                            = 0x11
zerrors_linux_s390x.go:	AF_PACKET                            = 0x11
zerrors_linux_sparc64.go:	AF_PACKET                        = 0x11
zerrors_solaris_amd64.go:	AF_PACKET                     = 0x20

This is a commit probably breaks compilation:
https://github.com/insomniacslk/dhcp/commit/4eedccfd12105dbcde88298e87bbbcf41aa7c1df

In BSD system AF_PACKET should be replaced by AF_LINK

BTW, why not to move client for separate package? I just removed file client.go from repo in order to compile server code.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 17 (8 by maintainers)

Most upvoted comments

BTW, why not to move client for separate package? I just removed file client.go from repo in order to compile server code.

This is actually something I’ve considered in the past, splitting client and server from protocol parsing. The library structure wold become a bit more fragmented but I can try and see if it doesn’t look too bad.