]> git.german-service-network.de Git - fping.git/commitdiff
Fix getprotobyname missing on Android preventing use (by Paliak) develop
authorGerman Service Network <[email protected]>
Sun, 23 Aug 2026 07:19:05 +0000 (09:19 +0200)
committerSebastian <[email protected]>
Sun, 23 Aug 2026 07:48:25 +0000 (09:48 +0200)
CHANGELOG.md
src/socket4.c
src/socket6.c

index 94c421e73e402cf5de0ccf3db138355a7092e1f3..f4241893704668ae019ca06c5c3f2464d93a0f78 100644 (file)
@@ -8,6 +8,7 @@ Next
 
 ## Bugfixes and other changes
 
+- Fix getprotobyname missing on Android preventing use (#470, thanks Paliak. Merged #475)
 - ci: Removed travis-ci (#446, thanks @gsnw-sebast)
 - Performance optimization: reduce number of select calls and use
   recvmsg with MSG_DONTWAIT instead (#449)
index cb986e229cecec03f0f0048865c4b225284727d3..f6f96142d18d72c6ec86dff1ab7769ed7a62aa50 100644 (file)
@@ -59,20 +59,15 @@ static int outgoing_src_addr_set_ipv4 = 0;
 
 int open_ping_socket_ipv4(int *socktype)
 {
-    struct protoent* proto;
     int s;
 
-    /* confirm that ICMP is available on this machine */
-    if ((proto = getprotobyname("icmp")) == NULL)
-        crash_and_burn("icmp: unknown protocol");
-
     /* create raw socket for ICMP calls (ping) */
     *socktype = SOCK_RAW;
-    s = socket(AF_INET, *socktype, proto->p_proto);
+    s = socket(AF_INET, *socktype, IPPROTO_ICMP);
     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, IPPROTO_ICMP);
         if (s < 0) {
             return -1;
         }
index ab6e199f73fd956ce0a7a142a2602e0ff2d3251a..f2ccb7e2b490f8a5e0d104057a41e967038f4831 100644 (file)
@@ -57,20 +57,15 @@ static int outgoing_src_addr_set_ipv6 = 0;
 
 int open_ping_socket_ipv6(int *socktype)
 {
-    struct protoent* proto;
     int s;
 
-    /* confirm that ICMP6 is available on this machine */
-    if ((proto = getprotobyname("ipv6-icmp")) == NULL)
-        crash_and_burn("ipv6-icmp: unknown protocol");
-
     /* create raw socket for ICMP6 calls (ping) */
     *socktype = SOCK_RAW;
-    s = socket(AF_INET6, *socktype, proto->p_proto);
+    s = socket(AF_INET6, *socktype, IPPROTO_ICMPV6);
     if (s < 0) {
         /* try non-privileged icmp6 (works on Mac OSX without privileges, for example) */
         *socktype = SOCK_DGRAM;
-        s = socket(AF_INET6, *socktype, proto->p_proto);
+        s = socket(AF_INET6, *socktype, IPPROTO_ICMPV6);
         if (s < 0) {
             return -1;
         }