-
-
Notifications
You must be signed in to change notification settings - Fork 194
Use jschwinger233/elibpcap to compile and inject libpcap #543
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
base: main
Are you sure you want to change the base?
Conversation
81117ec
to
c1744b2
Compare
This is because we are going to import elibpcap to compile with cgo, we can't count on the pseudo #cgo directives from elibpcap package. Signed-off-by: gray <[email protected]>
Signed-off-by: gray <[email protected]>
Signed-off-by: gray <[email protected]>
c1744b2
to
3c948a7
Compare
CGO_CFLAGS="-I/pwru/libpcap" | ||
CGO_LDFLAGS="-L/pwru/libpcap -lpcap -static" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Failed to compile locally, the path should be ./libpcap
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What command did you run locally? make release
and make
are both okay on my local ubuntu.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why this is supposed to work locally. The CI build with docker which set workdir to /pwru so there is no problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that this shouldn't be an absolute path, otherwise e.g. make pwru
will fail on hosts where /pwru/libpcap/
does not exist. We could also consider using -L$(CURDIR)/libpcap
.
If I run
The issue goes away if I apply the following diff:
@jschwinger233 One solution would be to ship the libcap in the jschwinger233/elibpcap? |
@jschwinger233 👋 Would you accept such a contribution? |
Thank you for suggestion! I believe shipping libpcap in elibpcap is the correct direction. I am learning from https://github.com/mattn/go-sqlite3 to see how to do it properly, then I'll upgrade the pr. 🙏 |
The https://github.com/jschwinger233/elibpcap has been adopted by several popular projects such as https://github.com/gojue/ecapture, let's use it to simplify the codebase.
Historically, elibpcap was derived from pwru/internal/libpcap/ following #198. The two share nearly identical code and logic, so there should be no compatibility issues in transitioning pwru to use elibpcap.
Signed-off-by: gray [email protected]