summaryrefslogtreecommitdiffstats
path: root/lib/libfetch/common.c
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2000-11-10 08:43:40 +0000
committerdes <des@FreeBSD.org>2000-11-10 08:43:40 +0000
commit985bff769942e74d8a4614115b7153a96bf6d0b6 (patch)
treeda8eae065a0f12e6489dde4d5fef45d7a0b7ac3d /lib/libfetch/common.c
parentfaf86e96f0a2a44d87ffbce68497bf4426dcc3af (diff)
downloadFreeBSD-src-985bff769942e74d8a4614115b7153a96bf6d0b6.zip
FreeBSD-src-985bff769942e74d8a4614115b7153a96bf6d0b6.tar.gz
Use the documented (and historical) defaults. Centralize the decision logic
in order to avoid this bug in the future. Submitted by: se
Diffstat (limited to 'lib/libfetch/common.c')
-rw-r--r--lib/libfetch/common.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/libfetch/common.c b/lib/libfetch/common.c
index c03b1f5..4d05a6b6 100644
--- a/lib/libfetch/common.c
+++ b/lib/libfetch/common.c
@@ -168,6 +168,40 @@ _fetch_info(char *fmt, ...)
/*** Network-related utility functions ***************************************/
/*
+ * Return the default port for a scheme
+ */
+int
+_fetch_default_port(char *scheme)
+{
+ struct servent *se;
+
+ if ((se = getservbyname(scheme, "tcp")) != NULL)
+ return ntohs(se->s_port);
+ if (strcasecmp(scheme, SCHEME_FTP) == 0)
+ return FTP_DEFAULT_PORT;
+ if (strcasecmp(scheme, SCHEME_HTTP) == 0)
+ return HTTP_DEFAULT_PORT;
+ return 0;
+}
+
+/*
+ * Return the default proxy port for a scheme
+ */
+int
+_fetch_default_proxy_port(char *scheme)
+{
+ struct servent *se;
+
+ if ((se = getservbyname(scheme, "tcp")) != NULL)
+ return ntohs(se->s_port);
+ if (strcasecmp(scheme, SCHEME_FTP) == 0)
+ return FTP_DEFAULT_PROXY_PORT;
+ if (strcasecmp(scheme, SCHEME_HTTP) == 0)
+ return HTTP_DEFAULT_PROXY_PORT;
+ return 0;
+}
+
+/*
* Establish a TCP connection to the specified port on the specified host.
*/
int
OpenPOWER on IntegriCloud