2 * "$Id: http-private.h 6187 2007-01-10 16:20:42Z 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 # if defined(__sgi) || (defined(__APPLE__) && !defined(_SOCKLEN_T))
78 * IRIX and MacOS X 10.2.x do not define socklen_t, and in fact use an int instead of
79 * unsigned type for length values...
82 typedef int socklen_t
;
83 # endif /* __sgi || (__APPLE__ && !_SOCKLEN_T) */
87 # include "ipp-private.h"
89 # if defined HAVE_LIBSSL
91 * The OpenSSL library provides its own SSL/TLS context structure for its
92 * IO and protocol management. However, we need to provide our own BIO
93 * (basic IO) implementation to do timeouts...
96 # include <openssl/err.h>
97 # include <openssl/rand.h>
98 # include <openssl/ssl.h>
100 typedef SSL http_tls_t
;
102 extern BIO_METHOD
*_httpBIOMethods(void);
104 # elif defined HAVE_GNUTLS
106 * The GNU TLS library is more of a "bare metal" SSL/TLS library...
108 # include <gnutls/gnutls.h>
112 gnutls_session session
; /* GNU TLS session object */
113 void *credentials
; /* GNU TLS credentials object */
116 extern ssize_t
_httpReadGNUTLS(gnutls_transport_ptr ptr
, void *data
,
118 extern ssize_t
_httpWriteGNUTLS(gnutls_transport_ptr ptr
, const void *data
,
121 # elif defined(HAVE_CDSASSL)
123 * Darwin's Security framework provides its own SSL/TLS context structure
124 * for its IO and protocol management...
127 # include <Security/SecureTransport.h>
129 typedef struct /**** CDSA connection information ****/
131 SSLContextRef session
; /* CDSA session object */
132 CFArrayRef certsArray
; /* Certificates array */
135 extern OSStatus
_httpReadCDSA(SSLConnectionRef connection
, void *data
,
137 extern OSStatus
_httpWriteCDSA(SSLConnectionRef connection
, const void *data
,
139 # endif /* HAVE_LIBSSL */
142 struct _http_s
/**** HTTP connection structure. ****/
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
];
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
];
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 ****/
171 fd_set
*input_set
; /* select() set for httpWait() @deprecated@ */
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 ****/
175 char _authstring
[HTTP_MAX_VALUE
],
176 /* Current Authentication value. @deprecated@ */
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@ */
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 */
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 */
200 * Some OS's don't have hstrerror(), most notably Solaris...
203 # ifndef HAVE_HSTRERROR
204 extern const char *_cups_hstrerror(int error
);
205 # define hstrerror _cups_hstrerror
206 # elif defined(_AIX) || defined(__osf__)
208 * AIX and Tru64 UNIX don't provide a prototype but do provide the function...
210 extern const char *hstrerror(int error
);
211 # endif /* !HAVE_HSTRERROR */
215 * Some OS's don't have getifaddrs() and freeifaddrs()...
220 # ifdef HAVE_GETIFADDRS
221 # include <ifaddrs.h>
223 # include <sys/ioctl.h>
224 # ifdef HAVE_SYS_SOCKIO_H
225 # include <sys/sockio.h>
226 # endif /* HAVE_SYS_SOCKIO_H */
230 # endif /* ifa_dstaddr */
232 # define ifr_netmask ifr_addr
233 # endif /* !ifr_netmask */
235 struct ifaddrs
/**** Interface Structure ****/
237 struct ifaddrs
*ifa_next
; /* Next interface in list */
238 char *ifa_name
; /* Name of interface */
239 unsigned int ifa_flags
; /* Flags (up, point-to-point, etc.) */
240 struct sockaddr
*ifa_addr
, /* Network address */
241 *ifa_netmask
; /* Address mask */
244 struct sockaddr
*ifu_broadaddr
; /* Broadcast address of this interface. */
245 struct sockaddr
*ifu_dstaddr
; /* Point-to-point destination address. */
248 void *ifa_data
; /* Interface statistics */
251 # ifndef ifa_broadaddr
252 # define ifa_broadaddr ifa_ifu.ifu_broadaddr
253 # endif /* !ifa_broadaddr */
255 # define ifa_dstaddr ifa_ifu.ifu_dstaddr
256 # endif /* !ifa_dstaddr */
258 extern int _cups_getifaddrs(struct ifaddrs
**addrs
);
259 # define getifaddrs _cups_getifaddrs
260 extern void _cups_freeifaddrs(struct ifaddrs
*addrs
);
261 # define freeifaddrs _cups_freeifaddrs
262 # endif /* HAVE_GETIFADDRS */
265 #endif /* !_CUPS_HTTP_PRIVATE_H_ */
268 * End of "$Id: http-private.h 6187 2007-01-10 16:20:42Z mike $".