Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
buracchi committed Apr 7, 2024
1 parent 9a17998 commit bf353de
Show file tree
Hide file tree
Showing 10 changed files with 387 additions and 76 deletions.
2 changes: 1 addition & 1 deletion client/src/service_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include <event2/util.h>

typedef struct service_handler {
typedef struct tftp_service {
char const *command; // command to send to the server (e.g. "list", "get", "put")
char *filename; // file to send or receive (used with the "get" and "put" commands)
uint32_t window_size; // size of the dispatch window to use for the Go-Back N protocol
Expand Down
2 changes: 1 addition & 1 deletion docs/rfcs-compliance-metadata.csv
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ RFC 1350 - TFTP (Trivial File Transfer Protocol);;
6. Normal Termination;;
;Transfer ends with a DATA packet containing 0 to 511 bytes.;test_false
;Final DATA packet is acknowledged like other DATA packets.;test_false
;The host sending the final ACK wait for a long timeout before terminating in oreder to retransmit the final ACK if lost.;test_false
;The host sending the final ACK wait for a long timeout before terminating in order to retransmit the final ACK if lost.;test_false
;Sender of the final DATA packet should retransmit until acknowledged or timeout.;test_false
;Successful completion is indicated by reception of the final ACK.;test_false
;Timeout or DATA sender unwillingness to retransmit may indicate an incomplete transfer.;test_false
Expand Down
2 changes: 1 addition & 1 deletion server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ add_library(server_obj OBJECT
"src/cmdline.c"
"src/acceptor.c"
"src/dispatcher.c"
"src/service_handler.c"
"src/tftp_service.c"
)
target_include_directories(server_obj PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>")
target_link_libraries(server_obj PRIVATE buracchi::argparser::argparser)
Expand Down
12 changes: 6 additions & 6 deletions server/src/acceptor.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ int acceptor_destroy(struct acceptor acceptor[static 1]) {
return 0;
}

bool acceptor_accept(struct acceptor acceptor[static 1], evutil_socket_t socket[static 1], struct acceptor_packet packet[static 1]) {
evutil_socket_t acceptor_accept(struct acceptor acceptor[static 1], struct acceptor_packet packet[static 1]) {
evutil_socket_t client_socket = EVUTIL_INVALID_SOCKET;
char client_address_str[INET6_ADDRSTRLEN] = {};
uint16_t client_address_port;
char rbuff_hex[sizeof packet->data] = {};
Expand All @@ -76,12 +77,11 @@ bool acceptor_accept(struct acceptor acceptor[static 1], evutil_socket_t socket[
}
cmn_logger_log_debug("Acceptor: Got packet from host %s on port %hu of %zu bytes, packet content is \"%s\"",
client_address_str, client_address_port, packet->payload_size, rbuff_hex);
*socket = create_client_transport_endpoint(packet);
if (*socket == EVUTIL_INVALID_SOCKET) {
client_socket = create_client_transport_endpoint(packet);
if (client_socket == EVUTIL_INVALID_SOCKET) {
cmn_logger_log_error("Acceptor: Unable to create an endpoint to the client, denying connection.");
return false;
}
return true;
}
return client_socket;
}

// Resolves the specified service and returns a list of addrinfo
Expand Down
2 changes: 1 addition & 1 deletion server/src/acceptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ int acceptor_destroy(struct acceptor acceptor[static 1]);
* @param socket
* @param packet
*/
bool acceptor_accept(struct acceptor acceptor[static 1], evutil_socket_t socket[static 1], struct acceptor_packet packet[static 1]);
evutil_socket_t acceptor_accept(struct acceptor acceptor[static 1], struct acceptor_packet packet[static 1]);
Loading

0 comments on commit bf353de

Please sign in to comment.