aboutsummaryrefslogtreecommitdiffstats
path: root/metis
diff options
context:
space:
mode:
authormicpapal <micpapal+fdio@cisco.com>2018-02-16 04:11:07 -0800
committermicpapal <micpapal+fdio@cisco.com>2018-02-16 04:11:07 -0800
commitd92759bde48a830bd87498ee95c85cf2b8184c9c (patch)
tree404483f8afe083fc5c1fe5970bff56eb98dd13d3 /metis
parentc2c5fc6b5c2b27ed4c1d1e16a9119cb214099948 (diff)
connections on the server side are created automatically
Change-Id: Idd97ef1dbc4a84d5eeee17538d54668a8f2361b9 Signed-off-by: micpapal <micpapal+fdio@cisco.com>
Diffstat (limited to 'metis')
-rw-r--r--metis/ccnx/forwarder/metis/config/metis_Configuration.c25
-rw-r--r--metis/ccnx/forwarder/metis/io/metis_UdpListener.c44
2 files changed, 44 insertions, 25 deletions
diff --git a/metis/ccnx/forwarder/metis/config/metis_Configuration.c b/metis/ccnx/forwarder/metis/config/metis_Configuration.c
index 3703c6ef..4a72ab41 100644
--- a/metis/ccnx/forwarder/metis/config/metis_Configuration.c
+++ b/metis/ccnx/forwarder/metis/config/metis_Configuration.c
@@ -47,6 +47,7 @@
#include <ccnx/forwarder/metis/core/metis_Forwarder.h>
#include <ccnx/forwarder/metis/core/metis_System.h>
+#include <ccnx/forwarder/metis/io/metis_AddressPair.h>
#include <ccnx/forwarder/metis/core/metis_ConnectionTable.h>
#include <ccnx/forwarder/metis/core/metis_Connection.h>
@@ -351,14 +352,34 @@ static CCNxControl *
metisConfiguration_ProcessCreateTunnel(MetisConfiguration *config, CCNxControl *control, unsigned ingressId)
{
bool success = false;
+ bool exists = true;
CPIInterfaceIPTunnel *iptun = cpiLinks_CreateIPTunnelFromControlMessage(control);
const char *symbolicName = cpiInterfaceIPTunnel_GetSymbolicName(iptun);
+ const CPIAddress *source;
+ const CPIAddress *destination;
+
if (!metisSymbolicNameTable_Exists(config->symbolicNameTable, symbolicName)) {
- const CPIAddress *source = cpiInterfaceIPTunnel_GetSourceAddress(iptun);
- const CPIAddress *destination = cpiInterfaceIPTunnel_GetDestinationAddress(iptun);
+ source = cpiInterfaceIPTunnel_GetSourceAddress(iptun);
+ destination = cpiInterfaceIPTunnel_GetDestinationAddress(iptun);
+
+ MetisAddressPair *pair = metisAddressPair_Create(source, destination);
+ const MetisConnection *conn =
+ metisConnectionTable_FindByAddressPair(metisForwarder_GetConnectionTable(config->metis), pair);
+
+ metisAddressPair_Release(&pair);
+
+ if(conn == NULL){
+ //the connection does not exists (even without a name)
+ exists = false;
+ }
+ }
+
+ if(!exists){
+ source = cpiInterfaceIPTunnel_GetSourceAddress(iptun);
+ destination = cpiInterfaceIPTunnel_GetDestinationAddress(iptun);
MetisIoOperations *ops = NULL;
switch (cpiInterfaceIPTunnel_GetTunnelType(iptun)) {
diff --git a/metis/ccnx/forwarder/metis/io/metis_UdpListener.c b/metis/ccnx/forwarder/metis/io/metis_UdpListener.c
index 1bd54187..342f7ce4 100644
--- a/metis/ccnx/forwarder/metis/io/metis_UdpListener.c
+++ b/metis/ccnx/forwarder/metis/io/metis_UdpListener.c
@@ -25,6 +25,7 @@
#include <ccnx/forwarder/metis/io/metis_UdpListener.h>
#include <ccnx/forwarder/metis/io/metis_UdpConnection.h>
+#include <ccnx/forwarder/metis/io/metis_UdpTunnel.h>
#include <ccnx/forwarder/metis/core/metis_Forwarder.h>
#include <ccnx/forwarder/metis/core/metis_Connection.h>
@@ -459,23 +460,20 @@ _lookupConnectionId(MetisUdpListener *udp, MetisAddressPair *pair, unsigned *out
* @return The connection id for the new connection
*/
-//for the moment this is not used anymore
-//we need to handle the connection tables in a better way in order to avoid multiple connections
-//with the same address pair.
-/*static unsigned
- * _createNewConnection(MetisUdpListener *udp, int fd, const MetisAddressPair *pair)
- * {
- * bool isLocal = false;
- *
- * // metisUdpConnection_Create takes ownership of the pair
- * MetisIoOperations *ops = metisUdpConnection_Create(udp->metis, fd, pair, isLocal);
- * MetisConnection *conn = metisConnection_Create(ops);
- *
- * metisConnectionTable_Add(metisForwarder_GetConnectionTable(udp->metis), conn);
- * unsigned connid = metisIoOperations_GetConnectionId(ops);
- *
- * return connid;
- * }*/
+static unsigned
+_createNewConnection(MetisUdpListener * udp, int fd, const MetisAddressPair * pair)
+{
+ bool isLocal = false;
+
+ // metisUdpConnection_Create takes ownership of the pair
+ MetisIoOperations * ops = metisUdpConnection_Create(udp->metis, fd, pair, isLocal);
+ MetisConnection * conn = metisConnection_Create(ops);
+
+ metisConnectionTable_Add(metisForwarder_GetConnectionTable(udp->metis), conn);
+ unsigned connid = metisIoOperations_GetConnectionId(ops);
+
+ return connid;
+}
static void
_receivePacket(MetisUdpListener *udp, int fd, size_t packetLength, struct sockaddr_storage *peerIpAddress, socklen_t peerIpAddressLength)
@@ -485,12 +483,12 @@ _receivePacket(MetisUdpListener *udp, int fd, size_t packetLength, struct sockad
bool foundConnection = _lookupConnectionId(udp, pair, &connid);
if (!foundConnection) {
- PARCEventBuffer *readbuffer = parcEventBuffer_Create();
- parcEventBuffer_ReadFromFileDescriptor(readbuffer, fd, packetLength);
- parcEventBuffer_Destroy(&readbuffer);
- metisAddressPair_Release(&pair);
- return;
- //connid = _createNewConnection(udp, fd, pair);
+ //PARCEventBuffer *readbuffer = parcEventBuffer_Create();
+ //parcEventBuffer_ReadFromFileDescriptor(readbuffer, fd, packetLength);
+ //parcEventBuffer_Destroy(&readbuffer);
+ //metisAddressPair_Release(&pair);
+ //return;
+ connid = _createNewConnection(udp, fd, pair);
}
metisAddressPair_Release(&pair);