diff options
author | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2016-10-27 16:41:03 +0000 |
---|---|---|
committer | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2016-10-27 16:41:03 +0000 |
commit | 64c8f8f3371799b8e818569666fd85e723c84d3a (patch) | |
tree | 9eea2090fc2083b5cd27d8fde2829075ef8cdeb0 /src/ipcpd/normal/frct.c | |
parent | e84e294de2e73db418e8f249d795d2dd6c6faae0 (diff) | |
parent | 09a348b325e2b819e3deb952c1b3a6b141d75572 (diff) | |
download | ouroboros-64c8f8f3371799b8e818569666fd85e723c84d3a.tar.gz ouroboros-64c8f8f3371799b8e818569666fd85e723c84d3a.zip |
Merged in sandervrijders/ouroboros/be-fix-conn (pull request #291)0.3
ipcpd: normal: Fix bugs in connection establishment
Diffstat (limited to 'src/ipcpd/normal/frct.c')
-rw-r--r-- | src/ipcpd/normal/frct.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/ipcpd/normal/frct.c b/src/ipcpd/normal/frct.c index 3f80f91e..ff980772 100644 --- a/src/ipcpd/normal/frct.c +++ b/src/ipcpd/normal/frct.c @@ -156,7 +156,8 @@ int frct_nm1_post_sdu(struct pci * pci, if (pci == NULL || sdb == NULL) return -1; - if (pci->dst_cep_id == INVALID_CEP_ID) { + if (pci->dst_cep_id == INVALID_CEP_ID && + pci->pdu_type == PDU_TYPE_MGMT) { pthread_mutex_lock(&frct.instances_lock); instance = create_frct_i(pci->src_addr, pci->src_cep_id); @@ -176,6 +177,25 @@ int frct_nm1_post_sdu(struct pci * pci, free(pci); return -1; } + } else if (pci->pdu_type == PDU_TYPE_MGMT) { + pthread_mutex_lock(&frct.instances_lock); + instance = frct.instances[pci->dst_cep_id]; + if (instance == NULL) { + pthread_mutex_unlock(&frct.instances_lock); + return -1; + } + instance->r_cep_id = pci->src_cep_id; + instance->state = CONN_ESTABLISHED; + pthread_mutex_unlock(&frct.instances_lock); + + buf.len = shm_du_buff_tail(sdb) - shm_du_buff_head(sdb); + buf.data = shm_du_buff_head(sdb); + + if (fmgr_np1_post_buf(pci->dst_cep_id, &buf)) { + LOG_ERR("Failed to hand buffer to Flow Manager."); + free(pci); + return -1; + } } else { /* FIXME: Known cep-ids are delivered to FMGR (minimal DTP) */ if (fmgr_np1_post_sdu(pci->dst_cep_id, sdb)) { @@ -357,5 +377,7 @@ int frct_i_write_sdu(cep_id_t id, return -1; } + pthread_mutex_unlock(&frct.instances_lock); + return 0; } |