diff options
author | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2017-02-06 16:05:44 +0100 |
---|---|---|
committer | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2017-02-06 20:04:34 +0100 |
commit | 373efaf24d3600fe4dadf6bfaaee8d19e2ec32d7 (patch) | |
tree | 8711a4edbc2a6defaab63f0dcc2b0690252307b4 /src/ipcpd/normal/fmgr.c | |
parent | 4b11f952c521315883f64571e1790389e8d20f64 (diff) | |
download | ouroboros-373efaf24d3600fe4dadf6bfaaee8d19e2ec32d7.tar.gz ouroboros-373efaf24d3600fe4dadf6bfaaee8d19e2ec32d7.zip |
ipcpd, lib: Revise normal IPCP
This PR updates the normal IPCP to use the new RIB. The old ribmgr is
removed and replaced by a stub that needs to be implemented. All
components (dir, fmgr, frct) were adapted to the new RIB API. A lot
of functionality was moved outside of the ribmgr, such as the
addr_auth, which is now a component of the IPCP. The address is also
stored to the ipcpi struct. The irm tool has an option to set the gam
policy of the rib manager.
Diffstat (limited to 'src/ipcpd/normal/fmgr.c')
-rw-r--r-- | src/ipcpd/normal/fmgr.c | 100 |
1 files changed, 61 insertions, 39 deletions
diff --git a/src/ipcpd/normal/fmgr.c b/src/ipcpd/normal/fmgr.c index 6fe6fb60..6b21cdbf 100644 --- a/src/ipcpd/normal/fmgr.c +++ b/src/ipcpd/normal/fmgr.c @@ -29,22 +29,19 @@ #include <ouroboros/fqueue.h> #include <ouroboros/errno.h> #include <ouroboros/cacep.h> - -#include <stdlib.h> -#include <stdbool.h> -#include <pthread.h> -#include <string.h> +#include <ouroboros/rib.h> #include "fmgr.h" -#include "ribmgr.h" #include "frct.h" #include "ipcp.h" #include "shm_pci.h" -#include "dir.h" -#include "pathname.h" -#include "ro.h" #include "gam.h" +#include <stdlib.h> +#include <stdbool.h> +#include <pthread.h> +#include <string.h> + #include "flow_alloc.pb-c.h" typedef FlowAllocMsg flow_alloc_msg_t; @@ -167,10 +164,10 @@ void * fmgr_nm1_sdu_reader(void * o) continue; } - if (pci->dst_addr != ribmgr_address()) { + if (pci->dst_addr != ipcpi.address) { LOG_DBG("PDU needs to be forwarded."); - if (ribmgr_dt_const()->has_ttl) { + if (pci->has_ttl) { if (pci->ttl == 0) { LOG_DBG("TTL was zero."); ipcp_flow_del(sdb); @@ -269,8 +266,11 @@ static void fmgr_destroy_flows(void) } } -int fmgr_init() +int fmgr_init(void) { + enum pol_cacep pc; + enum pol_gam pg; + int i; for (i = 0; i < AP_MAX_FLOWS; ++i) @@ -305,7 +305,22 @@ int fmgr_init() } } - fmgr.gam = gam_create(ribmgr_dt_gam(), DT_AE); + if (rib_read("/" BOOT_NAME "/dt/gam/type", &pg, sizeof(pg)) + != sizeof(pg)) { + LOG_ERR("Failed to read policy for ribmgr gam."); + return -1; + } + + if (rib_read("/" BOOT_NAME "/dt/gam/cacep", &pc, sizeof(pc)) + != sizeof(pc)) { + LOG_ERR("Failed to read CACEP policy for ribmgr gam."); + return -1; + } + + /* FIXME: Implement cacep policies */ + (void) pc; + + fmgr.gam = gam_create(pg, DT_AE); if (fmgr.gam == NULL) { LOG_ERR("Failed to create graph adjacency manager."); fmgr_destroy_flows(); @@ -324,7 +339,7 @@ int fmgr_init() return 0; } -int fmgr_fini() +void fmgr_fini() { struct list_head * pos = NULL; struct list_head * n = NULL; @@ -359,8 +374,6 @@ int fmgr_fini() pthread_rwlock_destroy(&fmgr.np1_flows_lock); fmgr_destroy_flows(); - - return 0; } int fmgr_np1_alloc(int fd, @@ -371,27 +384,43 @@ int fmgr_np1_alloc(int fd, cep_id_t cep_id; buffer_t buf; flow_alloc_msg_t msg = FLOW_ALLOC_MSG__INIT; - char * path; - uint8_t * ro_data; + char path[RIB_MAX_PATH_LEN + 1]; uint64_t addr; + ssize_t ch; + ssize_t i; + char ** children; + char * dst_ipcp = NULL; - path = pathname_create(RO_DIR); - if (path == NULL) - return -1; + assert(strlen(dst_ap_name) + strlen("/" DIR_NAME) + 1 + < RIB_MAX_PATH_LEN); + + strcpy(path, "/" DIR_NAME); + + rib_path_append(path, dst_ap_name); - path = pathname_append(path, dst_ap_name); - if (path == NULL) { - pathname_destroy(path); + ch = rib_children(path, &children); + if (ch <= 0) return -1; - } - if (ro_read(path, &ro_data) < 0) { - pathname_destroy(path); + for (i = 0; i < ch; ++i) + if (dst_ipcp == NULL && strcmp(children[i], ipcpi.name) != 0) + dst_ipcp = children[i]; + else + free(children[i]); + + free(children); + + if (dst_ipcp == NULL) return -1; - } - addr = *((uint64_t *) ro_data); - pathname_destroy(path); + strcpy(path, "/" MEMBERS_NAME); + + rib_path_append(path, dst_ipcp); + + free(dst_ipcp); + + if (rib_read(path, &addr, sizeof(addr)) < 0) + return -1; msg.code = FLOW_ALLOC_CODE__FLOW_REQ; msg.dst_name = dst_ap_name; @@ -400,16 +429,12 @@ int fmgr_np1_alloc(int fd, msg.qoscube = cube; buf.len = flow_alloc_msg__get_packed_size(&msg); - if (buf.len == 0) { - free(ro_data); + if (buf.len == 0) return -1; - } buf.data = malloc(buf.len); - if (buf.data == NULL) { - free(ro_data); + if (buf.data == NULL) return -1; - } flow_alloc_msg__pack(&msg, buf.data); @@ -417,14 +442,11 @@ int fmgr_np1_alloc(int fd, cep_id = frct_i_create(addr, &buf, cube); if (cep_id == INVALID_CEP_ID) { - free(ro_data); free(buf.data); pthread_rwlock_unlock(&fmgr.np1_flows_lock); return -1; } - free(ro_data); - fmgr.np1_fd_to_cep_id[fd] = cep_id; fmgr.np1_cep_id_to_fd[cep_id] = fd; |