diff options
author | Dimitri Staessens <dimitri@ouroboros.rocks> | 2023-02-12 21:05:40 +0100 |
---|---|---|
committer | Sander Vrijders <sander@ouroboros.rocks> | 2023-02-13 21:10:11 +0100 |
commit | 269f25d3bac5ab871d8044935eacc15cfeadeec6 (patch) | |
tree | d68cba31a7a4b941658836d0c0d616fc7ec6400b /include | |
parent | c3814fa77eb7afbe6e798ded0fdff2df74ad8642 (diff) | |
download | ouroboros-269f25d3bac5ab871d8044935eacc15cfeadeec6.tar.gz ouroboros-269f25d3bac5ab871d8044935eacc15cfeadeec6.zip |
ipcpd: refactor IPCP configuration
The ipcp configuration struct now has internal structures for the
different IPCPs and for IPCP components of the unicast IPCP.
Split the very long IPCP main loop into individual handler functions.
Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks>
Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'include')
-rw-r--r-- | include/ouroboros/ipcp.h | 61 | ||||
-rw-r--r-- | include/ouroboros/sockets.h.in | 4 |
2 files changed, 38 insertions, 27 deletions
diff --git a/include/ouroboros/ipcp.h b/include/ouroboros/ipcp.h index 857f4f5d..e2ae0c0e 100644 --- a/include/ouroboros/ipcp.h +++ b/include/ouroboros/ipcp.h @@ -29,10 +29,7 @@ #define LAYER_NAME_SIZE 255 -/* - * NOTE: the IRMd uses this order to select an IPCP - * for flow allocation. - */ +/* NOTE: The IRMd uses this order to select an IPCP for flow allocation. */ enum ipcp_type { IPCP_LOCAL = 0, IPCP_UNICAST, @@ -66,6 +63,31 @@ enum pol_dir_hash { DIR_HASH_SHA3_512 }; +struct dt_config { + uint8_t addr_size; + uint8_t eid_size; + uint8_t max_ttl; + enum pol_routing routing_type; +}; + +/* IPCP configuration */ +struct uni_config { + struct dt_config dt; + enum pol_addr_auth addr_auth_type; + enum pol_cong_avoid cong_avoid; +}; + +struct eth_config { + char * dev; + uint16_t ethertype; /* DIX only*/ +}; + +struct udp_config { + uint32_t ip_addr; + uint32_t dns_addr; + uint16_t port; +}; + /* Info reported back to the IRMd about the layer on enrollment */ struct layer_info { char layer_name[LAYER_NAME_SIZE + 1]; @@ -74,29 +96,14 @@ struct layer_info { /* Structure to configure the first IPCP */ struct ipcp_config { - struct layer_info layer_info; - - enum ipcp_type type; - - /* Unicast */ - uint8_t addr_size; - uint8_t eid_size; - uint8_t max_ttl; - - enum pol_addr_auth addr_auth_type; - enum pol_routing routing_type; - enum pol_cong_avoid cong_avoid; - - /* UDP */ - uint32_t ip_addr; - uint32_t dns_addr; - uint16_t port; - - /* Ethernet */ - char * dev; - - /* Ethernet DIX */ - uint16_t ethertype; + struct layer_info layer_info; + enum ipcp_type type; + + union { + struct uni_config unicast; + struct udp_config udp; + struct eth_config eth; + }; }; #endif /* OUROBOROS_IPCP_H */ diff --git a/include/ouroboros/sockets.h.in b/include/ouroboros/sockets.h.in index 554fcc0a..b1e714f4 100644 --- a/include/ouroboros/sockets.h.in +++ b/include/ouroboros/sockets.h.in @@ -30,6 +30,10 @@ #include "ipcp_config.pb-c.h" typedef IpcpConfigMsg ipcp_config_msg_t; typedef LayerInfoMsg layer_info_msg_t; +typedef DtConfigMsg dt_config_msg_t; +typedef EthConfigMsg eth_config_msg_t; +typedef UdpConfigMsg udp_config_msg_t; +typedef UniConfigMsg uni_config_msg_t; #include "irmd_messages.pb-c.h" typedef IrmMsg irm_msg_t; |