source:
npl/overig/netcat_openbsd/patches/0007-udp-scan-timeout.patch
Last change on this file was c5c522c, checked in by , 8 years ago | |
---|---|
|
|
File size: 1.3 KB |
-
netcat.c
From: Aron Xu <aron@debian.org> Date: Mon, 13 Feb 2012 15:29:37 +0800 Subject: udp scan timeout --- netcat.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/netcat.c b/netcat.c index 29ecf1a..baab909 100644
a b 111 111 #define CONNECTION_FAILED 1 112 112 #define CONNECTION_TIMEOUT 2 113 113 114 #define UDP_SCAN_TIMEOUT 3 /* Seconds */ 115 114 116 /* Command Line Options */ 115 117 int Cflag = 0; /* CRLF line-ending */ 116 118 int dflag; /* detached, no stdin */ … … main(int argc, char *argv[]) 497 499 continue; 498 500 499 501 ret = 0; 500 if (vflag || zflag) {502 if (vflag) { 501 503 /* For UDP, make sure we are connected. */ 502 504 if (uflag) { 503 505 if (udptest(s) == -1) { … … build_ports(char *p) 1057 1059 int 1058 1060 udptest(int s) 1059 1061 { 1060 int i, ret; 1061 1062 for (i = 0; i <= 3; i++) { 1063 if (write(s, "X", 1) == 1) 1064 ret = 1; 1065 else 1066 ret = -1; 1062 int i, t; 1063 1064 if ((write(s, "X", 1) != 1) || 1065 ((write(s, "X", 1) != 1) && (errno == ECONNREFUSED))) 1066 return -1; 1067 1068 /* Give the remote host some time to reply. */ 1069 for (i = 0, t = (timeout == -1) ? UDP_SCAN_TIMEOUT : (timeout / 1000); 1070 i < t; i++) { 1071 sleep(1); 1072 if ((write(s, "X", 1) != 1) && (errno == ECONNREFUSED)) 1073 return -1; 1067 1074 } 1068 return (ret);1075 return 1; 1069 1076 } 1070 1077 1071 1078 void
Note: See TracBrowser
for help on using the repository browser.