From 8940fe2cc063d2de8393684ff48efec0e27edc8a Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Sat, 16 Mar 2019 15:16:21 +0100 Subject: ipcpd: Revise UDP IPCP The UDP IPCP now uses a fixed server UDP port (default 3435) for all communications. This allows passing firewalls more easily since only a single port needs to be opened. The client port can be fixed as well if needed (default random). It uses an internal eid, so the MTU of the UDP layer is reduced by 4 bytes, similar to the Ethernet IPCPs. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/tools/irm/irm_ipcp_bootstrap.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/tools/irm') diff --git a/src/tools/irm/irm_ipcp_bootstrap.c b/src/tools/irm/irm_ipcp_bootstrap.c index 259b4325..7134bf64 100644 --- a/src/tools/irm/irm_ipcp_bootstrap.c +++ b/src/tools/irm/irm_ipcp_bootstrap.c @@ -73,6 +73,8 @@ #define DEFAULT_PFF PFF_SIMPLE #define DEFAULT_HASH_ALGO DIR_HASH_SHA3_256 #define DEFAULT_ETHERTYPE 0xA000 +#define DEFAULT_CLIENT_PORT 0x0000 /* random port */ +#define DEFAULT_SERVER_PORT 0x0D6B /* 3435 */ #define FLAT_RANDOM_ADDR_AUTH "flat" #define LINK_STATE_ROUTING "link_state" @@ -106,6 +108,8 @@ static void usage(void) SHA3_384 " " SHA3_512 "}\n\n" "if TYPE == " UDP "\n" " ip \n" + " [cport (default: random)]\n" + " [sport (default: %d)]\n" " [dns " " (default: none)]\n\n" "if TYPE == " ETH_LLC "\n" @@ -126,12 +130,13 @@ static void usage(void) "if TYPE == " RAPTOR "\n" " [hash [ALGORITHM] (default: %s)]\n" "where ALGORITHM = {" SHA3_224 " " SHA3_256 " " - SHA3_384 " " SHA3_512 "}\n" + SHA3_384 " " SHA3_512 "}\n\n" "if TYPE == " BROADCAST "\n" " [autobind]\n\n", DEFAULT_ADDR_SIZE, DEFAULT_EID_SIZE, DEFAULT_TTL, FLAT_RANDOM_ADDR_AUTH, LINK_STATE_ROUTING, SIMPLE_PFF, - SHA3_256, SHA3_256, 0xA000, SHA3_256, SHA3_256, SHA3_256); + SHA3_256, DEFAULT_SERVER_PORT, SHA3_256, 0xA000, SHA3_256, + SHA3_256, SHA3_256); } int do_bootstrap_ipcp(int argc, @@ -159,6 +164,8 @@ int do_bootstrap_ipcp(int argc, int i = 0; bool autobind = false; int cargs; + int cport = DEFAULT_CLIENT_PORT; + int sport = DEFAULT_SERVER_PORT; while (argc > 0) { cargs = 2; @@ -205,6 +212,10 @@ int do_bootstrap_ipcp(int argc, eid_size = atoi(*(argv + 1)); } else if (matches(*argv, "ttl") == 0) { max_ttl = atoi(*(argv + 1)); + } else if (matches(*argv, "cport") == 0) { + cport = atoi(*(argv + 1)); + } else if (matches(*argv, "sport") == 0) { + sport = atoi(*(argv + 1)); } else if (matches(*argv, "autobind") == 0) { autobind = true; cargs = 1; @@ -318,8 +329,10 @@ int do_bootstrap_ipcp(int argc, case IPCP_UDP: if (ip_addr == 0) goto fail_usage; - conf.ip_addr = ip_addr; + conf.ip_addr = ip_addr; conf.dns_addr = dns_addr; + conf.clt_port = cport; + conf.srv_port = sport; break; case IPCP_ETH_LLC: if (dev == NULL) -- cgit v1.2.3