about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.c18
-rw-r--r--src/netascii.c2
-rw-r--r--src/packet.c24
3 files changed, 42 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index 15d3008..159b0b5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,4 +1,20 @@
+#include <stdint.h>
+#include <stdio.h>
+#include <sys/socket.h>
+#include <pthread.h>
 
-int main() {
+#include "packet.h"
+#include "netascii.h"
+
+int main(int argc, char** argv) {
+	//TODO: use getopt() to parse args
+	int s = socket(AF_INET, SOCK_DGRAM, 0);
+	if (s <= 0) {
+		fprintf(stderr, "error: socket cannot be created.\n");
+		return -1;
+	}
+	//TODO: threading!
+	//TODO: daemonize!
+	fprintf(stderr, "error: routine completed successfully.\n");
 	return 0;
 }
diff --git a/src/netascii.c b/src/netascii.c
index 606d257..2180093 100644
--- a/src/netascii.c
+++ b/src/netascii.c
@@ -1,6 +1,6 @@
 #include <stdint.h>
 
-#include "inc/netascii.h"
+#include "netascii.h"
 
 uint8_t is_netascii_char(char c) {
 	static const uint64_t LUT[4] = 
diff --git a/src/packet.c b/src/packet.c
new file mode 100644
index 0000000..8f7a7e6
--- /dev/null
+++ b/src/packet.c
@@ -0,0 +1,24 @@
+#include "packet.h"
+
+char* nbt_tftp_error_to_message(nbt_tftp_ecode error) {
+	switch (error) {
+		case 0:
+			return "ERROR";
+		case 1:
+			return "File not Found";
+		case 2:
+			return "Access violation";
+		case 3:
+			return "Disk full or allocation exceeded";
+		case 4:
+			return "Illegal TFTP operation";
+		case 5:
+			return "Unknown Transfer ID";
+		case 6:
+			return "File already exists";
+		case 7:
+			return "No such user";
+	}
+	return "UNKNOWN ERROR";
+}
+