From 09a348b325e2b819e3deb952c1b3a6b141d75572 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Thu, 27 Oct 2016 16:40:39 +0200 Subject: ipcpd: normal: Fix bugs in connection establishment This fixes some bugs in connection establishment over the normal IPCP. --- src/ipcpd/normal/frct.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/ipcpd/normal/frct.c') 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; } -- cgit v1.2.3