Add comments to functions.
This commit is contained in:
@@ -13,6 +13,13 @@ const struct option opts[] =
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
/**
|
||||
* Parses the command line and stores values in the cmdline structure.
|
||||
*
|
||||
* @param cmd A pointer to the cmdline structure.
|
||||
*
|
||||
* @return Void
|
||||
*/
|
||||
void parsecommandline(struct cmdline *cmd, int argc, char *argv[])
|
||||
{
|
||||
int c;
|
||||
|
||||
21
src/config.c
21
src/config.c
@@ -11,6 +11,13 @@
|
||||
|
||||
FILE *file;
|
||||
|
||||
/**
|
||||
* Sets the config structure's default values.
|
||||
*
|
||||
* @param cfg A pointer to the config structure.
|
||||
*
|
||||
* @return Void
|
||||
*/
|
||||
void setcfgdefaults(struct config *cfg)
|
||||
{
|
||||
cfg->updatetime = 0;
|
||||
@@ -74,6 +81,13 @@ void setcfgdefaults(struct config *cfg)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the config file.
|
||||
*
|
||||
* @param filename Path to config file.
|
||||
*
|
||||
* @return 0 on success or 1 on error.
|
||||
*/
|
||||
int opencfg(const char *filename)
|
||||
{
|
||||
// Close any existing files.
|
||||
@@ -94,6 +108,13 @@ int opencfg(const char *filename)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the config file and stores values in config structure.
|
||||
*
|
||||
* @param cfg A pointer to the config structure.
|
||||
*
|
||||
* @return 0 on success or 1/-1 on error.
|
||||
*/
|
||||
int readcfg(struct config *cfg)
|
||||
{
|
||||
// Not sure why this would be set to NULL after checking for it in OpenConfig(), but just for safety.
|
||||
|
||||
30
src/xdpfw.c
30
src/xdpfw.c
@@ -31,6 +31,13 @@ void signalHndl(int tmp)
|
||||
cont = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the filter's BPF map.
|
||||
*
|
||||
* @param cfg A pointer to the config structure.
|
||||
*
|
||||
* @return Void
|
||||
*/
|
||||
void updatefilters(struct config *cfg)
|
||||
{
|
||||
// Loop through all filters and delete the map.
|
||||
@@ -58,6 +65,14 @@ void updatefilters(struct config *cfg)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves an update from the config.
|
||||
*
|
||||
* @param cfg A pointer to the config structure.
|
||||
* @param cfgfile The path to the config file.
|
||||
*
|
||||
* @return 0 on success or -1 on error.
|
||||
*/
|
||||
int updateconfig(struct config *cfg, char *cfgfile)
|
||||
{
|
||||
// Open config file.
|
||||
@@ -86,6 +101,14 @@ int updateconfig(struct config *cfg, char *cfgfile)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a BPF map's FD.
|
||||
*
|
||||
* @param bpf_obj A pointer to the BPF object.
|
||||
* @param mapname The name of the map to retrieve.
|
||||
*
|
||||
* @return The map's FD.
|
||||
*/
|
||||
int findmapfd(struct bpf_object *bpf_obj, const char *mapname)
|
||||
{
|
||||
struct bpf_map *map;
|
||||
@@ -106,6 +129,13 @@ int findmapfd(struct bpf_object *bpf_obj, const char *mapname)
|
||||
return fd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a BPF object file.
|
||||
*
|
||||
* @param filename The path to the BPF object file.
|
||||
*
|
||||
* @return BPF's program FD.
|
||||
*/
|
||||
int loadbpfobj(const char *filename)
|
||||
{
|
||||
int first_prog_fd = -1;
|
||||
|
||||
Reference in New Issue
Block a user