From 84e3dee4ff0d5c2bd16848caae8e3a5d7987d0dd Mon Sep 17 00:00:00 2001 From: Martin Koegler Date: Thu, 3 Mar 2011 19:32:09 +0100 Subject: [PATCH] Add support for NAT in the tunneling client Signed-off-by: Martin Koegler --- eibd/backend/eibnettunnel.cpp | 3 +++ eibd/server/b-EIBNETIPTUNNEL.h | 44 ++++++++++++++++++++++++++++++++++++++++++ eibd/server/layer2create.h | 1 + 3 files changed, 48 insertions(+) diff --git a/eibd/backend/eibnettunnel.cpp b/eibd/backend/eibnettunnel.cpp index ab2b718..60638c4 100644 --- a/eibd/backend/eibnettunnel.cpp +++ b/eibd/backend/eibnettunnel.cpp @@ -241,12 +241,15 @@ EIBNetIPTunnel::Run (pth_sem_t * stop1) EIBNetIPPacket p; EIBNetIPPacket *p1; EIBnet_ConnectRequest creq; + creq.nat = saddr.sin_addr.s_addr == 0; EIBnet_ConnectResponse cresp; EIBnet_ConnectionStateRequest csreq; + csreq.nat = saddr.sin_addr.s_addr == 0; EIBnet_ConnectionStateResponse csresp; EIBnet_TunnelRequest treq; EIBnet_TunnelACK tresp; EIBnet_DisconnectRequest dreq; + dreq.nat = saddr.sin_addr.s_addr == 0; EIBnet_DisconnectResponse dresp; creq.caddr = saddr; creq.daddr = saddr; diff --git a/eibd/server/b-EIBNETIPTUNNEL.h b/eibd/server/b-EIBNETIPTUNNEL.h index c283916..7e7b52c 100644 --- a/eibd/server/b-EIBNETIPTUNNEL.h +++ b/eibd/server/b-EIBNETIPTUNNEL.h @@ -30,6 +30,14 @@ #define EIBNETIPTUNNEL_CREATE eibnetiptunnel_Create #define EIBNETIPTUNNEL_CLEANUP NULL +#define EIBNETIPTUNNELNAT_URL "iptn:router-ip[:dest-port[:src-port]]\n" +#define EIBNETIPTUNNELNAT_DOC "iptn connects with the EIBnet/IP Tunneling protocol over an EIBnet/IP gateway using the NAT mode\n\n" + +#define EIBNETIPTUNNELNAT_PREFIX "iptn" +#define EIBNETIPTUNNELNAT_CREATE eibnetiptunnelnat_Create +#define EIBNETIPTUNNELNAT_CLEANUP NULL + + inline Layer2Interface * eibnetiptunnel_Create (const char *dev, int flags, Trace * t) { @@ -85,5 +93,41 @@ eibnetiptunnel_Create (const char *dev, int flags, Trace * t) return iface; } +inline Layer2Interface * +eibnetiptunnelnat_Create (const char *dev, int flags, Trace * t) +{ + char *a = strdup (dev); + char *b; + char *c; + int dport; + int sport; + Layer2Interface *iface; + if (!a) + die ("out of memory"); + for (b = a; *b; b++) + if (*b == ':') + break; + sport = 3672; + if (*b == ':') + { + *b = 0; + for (c = b + 1; *c; c++) + if (*c == ':') + break; + if (*c == ':') + { + *c = 0; + sport = atoi (c + 1); + } + dport = atoi (b + 1); + } + else + dport = 3671; + + iface = new EIBNetIPTunnel (a, dport, sport, "0.0.0.0", -1, flags, t); + free (a); + return iface; +} + #endif diff --git a/eibd/server/layer2create.h b/eibd/server/layer2create.h index cfe1dbc..e9e3a1f 100644 --- a/eibd/server/layer2create.h +++ b/eibd/server/layer2create.h @@ -32,6 +32,7 @@ L2_NAME (FT12) #endif #ifdef HAVE_EIBNETIPTUNNEL L2_NAME (EIBNETIPTUNNEL) + L2_NAME (EIBNETIPTUNNELNAT) #endif #ifdef HAVE_PEI16s L2_NAME (PEI16s) -- 2.11.4.GIT