]> git.gsnw.org Git - fping.git/commitdiff
The --oiface option is not allowed with -I --iface
authorGerman Service Network <support@gsnw.de>
Sun, 22 Mar 2026 08:08:21 +0000 (09:08 +0100)
committerSebastian <176771227+gsnw-sebast@users.noreply.github.com>
Sat, 25 Apr 2026 05:42:10 +0000 (07:42 +0200)
src/flags.c
src/flags.h
src/fping.c

index 2c491e1f423d0e5987b4f21736d4c8a984b10534..6b071b34d73d65a0dddc92213692ebc7a3e1c65c 100644 (file)
@@ -45,6 +45,8 @@ int opt_outage_on = 0;
 int opt_random_data_on = 0;
 int opt_check_source_on = 0;
 int opt_size_on = 0;
+int opt_oiface_on = 0;
+int opt_bindiface_on = 0;
 int opt_timestamp_on = 0;
 int opt_timestamp_format = 0;
 int opt_icmp_request_typ = 0;
\ No newline at end of file
index 9ab79225cd42aa901a8f9b9915772cd4467a4289..84f345ec593f7263831278a5f484e33711d226f9 100644 (file)
@@ -49,6 +49,8 @@ extern int opt_outage_on;
 extern int opt_random_data_on;
 extern int opt_check_source_on;
 extern int opt_size_on;
+extern int opt_oiface_on;
+extern int opt_bindiface_on;
 extern int opt_timestamp_on;
 extern int opt_timestamp_format;
 extern int opt_icmp_request_typ;
index be9dcfcfbaf3305418ec457dbc1e14dad88529a7..abaebf7f3f3eca6383f8f375c1088515ca9c0a24 100644 (file)
@@ -600,6 +600,7 @@ int main(int argc, char **argv)
             } else if (strstr(optparse_state.optlongname, "seqmap-timeout") != NULL) {
                 opt_seqmap_timeout = strtod_strict(optparse_state.optarg) * 1000000;
             } else if (strstr(optparse_state.optlongname, "oiface") != NULL) {
+              opt_oiface_on = 1;
 #ifdef IP_PKTINFO
               if (socket4 >= 0) {
                   socket_set_outgoing_iface_ipv4(socket4, optparse_state.optarg);
@@ -863,6 +864,7 @@ int main(int argc, char **argv)
             exit(1);
 
         case 'I':
+            opt_bindiface_on = 1;
 #ifdef SO_BINDTODEVICE
             if (socket4 >= 0) {
                 if (p_setsockopt(suid, socket4, SOL_SOCKET, SO_BINDTODEVICE, optparse_state.optarg, strlen(optparse_state.optarg))) {
@@ -955,6 +957,11 @@ int main(int argc, char **argv)
         exit(1);
     }
 
+    if (opt_oiface_on && opt_bindiface_on) {
+        fprintf(stderr, "%s: specify only --oiface or -I, --iface\n", prog);
+        exit(1);
+    }
+
     if (opt_count_on && opt_loop_on) {
         fprintf(stderr, "%s: specify only one of c, l\n", prog);
         exit(1);