2 * "$Id: http-private.h 6499 2007-04-30 21:44:43Z mike $"
4 * Private HTTP definitions for the Common UNIX Printing System (CUPS).
6 * Copyright 1997-2007 by Easy Software Products, all rights reserved.
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
15 * Attn: CUPS Licensing Information
16 * Easy Software Products
17 * 44141 Airport View Drive, Suite 204
18 * Hollywood, Maryland 20636 USA
20 * Voice: (301) 373-9600
21 * EMail: cups-info@cups.org
22 * WWW: http://www.cups.org
24 * This file is subject to the Apple OS-Developed Software exception.
27 #ifndef _CUPS_HTTP_PRIVATE_H_
28 # define _CUPS_HTTP_PRIVATE_H_
31 * Include necessary headers...
39 * Define FD_SETSIZE to CUPS_MAX_FDS on Solaris to get the correct version of
40 * select() for large numbers of file descriptors.
43 # define FD_SETSIZE CUPS_MAX_FDS
44 # include <sys/select.h>
50 # include <winsock2.h>
54 # include <sys/socket.h>
55 # define closesocket(f) close(f)
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 */
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 */
76 # ifdef HAVE_AUTHORIZATION_H
77 # include <Security/Authorization.h>
78 # endif /* HAVE_AUTHORIZATION_H */
80 # if defined(__sgi) || (defined(__APPLE__) && !defined(_SOCKLEN_T))
82 * IRIX and MacOS X 10.2.x do not define socklen_t, and in fact use an int instead of
83 * unsigned type for length values...
86 typedef int socklen_t
;
87 # endif /* __sgi || (__APPLE__ && !_SOCKLEN_T) */
91 # include "ipp-private.h"
93 # if defined HAVE_LIBSSL
95 * The OpenSSL library provides its own SSL/TLS context structure for its
96 * IO and protocol management. However, we need to provide our own BIO
97 * (basic IO) implementation to do timeouts...
100 # include <openssl/err.h>
101 # include <openssl/rand.h>
102 # include <openssl/ssl.h>
104 typedef SSL http_tls_t
;
106 extern BIO_METHOD
*_httpBIOMethods(void);
108 # elif defined HAVE_GNUTLS
110 * The GNU TLS library is more of a "bare metal" SSL/TLS library...
112 # include <gnutls/gnutls.h>
116 gnutls_session session
; /* GNU TLS session object */
117 void *credentials
; /* GNU TLS credentials object */
120 extern ssize_t
_httpReadGNUTLS(gnutls_transport_ptr ptr
, void *data
,
122 extern ssize_t
_httpWriteGNUTLS(gnutls_transport_ptr ptr
, const void *data
,
125 # elif defined(HAVE_CDSASSL)
127 * Darwin's Security framework provides its own SSL/TLS context structure
128 * for its IO and protocol management...
131 # include <Security/SecureTransport.h>
133 typedef struct /**** CDSA connection information ****/
135 SSLContextRef session
; /* CDSA session object */
136 CFArrayRef certsArray
; /* Certificates array */
139 extern OSStatus
_httpReadCDSA(SSLConnectionRef connection
, void *data
,
141 extern OSStatus
_httpWriteCDSA(SSLConnectionRef connection
, const void *data
,
143 # endif /* HAVE_LIBSSL */
146 struct _http_s
/**** HTTP connection structure. ****/
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
];
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
];
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 */
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 */
200 # ifdef HAVE_AUTHORIZATION_H
201 AuthorizationRef auth_ref
; /* Authorization ref */
202 # endif /* HAVE_AUTHORIZATION_H */
207 * Some OS's don't have hstrerror(), most notably Solaris...
210 # ifndef HAVE_HSTRERROR
211 extern const char *_cups_hstrerror(int error
);
212 # define hstrerror _cups_hstrerror
213 # elif defined(_AIX) || defined(__osf__)
215 * AIX and Tru64 UNIX don't provide a prototype but do provide the function...
217 extern const char *hstrerror(int error
);
218 # endif /* !HAVE_HSTRERROR */
222 * Some OS's don't have getifaddrs() and freeifaddrs()...
227 # ifdef HAVE_GETIFADDRS
228 # include <ifaddrs.h>
230 # include <sys/ioctl.h>
231 # ifdef HAVE_SYS_SOCKIO_H
232 # include <sys/sockio.h>
233 # endif /* HAVE_SYS_SOCKIO_H */
237 # endif /* ifa_dstaddr */
239 # define ifr_netmask ifr_addr
240 # endif /* !ifr_netmask */
242 struct ifaddrs
/**** Interface Structure ****/
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 */
248 *ifa_netmask
; /* Address mask */
251 struct sockaddr
*ifu_broadaddr
; /* Broadcast address of this interface. */
252 struct sockaddr
*ifu_dstaddr
; /* Point-to-point destination address. */
255 void *ifa_data
; /* Interface statistics */
258 # ifndef ifa_broadaddr
259 # define ifa_broadaddr ifa_ifu.ifu_broadaddr
260 # endif /* !ifa_broadaddr */
262 # define ifa_dstaddr ifa_ifu.ifu_dstaddr
263 # endif /* !ifa_dstaddr */
265 extern int _cups_getifaddrs(struct ifaddrs
**addrs
);
266 # define getifaddrs _cups_getifaddrs
267 extern void _cups_freeifaddrs(struct ifaddrs
*addrs
);
268 # define freeifaddrs _cups_freeifaddrs
269 # endif /* HAVE_GETIFADDRS */
272 #endif /* !_CUPS_HTTP_PRIVATE_H_ */
275 * End of "$Id: http-private.h 6499 2007-04-30 21:44:43Z mike $".