📄 socks.h
字号:
/* * Copyright (c) 1997, 1998, 1999 * Inferno Nettverk A/S, Norway. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. The above copyright notice, this list of conditions and the following * disclaimer must appear in all copies of the software, derivative works * or modified versions, and any portions thereof, aswell as in all * supporting documentation. * 2. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by * Inferno Nettverk A/S, Norway. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Inferno Nettverk A/S requests users of this software to return to * * Software Distribution Coordinator or sdc@inet.no * Inferno Nettverk A/S * Oslo Research Park * Gaustadal閑n 21 * N-0349 Oslo * Norway * * any improvements or extensions that they make and grant Inferno Nettverk A/S * the rights to redistribute these changes. * *//* $Id: socks.h,v 1.150 1999/12/22 09:29:20 karls Exp $ */#ifndef _SOCKS_H_#define _SOCKS_H_#endif /* ! _SOCKS_H_ */#ifdef lintextern const int lintnoloop_socks_h;#else#define lintnoloop_socks_h 0#endif#ifndef HAVE_OSF_OLDSTYLE#define HAVE_OSF_OLDSTYLE 0#endif /* !HAVE_OSF_OLDSTYLE */#ifdef SOCKSLIBRARY_DYNAMIC#ifdef accept#undef accept#endif /* accept */#if HAVE_EXTRA_OSF_SYMBOLS#define accept(s, addr, addrlen) sys_Eaccept(s, addr, addrlen)#else#define accept(s, addr, addrlen) sys_accept(s, addr, addrlen)#endif /* HAVE_EXTRA_OSF_SYMBOLS */#ifdef bind#undef bind#endif /* bind */#define bind(s, name, namelen) sys_bind(s, name, namelen)#ifdef bindresvport#undef bindresvport#endif /* bindresvport */#define bindresvport(sd, sin) sys_bindresvport(sd, sin)#ifdef connect#undef connect#endif /* connect */#define connect(s, name, namelen) sys_connect(s, name, namelen)#ifdef gethostbyname#undef gethostbyname#endif /* gethostbyname */#define gethostbyname(name) sys_gethostbyname(name)#ifdef gethostbyname2#undef gethostbyname2#endif /* gethostbyname2 */#define gethostbyname2(name, af) sys_gethostbyname2(name, af)#ifdef getpeername#undef getpeername#endif /* getpeername */#if HAVE_EXTRA_OSF_SYMBOLS#define getpeername(s, name, namelen) sys_Egetpeername(s, name, namelen)#else#define getpeername(s, name, namelen) sys_getpeername(s, name, namelen)#endif /* HAVE_EXTRA_OSF_SYMBOLS */#ifdef getsockname#undef getsockname#endif /* getsockname */#if HAVE_EXTRA_OSF_SYMBOLS#define getsockname(s, name, namelen) sys_Egetsockname(s, name, namelen)#else#define getsockname(s, name, namelen) sys_getsockname(s, name, namelen)#endif /* HAVE_EXTRA_OSF_SYMBOLS */#ifdef read#undef read#endif /* read */#define read(d, buf, nbytes) sys_read(d, buf, nbytes)#ifdef readv#undef readv#endif /* readv */#if HAVE_EXTRA_OSF_SYMBOLS#define readv(d, iov, iovcnt) sys_Ereadv(d, iov, iovcnt)#else#define readv(d, iov, iovcnt) sys_readv(d, iov, iovcnt)#endif /* HAVE_EXTRA_OSF_SYMBOLS */#ifdef recv#undef recv#endif /* recv */#define recv(s, msg, len, flags) sys_recv(s, msg, len, flags)#ifdef recvfrom#undef recvfrom#endif /* recvfrom */#if HAVE_EXTRA_OSF_SYMBOLS#define recvfrom(s, buf, len, flags, from, fromlen) \ sys_Erecvfrom(s, buf, len, flags, from, fromlen)#else#define recvfrom(s, buf, len, flags, from, fromlen) \ sys_recvfrom(s, buf, len, flags, from, fromlen)#endif /* HAVE_EXTRA_OSF_SYMBOLS */#ifdef recvmsg#undef recvmsg#endif /* recvmsg */#if HAVE_EXTRA_OSF_SYMBOLS#define recvmsg(s, msg, flags) sys_Erecvmsg(s, msg, flags)#else#define recvmsg(s, msg, flags) sys_recvmsg(s, msg, flags)#endif /* HAVE_EXTRA_OSF_SYMBOLS */#ifdef rresvport#undef rresvport#endif /* rresvport */#define rresvport(port) sys_rresvport(port)#ifdef sendto#undef sendto#endif /* sendto */#define sendto(s, msg, len, flags, to, tolen) \ sys_sendto(s, msg, len, flags, to, tolen)#ifdef write#undef write#endif /* write */#define write(d, buf, nbytes) sys_write(d, buf, nbytes)#ifdef writev#undef writev#endif /* writev */#if HAVE_EXTRA_OSF_SYMBOLS#define writev(d, iov, iovcnt) sys_Ewritev(d, iov, iovcnt)#else#define writev(d, iov, iovcnt) sys_writev(d, iov, iovcnt)#endif /* HAVE_EXTRA_OSF_SYMBOLS */#ifdef send#undef send#endif /* send */#define send(s, msg, len, flags) sys_send(s, msg, len, flags)#ifdef sendmsg#undef sendmsg#endif /* sendmsg */#if HAVE_EXTRA_OSF_SYMBOLS#define sendmsg(s, msg, flags) sys_Esendmsg(s, msg, flags)#else#define sendmsg(s, msg, flags) sys_sendmsg(s, msg, flags)#endif /* HAVE_EXTRA_OSF_SYMBOLS */#endif /* SOCKSLIBRARY_DYNAMIC */struct configstate_t { unsigned init:1; unsigned :0; struct sockaddr lastconnect; /* address we last connected to. */ pid_t pid; unsigned :0;};struct option_t { int debug; char *configfile; /* name of current configfile. */ unsigned lbuf:1; /* linebuffered output? */ unsigned :0;};struct config_t { pid_t connectchild; /* connect process. */ int connect_s; /* socket to child. */ char domain[MAXHOSTNAMELEN]; /* localdomain. */ struct logtype_t log; /* where to log. */ struct option_t option; /* misc. options. */ struct configstate_t state; int resolveprotocol; /* resolveprotocol. */ struct route_t *route; /* linked list of routes*/};struct childpacket_t { struct sockshost_t src; struct sockshost_t dst; struct socks_t packet;};__BEGIN_DECLS/* * libsocks function declarations */voidclientinit __P((void));/* * initialises clientstate, reads configfile, etc. */#if !HAVE_OSF_OLDSTYLEint Raccept __P((int, struct sockaddr *, socklen_t *));int Rconnect __P((int, const struct sockaddr *, socklen_t));int Rgetsockname __P((int, struct sockaddr *, socklen_t *));int Rgetpeername __P((int, struct sockaddr *, socklen_t *));ssize_t Rsendto __P((int s, const void *msg, size_t len, int flags, const struct sockaddr *to, socklen_t tolen));ssize_t Rrecvfrom __P((int s, void *buf, size_t len, int flags, struct sockaddr * from, socklen_t *fromlen));ssize_t Rsendmsg __P((int s, const struct msghdr *msg, int flags));ssize_t Rrecvmsg __P((int s, struct msghdr *msg, int flags));int Rbind __P((int, const struct sockaddr *, socklen_t));#endif /* !HAVE_OSF_OLDSTYLE */int Rbindresvport __P((int, struct sockaddr_in *));int Rrresvport __P((int *));struct hostent *Rgethostbyname __P((const char *));struct hostent *Rgethostbyname2 __P((const char *, int af));ssize_t Rwrite __P((int d, const void *buf, size_t nbytes));ssize_t Rwritev __P((int d, const struct iovec *iov, int iovcnt));ssize_t Rsend __P((int s, const void *msg, size_t len, int flags));ssize_t Rread __P((int d, void *buf, size_t nbytes));ssize_t Rreadv __P((int d, const struct iovec *iov, int iovcnt));ssize_t Rrecv __P((int s, void *msg, size_t len, int flags));int SOCKSinit __P((char *));int Rlisten __P((int, int));int Rselect __P((int, fd_set *, fd_set *, fd_set *, struct timeval *));/* * unused functions needed to compile programs with support for other * socks implementations. */intudpsetup __P((int s, const struct sockaddr *to, int type));/* * sets up udp relaying between address of "s" and "to" by connecting * to socksserver. * If relaying is already set up the function returns with success. * Type is the type of connection setup, SOCKS_SEND or SOCKS_RECV. * At the moment only SOCKS_SEND is supported. * Returns: * On success: 0 * On failure: -1 */intnegotiate_method __P((int s, struct socks_t *packet));/* * Negotiates a method to be used when talking with the server connected * to "s". "packet" is the packet that will later be sent to server, * only the "auth" element in it will be set but other elements are needed * too. * Returns: * On success: 0 * On failure: -1 */intsocks_sendrequest __P((int s, const struct request_t *request));/* * Sends the request "request" to the socksserver connected to "s". * Returns: * On success: 0 * On failure: -1 */intsocks_recvresponse __P((int s, struct response_t *response, int version));/* * Receives a socks response from the "s". "response" is filled in with * the data received. * "version" is the protocolversion negotiated. * Returns: * On success: 0 * On failure: -1 */intsocks_negotiate __P((int s, int control, struct socks_t *packet, struct route_t *route));/* * "s" is the socket data will flow over. * "control" is the control connection to the socks server. * "packet" is a socks packet containing the request. * "route" is the connected route. * Negotiates method and fills the response to the request into packet->res. * Returns: * On success: 0. (server accepted our request.) * On failure: -1. */struct route_t *socks_nbconnectroute __P((int s, int control, struct socks_t *packet, const struct sockshost_t *src, const struct sockshost_t *dst));/* * The non-blocking version of socks_connectroute(), only used by client. * Takes one additional argument, "s", which is the socket to connect * and not necessarily the same as "control" (msproxy case). */voidsocks_badroute __P((struct route_t *route));/* * Marks route "route" as bad. */intrecv_sockshost __P((int s, struct sockshost_t *host, int version));/* * Fills "host" based on data read from "s". "version" is the version
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -