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