diff options
author | Sander Vrijders <sander.vrijders@intec.ugent.be> | 2016-08-11 12:19:24 +0200 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@intec.ugent.be> | 2016-08-11 14:59:42 +0200 |
commit | b411f856e27b3f76a37128f397a28df45d11db46 (patch) | |
tree | c8f8f614015448a69c22e3189240923527e89022 /src/tools/irm/irm_ipcp_enroll.c | |
parent | 97b1d71846bddef59020f5f250d7804617df3763 (diff) | |
download | ouroboros-b411f856e27b3f76a37128f397a28df45d11db46.tar.gz ouroboros-b411f856e27b3f76a37128f397a28df45d11db46.zip |
tools: irm: Create IPCP upon enroll if unexisting
This will create a new IPCP if enroll is called on a non existing
IPCP. It also fixes two memleaks.
Diffstat (limited to 'src/tools/irm/irm_ipcp_enroll.c')
-rw-r--r-- | src/tools/irm/irm_ipcp_enroll.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/tools/irm/irm_ipcp_enroll.c b/src/tools/irm/irm_ipcp_enroll.c index d6b1b27e..b7a12e2c 100644 --- a/src/tools/irm/irm_ipcp_enroll.c +++ b/src/tools/irm/irm_ipcp_enroll.c @@ -21,6 +21,7 @@ */ #include <stdio.h> +#include <stdlib.h> #include <ouroboros/irm.h> @@ -63,12 +64,17 @@ int do_enroll_ipcp(int argc, char ** argv) } len = irm_list_ipcps(name, &apis); - if (len <= 0) - return -1; + if (len <= 0) { + if (!irm_create_ipcp(name, IPCP_NORMAL)) + return -1; + len = irm_list_ipcps(name, &apis); + } for (i = 0; i < len; i++) if (irm_enroll_ipcp(apis[i], dif_name)) return -1; + free(apis); + return 0; } |