Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions .github/workflows/run_all_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@ jobs:
- uses: actions/checkout@v4
- name: build
run: |
cmake ../src
make -j4
./build_for_testing.sh
working-directory: build
- name: build_tests
- name: build_integration_tests
run: |
cmake .
make -j4
working-directory: tests
- name: run_tests
./build_tests.sh
working-directory: tests/integration_tests/build
- name: run_integration_tests
run: |
sudo ./output/run_tests
working-directory: tests
sudo ./run_tests
working-directory: tests/integration_tests/output
23 changes: 11 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
.DS_Store
*.DS_Store

/build/Makefile
/build/CMakeCache.txt
/build/cmake_install.cmake
/build/CMakeFiles/
CMakeCache.txt
CMakeFiles/
cmake_install.cmake
install_manifest.txt
Makefile
*.cmake

/build/output/
!/build/cmake

compile_commands.json

/tests/Makefile
/tests/CMakeCache.txt
/tests/cmake_install.cmake
/tests/CMakeFiles/
/tests/output/
/tests/run_all_tests
/build/output/

*.dSYM/
2 changes: 1 addition & 1 deletion build/build_for_release.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
cmake ../src -DCMAKE_BUILD_TYPE=Release
cmake ../src -DCMAKE_BUILD_TYPE=Release -DSANITIZER=none
make -B -j8
28 changes: 0 additions & 28 deletions build/cmake/deadlightreal-swiftnetConfig.cmake

This file was deleted.

43 changes: 0 additions & 43 deletions build/cmake/deadlightreal-swiftnetConfigVersion.cmake

This file was deleted.

28 changes: 0 additions & 28 deletions build/cmake/morcules-swiftnetConfig.cmake

This file was deleted.

43 changes: 0 additions & 43 deletions build/cmake/morcules-swiftnetConfigVersion.cmake

This file was deleted.

28 changes: 0 additions & 28 deletions build/cmake/swiftnetConfig.cmake

This file was deleted.

43 changes: 0 additions & 43 deletions build/cmake/swiftnetConfigVersion.cmake

This file was deleted.

6 changes: 0 additions & 6 deletions build/install_manifest.txt

This file was deleted.

6 changes: 6 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ include(GNUInstallDirs)

set(CMAKE_C_STANDARD 99)

option(SWIFT_NET_INTERNAL_TESTING "Enable internal testing features" OFF)

set(SOURCE_FILES
initialize_swift_net.c
send_packet.c
Expand Down Expand Up @@ -50,11 +52,15 @@ endif()
add_library(swiftnet STATIC ${SOURCE_FILES})

if (SWIFT_NET_INTERNAL_TESTING)
message("Internal Testing Enabled")

add_compile_definitions(SWIFT_NET_INTERNAL_TESTING)

target_compile_options(swiftnet PRIVATE -O0)
target_link_options(swiftnet PRIVATE -O0)
else()
message("Internal Testing Disabled")

target_compile_options(swiftnet PRIVATE -O3)
target_link_options(swiftnet PRIVATE -O3)
endif()
Expand Down
4 changes: 2 additions & 2 deletions src/initialize_swift_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#endif

uint32_t maximum_transmission_unit = 0x00;
struct in_addr private_ip_address;
struct in_addr private_ip_address_testing;
uint8_t mac_address[6];
char default_network_interface[SIZEOF_FIELD(struct ifreq, ifr_name)];

Expand Down Expand Up @@ -77,7 +77,7 @@ void swiftnet_initialize() {
exit(EXIT_FAILURE);
}

private_ip_address = ((struct sockaddr_in *)&private_sockaddr)->sin_addr;
private_ip_address_testing = ((struct sockaddr_in *)&private_sockaddr)->sin_addr;

const int got_default_interface = get_default_interface_and_mac(default_network_interface, sizeof(default_network_interface), mac_address, temp_socket);
if(unlikely(got_default_interface != 0)) {
Expand Down
4 changes: 2 additions & 2 deletions src/internal/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ extern void* swiftnet_client_process_packets(void* const void_client);
extern void* execute_packet_callback_client(void* const void_client);
extern void* execute_packet_callback_server(void* const void_server);

extern struct in_addr private_ip_address;
extern struct in_addr private_ip_address_testing;
extern uint8_t mac_address[6];
extern char default_network_interface[SIZEOF_FIELD(struct ifreq, ifr_name)];
extern pcap_t* swiftnet_pcap_open(const char* interface);
Expand Down Expand Up @@ -265,7 +265,7 @@ static struct ip construct_ip_header(struct in_addr destination_addr, const uint
.ip_off = htons(0), // Not used
.ip_ttl = 64,// Time to live
.ip_sum = htons(0), // Checksum
.ip_src = private_ip_address, // Source ip
.ip_src = private_ip_address_testing, // Source ip
.ip_dst = destination_addr // Destination ip
};

Expand Down
4 changes: 2 additions & 2 deletions src/swift_net.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ enum PacketType {
SEND_LOST_PACKETS_REQUEST = 0x03,
SEND_LOST_PACKETS_RESPONSE = 0x04,
SUCCESSFULLY_RECEIVED_PACKET = 0x05,
REQUEST = 0x06,
#ifdef SWIFT_NET_REQUESTS
REQUEST = 0x06,
RESPONSE = 0x07,
#endif
};
Expand Down Expand Up @@ -397,7 +397,7 @@ extern void swiftnet_server_make_response(
#ifdef SWIFT_NET_DEBUG
// Adds one or more debug flags to the global debugger state.
extern void swiftnet_add_debug_flags(const uint32_t flags);
// Removes one or more debug flags from the global debugger state.
// Removes one or more debug flags from the global debugger state.
extern void swiftnet_remove_debug_flags(const uint32_t flags);
#endif

Expand Down
4 changes: 0 additions & 4 deletions tests/config.h

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.15)
project(SwiftNetTests C)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../output)

if(SANITIZER STREQUAL "address")
message(STATUS "Using AddressSanitizer")
Expand All @@ -19,11 +19,11 @@ else()
message(STATUS "No sanitizer enabled")
endif()

link_directories(${CMAKE_SOURCE_DIR}/../build/output)
link_directories(${CMAKE_SOURCE_DIR}/../../../build/output)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0")

file(GLOB SRC_FILES "${CMAKE_SOURCE_DIR}/src/*.c")
file(GLOB SRC_FILES "${CMAKE_SOURCE_DIR}/../src/*.c")

add_executable(run_tests ${SRC_FILES})

Expand Down
File renamed without changes.
Binary file added tests/integration_tests/output/run_tests
Binary file not shown.
Loading
Loading