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