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