From d2502dbd95083fe4fd7cb1e2a0197267b2b08ca5 Mon Sep 17 00:00:00 2001 From: fadhil riyanto Date: Tue, 24 Sep 2024 09:37:03 +0700 Subject: add destport and srcport params Signed-off-by: fadhil riyanto --- main.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'main.c') diff --git a/main.c b/main.c index 7307d64..d76fab3 100644 --- a/main.c +++ b/main.c @@ -1,6 +1,9 @@ + #include #include #include "submodule/log.c-patched/src/log.h" +#include +#include #define dbgchr(x) log_info("%c", x) @@ -11,6 +14,9 @@ enum tcpf_mode { struct runtime_opts { enum tcpf_mode mode; + uint16_t srcport; + uint16_t destport; + }; static int parseopt(int argc, char **argv, struct runtime_opts *r_opts) @@ -20,12 +26,14 @@ static int parseopt(int argc, char **argv, struct runtime_opts *r_opts) static struct option opt_table[] = { {"mode", required_argument, 0, 'm'}, + {"srcport", required_argument, 0, 's'}, + {"destport", required_argument, 0, 'd'}, // {"mode", required_argument, 0, 'm'},4 {0, 0, 0, 0} }; while(1) { - c = getopt_long(argc, argv, "m:", opt_table, &optcounter); + c = getopt_long(argc, argv, "m:s:d:", opt_table, &optcounter); // dbgchr(c); if (c == -1) @@ -41,6 +49,14 @@ static int parseopt(int argc, char **argv, struct runtime_opts *r_opts) r_opts->mode = TCPF_CLIENT; } break; + + case 's': + r_opts->srcport = atoi(optarg); + break; + + case 'd': + r_opts->destport = atoi(optarg); + break; } -- cgit v1.2.3