diff options
author | Ren Kararou <[email protected]> | 2025-01-06 17:06:05 -0600 |
---|---|---|
committer | Ren Kararou <[email protected]> | 2025-01-06 17:06:05 -0600 |
commit | b9635ce3b4ca30b14128c131bb9fe9be08740d6d (patch) | |
tree | 14e3a0d128635b70fd71bedbb6caee074ac7eda4 /inc/handlers.h | |
parent | 5605a5ddf3c77232b04c002a82b91e227c0f27da (diff) | |
download | nbtpd-b9635ce3b4ca30b14128c131bb9fe9be08740d6d.tar.gz nbtpd-b9635ce3b4ca30b14128c131bb9fe9be08740d6d.tar.bz2 nbtpd-b9635ce3b4ca30b14128c131bb9fe9be08740d6d.zip |
start documentation efforts; cleanup handlers
socket connect in handlers, etc.
Diffstat (limited to 'inc/handlers.h')
-rw-r--r-- | inc/handlers.h | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/inc/handlers.h b/inc/handlers.h index 6be05da..aecd964 100644 --- a/inc/handlers.h +++ b/inc/handlers.h @@ -7,6 +7,14 @@ #define NBD_NBTPD_ARGS_PATH_MAX 768 #define NBD_NBTPD_ARGS_MODE_MAX 32 +typedef enum opmode { + NOT_FOUND, + NETASCII, + OCTAL, + MAIL +// any additional modes +} nbd_opmode; + typedef struct { char path[NBD_NBTPD_ARGS_PATH_MAX]; char mode[NBD_NBTPD_ARGS_MODE_MAX]; @@ -14,9 +22,30 @@ typedef struct { struct sockaddr_in client; } nbd_nbtpd_args; -/// WARNING: use this only if you know what you are doing +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 +/*! + * 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); |