Cleanup and organize a lot of Loader code.

This commit is contained in:
Christian Deacon
2025-02-23 06:34:37 -05:00
parent b27558cee7
commit ea47a7a435
6 changed files with 226 additions and 448 deletions

View File

@@ -1,12 +1,40 @@
#include <loader/utils/helpers.h>
/**
* Prints help menu.
*
* @return void
*/
void PrintHelpMenu()
{
fprintf(stdout, "Usage:\n" \
"--config -c => Config file location (default is /etc/xdpfw/xdpfw.conf).\n" \
"--offload -o => Tries to load the XDP program in hardware/offload mode.\n" \
"--skb -s => Force the XDP program to load with SKB mode instead of DRV.\n" \
"--time -t => How long to run the program for in seconds before exiting. 0 or not set = infinite.\n" \
"--list -l => Print config details including filters (this will exit program after done).\n" \
"--help -h => Print help menu.\n");
}
/**
* Handles signals from user.
*
* @param code Signal code.
*
* @return void
*/
void SignalHndl(int code)
{
cont = 0;
}
/**
* Parses an IP string with CIDR support. Stores IP in network byte order in ip.ip and CIDR in ip.cidr.
*
* @param ip The IP string.
*
* @return Returns an IP structure with IP and CIDR.
*/
*/
ip_range_t ParseIpCidr(const char *ip)
{
ip_range_t ret = {0};
@@ -22,7 +50,7 @@ ip_range_t ParseIpCidr(const char *ip)
if (token)
{
ret.cidr = (unsigned int) strtoul(token, NULL, 10);
ret.cidr = (u8) strtoul(token, NULL, 10);
}
}