summaryrefslogtreecommitdiff
path: root/flowtop.c
diff options
context:
space:
mode:
Diffstat (limited to 'flowtop.c')
-rw-r--r--flowtop.c55
1 files changed, 1 insertions, 54 deletions
diff --git a/flowtop.c b/flowtop.c
index 8cf2fd3..bf2e585 100644
--- a/flowtop.c
+++ b/flowtop.c
@@ -39,6 +39,7 @@
#include "pkt_buff.h"
#include "screen.h"
#include "proc.h"
+#include "sysctl.h"
struct flow_entry {
uint32_t flow_id, use, status;
@@ -222,60 +223,6 @@ static const struct nfct_filter_ipv6 filter_ipv6 = {
.mask = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff },
};
-#define SYS_PATH "/proc/sys/"
-
-static int sysctl_set_int(char *file, int value)
-{
- char path[PATH_MAX];
- char str[64];
- ssize_t ret;
- int fd;
-
- strncpy(path, SYS_PATH, PATH_MAX);
- strncat(path, file, PATH_MAX - sizeof(SYS_PATH) - 1);
-
- fd = open(path, O_WRONLY);
- if (unlikely(fd < 0))
- return -1;
-
- ret = snprintf(str, 63, "%d", value);
- if (ret < 0) {
- close(fd);
- return -1;
- }
-
- ret = write(fd, str, strlen(str));
-
- close(fd);
- return ret <= 0 ? -1 : 0;
-}
-
-static int sysctl_get_int(char *file, int *value)
-{
- char path[PATH_MAX];
- char str[64];
- ssize_t ret;
- int fd;
-
- strncpy(path, SYS_PATH, PATH_MAX);
- strncat(path, file, PATH_MAX - sizeof(SYS_PATH) - 1);
-
- fd = open(path, O_RDONLY);
- if (fd < 0)
- return -1;
-
- ret = read(fd, str, sizeof(str));
- if (ret > 0) {
- *value = atoi(str);
- ret = 0;
- } else {
- ret = -1;
- }
-
- close(fd);
- return ret;
-}
-
static void signal_handler(int number)
{
switch (number) {