diff options
author | Ren Kararou <[email protected]> | 2025-01-26 03:41:25 -0600 |
---|---|---|
committer | Ren Kararou <[email protected]> | 2025-01-26 03:41:25 -0600 |
commit | 1bcf3de7f521d83185cce580db2dea6d50a617b6 (patch) | |
tree | c06850c6c0df9bdc9ca395ecc9ebe67b7c9dfb86 /inc | |
parent | 9ec8d6d9dc03791f6ab1e3ad108c8d705d355696 (diff) | |
download | nbtpd-1bcf3de7f521d83185cce580db2dea6d50a617b6.tar.gz nbtpd-1bcf3de7f521d83185cce580db2dea6d50a617b6.tar.bz2 nbtpd-1bcf3de7f521d83185cce580db2dea6d50a617b6.zip |
try bazel bazel
Diffstat (limited to 'inc')
-rw-r--r-- | inc/handlers.h | 53 | ||||
-rw-r--r-- | inc/netascii.h | 10 | ||||
-rw-r--r-- | inc/packet.h | 61 |
3 files changed, 0 insertions, 124 deletions
diff --git a/inc/handlers.h b/inc/handlers.h deleted file mode 100644 index acf994e..0000000 --- a/inc/handlers.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef NBD_NBTPD_HANDLERS_H -#define NBD_NBTPD_HANDLERS_H - -#include <netinet/in.h> -#include "packet.h" - -#define NBD_NBTPD_ARGS_PATH_MAX 768 -#define NBD_NBTPD_ARGS_MODE_MAX 32 - -typedef enum opmode { - NOT_FOUND, - NETASCII, - OCTET, - MAIL -// any additional modes -} nbd_opmode; - -typedef struct { - char path[NBD_NBTPD_ARGS_PATH_MAX]; - char mode[NBD_NBTPD_ARGS_MODE_MAX]; - nbd_tftp_ecode err; - struct sockaddr_in client; -} nbd_nbtpd_args; - -nbd_opmode get_mode(char *mode); - - -/*! - * WARNING: use this only if you know what you are doing - * The actual function signature is `void read_req_resp(nbd_nbtpd_args *args)` - * Invoke this function as a response to getting a new read request. - * It opens a new UDP socket and reads file to transmit. - * ```c - * nbd_nbtpd_args *args = malloc(sizeof(nbd_nbtpd_args)); - * pthread_create(thread, attrs, read_req_resp, (void *)args); - * ``` - */ -void *read_req_resp(void *args); -/*! - * WARNING: use this only if you know what you are doing - * The actual function signature is `void write_req_resp(nbd_nbtpd_args *args)` - * Invoke this function as a response to getting a new write request. - * It opens a new UDP socket, receives file to write to disk. - * ```c - * nbd_nbtpd_args *args = malloc(sizeof(nbd_nbtpd_args)); - * pthread_create(thread, attrs, write_req_resp, (void *)args); - * ``` - */ -void *write_req_resp(void *args); -/// WARNING: use this only if you know what you are doing -void *nbd_nbtpd_resp_error(void *args); - -#endif diff --git a/inc/netascii.h b/inc/netascii.h deleted file mode 100644 index ae80bae..0000000 --- a/inc/netascii.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef NBD_NETASCII_H -#define NBD_NETASCII_H -#include <stdint.h> -#include <stdlib.h> - -uint8_t is_netascii_char(char c); -uint8_t is_netascii_str(char *str); -uint8_t is_netascii_buf(char *buf, size_t len); - -#endif diff --git a/inc/packet.h b/inc/packet.h deleted file mode 100644 index 86b43a3..0000000 --- a/inc/packet.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef NBD_TFTP_PACKET_H -#define NBD_TFTP_PACKET_H - -#include <stdint.h> -#include <unistd.h> - -typedef enum { - RRQ = 1, - WRQ = 2, - DAT = 3, - ACK = 4, - ERR = 5, -} nbd_tftp_opcode; - -typedef enum { - ERROR = 0, - ENOTFOUND = 1, - EACCESS = 2, - ENOSPACE = 3, - EOPERATION = 4, - ETRANS = 5, - EEXISTS = 6, - EUSER = 7, -} nbd_tftp_ecode; - -typedef struct { - uint16_t opcode; - char *filename; - char *mode; -} nbd_tftp_packet_rq; - -typedef struct { - uint16_t opcode; - uint16_t block_num; - char *data; - size_t datalen; -} nbd_tftp_packet_data; - -typedef struct { - uint16_t opcode; - uint16_t block_num; -} nbd_tftp_packet_ack; - -typedef struct { - uint16_t opcode; - uint16_t err; - char *emsg; -} nbd_tftp_packet_error; - -char *nbd_tftp_error_to_message(nbd_tftp_ecode error); -char *nbd_tftp_ser_data(nbd_tftp_packet_data d); -char *nbd_tftp_ser_data_from_parts(uint16_t blocknum, char *data, size_t datalen); -nbd_tftp_packet_data nbd_tftp_de_data(char *data, size_t len); -char *nbd_tftp_ser_error(nbd_tftp_packet_error e); -char *nbd_tftp_ser_error_from_code(nbd_tftp_ecode error); -char *nbd_tftp_ser_ack(nbd_tftp_packet_ack ack); -char *nbd_tftp_ser_ack_from_block_num(uint16_t block_num); -nbd_tftp_packet_ack nbd_tftp_de_ack(char *buf, ssize_t buflen); - -#endif - |