summaryrefslogtreecommitdiff
path: root/src/ipcpd/normal/cdap_flow.c
diff options
context:
space:
mode:
authordimitri staessens <[email protected]>2017-02-27 22:59:52 +0100
committerdimitri staessens <[email protected]>2017-02-28 14:48:16 +0100
commite6f5d45855b4a8091b52b3fc91451d2d132a5a6d (patch)
treec69603a29712665f3c7e8ee4e90d7209d61d3d85 /src/ipcpd/normal/cdap_flow.c
parentd06cb62e111be1ac3f09398ae559f99e4833b4bf (diff)
downloadouroboros-e6f5d45855b4a8091b52b3fc91451d2d132a5a6d.tar.gz
ouroboros-e6f5d45855b4a8091b52b3fc91451d2d132a5a6d.zip
lib: Split CACEP into request/response protocol
Diffstat (limited to 'src/ipcpd/normal/cdap_flow.c')
-rw-r--r--src/ipcpd/normal/cdap_flow.c48
1 files changed, 44 insertions, 4 deletions
diff --git a/src/ipcpd/normal/cdap_flow.c b/src/ipcpd/normal/cdap_flow.c
index d3d98884..c694e637 100644
--- a/src/ipcpd/normal/cdap_flow.c
+++ b/src/ipcpd/normal/cdap_flow.c
@@ -67,12 +67,32 @@ struct cdap_flow * cdap_flow_arr(int fd,
flow->fd = fd;
flow->ci = NULL;
- if (cacep_listen(fd, info, &flow->info)) {
+ if (cacep_rcv(fd, &flow->info)) {
log_err("Error establishing application connection.");
cdap_flow_destroy(flow);
return NULL;
}
+ if (cacep_snd(fd, info)) {
+ log_err("Failed to respond to application connection request.");
+ cdap_flow_destroy(flow);
+ return NULL;
+ }
+
+ if (strcmp(flow->info.ae_name, info->ae_name)) {
+ log_err("Received connection for wrong AE.");
+ cdap_flow_destroy(flow);
+ return NULL;
+ }
+
+ if (strcmp(flow->info.protocol, info->protocol) ||
+ flow->info.pref_version != info->pref_version ||
+ flow->info.pref_syntax != info->pref_syntax) {
+ log_err("Unknown protocol.");
+ cdap_flow_destroy(flow);
+ return NULL;
+ }
+
flow->ci = cdap_create(fd);
if (flow->ci == NULL) {
log_err("Failed to create CDAP instance.");
@@ -87,8 +107,8 @@ struct cdap_flow * cdap_flow_alloc(const char * dst_name,
qosspec_t * qs,
const struct conn_info * info)
{
- struct cdap_flow * flow;
- int fd;
+ struct cdap_flow * flow;
+ int fd;
log_dbg("Allocating flow to %s.", dst_name);
@@ -120,12 +140,32 @@ struct cdap_flow * cdap_flow_alloc(const char * dst_name,
flow->fd = fd;
flow->ci = NULL;
- if (cacep_connect(fd, info, &flow->info)) {
+ if (cacep_snd(fd, info)) {
+ log_err("Failed to send connection request.");
+ cdap_flow_dealloc(flow);
+ return NULL;
+ }
+
+ if (cacep_rcv(fd, &flow->info)) {
log_err("Failed to connect to application.");
cdap_flow_dealloc(flow);
return NULL;
}
+ if (strcmp(flow->info.ae_name, info->ae_name)) {
+ log_err("Received connection for wrong AE.");
+ cdap_flow_destroy(flow);
+ return NULL;
+ }
+
+ if (strcmp(flow->info.protocol, info->protocol) ||
+ flow->info.pref_version != info->pref_version ||
+ flow->info.pref_syntax != info->pref_syntax) {
+ log_err("Unknown protocol.");
+ cdap_flow_destroy(flow);
+ return NULL;
+ }
+
flow->ci = cdap_create(fd);
if (flow->ci == NULL) {
log_err("Failed to create CDAP instance.");