summaryrefslogtreecommitdiff
path: root/src/tools/oping
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/oping')
-rw-r--r--src/tools/oping/CMakeLists.txt5
-rw-r--r--src/tools/oping/oping.c15
-rw-r--r--src/tools/oping/oping_client.c28
-rw-r--r--src/tools/oping/oping_server.c4
4 files changed, 25 insertions, 27 deletions
diff --git a/src/tools/oping/CMakeLists.txt b/src/tools/oping/CMakeLists.txt
index ebf96bdb..31a4f961 100644
--- a/src/tools/oping/CMakeLists.txt
+++ b/src/tools/oping/CMakeLists.txt
@@ -4,6 +4,11 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(${CMAKE_BINARY_DIR}/include)
+get_filename_component(CURRENT_SOURCE_PARENT_DIR
+ ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY)
+
+include_directories(${CURRENT_SOURCE_PARENT_DIR})
+
find_library(LIBM_LIBRARIES m)
if(NOT LIBM_LIBRARIES)
message(FATAL_ERROR "libm not found")
diff --git a/src/tools/oping/oping.c b/src/tools/oping/oping.c
index 5e01e026..3c1d4fe9 100644
--- a/src/tools/oping/oping.c
+++ b/src/tools/oping/oping.c
@@ -37,17 +37,26 @@
*/
#define _POSIX_C_SOURCE 199506L
-#define __XSI_VISIBLE 500
+#define __XSI_VISIBLE 500
-#include <ouroboros/endian.h>
-#include <ouroboros/fqueue.h>
#include <ouroboros/dev.h>
+#include <ouroboros/fccntl.h>
+#include <ouroboros/fqueue.h>
+
+#include "time_utils.h"
#include <stdio.h>
#include <string.h>
#include <pthread.h>
#include <stdint.h>
#include <stdbool.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <arpa/inet.h>
+#include <math.h>
+#include <errno.h>
+#include <float.h>
#define OPING_BUF_SIZE 1500
diff --git a/src/tools/oping/oping_client.c b/src/tools/oping/oping_client.c
index 8952f5ed..07fbde74 100644
--- a/src/tools/oping/oping_client.c
+++ b/src/tools/oping/oping_client.c
@@ -36,18 +36,6 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <ouroboros/dev.h>
-#include <ouroboros/fccntl.h>
-#include <ouroboros/time_utils.h>
-
-#include <signal.h>
-#include <stdlib.h>
-#include <sys/time.h>
-#include <arpa/inet.h>
-#include <math.h>
-#include <errno.h>
-#include <float.h>
-
volatile bool stop;
void shutdown_client(int signo, siginfo_t * info, void * c)
@@ -88,12 +76,12 @@ void * reader(void * o)
if (msg_len < 0)
continue;
- if (ntoh32(msg->type) != ECHO_REPLY) {
+ if (ntohl(msg->type) != ECHO_REPLY) {
printf("Invalid message on fd %d.\n", fd);
continue;
}
- if (ntoh32(msg->id) >= client.count) {
+ if ((uint32_t) ntohl(msg->id) >= client.count) {
printf("Invalid id.\n");
continue;
}
@@ -102,8 +90,8 @@ void * reader(void * o)
clock_gettime(CLOCK_MONOTONIC, &now);
- sent.tv_sec = ntoh64(msg->tv_sec);
- sent.tv_nsec = ntoh64(msg->tv_nsec);
+ sent.tv_sec = msg->tv_sec;
+ sent.tv_nsec = msg->tv_nsec;
ms = ts_diff_us(&sent, &now) / 1000.0;
@@ -155,10 +143,10 @@ void * writer(void * o)
clock_gettime(CLOCK_MONOTONIC, &now);
- msg->type = hton32(ECHO_REQUEST);
- msg->id = hton32(client.sent++);
- msg->tv_sec = hton64(now.tv_sec);
- msg->tv_nsec = hton64(now.tv_nsec);
+ msg->type = htonl(ECHO_REQUEST);
+ msg->id = htonl(client.sent++);
+ msg->tv_sec = now.tv_sec;
+ msg->tv_nsec = now.tv_nsec;
if (flow_write(*fdp, buf, client.size) == -1) {
printf("Failed to send SDU.\n");
diff --git a/src/tools/oping/oping_server.c b/src/tools/oping/oping_server.c
index 49b14f81..e91b6f10 100644
--- a/src/tools/oping/oping_server.c
+++ b/src/tools/oping/oping_server.c
@@ -36,10 +36,6 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <stdlib.h>
-#include <signal.h>
-#include <arpa/inet.h>
-
void shutdown_server(int signo, siginfo_t * info, void * c)
{
(void) info;