home *** CD-ROM | disk | FTP | other *** search
/ Steganos Hacker Tools / SHT151.iso / programme / scanner / nmapNTsp1 / Win_2000.exe / nmapNT-src / portlist.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-08  |  3.1 KB  |  89 lines

  1. #ifndef PORTLIST_H
  2. #define PORTLIST_H
  3.  
  4. /* struct port stuff */
  5. #define PORT_UNKNOWN 0
  6. #define PORT_CLOSED 1
  7. #define PORT_OPEN 2
  8. #define PORT_FIREWALLED 3
  9. #define PORT_TESTING 4
  10. #define PORT_FRESH 5
  11. #define PORT_UNFIREWALLED 6
  12. #define PORT_HIGHEST_STATE 7 /* ***IMPORTANT -- BUMP THIS UP WHEN STATES ARE 
  13.                 ADDED *** */
  14.  
  15. #define CONF_NONE 0
  16. #define CONF_LOW 1
  17. #define CONF_HIGH 2
  18.  
  19.  
  20. struct port {
  21.   unsigned short portno;
  22.   unsigned char proto;
  23.   char *owner;
  24.   char *rpc_name;
  25.   int rpc_status; /* RPC_STATUS_UNTESTED means we haven't checked
  26.             RPC_STATUS_UNKNOWN means the port appears to be RPC
  27.             but we couldn't find a match
  28.             RPC_STATUS_GOOD_PROG means rpc_program gives the prog #
  29.             RPC_STATUS_NOT_RPC means the port doesn't appear to 
  30.             be RPC */
  31.   unsigned long rpc_program; /* Only valid if rpc_state == RPC_STATUS_GOOD_PROG */
  32.   unsigned int rpc_lowver;
  33.   unsigned int rpc_highver;
  34.   int state; 
  35.   int confidence; /* How sure are we about the state? */
  36.  
  37.   struct port *next; /* Internal use only -- we sometimes like to link them
  38.             together */
  39. };
  40.  
  41.  
  42.  
  43. typedef struct portlist {
  44.   struct port **udp_ports;
  45.   struct port **tcp_ports;
  46.   int state_counts[PORT_HIGHEST_STATE]; /* How many ports in list are in each
  47.                        state */
  48.   int state_counts_udp[PORT_HIGHEST_STATE];
  49.   int state_counts_tcp[PORT_HIGHEST_STATE];
  50.   int ignored_port_state; /* The state of the port we ignore for output */
  51.   int numports; /* Total number of ports in list in ANY state */
  52. } portlist;
  53.  
  54. int addport(portlist *plist, unsigned short portno, unsigned short protocol,
  55.         char *owner, int state);
  56. int deleteport(portlist *plist, unsigned short portno,
  57.            unsigned short protocol);
  58.  
  59. /* A function for iterating through the ports.  Give NULL for the
  60.    first "afterthisport".  Then supply the most recent returned port
  61.    for each subsequent call.  When no more matching ports remain, NULL
  62.    will be returned.  To restrict returned ports to just one protocol,
  63.    specify IPPROTO_TCP or IPPROTO_UDP for allowed_protocol.  A 0 for
  64.    allowed_protocol matches either.  allowed_state works in the same
  65.    fashion as allowed_protocol. This function returns ports in numeric
  66.    order from lowest to highest, except that if you ask for both TCP &
  67.    UDP, every TCP port will be returned before we start returning UDP
  68.    ports */
  69. struct port *nextport(portlist *plist, struct port *afterthisport, 
  70.               int allowed_protocol, int allowed_state);
  71.  
  72. struct port *lookupport(portlist *ports, unsigned short portno, 
  73.             unsigned short protocol);
  74. /* Decide which port we want to ignore in output (for example, we don't want
  75.  to show closed ports if there are 40,000 of them.) */
  76. void assignignoredportstate(portlist *plist);
  77.  
  78. /* RECYCLES the port so that it can later be obtained again using 
  79.    make_empty_port */
  80. void free_port(struct port *pt);
  81.  
  82. struct port *make_empty_port();
  83.  
  84. /* Empties out a portlist so that it can be reused (or freed).  All the 
  85.    internal structures that must be freed are done so here. */
  86. void resetportlist(portlist *plist);
  87.  
  88. #endif
  89.