| ne_auth.h | | ne_auth.h | |
| /* | | /* | |
| HTTP authentication routines | | HTTP authentication routines | |
|
| Copyright (C) 1999-2007, Joe Orton <joe@manyfish.co.uk> | | Copyright (C) 1999-2009, Joe Orton <joe@manyfish.co.uk> | |
| | | | |
| This library is free software; you can redistribute it and/or | | This library is free software; you can redistribute it and/or | |
| modify it under the terms of the GNU Library General Public | | modify it under the terms of the GNU Library General Public | |
| License as published by the Free Software Foundation; either | | License as published by the Free Software Foundation; either | |
| version 2 of the License, or (at your option) any later version. | | version 2 of the License, or (at your option) any later version. | |
| | | | |
| This library is distributed in the hope that it will be useful, | | This library is distributed in the hope that it will be useful, | |
| but WITHOUT ANY WARRANTY; without even the implied warranty of | | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| Library General Public License for more details. | | Library General Public License for more details. | |
| | | | |
| skipping to change at line 68 | | skipping to change at line 68 | |
| | | | |
| /* As an alternative to using ne_set_server_auth and | | /* As an alternative to using ne_set_server_auth and | |
| * ne_set_proxy_auth, the following interfaces may be used; these | | * ne_set_proxy_auth, the following interfaces may be used; these | |
| * allow control over which authentication protocol is used. */ | | * allow control over which authentication protocol is used. */ | |
| | | | |
| /* NE_AUTH_BASIC: Basic authentication transmits the username and | | /* NE_AUTH_BASIC: Basic authentication transmits the username and | |
| * password unprotected over the channel; this allows a passive attack | | * password unprotected over the channel; this allows a passive attack | |
| * to steal the credentials if using an unsecured channel | | * to steal the credentials if using an unsecured channel | |
| * (i.e. non-SSL). */ | | * (i.e. non-SSL). */ | |
| #define NE_AUTH_BASIC (0x0001) | | #define NE_AUTH_BASIC (0x0001) | |
|
| | | | |
| /* NE_AUTH_DIGEST: Digest authentication uses a hash of the username, | | /* NE_AUTH_DIGEST: Digest authentication uses a hash of the username, | |
| * password, and certain aspects of the request, so prevents passive | | * password, and certain aspects of the request, so prevents passive | |
| * attackers from obtaining the credentials; active attackers can | | * attackers from obtaining the credentials; active attackers can | |
| * still modify most of the request/response if using an unsecured | | * still modify most of the request/response if using an unsecured | |
| * channel. */ | | * channel. */ | |
| #define NE_AUTH_DIGEST (0x0002) | | #define NE_AUTH_DIGEST (0x0002) | |
|
| /* NE_AUTH_NEGOTIATE: Negotiate uses GSSAPI/SSPI to authenticate the | | | |
| * user; an active attacker can modify any of the request/response at | | /* NE_AUTH_NEGOTIATE: Negotiate uses GSSAPI/SSPI, or NTLM, to | |
| * will, so this must not be used over an unsecured channel. */ | | * authenticate the user; an active attacker can modify any of the | |
| | | * request/response at will, so this must not be used over an | |
| | | * unsecured channel. NE_AUTH_NEGOTIATE is currently equivalent to | |
| | | * use of (NE_AUTH_GSSAPI | NE_AUTH_NTLM). */ | |
| #define NE_AUTH_NEGOTIATE (0x0004) | | #define NE_AUTH_NEGOTIATE (0x0004) | |
|
| | | | |
| | | /* NE_AUTH_GSSAPI: Use GSSAPI or SSPI to authenticate the user; an | |
| | | * active attacker can modify any of the request/response at will, so | |
| | | * this must not be used over an unsecured channel. */ | |
| | | #define NE_AUTH_GSSAPI (0x0008) | |
| | | | |
| | | /* NE_AUTH_NTLM: Use NTLM to authenticate the user; an active attacker | |
| | | * can modify any of the request/response at will, so this must not be | |
| | | * used over an unsecured channel. */ | |
| | | #define NE_AUTH_NTLM (0x0010) | |
| | | | |
| /* The default set of supported protocols, as deemed appropriate for | | /* The default set of supported protocols, as deemed appropriate for | |
| * the given session scheme. */ | | * the given session scheme. */ | |
| #define NE_AUTH_DEFAULT (0x1000) | | #define NE_AUTH_DEFAULT (0x1000) | |
|
| | | | |
| /* All protocols supported by the library. */ | | /* All protocols supported by the library. */ | |
| #define NE_AUTH_ALL (0x2000) | | #define NE_AUTH_ALL (0x2000) | |
| | | | |
| /* Add a callback to provide credentials for server and proxy | | /* Add a callback to provide credentials for server and proxy | |
| * authentication using a particular auth protocol or set of | | * authentication using a particular auth protocol or set of | |
| * protocols. The protocol is supplied as a bitmask of NE_AUTH_* | | * protocols. The protocol is supplied as a bitmask of NE_AUTH_* | |
| * values. For NE_AUTH_NEGOTIATE, the creds and userdata arguments | | * values. For NE_AUTH_NEGOTIATE, the creds and userdata arguments | |
| * are ignored and may be NULL. | | * are ignored and may be NULL. | |
| * | | * | |
| * These functions may be called multiple times per session to | | * These functions may be called multiple times per session to | |
| | | | |
End of changes. 5 change blocks. |
| 4 lines changed or deleted | | 20 lines changed or added | |
|
| ne_session.h | | ne_session.h | |
| /* | | /* | |
| HTTP session handling | | HTTP session handling | |
|
| Copyright (C) 1999-2008, Joe Orton <joe@manyfish.co.uk> | | Copyright (C) 1999-2009, Joe Orton <joe@manyfish.co.uk> | |
| | | | |
| This library is free software; you can redistribute it and/or | | This library is free software; you can redistribute it and/or | |
| modify it under the terms of the GNU Library General Public | | modify it under the terms of the GNU Library General Public | |
| License as published by the Free Software Foundation; either | | License as published by the Free Software Foundation; either | |
| version 2 of the License, or (at your option) any later version. | | version 2 of the License, or (at your option) any later version. | |
| | | | |
| This library is distributed in the hope that it will be useful, | | This library is distributed in the hope that it will be useful, | |
| but WITHOUT ANY WARRANTY; without even the implied warranty of | | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| Library General Public License for more details. | | Library General Public License for more details. | |
| | | | |
| skipping to change at line 50 | | skipping to change at line 50 | |
| const char *hostname, unsigned int port); | | const char *hostname, unsigned int port); | |
| | | | |
| /* Finish an HTTP session */ | | /* Finish an HTTP session */ | |
| void ne_session_destroy(ne_session *sess); | | void ne_session_destroy(ne_session *sess); | |
| | | | |
| /* Prematurely force the connection to be closed for the given | | /* Prematurely force the connection to be closed for the given | |
| * session. */ | | * session. */ | |
| void ne_close_connection(ne_session *sess); | | void ne_close_connection(ne_session *sess); | |
| | | | |
| /* Set the proxy server to be used for the session. This function | | /* Set the proxy server to be used for the session. This function | |
|
| * must only be called before any requests are created for the | | * will override (remove) any proxy servers previously configured, and | |
| | | * must be called before any requests are created using this | |
| * session. */ | | * session. */ | |
| void ne_session_proxy(ne_session *sess, | | void ne_session_proxy(ne_session *sess, | |
| const char *hostname, unsigned int port); | | const char *hostname, unsigned int port); | |
| | | | |
|
| | | /* Configure a SOCKS proxy server which will be used for the session. | |
| | | * The SOCKS protocol version 'vers' will be used to contact the | |
| | | * proxy at given 'hostname' and 'port'. | |
| | | * | |
| | | * If SOCKSv4 or v4a are used, username must be non-NULL. For v5, | |
| | | * username may be NULL, in which case, password is ignored. If | |
| | | * username is non-NULL, password must also be non-NULL. | |
| | | * | |
| | | * This function will override (remove) any proxy servers previously | |
| | | * configured, and must be called before any requests are created | |
| | | * using this session. */ | |
| | | void ne_session_socks_proxy(ne_session *sess, enum ne_sock_sversion vers, | |
| | | const char *hostname, unsigned int port, | |
| | | const char *username, const char *password); | |
| | | | |
| | | /* Configure use of proxy servers from any system-wide default sources | |
| | | * which are configured at build time. This function will override | |
| | | * (remove) any proxy servers previously configured, and must be | |
| | | * called before any requests are created using this session. The | |
| | | * 'flags' parameter must be zero. */ | |
| | | void ne_session_system_proxy(ne_session *sess, unsigned int flags); | |
| | | | |
| /* Defined session flags: */ | | /* Defined session flags: */ | |
| typedef enum ne_session_flag_e { | | typedef enum ne_session_flag_e { | |
| NE_SESSFLAG_PERSIST = 0, /* disable this flag to prevent use of | | NE_SESSFLAG_PERSIST = 0, /* disable this flag to prevent use of | |
| * persistent connections. */ | | * persistent connections. */ | |
| | | | |
| NE_SESSFLAG_ICYPROTO, /* enable this flag to enable support for | | NE_SESSFLAG_ICYPROTO, /* enable this flag to enable support for | |
| * non-HTTP ShoutCast-style "ICY" responses. */ | | * non-HTTP ShoutCast-style "ICY" responses. */ | |
| | | | |
| NE_SESSFLAG_SSLv2, /* disable this flag to disable support for | | NE_SESSFLAG_SSLv2, /* disable this flag to disable support for | |
| * SSLv2, if supported by the SSL library. */ | | * SSLv2, if supported by the SSL library. */ | |
| | | | |
| skipping to change at line 78 | | skipping to change at line 101 | |
| * backwards-compatibility with RFC2518 | | * backwards-compatibility with RFC2518 | |
| * servers. */ | | * servers. */ | |
| | | | |
| NE_SESSFLAG_CONNAUTH, /* enable this flag if an awful, broken, | | NE_SESSFLAG_CONNAUTH, /* enable this flag if an awful, broken, | |
| * RFC-violating, connection-based HTTP | | * RFC-violating, connection-based HTTP | |
| * authentication scheme is in use. */ | | * authentication scheme is in use. */ | |
| | | | |
| NE_SESSFLAG_TLS_SNI, /* disable this flag to disable use of the | | NE_SESSFLAG_TLS_SNI, /* disable this flag to disable use of the | |
| * TLS Server Name Indication extension. */ | | * TLS Server Name Indication extension. */ | |
| | | | |
|
| | | NE_SESSFLAG_EXPECT100, /* enable this flag to enable the flag | |
| | | * NE_REQFLAG_EXPECT100 for new requests. */ | |
| | | | |
| NE_SESSFLAG_LAST /* enum sentinel value */ | | NE_SESSFLAG_LAST /* enum sentinel value */ | |
| } ne_session_flag; | | } ne_session_flag; | |
| | | | |
| /* Set a new value for a particular session flag. */ | | /* Set a new value for a particular session flag. */ | |
| void ne_set_session_flag(ne_session *sess, ne_session_flag flag, int value)
; | | void ne_set_session_flag(ne_session *sess, ne_session_flag flag, int value)
; | |
| | | | |
| /* Return 0 if the given flag is not set, >0 it is set, or -1 if the | | /* Return 0 if the given flag is not set, >0 it is set, or -1 if the | |
| * flag is not supported. */ | | * flag is not supported. */ | |
| int ne_get_session_flag(ne_session *sess, ne_session_flag flag); | | int ne_get_session_flag(ne_session *sess, ne_session_flag flag); | |
| | | | |
| /* Bypass the normal name resolution; force the use of specific set of | | /* Bypass the normal name resolution; force the use of specific set of | |
|
| * addresses for this session, addrs[0]...addrs[n-1]. The addrs array | | * addresses for this session, addrs[0]...addrs[n-1]. The 'addrs' | |
| * must remain valid until the session is destroyed. */ | | * array and pointed-to objects must remain valid until the session is | |
| | | * destroyed. This function will override (remove) any proxy servers | |
| | | * previously configured, and must be called before any requests are | |
| | | * created using this session. */ | |
| void ne_set_addrlist(ne_session *sess, const ne_inet_addr **addrs, size_t n
); | | void ne_set_addrlist(ne_session *sess, const ne_inet_addr **addrs, size_t n
); | |
| | | | |
| /* Bind connections to the specified local address. If the address | | /* Bind connections to the specified local address. If the address | |
| * determined for the remote host has a different family (type) to | | * determined for the remote host has a different family (type) to | |
| * 'addr', 'addr' will be ignored. The 'addr' object must remain | | * 'addr', 'addr' will be ignored. The 'addr' object must remain | |
| * valid until the session is destroyed. */ | | * valid until the session is destroyed. */ | |
| void ne_set_localaddr(ne_session *sess, const ne_inet_addr *addr); | | void ne_set_localaddr(ne_session *sess, const ne_inet_addr *addr); | |
| | | | |
| /* DEPRECATED: Progress callback. */ | | /* DEPRECATED: Progress callback. */ | |
| typedef void (*ne_progress)(void *userdata, ne_off_t progress, ne_off_t tot
al); | | typedef void (*ne_progress)(void *userdata, ne_off_t progress, ne_off_t tot
al); | |
| | | | |
| skipping to change at line 179 | | skipping to change at line 208 | |
| * session status events. Only one notification callback per session | | * session status events. Only one notification callback per session | |
| * can be registered; the most recent of successive calls to this | | * can be registered; the most recent of successive calls to this | |
| * function takes effect. If status is NULL, any existing callback | | * function takes effect. If status is NULL, any existing callback | |
| * is deregistered and will no longer be invoked. | | * is deregistered and will no longer be invoked. | |
| * | | * | |
| * NOTE: Use of this interface is mutually exclusive with the use of | | * NOTE: Use of this interface is mutually exclusive with the use of | |
| * ne_set_progress(). A call to ne_set_notifier() removes the | | * ne_set_progress(). A call to ne_set_notifier() removes the | |
| * progress callback, and vice versa. */ | | * progress callback, and vice versa. */ | |
| void ne_set_notifier(ne_session *sess, ne_notify_status status, void *userd
ata); | | void ne_set_notifier(ne_session *sess, ne_notify_status status, void *userd
ata); | |
| | | | |
|
| /* Certificate verification failures. | | /* Certificate verification failures. */ | |
| * The certificate is not yet valid: */ | | | |
| | | /* NE_SSL_NOTYETVALID: the certificate is not yet valid. */ | |
| #define NE_SSL_NOTYETVALID (0x01) | | #define NE_SSL_NOTYETVALID (0x01) | |
|
| /* The certificate has expired: */ | | | |
| | | /* NE_SSL_EXPIRED: the certificate has expired. */ | |
| #define NE_SSL_EXPIRED (0x02) | | #define NE_SSL_EXPIRED (0x02) | |
|
| /* The hostname for which the certificate was issued does not | | | |
| * match the hostname of the server; this could mean that the | | /* NE_SSL_IDMISMATCH: the hostname for which the certificate was | |
| * connection is being intercepted: */ | | * issued does not match the hostname of the server; this could mean | |
| | | * that the connection is being intercepted. */ | |
| #define NE_SSL_IDMISMATCH (0x04) | | #define NE_SSL_IDMISMATCH (0x04) | |
|
| /* The certificate authority which signed the server certificate is | | | |
| * not trusted: there is no indicatation the server is who they claim | | /* NE_SSL_UNTRUSTED: the certificate authority which signed the server | |
| * to be: */ | | * certificate is not trusted: there is no indicatation the server is | |
| | | * who they claim to be: */ | |
| #define NE_SSL_UNTRUSTED (0x08) | | #define NE_SSL_UNTRUSTED (0x08) | |
| | | | |
|
| /* The bitmask of known failure bits: if (failures & ~NE_SSL_FAILMASK) | | /* NE_SSL_BADCHAIN: the certificate chain contained a certificate | |
| * is non-zero, an unrecognized failure is given, and the verification | | * other than the server cert which failed verification for a reason | |
| * should be failed. */ | | * other than lack of trust; for example, due to a CA cert being | |
| #define NE_SSL_FAILMASK (0x0f) | | * outside its validity period. */ | |
| | | #define NE_SSL_BADCHAIN (0x10) | |
| | | | |
| | | /* N.B.: 0x20 is reserved. */ | |
| | | | |
| | | /* NE_SSL_REVOKED: the server certificate has been revoked by the | |
| | | * issuing authority. */ | |
| | | #define NE_SSL_REVOKED (0x40) | |
| | | | |
| | | /* For purposes of forwards-compatibility, the bitmask of all | |
| | | * currently exposed failure bits is given as NE_SSL_FAILMASK. If the | |
| | | * expression (failures & ~NE_SSL_FAILMASK) is non-zero a failure type | |
| | | * is present which the application does not recognize but must treat | |
| | | * as a verification failure nonetheless. */ | |
| | | #define NE_SSL_FAILMASK (0x5f) | |
| | | | |
| /* A callback which is used when server certificate verification is | | /* A callback which is used when server certificate verification is | |
| * needed. The reasons for verification failure are given in the | | * needed. The reasons for verification failure are given in the | |
| * 'failures' parameter, which is a binary OR of one or more of the | | * 'failures' parameter, which is a binary OR of one or more of the | |
| * above NE_SSL_* values. failures is guaranteed to be non-zero. The | | * above NE_SSL_* values. failures is guaranteed to be non-zero. The | |
| * callback must return zero to accept the certificate: a non-zero | | * callback must return zero to accept the certificate: a non-zero | |
| * return value will fail the SSL negotiation. */ | | * return value will fail the SSL negotiation. */ | |
| typedef int (*ne_ssl_verify_fn)(void *userdata, int failures, | | typedef int (*ne_ssl_verify_fn)(void *userdata, int failures, | |
| const ne_ssl_certificate *cert); | | const ne_ssl_certificate *cert); | |
| | | | |
| | | | |
| skipping to change at line 277 | | skipping to change at line 324 | |
| * the trailing ':'; e.g. "http" or "https". */ | | * the trailing ':'; e.g. "http" or "https". */ | |
| const char *ne_get_scheme(ne_session *sess); | | const char *ne_get_scheme(ne_session *sess); | |
| | | | |
| /* Sets the host, scheme, and port fields of the given URI structure | | /* Sets the host, scheme, and port fields of the given URI structure | |
| * to that of the configured server and scheme for the session; host | | * to that of the configured server and scheme for the session; host | |
| * and scheme are malloc-allocated. No other fields in the URI | | * and scheme are malloc-allocated. No other fields in the URI | |
| * structure are changed. */ | | * structure are changed. */ | |
| void ne_fill_server_uri(ne_session *sess, ne_uri *uri); | | void ne_fill_server_uri(ne_session *sess, ne_uri *uri); | |
| | | | |
| /* If a proxy is configured, sets the host and port fields in the | | /* If a proxy is configured, sets the host and port fields in the | |
|
| * given URI structure to that of the proxy. The hostname is | | * given URI structure to that of the proxy. If multiple proxies are | |
| * malloc-allocated. No other fields in the URI structure are | | * configured, the active is used if any, otherwise the first. The | |
| * changed; if a proxy is not configured, no fields are changed. */ | | * hostname is malloc-allocated. No other fields in the URI structure | |
| | | * are changed; if no proxy is configured or a non-HTTP proxy is in | |
| | | * use, no fields are changed. */ | |
| void ne_fill_proxy_uri(ne_session *sess, ne_uri *uri); | | void ne_fill_proxy_uri(ne_session *sess, ne_uri *uri); | |
| | | | |
| /* Set the error string for the session; takes printf-like format | | /* Set the error string for the session; takes printf-like format | |
| * string. */ | | * string. */ | |
| void ne_set_error(ne_session *sess, const char *format, ...) | | void ne_set_error(ne_session *sess, const char *format, ...) | |
| ne_attribute((format (printf, 2, 3))); | | ne_attribute((format (printf, 2, 3))); | |
| | | | |
| /* Retrieve the error string for the session */ | | /* Retrieve the error string for the session */ | |
| const char *ne_get_error(ne_session *sess); | | const char *ne_get_error(ne_session *sess); | |
| | | | |
| | | | |
End of changes. 11 change blocks. |
| 20 lines changed or deleted | | 69 lines changed or added | |
|
| ne_socket.h | | ne_socket.h | |
| /* | | /* | |
| socket handling interface | | socket handling interface | |
|
| Copyright (C) 1999-2007, Joe Orton <joe@manyfish.co.uk> | | Copyright (C) 1999-2009, Joe Orton <joe@manyfish.co.uk> | |
| | | | |
| This library is free software; you can redistribute it and/or | | This library is free software; you can redistribute it and/or | |
| modify it under the terms of the GNU Library General Public | | modify it under the terms of the GNU Library General Public | |
| License as published by the Free Software Foundation; either | | License as published by the Free Software Foundation; either | |
| version 2 of the License, or (at your option) any later version. | | version 2 of the License, or (at your option) any later version. | |
| | | | |
| This library is distributed in the hope that it will be useful, | | This library is distributed in the hope that it will be useful, | |
| but WITHOUT ANY WARRANTY; without even the implied warranty of | | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| Library General Public License for more details. | | Library General Public License for more details. | |
| | | | |
| skipping to change at line 117 | | skipping to change at line 117 | |
| * are equivalent or non-zero otherwise. */ | | * are equivalent or non-zero otherwise. */ | |
| int ne_iaddr_cmp(const ne_inet_addr *i1, const ne_inet_addr *i2); | | int ne_iaddr_cmp(const ne_inet_addr *i1, const ne_inet_addr *i2); | |
| | | | |
| /* Return the type of the given network address object. */ | | /* Return the type of the given network address object. */ | |
| ne_iaddr_type ne_iaddr_typeof(const ne_inet_addr *ia); | | ne_iaddr_type ne_iaddr_typeof(const ne_inet_addr *ia); | |
| | | | |
| /* Print the string representation of network address 'ia' into the | | /* Print the string representation of network address 'ia' into the | |
| * buffer 'buffer', which is of length 'bufsiz'. Returns 'buffer'. */ | | * buffer 'buffer', which is of length 'bufsiz'. Returns 'buffer'. */ | |
| char *ne_iaddr_print(const ne_inet_addr *ia, char *buffer, size_t bufsiz); | | char *ne_iaddr_print(const ne_inet_addr *ia, char *buffer, size_t bufsiz); | |
| | | | |
|
| | | /* Dump the raw byte representation (in network byte order) of address | |
| | | * 'ia' into the buffer 'buffer', which must be of a suitable length | |
| | | * (4 bytes for an IPv4 address, 16 bytes for an IPv6 address). | |
| | | * Returns 'buffer'. */ | |
| | | unsigned char *ne_iaddr_raw(const ne_inet_addr *ia, unsigned char *buffer); | |
| | | | |
| /* Perform the reverse name lookup on network address 'ia', placing | | /* Perform the reverse name lookup on network address 'ia', placing | |
| * the returned name in the 'buf' buffer (of length 'bufsiz') if | | * the returned name in the 'buf' buffer (of length 'bufsiz') if | |
| * successful. Returns zero on success, or non-zero on error. */ | | * successful. Returns zero on success, or non-zero on error. */ | |
| int ne_iaddr_reverse(const ne_inet_addr *ia, char *buf, size_t bufsiz); | | int ne_iaddr_reverse(const ne_inet_addr *ia, char *buf, size_t bufsiz); | |
| | | | |
|
| /* Destroy a network address object created using ne_iaddr_make. */ | | /* Convert network address string 'addr' (for example, "127.0.0.1") | |
| | | * into a network address object. Returns NULL on parse error. If | |
| | | * non-NULL, return value must be freed using ne_iaddr_free. */ | |
| | | ne_inet_addr *ne_iaddr_parse(const char *addr, ne_iaddr_type type); | |
| | | | |
| | | /* Destroy a network address object created using ne_iaddr_make or | |
| | | * ne_iaddr_parse. */ | |
| void ne_iaddr_free(ne_inet_addr *addr); | | void ne_iaddr_free(ne_inet_addr *addr); | |
| | | | |
| /* Create a socket object; returns NULL on error. */ | | /* Create a socket object; returns NULL on error. */ | |
| ne_socket *ne_sock_create(void); | | ne_socket *ne_sock_create(void); | |
| | | | |
| /* Specify an address to which the local end of the socket will be | | /* Specify an address to which the local end of the socket will be | |
| * bound during a subsequent ne_sock_connect() call. If the address | | * bound during a subsequent ne_sock_connect() call. If the address | |
| * passed to ne_sock_connect() is of a different type (family) to | | * passed to ne_sock_connect() is of a different type (family) to | |
| * 'addr', 'addr' is ignored. Either 'addr' may be NULL, to use the | | * 'addr', 'addr' is ignored. Either 'addr' may be NULL, to use the | |
| * given port with unspecified address, or 'port' may be 0, to use the | | * given port with unspecified address, or 'port' may be 0, to use the | |
| | | | |
| skipping to change at line 174 | | skipping to change at line 186 | |
| * NE_SOCK_TIMEOUT if no data arrives in 'n' seconds, | | * NE_SOCK_TIMEOUT if no data arrives in 'n' seconds, | |
| * 0 if data arrived on the socket. | | * 0 if data arrived on the socket. | |
| */ | | */ | |
| int ne_sock_block(ne_socket *sock, int n); | | int ne_sock_block(ne_socket *sock, int n); | |
| | | | |
| /* Write 'count' bytes of 'data' to the socket. Guarantees to either | | /* Write 'count' bytes of 'data' to the socket. Guarantees to either | |
| * write all the bytes or to fail. Returns 0 on success, or NE_SOCK_* | | * write all the bytes or to fail. Returns 0 on success, or NE_SOCK_* | |
| * on error. */ | | * on error. */ | |
| int ne_sock_fullwrite(ne_socket *sock, const char *data, size_t count); | | int ne_sock_fullwrite(ne_socket *sock, const char *data, size_t count); | |
| | | | |
|
| | | /* I/O vector. */ | |
| | | struct ne_iovec { | |
| | | void *base; | |
| | | size_t len; | |
| | | }; | |
| | | | |
| | | /* Writes 'count' blocks described by 'vector' to the socket. | |
| | | * Guarantees to either write all the bytes or to fail. Count must be | |
| | | * greater than zero and smaller than the system-defined maximum | |
| | | * vector limit. Returns 0 on success, or NE_SOCK_* on error. */ | |
| | | int ne_sock_fullwritev(ne_socket *sock, const struct ne_iovec *vector, | |
| | | int count); | |
| | | | |
| /* Read an LF-terminated line into 'buffer', and NUL-terminate it. | | /* Read an LF-terminated line into 'buffer', and NUL-terminate it. | |
| * At most 'len' bytes are read (including the NUL terminator). | | * At most 'len' bytes are read (including the NUL terminator). | |
| * Returns: | | * Returns: | |
| * NE_SOCK_* on error, | | * NE_SOCK_* on error, | |
| * >0 number of bytes read (including NUL terminator) | | * >0 number of bytes read (including NUL terminator) | |
| */ | | */ | |
| ssize_t ne_sock_readline(ne_socket *sock, char *buffer, size_t len); | | ssize_t ne_sock_readline(ne_socket *sock, char *buffer, size_t len); | |
| | | | |
| /* Read exactly 'len' bytes into buffer, or fail; returns 0 on | | /* Read exactly 'len' bytes into buffer, or fail; returns 0 on | |
| * success, NE_SOCK_* on error. */ | | * success, NE_SOCK_* on error. */ | |
| | | | |
| skipping to change at line 204 | | skipping to change at line 229 | |
| * must be destroyed by caller using ne_iaddr_free. */ | | * must be destroyed by caller using ne_iaddr_free. */ | |
| ne_inet_addr *ne_sock_peer(ne_socket *sock, unsigned int *port); | | ne_inet_addr *ne_sock_peer(ne_socket *sock, unsigned int *port); | |
| | | | |
| /* Close the socket and destroy the socket object. Returns zero on | | /* Close the socket and destroy the socket object. Returns zero on | |
| * success, or an errno value if close() failed. */ | | * success, or an errno value if close() failed. */ | |
| int ne_sock_close(ne_socket *sock); | | int ne_sock_close(ne_socket *sock); | |
| | | | |
| /* Return current error string for socket. */ | | /* Return current error string for socket. */ | |
| const char *ne_sock_error(const ne_socket *sock); | | const char *ne_sock_error(const ne_socket *sock); | |
| | | | |
|
| | | /* Set the error string for the socket; takes printf-like format | |
| | | * string. */ | |
| | | void ne_sock_set_error(ne_socket *sock, const char *format, ...) | |
| | | ne_attribute((format (printf, 2, 3))); | |
| | | | |
| /* Set read timeout for socket, in seconds; must be a non-zero | | /* Set read timeout for socket, in seconds; must be a non-zero | |
| * positive integer. */ | | * positive integer. */ | |
| void ne_sock_read_timeout(ne_socket *sock, int timeout); | | void ne_sock_read_timeout(ne_socket *sock, int timeout); | |
| | | | |
| /* Set connect timeout for socket, in seconds; must be a positive | | /* Set connect timeout for socket, in seconds; must be a positive | |
| * integer. If a timeout of 'zero' is used then then no explicit | | * integer. If a timeout of 'zero' is used then then no explicit | |
| * timeout handling will be used for ne_sock_connect(), and the | | * timeout handling will be used for ne_sock_connect(), and the | |
| * connect call will only timeout as dictated by the TCP stack. */ | | * connect call will only timeout as dictated by the TCP stack. */ | |
| void ne_sock_connect_timeout(ne_socket *sock, int timeout); | | void ne_sock_connect_timeout(ne_socket *sock, int timeout); | |
| | | | |
| | | | |
| skipping to change at line 239 | | skipping to change at line 269 | |
| * Returns zero on success, non-zero on error. */ | | * Returns zero on success, non-zero on error. */ | |
| int ne_sock_sessid(ne_socket *sock, unsigned char *buf, size_t *buflen); | | int ne_sock_sessid(ne_socket *sock, unsigned char *buf, size_t *buflen); | |
| | | | |
| /* Return human-readable name of SSL/TLS cipher used for connection, | | /* Return human-readable name of SSL/TLS cipher used for connection, | |
| * or NULL if none. The format of this string is not intended to be | | * or NULL if none. The format of this string is not intended to be | |
| * fixed or parseable, but is informational only. Return value is | | * fixed or parseable, but is informational only. Return value is | |
| * NUL-terminated malloc-allocated string if not NULL, which must be | | * NUL-terminated malloc-allocated string if not NULL, which must be | |
| * freed by the caller. */ | | * freed by the caller. */ | |
| char *ne_sock_cipher(ne_socket *sock); | | char *ne_sock_cipher(ne_socket *sock); | |
| | | | |
|
| | | /* SOCKS proxy protocol version: */ | |
| | | enum ne_sock_sversion { | |
| | | NE_SOCK_SOCKSV4 = 0, | |
| | | NE_SOCK_SOCKSV4A, | |
| | | NE_SOCK_SOCKSV5 | |
| | | }; | |
| | | | |
| | | /* Given a socket 'sock' which is connected to a SOCKS proxy, initiate | |
| | | * a connection to a destination server using that proxy, specified | |
| | | * either by network address or hostname, at given port 'port'. | |
| | | * | |
| | | * If 'vers' is NE_SOCKS_V4, addr must be an IPv4 address; hostname | |
| | | * and password are ignored; username must be non-NULL. | |
| | | * | |
| | | * If 'vers' is NE_SOCKS_V4A, hostname must be non-NULL; addr is | |
| | | * ignored; password is ignored; username must be non-NULL. | |
| | | * | |
| | | * If 'vers' is NE_SOCKS_V5, addr may be NULL, in which case hostname | |
| | | * must be non-NULL. addr if non-NULL may be an IPv4 or IPv6 address; | |
| | | * username may be NULL, in which case password is ignored. If | |
| | | * username is non-NULL password must also be non-NULL. | |
| | | * | |
| | | * Returns 0 on success, or NE_SOCK_* on failure - in which case, the | |
| | | * socket error string is set. On failure, the socket must be closed | |
| | | * by the caller. | |
| | | */ | |
| | | int ne_sock_proxy(ne_socket *sock, enum ne_sock_sversion vers, | |
| | | const ne_inet_addr *addr, const char *hostname, | |
| | | unsigned int port, | |
| | | const char *username, const char *password); | |
| | | | |
| NE_END_DECLS | | NE_END_DECLS | |
| | | | |
| #endif /* NE_SOCKET_H */ | | #endif /* NE_SOCKET_H */ | |
| | | | |
End of changes. 6 change blocks. |
| 2 lines changed or deleted | | 63 lines changed or added | |
|
| ne_string.h | | ne_string.h | |
| | | | |
| skipping to change at line 93 | | skipping to change at line 93 | |
| void ne_buffer_concat(ne_buffer *buf, ...) | | void ne_buffer_concat(ne_buffer *buf, ...) | |
| ne_attribute_sentinel; | | ne_attribute_sentinel; | |
| | | | |
| /* Append a NUL-terminated string 'str' to buf. */ | | /* Append a NUL-terminated string 'str' to buf. */ | |
| void ne_buffer_zappend(ne_buffer *buf, const char *str); | | void ne_buffer_zappend(ne_buffer *buf, const char *str); | |
| | | | |
| /* Append 'len' bytes of 'data' to buf, where 'data' does not contain | | /* Append 'len' bytes of 'data' to buf, where 'data' does not contain | |
| * a NUL terminator. (A NUL terminator is appended to buf) */ | | * a NUL terminator. (A NUL terminator is appended to buf) */ | |
| void ne_buffer_append(ne_buffer *buf, const char *data, size_t len); | | void ne_buffer_append(ne_buffer *buf, const char *data, size_t len); | |
| | | | |
|
| | | /* Append 'len' bytes of 'data' to buf. All non-ASCII bytes, and | |
| | | * ASCII control characters, are escaped. (Note that this includes | |
| | | * the NUL byte). */ | |
| | | void ne_buffer_qappend(ne_buffer *buf, const unsigned char *data, size_t le | |
| | | n); | |
| | | | |
| /* Print a string to the end of the buffer using printf-style format | | /* Print a string to the end of the buffer using printf-style format | |
| * string 'format' and subsqeuent arguments. At most 'max' characters | | * string 'format' and subsqeuent arguments. At most 'max' characters | |
| * are appended; the number of characters appended (excluding the NUL | | * are appended; the number of characters appended (excluding the NUL | |
| * terminator) is returned. Behaviour is undefined if 'max' is passed | | * terminator) is returned. Behaviour is undefined if 'max' is passed | |
| * as zero. */ | | * as zero. */ | |
| size_t ne_buffer_snprintf(ne_buffer *buf, size_t max, | | size_t ne_buffer_snprintf(ne_buffer *buf, size_t max, | |
| const char *format, ...) | | const char *format, ...) | |
| ne_attribute((format(printf, 3, 4))); | | ne_attribute((format(printf, 3, 4))); | |
| | | | |
| /* Append a literal, NUL-terminated constant string 'str' to buffer | | /* Append a literal, NUL-terminated constant string 'str' to buffer | |
| | | | |
| skipping to change at line 137 | | skipping to change at line 142 | |
| /* Thread-safe strerror() wrapper; place system error for errno value | | /* Thread-safe strerror() wrapper; place system error for errno value | |
| * 'errnum' in 'buffer', which is of length 'buflen'. Returns | | * 'errnum' in 'buffer', which is of length 'buflen'. Returns | |
| * 'buffer'. */ | | * 'buffer'. */ | |
| char *ne_strerror(int errnum, char *buffer, size_t buflen); | | char *ne_strerror(int errnum, char *buffer, size_t buflen); | |
| | | | |
| /* ne_strnzcpy copies at most 'n'-1 bytes of 'src' to 'dest', and | | /* ne_strnzcpy copies at most 'n'-1 bytes of 'src' to 'dest', and | |
| * ensures that 'dest' is subsequently NUL-terminated. */ | | * ensures that 'dest' is subsequently NUL-terminated. */ | |
| #define ne_strnzcpy(dest, src, n) do { size_t ne__nm1 = (n) - 1; \ | | #define ne_strnzcpy(dest, src, n) do { size_t ne__nm1 = (n) - 1; \ | |
| strncpy(dest, src, ne__nm1); dest[ne__nm1] = '\0'; } while (0) | | strncpy(dest, src, ne__nm1); dest[ne__nm1] = '\0'; } while (0) | |
| | | | |
|
| | | /* Return a malloc-allocated copy of 'data', of length 'len', with all | |
| | | * non-ASCII bytes, and ASCII control characters escaped. (Note that | |
| | | * the escaping includes the NUL byte). */ | |
| | | char *ne_strnqdup(const unsigned char *data, size_t len); | |
| | | | |
| /* Return malloc-allocated concatenation of all NUL-terminated string | | /* Return malloc-allocated concatenation of all NUL-terminated string | |
| * arguments, up to a terminating NULL pointer. */ | | * arguments, up to a terminating NULL pointer. */ | |
| char *ne_concat(const char *str, ...) | | char *ne_concat(const char *str, ...) | |
| ne_attribute_sentinel; | | ne_attribute_sentinel; | |
| | | | |
| /* Wrapper for snprintf: always NUL-terminates returned buffer, and | | /* Wrapper for snprintf: always NUL-terminates returned buffer, and | |
| * returns strlen(str). */ | | * returns strlen(str). */ | |
| size_t ne_snprintf(char *str, size_t size, const char *fmt, ...) | | size_t ne_snprintf(char *str, size_t size, const char *fmt, ...) | |
| ne_attribute((format(printf, 3, 4))); | | ne_attribute((format(printf, 3, 4))); | |
| | | | |
| | | | |
End of changes. 2 change blocks. |
| 0 lines changed or deleted | | 11 lines changed or added | |
|