diff options
author | Sander Vrijders <sander.vrijders@intec.ugent.be> | 2016-10-27 16:40:39 +0200 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@intec.ugent.be> | 2016-10-27 18:40:31 +0200 |
commit | 09a348b325e2b819e3deb952c1b3a6b141d75572 (patch) | |
tree | 8b9a093c36db09513dfb333cc1c90763c3112df9 /src/ipcpd/normal/frct.c | |
parent | 6a61274c2289a06b4c23d5c8b2e36d924eb72a48 (diff) | |
download | ouroboros-09a348b325e2b819e3deb952c1b3a6b141d75572.tar.gz ouroboros-09a348b325e2b819e3deb952c1b3a6b141d75572.zip |
ipcpd: normal: Fix bugs in connection establishment
This fixes some bugs in connection establishment over the normal IPCP.
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; } |