diff options
author | Glenn L McGrath | 2004-01-17 05:03:31 +0000 |
---|---|---|
committer | Glenn L McGrath | 2004-01-17 05:03:31 +0000 |
commit | 036dbaa082f1974246d1d7d21a8e163559642485 (patch) | |
tree | 2488441544ab16f8e08d0955d323019e96ed3d4f /networking/nc.c | |
parent | b03be7f5677b86acfe2f64b5a57e1f361e257f6c (diff) | |
download | busybox-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 'networking/nc.c')
-rw-r--r-- | networking/nc.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/networking/nc.c b/networking/nc.c index 4888ccc..ecb4a00 100644 --- a/networking/nc.c +++ b/networking/nc.c @@ -61,7 +61,7 @@ int nc_main(int argc, char **argv) do_listen++; break; case 'p': - lport = atoi(optarg); + lport = bb_lookup_port(optarg, "tcp", 0); break; case 'i': delay = atoi(optarg); @@ -96,7 +96,7 @@ int nc_main(int argc, char **argv) if (lport != 0) { memset(&address.sin_addr, 0, sizeof(address.sin_addr)); - address.sin_port = htons(lport); + address.sin_port = lport; if (bind(sfd, (struct sockaddr *) &address, sizeof(address)) < 0) bb_perror_msg_and_die("bind"); @@ -117,7 +117,7 @@ int nc_main(int argc, char **argv) hostinfo = xgethostbyname(argv[optind]); address.sin_addr = *(struct in_addr *) *hostinfo->h_addr_list; - address.sin_port = htons(atoi(argv[optind+1])); + address.sin_port = bb_lookup_port(argv[optind+1], "tcp", 0); if (connect(sfd, (struct sockaddr *) &address, sizeof(address)) < 0) bb_perror_msg_and_die("connect"); |