]> git.ipfire.org Git - thirdparty/cups.git/blame - cups/http-private.h
Merge changes from CUPS 1.5svn-r9105.
[thirdparty/cups.git] / cups / http-private.h
CommitLineData
ef416fc2 1/*
b19ccc9e 2 * "$Id: http-private.h 7850 2008-08-20 00:07:25Z mike $"
ef416fc2 3 *
71e16022 4 * Private HTTP definitions for CUPS.
ef416fc2 5 *
71e16022 6 * Copyright 2007-2010 by Apple Inc.
b86bc4cf 7 * Copyright 1997-2007 by Easy Software Products, all rights reserved.
ef416fc2 8 *
9 * These coded instructions, statements, and computer programs are the
bc44d920 10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
ef416fc2 14 *
15 * This file is subject to the Apple OS-Developed Software exception.
16 */
17
18#ifndef _CUPS_HTTP_PRIVATE_H_
19# define _CUPS_HTTP_PRIVATE_H_
20
21/*
22 * Include necessary headers...
23 */
24
71e16022 25# include "config.h"
5180a04c 26# include <stddef.h>
a74454a7 27# include <stdlib.h>
ef416fc2 28
29# ifdef __sun
ef416fc2 30# include <sys/select.h>
31# endif /* __sun */
32
33# include <limits.h>
34# ifdef WIN32
35# include <io.h>
36# include <winsock2.h>
37# else
38# include <unistd.h>
39# include <fcntl.h>
40# include <sys/socket.h>
41# define closesocket(f) close(f)
42# endif /* WIN32 */
43
f7deaa1a 44# ifdef HAVE_GSSAPI
45# ifdef HAVE_GSSAPI_GSSAPI_H
46# include <gssapi/gssapi.h>
47# endif /* HAVE_GSSAPI_GSSAPI_H */
48# ifdef HAVE_GSSAPI_GSSAPI_GENERIC_H
49# include <gssapi/gssapi_generic.h>
50# endif /* HAVE_GSSAPI_GSSAPI_GENERIC_H */
51# ifdef HAVE_GSSAPI_GSSAPI_KRB5_H
52# include <gssapi/gssapi_krb5.h>
53# endif /* HAVE_GSSAPI_GSSAPI_KRB5_H */
54# ifdef HAVE_GSSAPI_H
55# include <gssapi.h>
56# endif /* HAVE_GSSAPI_H */
57# ifndef HAVE_GSS_C_NT_HOSTBASED_SERVICE
58# define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name
59# endif /* !HAVE_GSS_C_NT_HOSTBASED_SERVICE */
db1f069b
MS
60# ifdef HAVE_KRB5_H
61# include <krb5.h>
62# endif /* HAVE_KRB5_H */
f7deaa1a 63# endif /* HAVE_GSSAPI */
64
b94498cf 65# ifdef HAVE_AUTHORIZATION_H
66# include <Security/Authorization.h>
67# endif /* HAVE_AUTHORIZATION_H */
68
4400e98d 69# if defined(__sgi) || (defined(__APPLE__) && !defined(_SOCKLEN_T))
ef416fc2 70/*
4400e98d 71 * IRIX and MacOS X 10.2.x do not define socklen_t, and in fact use an int instead of
ef416fc2 72 * unsigned type for length values...
73 */
74
75typedef int socklen_t;
4400e98d 76# endif /* __sgi || (__APPLE__ && !_SOCKLEN_T) */
ef416fc2 77
71e16022
MS
78# include <cups/http.h>
79# include "md5-private.h"
fa73b229 80# include "ipp-private.h"
ef416fc2 81
82# if defined HAVE_LIBSSL
83/*
84 * The OpenSSL library provides its own SSL/TLS context structure for its
411affcf 85 * IO and protocol management. However, we need to provide our own BIO
86 * (basic IO) implementation to do timeouts...
ef416fc2 87 */
88
89# include <openssl/err.h>
90# include <openssl/rand.h>
91# include <openssl/ssl.h>
92
93typedef SSL http_tls_t;
94
411affcf 95extern BIO_METHOD *_httpBIOMethods(void);
96
ef416fc2 97# elif defined HAVE_GNUTLS
98/*
99 * The GNU TLS library is more of a "bare metal" SSL/TLS library...
100 */
101# include <gnutls/gnutls.h>
6d2f911b 102# include <gcrypt.h>
ef416fc2 103
104typedef struct
105{
106 gnutls_session session; /* GNU TLS session object */
107 void *credentials; /* GNU TLS credentials object */
108} http_tls_t;
109
411affcf 110extern ssize_t _httpReadGNUTLS(gnutls_transport_ptr ptr, void *data,
111 size_t length);
112extern ssize_t _httpWriteGNUTLS(gnutls_transport_ptr ptr, const void *data,
113 size_t length);
114
ef416fc2 115# elif defined(HAVE_CDSASSL)
116/*
117 * Darwin's Security framework provides its own SSL/TLS context structure
118 * for its IO and protocol management...
119 */
120
121# include <Security/SecureTransport.h>
122
89d46774 123typedef struct /**** CDSA connection information ****/
124{
125 SSLContextRef session; /* CDSA session object */
126 CFArrayRef certsArray; /* Certificates array */
127} http_tls_t;
ef416fc2 128
129extern OSStatus _httpReadCDSA(SSLConnectionRef connection, void *data,
130 size_t *dataLength);
131extern OSStatus _httpWriteCDSA(SSLConnectionRef connection, const void *data,
132 size_t *dataLength);
133# endif /* HAVE_LIBSSL */
134
f7deaa1a 135
136struct _http_s /**** HTTP connection structure. ****/
137{
138 int fd; /* File descriptor for this socket */
139 int blocking; /* To block or not to block */
140 int error; /* Last error on read */
141 time_t activity; /* Time since last read/write */
142 http_state_t state; /* State of client */
143 http_status_t status; /* Status of last request */
144 http_version_t version; /* Protocol version */
145 http_keepalive_t keep_alive; /* Keep-alive supported? */
146 struct sockaddr_in _hostaddr; /* Address of connected host @deprecated@ */
147 char hostname[HTTP_MAX_HOST],
148 /* Name of connected host */
149 fields[HTTP_FIELD_MAX][HTTP_MAX_VALUE];
150 /* Field values */
151 char *data; /* Pointer to data buffer */
152 http_encoding_t data_encoding; /* Chunked or not */
153 int _data_remaining;/* Number of bytes left @deprecated@ */
154 int used; /* Number of bytes used in buffer */
155 char buffer[HTTP_MAX_BUFFER];
156 /* Buffer for incoming data */
157 int auth_type; /* Authentication in use */
158 _cups_md5_state_t md5_state; /* MD5 state */
159 char nonce[HTTP_MAX_VALUE];
160 /* Nonce value */
161 int nonce_count; /* Nonce count */
162 void *tls; /* TLS state information */
163 http_encryption_t encryption; /* Encryption requirements */
164 /**** New in CUPS 1.1.19 ****/
165 fd_set *input_set; /* select() set for httpWait() @deprecated@ */
166 http_status_t expect; /* Expect: header @since CUPS 1.1.19@ */
167 char *cookie; /* Cookie value(s) @since CUPS 1.1.19@ */
168 /**** New in CUPS 1.1.20 ****/
169 char _authstring[HTTP_MAX_VALUE],
170 /* Current Authentication value. @deprecated@ */
171 userpass[HTTP_MAX_VALUE];
172 /* Username:password string @since CUPS 1.1.20@ */
173 int digest_tries; /* Number of tries for digest auth @since CUPS 1.1.20@ */
174 /**** New in CUPS 1.2 ****/
175 off_t data_remaining; /* Number of bytes left @since CUPS 1.2@ */
176 http_addr_t *hostaddr; /* Current host address and port @since CUPS 1.2@ */
177 http_addrlist_t *addrlist; /* List of valid addresses @since CUPS 1.2@ */
178 char wbuffer[HTTP_MAX_BUFFER];
179 /* Buffer for outgoing data */
180 int wused; /* Write buffer bytes used @since CUPS 1.2@ */
181 /**** New in CUPS 1.3 ****/
182 char *field_authorization;
183 /* Authorization field @since CUPS 1.3@ */
184 char *authstring; /* Current authorization field @since CUPS 1.3 */
185# ifdef HAVE_GSSAPI
186 gss_OID gssmech; /* Authentication mechanism @since CUPS 1.3@ */
187 gss_ctx_id_t gssctx; /* Authentication context @since CUPS 1.3@ */
188 gss_name_t gssname; /* Authentication server name @since CUPS 1.3@ */
189# endif /* HAVE_GSSAPI */
b94498cf 190# ifdef HAVE_AUTHORIZATION_H
191 AuthorizationRef auth_ref; /* Authorization ref */
192# endif /* HAVE_AUTHORIZATION_H */
f7deaa1a 193};
194
195
ef416fc2 196/*
197 * Some OS's don't have hstrerror(), most notably Solaris...
198 */
199
200# ifndef HAVE_HSTRERROR
201extern const char *_cups_hstrerror(int error);
202# define hstrerror _cups_hstrerror
203# elif defined(_AIX) || defined(__osf__)
204/*
205 * AIX and Tru64 UNIX don't provide a prototype but do provide the function...
206 */
207extern const char *hstrerror(int error);
208# endif /* !HAVE_HSTRERROR */
209
89d46774 210
211/*
212 * Some OS's don't have getifaddrs() and freeifaddrs()...
213 */
214
b86bc4cf 215# ifndef WIN32
216# include <net/if.h>
217# ifdef HAVE_GETIFADDRS
218# include <ifaddrs.h>
219# else
220# include <sys/ioctl.h>
221# ifdef HAVE_SYS_SOCKIO_H
222# include <sys/sockio.h>
223# endif /* HAVE_SYS_SOCKIO_H */
224
225# ifdef ifa_dstaddr
226# undef ifa_dstaddr
227# endif /* ifa_dstaddr */
228# ifndef ifr_netmask
229# define ifr_netmask ifr_addr
230# endif /* !ifr_netmask */
89d46774 231
232struct ifaddrs /**** Interface Structure ****/
233{
234 struct ifaddrs *ifa_next; /* Next interface in list */
235 char *ifa_name; /* Name of interface */
236 unsigned int ifa_flags; /* Flags (up, point-to-point, etc.) */
237 struct sockaddr *ifa_addr, /* Network address */
f301802f 238 *ifa_netmask; /* Address mask */
239 union
240 {
241 struct sockaddr *ifu_broadaddr; /* Broadcast address of this interface. */
242 struct sockaddr *ifu_dstaddr; /* Point-to-point destination address. */
243 } ifa_ifu;
244
89d46774 245 void *ifa_data; /* Interface statistics */
246};
247
b86bc4cf 248# ifndef ifa_broadaddr
249# define ifa_broadaddr ifa_ifu.ifu_broadaddr
250# endif /* !ifa_broadaddr */
251# ifndef ifa_dstaddr
252# define ifa_dstaddr ifa_ifu.ifu_dstaddr
253# endif /* !ifa_dstaddr */
f301802f 254
a74454a7 255extern int _cups_getifaddrs(struct ifaddrs **addrs);
b86bc4cf 256# define getifaddrs _cups_getifaddrs
a74454a7 257extern void _cups_freeifaddrs(struct ifaddrs *addrs);
b86bc4cf 258# define freeifaddrs _cups_freeifaddrs
259# endif /* HAVE_GETIFADDRS */
260# endif /* !WIN32 */
89d46774 261
839a51c8 262/*
1ff0402e 263 * Prototypes...
839a51c8
MS
264 */
265
1ff0402e
MS
266extern int _httpAddrPort(http_addr_t *addr);
267extern http_t *_httpCreate(const char *host, int port,
268 http_encryption_t encryption);
6d2f911b 269extern void _httpDisconnect(http_t *http);
5eb9da71
MS
270extern char *_httpEncodeURI(char *dst, const char *src,
271 size_t dstsize);
6d2f911b 272extern ssize_t _httpPeek(http_t *http, char *buffer, size_t length);
5eb9da71 273extern const char *_httpResolveURI(const char *uri, char *resolved_uri,
1f0275e3 274 size_t resolved_size, int log);
38e73f87 275extern int _httpWait(http_t *http, int msec, int usessl);
6d2f911b
MS
276
277
ef416fc2 278#endif /* !_CUPS_HTTP_PRIVATE_H_ */
279
280/*
b19ccc9e 281 * End of "$Id: http-private.h 7850 2008-08-20 00:07:25Z mike $".
ef416fc2 282 */