summaryrefslogtreecommitdiff
path: root/src/ipcpd/normal/gam.c
diff options
context:
space:
mode:
authordimitri staessens <[email protected]>2017-02-27 19:01:12 +0000
committerSander Vrijders <[email protected]>2017-02-27 19:01:12 +0000
commit6450c9d385ff9ec5234a489130a45378cafb8a6e (patch)
tree6270bf43428fe4e33594a86245b68503a4cca756 /src/ipcpd/normal/gam.c
parent7baebbfc117e3b349f397d4675c49a582d13653a (diff)
parentd06cb62e111be1ac3f09398ae559f99e4833b4bf (diff)
downloadouroboros-6450c9d385ff9ec5234a489130a45378cafb8a6e.tar.gz
ouroboros-6450c9d385ff9ec5234a489130a45378cafb8a6e.zip
Merged in dstaesse/ouroboros/be-cacep (pull request #393)
lib: Split authentication from CACEP
Diffstat (limited to 'src/ipcpd/normal/gam.c')
-rw-r--r--src/ipcpd/normal/gam.c87
1 files changed, 37 insertions, 50 deletions
diff --git a/src/ipcpd/normal/gam.c b/src/ipcpd/normal/gam.c
index 2479fa62..bdfc8cb9 100644
--- a/src/ipcpd/normal/gam.c
+++ b/src/ipcpd/normal/gam.c
@@ -120,7 +120,6 @@ void gam_destroy(struct gam * instance)
list_for_each_safe(p, n, &instance->gas) {
struct ga * e = list_entry(p, struct ga, next);
list_del(&e->next);
- free(e->info->name);
free(e->info);
free(e);
}
@@ -156,7 +155,7 @@ static int add_ga(struct gam * instance,
pthread_cond_signal(&instance->gas_cond);
pthread_mutex_unlock(&instance->gas_lock);
- log_info("Added flow to %s.", info->name);
+ log_info("Added flow.");
return 0;
}
@@ -166,7 +165,7 @@ int gam_flow_arr(struct gam * instance,
qosspec_t qs)
{
struct conn_info * rcv_info;
- struct conn_info snd_info;
+ struct conn_info snd_info;
if (flow_alloc_resp(fd, instance->ops->accept_new_flow(instance->ops_o))
< 0) {
@@ -174,34 +173,29 @@ int gam_flow_arr(struct gam * instance,
return -1;
}
- conn_info_init(&snd_info);
- snd_info.proto.protocol = strdup(CDAP_PROTO);
- if (snd_info.proto.protocol == NULL) {
- conn_info_fini(&snd_info);
+ rcv_info = malloc(sizeof(*rcv_info));
+ if (rcv_info == NULL)
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) {
- conn_info_fini(&snd_info);
- return -ENOMEM;
- }
+ memset(&snd_info, 0, sizeof(snd_info));
+ memset(rcv_info, 0, sizeof(*rcv_info));
+
+ /* FIXME: send correct AE */
+ strcpy(snd_info.ae_name, "FIXME:CORRECT_AE");
+ strcpy(snd_info.protocol, CDAP_PROTO);
+ snd_info.pref_version = 1;
+ snd_info.pref_syntax = PROTO_GPB;
+ snd_info.ae.addr = ipcpi.address;
- rcv_info = cacep_auth_wait(fd, SIMPLE_AUTH, &snd_info, NULL);
- if (rcv_info == NULL) {
- log_err("Other side failed to authenticate.");
- conn_info_fini(&snd_info);
+ if (cacep_listen(fd, &snd_info, rcv_info)) {
+ log_err("Failed to create application connection.");
+ flow_dealloc(fd);
+ free(rcv_info);
return -1;
}
- conn_info_fini(&snd_info);
-
if (instance->ops->accept_flow(instance->ops_o, qs, rcv_info)) {
flow_dealloc(fd);
- conn_info_fini(rcv_info);
free(rcv_info);
return 0;
}
@@ -209,7 +203,6 @@ int gam_flow_arr(struct gam * instance,
if (add_ga(instance, fd, qs, rcv_info)) {
log_err("Failed to add ga to graph adjacency manager list.");
flow_dealloc(fd);
- conn_info_fini(rcv_info);
free(rcv_info);
return -1;
}
@@ -222,11 +215,15 @@ int gam_flow_alloc(struct gam * instance,
qosspec_t qs)
{
struct conn_info * rcv_info;
- struct conn_info snd_info;
+ struct conn_info snd_info;
int fd;
log_dbg("Allocating flow to %s.", dst_name);
+ rcv_info = malloc(sizeof(*rcv_info));
+ if (rcv_info == NULL)
+ return -ENOMEM;
+
fd = flow_alloc(dst_name, NULL);
if (fd < 0) {
log_err("Failed to allocate flow to %s.", dst_name);
@@ -239,34 +236,25 @@ int gam_flow_alloc(struct gam * instance,
return -1;
}
- conn_info_init(&snd_info);
- snd_info.proto.protocol = strdup(CDAP_PROTO);
- if (snd_info.proto.protocol == NULL) {
- conn_info_fini(&snd_info);
- return -ENOMEM;
- }
+ memset(&snd_info, 0, sizeof(snd_info));
+ memset(rcv_info, 0, sizeof(*rcv_info));
- 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) {
- conn_info_fini(&snd_info);
- return -ENOMEM;
- }
+ /* FIXME: send correct AE */
+ strcpy(snd_info.ae_name, "FIXME:CORRECT_AE");
+ strcpy(snd_info.protocol, CDAP_PROTO);
+ snd_info.pref_version = 1;
+ snd_info.pref_syntax = PROTO_GPB;
+ snd_info.ae.addr = ipcpi.address;
- rcv_info = cacep_auth(fd, SIMPLE_AUTH, &snd_info, NULL);
- if (rcv_info == NULL) {
- log_err("Other side failed to authenticate.");
- conn_info_fini(&snd_info);
+ if (cacep_connect(fd, &snd_info, rcv_info)) {
+ log_err("Failed to create application connection.");
+ flow_dealloc(fd);
+ free(rcv_info);
return -1;
}
- conn_info_fini(&snd_info);
-
if (instance->ops->accept_flow(instance->ops_o, qs, rcv_info)) {
flow_dealloc(fd);
- conn_info_fini(rcv_info);
free(rcv_info);
return 0;
}
@@ -274,7 +262,6 @@ int gam_flow_alloc(struct gam * instance,
if (add_ga(instance, fd, qs, rcv_info)) {
log_err("Failed to add GA to graph adjacency manager list.");
flow_dealloc(fd);
- conn_info_fini(rcv_info);
free(rcv_info);
return -1;
}
@@ -282,10 +269,10 @@ int gam_flow_alloc(struct gam * instance,
return 0;
}
-int gam_flow_wait(struct gam * instance,
- int * fd,
+int gam_flow_wait(struct gam * instance,
+ int * fd,
struct conn_info ** info,
- qosspec_t * qs)
+ qosspec_t * qs)
{
struct ga * ga;