natd 1_10 => 1_11

Cosmetic style changes
  Use u_short for port values.
Submitted by:	Ari Suutari <ari@suutari.iki.fi>
This commit is contained in:
Brian Somers 1997-12-10 02:14:57 +00:00
parent c55f0f1425
commit 67a886fb97
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=31660
4 changed files with 140 additions and 122 deletions

View File

@ -117,3 +117,8 @@
- Ignored incoming packets are now dropped when
deny_incoming option is set to yes.
- Packet aliasing library upgraded to 2.4.
* Version 1.11
- Code cleanup work done in FreeBSD-current development merged.
- Port numbers are now unsigned as they should always have been.

View File

@ -36,6 +36,7 @@
#include <string.h>
#include <syslog.h>
#include <unistd.h>
#include "natd.h"
/*
@ -64,9 +65,9 @@ static void SetupPermanentLink (char* parms);
static void SetupPortRedirect (char* parms);
static void SetupAddressRedirect (char* parms);
static void StrToAddr (char* str, struct in_addr* addr);
static int StrToPort (char* str, char* proto);
static u_short StrToPort (char* str, char* proto);
static int StrToProto (char* str);
static int StrToAddrAndPort (char* str, struct in_addr* addr, char* proto);
static u_short StrToAddrAndPort (char* str, struct in_addr* addr, char* proto);
static void ParseArgs (int argc, char** argv);
static void FlushPacketBuffer (int fd);
@ -80,9 +81,9 @@ static int running;
static int assignAliasAddr;
static char* ifName;
static int ifIndex;
static int inPort;
static int outPort;
static int inOutPort;
static u_short inPort;
static u_short outPort;
static u_short inOutPort;
static struct in_addr aliasAddr;
static int dynamicMode;
static int ifMTU;
@ -138,8 +139,8 @@ int main (int argc, char** argv)
errx (1, "aliasing address not given");
if (aliasAddr.s_addr != INADDR_NONE && ifName != NULL)
errx(1,
"both alias address and interface name are not allowed");
errx (1, "both alias address and interface "
"name are not allowed");
/*
* Check that valid port number is known.
*/
@ -930,6 +931,7 @@ static void ParseOption (char* option, char* parms, int cmdLine)
int yesNoValue;
int aliasValue;
int numValue;
u_short uNumValue;
char* strValue;
struct in_addr addrValue;
int max;
@ -954,6 +956,7 @@ static void ParseOption (char* option, char* parms, int cmdLine)
Usage ();
}
uNumValue = 0;
yesNoValue = 0;
numValue = 0;
strValue = NULL;
@ -976,10 +979,11 @@ static void ParseOption (char* option, char* parms, int cmdLine)
case Service:
if (!parms)
errx(1,
"%s needs service name or port number parameter", option);
errx (1, "%s needs service name or "
"port number parameter",
option);
numValue = StrToPort (parms, "divert");
uNumValue = StrToPort (parms, "divert");
break;
case Numeric:
@ -1027,15 +1031,15 @@ static void ParseOption (char* option, char* parms, int cmdLine)
break;
case InPort:
inPort = numValue;
inPort = uNumValue;
break;
case OutPort:
outPort = numValue;
outPort = uNumValue;
break;
case Port:
inOutPort = numValue;
inOutPort = uNumValue;
break;
case AliasAddress:
@ -1086,7 +1090,7 @@ void ReadConfigFile (char* fileName)
ptr = strchr (buf, '\n');
if (!ptr)
errx(1, "config line too link: %s", buf);
errx (1, "config line too long: %s", buf);
*ptr = '\0';
if (buf[0] == '#')
@ -1155,9 +1159,9 @@ void SetupPermanentLink (char* parms)
char* ptr;
struct in_addr srcAddr;
struct in_addr dstAddr;
int srcPort;
int dstPort;
int aliasPort;
u_short srcPort;
u_short dstPort;
u_short aliasPort;
int proto;
char* protoName;
@ -1210,9 +1214,9 @@ void SetupPortRedirect (char* parms)
struct in_addr localAddr;
struct in_addr publicAddr;
struct in_addr remoteAddr;
int localPort;
int publicPort;
int remotePort;
u_short localPort;
u_short publicPort;
u_short remotePort;
int proto;
char* protoName;
char* separator;
@ -1324,9 +1328,9 @@ void StrToAddr (char* str, struct in_addr* addr)
memcpy (addr, hp->h_addr, sizeof (struct in_addr));
}
int StrToPort (char* str, char* proto)
u_short StrToPort (char* str, char* proto)
{
int port;
u_short port;
struct servent* sp;
char* end;
@ -1352,7 +1356,7 @@ int StrToProto (char* str)
errx (1, "unknown protocol %s. Expected tcp or udp", str);
}
int StrToAddrAndPort (char* str, struct in_addr* addr, char* proto)
u_short StrToAddrAndPort (char* str, struct in_addr* addr, char* proto)
{
char* ptr;

View File

@ -117,3 +117,8 @@
- Ignored incoming packets are now dropped when
deny_incoming option is set to yes.
- Packet aliasing library upgraded to 2.4.
* Version 1.11
- Code cleanup work done in FreeBSD-current development merged.
- Port numbers are now unsigned as they should always have been.

View File

@ -36,6 +36,7 @@
#include <string.h>
#include <syslog.h>
#include <unistd.h>
#include "natd.h"
/*
@ -64,9 +65,9 @@ static void SetupPermanentLink (char* parms);
static void SetupPortRedirect (char* parms);
static void SetupAddressRedirect (char* parms);
static void StrToAddr (char* str, struct in_addr* addr);
static int StrToPort (char* str, char* proto);
static u_short StrToPort (char* str, char* proto);
static int StrToProto (char* str);
static int StrToAddrAndPort (char* str, struct in_addr* addr, char* proto);
static u_short StrToAddrAndPort (char* str, struct in_addr* addr, char* proto);
static void ParseArgs (int argc, char** argv);
static void FlushPacketBuffer (int fd);
@ -80,9 +81,9 @@ static int running;
static int assignAliasAddr;
static char* ifName;
static int ifIndex;
static int inPort;
static int outPort;
static int inOutPort;
static u_short inPort;
static u_short outPort;
static u_short inOutPort;
static struct in_addr aliasAddr;
static int dynamicMode;
static int ifMTU;
@ -138,8 +139,8 @@ int main (int argc, char** argv)
errx (1, "aliasing address not given");
if (aliasAddr.s_addr != INADDR_NONE && ifName != NULL)
errx(1,
"both alias address and interface name are not allowed");
errx (1, "both alias address and interface "
"name are not allowed");
/*
* Check that valid port number is known.
*/
@ -930,6 +931,7 @@ static void ParseOption (char* option, char* parms, int cmdLine)
int yesNoValue;
int aliasValue;
int numValue;
u_short uNumValue;
char* strValue;
struct in_addr addrValue;
int max;
@ -954,6 +956,7 @@ static void ParseOption (char* option, char* parms, int cmdLine)
Usage ();
}
uNumValue = 0;
yesNoValue = 0;
numValue = 0;
strValue = NULL;
@ -976,10 +979,11 @@ static void ParseOption (char* option, char* parms, int cmdLine)
case Service:
if (!parms)
errx(1,
"%s needs service name or port number parameter", option);
errx (1, "%s needs service name or "
"port number parameter",
option);
numValue = StrToPort (parms, "divert");
uNumValue = StrToPort (parms, "divert");
break;
case Numeric:
@ -1027,15 +1031,15 @@ static void ParseOption (char* option, char* parms, int cmdLine)
break;
case InPort:
inPort = numValue;
inPort = uNumValue;
break;
case OutPort:
outPort = numValue;
outPort = uNumValue;
break;
case Port:
inOutPort = numValue;
inOutPort = uNumValue;
break;
case AliasAddress:
@ -1086,7 +1090,7 @@ void ReadConfigFile (char* fileName)
ptr = strchr (buf, '\n');
if (!ptr)
errx(1, "config line too link: %s", buf);
errx (1, "config line too long: %s", buf);
*ptr = '\0';
if (buf[0] == '#')
@ -1155,9 +1159,9 @@ void SetupPermanentLink (char* parms)
char* ptr;
struct in_addr srcAddr;
struct in_addr dstAddr;
int srcPort;
int dstPort;
int aliasPort;
u_short srcPort;
u_short dstPort;
u_short aliasPort;
int proto;
char* protoName;
@ -1210,9 +1214,9 @@ void SetupPortRedirect (char* parms)
struct in_addr localAddr;
struct in_addr publicAddr;
struct in_addr remoteAddr;
int localPort;
int publicPort;
int remotePort;
u_short localPort;
u_short publicPort;
u_short remotePort;
int proto;
char* protoName;
char* separator;
@ -1324,9 +1328,9 @@ void StrToAddr (char* str, struct in_addr* addr)
memcpy (addr, hp->h_addr, sizeof (struct in_addr));
}
int StrToPort (char* str, char* proto)
u_short StrToPort (char* str, char* proto)
{
int port;
u_short port;
struct servent* sp;
char* end;
@ -1352,7 +1356,7 @@ int StrToProto (char* str)
errx (1, "unknown protocol %s. Expected tcp or udp", str);
}
int StrToAddrAndPort (char* str, struct in_addr* addr, char* proto)
u_short StrToAddrAndPort (char* str, struct in_addr* addr, char* proto)
{
char* ptr;