2 * "$Id: http-private.h 181 2006-06-22 20:01:18Z jlovell $"
4 * Private HTTP definitions for the Common UNIX Printing System (CUPS).
6 * Copyright 1997-2005 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)
58 # if defined(__sgi) || (defined(__APPLE__) && !defined(_SOCKLEN_T))
60 * IRIX and MacOS X 10.2.x do not define socklen_t, and in fact use an int instead of
61 * unsigned type for length values...
64 typedef int socklen_t
;
65 # endif /* __sgi || (__APPLE__ && !_SOCKLEN_T) */
68 # include "ipp-private.h"
70 # if defined HAVE_LIBSSL
72 * The OpenSSL library provides its own SSL/TLS context structure for its
73 * IO and protocol management...
76 # include <openssl/err.h>
77 # include <openssl/rand.h>
78 # include <openssl/ssl.h>
80 typedef SSL http_tls_t
;
82 # elif defined HAVE_GNUTLS
84 * The GNU TLS library is more of a "bare metal" SSL/TLS library...
86 # include <gnutls/gnutls.h>
90 gnutls_session session
; /* GNU TLS session object */
91 void *credentials
; /* GNU TLS credentials object */
94 # elif defined(HAVE_CDSASSL)
96 * Darwin's Security framework provides its own SSL/TLS context structure
97 * for its IO and protocol management...
100 # include <Security/SecureTransport.h>
102 typedef struct /**** CDSA connection information ****/
104 SSLContextRef session
; /* CDSA session object */
105 CFArrayRef certsArray
; /* Certificates array */
108 typedef union _cdsa_conn_ref_u
/**** CDSA Connection reference union
109 **** used to resolve 64-bit casting
113 SSLConnectionRef connection
; /* SSL connection pointer */
114 int sock
; /* Socket */
117 extern OSStatus
_httpReadCDSA(SSLConnectionRef connection
, void *data
,
119 extern OSStatus
_httpWriteCDSA(SSLConnectionRef connection
, const void *data
,
121 # endif /* HAVE_LIBSSL */
124 struct _http_s
/**** HTTP connection structure. ****/
126 int fd
; /* File descriptor for this socket */
127 int blocking
; /* To block or not to block */
128 int error
; /* Last error on read */
129 time_t activity
; /* Time since last read/write */
130 http_state_t state
; /* State of client */
131 http_status_t status
; /* Status of last request */
132 http_version_t version
; /* Protocol version */
133 http_keepalive_t keep_alive
; /* Keep-alive supported? */
134 struct sockaddr_in _hostaddr
; /* Address of connected host @deprecated@ */
135 char hostname
[HTTP_MAX_HOST
],
136 /* Name of connected host */
137 fields
[HTTP_FIELD_MAX
][HTTP_MAX_VALUE
];
139 char *data
; /* Pointer to data buffer */
140 http_encoding_t data_encoding
; /* Chunked or not */
141 int _data_remaining
;/* Number of bytes left @deprecated@ */
142 int used
; /* Number of bytes used in buffer */
143 char buffer
[HTTP_MAX_BUFFER
];
144 /* Buffer for incoming data */
145 int auth_type
; /* Authentication in use */
146 _cups_md5_state_t md5_state
; /* MD5 state */
147 char nonce
[HTTP_MAX_VALUE
];
149 int nonce_count
; /* Nonce count */
150 void *tls
; /* TLS state information */
151 http_encryption_t encryption
; /* Encryption requirements */
152 /**** New in CUPS 1.1.19 ****/
153 fd_set
*input_set
; /* select() set for httpWait() @since CUPS 1.1.19@ */
154 http_status_t expect
; /* Expect: header @since CUPS 1.1.19@ */
155 char *cookie
; /* Cookie value(s) @since CUPS 1.1.19@ */
156 /**** New in CUPS 1.1.20 ****/
157 char authstring
[HTTP_MAX_VALUE
],
158 /* Current Authentication value @since CUPS 1.1.20@ */
159 userpass
[HTTP_MAX_VALUE
];
160 /* Username:password string @since CUPS 1.1.20@ */
161 int digest_tries
; /* Number of tries for digest auth @since CUPS 1.1.20@ */
162 /**** New in CUPS 1.2 ****/
163 off_t data_remaining
; /* Number of bytes left @since CUPS 1.2@ */
164 http_addr_t
*hostaddr
; /* Current host address and port @since CUPS 1.2@ */
165 http_addrlist_t
*addrlist
; /* List of valid addresses @since CUPS 1.2@ */
166 char wbuffer
[HTTP_MAX_BUFFER
];
167 /* Buffer for outgoing data */
168 int wused
; /* Write buffer bytes used @since CUPS 1.2@ */
173 * Some OS's don't have hstrerror(), most notably Solaris...
176 # ifndef HAVE_HSTRERROR
177 extern const char *_cups_hstrerror(int error
);
178 # define hstrerror _cups_hstrerror
179 # elif defined(_AIX) || defined(__osf__)
181 * AIX and Tru64 UNIX don't provide a prototype but do provide the function...
183 extern const char *hstrerror(int error
);
184 # endif /* !HAVE_HSTRERROR */
188 * Some OS's don't have getifaddrs() and freeifaddrs()...
192 # ifdef HAVE_GETIFADDRS
193 # include <ifaddrs.h>
195 # include <sys/ioctl.h>
196 # ifdef HAVE_SYS_SOCKIO_H
197 # include <sys/sockio.h>
198 # endif /* HAVE_SYS_SOCKIO_H */
202 # endif /* ifa_dstaddr */
204 # define ifr_netmask ifr_addr
205 # endif /* !ifr_netmask */
207 struct ifaddrs
/**** Interface Structure ****/
209 struct ifaddrs
*ifa_next
; /* Next interface in list */
210 char *ifa_name
; /* Name of interface */
211 unsigned int ifa_flags
; /* Flags (up, point-to-point, etc.) */
212 struct sockaddr
*ifa_addr
, /* Network address */
213 *ifa_netmask
; /* Address mask */
216 struct sockaddr
*ifu_broadaddr
; /* Broadcast address of this interface. */
217 struct sockaddr
*ifu_dstaddr
; /* Point-to-point destination address. */
220 void *ifa_data
; /* Interface statistics */
223 # ifndef ifa_broadaddr
224 # define ifa_broadaddr ifa_ifu.ifu_broadaddr
225 # endif /* !ifa_broadaddr */
227 # define ifa_dstaddr ifa_ifu.ifu_dstaddr
228 # endif /* !ifa_dstaddr */
230 extern int _cups_getifaddrs(struct ifaddrs
**addrs
);
231 # define getifaddrs _cups_getifaddrs
232 extern void _cups_freeifaddrs(struct ifaddrs
*addrs
);
233 # define freeifaddrs _cups_freeifaddrs
234 # endif /* HAVE_GETIFADDRS */
236 #endif /* !_CUPS_HTTP_PRIVATE_H_ */
239 * End of "$Id: http-private.h 181 2006-06-22 20:01:18Z jlovell $".