summaryrefslogtreecommitdiff
path: root/src/ipcpd/normal/gam.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ipcpd/normal/gam.c')
-rw-r--r--src/ipcpd/normal/gam.c91
1 files changed, 58 insertions, 33 deletions
diff --git a/src/ipcpd/normal/gam.c b/src/ipcpd/normal/gam.c
index 9ee55261..791cf34e 100644
--- a/src/ipcpd/normal/gam.c
+++ b/src/ipcpd/normal/gam.c
@@ -23,6 +23,7 @@
#define OUROBOROS_PREFIX "graph-adjacency-manager"
#include <ouroboros/config.h>
+#include <ouroboros/cdap.h>
#include <ouroboros/dev.h>
#include <ouroboros/logs.h>
#include <ouroboros/list.h>
@@ -178,8 +179,8 @@ int gam_flow_arr(struct gam * instance,
int fd,
qosspec_t qs)
{
- struct cacep * cacep;
- struct cacep_info * info;
+ struct cacep_info * rcv_info;
+ struct cacep_info snd_info;
if (flow_alloc_resp(fd, instance->ops->accept_new_flow(instance->ops_o))
< 0) {
@@ -187,32 +188,43 @@ int gam_flow_arr(struct gam * instance,
return -1;
}
- cacep = cacep_create(fd, ipcpi.name, ipcpi.address);
- if (cacep == NULL) {
- log_err("Failed to create CACEP instance.");
- return -1;
+ cacep_info_init(&snd_info);
+ snd_info.proto.protocol = strdup(CDAP_PROTO);
+ if (snd_info.proto.protocol == NULL) {
+ cacep_info_fini(&snd_info);
+ return -ENOMEM;
+ }
+
+ snd_info.proto.pref_version = 1;
+ snd_info.proto.pref_syntax = PROTO_GPB;
+ snd_info.addr = ipcpi.address;
+ snd_info.name = strdup(ipcpi.name);
+ if (snd_info.name == NULL) {
+ cacep_info_fini(&snd_info);
+ return -ENOMEM;
}
- info = cacep_auth_wait(cacep);
- if (info == NULL) {
+ rcv_info = cacep_auth_wait(fd, SIMPLE_AUTH, &snd_info);
+ if (rcv_info == NULL) {
log_err("Other side failed to authenticate.");
- cacep_destroy(cacep);
+ cacep_info_fini(&snd_info);
return -1;
}
- cacep_destroy(cacep);
+ cacep_info_fini(&snd_info);
- if (instance->ops->accept_flow(instance->ops_o, qs, info)) {
+ if (instance->ops->accept_flow(instance->ops_o, qs, rcv_info)) {
flow_dealloc(fd);
- free(info->name);
- free(info);
+ cacep_info_fini(rcv_info);
+ free(rcv_info);
return 0;
}
- if (add_ga(instance, fd, qs, info)) {
+ if (add_ga(instance, fd, qs, rcv_info)) {
log_err("Failed to add ga to graph adjacency manager list.");
- free(info->name);
- free(info);
+ flow_dealloc(fd);
+ cacep_info_fini(rcv_info);
+ free(rcv_info);
return -1;
}
@@ -223,10 +235,12 @@ int gam_flow_alloc(struct gam * instance,
char * dst_name,
qosspec_t qs)
{
- struct cacep * cacep;
- struct cacep_info * info;
+ struct cacep_info * rcv_info;
+ struct cacep_info snd_info;
int fd;
+ log_dbg("Allocating flow to %s.", dst_name);
+
fd = flow_alloc(dst_name, instance->ae_name, NULL);
if (fd < 0) {
log_err("Failed to allocate flow to %s.", dst_name);
@@ -239,32 +253,43 @@ int gam_flow_alloc(struct gam * instance,
return -1;
}
- cacep = cacep_create(fd, ipcpi.name, ipcpi.address);
- if (cacep == NULL) {
- log_err("Failed to create CACEP instance.");
- return -1;
+ cacep_info_init(&snd_info);
+ snd_info.proto.protocol = strdup(CDAP_PROTO);
+ if (snd_info.proto.protocol == NULL) {
+ cacep_info_fini(&snd_info);
+ return -ENOMEM;
+ }
+
+ snd_info.proto.pref_version = 1;
+ snd_info.proto.pref_syntax = PROTO_GPB;
+ snd_info.addr = ipcpi.address;
+ snd_info.name = strdup(ipcpi.name);
+ if (snd_info.name == NULL) {
+ cacep_info_fini(&snd_info);
+ return -ENOMEM;
}
- info = cacep_auth(cacep);
- if (info == NULL) {
- log_err("Failed to authenticate.");
- cacep_destroy(cacep);
+ rcv_info = cacep_auth(fd, SIMPLE_AUTH, &snd_info);
+ if (rcv_info == NULL) {
+ log_err("Other side failed to authenticate.");
+ cacep_info_fini(&snd_info);
return -1;
}
- cacep_destroy(cacep);
+ cacep_info_fini(&snd_info);
- if (instance->ops->accept_flow(instance->ops_o, qs, info)) {
+ if (instance->ops->accept_flow(instance->ops_o, qs, rcv_info)) {
flow_dealloc(fd);
- free(info->name);
- free(info);
+ cacep_info_fini(rcv_info);
+ free(rcv_info);
return 0;
}
- if (add_ga(instance, fd, qs, info)) {
+ if (add_ga(instance, fd, qs, rcv_info)) {
log_err("Failed to add GA to graph adjacency manager list.");
- free(info->name);
- free(info);
+ flow_dealloc(fd);
+ cacep_info_fini(rcv_info);
+ free(rcv_info);
return -1;
}