summaryrefslogtreecommitdiff
path: root/src/ipcpd/normal/rmt.c
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@intec.ugent.be>2016-10-12 14:54:18 +0200
committerSander Vrijders <sander.vrijders@intec.ugent.be>2016-10-12 14:54:18 +0200
commit43e2f332770007a3fcea011ffb35e8fbb24a6205 (patch)
treec792e7674d1247fa95e096f746a3559e2f4f8b7e /src/ipcpd/normal/rmt.c
parent2ba45f5efe0486b88f91ecced451f74cc782e8a4 (diff)
downloadouroboros-43e2f332770007a3fcea011ffb35e8fbb24a6205.tar.gz
ouroboros-43e2f332770007a3fcea011ffb35e8fbb24a6205.zip
ipcpd: normal: Improve upon the internal design
This commit will remove the RMT component from the normal IPCP, as some of its functionality would else be duplicated in the FMGR. Now all reading from flows, either N-1 or N+1 is done in the FMGR, then either passed to the FRCT or a lookup is performed in the PFF (not there yet) and the PDU is forwarded.
Diffstat (limited to 'src/ipcpd/normal/rmt.c')
-rw-r--r--src/ipcpd/normal/rmt.c195
1 files changed, 0 insertions, 195 deletions
diff --git a/src/ipcpd/normal/rmt.c b/src/ipcpd/normal/rmt.c
deleted file mode 100644
index fa4c7edd..00000000
--- a/src/ipcpd/normal/rmt.c
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Ouroboros - Copyright (C) 2016
- *
- * The Relaying and Multiplexing task
- *
- * Sander Vrijders <sander.vrijders@intec.ugent.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#define OUROBOROS_PREFIX "flow-manager"
-
-#include <ouroboros/config.h>
-#include <ouroboros/logs.h>
-#include <ouroboros/select.h>
-#include <ouroboros/ipcp-dev.h>
-#include <ouroboros/errno.h>
-#include <ouroboros/dev.h>
-
-#include <stdlib.h>
-
-#include "rmt.h"
-#include "config.h"
-#include "frct.h"
-
-struct {
- pthread_t sdu_reader;
- struct flow_set * set;
- uint32_t address;
-
- /*
- * FIXME: Normally the PFF is held here,
- * for now we keep 1 fd to forward a PDU on
- */
- int fd;
-} rmt;
-
-int rmt_init(uint32_t address)
-{
- rmt.set = flow_set_create();
- if (rmt.set == NULL)
- return -1;
-
- rmt.address = address;
-
- return 0;
-}
-
-int rmt_fini()
-{
- flow_set_destroy(rmt.set);
-
- return 0;
-}
-
-void * rmt_sdu_reader(void * o)
-{
- struct timespec timeout = {0, FD_UPDATE_TIMEOUT};
- struct shm_du_buff * sdb;
- struct pci * pci;
-
- while (true) {
- int fd = flow_select(rmt.set, &timeout);
- if (fd == -ETIMEDOUT)
- continue;
-
- if (fd < 0) {
- LOG_ERR("Failed to get active fd.");
- continue;
- }
-
- if (ipcp_flow_read(fd, &sdb)) {
- LOG_ERR("Failed to read SDU from fd %d.", fd);
- continue;
- }
-
- pci = shm_pci_des(sdb);
- if (pci == NULL) {
- LOG_ERR("Failed to get PCI.");
- ipcp_flow_del(sdb);
- continue;
- }
-
- if (pci->dst_addr != rmt.address) {
- LOG_DBG("PDU needs to be forwarded.");
-
- if (pci->ttl == 0) {
- LOG_DBG("TTL was zero.");
- ipcp_flow_del(sdb);
- free(pci);
- continue;
- }
-
- if (shm_pci_dec_ttl(sdb)) {
- LOG_ERR("Failed to decrease TTL.");
- ipcp_flow_del(sdb);
- free(pci);
- continue;
- }
- /*
- * FIXME: Dropping for now, since
- * we don't have a PFF yet
- */
- ipcp_flow_del(sdb);
- free(pci);
- continue;
- }
-
- if (shm_pci_shrink(sdb)) {
- LOG_ERR("Failed to shrink PDU.");
- ipcp_flow_del(sdb);
- free(pci);
- continue;
- }
-
- if (frct_rmt_post_sdu(pci, sdb)) {
- LOG_ERR("Failed to hand PDU to FRCT.");
- ipcp_flow_del(sdb);
- free(pci);
- continue;
- }
- }
-
- return (void *) 0;
-}
-
-int rmt_dt_flow(int fd,
- enum qos_cube qos)
-{
- struct flow_set * set = rmt.set;
- if (set == NULL)
- return -1;
-
- flow_set_add(set, fd);
-
- /* FIXME: This will be removed once we have a PFF */
- rmt.fd = fd;
-
- return 0;
-}
-
-int rmt_frct_write_sdu(struct pci * pci,
- struct shm_du_buff * sdb)
-{
- if (shm_pci_ser(sdb, pci)) {
- LOG_ERR("Failed to serialize PDU.");
- ipcp_flow_del(sdb);
- return -1;
- }
-
- if (ipcp_flow_write(rmt.fd, sdb)) {
- LOG_ERR("Failed to write SDU to fd %d.", rmt.fd);
- ipcp_flow_del(sdb);
- return -1;
- }
-
- return 0;
-}
-
-int rmt_frct_write_buf(struct pci * pci,
- buffer_t * buf)
-{
- buffer_t * buffer;
-
- if (pci == NULL || buf == NULL || buf->data == NULL)
- return -1;
-
- buffer = shm_pci_ser_buf(buf, pci);
- if (buffer == NULL) {
- LOG_ERR("Failed to serialize buffer.");
- free(buf->data);
- return -1;
- }
-
- if (flow_write(rmt.fd, buffer->data, buffer->len) == -1) {
- LOG_ERR("Failed to write buffer to fd.");
- free(buffer);
- return -1;
- }
-
- free(buffer);
- return 0;
-}