Join GitHub today
GitHub is where the world builds software
syscall: AF_INET/SOCK_PACKET interface doesn't work on Linux #7653
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
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.
Status changed to Invalid.