summaryrefslogtreecommitdiff
path: root/netcon/RPC.c
diff options
context:
space:
mode:
authorJoseph Henry <josephjah@gmail.com>2016-01-25 12:55:29 -0800
committerJoseph Henry <josephjah@gmail.com>2016-01-25 12:55:29 -0800
commit95d28494f6fbe352ac7746f0c544e3527534ba0d (patch)
tree7f89521d3afa6cc8519aaef31b0376c4ed3d7817 /netcon/RPC.c
parent935f00ad4cc883fbdb572c39584ab34dff7d0f12 (diff)
downloadinfinitytier-95d28494f6fbe352ac7746f0c544e3527534ba0d.tar.gz
infinitytier-95d28494f6fbe352ac7746f0c544e3527534ba0d.zip
Mac OSX Port - Lightly tested
Diffstat (limited to 'netcon/RPC.c')
-rw-r--r--netcon/RPC.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/netcon/RPC.c b/netcon/RPC.c
index a6965892..7d5c11e0 100644
--- a/netcon/RPC.c
+++ b/netcon/RPC.c
@@ -3,7 +3,10 @@
#include <sys/un.h>
#include <pthread.h>
#include <errno.h>
+
+#if defined(__linux__)
#include <sys/syscall.h>
+#endif
#include <fcntl.h>
#include <dlfcn.h>
@@ -70,12 +73,12 @@ int get_retval(int rpc_sock)
int load_symbols_rpc()
{
- #ifdef NETCON_INTERCEPT
+#ifdef NETCON_INTERCEPT
realsocket = dlsym(RTLD_NEXT, "socket");
realconnect = dlsym(RTLD_NEXT, "connect");
if(!realconnect || !realsocket)
return -1;
- #endif
+#endif
return 1;
}
@@ -131,19 +134,22 @@ int rpc_send_command(char *path, int cmd, int forfd, void *data, int len)
memcpy(&cmdbuf[CANARY_IDX], &canary_num, CANARY_SZ);
memcpy(&cmdbuf[STRUCT_IDX], data, len);
-#ifdef VERBOSE
+#if defined(VERBOSE)
+ rpc_count++;
memset(metabuf, 0, BUF_SZ);
+#if defined(__linux__)
pid_t pid = syscall(SYS_getpid);
pid_t tid = syscall(SYS_gettid);
- rpc_count++;
+#endif
char timestring[20];
time_t timestamp;
timestamp = time(NULL);
strftime(timestring, sizeof(timestring), "%H:%M:%S", localtime(&timestamp));
memcpy(metabuf, RPC_PHRASE, RPC_PHRASE_SZ); // Write signal phrase
-
+#if defined(__linux__)
memcpy(&metabuf[IDX_PID], &pid, sizeof(pid_t) ); /* pid */
memcpy(&metabuf[IDX_TID], &tid, sizeof(pid_t) ); /* tid */
+#endif
memcpy(&metabuf[IDX_COUNT], &rpc_count, sizeof(rpc_count) ); /* rpc_count */
memcpy(&metabuf[IDX_TIME], &timestring, 20 ); /* timestamp */
#endif