[PATCH] tools: Fix type check when bootstrapping ipcps

  • From: Dimitri Staessens <dimitri.staessens@xxxxxxxx>
  • To: ouroboros@xxxxxxxxxxxxx
  • Date: Fri, 20 Apr 2018 10:53:01 +0200

The type check failed incorrectly if the type was specified because
the specified type was not set.

Signed-off-by: Dimitri Staessens <dimitri.staessens@xxxxxxxx>
---
 src/tools/irm/irm_ipcp_bootstrap.c | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/src/tools/irm/irm_ipcp_bootstrap.c 
b/src/tools/irm/irm_ipcp_bootstrap.c
index 8c01569..e1f7595 100644
--- a/src/tools/irm/irm_ipcp_bootstrap.c
+++ b/src/tools/irm/irm_ipcp_bootstrap.c
@@ -247,24 +247,26 @@ int do_bootstrap_ipcp(int     argc,
                 }
         }
 
+        if (ipcp_type != NULL) {
+                if (strcmp(ipcp_type, NORMAL) == 0)
+                        type = IPCP_NORMAL;
+                else if (strcmp(ipcp_type, UDP) == 0)
+                        type = IPCP_UDP;
+                else if (strcmp(ipcp_type, ETH_LLC) == 0)
+                        type = IPCP_ETH_LLC;
+                else if (strcmp(ipcp_type, ETH_DIX) == 0)
+                        type = IPCP_ETH_DIX;
+                else if (strcmp(ipcp_type, LOCAL) == 0)
+                        type = IPCP_LOCAL;
+                else if (strcmp(ipcp_type, RAPTOR) == 0)
+                        type = IPCP_RAPTOR;
+                else goto fail_usage;
+        }
+
         if (pid == -1) {
                 if (ipcp_type == NULL) {
                         printf("No IPCPs matching %s found.\n\n", ipcp);
                         goto fail;
-                } else {
-                        if (strcmp(ipcp_type, NORMAL) == 0)
-                                type = IPCP_NORMAL;
-                        else if (strcmp(ipcp_type, UDP) == 0)
-                                type = IPCP_UDP;
-                        else if (strcmp(ipcp_type, ETH_LLC) == 0)
-                                type = IPCP_ETH_LLC;
-                        else if (strcmp(ipcp_type, ETH_DIX) == 0)
-                                type = IPCP_ETH_DIX;
-                        else if (strcmp(ipcp_type, LOCAL) == 0)
-                                type = IPCP_LOCAL;
-                        else if (strcmp(ipcp_type, RAPTOR) == 0)
-                                type = IPCP_RAPTOR;
-                        else goto fail_usage;
                 }
 
                 pid = irm_create_ipcp(ipcp, type);
-- 
2.17.0


Other related posts:

  • » [PATCH] tools: Fix type check when bootstrapping ipcps - Dimitri Staessens