summaryrefslogtreecommitdiff
path: root/server.c
diff options
context:
space:
mode:
Diffstat (limited to 'server.c')
-rw-r--r--server.c39
1 files changed, 0 insertions, 39 deletions
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);
-}