Commit | Line | Data |
---|---|---|
d0aeaf5a | 1 | /* |
f6e43951 KB |
2 | * Copyright (c) 1983 Regents of the University of California. |
3 | * All rights reserved. | |
4 | * | |
cb956e54 | 5 | * %sccs.include.redist.c% |
d0aeaf5a DF |
6 | */ |
7 | ||
8 | #ifndef lint | |
9 | char copyright[] = | |
10 | "@(#) Copyright (c) 1983 Regents of the University of California.\n\ | |
11 | All rights reserved.\n"; | |
f6e43951 | 12 | #endif /* not lint */ |
d0aeaf5a | 13 | |
524aa063 | 14 | #ifndef lint |
cb956e54 | 15 | static char sccsid[] = "@(#)main.c 5.9 (Berkeley) %G%"; |
f6e43951 | 16 | #endif /* not lint */ |
c3353d83 | 17 | |
6457cfd6 GM |
18 | /* Many bug fixes are from Jim Guyton <guyton@rand-unix> */ |
19 | ||
c3353d83 SL |
20 | /* |
21 | * TFTP User Program -- Command Interface. | |
22 | */ | |
23 | #include <sys/types.h> | |
c3353d83 | 24 | #include <sys/socket.h> |
61ad9979 | 25 | #include <sys/file.h> |
de3b21e8 SL |
26 | |
27 | #include <netinet/in.h> | |
28 | ||
c3353d83 SL |
29 | #include <signal.h> |
30 | #include <stdio.h> | |
31 | #include <errno.h> | |
32 | #include <setjmp.h> | |
33 | #include <ctype.h> | |
4d5e33bd | 34 | #include <netdb.h> |
c3353d83 | 35 | |
61ad9979 SL |
36 | #define TIMEOUT 5 /* secs between rexmt's */ |
37 | ||
6457cfd6 | 38 | struct sockaddr_in sin; |
c3353d83 | 39 | int f; |
6457cfd6 | 40 | short port; |
c3353d83 | 41 | int trace; |
6457cfd6 | 42 | int verbose; |
c3353d83 SL |
43 | int connected; |
44 | char mode[32]; | |
45 | char line[200]; | |
46 | int margc; | |
47 | char *margv[20]; | |
48 | char *prompt = "tftp"; | |
49 | jmp_buf toplevel; | |
50 | int intr(); | |
4d5e33bd | 51 | struct servent *sp; |
c3353d83 | 52 | |
6457cfd6 GM |
53 | int quit(), help(), setverbose(), settrace(), status(); |
54 | int get(), put(), setpeer(), modecmd(), setrexmt(), settimeout(); | |
55 | int setbinary(), setascii(); | |
c3353d83 SL |
56 | |
57 | #define HELPINDENT (sizeof("connect")) | |
58 | ||
59 | struct cmd { | |
60 | char *name; | |
61 | char *help; | |
62 | int (*handler)(); | |
63 | }; | |
64 | ||
6457cfd6 | 65 | char vhelp[] = "toggle verbose mode"; |
c3353d83 SL |
66 | char thelp[] = "toggle packet tracing"; |
67 | char chelp[] = "connect to remote tftp"; | |
68 | char qhelp[] = "exit tftp"; | |
69 | char hhelp[] = "print help information"; | |
70 | char shelp[] = "send file"; | |
71 | char rhelp[] = "receive file"; | |
72 | char mhelp[] = "set file transfer mode"; | |
73 | char sthelp[] = "show current status"; | |
61ad9979 SL |
74 | char xhelp[] = "set per-packet retransmission timeout"; |
75 | char ihelp[] = "set total retransmission timeout"; | |
6457cfd6 GM |
76 | char ashelp[] = "set mode to netascii"; |
77 | char bnhelp[] = "set mode to octet"; | |
c3353d83 SL |
78 | |
79 | struct cmd cmdtab[] = { | |
80 | { "connect", chelp, setpeer }, | |
6457cfd6 | 81 | { "mode", mhelp, modecmd }, |
c3353d83 SL |
82 | { "put", shelp, put }, |
83 | { "get", rhelp, get }, | |
84 | { "quit", qhelp, quit }, | |
6457cfd6 | 85 | { "verbose", vhelp, setverbose }, |
c3353d83 SL |
86 | { "trace", thelp, settrace }, |
87 | { "status", sthelp, status }, | |
6457cfd6 GM |
88 | { "binary", bnhelp, setbinary }, |
89 | { "ascii", ashelp, setascii }, | |
61ad9979 SL |
90 | { "rexmt", xhelp, setrexmt }, |
91 | { "timeout", ihelp, settimeout }, | |
c3353d83 SL |
92 | { "?", hhelp, help }, |
93 | 0 | |
94 | }; | |
95 | ||
96 | struct cmd *getcmd(); | |
97 | char *tail(); | |
98 | char *index(); | |
99 | char *rindex(); | |
100 | ||
101 | main(argc, argv) | |
102 | char *argv[]; | |
103 | { | |
6457cfd6 | 104 | struct sockaddr_in sin; |
61ad9979 SL |
105 | int top; |
106 | ||
4d5e33bd SL |
107 | sp = getservbyname("tftp", "udp"); |
108 | if (sp == 0) { | |
109 | fprintf(stderr, "tftp: udp/tftp: unknown service\n"); | |
110 | exit(1); | |
111 | } | |
7457289f | 112 | f = socket(AF_INET, SOCK_DGRAM, 0); |
c3353d83 | 113 | if (f < 0) { |
61ad9979 | 114 | perror("tftp: socket"); |
c3353d83 SL |
115 | exit(3); |
116 | } | |
6457cfd6 GM |
117 | bzero((char *)&sin, sizeof (sin)); |
118 | sin.sin_family = AF_INET; | |
61ad9979 SL |
119 | if (bind(f, &sin, sizeof (sin)) < 0) { |
120 | perror("tftp: bind"); | |
121 | exit(1); | |
122 | } | |
6457cfd6 | 123 | strcpy(mode, "netascii"); |
61ad9979 | 124 | signal(SIGINT, intr); |
c3353d83 SL |
125 | if (argc > 1) { |
126 | if (setjmp(toplevel) != 0) | |
127 | exit(0); | |
128 | setpeer(argc, argv); | |
129 | } | |
61ad9979 | 130 | top = setjmp(toplevel) == 0; |
c3353d83 | 131 | for (;;) |
61ad9979 | 132 | command(top); |
c3353d83 SL |
133 | } |
134 | ||
6457cfd6 | 135 | char hostname[100]; |
c3353d83 SL |
136 | |
137 | setpeer(argc, argv) | |
138 | int argc; | |
139 | char *argv[]; | |
140 | { | |
4d5e33bd | 141 | struct hostent *host; |
c3353d83 SL |
142 | |
143 | if (argc < 2) { | |
144 | strcpy(line, "Connect "); | |
145 | printf("(to) "); | |
146 | gets(&line[strlen(line)]); | |
147 | makeargv(); | |
148 | argc = margc; | |
149 | argv = margv; | |
150 | } | |
151 | if (argc > 3) { | |
152 | printf("usage: %s host-name [port]\n", argv[0]); | |
153 | return; | |
154 | } | |
4d5e33bd SL |
155 | host = gethostbyname(argv[1]); |
156 | if (host) { | |
de3b21e8 | 157 | sin.sin_family = host->h_addrtype; |
4d5e33bd | 158 | bcopy(host->h_addr, &sin.sin_addr, host->h_length); |
6457cfd6 | 159 | strcpy(hostname, host->h_name); |
4d5e33bd | 160 | } else { |
de3b21e8 | 161 | sin.sin_family = AF_INET; |
4d5e33bd SL |
162 | sin.sin_addr.s_addr = inet_addr(argv[1]); |
163 | if (sin.sin_addr.s_addr == -1) { | |
164 | connected = 0; | |
165 | printf("%s: unknown host\n", argv[1]); | |
166 | return; | |
167 | } | |
6457cfd6 | 168 | strcpy(hostname, argv[1]); |
c3353d83 | 169 | } |
6457cfd6 | 170 | port = sp->s_port; |
c3353d83 | 171 | if (argc == 3) { |
6457cfd6 GM |
172 | port = atoi(argv[2]); |
173 | if (port < 0) { | |
c3353d83 SL |
174 | printf("%s: bad port number\n", argv[2]); |
175 | connected = 0; | |
176 | return; | |
177 | } | |
6457cfd6 | 178 | port = htons(port); |
4d5e33bd | 179 | } |
c3353d83 SL |
180 | connected = 1; |
181 | } | |
182 | ||
183 | struct modes { | |
184 | char *m_name; | |
185 | char *m_mode; | |
186 | } modes[] = { | |
6457cfd6 GM |
187 | { "ascii", "netascii" }, |
188 | { "netascii", "netascii" }, | |
189 | { "binary", "octet" }, | |
190 | { "image", "octet" }, | |
f440089a | 191 | { "octet", "octet" }, |
6457cfd6 | 192 | /* { "mail", "mail" }, */ |
c3353d83 SL |
193 | { 0, 0 } |
194 | }; | |
195 | ||
6457cfd6 | 196 | modecmd(argc, argv) |
c3353d83 SL |
197 | char *argv[]; |
198 | { | |
199 | register struct modes *p; | |
6457cfd6 | 200 | char *sep; |
c3353d83 | 201 | |
c3353d83 SL |
202 | if (argc < 2) { |
203 | printf("Using %s mode to transfer files.\n", mode); | |
204 | return; | |
205 | } | |
6457cfd6 GM |
206 | if (argc == 2) { |
207 | for (p = modes; p->m_name; p++) | |
208 | if (strcmp(argv[1], p->m_name) == 0) | |
209 | break; | |
210 | if (p->m_name) { | |
211 | setmode(p->m_mode); | |
212 | return; | |
213 | } | |
c3353d83 | 214 | printf("%s: unknown mode\n", argv[1]); |
6457cfd6 GM |
215 | /* drop through and print usage message */ |
216 | } | |
217 | ||
218 | printf("usage: %s [", argv[0]); | |
219 | sep = " "; | |
220 | for (p = modes; p->m_name; p++) { | |
221 | printf("%s%s", sep, p->m_name); | |
222 | if (*sep == ' ') | |
223 | sep = " | "; | |
224 | } | |
225 | printf(" ]\n"); | |
226 | return; | |
227 | } | |
228 | ||
229 | setbinary(argc, argv) | |
230 | char *argv[]; | |
231 | { setmode("octet"); | |
232 | } | |
233 | ||
234 | setascii(argc, argv) | |
235 | char *argv[]; | |
236 | { setmode("netascii"); | |
c3353d83 SL |
237 | } |
238 | ||
6457cfd6 GM |
239 | setmode(newmode) |
240 | char *newmode; | |
241 | { | |
242 | strcpy(mode, newmode); | |
243 | if (verbose) | |
244 | printf("mode set to %s\n", mode); | |
245 | } | |
246 | ||
247 | ||
c3353d83 SL |
248 | /* |
249 | * Send file(s). | |
250 | */ | |
251 | put(argc, argv) | |
252 | char *argv[]; | |
253 | { | |
254 | int fd; | |
6457cfd6 | 255 | register int n; |
c3353d83 SL |
256 | register char *cp, *targ; |
257 | ||
258 | if (argc < 2) { | |
259 | strcpy(line, "send "); | |
260 | printf("(file) "); | |
261 | gets(&line[strlen(line)]); | |
262 | makeargv(); | |
263 | argc = margc; | |
264 | argv = margv; | |
265 | } | |
266 | if (argc < 2) { | |
267 | putusage(argv[0]); | |
268 | return; | |
269 | } | |
270 | targ = argv[argc - 1]; | |
271 | if (index(argv[argc - 1], ':')) { | |
4d5e33bd SL |
272 | char *cp; |
273 | struct hostent *hp; | |
c3353d83 SL |
274 | |
275 | for (n = 1; n < argc - 1; n++) | |
276 | if (index(argv[n], ':')) { | |
277 | putusage(argv[0]); | |
278 | return; | |
279 | } | |
4d5e33bd SL |
280 | cp = argv[argc - 1]; |
281 | targ = index(cp, ':'); | |
c3353d83 | 282 | *targ++ = 0; |
4d5e33bd | 283 | hp = gethostbyname(cp); |
7620b226 KB |
284 | if (hp == NULL) { |
285 | fprintf(stderr, "tftp: %s: ", cp); | |
286 | herror((char *)NULL); | |
c3353d83 SL |
287 | return; |
288 | } | |
de3b21e8 | 289 | bcopy(hp->h_addr, (caddr_t)&sin.sin_addr, hp->h_length); |
4d5e33bd | 290 | sin.sin_family = hp->h_addrtype; |
c3353d83 | 291 | connected = 1; |
6457cfd6 | 292 | strcpy(hostname, hp->h_name); |
c3353d83 SL |
293 | } |
294 | if (!connected) { | |
295 | printf("No target machine specified.\n"); | |
296 | return; | |
297 | } | |
c3353d83 SL |
298 | if (argc < 4) { |
299 | cp = argc == 2 ? tail(targ) : argv[1]; | |
61ad9979 | 300 | fd = open(cp, O_RDONLY); |
c3353d83 | 301 | if (fd < 0) { |
61ad9979 | 302 | fprintf(stderr, "tftp: "); perror(cp); |
c3353d83 SL |
303 | return; |
304 | } | |
6457cfd6 GM |
305 | if (verbose) |
306 | printf("putting %s to %s:%s [%s]\n", | |
307 | cp, hostname, targ, mode); | |
308 | sin.sin_port = port; | |
309 | sendfile(fd, targ, mode); | |
c3353d83 SL |
310 | return; |
311 | } | |
6457cfd6 GM |
312 | /* this assumes the target is a directory */ |
313 | /* on a remote unix system. hmmmm. */ | |
c3353d83 SL |
314 | cp = index(targ, '\0'); |
315 | *cp++ = '/'; | |
316 | for (n = 1; n < argc - 1; n++) { | |
317 | strcpy(cp, tail(argv[n])); | |
61ad9979 | 318 | fd = open(argv[n], O_RDONLY); |
c3353d83 | 319 | if (fd < 0) { |
61ad9979 | 320 | fprintf(stderr, "tftp: "); perror(argv[n]); |
c3353d83 SL |
321 | continue; |
322 | } | |
6457cfd6 GM |
323 | if (verbose) |
324 | printf("putting %s to %s:%s [%s]\n", | |
325 | argv[n], hostname, targ, mode); | |
326 | sin.sin_port = port; | |
327 | sendfile(fd, targ, mode); | |
c3353d83 SL |
328 | } |
329 | } | |
330 | ||
331 | putusage(s) | |
332 | char *s; | |
333 | { | |
334 | printf("usage: %s file ... host:target, or\n", s); | |
335 | printf(" %s file ... target (when already connected)\n", s); | |
336 | } | |
337 | ||
338 | /* | |
339 | * Receive file(s). | |
340 | */ | |
341 | get(argc, argv) | |
342 | char *argv[]; | |
343 | { | |
344 | int fd; | |
6457cfd6 | 345 | register int n; |
c3353d83 SL |
346 | register char *cp; |
347 | char *src; | |
348 | ||
349 | if (argc < 2) { | |
350 | strcpy(line, "get "); | |
351 | printf("(files) "); | |
352 | gets(&line[strlen(line)]); | |
353 | makeargv(); | |
354 | argc = margc; | |
355 | argv = margv; | |
356 | } | |
357 | if (argc < 2) { | |
358 | getusage(argv[0]); | |
359 | return; | |
360 | } | |
6457cfd6 GM |
361 | if (!connected) { |
362 | for (n = 1; n < argc ; n++) | |
c3353d83 SL |
363 | if (index(argv[n], ':') == 0) { |
364 | getusage(argv[0]); | |
365 | return; | |
366 | } | |
6457cfd6 GM |
367 | } |
368 | for (n = 1; n < argc ; n++) { | |
c3353d83 SL |
369 | src = index(argv[n], ':'); |
370 | if (src == NULL) | |
371 | src = argv[n]; | |
372 | else { | |
4d5e33bd SL |
373 | struct hostent *hp; |
374 | ||
c3353d83 | 375 | *src++ = 0; |
4d5e33bd | 376 | hp = gethostbyname(argv[n]); |
7620b226 KB |
377 | if (hp == NULL) { |
378 | fprintf(stderr, "tftp: %s: ", argv[n]); | |
379 | herror((char *)NULL); | |
c3353d83 SL |
380 | continue; |
381 | } | |
de3b21e8 | 382 | bcopy(hp->h_addr, (caddr_t)&sin.sin_addr, hp->h_length); |
4d5e33bd | 383 | sin.sin_family = hp->h_addrtype; |
c3353d83 | 384 | connected = 1; |
6457cfd6 | 385 | strcpy(hostname, hp->h_name); |
c3353d83 SL |
386 | } |
387 | if (argc < 4) { | |
388 | cp = argc == 3 ? argv[2] : tail(src); | |
389 | fd = creat(cp, 0644); | |
390 | if (fd < 0) { | |
61ad9979 | 391 | fprintf(stderr, "tftp: "); perror(cp); |
c3353d83 SL |
392 | return; |
393 | } | |
6457cfd6 GM |
394 | if (verbose) |
395 | printf("getting from %s:%s to %s [%s]\n", | |
396 | hostname, src, cp, mode); | |
397 | sin.sin_port = port; | |
398 | recvfile(fd, src, mode); | |
c3353d83 SL |
399 | break; |
400 | } | |
6457cfd6 GM |
401 | cp = tail(src); /* new .. jdg */ |
402 | fd = creat(cp, 0644); | |
c3353d83 | 403 | if (fd < 0) { |
6457cfd6 | 404 | fprintf(stderr, "tftp: "); perror(cp); |
c3353d83 SL |
405 | continue; |
406 | } | |
6457cfd6 GM |
407 | if (verbose) |
408 | printf("getting from %s:%s to %s [%s]\n", | |
409 | hostname, src, cp, mode); | |
410 | sin.sin_port = port; | |
411 | recvfile(fd, src, mode); | |
c3353d83 SL |
412 | } |
413 | } | |
414 | ||
415 | getusage(s) | |
7457289f | 416 | char * s; |
c3353d83 SL |
417 | { |
418 | printf("usage: %s host:file host:file ... file, or\n", s); | |
419 | printf(" %s file file ... file if connected\n", s); | |
420 | } | |
421 | ||
61ad9979 SL |
422 | int rexmtval = TIMEOUT; |
423 | ||
424 | setrexmt(argc, argv) | |
425 | char *argv[]; | |
426 | { | |
427 | int t; | |
428 | ||
429 | if (argc < 2) { | |
430 | strcpy(line, "Rexmt-timeout "); | |
431 | printf("(value) "); | |
432 | gets(&line[strlen(line)]); | |
433 | makeargv(); | |
434 | argc = margc; | |
435 | argv = margv; | |
436 | } | |
437 | if (argc != 2) { | |
438 | printf("usage: %s value\n", argv[0]); | |
439 | return; | |
440 | } | |
441 | t = atoi(argv[1]); | |
442 | if (t < 0) | |
443 | printf("%s: bad value\n", t); | |
444 | else | |
445 | rexmtval = t; | |
446 | } | |
447 | ||
448 | int maxtimeout = 5 * TIMEOUT; | |
449 | ||
450 | settimeout(argc, argv) | |
451 | char *argv[]; | |
452 | { | |
453 | int t; | |
454 | ||
455 | if (argc < 2) { | |
456 | strcpy(line, "Maximum-timeout "); | |
457 | printf("(value) "); | |
458 | gets(&line[strlen(line)]); | |
459 | makeargv(); | |
460 | argc = margc; | |
461 | argv = margv; | |
462 | } | |
463 | if (argc != 2) { | |
464 | printf("usage: %s value\n", argv[0]); | |
465 | return; | |
466 | } | |
467 | t = atoi(argv[1]); | |
468 | if (t < 0) | |
469 | printf("%s: bad value\n", t); | |
470 | else | |
471 | maxtimeout = t; | |
472 | } | |
473 | ||
c3353d83 SL |
474 | status(argc, argv) |
475 | char *argv[]; | |
476 | { | |
477 | if (connected) | |
4d5e33bd | 478 | printf("Connected to %s.\n", hostname); |
c3353d83 SL |
479 | else |
480 | printf("Not connected.\n"); | |
6457cfd6 GM |
481 | printf("Mode: %s Verbose: %s Tracing: %s\n", mode, |
482 | verbose ? "on" : "off", trace ? "on" : "off"); | |
61ad9979 SL |
483 | printf("Rexmt-interval: %d seconds, Max-timeout: %d seconds\n", |
484 | rexmtval, maxtimeout); | |
c3353d83 SL |
485 | } |
486 | ||
487 | intr() | |
488 | { | |
6457cfd6 | 489 | signal(SIGALRM, SIG_IGN); |
b09ddebf | 490 | alarm(0); |
c3353d83 SL |
491 | longjmp(toplevel, -1); |
492 | } | |
493 | ||
494 | char * | |
495 | tail(filename) | |
496 | char *filename; | |
497 | { | |
498 | register char *s; | |
499 | ||
500 | while (*filename) { | |
501 | s = rindex(filename, '/'); | |
502 | if (s == NULL) | |
503 | break; | |
504 | if (s[1]) | |
505 | return (s + 1); | |
506 | *s = '\0'; | |
507 | } | |
508 | return (filename); | |
509 | } | |
510 | ||
511 | /* | |
512 | * Command parser. | |
513 | */ | |
514 | command(top) | |
515 | int top; | |
516 | { | |
517 | register struct cmd *c; | |
518 | ||
519 | if (!top) | |
520 | putchar('\n'); | |
c3353d83 SL |
521 | for (;;) { |
522 | printf("%s> ", prompt); | |
f440089a GM |
523 | if (gets(line) == 0) { |
524 | if (feof(stdin)) { | |
525 | quit(); | |
526 | } else { | |
527 | continue; | |
528 | } | |
529 | } | |
c3353d83 | 530 | if (line[0] == 0) |
61ad9979 | 531 | continue; |
c3353d83 SL |
532 | makeargv(); |
533 | c = getcmd(margv[0]); | |
534 | if (c == (struct cmd *)-1) { | |
535 | printf("?Ambiguous command\n"); | |
536 | continue; | |
537 | } | |
538 | if (c == 0) { | |
539 | printf("?Invalid command\n"); | |
540 | continue; | |
541 | } | |
542 | (*c->handler)(margc, margv); | |
c3353d83 | 543 | } |
c3353d83 SL |
544 | } |
545 | ||
546 | struct cmd * | |
547 | getcmd(name) | |
548 | register char *name; | |
549 | { | |
550 | register char *p, *q; | |
551 | register struct cmd *c, *found; | |
552 | register int nmatches, longest; | |
553 | ||
554 | longest = 0; | |
555 | nmatches = 0; | |
556 | found = 0; | |
557 | for (c = cmdtab; p = c->name; c++) { | |
558 | for (q = name; *q == *p++; q++) | |
559 | if (*q == 0) /* exact match? */ | |
560 | return (c); | |
561 | if (!*q) { /* the name was a prefix */ | |
562 | if (q - name > longest) { | |
563 | longest = q - name; | |
564 | nmatches = 1; | |
565 | found = c; | |
566 | } else if (q - name == longest) | |
567 | nmatches++; | |
568 | } | |
569 | } | |
570 | if (nmatches > 1) | |
571 | return ((struct cmd *)-1); | |
572 | return (found); | |
573 | } | |
574 | ||
575 | /* | |
576 | * Slice a string up into argc/argv. | |
577 | */ | |
578 | makeargv() | |
579 | { | |
580 | register char *cp; | |
581 | register char **argp = margv; | |
582 | ||
583 | margc = 0; | |
584 | for (cp = line; *cp;) { | |
585 | while (isspace(*cp)) | |
586 | cp++; | |
587 | if (*cp == '\0') | |
588 | break; | |
589 | *argp++ = cp; | |
590 | margc += 1; | |
591 | while (*cp != '\0' && !isspace(*cp)) | |
592 | cp++; | |
593 | if (*cp == '\0') | |
594 | break; | |
595 | *cp++ = '\0'; | |
596 | } | |
597 | *argp++ = 0; | |
598 | } | |
599 | ||
600 | /*VARARGS*/ | |
601 | quit() | |
602 | { | |
603 | exit(0); | |
604 | } | |
605 | ||
606 | /* | |
607 | * Help command. | |
c3353d83 SL |
608 | */ |
609 | help(argc, argv) | |
610 | int argc; | |
611 | char *argv[]; | |
612 | { | |
613 | register struct cmd *c; | |
614 | ||
615 | if (argc == 1) { | |
616 | printf("Commands may be abbreviated. Commands are:\n\n"); | |
617 | for (c = cmdtab; c->name; c++) | |
618 | printf("%-*s\t%s\n", HELPINDENT, c->name, c->help); | |
619 | return; | |
620 | } | |
621 | while (--argc > 0) { | |
622 | register char *arg; | |
623 | arg = *++argv; | |
624 | c = getcmd(arg); | |
625 | if (c == (struct cmd *)-1) | |
626 | printf("?Ambiguous help command %s\n", arg); | |
627 | else if (c == (struct cmd *)0) | |
628 | printf("?Invalid help command %s\n", arg); | |
629 | else | |
630 | printf("%s\n", c->help); | |
631 | } | |
632 | } | |
633 | ||
c3353d83 SL |
634 | /*VARARGS*/ |
635 | settrace() | |
636 | { | |
637 | trace = !trace; | |
638 | printf("Packet tracing %s.\n", trace ? "on" : "off"); | |
639 | } | |
6457cfd6 GM |
640 | |
641 | /*VARARGS*/ | |
642 | setverbose() | |
643 | { | |
644 | verbose = !verbose; | |
645 | printf("Verbose mode %s.\n", verbose ? "on" : "off"); | |
646 | } |