home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / nmap254b.zip / targets.h < prev    next >
C/C++ Source or Header  |  2001-08-10  |  7KB  |  165 lines

  1. /***********************************************************************/
  2. /* targets.h -- Functions relating to "ping scanning" as well as       */
  3. /* determining the exact IPs to hit based on CIDR and other input      */
  4. /* formats.                                                            */
  5. /*                                                                     */
  6. /***********************************************************************/
  7. /*  The Nmap Security Scanner is (C) 1995-2001 Insecure.Com LLC. This  */
  8. /*  program is free software; you can redistribute it and/or modify    */
  9. /*  it under the terms of the GNU General Public License as published  */
  10. /*  by the Free Software Foundation; Version 2.  This guarantees your  */
  11. /*  right to use, modify, and redistribute this software under certain */
  12. /*  conditions.  If this license is unacceptable to you, we may be     */
  13. /*  willing to sell alternative licenses (contact sales@insecure.com). */
  14. /*                                                                     */
  15. /*  If you received these files with a written license agreement       */
  16. /*  stating terms other than the (GPL) terms above, then that          */
  17. /*  alternative license agreement takes precendence over this comment. */
  18. /*                                                                     */
  19. /*  Source is provided to this software because we believe users have  */
  20. /*  a right to know exactly what a program is going to do before they  */
  21. /*  run it.  This also allows you to audit the software for security   */
  22. /*  holes (none have been found so far).                               */
  23. /*                                                                     */
  24. /*  Source code also allows you to port Nmap to new platforms, fix     */
  25. /*  bugs, and add new features.  You are highly encouraged to send     */
  26. /*  your changes to fyodor@insecure.org for possible incorporation     */
  27. /*  into the main distribution.  By sending these changes to Fyodor or */
  28. /*  one the insecure.org development mailing lists, it is assumed that */
  29. /*  you are offering Fyodor the unlimited, non-exclusive right to      */
  30. /*  reuse, modify, and relicense the code.  This is important because  */
  31. /*  the inability to relicense code has caused devastating problems    */
  32. /*  for other Free Software projects (such as KDE and NASM).  Nmap     */
  33. /*  will always be available Open Source.  If you wish to specify      */
  34. /*  special license conditions of your contributions, just say so      */
  35. /*  when you send them.                                                */
  36. /*                                                                     */
  37. /*  This program is distributed in the hope that it will be useful,    */
  38. /*  but WITHOUT ANY WARRANTY; without even the implied warranty of     */
  39. /*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  */
  40. /*  General Public License for more details (                          */
  41. /*  http://www.gnu.org/copyleft/gpl.html ).                            */
  42. /*                                                                     */
  43. /***********************************************************************/
  44.  
  45. /* $Id: targets.h,v 1.12 2001/08/10 05:53:08 fyodor Exp $ */
  46.  
  47. #ifndef TARGETS_H
  48. #define TARGETS_H
  49.  
  50. #ifdef HAVE_CONFIG_H
  51. #include "config.h"
  52. #else
  53. #ifdef WIN32
  54. #include "nmap_winconfig.h"
  55. #endif /* WIN32 */
  56. #endif /* HAVE_CONFIG_H */
  57.  
  58. /* This contains pretty much everythign we need ... */
  59. #if HAVE_SYS_TIME_H
  60. #include <sys/time.h>
  61. #endif
  62.  
  63. #if HAVE_UNISTD_H
  64. #include <unistd.h>
  65. #endif
  66.  
  67. #ifdef HAVE_SYS_PARAM_H   
  68. #include <sys/param.h> /* Defines MAXHOSTNAMELEN on BSD*/
  69. #endif
  70.  
  71. #include "nmap.h"
  72. #include "global_structures.h"
  73.  
  74. /**************************STRUCTURES******************************/
  75. struct pingtune {
  76.   int up_this_block;
  77.   int down_this_block;
  78.   int block_tries;
  79.   int block_unaccounted;
  80.   int max_tries;
  81.   int num_responses;
  82.   int dropthistry;
  83.   int group_size;
  84.   int group_start;
  85.   int group_end;
  86.   int discardtimesbefore;
  87. };
  88.  
  89. struct tcpqueryinfo {
  90.   int *sockets;
  91.   int maxsd;
  92.   fd_set fds_r;
  93.   fd_set fds_w;
  94.   fd_set fds_x;
  95.   int sockets_out;
  96. };
  97.  
  98. struct pingtech {
  99.   int icmpscan: 1,
  100.     rawicmpscan: 1,
  101.     connecttcpscan: 1,
  102.     rawtcpscan: 1;
  103. };
  104.  
  105.  
  106. int get_ping_results(int sd, pcap_t *pd, struct hoststruct *hostbatch, struct timeval *time,  struct pingtune *pt, struct timeout_info *to, int id, struct pingtech *ptech, struct scan_lists *ports);
  107. int hostupdate(struct hoststruct *hostbatch, struct hoststruct *target, 
  108.            int newstate, int dotimeout, int trynum, 
  109.            struct timeout_info *to, struct timeval *sent, 
  110.            struct pingtune *pt, struct tcpqueryinfo *tqi, int pingtype);
  111. int sendpingquery(int sd, int rawsd, struct hoststruct *target,  
  112.           int seq, unsigned short id, struct scanstats *ss, 
  113.           struct timeval *time, struct pingtech ptech);
  114. int sendrawtcppingquery(int rawsd, struct hoststruct *target, int seq,
  115.             struct timeval *time, struct pingtune *pt);
  116. int sendconnecttcpquery(struct hoststruct *hostbatch, struct tcpqueryinfo *tqi, struct hoststruct *target, 
  117.             int seq, struct timeval *time, struct pingtune *pt, struct timeout_info *to, int max_width);
  118. int get_connecttcpscan_results(struct tcpqueryinfo *tqi, 
  119.                    struct hoststruct *hostbatch, 
  120.                    struct timeval *time, struct pingtune *pt, 
  121.                    struct timeout_info *to);
  122. char *readhoststate(int state);
  123. void massping(struct hoststruct *hostbatch, int numhosts, 
  124.         struct scan_lists *ports);
  125. /* Fills up the hostgroup_state structure passed in (which must point
  126.    to valid memory).  Lookahead is the number of hosts that can be
  127.    checked (such as ping scanned) in advance.  Randomize causes each
  128.    group of up to lookahead hosts to be internally shuffled around.
  129.    The target_expressions array must remail valid in memory as long as
  130.    this hostgroup_state structure is used -- the array is NOT copied */
  131. int hostgroup_state_init(struct hostgroup_state *hs, int lookahead,
  132.              int randomize, char *target_expressions[],
  133.              int num_expressions);
  134. /* Free the *internal state* of a hostgroup_state structure -- it is
  135.    important to note that this does not free the actual memory
  136.    allocated for the "struct hostgroup_state" you pass in.  It only
  137.    frees internal stuff -- after all, your hostgroup_state could be on
  138.    the stack */
  139. void hostgroup_state_destroy(struct hostgroup_state *hs);
  140. /* If there is at least one IP address left in t, one is pulled out and placed
  141.    in sin and then zero is returned and state information in t is updated
  142.    to reflect that the IP was pulled out.  If t is empty, -1 is returned */
  143. int target_struct_get(struct targets *t, struct in_addr *sin);
  144. /* Undoes the previous target_struct_get operation */
  145. void target_struct_return(struct targets *t);
  146. void hoststructfry(struct hoststruct *hostbatch, int nelem);
  147. /* Ports is the list of ports the user asked to be scanned (0 terminated),
  148.    you can just pass NULL (it is only a stupid optimization that needs it) */
  149. struct hoststruct *nexthost(struct hostgroup_state *hs, struct scan_lists *ports);
  150. /* Frees the *INTERNAL STRUCTURES* inside a hoststruct -- does not
  151.    free the actual memory allocated to the hoststruct itself (for all
  152.    this function knows, you could have declared it on the stack */
  153. void hoststruct_free(struct hoststruct *currenths);
  154. #endif /* TARGETS_H */
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.