-
Notifications
You must be signed in to change notification settings - Fork 260
Fix getprotobyname missing on Android preventing use #470
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: develop
Are you sure you want to change the base?
Changes from 1 commit
9d07f0c
85ee18b
be8cc59
0d09161
c2f67d0
cb15cc5
d335b8c
4cd0304
d48e910
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,20 +59,23 @@ static int outgoing_src_addr_set_ipv4 = 0; | |
|
|
||
| int open_ping_socket_ipv4(int *socktype) | ||
| { | ||
| struct protoent* proto; | ||
| int s; | ||
| int s = -1; | ||
| int p_proto = IPPROTO_ICMP; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't we just use this on all platforms? It seems to me that maybe we don't need getprotobyname at all.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That was my thinking too. @gsnw-sebast suggested there may be situations where If we really want to check whether ICMP is supported on a given platform maybe we could just check for the define?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I looked into it, and you're actually right. The value could be set statically without the check via It would even keep fping running if an incorrect protocol file were stored on the system [1] https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed |
||
|
|
||
| /* confirm that ICMP is available on this machine */ | ||
| if ((proto = getprotobyname("icmp")) == NULL) | ||
| crash_and_burn("icmp: unknown protocol"); | ||
| #if defined(USE_GETPROTOBYNAME) && !(defined(ANDROID) || defined(__ANDROID__)) | ||
| /* confirm that ICMP is available on this machine */ | ||
| if (getprotobyname("icmp") == NULL) { | ||
| crash_and_burn("icmp: unknown protocol"); | ||
| } | ||
|
gsnw-sebast marked this conversation as resolved.
Outdated
|
||
| #endif | ||
|
|
||
| /* create raw socket for ICMP calls (ping) */ | ||
| *socktype = SOCK_RAW; | ||
| s = socket(AF_INET, *socktype, proto->p_proto); | ||
| s = socket(AF_INET, *socktype, p_proto); | ||
| if (s < 0) { | ||
| /* try non-privileged icmp (works on Mac OSX without privileges, for example) */ | ||
| *socktype = SOCK_DGRAM; | ||
| s = socket(AF_INET, *socktype, proto->p_proto); | ||
| s = socket(AF_INET, *socktype, p_proto); | ||
| if (s < 0) { | ||
| return -1; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.