From 746cd14f273a96c0348f4e64f9b347ce49a93f45 Mon Sep 17 00:00:00 2001 From: Ren Kararou Date: Thu, 26 Dec 2024 01:50:22 -0600 Subject: add ci; update packet structs; add makefile --- src/main.c | 18 +++++++++++++++++- src/netascii.c | 2 +- src/packet.c | 24 ++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 src/packet.c (limited to 'src') 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 +#include +#include +#include -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 -#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"; +} + -- cgit 1.4.1-2-gfad0