summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/ouroboros/CMakeLists.txt2
-rw-r--r--include/ouroboros/btree.h47
-rw-r--r--include/ouroboros/endian.h2
-rw-r--r--include/ouroboros/errno.h6
-rw-r--r--include/ouroboros/hash.h41
-rw-r--r--include/ouroboros/ipcp-dev.h7
-rw-r--r--include/ouroboros/ipcp.h (renamed from include/ouroboros/irm_config.h)33
-rw-r--r--include/ouroboros/irm.h12
-rw-r--r--include/ouroboros/sha3.h86
-rw-r--r--include/ouroboros/sockets.h4
-rw-r--r--include/ouroboros/wrap/ouroboros.i4
11 files changed, 214 insertions, 30 deletions
diff --git a/include/ouroboros/CMakeLists.txt b/include/ouroboros/CMakeLists.txt
index a8589da1..748d5e2d 100644
--- a/include/ouroboros/CMakeLists.txt
+++ b/include/ouroboros/CMakeLists.txt
@@ -6,12 +6,10 @@ set(HEADER_FILES
cacep.h
cdap.h
dev.h
- endian.h
errno.h
fcntl.h
fqueue.h
irm.h
- irm_config.h
nsm.h
qos.h)
diff --git a/include/ouroboros/btree.h b/include/ouroboros/btree.h
new file mode 100644
index 00000000..f7c293c5
--- /dev/null
+++ b/include/ouroboros/btree.h
@@ -0,0 +1,47 @@
+/*
+ * Ouroboros - Copyright (C) 2016 - 2017
+ *
+ * B-trees
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef OUROBOROS_LIB_BTREE_H
+#define OUROBOROS_LIB_BTREE_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+struct btree;
+
+/* Create a B-tree of order k */
+struct btree * btree_create(size_t k);
+
+void btree_destroy(struct btree * tree);
+
+int btree_insert(struct btree * tree,
+ uint32_t key,
+ void * val);
+
+int btree_remove(struct btree * tree,
+ uint32_t key);
+
+void * btree_search(struct btree * tree,
+ uint32_t key);
+
+#endif /* OUROBOROS_LIB_BTREE_H */
diff --git a/include/ouroboros/endian.h b/include/ouroboros/endian.h
index d712b1b3..691e3f8b 100644
--- a/include/ouroboros/endian.h
+++ b/include/ouroboros/endian.h
@@ -84,5 +84,7 @@
#define hton32(x) htobe32(x)
#define ntoh64(x) betoh64(x)
#define noth32(x) betoh32(x)
+#define hton16(x) htobe16(x)
+#define ntoh16(x) betoh16(x)
#endif /* OUROBOROS_ENDIAN_H */
diff --git a/include/ouroboros/errno.h b/include/ouroboros/errno.h
index d2117992..fa1a33f2 100644
--- a/include/ouroboros/errno.h
+++ b/include/ouroboros/errno.h
@@ -28,6 +28,8 @@
#define ENOTALLOC 1000 /* Flow is not allocated */
#define EIPCPTYPE 1001 /* Unknown IPCP type */
-#define EIRMD 1002 /* Failed to contact IRMD */
+#define EIRMD 1002 /* Failed to communicate with IRMD */
+#define EIPCP 1003 /* Failed to communicate with IPCP */
+#define EIPCPSTATE 1004 /* Target in wrong state */
-#endif
+#endif /* OUROBOROS_ERRNO_H */
diff --git a/include/ouroboros/hash.h b/include/ouroboros/hash.h
new file mode 100644
index 00000000..4779a9a6
--- /dev/null
+++ b/include/ouroboros/hash.h
@@ -0,0 +1,41 @@
+/*
+ * Ouroboros - Copyright (C) 2016 - 2017
+ *
+ * Hashing functions
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef OUROBOROS_LIB_HASH_H
+#define OUROBOROS_LIB_HASH_H
+
+#include <ouroboros/sha3.h>
+#include <ouroboros/crc32.h>
+
+#define HASH_FMT "%02x%02x%02x%02x"
+#define HASH_VAL(hash) \
+ ((*(unsigned int *) hash) & 0xFF000000) >> 24, \
+ ((*(unsigned int *) hash) & 0x00FF0000) >> 16, \
+ ((*(unsigned int *) hash) & 0x0000FF00) >> 8, \
+ ((*(unsigned int *) hash) & 0x000000FF)
+
+/* FIXME: Implement specifying algorithm */
+void get_hash(uint8_t buf[],
+ const char * name);
+
+#endif /* OUROBOROS_LIB_HASH_H */
diff --git a/include/ouroboros/ipcp-dev.h b/include/ouroboros/ipcp-dev.h
index 89ef733b..571689ca 100644
--- a/include/ouroboros/ipcp-dev.h
+++ b/include/ouroboros/ipcp-dev.h
@@ -29,9 +29,10 @@
int ipcp_create_r(pid_t api,
int result);
-int ipcp_flow_req_arr(pid_t api,
- char * dst_name,
- qoscube_t cube);
+int ipcp_flow_req_arr(pid_t api,
+ const uint8_t * dst,
+ size_t len,
+ qoscube_t cube);
int ipcp_flow_alloc_reply(int fd,
int response);
diff --git a/include/ouroboros/irm_config.h b/include/ouroboros/ipcp.h
index 3dd55823..f439f29b 100644
--- a/include/ouroboros/irm_config.h
+++ b/include/ouroboros/ipcp.h
@@ -1,7 +1,7 @@
/*
* Ouroboros - Copyright (C) 2016 - 2017
*
- * Configuration information for the IPC Resource Manager
+ * IPCP definitions and policies
*
* Dimitri Staessens <[email protected]>
* Sander Vrijders <[email protected]>
@@ -21,25 +21,25 @@
* 02110-1301 USA
*/
+#ifndef OUROBOROS_IPCP_H
+#define OUROBOROS_IPCP_H
+
#include <stdint.h>
#include <unistd.h>
#include <stdbool.h>
-#ifndef OUROBOROS_IRM_CONFIG_H
-#define OUROBOROS_IRM_CONFIG_H
-
-/* Name binding options */
-
-#define BIND_AP_AUTO 0x01
-#define BIND_AP_UNIQUE 0x02
-
+/*
+ * NOTE: the IRMd uses this order to select an IPCP
+ * for flow allocation
+ */
enum ipcp_type {
- IPCP_NORMAL = 0,
- IPCP_LOCAL,
+ IPCP_LOCAL = 0,
+ IPCP_SHIM_ETH_LLC,
IPCP_SHIM_UDP,
- IPCP_SHIM_ETH_LLC
+ IPCP_NORMAL
};
+/* IPCP policies */
enum pol_addr_auth {
FLAT_RANDOM = 0
};
@@ -48,9 +48,10 @@ enum pol_gam {
COMPLETE = 0
};
-struct dif_config {
- char * dif_name;
- enum ipcp_type type;
+struct ipcp_config {
+ char * dif_name;
+ enum ipcp_type type;
+ uint16_t dir_hash_len;
/* Normal DIF */
uint8_t addr_size;
@@ -76,4 +77,4 @@ struct dif_config {
char * if_name;
};
-#endif /* OUROBOROS_IRM_CONFIG_H */
+#endif /* OUROBOROS_IPCP_H */
diff --git a/include/ouroboros/irm.h b/include/ouroboros/irm.h
index 9bd0c93b..d1aa5230 100644
--- a/include/ouroboros/irm.h
+++ b/include/ouroboros/irm.h
@@ -24,9 +24,15 @@
#ifndef OUROBOROS_IRM_H
#define OUROBOROS_IRM_H
-#include <ouroboros/irm_config.h>
+#include <ouroboros/ipcp.h>
+
#include <sys/types.h>
+/* Name binding options */
+
+#define BIND_AP_AUTO 0x01
+#define BIND_AP_UNIQUE 0x02
+
pid_t irm_create_ipcp(const char * name,
enum ipcp_type ipcp_type);
@@ -39,8 +45,8 @@ ssize_t irm_list_ipcps(const char * name,
int irm_enroll_ipcp(pid_t api,
const char * dif_name);
-int irm_bootstrap_ipcp(pid_t api,
- const struct dif_config * conf);
+int irm_bootstrap_ipcp(pid_t api,
+ const struct ipcp_config * conf);
int irm_bind_ap(const char * ap,
const char * name,
diff --git a/include/ouroboros/sha3.h b/include/ouroboros/sha3.h
new file mode 100644
index 00000000..17888870
--- /dev/null
+++ b/include/ouroboros/sha3.h
@@ -0,0 +1,86 @@
+/*
+ * Ouroboros - Copyright (C) 2016 - 2017
+ *
+ * SHA3 algorithm
+ *
+ * Dimitri Staessens <[email protected]>
+ * Sander Vrijders <[email protected]>
+ *
+ * This implementation is adapted and redistributed from the RHASH
+ * project implementation of the sha3 algorithm
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ * -- original license
+ *
+ * sha3.c - an implementation of Secure Hash Algorithm 3 (Keccak).
+ * based on the
+ * The Keccak SHA-3 submission. Submission to NIST (Round 3), 2011
+ * by Guido Bertoni, Joan Daemen, Michaƫl Peeters and Gilles Van Assche
+ *
+ * Copyright: 2013 Aleksey Kravchenko <[email protected]>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so.
+ *
+ * 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. Use this program at your own risk!
+ */
+
+#ifndef OUROBOROS_SHA3_H
+#define OUROBOROS_SHA3_H
+
+#include <unistd.h>
+#include <stdint.h>
+
+#define SHA3_224_HASH_LEN 28
+#define SHA3_256_HASH_LEN 32
+#define SHA3_384_HASH_LEN 48
+#define SHA3_512_HASH_LEN 64
+#define SHA3_MAX_PERMUTATION_SIZE 25
+#define SHA3_MAX_RATE_IN_QWORDS 24
+
+struct sha3_ctx {
+ /* 1600 bits algorithm hashing state */
+ uint64_t hash[SHA3_MAX_PERMUTATION_SIZE];
+ /* 1536-bit buffer for leftovers */
+ uint64_t message[SHA3_MAX_RATE_IN_QWORDS];
+ /* count of bytes in the message[] buffer */
+ unsigned rest;
+ /* size of a message block processed at once */
+ unsigned block_size;
+};
+
+void rhash_sha3_224_init(struct sha3_ctx * ctx);
+
+void rhash_sha3_256_init(struct sha3_ctx * ctx);
+
+void rhash_sha3_384_init(struct sha3_ctx * ctx);
+
+void rhash_sha3_512_init(struct sha3_ctx * ctx);
+
+void rhash_sha3_update(struct sha3_ctx * ctx,
+ const void * msg,
+ size_t size);
+
+void rhash_sha3_final(struct sha3_ctx * ctx,
+ uint8_t * res);
+
+#endif /* OUROBOROS_SHA3_H */
diff --git a/include/ouroboros/sockets.h b/include/ouroboros/sockets.h
index 8237efb6..bb8f6d87 100644
--- a/include/ouroboros/sockets.h
+++ b/include/ouroboros/sockets.h
@@ -26,8 +26,8 @@
#include <sys/types.h>
-#include "dif_config.pb-c.h"
-typedef DifConfigMsg dif_config_msg_t;
+#include "ipcp_config.pb-c.h"
+typedef IpcpConfigMsg ipcp_config_msg_t;
#include "irmd_messages.pb-c.h"
typedef IrmMsg irm_msg_t;
diff --git a/include/ouroboros/wrap/ouroboros.i b/include/ouroboros/wrap/ouroboros.i
index b156eb36..62a829e2 100644
--- a/include/ouroboros/wrap/ouroboros.i
+++ b/include/ouroboros/wrap/ouroboros.i
@@ -29,7 +29,7 @@
#include "ouroboros/fcntl.h"
#include "ouroboros/fqueue.h"
#include "ouroboros/irm.h"
-#include "ouroboros/irm_config.h"
+#include "ouroboros/ipcp.h"
#include "ouroboros/nsm.h"
#include "ouroboros/qos.h"
%}
@@ -43,6 +43,6 @@ typedef int pid_t;
%include "ouroboros/fcntl.h"
%include "ouroboros/fqueue.h"
%include "ouroboros/irm.h"
-%include "ouroboros/irm_config.h"
+%include "ouroboros/ipcp.h"
%include "ouroboros/nsm.h"
%include "ouroboros/qos.h"