summaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorGlenn L McGrath2004-01-17 05:03:31 +0000
committerGlenn L McGrath2004-01-17 05:03:31 +0000
commit036dbaa082f1974246d1d7d21a8e163559642485 (patch)
tree2488441544ab16f8e08d0955d323019e96ed3d4f /libbb
parentb03be7f5677b86acfe2f64b5a57e1f361e257f6c (diff)
downloadbusybox-036dbaa082f1974246d1d7d21a8e163559642485.zip
busybox-036dbaa082f1974246d1d7d21a8e163559642485.tar.gz
Modify bb_lookup_port to allow the protocol to be specified, allowing
/etc/services support for inetd, netcat and tftp.
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 29b9847..2443bb2 100644
--- a/libbb/xconnect.c
+++ b/libbb/xconnect.c
@@ -23,7 +23,7 @@
* If "port" is a name it is looked up in /etc/services, if it isnt found return
* default_port
*/
-unsigned short bb_lookup_port(const char *port, unsigned short default_port)
+unsigned short bb_lookup_port(const char *port, const char *protocol, unsigned short default_port)
{
unsigned short port_nr = htons(default_port);
if (port) {
@@ -37,7 +37,7 @@ unsigned short bb_lookup_port(const char *port, unsigned short default_port)
errno = 0;
port_long = strtol(port, &endptr, 10);
if (errno != 0 || *endptr!='\0' || endptr==port || port_long < 0 || port_long > 65535) {
- struct servent *tserv = getservbyname(port, "tcp");
+ struct servent *tserv = getservbyname(port, protocol);
if (tserv) {
port_nr = tserv->s_port;
}