From a7fe7e7cedfee8dd76c87180634686274b9e030a Mon Sep 17 00:00:00 2001 From: michele papalini Date: Thu, 28 Feb 2019 17:23:58 +0100 Subject: [HICN-84] check if a UDP connection is local Change-Id: Ieca7f91c91013f336a4d570177aa0b089455fe6f Signed-off-by: michele papalini --- hicn-light/src/io/udpListener.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'hicn-light/src/io/udpListener.c') 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 #include +#include #include #include #include @@ -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); -- cgit