"Fossies" - the Fresh Open Source Software Archive

Member "scanssh-2.1/scanssh.h" (21 Nov 2004, 4458 Bytes) of package /linux/privat/old/scanssh-2.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "scanssh.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright 2000 Niels Provos <provos@citi.umich.edu>
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  * 3. The name of the author may not be used to endorse or promote products
   14  *    derived from this software without specific prior written permission.
   15  *
   16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   21  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   26  */
   27 
   28 #ifndef _SCANSSH_H_
   29 #define _SCANSSH_H_
   30 
   31 #define SSHMAPVERSION   "SSH-1.0-SSH_Version_Mapper\n"
   32 #define SSHUSERAGENT    "ScanSSH/2.0"
   33 #define MAXITER     10
   34 #define LONGWAIT    50
   35 #define SHORTWAIT   30
   36 #define CONNECTWAIT 20
   37 #define SYNWAIT     1
   38 #define SYNRETRIES  7
   39 #define MAXBUF      2048
   40 #define MAXSYNQUEUESZ   4096
   41 #define MAXSCANQUEUESZ  100
   42 #define MAXBURST    256
   43 #define SEEDLEN     4
   44 #define EXPANDEDARGS    32000   /* number of expanded addresses */
   45 #define MAXSLOTS    8   /* number of slots addrs are alloced from */
   46 
   47 #define FLAGS_USERANDOM     0x01
   48 #define FLAGS_SUBTRACTEXCLUDE   0x02
   49 
   50 struct socks_host {
   51     TAILQ_ENTRY(socks_host) next;
   52     struct addr host;
   53     uint16_t port;
   54 };
   55 
   56 TAILQ_HEAD(socksq, socks_host);
   57 
   58 struct argument;
   59 
   60 struct address_slot {
   61     struct argument *slot_base;
   62     uint32_t slot_size;
   63     uint32_t slot_ref;
   64 };
   65 
   66 struct argument;
   67 
   68 struct port_scan {
   69     struct argument *arg;
   70     uint16_t port;
   71     uint8_t count;
   72     uint8_t flags;
   73     
   74     struct event ev;
   75 };
   76 
   77 #define PORT_CHECKED    0x0001
   78 
   79 /* Bloated port structure */
   80 
   81 struct port {
   82     uint16_t port;
   83     struct port_scan *scan;
   84 };
   85 
   86 struct argument {
   87     SPLAY_ENTRY (argument) a_node;
   88     TAILQ_ENTRY (argument) a_next;
   89 
   90     uint16_t a_retry;       /* what a waste of memory */
   91 
   92     struct port *a_ports;       /* list of ports to scan */
   93     uint16_t a_nports;      /* number of ports left to scan */
   94     uint16_t a_hasports;
   95 
   96     uint32_t a_seqnr;
   97 
   98     struct addr addr;
   99     int a_fd;
  100 
  101     uint16_t a_flags;       /* state that scanners can use */
  102     void *a_state;          /* opaque state for scanners */
  103 
  104     struct scanner *a_scanner;  /* which scanner to use */
  105     int a_scanneroff;       /* offset into scan structure */
  106 
  107     struct address_slot *a_slot;
  108 
  109     char *a_res;            /* last posted result */
  110 
  111     struct event ev;
  112 };
  113 
  114 TAILQ_HEAD (queue_list, argument);
  115 
  116 struct scanner {
  117     char *name;
  118     char *description;
  119     void (*init)(struct bufferevent *, struct argument *);
  120     void (*finalize)(struct bufferevent *, struct argument *);
  121     evbuffercb readcb;
  122     evbuffercb writecb;
  123     everrorcb  errorcb;
  124 };
  125 
  126 int synprobe_send(struct addr *, struct addr *, uint16_t, uint32_t *);
  127 
  128 ssize_t atomicio(ssize_t (*)(), int, void *, size_t);
  129 int ipv4toa(char *, size_t, void *);
  130 void waitforcommands(int, int);
  131 
  132 void argument_free(struct argument *);
  133 void postres(struct argument *, const char *fmt, ...);
  134 void printres(struct argument *, uint16_t, char *);
  135 
  136 int probe_haswork(void);
  137 
  138 int ports_parse(char *, struct port **, int *);
  139 int ports_setup(struct argument *, struct port *, int);
  140 int ports_remove(struct argument *, uint16_t);
  141 struct port *ports_find(struct argument *, uint16_t);
  142 int ports_isalive(struct argument *);
  143 void ports_markchecked(struct argument *, struct port *);
  144 
  145 void scanhost_ready(struct argument *);
  146 
  147 void scanhost_return(struct bufferevent *bev, struct argument *, int success);
  148 void scanhost_fromlist(void);
  149 
  150 int scanner_parse(char *);
  151 struct scanner *scanner_find(char *);
  152 void scanner_print(char *);
  153 
  154 void http_makerequest(struct bufferevent *, struct argument *, const char *,
  155     int);
  156 
  157 #endif /* _SCANSSH_H_ */