147{
148 char buf[2048], kb[64];
149 int s, tcpproto, pass;
150 struct protoent *proto;
151 fd_set rfs, wfs, efs;
153 struct sockaddr_in sa;
154 struct sockaddr_in6 sa6;
156 int retval;
157 int port = 23;
158 int imax, i, j, scanned_ports, x, opt;
159 unsigned int optsz;
160 int minport;
161 unsigned char ports_states[65536];
163 int open_sock_nb, open_sock_max, open_sock_max2;
164 int unfiltered_ports_nb, filtered_ports_nb;
165 int dropped_nb, timeout_nb, dropped_flag = 0;
166 int old_filtered = -1, old_opened = -1;
167 int open_ports_nb, closed_ports_nb;
168 int untested_ports_nb, total_ports_nb;
169 int cnx_max[3], rtt_max[3], rtt_min[3], ping_rtt = 0;
170#if defined COMPUTE_RTT
171 double rtt_sum[3], rtt_sum2[3];
172 int rtt_nb[3];
173 static const char *rtt_type[] = {"unfiltered", "open", "closed"};
174#endif
175 time_t start_time = time (NULL), start_time_1pass, end_time;
176 long diff_time, diff_time1;
177 int rst_rate_limit_flag = 0, doublecheck_flag = 0;
178#if defined COMPUTE_RTT
179 double mean, sd = -1.0, emax = -1.0;
180#endif
181
182 proto = getprotobyname ("tcp");
183 if (proto == NULL)
184 {
185 perror ("tcp");
186 return -1;
187 }
188 tcpproto = proto->p_proto;
189
190 for (i = 0; i < (int) (sizeof (ports_states) / sizeof (*ports_states)); i++)
192 scanned_ports = 0;
193 for (i = 0; i < 3; i++)
194 {
195#if defined COMPUTE_RTT
196 rtt_sum[i] = rtt_sum2[i] = 0.0;
197 rtt_nb[i] = 0;
198#endif
199 rtt_max[i] = cnx_max[i] = 0;
201 }
202
203 {
204 char *k;
205 int type = 0;
206 k =
plug_get_key (desc,
"/tmp/ping/RTT", &type, NULL, 0);
208 ping_rtt = atoi (k);
210 ping_rtt = GPOINTER_TO_SIZE (k);
211 else if (type >= 0)
212 g_message ("openvas_tcp_scanner: unknown key type %d", type);
213 g_free (k);
215 ping_rtt = 0;
216 }
217
218 {
219 char *p, *q;
220 int po1, po2 = 0;
221 p = (char *) portrange;
222 untested_ports_nb = 0;
223
224 if (p)
225 while (*p != '\0')
226 {
227 while (*p == ',')
228 p++;
229
230
231
232 if (*p == 'T' && p[1] && p[1] == ':')
233
234 p += 2;
235 else if (*p == 'U' && p[1] && p[1] == ':')
236
237 break;
238
239 if (*p == '-')
240 {
241 po1 = 1;
242 q = p + 1;
243 po2 = strtol (q, &p, 10);
244 if (q == p)
245 {
246 g_message ("openvas_tcp_scanner: Cannot parse '%s'", p);
247 return -1;
248 }
249 }
250 else
251 {
252 po1 = strtol (p, &q, 10);
253 if (q == p)
254 {
255 g_message ("openvas_tcp_scanner: Cannot parse '%s'", p);
256 return -1;
257 }
258 if (*q == ',')
259 {
260 p = q + 1;
261 po2 = po1;
262 }
263 else if (*q == '\0')
264 {
265 p = q;
266 po2 = po1;
267 }
268 else if (*q == '-')
269 {
270 if (q[1] == '\0')
271 {
272 po2 = 65535;
273 p = q + 1;
274 }
275 else
276 {
277 po2 = strtol (q + 1, &p, 10);
278 if (q + 1 == p)
279 {
280 g_message ("openvas_tcp_scanner: Cannot parse '%s'",
281 p);
282 return -1;
283 }
284 }
285 }
286
287 if (po1 > 65535)
288 {
289 g_message ("%s: Wrong port '%d'. It will be skipped.", __func__, po1);
290 continue;
291 }
292 if (po2 > 65535)
293 {
294 g_message ("%s: Wrong port '%d'. It will be skipped.", __func__, po2);
295 continue;
296 }
297 }
298 for (i = po1; i <= po2; i++)
299 {
301 untested_ports_nb++;
302 }
303 }
304 else
305 {
306 g_message ("openvas_tcp_scanner: port list empty");
307 return -1;
308 }
309 }
310
311 for (i = 0; i < max_cnx; i++)
312 {
315 }
316
317 open_sock_nb = 0;
318 open_sock_max = min_cnx;
319 open_sock_max2 = max_cnx;
320
321 open_ports_nb = closed_ports_nb = filtered_ports_nb = unfiltered_ports_nb = 0;
322
324 {
325 int open_ports_nb1 = 0, closed_ports_nb1 = 0;
326 int wait_sock_nb = 0;
327
328 minport = 1;
329 start_time_1pass = time (NULL);
330 FD_ZERO (&rfs);
331 FD_ZERO (&wfs);
332 imax = -1;
333
334 while (scanned_ports < 65535)
335 {
336 total_ports_nb =
337 unfiltered_ports_nb + filtered_ports_nb + untested_ports_nb;
338 while (open_sock_nb < open_sock_max)
339 {
340 for (port = minport;
342 port++)
343 ;
344 if (port > 65535)
345 break;
346 minport = port;
347
349 if (IN6_IS_ADDR_V4MAPPED (pia))
350 {
351 s = socket (PF_INET, SOCK_STREAM, tcpproto);
352 }
353 else
354 {
355 s = socket (PF_INET6, SOCK_STREAM, tcpproto);
356 }
357 if (s < 0)
358 {
359 if (errno == ENFILE)
360 {
361 open_sock_max = open_sock_max2 = open_sock_nb / 2 - 1;
362
363
364
365 continue;
366 }
367 else if (errno == EMFILE)
368 {
369 x = open_sock_nb / 16;
370 open_sock_max = open_sock_max2 =
371 open_sock_nb - (x > 0 ? x : 1);
372
373
374
375 continue;
376 }
377 else
378 {
379 perror ("socket");
380 return -1;
381 }
382 }
383#if defined FD_SETSIZE
384 if (s >= FD_SETSIZE)
385 {
386 open_sock_max--;
387 open_sock_max2--;
388 if (close (s) < 0)
389 perror ("close");
390 continue;
391 }
392#endif
393
394 if ((x = fcntl (s, F_GETFL)) < 0)
395 {
396 perror ("fcntl(F_GETFL)");
397 close (s);
398 return -1;
399 }
400 if (fcntl (s, F_SETFL, x | O_NONBLOCK) < 0)
401 {
402 perror ("fcntl(F_SETFL)");
403 close (s);
404 return -1;
405 }
406
407#ifdef SO_LINGER
408 {
409 struct linger l;
410
411 l.l_onoff = 0;
412 l.l_linger = 0;
413 if (setsockopt (s, SOL_SOCKET, SO_LINGER, &l, sizeof (l)) < 0)
414 perror ("setsockopt(SO_LINGER)");
415 }
416#endif
417#if defined LINUX && defined IPTOS_RELIABILITY
418
419
420
421
422
423 x = IPTOS_RELIABILITY;
424 if (setsockopt (s, SOL_IP, IP_TOS, &x, sizeof (x)) < 0)
425 perror ("setsockopt(IP_TOS");
426#endif
427 bzero (&sa, sizeof (sa));
428 bzero (&sa6, sizeof (sa6));
429 if (IN6_IS_ADDR_V4MAPPED (pia))
430 {
431 sa.sin_addr.s_addr = pia->s6_addr32[3];
432 sa.sin_family = AF_INET;
433 sa.sin_port = htons (port);
434 len =
sizeof (
struct sockaddr_in);
435 retval = connect (s, (
struct sockaddr *) &sa,
len);
436 }
437 else
438 {
439 memcpy (&sa6.sin6_addr, pia, sizeof (struct in6_addr));
440 sa6.sin6_family = AF_INET6;
441 sa6.sin6_port = htons (port);
442 len =
sizeof (
struct sockaddr_in6);
443 retval = connect (s, (
struct sockaddr *) &sa6,
len);
444 }
445 if (retval < 0)
446 {
447 switch (errno)
448 {
449 case EINPROGRESS:
450 case EALREADY:
451 sockets[open_sock_nb].
fd = s;
452 sockets[open_sock_nb].
port = port;
454 (void) gettimeofday (&sockets[open_sock_nb].tictac, NULL);
455 open_sock_nb++;
456 FD_SET (s, &wfs);
457 if (s > imax)
458 imax = s;
459 break;
460
461 case EAGAIN:
462 x = open_sock_nb / 16;
463 open_sock_max = open_sock_max2 =
464 open_sock_nb - (x > 0 ? x : 1);
465
466 continue;
467
468 case ECONNREFUSED:
471 unfiltered_ports_nb++;
472 closed_ports_nb++;
473 closed_ports_nb1++;
474 untested_ports_nb--;
475 continue;
476
477 case ENETUNREACH:
478 case EHOSTUNREACH:
481 filtered_ports_nb++;
482 untested_ports_nb--;
483 continue;
484
485 default:
486 perror ("connect");
487 return -1;
488 }
489 }
490 else
491 {
492 sockets[open_sock_nb].
fd = s;
493 sockets[open_sock_nb].
port = port;
495 (void) gettimeofday (&sockets[open_sock_nb].tictac, NULL);
496 open_sock_nb++;
498 unfiltered_ports_nb++;
499 open_ports_nb++;
500 open_ports_nb1++;
501 wait_sock_nb++;
502 untested_ports_nb--;
504 }
505 if (imax >= 0)
506 {
507 timeout.tv_sec = timeout.tv_usec = 0;
508 if (select (imax + 1, NULL, &wfs, NULL, &timeout) > 0)
509 break;
510 }
511 }
512
513 if (open_sock_max2 <= 0)
514 return -1;
515
516 if (open_sock_nb == 0)
517 goto end;
518
519 FD_ZERO (&rfs);
520 FD_ZERO (&wfs);
521 FD_ZERO (&efs);
522 imax = -1;
523
524 for (i = 0; i < open_sock_nb; i++)
525 {
526 if (sockets[i].fd >= 0)
527 {
528 switch (sockets[i].state)
529 {
531 FD_SET (sockets[i].fd, &rfs);
532 break;
534 FD_SET (sockets[i].fd, &wfs);
535 break;
536 default:
537 break;
538 }
539 if (sockets[i].fd > imax)
540 imax = sockets[i].
fd;
541 }
542 }
543
544 if (imax < 0)
545 {
546 if (untested_ports_nb > 0)
547 return -1;
548 else
549 goto end;
550 }
551
552 timeout_nb = 0;
553 dropped_nb = 0;
554 dropped_flag = 0;
555#if defined COMPUTE_RTT
556 if (rtt_nb[0] > 1)
557 {
558
559 int em, moy;
560
561 mean = rtt_sum[0] / (double) rtt_nb[0];
562 if ((double) rtt_max[0] > mean)
563 {
564 sd = sqrt ((rtt_sum2[0] / rtt_nb[0] - mean * mean)
565 * (double) rtt_nb[0] / (rtt_nb[0] - 1));
566 emax = mean + 3 * sd;
567 em = floor (emax + 0.5);
568 moy = floor (rtt_sum[0] / rtt_nb[0] + 0.5);
569 if (em <= moy)
570 em = moy;
571 if (rtt_max[0] > em)
572 rtt_max[0] = em;
573 }
574 if (rtt_max[0] < rtt_min[0])
575 rtt_max[0] = rtt_min[0];
576 }
577#endif
578
579
580
581
582
583 if (wait_sock_nb == 0)
584 if (rtt_max[0] > 0 || ping_rtt > 0)
585 {
586 if (rtt_max[0] > 0)
587 x = rtt_max[0];
588 else
589 x = ping_rtt;
590
591 if (doublecheck_flag)
592 {
593 x = 3 * x + 20000;
596 }
597 if (x > 1000000)
598 x += (unsigned) (lrand48 () & 0x7FFFFFFF) % 100000;
599 else if (x > 20000)
600 x += (unsigned) (lrand48 () & 0x7FFFFFFF) % 50000;
601 else
602 x = 20000 + (unsigned) (lrand48 () & 0x7FFFFFFF) % 20000;
603 timeout.tv_sec = x / 1000000;
604 timeout.tv_usec = x % 1000000;
605 }
606 else
607 {
608
609 timeout.tv_sec = 2;
610 timeout.tv_usec = (unsigned) (lrand48 () & 0x7FFFFFFF) % 250000;
611 }
612 else
613 {
614 timeout.tv_sec = read_timeout;
615 timeout.tv_usec = (unsigned) (lrand48 () & 0x7FFFFFFF) % 500000;
616 }
617 i = 0;
618 do
619 x = select (imax + 1, &rfs, &wfs, NULL, &timeout);
620 while (i++ < 10 && x < 0 && errno == EINTR);
621
622 if (x < 0)
623 {
624 perror ("select");
625 return -1;
626 }
627 else if (x == 0)
628 {
629 for (i = 0; i < open_sock_nb; i++)
630 {
631 if (sockets[i].fd > 0)
632 {
635 switch (sockets[i].state)
636 {
639 filtered_ports_nb++;
640 dropped_nb++;
641 untested_ports_nb--;
642 break;
644 wait_sock_nb--;
645 break;
646 }
647 }
649 }
650 }
651 else
652 {
653 (void) gettimeofday (&ti, NULL);
654 for (i = 0; i < open_sock_nb; i++)
655 {
656 if (sockets[i].fd > 0)
657 {
658 if (FD_ISSET (sockets[i].fd, &wfs))
659 {
660 opt = 0;
661 optsz = sizeof (opt);
662 if (getsockopt (sockets[i].fd, SOL_SOCKET, SO_ERROR,
663 &opt, &optsz)
664 < 0)
665 {
666 perror ("getsockopt");
667 return -1;
668 }
669
670 x =
DIFFTVu (ti, sockets[i].tictac);
671 if (opt != 0)
672 {
673 errno = opt;
674 if (x > cnx_max[2])
675 cnx_max[2] = x;
676 if (x < rtt_min[2])
677 rtt_min[2] = x;
679 {
680 if (x > rtt_max[2])
681 rtt_max[2] = x;
682#if defined COMPUTE_RTT
683 rtt_nb[2]++;
684 rtt_sum[2] += (double) x;
685 rtt_sum2[2] += (double) x * (double) x;
686#endif
687 }
688
692
693 untested_ports_nb--;
694 switch (opt)
695 {
696 case ENETUNREACH:
697 case EHOSTUNREACH:
698 ports_states[sockets[i].
port] =
700 filtered_ports_nb++;
701 break;
702
703 case ECONNREFUSED:
704 default:
705 ports_states[sockets[i].port] =
707 unfiltered_ports_nb++;
708 closed_ports_nb++;
709 closed_ports_nb1++;
710 break;
711 }
712 }
713 else
714 {
716 if (x > cnx_max[1])
717 cnx_max[1] = x;
718 if (x < rtt_min[1])
719 rtt_min[1] = x;
721 {
722 if (x > rtt_max[1])
723 rtt_max[1] = x;
724#if defined COMPUTE_RTT
725 rtt_nb[1]++;
726 rtt_sum[1] += (double) x;
727 rtt_sum2[1] += (double) x * (double) x;
728#endif
729 }
730
731 unfiltered_ports_nb++;
732 open_ports_nb++;
733 open_ports_nb1++;
734 untested_ports_nb--;
737 wait_sock_nb++;
738 snprintf (kb, sizeof (kb),
739 "TCPScanner/CnxTime1000/%u",
740 sockets[i].port);
742 GSIZE_TO_POINTER (x / 1000));
743 snprintf (kb, sizeof (kb),
744 "TCPScanner/CnxTime/%u",
745 sockets[i].port);
748 GSIZE_TO_POINTER ((x + 500000) / 1000000));
749 sockets[i].tictac = ti;
750 }
751 if (x > cnx_max[0])
752 cnx_max[0] = x;
753 if (x < rtt_min[0])
754 rtt_min[0] = x;
756 {
757 if (x > rtt_max[0])
758 rtt_max[0] = x;
759#if defined COMPUTE_RTT
760 rtt_nb[0]++;
761 rtt_sum[0] += (double) x;
762 rtt_sum2[0] += (double) x * (double) x;
763#endif
764 }
765 }
766 else if (FD_ISSET (sockets[i].fd, &rfs))
767 {
768 x = read (sockets[i].fd, buf, sizeof (buf) - 1);
769 if (x > 0)
770 {
771 char buf2[sizeof (buf) * 2 + 1];
772 int y, flag = 0;
773
774 for (y = 0; y < x; y++)
775 {
776 sprintf (buf2 + 2 * y, "%02x",
777 (unsigned char) buf[y]);
778 if (buf[y] == '\0')
779 flag = 1;
780 }
781 buf2[2 * x - 1] = '\0';
782 if (flag)
783 {
784 snprintf (kb, sizeof (kb), "BannerHex/%u",
785 sockets[i].port);
787 }
788
789 buf[x] = '\0';
790 snprintf (kb, sizeof (kb), "Banner/%u",
791 sockets[i].port);
793 x =
DIFFTVu (ti, sockets[i].tictac) / 1000;
794 snprintf (kb, sizeof (kb),
795 "TCPScanner/RwTime1000/%u",
796 sockets[i].port);
798 GSIZE_TO_POINTER (x));
799 snprintf (kb, sizeof (kb), "TCPScanner/RwTime/%u",
800 sockets[i].port);
803 GSIZE_TO_POINTER ((x + 500) / 1000));
804 }
805 wait_sock_nb--;
807 sockets[i].fd = -1;
809 }
810 }
811 }
812 }
813
814 (void) gettimeofday (&ti, NULL);
815 for (i = 0; i < open_sock_nb; i++)
816 if (sockets[i].fd >= 0
817 &&
DIFFTV (ti, sockets[i].tictac) >= read_timeout)
818 {
819 switch (sockets[i].state)
820 {
822 timeout_nb++;
823 wait_sock_nb--;
824 snprintf (kb, sizeof (kb), "/tmp/NoBanner/%u",
825 sockets[i].port);
827 break;
830 filtered_ports_nb++;
831 dropped_nb++;
832 untested_ports_nb--;
833 break;
834 default:
835 g_message (
836 "openvas_tcp_scanner: Unhandled case %d at %s:%d",
837 sockets[i].state, __FILE__, __LINE__);
838 break;
839 }
841 sockets[i].fd = -1;
843 }
844
845 if (dropped_nb > 0 && dropped_nb >= (open_sock_nb * 3) / 4
846 && (dropped_nb < filtered_ports_nb
847 || dropped_nb > unfiltered_ports_nb))
848 {
849
850 open_sock_max += dropped_nb;
851 if (open_sock_max2 < max_cnx)
852 open_sock_max2++;
853 }
854 else if (dropped_nb > 0)
855 {
856 dropped_flag = 1;
857 open_sock_max -= (dropped_nb + 2) / 3;
858 if (open_sock_max < min_cnx)
859 open_sock_max = min_cnx;
860 open_sock_max2 = (open_sock_max + 3 * open_sock_max2) / 4;
861 }
862 else if (dropped_nb == 0 && dropped_flag)
863 {
864
865 open_sock_max++;
866 }
867 open_sock_max += timeout_nb;
868 if (open_sock_max > open_sock_max2)
869 {
870 open_sock_max = open_sock_max2;
871 }
872 if (open_sock_max < min_cnx)
873 open_sock_max = min_cnx;
874 for (i = 0; i < open_sock_nb;)
876 {
877 for (j = i + 1; j < open_sock_nb
879 || sockets[j].fd < 0);
880 j++)
881 ;
882 if (j < open_sock_nb)
883 memmove (sockets + i, sockets + j,
884 sizeof (*sockets) * (max_cnx - j));
885 open_sock_nb -= j - i;
886 }
887 else
888 i++;
889 }
890
891 end:
892 end_time = time (NULL);
893 diff_time1 = end_time - start_time_1pass;
894 diff_time = end_time - start_time;
895 if (dropped_flag
896 || (pass == 1 && filtered_ports_nb > 10 && closed_ports_nb > 10)
897 || (pass > 1 && filtered_ports_nb > 0))
898 {
899 if (doublecheck_flag && rst_rate_limit_flag
900 && open_ports_nb == old_opened)
901 break;
902 old_opened = open_ports_nb;
903
904 doublecheck_flag = 0;
905 if (filtered_ports_nb == old_filtered)
906 break;
907
908 if (pass > 1 && open_ports_nb1 == 0 && closed_ports_nb1 >= min_cnx &&
909
910
911
912
913
914 closed_ports_nb1 >= (diff_time1 + 1) * 10
915 && closed_ports_nb1 < (diff_time1 + 1) * 201 &&
916
917 closed_ports_nb >= (diff_time + 1) * 10
918 && closed_ports_nb < (diff_time + 1) * 201)
919 {
920
921 int break_flag =
923 int tbd = break_flag && !doublecheck_flag
925 : 0;
926 if (tbd > 0)
927 {
928 doublecheck_flag = 1;
929 break_flag = 0;
930 }
931 rst_rate_limit_flag++;
932 if (break_flag)
933 break;
934 }
935
936
937
938
939 old_filtered = 0;
940 for (port = 1; port <= 65535; port++)
942 {
944 old_filtered++;
945 }
946 untested_ports_nb = old_filtered;
947 filtered_ports_nb = 0;
948 open_sock_max = min_cnx / (pass + 1);
949 if (open_sock_max < 1)
950 open_sock_max = 1;
951 if (!dropped_flag)
952 {
953 open_sock_max2 *= 2;
954 open_sock_max2 /= 3;
955 }
956 else if (rst_rate_limit_flag)
957 {
962 }
963 else if (open_sock_max2 <= open_sock_max)
964 open_sock_max2 = open_sock_max * 2;
965 }
966 else if (filtered_ports_nb > 0)
967 {
968 int tbd_nb = 0;
969 doublecheck_flag = 1;
970
971
973 break;
974 old_filtered = untested_ports_nb = tbd_nb;
975 filtered_ports_nb = 0;
976 open_sock_max = min_cnx / pass;
977 if (open_sock_max2 <= open_sock_max)
978 open_sock_max2 = open_sock_max * 2;
983 }
984 else
985 break;
986 }
987
989 {
990 pass--;
991 filtered_ports_nb = old_filtered;
992 }
993
995
996#if defined COMPUTE_RTT
997 for (i = 0; i < 3; i++)
998 if (rtt_nb[i] > 0)
999 {
1000 char rep[64];
1001 double crtt_mean, crtt_sd = -1.0, crtt_emax = -1.0;
1002
1003
1004 rtt_sum[i] /= 1e6;
1005 rtt_sum2[i] /= 1e12;
1006
1007 crtt_mean = rtt_sum[i] / rtt_nb[i];
1008 snprintf (rep, sizeof (rep), "%6g", crtt_mean);
1009 snprintf (kb, sizeof (kb), "TCPScanner/%s/MeanRTT", rtt_type[i]);
1011 x = floor (crtt_mean * 1000 + 0.5);
1012 snprintf (kb, sizeof (kb), "TCPScanner/%s/MeanRTT1000", rtt_type[i]);
1014
1015 snprintf (kb, sizeof (kb), "TCPScanner/%s/MaxRTT1000", rtt_type[i]);
1017 GSIZE_TO_POINTER ((rtt_max[i] + 500) / 1000));
1018 snprintf (rep, sizeof (rep), "%6g",
1019 (rtt_max[i] + 500000.0) / 1000000.0);
1020 snprintf (kb, sizeof (kb), "TCPScanner/%s/MaxRTT", rtt_type[i]);
1022 if (rtt_nb[i] > 1)
1023 {
1024 crtt_sd = sqrt ((rtt_sum2[i] / rtt_nb[i] - crtt_mean * crtt_mean)
1025 * rtt_nb[i] / (rtt_nb[i] - 1));
1026 crtt_emax = crtt_mean + 3 * crtt_sd;
1027 snprintf (rep, sizeof (rep), "%6g", crtt_sd);
1028 snprintf (kb, sizeof (kb), "TCPScanner/%s/SDRTT", rtt_type[i]);
1030 x = floor (crtt_sd * 1000 + 0.5);
1031 snprintf (kb, sizeof (kb), "TCPScanner/%s/SDRTT1000", rtt_type[i]);
1033 snprintf (rep, sizeof (rep), "%6g", crtt_emax);
1034 snprintf (kb, sizeof (kb), "TCPScanner/%s/EstimatedMaxRTT",
1035 rtt_type[i]);
1037 x = floor (crtt_emax * 1000 + 0.5);
1038 snprintf (kb, sizeof (kb), "TCPScanner/%s/EstimatedMaxRTT1000",
1039 rtt_type[i]);
1041 }
1042 }
1043#endif
1045 GSIZE_TO_POINTER (open_ports_nb));
1047 GSIZE_TO_POINTER (closed_ports_nb));
1049 GSIZE_TO_POINTER (filtered_ports_nb));
1051 GSIZE_TO_POINTER (rst_rate_limit_flag));
1052 if (untested_ports_nb <= 0)
1055 GSIZE_TO_POINTER ((total_ports_nb - untested_ports_nb)));
1056 return 0;
1057}
#define GRAB_PORT_TESTING
#define GRAB_PORT_UNKNOWN
#define GRAB_MAX_SOCK_SAFE
#define GRAB_PORT_REJECTED
#define GRAB_SOCKET_OPENING
static int my_socket_close(int s)
static int double_check_std_ports(unsigned char *ports_states)
#define GRAB_SOCKET_UNUSED
#define GRAB_PORT_NOT_TESTED
static struct timeval timeval(unsigned long val)
void scanner_add_port(struct script_infos *args, int port, char *proto)
void plug_set_key(struct script_infos *args, char *name, int type, const void *value)
void * plug_get_key(struct script_infos *args, char *name, int *type, size_t *len, int single)
Get values from a kb under the given key name.