"Fossies" - the Fresh Open Source Software Archive

Member "scanssh-2.1/socks.h" (6 Apr 2004, 3012 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.

    1 /*
    2  * Copyright 2004 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 _SOCKS_H_
   29 #define _SOCKS_H_
   30 
   31 #define SOCKS_VERSION4      0x04
   32 #define SOCKS_VERSION5      0x05
   33 
   34 #define SOCKS_CMD_CONNECT   0x01
   35 
   36 #define SOCKS_ADDR_IPV4     0x01
   37 #define SOCKS_ADDR_NAME     0x03
   38 #define SOCKS_ADDR_IPV6     0x04
   39 
   40 #define SOCKS5_RESP_SUCCESS 0x00
   41 #define SOCKS5_RESP_FAILURE 0x01
   42 #define SOCKS5_RESP_FORBIDDEN   0x02
   43 #define SOCKS5_RESP_NETUNREACH  0x03
   44 #define SOCKS5_RESP_HOSTUNREACH 0x04
   45 #define SOCKS5_RESP_REFUSED 0x05
   46 #define SOCKS5_RESP_TTLEXPIRE   0x06
   47 #define SOCKS5_RESP_NOSUPPORT   0x07
   48 #define SOCKS5_RESP_BADADDRESS  0x08
   49 
   50 #define SOCKS4_RESP_SUCCESS 90
   51 #define SOCKS4_RESP_FAILURE 91
   52 #define SOCKS4_RESP_NOIDENT 92
   53 #define SOCKS4_RESP_BADIDENT    93
   54 
   55 /* Our little state machine */
   56 
   57 #define SOCKS_WAITING_RESPONSE      0x01
   58 #define SOCKS_SENDING_COMMAND       0x02
   59 #define SOCKS_WAITING_COMMANDRESPONSE   0x03
   60 #define SOCKS_SENDING_WEBREQUEST    0x04
   61 #define SOCKS_READING_RESPONSE      0x05
   62 
   63 struct socks_state {
   64     uint8_t version;
   65     uint8_t method;
   66     uint8_t gotheaders;
   67     uint8_t success;
   68 
   69     uint16_t port;
   70 
   71     char domain[64];    /* the host where it lives */
   72     char *word;     /* which word to search at google */
   73 };
   74 
   75 struct socks4_cmd {
   76     uint8_t version;
   77     uint8_t command;
   78     uint16_t dstport;
   79     struct in_addr address;
   80 };
   81 
   82 struct socks5_cmd {
   83     uint8_t version;
   84     uint8_t command;
   85     uint8_t reserved;
   86     uint8_t addrtype;
   87     struct in_addr address;
   88     uint16_t dstport;
   89 };
   90 
   91 char *socks_getword(void);
   92 void socks_bufferanalyse(struct bufferevent *, struct argument *);
   93 void socks_resolveaddress(char *name, ip_addr_t *address);
   94 
   95 
   96 #endif /* _SOCKS_H_ */