diff options
Diffstat (limited to 'src/usr.bin/nc/netcat.c')
| -rw-r--r-- | src/usr.bin/nc/netcat.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/usr.bin/nc/netcat.c b/src/usr.bin/nc/netcat.c index ee151972e8..ea907d6b1a 100644 --- a/src/usr.bin/nc/netcat.c +++ b/src/usr.bin/nc/netcat.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: netcat.c,v 1.72 2004/03/12 10:10:00 jmc Exp $ */ | 1 | /* $OpenBSD: netcat.c,v 1.73 2004/07/15 15:07:52 markus Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> | 3 | * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> |
| 4 | * | 4 | * |
| @@ -73,6 +73,7 @@ int uflag; /* UDP - Default to TCP */ | |||
| 73 | int vflag; /* Verbosity */ | 73 | int vflag; /* Verbosity */ |
| 74 | int xflag; /* Socks proxy */ | 74 | int xflag; /* Socks proxy */ |
| 75 | int zflag; /* Port Scan Flag */ | 75 | int zflag; /* Port Scan Flag */ |
| 76 | int Dflag; /* sodebug */ | ||
| 76 | int Sflag; /* TCP MD5 signature option */ | 77 | int Sflag; /* TCP MD5 signature option */ |
| 77 | 78 | ||
| 78 | int timeout = -1; | 79 | int timeout = -1; |
| @@ -114,7 +115,7 @@ main(int argc, char *argv[]) | |||
| 114 | endp = NULL; | 115 | endp = NULL; |
| 115 | sv = NULL; | 116 | sv = NULL; |
| 116 | 117 | ||
| 117 | while ((ch = getopt(argc, argv, "46UX:dhi:klnp:rs:tuvw:x:zS")) != -1) { | 118 | while ((ch = getopt(argc, argv, "46Ddhi:klnp:rSs:tUuvw:X:x:z")) != -1) { |
| 118 | switch (ch) { | 119 | switch (ch) { |
| 119 | case '4': | 120 | case '4': |
| 120 | family = AF_INET; | 121 | family = AF_INET; |
| @@ -184,6 +185,9 @@ main(int argc, char *argv[]) | |||
| 184 | case 'z': | 185 | case 'z': |
| 185 | zflag = 1; | 186 | zflag = 1; |
| 186 | break; | 187 | break; |
| 188 | case 'D': | ||
| 189 | Dflag = 1; | ||
| 190 | break; | ||
| 187 | case 'S': | 191 | case 'S': |
| 188 | Sflag = 1; | 192 | Sflag = 1; |
| 189 | break; | 193 | break; |
| @@ -486,6 +490,11 @@ remote_connect(char *host, char *port, struct addrinfo hints) | |||
| 486 | &x, sizeof(x)) == -1) | 490 | &x, sizeof(x)) == -1) |
| 487 | err(1, NULL); | 491 | err(1, NULL); |
| 488 | } | 492 | } |
| 493 | if (Dflag) { | ||
| 494 | if (setsockopt(s, SOL_SOCKET, SO_DEBUG, | ||
| 495 | &x, sizeof(x)) == -1) | ||
| 496 | err(1, NULL); | ||
| 497 | } | ||
| 489 | 498 | ||
| 490 | if (connect(s, res0->ai_addr, res0->ai_addrlen) == 0) | 499 | if (connect(s, res0->ai_addr, res0->ai_addrlen) == 0) |
| 491 | break; | 500 | break; |
| @@ -542,6 +551,11 @@ local_listen(char *host, char *port, struct addrinfo hints) | |||
| 542 | if (ret == -1) | 551 | if (ret == -1) |
| 543 | err(1, NULL); | 552 | err(1, NULL); |
| 544 | } | 553 | } |
| 554 | if (Dflag) { | ||
| 555 | if (setsockopt(s, SOL_SOCKET, SO_DEBUG, | ||
| 556 | &x, sizeof(x)) == -1) | ||
| 557 | err(1, NULL); | ||
| 558 | } | ||
| 545 | 559 | ||
| 546 | if (bind(s, (struct sockaddr *)res0->ai_addr, | 560 | if (bind(s, (struct sockaddr *)res0->ai_addr, |
| 547 | res0->ai_addrlen) == 0) | 561 | res0->ai_addrlen) == 0) |
| @@ -753,6 +767,7 @@ help(void) | |||
| 753 | fprintf(stderr, "\tCommand Summary:\n\ | 767 | fprintf(stderr, "\tCommand Summary:\n\ |
| 754 | \t-4 Use IPv4\n\ | 768 | \t-4 Use IPv4\n\ |
| 755 | \t-6 Use IPv6\n\ | 769 | \t-6 Use IPv6\n\ |
| 770 | \t-D Enable the debug socket option\n\ | ||
| 756 | \t-d Detach from stdin\n\ | 771 | \t-d Detach from stdin\n\ |
| 757 | \t-h This help text\n\ | 772 | \t-h This help text\n\ |
| 758 | \t-i secs\t Delay interval for lines sent, ports scanned\n\ | 773 | \t-i secs\t Delay interval for lines sent, ports scanned\n\ |
| @@ -778,7 +793,7 @@ help(void) | |||
| 778 | void | 793 | void |
| 779 | usage(int ret) | 794 | usage(int ret) |
| 780 | { | 795 | { |
| 781 | fprintf(stderr, "usage: nc [-46dhklnrStUuvz] [-i interval] [-p source_port]\n"); | 796 | fprintf(stderr, "usage: nc [-46DdhklnrStUuvz] [-i interval] [-p source_port]\n"); |
| 782 | fprintf(stderr, "\t [-s source_ip_address] [-w timeout] [-X socks_version]\n"); | 797 | fprintf(stderr, "\t [-s source_ip_address] [-w timeout] [-X socks_version]\n"); |
| 783 | fprintf(stderr, "\t [-x proxy_address[:port]] [hostname] [port[s]]\n"); | 798 | fprintf(stderr, "\t [-x proxy_address[:port]] [hostname] [port[s]]\n"); |
| 784 | if (ret) | 799 | if (ret) |
