diff options
author | fadhil riyanto <me@fadev.org> | 2024-09-24 09:37:03 +0700 |
---|---|---|
committer | fadhil riyanto <me@fadev.org> | 2024-09-24 09:37:03 +0700 |
commit | d2502dbd95083fe4fd7cb1e2a0197267b2b08ca5 (patch) | |
tree | bc707e468e3c2013a292f536a63c1fa8635a58c6 | |
parent | 66f581396e70098e13fafcc20f26f1b2a76f35e4 (diff) |
add destport and srcport params
Signed-off-by: fadhil riyanto <me@fadev.org>
-rw-r--r-- | main.c | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -1,6 +1,9 @@ + #include <string.h> #include <getopt.h> #include "submodule/log.c-patched/src/log.h" +#include <stdint.h> +#include <stdlib.h> #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; } |