Bernhard Reutner-Fischer | dac7ff1 | 2006-04-12 17:55:51 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* ------------------------------------------------------------------------- |
| 3 | * tftp.c |
| 4 | * |
| 5 | * A simple tftp client for busybox. |
| 6 | * Tries to follow RFC1350. |
| 7 | * Only "octet" mode supported. |
| 8 | * Optional blocksize negotiation (RFC2347 + RFC2348) |
| 9 | * |
| 10 | * Copyright (C) 2001 Magnus Damm <damm@opensource.se> |
| 11 | * |
| 12 | * Parts of the code based on: |
| 13 | * |
| 14 | * atftp: Copyright (C) 2000 Jean-Pierre Lefebvre <helix@step.polymtl.ca> |
| 15 | * and Remi Lefebvre <remi@debian.org> |
| 16 | * |
| 17 | * utftp: Copyright (C) 1999 Uwe Ohse <uwe@ohse.de> |
| 18 | * |
| 19 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
| 20 | * ------------------------------------------------------------------------- */ |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 21 | |
| 22 | #include <stdio.h> |
| 23 | #include <stdlib.h> |
| 24 | #include <string.h> |
| 25 | #include <sys/types.h> |
| 26 | #include <sys/socket.h> |
| 27 | #include <sys/time.h> |
| 28 | #include <sys/stat.h> |
| 29 | #include <netdb.h> |
| 30 | #include <netinet/in.h> |
| 31 | #include <arpa/inet.h> |
| 32 | #include <unistd.h> |
| 33 | #include <fcntl.h> |
| 34 | |
| 35 | #include "busybox.h" |
| 36 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 37 | //#define CONFIG_FEATURE_TFTP_DEBUG |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 38 | |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 39 | #define TFTP_BLOCKSIZE_DEFAULT 512 /* according to RFC 1350, don't change */ |
| 40 | #define TFTP_TIMEOUT 5 /* seconds */ |
| 41 | |
| 42 | /* opcodes we support */ |
| 43 | |
| 44 | #define TFTP_RRQ 1 |
| 45 | #define TFTP_WRQ 2 |
| 46 | #define TFTP_DATA 3 |
| 47 | #define TFTP_ACK 4 |
| 48 | #define TFTP_ERROR 5 |
| 49 | #define TFTP_OACK 6 |
| 50 | |
"Vladimir N. Oleynik" | 86ac072 | 2005-10-17 10:47:19 +0000 | [diff] [blame] | 51 | static const char * const tftp_bb_error_msg[] = { |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 52 | "Undefined error", |
| 53 | "File not found", |
| 54 | "Access violation", |
| 55 | "Disk full or allocation error", |
| 56 | "Illegal TFTP operation", |
| 57 | "Unknown transfer ID", |
| 58 | "File already exists", |
| 59 | "No such user" |
| 60 | }; |
| 61 | |
"Vladimir N. Oleynik" | 86ac072 | 2005-10-17 10:47:19 +0000 | [diff] [blame] | 62 | #ifdef CONFIG_FEATURE_TFTP_GET |
| 63 | # define tftp_cmd_get 1 |
| 64 | #else |
| 65 | # define tftp_cmd_get 0 |
| 66 | #endif |
| 67 | #ifdef CONFIG_FEATURE_TFTP_PUT |
| 68 | # define tftp_cmd_put (tftp_cmd_get+1) |
| 69 | #else |
| 70 | # define tftp_cmd_put 0 |
| 71 | #endif |
| 72 | |
Eric Andersen | 76fa8ea | 2001-08-20 17:47:49 +0000 | [diff] [blame] | 73 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 74 | #ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 75 | |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 76 | static int tftp_blocksize_check(int blocksize, int bufsize) |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 77 | { |
Tim Riker | c1ef7bd | 2006-01-25 00:08:53 +0000 | [diff] [blame] | 78 | /* Check if the blocksize is valid: |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 79 | * RFC2348 says between 8 and 65464, |
| 80 | * but our implementation makes it impossible |
| 81 | * to use blocksizes smaller than 22 octets. |
| 82 | */ |
| 83 | |
Tim Riker | c1ef7bd | 2006-01-25 00:08:53 +0000 | [diff] [blame] | 84 | if ((bufsize && (blocksize > bufsize)) || |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 85 | (blocksize < 8) || (blocksize > 65464)) { |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 86 | bb_error_msg("bad blocksize"); |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 87 | return 0; |
| 88 | } |
| 89 | |
| 90 | return blocksize; |
| 91 | } |
| 92 | |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 93 | static char *tftp_option_get(char *buf, int len, char *option) |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 94 | { |
Tim Riker | c1ef7bd | 2006-01-25 00:08:53 +0000 | [diff] [blame] | 95 | int opt_val = 0; |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 96 | int opt_found = 0; |
| 97 | int k; |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 98 | |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 99 | while (len > 0) { |
| 100 | |
| 101 | /* Make sure the options are terminated correctly */ |
| 102 | |
| 103 | for (k = 0; k < len; k++) { |
| 104 | if (buf[k] == '\0') { |
| 105 | break; |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | if (k >= len) { |
| 110 | break; |
| 111 | } |
| 112 | |
| 113 | if (opt_val == 0) { |
| 114 | if (strcasecmp(buf, option) == 0) { |
| 115 | opt_found = 1; |
| 116 | } |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 117 | } |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 118 | else { |
| 119 | if (opt_found) { |
| 120 | return buf; |
| 121 | } |
| 122 | } |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 123 | |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 124 | k++; |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 125 | |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 126 | buf += k; |
| 127 | len -= k; |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 128 | |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 129 | opt_val ^= 1; |
| 130 | } |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 131 | |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 132 | return NULL; |
| 133 | } |
| 134 | |
| 135 | #endif |
| 136 | |
Eric Andersen | 76fa8ea | 2001-08-20 17:47:49 +0000 | [diff] [blame] | 137 | static inline int tftp(const int cmd, const struct hostent *host, |
Glenn L McGrath | 036dbaa | 2004-01-17 05:03:31 +0000 | [diff] [blame] | 138 | const char *remotefile, int localfd, const unsigned short port, int tftp_bufsize) |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 139 | { |
Eric Andersen | 76fa8ea | 2001-08-20 17:47:49 +0000 | [diff] [blame] | 140 | const int cmd_get = cmd & tftp_cmd_get; |
| 141 | const int cmd_put = cmd & tftp_cmd_put; |
| 142 | const int bb_tftp_num_retries = 5; |
| 143 | |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 144 | struct sockaddr_in sa; |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 145 | struct sockaddr_in from; |
Eric Andersen | 76fa8ea | 2001-08-20 17:47:49 +0000 | [diff] [blame] | 146 | struct timeval tv; |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 147 | socklen_t fromlen; |
Eric Andersen | 76fa8ea | 2001-08-20 17:47:49 +0000 | [diff] [blame] | 148 | fd_set rfds; |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 149 | char *cp; |
| 150 | unsigned short tmp; |
Eric Andersen | 76fa8ea | 2001-08-20 17:47:49 +0000 | [diff] [blame] | 151 | int socketfd; |
| 152 | int len; |
| 153 | int opcode = 0; |
| 154 | int finished = 0; |
| 155 | int timeout = bb_tftp_num_retries; |
Glenn L McGrath | c699778 | 2004-02-22 03:33:53 +0000 | [diff] [blame] | 156 | unsigned short block_nr = 1; |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 157 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 158 | #ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 159 | int want_option_ack = 0; |
| 160 | #endif |
| 161 | |
Eric Andersen | 744a194 | 2001-11-10 11:16:39 +0000 | [diff] [blame] | 162 | /* Can't use RESERVE_CONFIG_BUFFER here since the allocation |
| 163 | * size varies meaning BUFFERS_GO_ON_STACK would fail */ |
| 164 | char *buf=xmalloc(tftp_bufsize + 4); |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 165 | |
Eric Andersen | 76fa8ea | 2001-08-20 17:47:49 +0000 | [diff] [blame] | 166 | tftp_bufsize += 4; |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 167 | |
Bernhard Reutner-Fischer | dac7ff1 | 2006-04-12 17:55:51 +0000 | [diff] [blame] | 168 | if ((socketfd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) { /* bb_xsocket? */ |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 169 | bb_perror_msg("socket"); |
Mark Whitley | 8bb7df4 | 2001-03-06 20:58:48 +0000 | [diff] [blame] | 170 | return EXIT_FAILURE; |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | len = sizeof(sa); |
| 174 | |
| 175 | memset(&sa, 0, len); |
Eric Andersen | e76c3b0 | 2001-04-05 03:14:39 +0000 | [diff] [blame] | 176 | bind(socketfd, (struct sockaddr *)&sa, len); |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 177 | |
| 178 | sa.sin_family = host->h_addrtype; |
Glenn L McGrath | 036dbaa | 2004-01-17 05:03:31 +0000 | [diff] [blame] | 179 | sa.sin_port = port; |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 180 | memcpy(&sa.sin_addr, (struct in_addr *) host->h_addr, |
| 181 | sizeof(sa.sin_addr)); |
| 182 | |
| 183 | /* build opcode */ |
| 184 | |
Eric Andersen | 76fa8ea | 2001-08-20 17:47:49 +0000 | [diff] [blame] | 185 | if (cmd_get) { |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 186 | opcode = TFTP_RRQ; |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 187 | } |
| 188 | |
Eric Andersen | 76fa8ea | 2001-08-20 17:47:49 +0000 | [diff] [blame] | 189 | if (cmd_put) { |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 190 | opcode = TFTP_WRQ; |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | while (1) { |
| 194 | |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 195 | cp = buf; |
| 196 | |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 197 | /* first create the opcode part */ |
| 198 | |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 199 | *((unsigned short *) cp) = htons(opcode); |
| 200 | |
| 201 | cp += 2; |
| 202 | |
| 203 | /* add filename and mode */ |
| 204 | |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 205 | if ((cmd_get && (opcode == TFTP_RRQ)) || |
| 206 | (cmd_put && (opcode == TFTP_WRQ))) { |
Tim Riker | c1ef7bd | 2006-01-25 00:08:53 +0000 | [diff] [blame] | 207 | int too_long = 0; |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 208 | |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 209 | /* see if the filename fits into buf */ |
| 210 | /* and fill in packet */ |
| 211 | |
| 212 | len = strlen(remotefile) + 1; |
| 213 | |
| 214 | if ((cp + len) >= &buf[tftp_bufsize - 1]) { |
| 215 | too_long = 1; |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 216 | } |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 217 | else { |
| 218 | safe_strncpy(cp, remotefile, len); |
| 219 | cp += len; |
| 220 | } |
| 221 | |
| 222 | if (too_long || ((&buf[tftp_bufsize - 1] - cp) < 6)) { |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 223 | bb_error_msg("too long remote-filename"); |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 224 | break; |
| 225 | } |
| 226 | |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 227 | /* add "mode" part of the package */ |
| 228 | |
| 229 | memcpy(cp, "octet", 6); |
| 230 | cp += 6; |
| 231 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 232 | #ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 233 | |
| 234 | len = tftp_bufsize - 4; /* data block size */ |
| 235 | |
| 236 | if (len != TFTP_BLOCKSIZE_DEFAULT) { |
| 237 | |
| 238 | if ((&buf[tftp_bufsize - 1] - cp) < 15) { |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 239 | bb_error_msg("too long remote-filename"); |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 240 | break; |
| 241 | } |
| 242 | |
| 243 | /* add "blksize" + number of blocks */ |
| 244 | |
| 245 | memcpy(cp, "blksize", 8); |
| 246 | cp += 8; |
| 247 | |
| 248 | cp += snprintf(cp, 6, "%d", len) + 1; |
| 249 | |
| 250 | want_option_ack = 1; |
| 251 | } |
| 252 | #endif |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 253 | } |
| 254 | |
| 255 | /* add ack and data */ |
| 256 | |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 257 | if ((cmd_get && (opcode == TFTP_ACK)) || |
| 258 | (cmd_put && (opcode == TFTP_DATA))) { |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 259 | |
| 260 | *((unsigned short *) cp) = htons(block_nr); |
| 261 | |
| 262 | cp += 2; |
| 263 | |
| 264 | block_nr++; |
| 265 | |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 266 | if (cmd_put && (opcode == TFTP_DATA)) { |
Eric Andersen | 4872ed9 | 2004-06-22 10:18:30 +0000 | [diff] [blame] | 267 | len = bb_full_read(localfd, cp, tftp_bufsize - 4); |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 268 | |
| 269 | if (len < 0) { |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 270 | bb_perror_msg("read"); |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 271 | break; |
| 272 | } |
| 273 | |
Eric Andersen | 76fa8ea | 2001-08-20 17:47:49 +0000 | [diff] [blame] | 274 | if (len != (tftp_bufsize - 4)) { |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 275 | finished++; |
| 276 | } |
| 277 | |
| 278 | cp += len; |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 279 | } |
| 280 | } |
| 281 | |
| 282 | |
| 283 | /* send packet */ |
| 284 | |
| 285 | |
Eric Andersen | 05e662a | 2003-07-26 08:16:10 +0000 | [diff] [blame] | 286 | timeout = bb_tftp_num_retries; /* re-initialize */ |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 287 | do { |
| 288 | |
| 289 | len = cp - buf; |
| 290 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 291 | #ifdef CONFIG_FEATURE_TFTP_DEBUG |
Glenn L McGrath | d33278d | 2004-02-22 07:20:25 +0000 | [diff] [blame] | 292 | fprintf(stderr, "sending %u bytes\n", len); |
Eric Andersen | 76fa8ea | 2001-08-20 17:47:49 +0000 | [diff] [blame] | 293 | for (cp = buf; cp < &buf[len]; cp++) |
Glenn L McGrath | fbe984e | 2004-03-05 13:04:39 +0000 | [diff] [blame] | 294 | fprintf(stderr, "%02x ", (unsigned char)*cp); |
Glenn L McGrath | d33278d | 2004-02-22 07:20:25 +0000 | [diff] [blame] | 295 | fprintf(stderr, "\n"); |
Eric Andersen | 76fa8ea | 2001-08-20 17:47:49 +0000 | [diff] [blame] | 296 | #endif |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 297 | if (sendto(socketfd, buf, len, 0, |
Eric Andersen | 76fa8ea | 2001-08-20 17:47:49 +0000 | [diff] [blame] | 298 | (struct sockaddr *) &sa, sizeof(sa)) < 0) { |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 299 | bb_perror_msg("send"); |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 300 | len = -1; |
| 301 | break; |
| 302 | } |
| 303 | |
| 304 | |
Eric Andersen | b99aec0 | 2003-07-30 07:16:39 +0000 | [diff] [blame] | 305 | if (finished && (opcode == TFTP_ACK)) { |
Glenn L McGrath | 0f18271 | 2002-12-19 20:16:22 +0000 | [diff] [blame] | 306 | break; |
| 307 | } |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 308 | |
Glenn L McGrath | 0f18271 | 2002-12-19 20:16:22 +0000 | [diff] [blame] | 309 | /* receive packet */ |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 310 | |
| 311 | memset(&from, 0, sizeof(from)); |
| 312 | fromlen = sizeof(from); |
| 313 | |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 314 | tv.tv_sec = TFTP_TIMEOUT; |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 315 | tv.tv_usec = 0; |
| 316 | |
| 317 | FD_ZERO(&rfds); |
| 318 | FD_SET(socketfd, &rfds); |
| 319 | |
Paul Fox | 1d4c88c | 2005-07-20 19:49:15 +0000 | [diff] [blame] | 320 | switch (select(socketfd + 1, &rfds, NULL, NULL, &tv)) { |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 321 | case 1: |
Eric Andersen | 76fa8ea | 2001-08-20 17:47:49 +0000 | [diff] [blame] | 322 | len = recvfrom(socketfd, buf, tftp_bufsize, 0, |
| 323 | (struct sockaddr *) &from, &fromlen); |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 324 | |
| 325 | if (len < 0) { |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 326 | bb_perror_msg("recvfrom"); |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 327 | break; |
| 328 | } |
| 329 | |
| 330 | timeout = 0; |
| 331 | |
Glenn L McGrath | 036dbaa | 2004-01-17 05:03:31 +0000 | [diff] [blame] | 332 | if (sa.sin_port == port) { |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 333 | sa.sin_port = from.sin_port; |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 334 | } |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 335 | if (sa.sin_port == from.sin_port) { |
| 336 | break; |
| 337 | } |
| 338 | |
| 339 | /* fall-through for bad packets! */ |
| 340 | /* discard the packet - treat as timeout */ |
Eric Andersen | 76fa8ea | 2001-08-20 17:47:49 +0000 | [diff] [blame] | 341 | timeout = bb_tftp_num_retries; |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 342 | |
| 343 | case 0: |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 344 | bb_error_msg("timeout"); |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 345 | |
Eric Andersen | b99aec0 | 2003-07-30 07:16:39 +0000 | [diff] [blame] | 346 | timeout--; |
Eric Andersen | 76fa8ea | 2001-08-20 17:47:49 +0000 | [diff] [blame] | 347 | if (timeout == 0) { |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 348 | len = -1; |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 349 | bb_error_msg("last timeout"); |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 350 | } |
| 351 | break; |
| 352 | |
| 353 | default: |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 354 | bb_perror_msg("select"); |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 355 | len = -1; |
| 356 | } |
| 357 | |
| 358 | } while (timeout && (len >= 0)); |
| 359 | |
Glenn L McGrath | 0f18271 | 2002-12-19 20:16:22 +0000 | [diff] [blame] | 360 | if ((finished) || (len < 0)) { |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 361 | break; |
| 362 | } |
| 363 | |
| 364 | /* process received packet */ |
| 365 | |
| 366 | |
| 367 | opcode = ntohs(*((unsigned short *) buf)); |
| 368 | tmp = ntohs(*((unsigned short *) &buf[2])); |
| 369 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 370 | #ifdef CONFIG_FEATURE_TFTP_DEBUG |
Glenn L McGrath | d33278d | 2004-02-22 07:20:25 +0000 | [diff] [blame] | 371 | fprintf(stderr, "received %d bytes: %04x %04x\n", len, opcode, tmp); |
Eric Andersen | 76fa8ea | 2001-08-20 17:47:49 +0000 | [diff] [blame] | 372 | #endif |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 373 | |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 374 | if (opcode == TFTP_ERROR) { |
"Vladimir N. Oleynik" | 86ac072 | 2005-10-17 10:47:19 +0000 | [diff] [blame] | 375 | const char *msg = NULL; |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 376 | |
| 377 | if (buf[4] != '\0') { |
| 378 | msg = &buf[4]; |
| 379 | buf[tftp_bufsize - 1] = '\0'; |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 380 | } else if (tmp < (sizeof(tftp_bb_error_msg) |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 381 | / sizeof(char *))) { |
| 382 | |
"Vladimir N. Oleynik" | 86ac072 | 2005-10-17 10:47:19 +0000 | [diff] [blame] | 383 | msg = tftp_bb_error_msg[tmp]; |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 384 | } |
| 385 | |
| 386 | if (msg) { |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 387 | bb_error_msg("server says: %s", msg); |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 388 | } |
| 389 | |
| 390 | break; |
| 391 | } |
| 392 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 393 | #ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 394 | if (want_option_ack) { |
| 395 | |
| 396 | want_option_ack = 0; |
| 397 | |
| 398 | if (opcode == TFTP_OACK) { |
| 399 | |
| 400 | /* server seems to support options */ |
| 401 | |
| 402 | char *res; |
| 403 | |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 404 | res = tftp_option_get(&buf[2], len-2, |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 405 | "blksize"); |
| 406 | |
| 407 | if (res) { |
Glenn L McGrath | fad90db | 2002-12-09 21:05:40 +0000 | [diff] [blame] | 408 | int blksize = atoi(res); |
Tim Riker | c1ef7bd | 2006-01-25 00:08:53 +0000 | [diff] [blame] | 409 | |
Glenn L McGrath | fad90db | 2002-12-09 21:05:40 +0000 | [diff] [blame] | 410 | if (tftp_blocksize_check(blksize, |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 411 | tftp_bufsize - 4)) { |
| 412 | |
| 413 | if (cmd_put) { |
| 414 | opcode = TFTP_DATA; |
| 415 | } |
| 416 | else { |
| 417 | opcode = TFTP_ACK; |
| 418 | } |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 419 | #ifdef CONFIG_FEATURE_TFTP_DEBUG |
Glenn L McGrath | d33278d | 2004-02-22 07:20:25 +0000 | [diff] [blame] | 420 | fprintf(stderr, "using blksize %u\n", blksize); |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 421 | #endif |
Glenn L McGrath | 9bf9f1e | 2002-12-09 21:52:29 +0000 | [diff] [blame] | 422 | tftp_bufsize = blksize + 4; |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 423 | block_nr = 0; |
| 424 | continue; |
| 425 | } |
| 426 | } |
| 427 | /* FIXME: |
| 428 | * we should send ERROR 8 */ |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 429 | bb_error_msg("bad server option"); |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 430 | break; |
| 431 | } |
| 432 | |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 433 | bb_error_msg("warning: blksize not supported by server" |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 434 | " - reverting to 512"); |
| 435 | |
| 436 | tftp_bufsize = TFTP_BLOCKSIZE_DEFAULT + 4; |
| 437 | } |
| 438 | #endif |
| 439 | |
| 440 | if (cmd_get && (opcode == TFTP_DATA)) { |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 441 | |
| 442 | if (tmp == block_nr) { |
Tim Riker | c1ef7bd | 2006-01-25 00:08:53 +0000 | [diff] [blame] | 443 | |
Eric Andersen | 4872ed9 | 2004-06-22 10:18:30 +0000 | [diff] [blame] | 444 | len = bb_full_write(localfd, &buf[4], len - 4); |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 445 | |
| 446 | if (len < 0) { |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 447 | bb_perror_msg("write"); |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 448 | break; |
| 449 | } |
| 450 | |
Eric Andersen | 76fa8ea | 2001-08-20 17:47:49 +0000 | [diff] [blame] | 451 | if (len != (tftp_bufsize - 4)) { |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 452 | finished++; |
| 453 | } |
| 454 | |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 455 | opcode = TFTP_ACK; |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 456 | continue; |
| 457 | } |
Rob Landley | f3133c4 | 2005-06-07 02:40:39 +0000 | [diff] [blame] | 458 | /* in case the last ack disappeared into the ether */ |
| 459 | if ( tmp == (block_nr - 1) ) { |
| 460 | --block_nr; |
| 461 | opcode = TFTP_ACK; |
| 462 | continue; |
Paul Fox | 1d4c88c | 2005-07-20 19:49:15 +0000 | [diff] [blame] | 463 | } else if (tmp + 1 == block_nr) { |
| 464 | /* Server lost our TFTP_ACK. Resend it */ |
| 465 | block_nr = tmp; |
| 466 | opcode = TFTP_ACK; |
| 467 | continue; |
Rob Landley | f3133c4 | 2005-06-07 02:40:39 +0000 | [diff] [blame] | 468 | } |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 469 | } |
| 470 | |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 471 | if (cmd_put && (opcode == TFTP_ACK)) { |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 472 | |
Glenn L McGrath | c699778 | 2004-02-22 03:33:53 +0000 | [diff] [blame] | 473 | if (tmp == (unsigned short)(block_nr - 1)) { |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 474 | if (finished) { |
| 475 | break; |
| 476 | } |
| 477 | |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 478 | opcode = TFTP_DATA; |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 479 | continue; |
| 480 | } |
| 481 | } |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 482 | } |
| 483 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 484 | #ifdef CONFIG_FEATURE_CLEAN_UP |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 485 | close(socketfd); |
| 486 | |
Tim Riker | c1ef7bd | 2006-01-25 00:08:53 +0000 | [diff] [blame] | 487 | free(buf); |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 488 | #endif |
| 489 | |
Mark Whitley | 8bb7df4 | 2001-03-06 20:58:48 +0000 | [diff] [blame] | 490 | return finished ? EXIT_SUCCESS : EXIT_FAILURE; |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 491 | } |
| 492 | |
| 493 | int tftp_main(int argc, char **argv) |
| 494 | { |
Eric Andersen | 76fa8ea | 2001-08-20 17:47:49 +0000 | [diff] [blame] | 495 | struct hostent *host = NULL; |
Glenn L McGrath | d4004ee | 2004-09-14 17:24:59 +0000 | [diff] [blame] | 496 | const char *localfile = NULL; |
| 497 | const char *remotefile = NULL; |
Glenn L McGrath | 036dbaa | 2004-01-17 05:03:31 +0000 | [diff] [blame] | 498 | int port; |
Eric Andersen | 76fa8ea | 2001-08-20 17:47:49 +0000 | [diff] [blame] | 499 | int cmd = 0; |
| 500 | int fd = -1; |
| 501 | int flags = 0; |
Eric Andersen | 76fa8ea | 2001-08-20 17:47:49 +0000 | [diff] [blame] | 502 | int result; |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 503 | int blocksize = TFTP_BLOCKSIZE_DEFAULT; |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 504 | |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 505 | /* figure out what to pass to getopt */ |
| 506 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 507 | #ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE |
"Vladimir N. Oleynik" | 86ac072 | 2005-10-17 10:47:19 +0000 | [diff] [blame] | 508 | char *sblocksize = NULL; |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 509 | #define BS "b:" |
"Vladimir N. Oleynik" | 86ac072 | 2005-10-17 10:47:19 +0000 | [diff] [blame] | 510 | #define BS_ARG , &sblocksize |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 511 | #else |
| 512 | #define BS |
"Vladimir N. Oleynik" | 86ac072 | 2005-10-17 10:47:19 +0000 | [diff] [blame] | 513 | #define BS_ARG |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 514 | #endif |
| 515 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 516 | #ifdef CONFIG_FEATURE_TFTP_GET |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 517 | #define GET "g" |
"Vladimir N. Oleynik" | 86ac072 | 2005-10-17 10:47:19 +0000 | [diff] [blame] | 518 | #define GET_COMPL ":g" |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 519 | #else |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 520 | #define GET |
Bernhard Reutner-Fischer | 886f6af | 2006-04-05 16:47:02 +0000 | [diff] [blame] | 521 | #define GET_COMPL |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 522 | #endif |
| 523 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 524 | #ifdef CONFIG_FEATURE_TFTP_PUT |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 525 | #define PUT "p" |
"Vladimir N. Oleynik" | 86ac072 | 2005-10-17 10:47:19 +0000 | [diff] [blame] | 526 | #define PUT_COMPL ":p" |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 527 | #else |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 528 | #define PUT |
"Vladimir N. Oleynik" | 86ac072 | 2005-10-17 10:47:19 +0000 | [diff] [blame] | 529 | #define PUT_COMPL |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 530 | #endif |
| 531 | |
"Vladimir N. Oleynik" | 86ac072 | 2005-10-17 10:47:19 +0000 | [diff] [blame] | 532 | #if defined(CONFIG_FEATURE_TFTP_GET) && defined(CONFIG_FEATURE_TFTP_PUT) |
| 533 | bb_opt_complementally = GET_COMPL PUT_COMPL ":?g--p:p--g"; |
| 534 | #elif defined(CONFIG_FEATURE_TFTP_GET) || defined(CONFIG_FEATURE_TFTP_PUT) |
| 535 | bb_opt_complementally = GET_COMPL PUT_COMPL; |
| 536 | #else |
| 537 | /* XXX: may be should #error ? */ |
| 538 | #endif |
| 539 | |
Tim Riker | c1ef7bd | 2006-01-25 00:08:53 +0000 | [diff] [blame] | 540 | |
| 541 | cmd = bb_getopt_ulflags(argc, argv, GET PUT "l:r:" BS, |
"Vladimir N. Oleynik" | 86ac072 | 2005-10-17 10:47:19 +0000 | [diff] [blame] | 542 | &localfile, &remotefile BS_ARG); |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 543 | #ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE |
"Vladimir N. Oleynik" | 86ac072 | 2005-10-17 10:47:19 +0000 | [diff] [blame] | 544 | if(sblocksize) { |
| 545 | blocksize = atoi(sblocksize); |
| 546 | if (!tftp_blocksize_check(blocksize, 0)) { |
| 547 | return EXIT_FAILURE; |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 548 | } |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 549 | } |
"Vladimir N. Oleynik" | 86ac072 | 2005-10-17 10:47:19 +0000 | [diff] [blame] | 550 | #endif |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 551 | |
Rob Landley | 5aabf4e | 2005-12-15 05:42:55 +0000 | [diff] [blame] | 552 | cmd &= (tftp_cmd_get | tftp_cmd_put); |
"Vladimir N. Oleynik" | 86ac072 | 2005-10-17 10:47:19 +0000 | [diff] [blame] | 553 | #ifdef CONFIG_FEATURE_TFTP_GET |
| 554 | if(cmd == tftp_cmd_get) |
| 555 | flags = O_WRONLY | O_CREAT | O_TRUNC; |
| 556 | #endif |
| 557 | #ifdef CONFIG_FEATURE_TFTP_PUT |
| 558 | if(cmd == tftp_cmd_put) |
| 559 | flags = O_RDONLY; |
| 560 | #endif |
| 561 | |
Eric Andersen | 744ec1d | 2002-04-15 07:40:27 +0000 | [diff] [blame] | 562 | if(localfile == NULL) |
| 563 | localfile = remotefile; |
| 564 | if(remotefile == NULL) |
| 565 | remotefile = localfile; |
"Vladimir N. Oleynik" | 86ac072 | 2005-10-17 10:47:19 +0000 | [diff] [blame] | 566 | /* XXX: I corrected this, but may be wrong too. vodz */ |
| 567 | if(localfile==NULL || strcmp(localfile, "-") == 0) { |
| 568 | fd = fileno((cmd==tftp_cmd_get)? stdout : stdin); |
| 569 | } else if (fd==-1) { |
Eric Andersen | a66a43e | 2002-04-13 09:30:25 +0000 | [diff] [blame] | 570 | fd = open(localfile, flags, 0644); |
| 571 | } |
Eric Andersen | 76fa8ea | 2001-08-20 17:47:49 +0000 | [diff] [blame] | 572 | if (fd < 0) { |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 573 | bb_perror_msg_and_die("local file"); |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 574 | } |
| 575 | |
"Vladimir N. Oleynik" | 86ac072 | 2005-10-17 10:47:19 +0000 | [diff] [blame] | 576 | /* XXX: argv[optind] and/or argv[optind + 1] may be NULL! */ |
Eric Andersen | 76fa8ea | 2001-08-20 17:47:49 +0000 | [diff] [blame] | 577 | host = xgethostbyname(argv[optind]); |
Glenn L McGrath | 036dbaa | 2004-01-17 05:03:31 +0000 | [diff] [blame] | 578 | port = bb_lookup_port(argv[optind + 1], "udp", 69); |
Eric Andersen | 76fa8ea | 2001-08-20 17:47:49 +0000 | [diff] [blame] | 579 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 580 | #ifdef CONFIG_FEATURE_TFTP_DEBUG |
Glenn L McGrath | d33278d | 2004-02-22 07:20:25 +0000 | [diff] [blame] | 581 | fprintf(stderr, "using server \"%s\", remotefile \"%s\", " |
Eric Andersen | 76fa8ea | 2001-08-20 17:47:49 +0000 | [diff] [blame] | 582 | "localfile \"%s\".\n", |
| 583 | inet_ntoa(*((struct in_addr *) host->h_addr)), |
| 584 | remotefile, localfile); |
| 585 | #endif |
| 586 | |
| 587 | result = tftp(cmd, host, remotefile, fd, port, blocksize); |
Mark Whitley | 450736c | 2001-03-02 19:08:50 +0000 | [diff] [blame] | 588 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 589 | #ifdef CONFIG_FEATURE_CLEAN_UP |
Eric Andersen | 70060d2 | 2004-03-27 10:02:48 +0000 | [diff] [blame] | 590 | if (!(fd == STDOUT_FILENO || fd == STDIN_FILENO)) { |
Eric Andersen | a66a43e | 2002-04-13 09:30:25 +0000 | [diff] [blame] | 591 | close(fd); |
| 592 | } |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 593 | #endif |
Eric Andersen | 76fa8ea | 2001-08-20 17:47:49 +0000 | [diff] [blame] | 594 | return(result); |
Glenn L McGrath | ad117d8 | 2001-10-05 04:40:37 +0000 | [diff] [blame] | 595 | } |