⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 common.h

📁 sock protocol ,it is useful!
💻 H
📖 第 1 页 / 共 4 页
字号:
 * If "s" is at oob mark, return 1, otherwise 0. * Returns -1 if a error occurred. */ssize_trecvmsgn __P((int s, struct msghdr *msg, int flags, size_t len));/* * Like recvmsg(), but tries to read until "len" has been read. * BUGS: *   Assumes msg->msg_iov[n] are laid out next to each others. */ssize_treadn __P((int, void *, size_t));/* * Like read() but retries. */ssize_twriten __P((int, const void *, size_t));/* * like write() but retries. */intclosen __P((int));/* * Wrapper around close().  Retries on EINTR. */intselectn __P((int, fd_set *, fd_set *, fd_set *, struct timeval *));/* * Wrapper around select().  Retries on EINTR. */intacceptn __P((int, struct sockaddr *, socklen_t *));/* * Wrapper around accept().  Retries on EINTR. */char *sockshost2string __P((const struct sockshost_t *host, char *string,							 size_t len));/* * Writes "host" out as a string.  The string is written to "string", * which is of length "len", including NUL termination. * Returns: "string". */const char *strcheck __P((const char *string));/* * Checks "string".  If it is NULL, returns a string indicating memory * exhausted, if not, returns the same string it was passed. */const char *command2string __P((int command));/* * Returns a printable representation of the socks command "command". * Can't fail. */const char *protocol2string __P((int protocol));/* * Returns a printable representation of "protocol". * Can't fail. */const char *method2string __P((int method));/* * Returns a printable representation of the authmethod "method". * Can't fail. */intstring2method __P((const char *methodname));/* * If "methodname" is the name of a supported method, the protocol * value of that method is returned. * Otherwise, -1 is returned. */char *sockshost2mem __P((const struct sockshost_t *host, char *mem, int version));/* * Writes "host" out to "mem".  The caller must make sure "mem" * is big enough to hold the contents of "host". * "version" gives the socks version "host" is to be written out in. * Returns a pointer to one element past the last byte written to "mem". */const char *mem2sockshost __P((struct sockshost_t *host, const char *mem, size_t len,						 int version));/* * Writes "mem", which is assumed to be a sockshost string * of version "version" in network order, out to "host". * Returns: *		On success: pointer to one element past last byte used of mem *						and fills in "host" appropriately. *		On failure: NULL ("mem" is not a valid sockshost.) */#ifdef STDC_HEADERSvoid slog(int priority, const char *message, ...);#elsevoid slog();#endif  /* STDC_HEADERS *//* * Logs message "message" at priority "priority" to previously configured * outputdevice. * Checks settings and ignores message if it's of to low a priority. */void vslog __P((int priority, const char *message, va_list ap));/* * Same as slog() but assumes varargs/stdargs have already processed * the arguments. */intreadconfig __P((const char *filename));/* * Parses the config stored in in the filename "filename". * Returns: *		On success: 0. *		On failure: -1. */voidyyerror __P((const char *s));/* * Report a error related to (configfile) parsing and exit. */intaddressmatch __P((const struct ruleaddress_t *rule,						const struct sockshost_t *address, int protocol,						int ipalias));/* * Tries to match "address" against "rule".  "address" is resolved * if necessary.  "address" supports the wildcard INADDR_ANY and port of 0. * "protocol" is the protocol to compare under. * If "ipalias" is true, the function will try to match any ip alias * "address"'s might have if appropriate, this can be useful to match * multihomed hosts where the client requests e.g a bind connection. * Returns true if "rule" matched "address". */struct hostent *hostentdup __P((const struct hostent *hostent));/* * Duplicates "hostent". * Returns: *		On success: a pointer to the duplicated hostent. *		On failure: NULL. */voidhostentfree __P((struct hostent *hostent));/* * Free's all resourced used by "hostent", including "hostent" * itself.  If "hostent" is NULL, nothing is done. */intsocks_connect __P((int s, const struct sockshost_t *host));/* * Tries to connect to "host".  If "host"'s address is not a ip address, * the function also tries to connect to any alias for "host"'s * name.  The connection is done using the open descriptor "s". * Returns: *		On success: 0 *		On failure: -1 */struct route_t *socks_connectroute __P((int s, struct socks_t *packet,								const struct sockshost_t *src,								const struct sockshost_t *dst));/* * Finds a route from "src" to "dst" and connects to it "s". * If src or dst is NULL, that argument is ignored. * * The route used may take into account the contents of "packet->req", * which is assumed to be the packet that will be sent to a socksserver, * so it is recommended that it's contents be as conservative as possible. * * When it has successfully connected to a gateway it will set * the packet->method members to point to the methods the gateway * should be offered. * * Returns: *		On success: the route that was used. *		On failure: NULL.  If errno is 0, the reason for failure was *						that no route was found. */struct request_t *socks_requestpolish __P((struct request_t *req, const struct sockshost_t *src,							   const struct sockshost_t *dst));/* * Tries to "polish" the request "req" so that a later socks_getroute() * will succeed. * Returns: *		On success: "req". *		On failure: NULL. */voidshowstate __P((const struct serverstate_t *state));/* * Shows "state". */struct route_t *addroute __P((const struct route_t *route));/* * Appends a copy of "route" to our list of routes. * Returns a pointer to the added route. */voidshowroute __P((const struct route_t *route));/* * prints the route "route". */struct route_t *socks_getroute __P((const struct request_t *req, const struct sockshost_t *src,						  const struct sockshost_t *dst));/* * Tries to find a  route to be used for a connection going from * "src" to "dst". * If src or dst is NULL, that argument is ignored. * * The route used may take into account the contents of "req", which is * assumed to be the packet that will be sent to a socksserver, so it is * recommended that it's contents be as conservative as possible. * * Returns: *		On success: pointer to route that should be used. *		On failure: NULL (no socks route found). */const char *ruleaddress2string __P((const struct ruleaddress_t *rule, char *string,								size_t len));/* * Writes "rule" out as a string.  The string is written to "string", * which is of length "len", including NUL termination. * Returns: "string". */intsockscode __P((int version, int code));/* * Maps the socks replycode "code", which is in non-version specific format, * to the equivalent replycode in version "version". */interrno2reply __P((int errnum, int version));/* * Returns the socks version "version" reply code for a error of type "errno". */enum operator_tstring2operator __P((const char *operator));/* * Returns the enum for the string representation of a operator. * Can't fail. */const char *operator2string __P((enum operator_t operator));/* * Returns the string representation of the operator. * Can't fail. */char *str2vis __P((const char *string, size_t len));/* * Visually encodes exactly "len" chars of "string". * Returns: *		On success: the visually encoded string, to be free()'ed by caller. *		On failure: NULL.  (out of memory). */in_addr_tsocks_addfakeip __P((const char *name));/* * Adds "name" to a internal table indexed by (fake)ip addresses. * Returns: *		On success: "name"'s index. *		On failure:	INADDR_NONE */const char *socks_getfakehost __P((in_addr_t addr));/* * If "addr" is a "fake" (non-resolved) addr, it returns the name * corresponding to it. * Else, NULL is returned. */intsocks_getfakeip __P((const char *host, struct in_addr *addr));/* * If "host" has a fake address entry, the address is written into * "addr". * Returns: *		If a fake address exits: 1 *		Else: 0 */struct sockshost_t *fakesockaddr2sockshost __P((const struct sockaddr *addr,									 struct sockshost_t *host));/* * Identical to sockaddr2sockshost, but checks whether * the address in "addr" is a "fake" one when converting. */intsockaddrareeq __P((const struct sockaddr *a, const struct sockaddr *b));/* * Compares the address "a" against "b". * Returns: *		If "a" and "b" are equal: true *		else: false */intsockshostareeq __P((const struct sockshost_t *a, const struct sockshost_t *b));/* * Compares the address "a" against "b". * Returns: *		If "a" and "b" are equal: true *		else: false */intfdsetop __P((int nfds, int op, const fd_set *a, const fd_set *b,				 fd_set *result));/* * Performs operation on descriptor sets. * "nfds" is the number of descriptors to perform "op" on in the sets * "a" and "b". * "op" is the operation to be performed on the descriptor sets and * can take on the value of standard C bitwise operators. * The result of the operation is stored in "result". * * Returns the number of the highest descriptor set in "result". * NOTES: *		Operators supported is: AND ('&') and XOR ('^') */intmethodisset __P((int method, const int *methodv, size_t methodc));/* * Returns true if the method "method" is set in "methodv", false otherwise. * "methodc" is the length of "methodv". */intsocketoptdup __P((int s));/* * Duplicates the settings of "s" and returns a new socket with the * same settings. * Returns: *		On success: the descriptor for the new socket *		On failure: -1 */intsocks_mklock __P((const char *template));/* * Creates a filedescriptor that can be used with socks_lock() and * socks_unlock(). * Returns: *		On success: filedescriptor *		On failure: -1 */intsocks_lock __P((int fd, int type, int timeout));/* * Looks the filedescriptor "fd". * "type" is the type of lock; F_RDLCK or F_WRLCK. * "timeout" is how long to wait for lock, supported values: *		-1: forever. *		0 : don't wait. * Returns: *		On success: 0 *		On error  : -1 */voidsocks_unlock __P((int d));/* * Unlocks the filedescriptor "d", previously locked by this process. */#if defined(DEBUG) || HAVE_SOLARIS_BUGSintfreedescriptors __P((const char *message));/* * Returns the number on unallocated descriptors. */#endif /* DEBUG) || HAVE_SOLARIS_BUGS */#ifdef DEBUGintfd_isset __P((int fd, fd_set *fdset));/* function version of FD_ISSET() */#endif /* DEBUG *//* replacements */#if !HAVE_DAEMONint daemon __P((int, int));#endif  /* !HAVE_DAEMON */#if !HAVE_GETDTABLESIZE/* return upper limit on per-process open file descriptors */int getdtablesize __P((void));#endif  /* !HAVE_GETDTABLESIZE */#if !HAVE_SNPRINTF# ifdef STDC_HEADERSint snprintf __P((char *, size_t, char const *, ...));# elseint snprintf ();# endif /* STDC_HEADERS */int vsnprintf __P((char *, size_t, const char *, va_list));#endif /* !HAVE_SNPRINTF */#if !HAVE_SETPROCTITLE#ifdef STDC_HEADERSvoid setproctitle __P((const char *fmt, ...));int initsetproctitle __P((int, char **, char **));#elsevoid setproctitle();int initsetproctitle __P((int, char **, char **));#endif  /* STDC_HEADERS */#endif  /* !HAVE_SETPROCTITLE */#if !HAVE_SOCKATMARKint sockatmark __P((int));#endif  /* !HAVE_SOCKATMARK */#if !HAVE_INET_ATONint inet_aton __P((register const char *cp, struct in_addr *addr));#endif  /* ! HAVE_ATON */#if !HAVE_GETDTABLESIZEint getdtablesize __P((void));#endif  /* ! HAVE_GETDTABLESIZE */#if !HAVE_STRERRORchar *__strerror __P((int, char *));char *strerror __P((int));const char *hstrerror __P((int));#endif  /* !HAVE_STRERROR */#if !HAVE_MEMMOVEvoid * memmove __P((void *, const void *, register size_t));#endif  /* !HAVE_MEMMOVE */#if !HAVE_INET_PTONint inet_pton __P((int af, const char *src, void *dst));#endif#if !HAVE_ISSETUGIDint issetugid __P((void));#endif  /* !HAVE_ISSETUGID */#if !HAVE_VSYSLOGvoid vsyslog __P((int, const char *, va_list));#endif  /* !HAVE_VSYSLOG */__END_DECLS/* XXX */#if defined(SOCKS_CLIENT) || defined(SOCKS_SERVER)#if SOCKS_CLIENT#include "socks.h"#endif#if SOCKS_SERVER#include "sockd.h"#endif  /* SOCKS_CLIENT */#endif  /* SOCKS_CLIENT || SOCKS_SERVER */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -