Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syscall: AF_INET/SOCK_PACKET interface doesn't work on Linux #7653

Closed
gopherbot opened this issue Mar 27, 2014 · 4 comments
Closed

syscall: AF_INET/SOCK_PACKET interface doesn't work on Linux #7653

gopherbot opened this issue Mar 27, 2014 · 4 comments

Comments

@gopherbot
Copy link

@gopherbot gopherbot commented Mar 27, 2014

by xiezhenye:

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
@gopherbot
Copy link
Author

@gopherbot gopherbot commented Mar 27, 2014

Comment 1 by xiezhenye:

use SockaddrUnix to syscall.Sendto caused the arg passed to sendto syscall is
AF_FILE,and got a return -1 EINVAL (Invalid argument)
@gopherbot
Copy link
Author

@gopherbot gopherbot commented Mar 27, 2014

Comment 2 by xiezhenye:

use SockaddrUnix to syscall.Sendto caused the arg passed to sendto syscall is
AF_FILE,and got a return -1 EINVAL (Invalid argument)
@mikioh
Copy link
Contributor

@mikioh mikioh commented Mar 28, 2014

Comment 3:

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.

Attachments:

  1. afpacket.go (885 bytes)
@gopherbot
Copy link
Author

@gopherbot gopherbot commented Mar 28, 2014

Comment 4 by xiezhenye:

Thank you. that solves my problem.
@gopherbot gopherbot added the invalid label Mar 28, 2014
@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.