summaryrefslogtreecommitdiffstats
path: root/hicn-light
diff options
context:
space:
mode:
authormichele papalini <micpapal@cisco.com>2019-02-28 17:23:58 +0100
committermichele papalini <micpapal@cisco.com>2019-02-28 17:23:58 +0100
commita7fe7e7cedfee8dd76c87180634686274b9e030a (patch)
tree22f1c946313cf0c51bb313b64565d5320b93261c /hicn-light
parent880795dec24dc966f8196e66b0fa1dd6debd958f (diff)
[HICN-84] check if a UDP connection is local
Change-Id: Ieca7f91c91013f336a4d570177aa0b089455fe6f Signed-off-by: michele papalini <micpapal@cisco.com>
Diffstat (limited to 'hicn-light')
-rw-r--r--hicn-light/src/io/udpListener.c14
-rw-r--r--hicn-light/src/io/udpTunnel.c14
2 files changed, 28 insertions, 0 deletions
diff --git a/hicn-light/src/io/udpListener.c b/hicn-light/src/io/udpListener.c
index c49571dd4..fefe116f9 100644
--- a/hicn-light/src/io/udpListener.c
+++ b/hicn-light/src/io/udpListener.c
@@ -29,6 +29,7 @@
#include <src/io/udpConnection.h>
#include <src/io/udpListener.h>
+#include <parc/algol/parc_Network.h>
#include <parc/algol/parc_Memory.h>
#include <parc/assert/parc_Assert.h>
#include <src/core/connection.h>
@@ -360,7 +361,20 @@ static bool _lookupConnectionId(UdpListener *udp, AddressPair *pair,
static unsigned _createNewConnection(UdpListener *udp, int fd,
const AddressPair *pair) {
+ //check it the connection is local
bool isLocal = false;
+ const Address *localAddress = addressPair_GetLocal(pair);
+ if(addressGetType(localAddress) == ADDR_INET){
+ struct sockaddr_in tmpAddr;
+ addressGetInet(localAddress, &tmpAddr);
+ if(parcNetwork_IsSocketLocal((struct sockaddr *)&tmpAddr))
+ isLocal = true;
+ }else{
+ struct sockaddr_in6 tmpAddr6;
+ addressGetInet6(localAddress, &tmpAddr6);
+ if(parcNetwork_IsSocketLocal((struct sockaddr *)&tmpAddr6))
+ isLocal = true;
+ }
// metisUdpConnection_Create takes ownership of the pair
IoOperations *ops = udpConnection_Create(udp->forwarder, fd, pair, isLocal);
diff --git a/hicn-light/src/io/udpTunnel.c b/hicn-light/src/io/udpTunnel.c
index d06a35ce6..d49f43f05 100644
--- a/hicn-light/src/io/udpTunnel.c
+++ b/hicn-light/src/io/udpTunnel.c
@@ -19,6 +19,7 @@
#include <stdio.h>
#include <string.h>
+#include <parc/algol/parc_Network.h>
#include <parc/assert/parc_Assert.h>
#include <src/io/udpConnection.h>
#include <src/io/udpListener.h>
@@ -42,7 +43,20 @@ IoOperations *udpTunnel_CreateOnListener(Forwarder *forwarder,
if (localType == remoteType) {
AddressPair *pair = addressPair_Create(localAddress, remoteAddress);
+
+ //check it the connection is local
bool isLocal = false;
+ if(localType == ADDR_INET){
+ struct sockaddr_in tmpAddr;
+ addressGetInet(localAddress, &tmpAddr);
+ if(parcNetwork_IsSocketLocal((struct sockaddr *)&tmpAddr))
+ isLocal = true;
+ }else{
+ struct sockaddr_in6 tmpAddr6;
+ addressGetInet6(localAddress, &tmpAddr6);
+ if(parcNetwork_IsSocketLocal((struct sockaddr *)&tmpAddr6))
+ isLocal = true;
+ }
int fd = localListener->getSocket(localListener);
// udpListener_SetPacketType(localListener,
// MessagePacketType_ContentObject);