The "from" return value of syscall.Recvfrom on a raw socket should not be
SockaddrUnix
What steps reproduce the problem?
sock, _ = syscall.Socket(syscall.AF_INET, syscall.SOCK_PACKET,
int(htons(syscall.ETH_P_ARP)))
_, from, err := syscall.Recvfrom(sock, buf, 0)
The type of from is SockaddrUnix so that the "from" returned can not used to
syscall.Sendto
The text was updated successfully, but these errors were encountered:
Your code doesn't compile, there's no htons/ntohs-like stuff in Go standard library.
Also your code looks wrong. The obsoleted Linux's AF_INET/SOCK_PACKET access interface
requires struct sockaddr in C, syscall.RawSockaddr in Go. But syscall.Bind requires a
struct that implements syscall.Sockaddr interface for its argument. So, trying to make
AF_INET/SOCK_PACKET socket work in Go is waste of time. Instead, you can use address
family AF_PACKET socket (see attached for the detail), or LSF, PF_RING, other.
by xiezhenye:
The text was updated successfully, but these errors were encountered: