aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2018-01-31 00:44:58 (GMT)
committerRob Landley <rob@landley.net>2018-01-31 00:44:58 (GMT)
commit1498c2fc3d0a9b72232e7aee2d973f15e82cb5b4 (patch)
treec5ab374b4bb75db748f91c4aa533431786b64bb6
parent03b83ee148b62fe56aa834a0e0c96352d34ef587 (diff)
downloadandroid_external_toybox-1498c2fc3d0a9b72232e7aee2d973f15e82cb5b4.zip
android_external_toybox-1498c2fc3d0a9b72232e7aee2d973f15e82cb5b4.tar.gz
android_external_toybox-1498c2fc3d0a9b72232e7aee2d973f15e82cb5b4.tar.bz2
Basic ping support.
Requires echo 0 $((1<<30)) > /proc/sys/net/ipv4/ping_group_range (as root)
-rw-r--r--lib/lib.h1
-rw-r--r--lib/net.c13
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/lib.h b/lib/lib.h
index 9466298..939d612 100644
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -294,6 +294,7 @@ struct addrinfo *xgetaddrinfo(char *host, char *port, int family, int socktype,
int xconnect(struct addrinfo *ai_arg);
int xpoll(struct pollfd *fds, int nfds, int timeout);
int pollinate(int in1, int in2, int out1, int out2, int timeout, int shutdown_timeout);
+char *ntop(struct sockaddr *sa);
// password.c
int get_salt(char *salt, char * algo);
diff --git a/lib/net.c b/lib/net.c
index 5c6d4f7..846be31 100644
--- a/lib/net.c
+++ b/lib/net.c
@@ -102,3 +102,16 @@ int pollinate(int in1, int in2, int out1, int out2, int timeout, int shutdown_ti
}
}
}
+
+// Return converted numeric address in libbuf
+char *ntop(struct sockaddr *sa)
+{
+ void *addr;
+
+ if (sa->sa_family == AF_INET) addr = &((struct sockaddr_in *)sa)->sin_addr;
+ else addr = &((struct sockaddr_in6 *)sa)->sin6_addr;
+
+ inet_ntop(sa->sa_family, addr, libbuf, sizeof(libbuf));
+
+ return libbuf;
+}