From 95dada12eb1c7c6d52a52b89e4bf1a56b95d692a Mon Sep 17 00:00:00 2001 From: Joel Grunbaum <joelgrun@gmail.com> Date: Wed, 01 Jun 2022 04:52:13 +0000 Subject: [PATCH] checks for server conductibility if user is root --- test.c | 40 +++++++++++++++++++++------------------- 1 files changed, 21 insertions(+), 19 deletions(-) diff --git a/test.c b/test.c index 7ddbf1c..aae2c20 100644 --- a/test.c +++ b/test.c @@ -6,25 +6,27 @@ int main(void) { - char* hostname = "google.com"; - char* IP = "127.0.0.1"; - int type = T_A; unsigned char buf[65536]; - struct timespec ret; - int r; + int error_count; - r = reachable(buf, "10.0.0.0"); - printf("%d\n", r); - /* print_packet(buf + sizeof(struct ip)); */ - r = reachable(buf, "127.0.0.2"); - printf("%d\n", r); - - /* ret = resolve(buf, hostname, IP, type); */ - - /* printf("%ld, %ld\n", ret.tv_sec, ret.tv_nsec); */ - - /* print_packet(buf); */ - /* for (int i = 0; i < 98; i++) { */ - /* printf("%X", buf[i]); */ - /* } */ + error_count = 0; + for (int i = 0; i < 100; i++) { + error_count += (reachable(buf, "1.1.1.1") != 0); + } + printf("1.1.1.1: %d\n", error_count); + error_count = 0; + for (int i = 0; i < 100; i++) { + error_count += (reachable(buf, "192.168.0.101") != 0); + } + printf("192.168.0.101: %d\n", error_count); + error_count = 0; + for (int i = 0; i < 100; i++) { + error_count += (reachable(buf, "192.168.0.100") != 0); + } + printf("192.168.0.100: %d\n", error_count); + error_count = 0; + for (int i = 0; i < 100; i++) { + error_count += (reachable(buf, "129.146.153.226") != 0); + } + printf("129.146.153.226: %d\n", error_count); } -- Gitblit v1.10.0