diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/ouroboros/ipcp.h | 72 | ||||
-rw-r--r-- | include/ouroboros/irm.h | 7 | ||||
-rw-r--r-- | include/ouroboros/protobuf.h | 99 | ||||
-rw-r--r-- | include/ouroboros/serdes-oep.h | 58 | ||||
-rw-r--r-- | include/ouroboros/sockets.h.in | 23 |
5 files changed, 226 insertions, 33 deletions
diff --git a/include/ouroboros/ipcp.h b/include/ouroboros/ipcp.h index 49deeffd..c4d596b2 100644 --- a/include/ouroboros/ipcp.h +++ b/include/ouroboros/ipcp.h @@ -28,6 +28,11 @@ #include <stdbool.h> #define LAYER_NAME_SIZE 255 +#define DEV_NAME_SIZE 255 + +/* Unicast IPCP components. */ +#define DT_COMP "Data Transfer" +#define MGMT_COMP "Management" /* NOTE: The IRMd uses this order to select an IPCP for flow allocation. */ enum ipcp_type { @@ -42,25 +47,29 @@ enum ipcp_type { /* Unicast IPCP policies */ enum pol_addr_auth { - ADDR_AUTH_FLAT_RANDOM = 0 + ADDR_AUTH_FLAT_RANDOM = 0, + ADDR_AUTH_INVALID }; enum pol_routing { ROUTING_LINK_STATE = 0, ROUTING_LINK_STATE_LFA, - ROUTING_LINK_STATE_ECMP + ROUTING_LINK_STATE_ECMP, + ROUTING_INVALID }; enum pol_cong_avoid { CA_NONE = 0, - CA_MB_ECN + CA_MB_ECN, + CA_INVALID }; enum pol_dir_hash { DIR_HASH_SHA3_224, DIR_HASH_SHA3_256, DIR_HASH_SHA3_384, - DIR_HASH_SHA3_512 + DIR_HASH_SHA3_512, + DIR_HASH_INVALID }; struct dt_config { @@ -78,7 +87,7 @@ struct uni_config { }; struct eth_config { - char * dev; + char dev[DEV_NAME_SIZE + 1]; uint16_t ethertype; /* DIX only*/ }; @@ -106,4 +115,57 @@ struct ipcp_config { }; }; +/* default configurations */ +static const struct ipcp_config local_default_conf = { + .type = IPCP_LOCAL, + .layer_info = { + .dir_hash_algo = DIR_HASH_SHA3_256 + } +}; + +static const struct ipcp_config eth_dix_default_conf = { + .type = IPCP_ETH_DIX, + .layer_info = { + .dir_hash_algo = DIR_HASH_SHA3_256 + }, + .eth = { + .ethertype=0xA000, + } +}; + +static const struct ipcp_config eth_llc_default_conf = { + .type = IPCP_ETH_LLC, + .layer_info = { + .dir_hash_algo = DIR_HASH_SHA3_256 + } +}; + +static const struct ipcp_config udp_default_conf = { + .type = IPCP_UDP, + .udp = { + .port = 3435 + } +}; + +static const struct ipcp_config uni_default_conf = { + .type = IPCP_UNICAST, + .layer_info = { + .dir_hash_algo = DIR_HASH_SHA3_256 + }, + .unicast = { + .dt = { + .addr_size = 4, + .eid_size = 8, + .max_ttl = 6, + .routing_type = ROUTING_LINK_STATE + }, + .addr_auth_type = ADDR_AUTH_FLAT_RANDOM, + .cong_avoid = CA_MB_ECN + } +}; + +static const struct ipcp_config bc_default_conf = { + .type = IPCP_BROADCAST +}; + #endif /* OUROBOROS_IPCP_H */ diff --git a/include/ouroboros/irm.h b/include/ouroboros/irm.h index 7cd63866..7fcf5357 100644 --- a/include/ouroboros/irm.h +++ b/include/ouroboros/irm.h @@ -29,10 +29,6 @@ #include <sys/types.h> -/* Unicast IPCP components. */ -#define DT_COMP "Data Transfer" -#define MGMT_COMP "Management" - /* Name binding options. */ #define BIND_AUTO 0x01 @@ -42,7 +38,8 @@ /* Load balancing policy for incoming flows. */ enum pol_balance { LB_RR = 0, - LB_SPILL + LB_SPILL, + LB_INVALID }; struct ipcp_info { diff --git a/include/ouroboros/protobuf.h b/include/ouroboros/protobuf.h new file mode 100644 index 00000000..edcbe4f0 --- /dev/null +++ b/include/ouroboros/protobuf.h @@ -0,0 +1,99 @@ +/* + * Ouroboros - Copyright (C) 2016 - 2023 + * + * Protobuf syntax conversion + * + * Dimitri Staessens <[email protected]> + * Sander Vrijders <[email protected]> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., http://www.fsf.org/about/contact/. + */ + +#ifndef OUROBOROS_PROTOBUF_H +#define OUROBOROS_PROTOBUF_H + +#include <ouroboros/qos.h> +#include <ouroboros/ipcp.h> +#include <ouroboros/serdes-oep.h> + +#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 "ipcpd_messages.pb-c.h" +typedef IpcpMsg ipcp_msg_t; + +#include "irmd_messages.pb-c.h" +typedef IpcpInfoMsg ipcp_info_msg_t; +typedef NameInfoMsg name_info_msg_t; + +#include "qosspec.pb-c.h" +typedef QosspecMsg qosspec_msg_t; + +#include "enroll.pb-c.h" +typedef EnrollReqMsg enroll_req_msg_t; +typedef EnrollRespMsg enroll_resp_msg_t; +typedef EnrollAckMsg enroll_ack_msg_t; + +/* IPCP configuration */ + +layer_info_msg_t * layer_info_s_to_msg(const struct layer_info * s); + +struct layer_info layer_info_msg_to_s(const layer_info_msg_t * msg); + +dt_config_msg_t * dt_config_s_to_msg(const struct dt_config * s); + +struct dt_config dt_config_msg_to_s(const dt_config_msg_t * msg); + +uni_config_msg_t * uni_config_s_to_msg(const struct uni_config * s); + +struct uni_config uni_config_msg_to_s(const uni_config_msg_t * msg); + +eth_config_msg_t * eth_config_s_to_msg(const struct eth_config * s); + +struct eth_config eth_config_msg_to_s(const eth_config_msg_t * msg); + +udp_config_msg_t * udp_config_s_to_msg(const struct udp_config * s); + +struct udp_config udp_config_msg_to_s(const udp_config_msg_t * msg); + +ipcp_config_msg_t * ipcp_config_s_to_msg(const struct ipcp_config * s); + +struct ipcp_config ipcp_config_msg_to_s(const ipcp_config_msg_t * msg); + +/* QoS */ + +qosspec_msg_t * qos_spec_s_to_msg(const struct qos_spec * s); + +struct qos_spec qos_spec_msg_to_s(const qosspec_msg_t * msg); + +/* Enrollment */ + +enroll_req_msg_t * enroll_req_s_to_msg(void); + +int enroll_req_msg_to_s(const enroll_req_msg_t * msg); + +enroll_resp_msg_t * enroll_resp_s_to_msg(const struct enroll_resp * s); + +struct enroll_resp enroll_resp_msg_to_s(enroll_resp_msg_t * msg); + +enroll_ack_msg_t * enroll_ack_s_to_msg(const int response); + +int enroll_ack_msg_to_s(const enroll_ack_msg_t * msg); + +#endif /* OUROBOROS_PROTOBUF_H */
\ No newline at end of file diff --git a/include/ouroboros/serdes-oep.h b/include/ouroboros/serdes-oep.h new file mode 100644 index 00000000..c503b31a --- /dev/null +++ b/include/ouroboros/serdes-oep.h @@ -0,0 +1,58 @@ +/* + * Ouroboros - Copyright (C) 2016 - 2023 + * + * Ouroboros Enrollment Protocol - serialization/deserialization + * + * Dimitri Staessens <[email protected]> + * Sander Vrijders <[email protected]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., http://www.fsf.org/about/contact/. + */ + +#ifndef OUROBOROS_LIB_SERDES_OEP_H +#define OUROBOROS_LIB_SERDES_OEP_H + +#include <ouroboros/ipcp.h> +#include <ouroboros/utils.h> + +#include <sys/time.h> + +/* Enrollment */ + +/* no structs yet for req and ack. TODO: authentication. */ + +struct enroll_resp { + struct timespec t; + int response; + struct ipcp_config conf; +}; + + +ssize_t enroll_req_ser(buffer_t buf); + +int enroll_req_des(const buffer_t buf); + +ssize_t enroll_resp_ser(const struct enroll_resp * resp, + buffer_t buf); + +int enroll_resp_des(struct enroll_resp * resp, + buffer_t buf); + +ssize_t enroll_ack_ser(const int response, + buffer_t buf); + +int enroll_ack_des(int * response, + const buffer_t buf); + +#endif /* OUROBOROS_LIB_SERDES_OEP_H*/
\ No newline at end of file diff --git a/include/ouroboros/sockets.h.in b/include/ouroboros/sockets.h.in index b1e714f4..8d4c2f48 100644 --- a/include/ouroboros/sockets.h.in +++ b/include/ouroboros/sockets.h.in @@ -23,28 +23,10 @@ #ifndef OUROBOROS_SOCKETS_H #define OUROBOROS_SOCKETS_H -#include <ouroboros/qos.h> - #include <sys/types.h> -#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; -typedef IpcpInfoMsg ipcp_info_msg_t; -typedef NameInfoMsg name_info_msg_t; - -#include "ipcpd_messages.pb-c.h" -typedef IpcpMsg ipcp_msg_t; - -#include "qosspec.pb-c.h" -typedef QosspecMsg qosspec_msg_t; #define SOCK_PATH "/var/run/ouroboros/" #define SOCK_PATH_SUFFIX ".sock" @@ -64,11 +46,6 @@ int client_socket_open(char * file_name); irm_msg_t * send_recv_irm_msg(irm_msg_t * msg); -/* qos message conversion needed in different components */ -qosspec_msg_t spec_to_msg(const qosspec_t * qs); - -qosspec_t msg_to_spec(const qosspec_msg_t * msg); - /* cleanup socket when cancelling thread */ void __cleanup_close_ptr(void * o); |