From 3a321cc77e0f6d29167a925dd706fc36e5aa7cdd Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Sun, 27 Aug 2023 17:59:20 +0200 Subject: lib: Move protobuf definitions to pb/ directory This moves the protobuf definition in the library to a pb/ directory. Also renames the protobuf files and does a quick review of the #define guards in the include library to specify _LIB_ for internal/non-public library headers. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- include/ouroboros/bitmap.h | 6 +- include/ouroboros/crc32.h | 6 +- include/ouroboros/endian.h | 7 +-- include/ouroboros/ipcp-dev.h | 6 +- include/ouroboros/local-dev.h | 6 +- include/ouroboros/lockfile.h | 6 +- include/ouroboros/logs.h | 6 +- include/ouroboros/np1_flow.h | 6 +- include/ouroboros/protobuf.h | 12 ++-- include/ouroboros/pthread.h | 6 +- include/ouroboros/qoscube.h | 6 +- include/ouroboros/random.h | 6 +- include/ouroboros/serdes-oep.h | 1 - include/ouroboros/shm_du_buff.h | 6 +- include/ouroboros/shm_flow_set.h | 6 +- include/ouroboros/shm_rbuff.h | 6 +- include/ouroboros/shm_rdrbuff.h | 6 +- include/ouroboros/sockets.h.in | 8 +-- include/ouroboros/time_utils.h | 6 +- include/ouroboros/utils.h | 6 +- src/ipcpd/common/enroll.c | 1 - src/ipcpd/unicast/CMakeLists.txt | 4 +- src/ipcpd/unicast/dir/dht.c | 62 ++++++++++---------- src/ipcpd/unicast/dir/dht.proto | 45 +++++++++++++++ src/ipcpd/unicast/dir/kademlia.proto | 45 --------------- src/ipcpd/unicast/dir/tests/CMakeLists.txt | 5 +- src/lib/CMakeLists.txt | 12 ++-- src/lib/cacep.proto | 39 ------------- src/lib/enroll.proto | 42 -------------- src/lib/ipcp_config.proto | 60 -------------------- src/lib/ipcpd_messages.proto | 58 ------------------- src/lib/irmd_messages.proto | 91 ------------------------------ src/lib/pb/cacep.proto | 39 +++++++++++++ src/lib/pb/enroll.proto | 42 ++++++++++++++ src/lib/pb/ipcp.proto | 58 +++++++++++++++++++ src/lib/pb/ipcp_config.proto | 60 ++++++++++++++++++++ src/lib/pb/irm.proto | 91 ++++++++++++++++++++++++++++++ src/lib/pb/qos.proto | 35 ++++++++++++ src/lib/qosspec.proto | 35 ------------ 39 files changed, 472 insertions(+), 476 deletions(-) create mode 100644 src/ipcpd/unicast/dir/dht.proto delete mode 100644 src/ipcpd/unicast/dir/kademlia.proto delete mode 100644 src/lib/cacep.proto delete mode 100644 src/lib/enroll.proto delete mode 100644 src/lib/ipcp_config.proto delete mode 100644 src/lib/ipcpd_messages.proto delete mode 100644 src/lib/irmd_messages.proto create mode 100644 src/lib/pb/cacep.proto create mode 100644 src/lib/pb/enroll.proto create mode 100644 src/lib/pb/ipcp.proto create mode 100644 src/lib/pb/ipcp_config.proto create mode 100644 src/lib/pb/irm.proto create mode 100644 src/lib/pb/qos.proto delete mode 100644 src/lib/qosspec.proto diff --git a/include/ouroboros/bitmap.h b/include/ouroboros/bitmap.h index 0bbd510c..9c395811 100644 --- a/include/ouroboros/bitmap.h +++ b/include/ouroboros/bitmap.h @@ -20,8 +20,8 @@ * Foundation, Inc., http://www.fsf.org/about/contact/. */ -#ifndef OUROBOROS_BITMAP_H -#define OUROBOROS_BITMAP_H +#ifndef OUROBOROS_LIB_BITMAP_H +#define OUROBOROS_LIB_BITMAP_H #include #include @@ -45,4 +45,4 @@ bool bmp_is_id_valid(struct bmp * bmp, bool bmp_is_id_used(struct bmp * bmp, ssize_t id); -#endif /* OUROBOROS_BITMAP_H */ +#endif /* OUROBOROS_LIB_BITMAP_H */ diff --git a/include/ouroboros/crc32.h b/include/ouroboros/crc32.h index 1c053834..b7fb9deb 100644 --- a/include/ouroboros/crc32.h +++ b/include/ouroboros/crc32.h @@ -20,8 +20,8 @@ * Foundation, Inc., http://www.fsf.org/about/contact/. */ -#ifndef OUROBOROS_CRC32_H -#define OUROBOROS_CRC32_H +#ifndef OUROBOROS_LIB_CRC32_H +#define OUROBOROS_LIB_CRC32_H #include #include @@ -32,4 +32,4 @@ void crc32(uint32_t * crc, const void * buf, size_t len); -#endif /* OUROBOROS_CRC32_H */ +#endif /* OUROBOROS_LIB_CRC32_H */ diff --git a/include/ouroboros/endian.h b/include/ouroboros/endian.h index 667ccb07..d4fb767a 100644 --- a/include/ouroboros/endian.h +++ b/include/ouroboros/endian.h @@ -20,9 +20,8 @@ * Foundation, Inc., http://www.fsf.org/about/contact/. */ -#ifndef OUROBOROS_ENDIAN_H -#define OUROBOROS_ENDIAN_H - +#ifndef OUROBOROS_LIB_ENDIAN_H +#define OUROBOROS_LIB_ENDIAN_H #if defined(__linux__) || defined(__CYGWIN__) || \ (defined(__MACH__) && !defined(__APPLE__)) @@ -73,4 +72,4 @@ #define hton16(x) htobe16(x) #define ntoh16(x) betoh16(x) -#endif /* OUROBOROS_ENDIAN_H */ +#endif /* OUROBOROS_LIB_ENDIAN_H */ diff --git a/include/ouroboros/ipcp-dev.h b/include/ouroboros/ipcp-dev.h index d332a2e0..f07d609b 100644 --- a/include/ouroboros/ipcp-dev.h +++ b/include/ouroboros/ipcp-dev.h @@ -23,8 +23,8 @@ #include #include -#ifndef OUROBOROS_IPCP_DEV_H -#define OUROBOROS_IPCP_DEV_H +#ifndef OUROBOROS_LIB_IPCP_DEV_H +#define OUROBOROS_LIB_IPCP_DEV_H int ipcp_create_r(int result); @@ -65,4 +65,4 @@ int ipcp_sdb_reserve(struct shm_du_buff ** sdb, void ipcp_sdb_release(struct shm_du_buff * sdb); -#endif /* OUROBOROS_IPCP_DEV_H */ +#endif /* OUROBOROS_LIB_IPCP_DEV_H */ diff --git a/include/ouroboros/local-dev.h b/include/ouroboros/local-dev.h index ca3d9b10..c79a13a3 100644 --- a/include/ouroboros/local-dev.h +++ b/include/ouroboros/local-dev.h @@ -20,12 +20,12 @@ * Foundation, Inc., http://www.fsf.org/about/contact/. */ -#ifndef OUROBOROS_LOCAL_DEV_H -#define OUROBOROS_LOCAL_DEV_H +#ifndef OUROBOROS_LIB_LOCAL_DEV_H +#define OUROBOROS_LIB_LOCAL_DEV_H ssize_t local_flow_read(int fd); int local_flow_write(int fd, size_t idx); -#endif /* OUROBOROS_LOCAL_DEV_H */ +#endif /* OUROBOROS_LIB_LOCAL_DEV_H */ diff --git a/include/ouroboros/lockfile.h b/include/ouroboros/lockfile.h index e09a8bf2..7652d6cc 100644 --- a/include/ouroboros/lockfile.h +++ b/include/ouroboros/lockfile.h @@ -20,8 +20,8 @@ * Foundation, Inc., http://www.fsf.org/about/contact/. */ -#ifndef OUROBOROS_LOCKFILE_H -#define OUROBOROS_LOCKFILE_H +#ifndef OUROBOROS_LIB_LOCKFILE_H +#define OUROBOROS_LIB_LOCKFILE_H #include @@ -37,4 +37,4 @@ void lockfile_destroy(struct lockfile * lf); pid_t lockfile_owner(struct lockfile * lf); -#endif /* OUROBOROS_LOCKFILE_H */ +#endif /* OUROBOROS_LIB_LOCKFILE_H */ diff --git a/include/ouroboros/logs.h b/include/ouroboros/logs.h index 479cae4a..331f38a9 100644 --- a/include/ouroboros/logs.h +++ b/include/ouroboros/logs.h @@ -20,8 +20,8 @@ * Foundation, Inc., http://www.fsf.org/about/contact/. */ -#ifndef OUROBOROS_LOGS_H -#define OUROBOROS_LOGS_H +#ifndef OUROBOROS_LIB_LOGS_H +#define OUROBOROS_LIB_LOGS_H #ifndef OUROBOROS_PREFIX #error You must define OUROBOROS_PREFIX before including this file @@ -103,4 +103,4 @@ void log_fini(void); #define log_dbg_id(...) do { } while (0) #endif -#endif /* OUROBOROS_LOGS_H */ +#endif /* OUROBOROS_LIB_LOGS_H */ diff --git a/include/ouroboros/np1_flow.h b/include/ouroboros/np1_flow.h index a613441d..65606fca 100644 --- a/include/ouroboros/np1_flow.h +++ b/include/ouroboros/np1_flow.h @@ -20,8 +20,8 @@ * Foundation, Inc., http://www.fsf.org/about/contact/. */ -#ifndef OUROBOROS_NP1_FLOW_H -#define OUROBOROS_NP1_FLOW_H +#ifndef OUROBOROS_LIB_NP1_FLOW_H +#define OUROBOROS_LIB_NP1_FLOW_H #include @@ -47,4 +47,4 @@ static const qosspec_t qos_np1 = { .timeout = 0 }; -#endif /* OUROBOROS_NP1_FLOW_H */ +#endif /* OUROBOROS_LIB_NP1_FLOW_H */ diff --git a/include/ouroboros/protobuf.h b/include/ouroboros/protobuf.h index bb802148..c20ad8ca 100644 --- a/include/ouroboros/protobuf.h +++ b/include/ouroboros/protobuf.h @@ -20,8 +20,8 @@ * Foundation, Inc., http://www.fsf.org/about/contact/. */ -#ifndef OUROBOROS_PROTOBUF_H -#define OUROBOROS_PROTOBUF_H +#ifndef OUROBOROS_LIB_PROTOBUF_H +#define OUROBOROS_LIB_PROTOBUF_H #include #include @@ -35,14 +35,14 @@ typedef EthConfigMsg eth_config_msg_t; typedef UdpConfigMsg udp_config_msg_t; typedef UniConfigMsg uni_config_msg_t; -#include "ipcpd_messages.pb-c.h" +#include "ipcp.pb-c.h" typedef IpcpMsg ipcp_msg_t; -#include "irmd_messages.pb-c.h" +#include "irm.pb-c.h" typedef IpcpInfoMsg ipcp_info_msg_t; typedef NameInfoMsg name_info_msg_t; -#include "qosspec.pb-c.h" +#include "qos.pb-c.h" typedef QosspecMsg qosspec_msg_t; #include "enroll.pb-c.h" @@ -96,4 +96,4 @@ enroll_ack_msg_t * enroll_ack_s_to_msg(const struct enroll_ack * s); struct enroll_ack enroll_ack_msg_to_s(const enroll_ack_msg_t * msg); -#endif /* OUROBOROS_PROTOBUF_H */ \ No newline at end of file +#endif /* OUROBOROS_LIB_PROTOBUF_H */ \ No newline at end of file diff --git a/include/ouroboros/pthread.h b/include/ouroboros/pthread.h index b7516373..917c078b 100644 --- a/include/ouroboros/pthread.h +++ b/include/ouroboros/pthread.h @@ -20,8 +20,8 @@ * Foundation, Inc., http://www.fsf.org/about/contact/. */ -#ifndef OUROBOROS_PTHREAD_H -#define OUROBOROS_PTHREAD_H +#ifndef OUROBOROS_LIB_PTHREAD_H +#define OUROBOROS_LIB_PTHREAD_H #include @@ -36,4 +36,4 @@ static void __attribute__((unused)) __cleanup_mutex_unlock(void * mutex) pthread_mutex_unlock((pthread_mutex_t *) mutex); } -#endif /* OUROBOROS_PTHREAD_H */ +#endif /* OUROBOROS_LIB_PTHREAD_H */ diff --git a/include/ouroboros/qoscube.h b/include/ouroboros/qoscube.h index 93c0480c..76de7d02 100644 --- a/include/ouroboros/qoscube.h +++ b/include/ouroboros/qoscube.h @@ -20,8 +20,8 @@ * Foundation, Inc., http://www.fsf.org/about/contact/. */ -#ifndef OUROBOROS_QOSCUBE_H -#define OUROBOROS_QOSCUBE_H +#ifndef OUROBOROS_LIB_QOSCUBE_H +#define OUROBOROS_LIB_QOSCUBE_H #include @@ -35,4 +35,4 @@ typedef enum qos_cube { qoscube_t qos_spec_to_cube(qosspec_t qs); qosspec_t qos_cube_to_spec(qoscube_t qc); -#endif +#endif /* OUROBOROS_LIB_QOSCUBE_H */ diff --git a/include/ouroboros/random.h b/include/ouroboros/random.h index bf962271..fd74f9be 100644 --- a/include/ouroboros/random.h +++ b/include/ouroboros/random.h @@ -20,12 +20,12 @@ * Foundation, Inc., http://www.fsf.org/about/contact/. */ -#ifndef OUROBOROS_RANDOM_H -#define OUROBOROS_RANDOM_H +#ifndef OUROBOROS_LIB_RANDOM_H +#define OUROBOROS_LIB_RANDOM_H #include int random_buffer(void * buf, size_t len); -#endif /* OUROBOROS_RANDOM_H */ +#endif /* OUROBOROS_LIB_RANDOM_H */ diff --git a/include/ouroboros/serdes-oep.h b/include/ouroboros/serdes-oep.h index 4409b047..e36b8fe5 100644 --- a/include/ouroboros/serdes-oep.h +++ b/include/ouroboros/serdes-oep.h @@ -49,7 +49,6 @@ struct enroll_ack { int result; }; - ssize_t enroll_req_ser(const struct enroll_req * req, buffer_t buf); diff --git a/include/ouroboros/shm_du_buff.h b/include/ouroboros/shm_du_buff.h index 000a6e46..33676a3c 100644 --- a/include/ouroboros/shm_du_buff.h +++ b/include/ouroboros/shm_du_buff.h @@ -20,8 +20,8 @@ * Foundation, Inc., http://www.fsf.org/about/contact/. */ -#ifndef OUROBOROS_SHM_DU_BUFF_H -#define OUROBOROS_SHM_DU_BUFF_H +#ifndef OUROBOROS_LIB_SHM_DU_BUFF_H +#define OUROBOROS_LIB_SHM_DU_BUFF_H #include #include @@ -55,4 +55,4 @@ int shm_du_buff_wait_ack(struct shm_du_buff * sdb); int shm_du_buff_ack(struct shm_du_buff * sdb); -#endif /* OUROBOROS_SHM_DU_BUFF_H */ +#endif /* OUROBOROS_LIB_SHM_DU_BUFF_H */ diff --git a/include/ouroboros/shm_flow_set.h b/include/ouroboros/shm_flow_set.h index 946678f3..7b133c4e 100644 --- a/include/ouroboros/shm_flow_set.h +++ b/include/ouroboros/shm_flow_set.h @@ -20,8 +20,8 @@ * Foundation, Inc., http://www.fsf.org/about/contact/. */ -#ifndef OUROBOROS_SHM_FLOW_SET_H -#define OUROBOROS_SHM_FLOW_SET_H +#ifndef OUROBOROS_LIB_SHM_FLOW_SET_H +#define OUROBOROS_LIB_SHM_FLOW_SET_H #include @@ -66,4 +66,4 @@ ssize_t shm_flow_set_wait(const struct shm_flow_set * shm_set, struct portevent * fqueue, const struct timespec * abstime); -#endif /* OUROBOROS_SHM_FLOW_SET_H */ +#endif /* OUROBOROS_LIB_SHM_FLOW_SET_H */ diff --git a/include/ouroboros/shm_rbuff.h b/include/ouroboros/shm_rbuff.h index 331d76fe..cb39babb 100644 --- a/include/ouroboros/shm_rbuff.h +++ b/include/ouroboros/shm_rbuff.h @@ -20,8 +20,8 @@ * Foundation, Inc., http://www.fsf.org/about/contact/. */ -#ifndef OUROBOROS_SHM_RBUFF_H -#define OUROBOROS_SHM_RBUFF_H +#ifndef OUROBOROS_LIB_SHM_RBUFF_H +#define OUROBOROS_LIB_SHM_RBUFF_H #include #include @@ -66,4 +66,4 @@ ssize_t shm_rbuff_read_b(struct shm_rbuff * rb, size_t shm_rbuff_queued(struct shm_rbuff * rb); -#endif /* OUROBOROS_SHM_RBUFF_H */ +#endif /* OUROBOROS_LIB_SHM_RBUFF_H */ diff --git a/include/ouroboros/shm_rdrbuff.h b/include/ouroboros/shm_rdrbuff.h index 91516cfd..8cd737f5 100644 --- a/include/ouroboros/shm_rdrbuff.h +++ b/include/ouroboros/shm_rdrbuff.h @@ -20,8 +20,8 @@ * Foundation, Inc., http://www.fsf.org/about/contact/. */ -#ifndef OUROBOROS_SHM_RDRBUFF_H -#define OUROBOROS_SHM_RDRBUFF_H +#ifndef OUROBOROS_LIB_SHM_RDRBUFF_H +#define OUROBOROS_LIB_SHM_RDRBUFF_H #include #include @@ -64,4 +64,4 @@ struct shm_du_buff * shm_rdrbuff_get(struct shm_rdrbuff * rdrb, int shm_rdrbuff_remove(struct shm_rdrbuff * rdrb, size_t idx); -#endif /* OUROBOROS_SHM_RDRBUFF_H */ +#endif /* OUROBOROS_LIB_SHM_RDRBUFF_H */ diff --git a/include/ouroboros/sockets.h.in b/include/ouroboros/sockets.h.in index 8d4c2f48..2dd3becf 100644 --- a/include/ouroboros/sockets.h.in +++ b/include/ouroboros/sockets.h.in @@ -20,12 +20,12 @@ * Foundation, Inc., http://www.fsf.org/about/contact/. */ -#ifndef OUROBOROS_SOCKETS_H -#define OUROBOROS_SOCKETS_H +#ifndef OUROBOROS_LIB_SOCKETS_H +#define OUROBOROS_LIB_SOCKETS_H #include -#include "irmd_messages.pb-c.h" +#include "irm.pb-c.h" typedef IrmMsg irm_msg_t; #define SOCK_PATH "/var/run/ouroboros/" @@ -49,4 +49,4 @@ irm_msg_t * send_recv_irm_msg(irm_msg_t * msg); /* cleanup socket when cancelling thread */ void __cleanup_close_ptr(void * o); -#endif +#endif /* OUROBOROS_LIB_SOCKETS_H */ diff --git a/include/ouroboros/time_utils.h b/include/ouroboros/time_utils.h index bd49e9d1..5b8583ef 100644 --- a/include/ouroboros/time_utils.h +++ b/include/ouroboros/time_utils.h @@ -20,8 +20,8 @@ * Foundation, Inc., http://www.fsf.org/about/contact/. */ -#ifndef OUROBOROS_TIME_UTILS_H -#define OUROBOROS_TIME_UTILS_H +#ifndef OUROBOROS_LIB_TIME_UTILS_H +#define OUROBOROS_LIB_TIME_UTILS_H #ifdef MILLION #undef MILLION @@ -118,4 +118,4 @@ (tv)->tv_usec = (ts)->tv_nsec / 1000L; \ } while (0); -#endif /* OUROBOROS_TIME_UTILS_H */ +#endif /* OUROBOROS_LIB_TIME_UTILS_H */ diff --git a/include/ouroboros/utils.h b/include/ouroboros/utils.h index be345c19..9ee81c92 100644 --- a/include/ouroboros/utils.h +++ b/include/ouroboros/utils.h @@ -20,8 +20,8 @@ * Foundation, Inc., http://www.fsf.org/about/contact/. */ -#ifndef OUROBOROS_UTILS_H -#define OUROBOROS_UTILS_H +#ifndef OUROBOROS_LIB_UTILS_H +#define OUROBOROS_LIB_UTILS_H #include #include @@ -57,4 +57,4 @@ char * path_strip(const char * src); free(ptr); \ } while (0); -#endif /* OUROBOROS_UTILS_H */ +#endif /* OUROBOROS_LIB_UTILS_H */ diff --git a/src/ipcpd/common/enroll.c b/src/ipcpd/common/enroll.c index 4cc2fa42..eeff391a 100644 --- a/src/ipcpd/common/enroll.c +++ b/src/ipcpd/common/enroll.c @@ -133,7 +133,6 @@ static void * enroll_handle(void * o) if (len < 0) { log_err_id(req.id, "Failed to read from flow."); goto finish_enroll; - } msg.data = buf.data; diff --git a/src/ipcpd/unicast/CMakeLists.txt b/src/ipcpd/unicast/CMakeLists.txt index c87a58c4..ca742871 100644 --- a/src/ipcpd/unicast/CMakeLists.txt +++ b/src/ipcpd/unicast/CMakeLists.txt @@ -16,7 +16,7 @@ set(IPCP_UNICAST_TARGET ipcpd-unicast CACHE INTERNAL "") set(IPCP_UNICAST_MPL 60 CACHE STRING "Default maximum packet lifetime for the unicast IPCP, in seconds") -protobuf_generate_c(KAD_PROTO_SRCS KAD_PROTO_HDRS dir/kademlia.proto) +protobuf_generate_c(DHT_PROTO_SRCS DHT_PROTO_HDRS dir/dht.proto) math(EXPR PFT_EXPR "1 << 12") set(PFT_SIZE ${PFT_EXPR} CACHE STRING @@ -57,7 +57,7 @@ set(SOURCE_FILES ) add_executable(ipcpd-unicast ${SOURCE_FILES} ${IPCP_SOURCES} ${COMMON_SOURCES} - ${KAD_PROTO_SRCS} ${LAYER_CONFIG_PROTO_SRCS}) + ${DHT_PROTO_SRCS} ${LAYER_CONFIG_PROTO_SRCS}) target_link_libraries(ipcpd-unicast LINK_PUBLIC ouroboros-dev) include(AddCompileFlags) diff --git a/src/ipcpd/unicast/dir/dht.c b/src/ipcpd/unicast/dir/dht.c index adc6feb2..7e4bd474 100644 --- a/src/ipcpd/unicast/dir/dht.c +++ b/src/ipcpd/unicast/dir/dht.c @@ -57,9 +57,9 @@ #include #include -#include "kademlia.pb-c.h" -typedef KadMsg kad_msg_t; -typedef KadContactMsg kad_contact_msg_t; +#include "dht.pb-c.h" +typedef DhtMsg dht_msg_t; +typedef DhtContactMsg dht_contact_msg_t; #ifndef CLOCK_REALTIME_COARSE #define CLOCK_REALTIME_COARSE CLOCK_REALTIME @@ -354,7 +354,7 @@ static uint8_t * create_id(size_t len) } static void kad_req_create(struct dht * dht, - kad_msg_t * msg, + dht_msg_t * msg, uint64_t addr) { struct kad_req * req; @@ -793,7 +793,7 @@ static void lookup_destroy(struct lookup * lu) static void lookup_update(struct dht * dht, struct lookup * lu, - kad_msg_t * msg) + dht_msg_t * msg) { struct list_head * p = NULL; struct list_head * h; @@ -1027,7 +1027,7 @@ static enum lookup_state lookup_wait(struct lookup * lu) } static struct kad_req * dht_find_request(struct dht * dht, - kad_msg_t * msg) + dht_msg_t * msg) { struct list_head * p; @@ -1464,7 +1464,7 @@ static int dht_update_bucket(struct dht * dht, } static int send_msg(struct dht * dht, - kad_msg_t * msg, + dht_msg_t * msg, uint64_t addr) { #ifndef __DHT_TEST__ @@ -1497,7 +1497,7 @@ static int send_msg(struct dht * dht, pthread_rwlock_unlock(&dht->lock); #ifndef __DHT_TEST__ - len = kad_msg__get_packed_size(msg); + len = dht_msg__get_packed_size(msg); if (len == 0) goto fail_msg; @@ -1505,7 +1505,7 @@ static int send_msg(struct dht * dht, if (ipcp_sdb_reserve(&sdb, len)) goto fail_msg; - kad_msg__pack(msg, shm_du_buff_head(sdb)); + dht_msg__pack(msg, shm_du_buff_head(sdb)); if (dt_write_packet(addr, QOS_CUBE_BE, dht->eid, sdb) == 0) break; @@ -1552,7 +1552,7 @@ static struct dht_entry * dht_find_entry(struct dht * dht, } static int kad_add(struct dht * dht, - const kad_contact_msg_t * contacts, + const dht_contact_msg_t * contacts, ssize_t n, time_t exp) { @@ -1591,7 +1591,7 @@ static int kad_add(struct dht * dht, } static int wait_resp(struct dht * dht, - kad_msg_t * msg, + dht_msg_t * msg, time_t timeo) { struct kad_req * req; @@ -1618,9 +1618,9 @@ static int kad_store(struct dht * dht, uint64_t r_addr, time_t ttl) { - kad_msg_t msg = KAD_MSG__INIT; - kad_contact_msg_t cmsg = KAD_CONTACT_MSG__INIT; - kad_contact_msg_t * cmsgp[1]; + dht_msg_t msg = DHT_MSG__INIT; + dht_contact_msg_t cmsg = DHT_CONTACT_MSG__INIT; + dht_contact_msg_t * cmsgp[1]; cmsg.id.data = (uint8_t *) key; cmsg.addr = addr; @@ -1650,7 +1650,7 @@ static ssize_t kad_find(struct dht * dht, const uint64_t * addrs, enum kad_code code) { - kad_msg_t msg = KAD_MSG__INIT; + dht_msg_t msg = DHT_MSG__INIT; ssize_t sent = 0; assert(dht); @@ -1790,7 +1790,7 @@ static void kad_publish(struct dht * dht, while (n-- > 0) { if (addrs[n] == dht->addr) { - kad_contact_msg_t msg = KAD_CONTACT_MSG__INIT; + dht_contact_msg_t msg = DHT_CONTACT_MSG__INIT; msg.id.data = (uint8_t *) key; msg.id.len = dht->b; msg.addr = addr; @@ -1809,7 +1809,7 @@ static void kad_publish(struct dht * dht, static int kad_join(struct dht * dht, uint64_t addr) { - kad_msg_t msg = KAD_MSG__INIT; + dht_msg_t msg = DHT_MSG__INIT; msg.code = KAD_JOIN; @@ -1944,7 +1944,7 @@ static buffer_t dht_retrieve(struct dht * dht, static ssize_t dht_get_contacts(struct dht * dht, const uint8_t * key, - kad_contact_msg_t *** msgs) + dht_contact_msg_t *** msgs) { struct list_head l; struct list_head * p; @@ -1981,7 +1981,7 @@ static ssize_t dht_get_contacts(struct dht * dht, return 0; } - kad_contact_msg__init((*msgs)[i]); + dht_contact_msg__init((*msgs)[i]); (*msgs)[i]->id.data = c->id; (*msgs)[i]->id.len = dht->b; @@ -2118,7 +2118,7 @@ static void * work(void * o) static int kad_handle_join_resp(struct dht * dht, struct kad_req * req, - kad_msg_t * msg) + dht_msg_t * msg) { assert(dht); assert(req); @@ -2178,7 +2178,7 @@ static int kad_handle_join_resp(struct dht * dht, static int kad_handle_find_resp(struct dht * dht, struct kad_req * req, - kad_msg_t * msg) + dht_msg_t * msg) { struct lookup * lu; @@ -2202,7 +2202,7 @@ static int kad_handle_find_resp(struct dht * dht, } static void kad_handle_response(struct dht * dht, - kad_msg_t * msg) + dht_msg_t * msg) { struct kad_req * req; @@ -2440,9 +2440,9 @@ static void * dht_handle_packet(void * o) assert(dht); while (true) { - kad_msg_t * msg; - kad_contact_msg_t ** cmsgs; - kad_msg_t resp_msg = KAD_MSG__INIT; + dht_msg_t * msg; + dht_contact_msg_t ** cmsgs; + dht_msg_t resp_msg = DHT_MSG__INIT; uint64_t addr; buffer_t buf; size_t i; @@ -2464,7 +2464,7 @@ static void * dht_handle_packet(void * o) i = shm_du_buff_len(cmd->sdb); - msg = kad_msg__unpack(NULL, i, shm_du_buff_head(cmd->sdb)); + msg = dht_msg__unpack(NULL, i, shm_du_buff_head(cmd->sdb)); #ifndef __DHT_TEST__ ipcp_sdb_release(cmd->sdb); #endif @@ -2476,7 +2476,7 @@ static void * dht_handle_packet(void * o) } if (msg->code != KAD_RESPONSE && dht_wait_running(dht)) { - kad_msg__free_unpacked(msg, NULL); + dht_msg__free_unpacked(msg, NULL); log_dbg("Got a request message when not running."); continue; } @@ -2489,13 +2489,13 @@ static void * dht_handle_packet(void * o) pthread_rwlock_unlock(&dht->lock); if (msg->has_key && msg->key.len != b) { - kad_msg__free_unpacked(msg, NULL); + dht_msg__free_unpacked(msg, NULL); log_warn("Bad key in message."); continue; } if (msg->has_s_id && !msg->has_b && msg->s_id.len != b) { - kad_msg__free_unpacked(msg, NULL); + dht_msg__free_unpacked(msg, NULL); log_warn("Bad source ID in message of type %d.", msg->code); continue; @@ -2596,7 +2596,7 @@ static void * dht_handle_packet(void * o) log_warn("Failed to send response."); finish: - kad_msg__free_unpacked(msg, NULL); + dht_msg__free_unpacked(msg, NULL); if (resp_msg.n_addrs > 0) free(resp_msg.addrs); @@ -2607,7 +2607,7 @@ static void * dht_handle_packet(void * o) } for (i = 0; i < resp_msg.n_contacts; ++i) - kad_contact_msg__free_unpacked(resp_msg.contacts[i], + dht_contact_msg__free_unpacked(resp_msg.contacts[i], NULL); free(resp_msg.contacts); diff --git a/src/ipcpd/unicast/dir/dht.proto b/src/ipcpd/unicast/dir/dht.proto new file mode 100644 index 00000000..e1063384 --- /dev/null +++ b/src/ipcpd/unicast/dir/dht.proto @@ -0,0 +1,45 @@ +/* + * Ouroboros - Copyright (C) 2016 - 2023 + * + * DHT protocol, based on Kademlia + * + * Dimitri Staessens + * Sander Vrijders + * + * 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/. + */ + +syntax = "proto2"; + +message dht_contact_msg { + required bytes id = 1; + required uint64 addr = 2; +} + +message dht_msg { + required uint32 code = 1; + required uint32 cookie = 2; + required uint64 s_addr = 3; + optional bytes s_id = 4; + optional bytes key = 5; + repeated uint64 addrs = 6; + repeated dht_contact_msg contacts = 7; + // enrolment parameters + optional uint32 alpha = 8; + optional uint32 b = 9; + optional uint32 k = 10; + optional uint32 t_expire = 11; + optional uint32 t_refresh = 12; + optional uint32 t_replicate = 13; +} \ No newline at end of file diff --git a/src/ipcpd/unicast/dir/kademlia.proto b/src/ipcpd/unicast/dir/kademlia.proto deleted file mode 100644 index 1cd890af..00000000 --- a/src/ipcpd/unicast/dir/kademlia.proto +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Ouroboros - Copyright (C) 2016 - 2023 - * - * KAD protocol - * - * Dimitri Staessens - * Sander Vrijders - * - * 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/. - */ - -syntax = "proto2"; - -message kad_contact_msg { - required bytes id = 1; - required uint64 addr = 2; -} - -message kad_msg { - required uint32 code = 1; - required uint32 cookie = 2; - required uint64 s_addr = 3; - optional bytes s_id = 4; - optional bytes key = 5; - repeated uint64 addrs = 6; - repeated kad_contact_msg contacts = 7; - // enrolment parameters - optional uint32 alpha = 8; - optional uint32 b = 9; - optional uint32 k = 10; - optional uint32 t_expire = 11; - optional uint32 t_refresh = 12; - optional uint32 t_replicate = 13; -} \ No newline at end of file diff --git a/src/ipcpd/unicast/dir/tests/CMakeLists.txt b/src/ipcpd/unicast/dir/tests/CMakeLists.txt index 482711d5..c850e41d 100644 --- a/src/ipcpd/unicast/dir/tests/CMakeLists.txt +++ b/src/ipcpd/unicast/dir/tests/CMakeLists.txt @@ -20,10 +20,9 @@ create_test_sourcelist(${PARENT_DIR}_tests test_suite.c dht_test.c ) -protobuf_generate_c(KAD_PROTO_SRCS KAD_PROTO_HDRS ../kademlia.proto) - +protobuf_generate_c(DHT_PROTO_SRCS KAD_PROTO_HDRS ../dht.proto) add_executable(${PARENT_DIR}_test EXCLUDE_FROM_ALL ${${PARENT_DIR}_tests} - ${KAD_PROTO_SRCS}) + ${DHT_PROTO_SRCS}) target_link_libraries(${PARENT_DIR}_test ouroboros-common) add_dependencies(check ${PARENT_DIR}_test) diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index ac5367ab..b75fd0e0 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -5,17 +5,17 @@ include_directories(${CMAKE_SOURCE_DIR}/include) include_directories(${CMAKE_BINARY_DIR}/include) protobuf_generate_c(QOSSPEC_PROTO_SRCS QOSSPEC_PROTO_HDRS - qosspec.proto) + pb/qos.proto) protobuf_generate_c(IPCP_CONFIG_PROTO_SRCS IPCP_CONFIG_PROTO_HDRS - ipcp_config.proto) + pb/ipcp_config.proto) protobuf_generate_c(ENROLL_PROTO_SRCS ENROLL_PROTO_HDRS - enroll.proto) + pb/enroll.proto) protobuf_generate_c(CACEP_PROTO_SRCS CACEP_PROTO_HDRS - cacep.proto) + pb/cacep.proto) protobuf_generate_c(IRM_PROTO_SRCS IRM_PROTO_HDRS - irmd_messages.proto) + pb/irm.proto) protobuf_generate_c(IPCP_PROTO_SRCS IPCP_PROTO_HDRS - ipcpd_messages.proto) + pb/ipcp.proto) if (NOT APPLE) find_library(LIBRT_LIBRARIES rt) diff --git a/src/lib/cacep.proto b/src/lib/cacep.proto deleted file mode 100644 index 5d735e33..00000000 --- a/src/lib/cacep.proto +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Ouroboros - Copyright (C) 2016 - 2023 - * - * Message for Connection Information in CACEP - * - * Dimitri Staessens - * Sander Vrijders - * - * 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/. - */ - -syntax = "proto2"; - -message fixed_conc_syntax_msg { - repeated uint32 fids = 1; - repeated uint32 lens = 2; -} - -message cacep_msg { - required string comp_name = 1; - required string protocol = 2; - required int32 pref_version = 3; - repeated int32 supp_version = 4; - required int32 pref_syntax = 5; - repeated int32 supp_syntax = 6; - optional fixed_conc_syntax_msg syntax_spec = 7; - required uint64 address = 8; -} \ No newline at end of file diff --git a/src/lib/enroll.proto b/src/lib/enroll.proto deleted file mode 100644 index 3b22ac17..00000000 --- a/src/lib/enroll.proto +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Ouroboros - Copyright (C) 2016 - 2023 - * - * Enrollment protocol - * - * Dimitri Staessens - * Sander Vrijders - * - * 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/. - */ - -syntax = "proto2"; -import "ipcp_config.proto"; - -message enroll_req_msg { - /* TODO authentication */ - required bytes id = 1; -} - -message enroll_resp_msg { - required bytes id = 1; - required int64 t_sec = 2; - required int32 t_nsec = 3; - required int32 response = 4; - optional ipcp_config_msg conf = 5; -} - -message enroll_ack_msg { - required bytes id = 1; - required int32 result = 2; -} diff --git a/src/lib/ipcp_config.proto b/src/lib/ipcp_config.proto deleted file mode 100644 index 1ff304f1..00000000 --- a/src/lib/ipcp_config.proto +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Ouroboros - Copyright (C) 2016 - 2023 - * - * Layer configuration message - * - * Dimitri Staessens - * Sander Vrijders - * - * 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/. - */ - -syntax = "proto2"; - -message layer_info_msg { - required string layer_name = 1; - required uint32 dir_hash_algo = 2; -} - -message dt_config_msg { - required uint32 addr_size = 1; - required uint32 eid_size = 2; - required uint32 max_ttl = 3; - required uint32 routing_type = 4; -} - -message uni_config_msg { - required dt_config_msg dt = 1; - required uint32 addr_auth_type = 2; - required uint32 cong_avoid = 3; -} - -message eth_config_msg { - required string dev = 1; - required uint32 ethertype = 2; -} - -message udp_config_msg { - required uint32 ip_addr = 1; - required uint32 port = 2; - required uint32 dns_addr = 3; /* set to 0 if unused */ -} - -message ipcp_config_msg { - required layer_info_msg layer_info = 1; - required uint32 ipcp_type = 2; - optional uni_config_msg unicast = 3; - optional udp_config_msg udp = 4; - optional eth_config_msg eth = 5; -} diff --git a/src/lib/ipcpd_messages.proto b/src/lib/ipcpd_messages.proto deleted file mode 100644 index c985b752..00000000 --- a/src/lib/ipcpd_messages.proto +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Ouroboros - Copyright (C) 2016 - 2023 - * - * Messages sent to IPCPds - * - * Dimitri Staessens - * Sander Vrijders - * - * 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/. - */ - -syntax = "proto2"; - -import "ipcp_config.proto"; -import "qosspec.proto"; - -enum ipcp_msg_code { - IPCP_BOOTSTRAP = 1; - IPCP_ENROLL = 2; - IPCP_REG = 3; - IPCP_UNREG = 4; - IPCP_QUERY = 5; - IPCP_FLOW_ALLOC = 6; - IPCP_FLOW_JOIN = 7; - IPCP_FLOW_ALLOC_RESP = 8; - IPCP_FLOW_DEALLOC = 9; - IPCP_CONNECT = 10; - IPCP_DISCONNECT = 11; - IPCP_REPLY = 12; -} - -message ipcp_msg { - required ipcp_msg_code code = 1; - optional bytes hash = 2; - optional int32 flow_id = 3; - optional string dst = 4; - optional qosspec_msg qosspec = 5; - optional bytes pk = 6; /* piggyback */ - optional ipcp_config_msg conf = 7; - optional int32 pid = 8; - optional layer_info_msg layer_info = 9; - optional int32 response = 10; - optional string comp = 11; - optional uint32 timeo_sec = 12; - optional sint32 mpl = 13; - optional int32 result = 14; -} diff --git a/src/lib/irmd_messages.proto b/src/lib/irmd_messages.proto deleted file mode 100644 index 41ef8595..00000000 --- a/src/lib/irmd_messages.proto +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Ouroboros - Copyright (C) 2016 - 2023 - * - * Messages sent to IRMd - * - * Dimitri Staessens - * Sander Vrijders - * - * 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/. - */ - -syntax = "proto2"; - -import "ipcp_config.proto"; -import "qosspec.proto"; - -enum irm_msg_code { - IRM_CREATE_IPCP = 1; - IPCP_CREATE_R = 2; - IRM_DESTROY_IPCP = 3; - IRM_LIST_IPCPS = 4; - IRM_BOOTSTRAP_IPCP = 5; - IRM_ENROLL_IPCP = 6; - IRM_CONNECT_IPCP = 7; - IRM_DISCONNECT_IPCP = 8; - IRM_BIND_PROGRAM = 9; - IRM_UNBIND_PROGRAM = 10; - IRM_PROC_ANNOUNCE = 11; - IRM_BIND_PROCESS = 12; - IRM_UNBIND_PROCESS = 13; - IRM_CREATE_NAME = 14; - IRM_DESTROY_NAME = 15; - IRM_LIST_NAMES = 16; - IRM_REG_NAME = 17; - IRM_UNREG_NAME = 18; - IRM_FLOW_ALLOC = 19; - IRM_FLOW_ACCEPT = 20; - IRM_FLOW_JOIN = 21; - IRM_FLOW_DEALLOC = 22; - IPCP_FLOW_REQ_ARR = 23; - IPCP_FLOW_ALLOC_REPLY = 24; - IRM_REPLY = 25; -} - -message ipcp_info_msg { - required uint32 pid = 1; - required uint32 type = 2; - required string name = 3; - required string layer = 4; -} - -message name_info_msg { - required string name = 1; - required uint32 pol_lb = 2; -} - -message irm_msg { - required irm_msg_code code = 1; - optional string prog = 2; - optional sint32 pid = 3; - optional string name = 4; - optional uint32 ipcp_type = 5; - optional string layer = 6; - repeated string args = 7; - optional sint32 response = 8; - optional string dst = 9; - optional bytes hash = 10; - optional sint32 flow_id = 11; - optional qosspec_msg qosspec = 12; - optional ipcp_config_msg conf = 13; - optional uint32 opts = 14; - repeated ipcp_info_msg ipcps = 15; - repeated name_info_msg names = 16; - optional uint32 timeo_sec = 17; - optional uint32 timeo_nsec = 18; - optional sint32 mpl = 19; - optional string comp = 20; - optional bytes pk = 21; /* piggyback */ - optional sint32 result = 22; -} diff --git a/src/lib/pb/cacep.proto b/src/lib/pb/cacep.proto new file mode 100644 index 00000000..5d735e33 --- /dev/null +++ b/src/lib/pb/cacep.proto @@ -0,0 +1,39 @@ +/* + * Ouroboros - Copyright (C) 2016 - 2023 + * + * Message for Connection Information in CACEP + * + * Dimitri Staessens + * Sander Vrijders + * + * 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/. + */ + +syntax = "proto2"; + +message fixed_conc_syntax_msg { + repeated uint32 fids = 1; + repeated uint32 lens = 2; +} + +message cacep_msg { + required string comp_name = 1; + required string protocol = 2; + required int32 pref_version = 3; + repeated int32 supp_version = 4; + required int32 pref_syntax = 5; + repeated int32 supp_syntax = 6; + optional fixed_conc_syntax_msg syntax_spec = 7; + required uint64 address = 8; +} \ No newline at end of file diff --git a/src/lib/pb/enroll.proto b/src/lib/pb/enroll.proto new file mode 100644 index 00000000..3b22ac17 --- /dev/null +++ b/src/lib/pb/enroll.proto @@ -0,0 +1,42 @@ +/* + * Ouroboros - Copyright (C) 2016 - 2023 + * + * Enrollment protocol + * + * Dimitri Staessens + * Sander Vrijders + * + * 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/. + */ + +syntax = "proto2"; +import "ipcp_config.proto"; + +message enroll_req_msg { + /* TODO authentication */ + required bytes id = 1; +} + +message enroll_resp_msg { + required bytes id = 1; + required int64 t_sec = 2; + required int32 t_nsec = 3; + required int32 response = 4; + optional ipcp_config_msg conf = 5; +} + +message enroll_ack_msg { + required bytes id = 1; + required int32 result = 2; +} diff --git a/src/lib/pb/ipcp.proto b/src/lib/pb/ipcp.proto new file mode 100644 index 00000000..f3eca0b8 --- /dev/null +++ b/src/lib/pb/ipcp.proto @@ -0,0 +1,58 @@ +/* + * Ouroboros - Copyright (C) 2016 - 2023 + * + * Messages sent to IPCPds + * + * Dimitri Staessens + * Sander Vrijders + * + * 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/. + */ + +syntax = "proto2"; + +import "ipcp_config.proto"; +import "qos.proto"; + +enum ipcp_msg_code { + IPCP_BOOTSTRAP = 1; + IPCP_ENROLL = 2; + IPCP_REG = 3; + IPCP_UNREG = 4; + IPCP_QUERY = 5; + IPCP_FLOW_ALLOC = 6; + IPCP_FLOW_JOIN = 7; + IPCP_FLOW_ALLOC_RESP = 8; + IPCP_FLOW_DEALLOC = 9; + IPCP_CONNECT = 10; + IPCP_DISCONNECT = 11; + IPCP_REPLY = 12; +} + +message ipcp_msg { + required ipcp_msg_code code = 1; + optional bytes hash = 2; + optional int32 flow_id = 3; + optional string dst = 4; + optional qosspec_msg qosspec = 5; + optional bytes pk = 6; /* piggyback */ + optional ipcp_config_msg conf = 7; + optional int32 pid = 8; + optional layer_info_msg layer_info = 9; + optional int32 response = 10; + optional string comp = 11; + optional uint32 timeo_sec = 12; + optional sint32 mpl = 13; + optional int32 result = 14; +} diff --git a/src/lib/pb/ipcp_config.proto b/src/lib/pb/ipcp_config.proto new file mode 100644 index 00000000..1ff304f1 --- /dev/null +++ b/src/lib/pb/ipcp_config.proto @@ -0,0 +1,60 @@ +/* + * Ouroboros - Copyright (C) 2016 - 2023 + * + * Layer configuration message + * + * Dimitri Staessens + * Sander Vrijders + * + * 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/. + */ + +syntax = "proto2"; + +message layer_info_msg { + required string layer_name = 1; + required uint32 dir_hash_algo = 2; +} + +message dt_config_msg { + required uint32 addr_size = 1; + required uint32 eid_size = 2; + required uint32 max_ttl = 3; + required uint32 routing_type = 4; +} + +message uni_config_msg { + required dt_config_msg dt = 1; + required uint32 addr_auth_type = 2; + required uint32 cong_avoid = 3; +} + +message eth_config_msg { + required string dev = 1; + required uint32 ethertype = 2; +} + +message udp_config_msg { + required uint32 ip_addr = 1; + required uint32 port = 2; + required uint32 dns_addr = 3; /* set to 0 if unused */ +} + +message ipcp_config_msg { + required layer_info_msg layer_info = 1; + required uint32 ipcp_type = 2; + optional uni_config_msg unicast = 3; + optional udp_config_msg udp = 4; + optional eth_config_msg eth = 5; +} diff --git a/src/lib/pb/irm.proto b/src/lib/pb/irm.proto new file mode 100644 index 00000000..49afa2e4 --- /dev/null +++ b/src/lib/pb/irm.proto @@ -0,0 +1,91 @@ +/* + * Ouroboros - Copyright (C) 2016 - 2023 + * + * Messages sent to IRMd + * + * Dimitri Staessens + * Sander Vrijders + * + * 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/. + */ + +syntax = "proto2"; + +import "ipcp_config.proto"; +import "qos.proto"; + +enum irm_msg_code { + IRM_CREATE_IPCP = 1; + IPCP_CREATE_R = 2; + IRM_DESTROY_IPCP = 3; + IRM_LIST_IPCPS = 4; + IRM_BOOTSTRAP_IPCP = 5; + IRM_ENROLL_IPCP = 6; + IRM_CONNECT_IPCP = 7; + IRM_DISCONNECT_IPCP = 8; + IRM_BIND_PROGRAM = 9; + IRM_UNBIND_PROGRAM = 10; + IRM_PROC_ANNOUNCE = 11; + IRM_BIND_PROCESS = 12; + IRM_UNBIND_PROCESS = 13; + IRM_CREATE_NAME = 14; + IRM_DESTROY_NAME = 15; + IRM_LIST_NAMES = 16; + IRM_REG_NAME = 17; + IRM_UNREG_NAME = 18; + IRM_FLOW_ALLOC = 19; + IRM_FLOW_ACCEPT = 20; + IRM_FLOW_JOIN = 21; + IRM_FLOW_DEALLOC = 22; + IPCP_FLOW_REQ_ARR = 23; + IPCP_FLOW_ALLOC_REPLY = 24; + IRM_REPLY = 25; +} + +message ipcp_info_msg { + required uint32 pid = 1; + required uint32 type = 2; + required string name = 3; + required string layer = 4; +} + +message name_info_msg { + required string name = 1; + required uint32 pol_lb = 2; +} + +message irm_msg { + required irm_msg_code code = 1; + optional string prog = 2; + optional sint32 pid = 3; + optional string name = 4; + optional uint32 ipcp_type = 5; + optional string layer = 6; + repeated string args = 7; + optional sint32 response = 8; + optional string dst = 9; + optional bytes hash = 10; + optional sint32 flow_id = 11; + optional qosspec_msg qosspec = 12; + optional ipcp_config_msg conf = 13; + optional uint32 opts = 14; + repeated ipcp_info_msg ipcps = 15; + repeated name_info_msg names = 16; + optional uint32 timeo_sec = 17; + optional uint32 timeo_nsec = 18; + optional sint32 mpl = 19; + optional string comp = 20; + optional bytes pk = 21; /* piggyback */ + optional sint32 result = 22; +} diff --git a/src/lib/pb/qos.proto b/src/lib/pb/qos.proto new file mode 100644 index 00000000..81d0e4a0 --- /dev/null +++ b/src/lib/pb/qos.proto @@ -0,0 +1,35 @@ +/* + * Ouroboros - Copyright (C) 2016 - 2023 + * + * QoS specification message + * + * Dimitri Staessens + * Sander Vrijders + * + * 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/. + */ + +syntax = "proto2"; + +message qosspec_msg { + required uint32 delay = 1; /* In ms. */ + required uint64 bandwidth = 2; /* In bits/s. */ + required uint32 availability = 3; /* Class of 9s. */ + required uint32 loss = 4; /* Packet loss. */ + required uint32 ber = 5; /* Bit error rate, ppb. */ + required uint32 in_order = 6; /* In-order delivery. */ + required uint32 max_gap = 7; /* In ms. */ + required uint32 cypher_s = 8; /* Crypto strength in bits. */ + required uint32 timeout = 9; /* Timeout in ms. */ +} diff --git a/src/lib/qosspec.proto b/src/lib/qosspec.proto deleted file mode 100644 index 81d0e4a0..00000000 --- a/src/lib/qosspec.proto +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Ouroboros - Copyright (C) 2016 - 2023 - * - * QoS specification message - * - * Dimitri Staessens - * Sander Vrijders - * - * 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/. - */ - -syntax = "proto2"; - -message qosspec_msg { - required uint32 delay = 1; /* In ms. */ - required uint64 bandwidth = 2; /* In bits/s. */ - required uint32 availability = 3; /* Class of 9s. */ - required uint32 loss = 4; /* Packet loss. */ - required uint32 ber = 5; /* Bit error rate, ppb. */ - required uint32 in_order = 6; /* In-order delivery. */ - required uint32 max_gap = 7; /* In ms. */ - required uint32 cypher_s = 8; /* Crypto strength in bits. */ - required uint32 timeout = 9; /* Timeout in ms. */ -} -- cgit v1.2.3