aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorbug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277>2004-01-17 05:03:31 +0000
committerbug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277>2004-01-17 05:03:31 +0000
commitd513a457e9b733962cabd486bb5f1ba5e279e82d (patch)
tree2488441544ab16f8e08d0955d323019e96ed3d4f /libbb
parent67b684b76ebc1a161e88404d35da4ee52364b5d8 (diff)
downloadbusybox-w32-d513a457e9b733962cabd486bb5f1ba5e279e82d.tar.gz
busybox-w32-d513a457e9b733962cabd486bb5f1ba5e279e82d.tar.bz2
busybox-w32-d513a457e9b733962cabd486bb5f1ba5e279e82d.zip
Modify bb_lookup_port to allow the protocol to be specified, allowing
/etc/services support for inetd, netcat and tftp. git-svn-id: svn://busybox.net/trunk/busybox@8307 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'libbb')
-rw-r--r--libbb/xconnect.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libbb/xconnect.c b/libbb/xconnect.c
index 29b984720..2443bb299 100644
--- a/libbb/xconnect.c
+++ b/libbb/xconnect.c
@@ -23,7 +23,7 @@
23 * If "port" is a name it is looked up in /etc/services, if it isnt found return 23 * If "port" is a name it is looked up in /etc/services, if it isnt found return
24 * default_port 24 * default_port
25 */ 25 */
26unsigned short bb_lookup_port(const char *port, unsigned short default_port) 26unsigned short bb_lookup_port(const char *port, const char *protocol, unsigned short default_port)
27{ 27{
28 unsigned short port_nr = htons(default_port); 28 unsigned short port_nr = htons(default_port);
29 if (port) { 29 if (port) {
@@ -37,7 +37,7 @@ unsigned short bb_lookup_port(const char *port, unsigned short default_port)
37 errno = 0; 37 errno = 0;
38 port_long = strtol(port, &endptr, 10); 38 port_long = strtol(port, &endptr, 10);
39 if (errno != 0 || *endptr!='\0' || endptr==port || port_long < 0 || port_long > 65535) { 39 if (errno != 0 || *endptr!='\0' || endptr==port || port_long < 0 || port_long > 65535) {
40 struct servent *tserv = getservbyname(port, "tcp"); 40 struct servent *tserv = getservbyname(port, protocol);
41 if (tserv) { 41 if (tserv) {
42 port_nr = tserv->s_port; 42 port_nr = tserv->s_port;
43 } 43 }