summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2018-08-12 12:41:17 +0200
committerTom Smeding <tom.smeding@gmail.com>2018-08-12 12:41:17 +0200
commite265035809d6d839b259edec8ac8b197ccce3249 (patch)
tree5c0670fbf89eb3601027be00e24e704b17762a13
parent0acc3047af9eef460e90adaa3e0e59b602adbb0a (diff)
Remove old client and server
-rw-r--r--Makefile2
-rw-r--r--client.c36
-rw-r--r--server.c39
3 files changed, 1 insertions, 76 deletions
diff --git a/Makefile b/Makefile
index eadce97..cbdd2f3 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@ CC = gcc
CFLAGS = -Wall -Wextra -O2 -g -std=c11 -fwrapv -pthread
LDFLAGS = -pthread
-TARGETS = server client serverd clientd
+TARGETS = serverd clientd
SOURCES = $(filter-out $(patsubst %,%.c,$(TARGETS)),$(wildcard *.c))
OBJECTS = $(patsubst %.c,%.o,$(SOURCES))
diff --git a/client.c b/client.c
deleted file mode 100644
index aa9b13c..0000000
--- a/client.c
+++ /dev/null
@@ -1,36 +0,0 @@
-#include <stdio.h>
-#include <stddef.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netinet/ip_icmp.h>
-#include <arpa/inet.h>
-#include <unistd.h>
-#include "icmp_client.h"
-#include "util.h"
-
-int main(void) {
- int sock = icmp_client_open_socket();
- if (sock < 0) {
- perror("icmp_client_open_socket");
- return 1;
- }
-
- const char *ip_address = "127.0.0.1";
- // const char *ip_address = "192.168.43.220";
- // const char *ip_address = "198.211.118.67"; // tomsmeding.com
-
- if (icmp_client_send(sock, inet_addr(ip_address), 1234, "kaashandel", 10) < 0) {
- perror("icmp_client_send");
- return 1;
- }
-
- struct icmp_incoming reply = icmp_client_receive(sock);
- if (reply.data == NULL) {
- perror("icmp_client_receive");
- return 1;
- }
-
- printf("Received length: %zd payload:\n", reply.length);
- xxd(reply.data, reply.length);
-}
diff --git a/server.c b/server.c
deleted file mode 100644
index df51032..0000000
--- a/server.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#include <stdio.h>
-#include <stdbool.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <unistd.h>
-#include "icmp_server.h"
-#include "util.h"
-
-
-int main(void) {
- int sock = icmp_server_open_socket();
- if (sock < 0) {
- perror("icmp_server_open_socket");
- return 1;
- }
-
- while (true) {
- struct icmp_incoming msg = icmp_server_receive(sock);
- if (msg.data == NULL) {
- perror("icmp_server_communicate");
- return 1;
- }
-
- printf("Received: id %d seqnum %d data:\n", msg.id, msg.seqnum);
- xxd(msg.data, msg.length);
-
- char data[msg.length + 1];
- for (size_t i = 0; i < msg.length; i++) {
- data[i] = toupper(msg.data[i]);
- }
- data[msg.length] = '!';
-
- if (icmp_server_send_reply(sock, msg.source_addr, msg.id, msg.seqnum, data, msg.length + 1) < 0) {
- perror("icmp_server_send_reply");
- }
- }
-
- close(sock);
-}