summaryrefslogtreecommitdiff
path: root/sbin/isakmpd
diff options
context:
space:
mode:
authorNiklas Hallqvist <niklas@cvs.openbsd.org>1998-12-22 01:46:05 +0000
committerNiklas Hallqvist <niklas@cvs.openbsd.org>1998-12-22 01:46:05 +0000
commit85f537c98079f9206e5cef6cdd117e93a09e7f67 (patch)
treea5ea1e0082204601933a632e11f0a7255b5ae137 /sbin/isakmpd
parentf83983246b73a8e212a652c2a63267ff29d169bb (diff)
Remove obsolete connection code. Use strtol instead of atoi
Diffstat (limited to 'sbin/isakmpd')
-rw-r--r--sbin/isakmpd/udp.c83
1 files changed, 12 insertions, 71 deletions
diff --git a/sbin/isakmpd/udp.c b/sbin/isakmpd/udp.c
index 3bcd8fbf5f4..a483bbefb4a 100644
--- a/sbin/isakmpd/udp.c
+++ b/sbin/isakmpd/udp.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: udp.c,v 1.4 1998/12/21 01:02:27 niklas Exp $ */
-/* $EOM: udp.c,v 1.23 1998/12/15 16:58:48 niklas Exp $ */
+/* $OpenBSD: udp.c,v 1.5 1998/12/22 01:46:04 niklas Exp $ */
+/* $EOM: udp.c,v 1.24 1998/12/22 01:40:23 niklas Exp $ */
/*
* Copyright (c) 1998 Niklas Hallqvist. All rights reserved.
@@ -214,61 +214,6 @@ udp_bind_if (struct ifreq *ifrp, void *arg)
}
/*
- * ADDR_ARG is either a numeric IP address (we cannot risk doing DNS lookups
- * which might take considerable time) or an address and a UDP port number
- * separated by a colon. That address specifies a peer ISAKMP daemon we
- * will talk to. Setup and return a transport useable to talk to that
- * service.
- */
-static struct transport *
-udp_create_old (char *addr_arg)
-{
- struct sockaddr_in dst;
- char *addr_str, *port_str;
- in_addr_t addr;
- in_port_t port;
-
- addr_str = strdup (addr_arg);
- if (!addr_str)
- {
- log_print ("udp_create_old: strdup (\"%s\") failed", addr_arg);
- return 0;
- }
-
- port_str = strchr (addr_str, ':');
- if (port_str)
- {
- *port_str++ = '\0';
- port = atoi (port_str);
- if (!port)
- {
- log_print ("udp_create_old: connection to port 0 not allowed");
- free (addr_str);
- return 0;
- }
- }
- else
- port = UDP_DEFAULT_PORT;
-
- addr = inet_addr (addr_str);
- if (addr == INADDR_NONE)
- {
- log_print ("udp_create_old: inet_addr (\"%s\") failed", addr_str);
- free (addr_str);
- return 0;
- }
- free (addr_str);
-
- memset (&dst, 0, sizeof dst);
- dst.sin_len = sizeof dst;
- dst.sin_family = AF_INET;
- dst.sin_addr.s_addr = addr;
- dst.sin_port = htons (port);
-
- return udp_clone ((struct udp_transport *)default_transport, &dst);
-}
-
-/*
* NAME is a section name found in the config database. Setup and return
* a transport useable to talk to the peer specified by that name
*/
@@ -279,17 +224,15 @@ udp_create (char *name)
char *addr_str, *port_str;
in_addr_t addr;
in_port_t port;
+ char *port_str_end;
+ long port_long;
struct servent *service;
- /* If an address tag does not exist, try backward compatibility mode. */
- addr_str = conf_get_str (name, "Address");
- if (!addr_str)
- return udp_create_old (name);
-
port_str = conf_get_str (name, "Port");
if (port_str)
{
- if (!isdigit (port_str[0]))
+ port_long = strtol (port_str, &port_str_end, 0);
+ if (port_str == port_str_end)
{
service = getservbyname (port_str, "udp");
if (!service)
@@ -299,20 +242,18 @@ udp_create (char *name)
}
port = service->s_port;
}
- else
+ else if (port_long < 1 || port_long > 65535)
{
- port = atoi (port_str);
- if (!port)
- {
- log_print ("udp_create: port specification \"%s\" malformed",
- port_str);
- return 0;
- }
+ log_print ("udp_create: port %l out of range", port_long);
+ return 0;
}
+ else
+ port = port_long;
}
else
port = UDP_DEFAULT_PORT;
+ addr_str = conf_get_str (name, "Address");
addr = inet_addr (addr_str);
if (addr == INADDR_NONE)
{