aboutsummaryrefslogtreecommitdiff
path: root/sbin/natd/natd.c
diff options
context:
space:
mode:
authorRuslan Ermilov <ru@FreeBSD.org>1999-09-28 08:01:46 +0000
committerRuslan Ermilov <ru@FreeBSD.org>1999-09-28 08:01:46 +0000
commitf2da55a243b8fa54c970a662c92d99c7137d4b1f (patch)
tree62e08c73760de6093a19b97e4a8fe4073ba378dc /sbin/natd/natd.c
parent810b4d751fb8d38ed09e1fc4e985e35035a4936c (diff)
downloadsrc-f2da55a243b8fa54c970a662c92d99c7137d4b1f.tar.gz
src-f2da55a243b8fa54c970a662c92d99c7137d4b1f.zip
Notes
Diffstat (limited to 'sbin/natd/natd.c')
-rw-r--r--sbin/natd/natd.c34
1 files changed, 15 insertions, 19 deletions
diff --git a/sbin/natd/natd.c b/sbin/natd/natd.c
index bde38f7a5a69..8a5833b6ff32 100644
--- a/sbin/natd/natd.c
+++ b/sbin/natd/natd.c
@@ -254,16 +254,21 @@ int main (int argc, char** argv)
Quit ("Unable to bind outgoing divert socket.");
}
/*
- * Create routing socket if interface name specified.
+ * Create routing socket if interface name specified and in dynamic mode.
*/
- if (ifName && dynamicMode) {
+ routeSock = -1;
+ if (ifName) {
+ if (dynamicMode) {
- routeSock = socket (PF_ROUTE, SOCK_RAW, 0);
- if (routeSock == -1)
- Quit ("Unable to create routing info socket.");
+ routeSock = socket (PF_ROUTE, SOCK_RAW, 0);
+ if (routeSock == -1)
+ Quit ("Unable to create routing info socket.");
+
+ assignAliasAddr = 1;
+ }
+ else
+ SetAliasAddressFromIfName (ifName);
}
- else
- routeSock = -1;
/*
* Create socket for sending ICMP messages.
*/
@@ -707,7 +712,6 @@ static void SetAliasAddressFromIfName (char* ifn)
{
struct ifconf cf;
struct ifreq buf[32];
- char msg[80];
struct ifreq* ifPtr;
int extra;
int helperSock;
@@ -720,22 +724,16 @@ static void SetAliasAddressFromIfName (char* ifn)
* Create a dummy socket to access interface information.
*/
helperSock = socket (AF_INET, SOCK_DGRAM, 0);
- if (helperSock == -1) {
-
+ if (helperSock == -1)
Quit ("Failed to create helper socket.");
- exit (1);
- }
cf.ifc_len = sizeof (buf);
cf.ifc_req = buf;
/*
* Get interface data.
*/
- if (ioctl (helperSock, SIOCGIFCONF, &cf) == -1) {
-
+ if (ioctl (helperSock, SIOCGIFCONF, &cf) == -1)
Quit ("Ioctl SIOCGIFCONF failed.");
- exit (1);
- }
ifIndex = 0;
ifPtr = buf;
@@ -775,8 +773,7 @@ static void SetAliasAddressFromIfName (char* ifn)
if (!found) {
close (helperSock);
- sprintf (msg, "Unknown interface name %s.\n", ifn);
- Quit (msg);
+ errx (1, "Unknown interface name %s.\n", ifn);
}
/*
* Get MTU size.
@@ -1209,7 +1206,6 @@ static void ParseOption (const char* option, const char* parms, int cmdLine)
free (ifName);
ifName = strdup (strValue);
- assignAliasAddr = 1;
break;
case ConfigFile: