diff options
author | dimitri staessens <[email protected]> | 2017-02-28 13:56:57 +0000 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2017-02-28 13:56:57 +0000 |
commit | a5796c7f02570a2878f9c6a5d28dca80beabed12 (patch) | |
tree | c69603a29712665f3c7e8ee4e90d7209d61d3d85 /src/ipcpd/normal/cdap_flow.c | |
parent | 6450c9d385ff9ec5234a489130a45378cafb8a6e (diff) | |
parent | e6f5d45855b4a8091b52b3fc91451d2d132a5a6d (diff) | |
download | ouroboros-a5796c7f02570a2878f9c6a5d28dca80beabed12.tar.gz ouroboros-a5796c7f02570a2878f9c6a5d28dca80beabed12.zip |
Merged in dstaesse/ouroboros/be-cacep (pull request #394)
lib: Split CACEP into request/response protocol
Diffstat (limited to 'src/ipcpd/normal/cdap_flow.c')
-rw-r--r-- | src/ipcpd/normal/cdap_flow.c | 48 |
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."); |