summaryrefslogtreecommitdiff
path: root/src/tools/irm/irm_ipcp_bootstrap.c
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2026-08-16 18:55:15 +0000
committerSander Vrijders <sander@ouroboros.rocks>2026-08-31 08:31:45 +0200
commit5c239c128c04883dbed6d66f574edf8b48d11e11 (patch)
tree6dfcc043c81bd10e1366172b9db5cf5ce93bb8d8 /src/tools/irm/irm_ipcp_bootstrap.c
parenta830ed966eb3b7d6dbcc43e42a7b6b7c5d796c6a (diff)
downloadouroboros-5c239c128c04883dbed6d66f574edf8b48d11e11.tar.gz
ouroboros-5c239c128c04883dbed6d66f574edf8b48d11e11.zip
lib: Replace shim IPCPs with points of attachment
Removes the UDP and Ethernet shim IPCPs. The unicast and broadcast IPCPs can now directly attach to a "legacy" socket. We adopt Saltzer's Point-of-Attachment terminology, also advocated in Day's "Patterns in Network Architecture". The "poa" component manages these PoA's with one management thread, one link monitoring thread and one thread per attached point. For Ethernet PoA's the irm connect and enroll can resolve the destination IPCP or Layer name with a broadcast name query over the attached PoAs (first reply wins). UDP PoA's require a destination IP address or FQDN. attach to a local endpoint (required both server and client side): irm ipcp poa attach name a udp 10.0.0.1 irm ipcp poa attach name a udp 10.0.0.1:3435 irm ipcp poa attach name a udp [::1]:3435 irm ipcp poa attach name a eth dev eth0 irm ipcp poa attach name a eth dev eth0 ethertype 0xA000 release a PoA (refused while it carries a flow): irm ipcp poa detach name a udp 10.0.0.1:3435 irm ipcp poa detach name a eth eth0 list an IPCP's PoAs: irm ipcp poa list name a connect to a peer, by name or at an address: irm ipcp connect name b dst a irm ipcp connect name b dst a eth irm ipcp connect name b dst a eth dev eth0 irm ipcp connect name b dst a udp 10.0.0.1:3435 irm ipcp connect name b dst a udp peer.example.com:3435 disconnect by peer name, no address: irm ipcp disconnect name b dst a irm ipcp disconnect name b dst a component mgmt enroll has the same shape as connect: irm ipcp enroll name b layer lr autobind irm ipcp enroll name b layer lr autobind eth dev eth0 irm ipcp enroll name b layer lr autobind udp 10.0.0.1:3435 the IRMd config file attaches PoAs and names peers the same way: udp = [ "10.0.0.1", "10.0.0.1:3436" ] eth = [ "eth0", {dev="eth1", ethertype=0xA007} ] enrol={dst="LAN", eth={dev="eth0"}} conn=[{dst="lan3", eth={}}, {dst="lan4", udp="10.0.0.1:3435"}] Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/tools/irm/irm_ipcp_bootstrap.c')
-rw-r--r--src/tools/irm/irm_ipcp_bootstrap.c148
1 files changed, 9 insertions, 139 deletions
diff --git a/src/tools/irm/irm_ipcp_bootstrap.c b/src/tools/irm/irm_ipcp_bootstrap.c
index cc8bf8fa..bbcf2312 100644
--- a/src/tools/irm/irm_ipcp_bootstrap.c
+++ b/src/tools/irm/irm_ipcp_bootstrap.c
@@ -53,10 +53,6 @@
#define UNICAST "unicast"
#define BROADCAST "broadcast"
-#define IP_UDP4 "udp4"
-#define IP_UDP6 "udp6"
-#define ETH_LLC "eth-llc"
-#define ETH_DIX "eth-dix"
#define LOCAL "local"
#define MD5 "MD5"
@@ -76,18 +72,13 @@
#define DT(x) default_dt_config.x
#define DHT(x) default_dht_config.params.x
#define UNI(x) default_uni_config.x
-#define DIX(x) eth_dix_default_conf.eth.x
-#define LLC(x) eth_llc_default_conf.eth.x
-#define UD4(x) udp4_default_conf.udp4.x
-#define UD6(x) udp6_default_conf.udp6.x
static char * usage_str = \
"Usage: irm ipcp bootstrap\n"
" name <ipcp name>\n"
" layer <layer name>\n"
" [type [TYPE]]\n"
- "where TYPE in {" UNICAST " " BROADCAST " " LOCAL " "
- IP_UDP4 " " IP_UDP6 " " ETH_LLC " " ETH_DIX "},\n\n"
+ "where TYPE in {" UNICAST " " BROADCAST " " LOCAL "},\n\n"
"if TYPE == " UNICAST "\n"
" [addr_auth <ADDRESS_POLICY> (default: %s)]\n"
" [directory <DIRECTORY_POLICY> (default: %s)]\n"
@@ -117,28 +108,6 @@ static char * usage_str = \
" [ls_t_recalc <pff recalc interval (s)> (default: %ld)]\n"
" [ls_t_update <LSA update interval (s)> (default: %ld)]\n"
" [ls_t_timeo <link timeout (s)> (default: %ld)]\n\n"
- "if TYPE == " IP_UDP4 "\n"
- " ip <IP address in dotted notation>\n"
- " [port <UDP port> (default: %d)]\n"
- " [dns <DDNS IPv4 address in dotted notation>"
- " (default: none)]\n\n"
- "if TYPE == " IP_UDP6 "\n"
- " ip <IPv6 address>\n"
- " [port <UDP port> (default: %d)]\n"
- " [dns <DDNS IPv6 address>"
- " (default: none)]\n\n"
-
- "if TYPE == " ETH_LLC "\n"
- " dev <interface name>\n"
- " [hash [ALGORITHM] (default: %s)]\n"
- "where ALGORITHM in {" SHA3_224 " " SHA3_256 " "
- SHA3_384 " " SHA3_512 "}\n\n"
- "if TYPE == " ETH_DIX "\n"
- " dev <interface name>\n"
- " [ethertype <ethertype> (default: 0x%4X)]\n"
- " [hash [ALGORITHM] (default: %s)]\n"
- "where ALGORITHM in {" SHA3_224 " " SHA3_256 " "
- SHA3_384 " " SHA3_512 "}\n\n"
"if TYPE == " LOCAL "\n"
" [hash [ALGORITHM] (default: %s)]\n"
"where ALGORITHM in {" SHA3_224 " " SHA3_256 " "
@@ -160,15 +129,6 @@ static void usage(void)
/* ls */
default_ls_config.t_recalc, default_ls_config.t_update,
default_ls_config.t_timeo,
- /* udp4 */
- UD4(port),
- /* udp6 */
- UD6(port),
- /* eth_llc */
- SHA3_256,
- /* eth_dix */
- DIX(ethertype),
- SHA3_256,
/* local */
SHA3_256,
/* broadcast */
@@ -190,19 +150,9 @@ int do_bootstrap_ipcp(int argc,
enum pol_addr_auth addr_auth_type = UNI(addr_auth_type);
enum pol_cong_avoid cong_avoid = UNI(cong_avoid);
enum pol_dir_hash hash_algo = DIR_HASH_SHA3_256;
- char * ipstr = NULL;
- char * dnsstr = NULL;
- struct in_addr ip4_addr = {.s_addr = INADDR_ANY};
- struct in_addr dns4_addr = UD4(dns_addr);
- int port4 = UD4(port);
- struct in6_addr ip6_addr = IN6ADDR_ANY_INIT;
- struct in6_addr dns6_addr = UD6(dns_addr);
- int port6 = UD6(port);
char * ipcp_type = NULL;
enum ipcp_type type = IPCP_INVALID;
char * layer = NULL;
- char * dev = NULL;
- uint16_t ethertype = DIX(ethertype);
struct ipcp_list_info * ipcps;
ssize_t len = 0;
int i = 0;
@@ -211,6 +161,14 @@ int do_bootstrap_ipcp(int argc,
while (argc > 0) {
cargs = 2;
+ if (matches(*argv, "autobind") == 0)
+ cargs = 1;
+
+ if (argc < cargs) {
+ usage();
+ return -1;
+ }
+
if (matches(*argv, "type") == 0) {
ipcp_type = *(argv + 1);
} else if (matches(*argv, "layer") == 0) {
@@ -228,24 +186,6 @@ int do_bootstrap_ipcp(int argc,
hash_algo = DIR_HASH_SHA3_512;
else
goto unknown_param;
- } else if (matches(*argv, "ip") == 0) {
- ipstr = *(argv + 1);
- } else if (matches(*argv, "dns") == 0) {
- dnsstr = *(argv + 1);
- } else if (matches(*argv, "device") == 0) {
- dev = *(argv + 1);
- } else if (matches(*argv, "ethertype") == 0) {
- /* NOTE: We might do some more checks on strtol. */
- if (matches(*(argv + 1), "0x") == 0)
- ethertype = strtol(*(argv + 1), NULL, 0);
- else
- ethertype = strtol(*(argv + 1), NULL, 16);
- if (ethertype < 0x0600 || ethertype >= 0xFFFF) {
- printf("Invalid Ethertype: \"%s\".\n"
- "Recommended range: 0xA000-0xEFFF.\n",
- *(argv + 1));
- return -1;
- }
} else if (matches(*argv, "addr") == 0) {
addr_size = atoi(*(argv + 1));
} else if (matches(*argv, "eid") == 0) {
@@ -254,9 +194,6 @@ int do_bootstrap_ipcp(int argc,
max_ttl = atoi(*(argv + 1));
} else if (matches(*argv, "rtt") == 0) {
max_rtt = atoi(*(argv + 1));
- } else if (matches(*argv, "port") == 0) {
- port4 = atoi(*(argv + 1));
- port6 = port4;
} else if (matches(*argv, "autobind") == 0) {
autobind = true;
cargs = 1;
@@ -334,55 +271,11 @@ int do_bootstrap_ipcp(int argc,
type = IPCP_UNICAST;
else if (matches(ipcp_type, BROADCAST) == 0)
type = IPCP_BROADCAST;
- else if (matches(ipcp_type, IP_UDP4) == 0)
- type = IPCP_UDP4;
- else if (matches(ipcp_type, IP_UDP6) == 0)
- type = IPCP_UDP6;
- else if (matches(ipcp_type, ETH_DIX) == 0)
- type = IPCP_ETH_DIX;
- else if (matches(ipcp_type, ETH_LLC) == 0)
- type = IPCP_ETH_LLC;
else if (matches(ipcp_type, LOCAL) == 0)
type = IPCP_LOCAL;
else goto fail_usage;
}
- if (type == IPCP_UDP4) {
- if (inet_pton (AF_INET, ipstr, &ip4_addr) != 1) {
- printf("Invalid IPv4 address: \"%s\".\n", ipstr);
- goto fail_usage;
- }
-
- if (ip4_addr.s_addr == INADDR_ANY) {
- printf("Cannot use IPv4 address: \"%s\".\n", ipstr);
- goto fail_usage;
- }
-
- if (dnsstr != NULL &&
- inet_pton(AF_INET, dnsstr, &dns4_addr) != 1) {
- printf("Invalid DNS IPv4 address: \"%s\".\n", dnsstr);
- goto fail_usage;
- }
- }
-
- if (type == IPCP_UDP6) {
- if (inet_pton(AF_INET6, ipstr, &ip6_addr) != 1) {
- printf("Invalid IPv6 address: \"%s\".\n", ipstr);
- goto fail_usage;
- }
-
- if (IN6_IS_ADDR_UNSPECIFIED(&ip6_addr)) {
- printf("Cannot use IPv6 address: \"%s\".\n", ipstr);
- goto fail_usage;
- }
-
- if (dnsstr != NULL &&
- inet_pton(AF_INET6, dnsstr, &dns6_addr) != 1) {
- printf("Invalid DNS IPv6 address: \"%s\".\n", dnsstr);
- goto fail_usage;
- }
- }
-
if (pid == -1) {
if (ipcp_type == NULL) {
printf("No IPCPs matching %s found.\n\n", ipcp);
@@ -432,29 +325,6 @@ int do_bootstrap_ipcp(int argc,
conf.unicast.cong_avoid = cong_avoid;
conf.unicast.dir = dir_config;
break;
- case IPCP_UDP4:
- conf.udp4.ip_addr = ip4_addr;
- conf.udp4.dns_addr = dns4_addr;
- conf.udp4.port = port4;
- break;
- case IPCP_UDP6:
- conf.udp6.ip_addr = ip6_addr;
- conf.udp6.dns_addr = dns6_addr;
- conf.udp6.port = port6;
- break;
- case IPCP_ETH_DIX:
- conf.eth.ethertype = ethertype;
- /* FALLTHRU */
- case IPCP_ETH_LLC:
- if (dev == NULL)
- goto fail_usage;
- if (strlen(dev) > DEV_NAME_SIZE) {
- printf("Device name too long.\n\n");
- goto fail_usage;
- }
-
- strcpy(conf.eth.dev, dev);
- break;
case IPCP_BROADCAST:
/* FALLTHRU */
case IPCP_LOCAL: