diff options
author | Hans-Joerg Hoexer <hshoexer@cvs.openbsd.org> | 2005-03-04 16:51:53 +0000 |
---|---|---|
committer | Hans-Joerg Hoexer <hshoexer@cvs.openbsd.org> | 2005-03-04 16:51:53 +0000 |
commit | e33c7b046085dbe714d5e1a231eb0b16e5c00f18 (patch) | |
tree | 234f8657857ae507215b6f6542c0187bc9d71da2 | |
parent | ccc2ee524f8a3d40f352a30d1e15d76830f470ba (diff) |
remove unused function udp_decode_port(), add modified version as text2port() to
utilities.
ok cloder ho
-rw-r--r-- | sbin/isakmpd/udp.c | 35 | ||||
-rw-r--r-- | sbin/isakmpd/util.c | 25 | ||||
-rw-r--r-- | sbin/isakmpd/util.h | 3 |
3 files changed, 27 insertions, 36 deletions
diff --git a/sbin/isakmpd/udp.c b/sbin/isakmpd/udp.c index f2428f95bff..a2c8c644462 100644 --- a/sbin/isakmpd/udp.c +++ b/sbin/isakmpd/udp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udp.c,v 1.82 2005/03/04 16:09:59 hshoexer Exp $ */ +/* $OpenBSD: udp.c,v 1.83 2005/03/04 16:51:52 hshoexer Exp $ */ /* $EOM: udp.c,v 1.57 2001/01/26 10:09:57 niklas Exp $ */ /* @@ -83,9 +83,6 @@ static void udp_report(struct transport *); static void udp_handle_message(struct transport *); static struct transport *udp_make(struct sockaddr *); static int udp_send_message(struct message *, struct transport *); -#if 0 -static in_port_t udp_decode_port(char *); -#endif static struct transport_vtbl udp_transport_vtbl = { {0}, "udp_physical", @@ -540,33 +537,3 @@ udp_decode_ids(struct transport *t) snprintf(result, sizeof result, "src: %s dst: %s", idsrc, iddst); return result; } - -#if 0 -/* - * Take a string containing an ext representation of port and return a - * binary port number in host byte order. Return zero if anything goes wrong. - * XXX Currently unused. - */ -static in_port_t -udp_decode_port(char *port_str) -{ - char *port_str_end; - long port_long; - struct servent *service; - - port_long = ntohl(strtol(port_str, &port_str_end, 0)); - if (port_str == port_str_end) { - service = getservbyname(port_str, "udp"); - if (!service) { - log_print("udp_decode_port: service \"%s\" unknown", - port_str); - return 0; - } - return ntohs(service->s_port); - } else if (port_long < 1 || port_long > 65535) { - log_print("udp_decode_port: port %ld out of range", port_long); - return 0; - } - return port_long; -} -#endif diff --git a/sbin/isakmpd/util.c b/sbin/isakmpd/util.c index 005ae1e8d8c..4cfb2899d08 100644 --- a/sbin/isakmpd/util.c +++ b/sbin/isakmpd/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.50 2005/02/27 13:12:12 hshoexer Exp $ */ +/* $OpenBSD: util.c,v 1.51 2005/03/04 16:51:52 hshoexer Exp $ */ /* $EOM: util.c,v 1.23 2000/11/23 12:22:08 niklas Exp $ */ /* @@ -242,6 +242,29 @@ hex2raw(char *s, u_int8_t *buf, size_t sz) return 0; } +in_port_t +text2port(char *port_str) +{ + char *port_str_end; + long port_long; + struct servent *service; + + port_long = strtol(port_str, &port_str_end, 0); + if (port_str == port_str_end) { + service = getservbyname(port_str, "udp"); + if (!service) { + log_print("text2port: service \"%s\" unknown", + port_str); + return 0; + } + return ntohs(service->s_port); + } else if (port_long < 1 || port_long > (long)USHRT_MAX) { + log_print("text2port: port %ld out of range", port_long); + return 0; + } + return port_long; +} + int text2sockaddr(char *address, char *port, struct sockaddr **sa, sa_family_t af, int netmask) diff --git a/sbin/isakmpd/util.h b/sbin/isakmpd/util.h index db2564eddbc..7c9b96c1442 100644 --- a/sbin/isakmpd/util.h +++ b/sbin/isakmpd/util.h @@ -1,4 +1,4 @@ -/* $OpenBSD: util.h,v 1.22 2004/12/14 10:17:28 mcbride Exp $ */ +/* $OpenBSD: util.h,v 1.23 2005/03/04 16:51:52 hshoexer Exp $ */ /* $EOM: util.h,v 1.10 2000/10/24 13:33:39 niklas Exp $ */ /* @@ -63,6 +63,7 @@ extern u_int8_t *sockaddr_addrdata(struct sockaddr *); extern int sockaddr_addrlen(struct sockaddr *); extern in_port_t sockaddr_port(struct sockaddr *); extern void sockaddr_set_port(struct sockaddr *, in_port_t); +extern in_port_t text2port(char *); extern int text2sockaddr(char *, char *, struct sockaddr **, sa_family_t, int); extern void util_ntoa(char **, int, u_int8_t *); |