diff options
author | Glenn L McGrath <bug1@ihug.co.nz> | 2004-01-17 05:03:31 +0000 |
---|---|---|
committer | Glenn L McGrath <bug1@ihug.co.nz> | 2004-01-17 05:03:31 +0000 |
commit | 036dbaa082f1974246d1d7d21a8e163559642485 (patch) | |
tree | 2488441544ab16f8e08d0955d323019e96ed3d4f /networking/nc.c | |
parent | b03be7f5677b86acfe2f64b5a57e1f361e257f6c (diff) | |
download | busybox-w32-036dbaa082f1974246d1d7d21a8e163559642485.tar.gz busybox-w32-036dbaa082f1974246d1d7d21a8e163559642485.tar.bz2 busybox-w32-036dbaa082f1974246d1d7d21a8e163559642485.zip |
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 4888ccceb..ecb4a007b 100644 --- a/networking/nc.c +++ b/networking/nc.c | |||
@@ -61,7 +61,7 @@ int nc_main(int argc, char **argv) | |||
61 | do_listen++; | 61 | do_listen++; |
62 | break; | 62 | break; |
63 | case 'p': | 63 | case 'p': |
64 | lport = atoi(optarg); | 64 | lport = bb_lookup_port(optarg, "tcp", 0); |
65 | break; | 65 | break; |
66 | case 'i': | 66 | case 'i': |
67 | delay = atoi(optarg); | 67 | delay = atoi(optarg); |
@@ -96,7 +96,7 @@ int nc_main(int argc, char **argv) | |||
96 | 96 | ||
97 | if (lport != 0) { | 97 | if (lport != 0) { |
98 | memset(&address.sin_addr, 0, sizeof(address.sin_addr)); | 98 | memset(&address.sin_addr, 0, sizeof(address.sin_addr)); |
99 | address.sin_port = htons(lport); | 99 | address.sin_port = lport; |
100 | 100 | ||
101 | if (bind(sfd, (struct sockaddr *) &address, sizeof(address)) < 0) | 101 | if (bind(sfd, (struct sockaddr *) &address, sizeof(address)) < 0) |
102 | bb_perror_msg_and_die("bind"); | 102 | bb_perror_msg_and_die("bind"); |
@@ -117,7 +117,7 @@ int nc_main(int argc, char **argv) | |||
117 | hostinfo = xgethostbyname(argv[optind]); | 117 | hostinfo = xgethostbyname(argv[optind]); |
118 | 118 | ||
119 | address.sin_addr = *(struct in_addr *) *hostinfo->h_addr_list; | 119 | address.sin_addr = *(struct in_addr *) *hostinfo->h_addr_list; |
120 | address.sin_port = htons(atoi(argv[optind+1])); | 120 | address.sin_port = bb_lookup_port(argv[optind+1], "tcp", 0); |
121 | 121 | ||
122 | if (connect(sfd, (struct sockaddr *) &address, sizeof(address)) < 0) | 122 | if (connect(sfd, (struct sockaddr *) &address, sizeof(address)) < 0) |
123 | bb_perror_msg_and_die("connect"); | 123 | bb_perror_msg_and_die("connect"); |