From 9903b8a2f9a7dc8ebac6928dcf2d2b5593ea0615 Mon Sep 17 00:00:00 2001
From: dimitri staessens <dimitri.staessens@ugent.be>
Date: Fri, 12 May 2017 13:05:47 +0200
Subject: ipcpd: Allow specifying fixed syntax

This commits adds the functions and messages to specify a fixed
protocol syntax during CACEP. It also revises the messages for
specifying the DT protocol syntax from the irm tool.
---
 include/ouroboros/CMakeLists.txt |  1 +
 include/ouroboros/cacep.h        | 12 +++++------
 include/ouroboros/ipcp.h         | 30 ++++++++++-----------------
 include/ouroboros/proto.h        | 44 ++++++++++++++++++++++++++++++++++++++++
 include/ouroboros/sockets.h      |  1 +
 5 files changed, 62 insertions(+), 26 deletions(-)
 create mode 100644 include/ouroboros/proto.h

(limited to 'include')

diff --git a/include/ouroboros/CMakeLists.txt b/include/ouroboros/CMakeLists.txt
index f582b915..8f57d4d7 100644
--- a/include/ouroboros/CMakeLists.txt
+++ b/include/ouroboros/CMakeLists.txt
@@ -13,6 +13,7 @@ set(HEADER_FILES
   ipcp.h
   irm.h
   nsm.h
+  proto.h
   qos.h)
 
 install(FILES ${HEADER_FILES} DESTINATION usr/include/ouroboros)
diff --git a/include/ouroboros/cacep.h b/include/ouroboros/cacep.h
index 967151de..fb52fd0f 100644
--- a/include/ouroboros/cacep.h
+++ b/include/ouroboros/cacep.h
@@ -25,21 +25,19 @@
 #define OUROBOROS_CACEP_H
 
 #include <ouroboros/cdefs.h>
+#include <ouroboros/proto.h>
 
 #include <stdint.h>
-
-enum proto_concrete_syntax {
-        PROTO_GPB = 0,
-        PROTO_ASN_1,
-        PROTO_FIXED
-};
+#include <sys/types.h>
 
 struct conn_info {
         char                       ae_name[64];
         char                       protocol[64];
         uint32_t                   pref_version;
         enum proto_concrete_syntax pref_syntax;
-        uint64_t                   addr;
+        struct proto_field         fixed_conc_syntax[PROTO_MAX_FIELDS];
+        size_t                     num_fields;
+        uint64_t                   addr; /* AE-I name */
 };
 
 __BEGIN_DECLS
diff --git a/include/ouroboros/ipcp.h b/include/ouroboros/ipcp.h
index f418d640..05fdcd49 100644
--- a/include/ouroboros/ipcp.h
+++ b/include/ouroboros/ipcp.h
@@ -57,22 +57,22 @@ enum hash_algo {
         HASH_SHA3_512
 };
 
+#define DIF_NAME_SIZE 256
+
+struct dif_info {
+        char           dif_name[DIF_NAME_SIZE];
+        enum hash_algo dir_hash_algo;
+};
+
 struct ipcp_config {
-        char *             dif_name;
+        struct dif_info    dif_info;
+
         enum ipcp_type     type;
-        enum hash_algo     dir_hash_algo;
 
-        /* Normal DIF */
+        /* DT syntax */
         uint8_t            addr_size;
-        uint8_t            cep_id_size;
-        uint8_t            pdu_length_size;
-        uint8_t            seqno_size;
-
+        uint8_t            fd_size;
         bool               has_ttl;
-        bool               has_chk;
-
-        uint32_t           min_pdu_size;
-        uint32_t           max_pdu_size;
 
         enum pol_addr_auth addr_auth_type;
         enum pol_gam       dt_gam_type;
@@ -86,12 +86,4 @@ struct ipcp_config {
         char *             if_name;
 };
 
-#define DIF_NAME_SIZE 256
-
-/* capability report of a DIF */
-struct dif_info {
-        enum hash_algo algo;
-        char           dif_name[DIF_NAME_SIZE];
-};
-
 #endif /* OUROBOROS_IPCP_H */
diff --git a/include/ouroboros/proto.h b/include/ouroboros/proto.h
new file mode 100644
index 00000000..30c549c0
--- /dev/null
+++ b/include/ouroboros/proto.h
@@ -0,0 +1,44 @@
+/*
+ * Ouroboros - Copyright (C) 2016 - 2017
+ *
+ * Protocol syntax definitions
+ *
+ *    Dimitri Staessens <dimitri.staessens@ugent.be>
+ *    Sander Vrijders   <sander.vrijders@ugent.be>
+ *
+ * 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_PROTO_H
+#define OUROBOROS_PROTO_H
+
+#include <sys/types.h>
+
+#define PROTO_FIELD_ABSENT   -1
+#define PROTO_FIELD_VARIABLE  0
+#define PROTO_MAX_FIELDS      128
+
+enum proto_concrete_syntax {
+        PROTO_GPB = 0,
+        PROTO_ASN_1,
+        PROTO_FIXED
+};
+
+struct proto_field {
+        size_t  fid; /* an ID for the protocol field */
+        ssize_t len; /* 0 variable, -1 not present   */
+};
+
+#endif /* OUROBOROS_PROTO_H */
diff --git a/include/ouroboros/sockets.h b/include/ouroboros/sockets.h
index bb8f6d87..660709bf 100644
--- a/include/ouroboros/sockets.h
+++ b/include/ouroboros/sockets.h
@@ -28,6 +28,7 @@
 
 #include "ipcp_config.pb-c.h"
 typedef IpcpConfigMsg ipcp_config_msg_t;
+typedef DifInfoMsg dif_info_msg_t;
 
 #include "irmd_messages.pb-c.h"
 typedef IrmMsg irm_msg_t;
-- 
cgit v1.2.3