summaryrefslogtreecommitdiff
path: root/src/ipcpd/normal/enroll.c
diff options
context:
space:
mode:
authordimitri staessens <[email protected]>2017-02-21 08:02:37 +0100
committerdimitri staessens <[email protected]>2017-02-21 11:55:36 +0100
commitadc6766221327f99ab484d66f6f92050ec9e62d7 (patch)
treecd0facb94108552b0b9e75619af4e42d77be1a17 /src/ipcpd/normal/enroll.c
parent354554c76cc2f9f30c7fd8edaeb2e3cc91c85332 (diff)
downloadouroboros-adc6766221327f99ab484d66f6f92050ec9e62d7.tar.gz
ouroboros-adc6766221327f99ab484d66f6f92050ec9e62d7.zip
lib: Exchange protocol info during CACEP
This exchanges a protocol name, a protocol version and concrete syntax for the protocol upon CACEP. For CDAP, only version 1 and GPB are supported. No lists for other supported versions or syntaxes are exchanged (but the proto file supports it). CACEP fails if there is a mismatch between the protocol names, version and syntax specified by the communicating parties.
Diffstat (limited to 'src/ipcpd/normal/enroll.c')
-rw-r--r--src/ipcpd/normal/enroll.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/src/ipcpd/normal/enroll.c b/src/ipcpd/normal/enroll.c
index e8c085a8..ce6768fb 100644
--- a/src/ipcpd/normal/enroll.c
+++ b/src/ipcpd/normal/enroll.c
@@ -26,6 +26,7 @@
#include <ouroboros/dev.h>
#include <ouroboros/logs.h>
#include <ouroboros/rib.h>
+#include <ouroboros/errno.h>
#include "ae.h"
#include "cdap_flow.h"
@@ -43,6 +44,7 @@
int enroll_handle(int fd)
{
struct cdap_flow * flow;
+ struct cacep_info info;
cdap_key_t key;
enum cdap_opcode oc;
char * name;
@@ -59,13 +61,27 @@ int enroll_handle(int fd)
char * members_ro = MEMBERS_PATH;
char * dif_ro = DIF_PATH;
- flow = cdap_flow_arr(fd, 0, ANONYMOUS_AUTH, NULL);
+ cacep_info_init(&info);
+
+ info.proto.protocol = strdup(CDAP_PROTO);
+ if (info.proto.protocol == NULL) {
+ cacep_info_fini(&info);
+ return -ENOMEM;
+ }
+
+ info.proto.pref_version = 1;
+ info.proto.pref_syntax = PROTO_GPB;
+
+ flow = cdap_flow_arr(fd, 0, ANONYMOUS_AUTH, &info);
if (flow == NULL) {
log_err("Failed to auth enrollment request.");
+ cacep_info_fini(&info);
flow_dealloc(fd);
return -1;
}
+ cacep_info_fini(&info);
+
while (!(boot_r && members_r && dif_name_r)) {
key = cdap_request_wait(flow->ci, &oc, &name, &data,
(size_t *) &len , &flags);
@@ -140,6 +156,7 @@ int enroll_handle(int fd)
int enroll_boot(char * dst_name)
{
struct cdap_flow * flow;
+ struct cacep_info info;
cdap_key_t key;
uint8_t * data;
size_t len;
@@ -153,12 +170,27 @@ int enroll_boot(char * dst_name)
char * members_ro = MEMBERS_PATH;
char * dif_ro = DIF_PATH;
- flow = cdap_flow_alloc(dst_name, ENROLL_AE, NULL, ANONYMOUS_AUTH, NULL);
+ cacep_info_init(&info);
+
+ info.proto.protocol = strdup(CDAP_PROTO);
+ if (info.proto.protocol == NULL) {
+ cacep_info_fini(&info);
+ return -ENOMEM;
+ }
+
+ info.proto.pref_version = 1;
+ info.proto.pref_syntax = PROTO_GPB;
+
+ flow = cdap_flow_alloc(dst_name, ENROLL_AE, NULL, ANONYMOUS_AUTH,
+ &info);
if (flow == NULL) {
log_err("Failed to allocate flow for enrollment request.");
+ cacep_info_fini(&info);
return -1;
}
+ cacep_info_fini(&info);
+
log_dbg("Getting boot information from %s.", dst_name);
clock_gettime(CLOCK_REALTIME, &t0);