summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/man/ouroboros.89
-rw-r--r--src/ipcpd/normal/CMakeLists.txt2
-rw-r--r--src/ipcpd/normal/main.c10
-rw-r--r--src/tools/irm/irm_ipcp_bootstrap.c42
-rw-r--r--src/tools/irm/irm_ipcp_enroll.c38
5 files changed, 71 insertions, 30 deletions
diff --git a/doc/man/ouroboros.8 b/doc/man/ouroboros.8
index e22a0541..394625fa 100644
--- a/doc/man/ouroboros.8
+++ b/doc/man/ouroboros.8
@@ -135,7 +135,7 @@ destroys the IPCP process with name \fIname\fR.
.RE
.PP
\fBirm ipcp bootstrap\fR type \fItype\fR name \fIname\fR dif \fIdif\fR \
-[\fIparams\fR]
+[\fIparams\fR] [\fIautobind\fR]
.RS 4
bootstraps an IPCP process of type \fItype\fR and name \fIname\fR in a
DIF \fIdif\fR. If an IPCP with that name does not exist yet, the IPCP
@@ -176,7 +176,6 @@ default: 4 bytes.
default: 2 bytes.
.PP
[ttl] specifies the presence of a time-to-live field.
-TODO: set a default TTL here?
.PP
[addr_auth \fIpolicy\fR] specifies the address authority policy.
.br
@@ -201,14 +200,18 @@ default: simple.
\fIpolicy\fR: SHA3_224, SHA3_256, SHA3_384, SHA3_512.
.br
default: SHA3_256.
+.PP
+[autobind] will automatically bind a normal IPCP to its name and the DIF name.
.RE
.RE
.PP
-\fBirm ipcp enroll\fR name \fIname\fR dif \fIdif\fR
+\fBirm ipcp enroll\fR name \fIname\fR dif \fIdif\fR [\fIautobind\fR]
.RS 4
enrolls a normal IPCP \fIname\fR to a dif for which the IPCPs accept flows for
\fIname\fR.
+.PP
+[autobind] will automatically bind this IPCP to its name and the DIF name.
.RE
\fBirm ipcp connect\fR name \fIname\fR component \fIcomponent\fR dst
diff --git a/src/ipcpd/normal/CMakeLists.txt b/src/ipcpd/normal/CMakeLists.txt
index c84d66ce..de0cd4af 100644
--- a/src/ipcpd/normal/CMakeLists.txt
+++ b/src/ipcpd/normal/CMakeLists.txt
@@ -50,7 +50,7 @@ set(SOURCE_FILES
add_executable(ipcpd-normal ${SOURCE_FILES} ${IPCP_SOURCES}
${FLOW_ALLOC_SRCS} ${LS_PROTO_SRCS} ${KAD_PROTO_SRCS} ${ENROLL_PROTO_SRCS})
-target_link_libraries(ipcpd-normal LINK_PUBLIC ouroboros-dev ouroboros-irm)
+target_link_libraries(ipcpd-normal LINK_PUBLIC ouroboros-dev)
include(AddCompileFlags)
if (CMAKE_BUILD_TYPE MATCHES "Debug*")
diff --git a/src/ipcpd/normal/main.c b/src/ipcpd/normal/main.c
index 719be77c..772b5792 100644
--- a/src/ipcpd/normal/main.c
+++ b/src/ipcpd/normal/main.c
@@ -29,7 +29,6 @@
#include <ouroboros/errno.h>
#include <ouroboros/hash.h>
#include <ouroboros/ipcp-dev.h>
-#include <ouroboros/irm.h>
#include <ouroboros/logs.h>
#include <ouroboros/notifier.h>
#include <ouroboros/rib.h>
@@ -304,11 +303,6 @@ int main(int argc,
goto fail_init;
}
- if (irm_bind_api(getpid(), ipcpi.name)) {
- log_err("Failed to bind AP name.");
- goto fail_bind_api;
- }
-
/* These components must be init at creation. */
if (rib_init("ipcpd-normal")) {
log_err("Failed to initialize RIB.");
@@ -357,8 +351,6 @@ int main(int argc,
rib_fini();
- irm_unbind_api(getpid(), ipcpi.name);
-
ipcp_fini();
exit(EXIT_SUCCESS);
@@ -374,8 +366,6 @@ int main(int argc,
fail_connmgr_init:
rib_fini();
fail_rib_init:
- irm_unbind_api(getpid(), ipcpi.name);
- fail_bind_api:
ipcp_fini();
fail_init:
ipcp_create_r(getpid(), -1);
diff --git a/src/tools/irm/irm_ipcp_bootstrap.c b/src/tools/irm/irm_ipcp_bootstrap.c
index ddda4550..3da78a2b 100644
--- a/src/tools/irm/irm_ipcp_bootstrap.c
+++ b/src/tools/irm/irm_ipcp_bootstrap.c
@@ -90,6 +90,7 @@ static void usage(void)
" [routing <ROUTING_POLICY> (default: %s)]\n"
" [pff [PFF_POLICY] (default: %s)]\n"
" [hash [ALGORITHM] (default: %s)]\n"
+ " [autobind]\n"
"where ADDRESS_POLICY = {"FLAT_RANDOM_ADDR_AUTH"}\n"
" ROUTING_POLICY = {"LINK_STATE_ROUTING " "
LINK_STATE_LFA_ROUTING "}\n"
@@ -126,8 +127,11 @@ int do_bootstrap_ipcp(int argc, char ** argv)
pid_t * apis = NULL;
ssize_t len = 0;
int i = 0;
+ bool autobind = false;
+ int cargs;
while (argc > 0) {
+ cargs = 2;
if (matches(*argv, "type") == 0) {
ipcp_type = *(argv + 1);
} else if (matches(*argv, "dif") == 0) {
@@ -159,8 +163,10 @@ int do_bootstrap_ipcp(int argc, char ** argv)
fd_size = atoi(*(argv + 1));
} else if (matches(*argv, "ttl") == 0) {
has_ttl = true;
- argc++;
- argv--;
+ cargs = 1;
+ } else if (matches(*argv, "autobind") == 0) {
+ autobind = true;
+ cargs = 1;
} else if (matches(*argv, "addr_auth") == 0) {
if (strcmp(FLAT_RANDOM_ADDR_AUTH, *(argv + 1)) == 0)
addr_auth_type = ADDR_AUTH_FLAT_RANDOM;
@@ -186,8 +192,8 @@ int do_bootstrap_ipcp(int argc, char ** argv)
return -1;
}
- argc -= 2;
- argv += 2;
+ argc -= cargs;
+ argv += cargs;
}
if (name == NULL || dif_name == NULL || ipcp_type == NULL) {
@@ -228,6 +234,11 @@ int do_bootstrap_ipcp(int argc, char ** argv)
return -1;
}
+ if (autobind && conf.type != IPCP_NORMAL) {
+ printf("Can only bind normal IPCPs, autobind disabled.\n");
+ autobind = false;
+ }
+
len = irm_list_ipcps(name, &apis);
if (len <= 0) {
api = irm_create_ipcp(name, conf.type);
@@ -236,14 +247,31 @@ int do_bootstrap_ipcp(int argc, char ** argv)
len = irm_list_ipcps(name, &apis);
}
- for (i = 0; i < len; i++)
+ for (i = 0; i < len; i++) {
+ if (autobind && irm_bind_api(apis[i], name)) {
+ printf("Failed to bind %d to %s.\n", apis[i], name);
+ free(apis);
+ return -1;
+ }
+
+ if (autobind && irm_bind_api(apis[i], dif_name)) {
+ printf("Failed to bind %d to %s.\n", apis[i], dif_name);
+ irm_unbind_api(apis[i], name);
+ free(apis);
+ return -1;
+ }
+
if (irm_bootstrap_ipcp(apis[i], &conf)) {
+ if (autobind) {
+ irm_unbind_api(apis[i], name);
+ irm_unbind_api(apis[i], dif_name);
+ }
free(apis);
return -1;
}
+ }
- if (apis != NULL)
- free(apis);
+ free(apis);
return 0;
diff --git a/src/tools/irm/irm_ipcp_enroll.c b/src/tools/irm/irm_ipcp_enroll.c
index 1a1d0ccc..1ebe9a6d 100644
--- a/src/tools/irm/irm_ipcp_enroll.c
+++ b/src/tools/irm/irm_ipcp_enroll.c
@@ -48,31 +48,38 @@ static void usage(void)
{
printf("Usage: irm ipcp enroll\n"
" name <ipcp name>\n"
- " dif <dif to enroll in>\n");
+ " dif <dif to enroll in>\n"
+ " [autobind]\n");
}
int do_enroll_ipcp(int argc, char ** argv)
{
- char * name = NULL;
- char * dif_name = NULL;
- pid_t * apis = NULL;
- pid_t api;
- ssize_t len = 0;
- int i = 0;
+ char * name = NULL;
+ char * dif_name = NULL;
+ pid_t * apis = NULL;
+ pid_t api;
+ ssize_t len = 0;
+ int i = 0;
+ bool autobind = false;
+ int cargs;
while (argc > 0) {
+ cargs = 2;
if (matches(*argv, "name") == 0) {
name = *(argv + 1);
} else if (matches(*argv, "dif") == 0) {
dif_name = *(argv + 1);
+ } else if (matches(*argv, "autobind") == 0) {
+ autobind = true;
+ cargs = 1;
} else {
printf("\"%s\" is unknown, try \"irm "
"enroll_ipcp\".\n", *argv);
return -1;
}
- argc -= 2;
- argv += 2;
+ argc -= cargs;
+ argv += cargs;
}
if (dif_name == NULL || name == NULL) {
@@ -89,7 +96,20 @@ int do_enroll_ipcp(int argc, char ** argv)
}
for (i = 0; i < len; i++) {
+ if (autobind && irm_bind_api(apis[i], name)) {
+ free(apis);
+ return -1;
+ }
+
if (irm_enroll_ipcp(apis[i], dif_name)) {
+ if (autobind)
+ irm_unbind_api(apis[i], name);
+ free(apis);
+ return -1;
+ }
+
+ if (autobind && irm_bind_api(apis[i], dif_name)) {
+ printf("Failed to bind %d to %s.\n", apis[i], dif_name);
free(apis);
return -1;
}