2 * "$Id: http-private.h 6649 2007-07-11 21:46:42Z mike $"
4 * Private HTTP definitions for the Common UNIX Printing System (CUPS).
6 * Copyright 2007 by Apple Inc.
7 * Copyright 1997-2007 by Easy Software Products, all rights reserved.
9 * These coded instructions, statements, and computer programs are the
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/".
15 * This file is subject to the Apple OS-Developed Software exception.
18 #ifndef _CUPS_HTTP_PRIVATE_H_
19 # define _CUPS_HTTP_PRIVATE_H_
22 * Include necessary headers...
30 * Define FD_SETSIZE to CUPS_MAX_FDS on Solaris to get the correct version of
31 * select() for large numbers of file descriptors.
34 # define FD_SETSIZE CUPS_MAX_FDS
35 # include <sys/select.h>
41 # include <winsock2.h>
45 # include <sys/socket.h>
46 # define closesocket(f) close(f)
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 */
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 */
65 # endif /* HAVE_GSSAPI */
67 # ifdef HAVE_AUTHORIZATION_H
68 # include <Security/Authorization.h>
69 # endif /* HAVE_AUTHORIZATION_H */
71 # if defined(__sgi) || (defined(__APPLE__) && !defined(_SOCKLEN_T))
73 * IRIX and MacOS X 10.2.x do not define socklen_t, and in fact use an int instead of
74 * unsigned type for length values...
77 typedef int socklen_t
;
78 # endif /* __sgi || (__APPLE__ && !_SOCKLEN_T) */
82 # include "ipp-private.h"
84 # if defined HAVE_LIBSSL
86 * The OpenSSL library provides its own SSL/TLS context structure for its
87 * IO and protocol management. However, we need to provide our own BIO
88 * (basic IO) implementation to do timeouts...
91 # include <openssl/err.h>
92 # include <openssl/rand.h>
93 # include <openssl/ssl.h>
95 typedef SSL http_tls_t
;
97 extern BIO_METHOD
*_httpBIOMethods(void);
99 # elif defined HAVE_GNUTLS
101 * The GNU TLS library is more of a "bare metal" SSL/TLS library...
103 # include <gnutls/gnutls.h>
107 gnutls_session session
; /* GNU TLS session object */
108 void *credentials
; /* GNU TLS credentials object */
111 extern ssize_t
_httpReadGNUTLS(gnutls_transport_ptr ptr
, void *data
,
113 extern ssize_t
_httpWriteGNUTLS(gnutls_transport_ptr ptr
, const void *data
,
116 # elif defined(HAVE_CDSASSL)
118 * Darwin's Security framework provides its own SSL/TLS context structure
119 * for its IO and protocol management...
122 # include <Security/SecureTransport.h>
124 typedef struct /**** CDSA connection information ****/
126 SSLContextRef session
; /* CDSA session object */
127 CFArrayRef certsArray
; /* Certificates array */
130 extern OSStatus
_httpReadCDSA(SSLConnectionRef connection
, void *data
,
132 extern OSStatus
_httpWriteCDSA(SSLConnectionRef connection
, const void *data
,
134 # endif /* HAVE_LIBSSL */
137 struct _http_s
/**** HTTP connection structure. ****/
139 int fd
; /* File descriptor for this socket */
140 int blocking
; /* To block or not to block */
141 int error
; /* Last error on read */
142 time_t activity
; /* Time since last read/write */
143 http_state_t state
; /* State of client */
144 http_status_t status
; /* Status of last request */
145 http_version_t version
; /* Protocol version */
146 http_keepalive_t keep_alive
; /* Keep-alive supported? */
147 struct sockaddr_in _hostaddr
; /* Address of connected host @deprecated@ */
148 char hostname
[HTTP_MAX_HOST
],
149 /* Name of connected host */
150 fields
[HTTP_FIELD_MAX
][HTTP_MAX_VALUE
];
152 char *data
; /* Pointer to data buffer */
153 http_encoding_t data_encoding
; /* Chunked or not */
154 int _data_remaining
;/* Number of bytes left @deprecated@ */
155 int used
; /* Number of bytes used in buffer */
156 char buffer
[HTTP_MAX_BUFFER
];
157 /* Buffer for incoming data */
158 int auth_type
; /* Authentication in use */
159 _cups_md5_state_t md5_state
; /* MD5 state */
160 char nonce
[HTTP_MAX_VALUE
];
162 int nonce_count
; /* Nonce count */
163 void *tls
; /* TLS state information */
164 http_encryption_t encryption
; /* Encryption requirements */
165 /**** New in CUPS 1.1.19 ****/
166 fd_set
*input_set
; /* select() set for httpWait() @deprecated@ */
167 http_status_t expect
; /* Expect: header @since CUPS 1.1.19@ */
168 char *cookie
; /* Cookie value(s) @since CUPS 1.1.19@ */
169 /**** New in CUPS 1.1.20 ****/
170 char _authstring
[HTTP_MAX_VALUE
],
171 /* Current Authentication value. @deprecated@ */
172 userpass
[HTTP_MAX_VALUE
];
173 /* Username:password string @since CUPS 1.1.20@ */
174 int digest_tries
; /* Number of tries for digest auth @since CUPS 1.1.20@ */
175 /**** New in CUPS 1.2 ****/
176 off_t data_remaining
; /* Number of bytes left @since CUPS 1.2@ */
177 http_addr_t
*hostaddr
; /* Current host address and port @since CUPS 1.2@ */
178 http_addrlist_t
*addrlist
; /* List of valid addresses @since CUPS 1.2@ */
179 char wbuffer
[HTTP_MAX_BUFFER
];
180 /* Buffer for outgoing data */
181 int wused
; /* Write buffer bytes used @since CUPS 1.2@ */
182 /**** New in CUPS 1.3 ****/
183 char *field_authorization
;
184 /* Authorization field @since CUPS 1.3@ */
185 char *authstring
; /* Current authorization field @since CUPS 1.3 */
187 gss_OID gssmech
; /* Authentication mechanism @since CUPS 1.3@ */
188 gss_ctx_id_t gssctx
; /* Authentication context @since CUPS 1.3@ */
189 gss_name_t gssname
; /* Authentication server name @since CUPS 1.3@ */
190 # endif /* HAVE_GSSAPI */
191 # ifdef HAVE_AUTHORIZATION_H
192 AuthorizationRef auth_ref
; /* Authorization ref */
193 # endif /* HAVE_AUTHORIZATION_H */
198 * Some OS's don't have hstrerror(), most notably Solaris...
201 # ifndef HAVE_HSTRERROR
202 extern const char *_cups_hstrerror(int error
);
203 # define hstrerror _cups_hstrerror
204 # elif defined(_AIX) || defined(__osf__)
206 * AIX and Tru64 UNIX don't provide a prototype but do provide the function...
208 extern const char *hstrerror(int error
);
209 # endif /* !HAVE_HSTRERROR */
213 * Some OS's don't have getifaddrs() and freeifaddrs()...
218 # ifdef HAVE_GETIFADDRS
219 # include <ifaddrs.h>
221 # include <sys/ioctl.h>
222 # ifdef HAVE_SYS_SOCKIO_H
223 # include <sys/sockio.h>
224 # endif /* HAVE_SYS_SOCKIO_H */
228 # endif /* ifa_dstaddr */
230 # define ifr_netmask ifr_addr
231 # endif /* !ifr_netmask */
233 struct ifaddrs
/**** Interface Structure ****/
235 struct ifaddrs
*ifa_next
; /* Next interface in list */
236 char *ifa_name
; /* Name of interface */
237 unsigned int ifa_flags
; /* Flags (up, point-to-point, etc.) */
238 struct sockaddr
*ifa_addr
, /* Network address */
239 *ifa_netmask
; /* Address mask */
242 struct sockaddr
*ifu_broadaddr
; /* Broadcast address of this interface. */
243 struct sockaddr
*ifu_dstaddr
; /* Point-to-point destination address. */
246 void *ifa_data
; /* Interface statistics */
249 # ifndef ifa_broadaddr
250 # define ifa_broadaddr ifa_ifu.ifu_broadaddr
251 # endif /* !ifa_broadaddr */
253 # define ifa_dstaddr ifa_ifu.ifu_dstaddr
254 # endif /* !ifa_dstaddr */
256 extern int _cups_getifaddrs(struct ifaddrs
**addrs
);
257 # define getifaddrs _cups_getifaddrs
258 extern void _cups_freeifaddrs(struct ifaddrs
*addrs
);
259 # define freeifaddrs _cups_freeifaddrs
260 # endif /* HAVE_GETIFADDRS */
263 #endif /* !_CUPS_HTTP_PRIVATE_H_ */
266 * End of "$Id: http-private.h 6649 2007-07-11 21:46:42Z mike $".