]> git.ipfire.org Git - thirdparty/cups.git/blob - cups/http-private.h
3e405d58594a960bf25f1f9e69805a885e260aab
[thirdparty/cups.git] / cups / http-private.h
1 /*
2 * "$Id: http-private.h 6188 2007-01-10 16:23:06Z mike $"
3 *
4 * Private HTTP definitions for the Common UNIX Printing System (CUPS).
5 *
6 * Copyright 1997-2007 by Easy Software Products, all rights reserved.
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
34 # include <stdlib.h>
35 # include <config.h>
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
58 # if defined(__sgi) || (defined(__APPLE__) && !defined(_SOCKLEN_T))
59 /*
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...
62 */
63
64 typedef int socklen_t;
65 # endif /* __sgi || (__APPLE__ && !_SOCKLEN_T) */
66
67 # include "http.h"
68 # include "ipp-private.h"
69
70 # if defined HAVE_LIBSSL
71 /*
72 * The OpenSSL library provides its own SSL/TLS context structure for its
73 * IO and protocol management. However, we need to provide our own BIO
74 * (basic IO) implementation to do timeouts...
75 */
76
77 # include <openssl/err.h>
78 # include <openssl/rand.h>
79 # include <openssl/ssl.h>
80
81 typedef SSL http_tls_t;
82
83 extern BIO_METHOD *_httpBIOMethods(void);
84
85 # elif defined HAVE_GNUTLS
86 /*
87 * The GNU TLS library is more of a "bare metal" SSL/TLS library...
88 */
89 # include <gnutls/gnutls.h>
90
91 typedef struct
92 {
93 gnutls_session session; /* GNU TLS session object */
94 void *credentials; /* GNU TLS credentials object */
95 } http_tls_t;
96
97 extern ssize_t _httpReadGNUTLS(gnutls_transport_ptr ptr, void *data,
98 size_t length);
99 extern ssize_t _httpWriteGNUTLS(gnutls_transport_ptr ptr, const void *data,
100 size_t length);
101
102 # elif defined(HAVE_CDSASSL)
103 /*
104 * Darwin's Security framework provides its own SSL/TLS context structure
105 * for its IO and protocol management...
106 */
107
108 # include <Security/SecureTransport.h>
109
110 typedef struct /**** CDSA connection information ****/
111 {
112 SSLContextRef session; /* CDSA session object */
113 CFArrayRef certsArray; /* Certificates array */
114 } http_tls_t;
115
116 extern OSStatus _httpReadCDSA(SSLConnectionRef connection, void *data,
117 size_t *dataLength);
118 extern OSStatus _httpWriteCDSA(SSLConnectionRef connection, const void *data,
119 size_t *dataLength);
120 # endif /* HAVE_LIBSSL */
121
122 /*
123 * Some OS's don't have hstrerror(), most notably Solaris...
124 */
125
126 # ifndef HAVE_HSTRERROR
127 extern const char *_cups_hstrerror(int error);
128 # define hstrerror _cups_hstrerror
129 # elif defined(_AIX) || defined(__osf__)
130 /*
131 * AIX and Tru64 UNIX don't provide a prototype but do provide the function...
132 */
133 extern const char *hstrerror(int error);
134 # endif /* !HAVE_HSTRERROR */
135
136
137 /*
138 * Some OS's don't have getifaddrs() and freeifaddrs()...
139 */
140
141 # ifndef WIN32
142 # include <net/if.h>
143 # ifdef HAVE_GETIFADDRS
144 # include <ifaddrs.h>
145 # else
146 # include <sys/ioctl.h>
147 # ifdef HAVE_SYS_SOCKIO_H
148 # include <sys/sockio.h>
149 # endif /* HAVE_SYS_SOCKIO_H */
150
151 # ifdef ifa_dstaddr
152 # undef ifa_dstaddr
153 # endif /* ifa_dstaddr */
154 # ifndef ifr_netmask
155 # define ifr_netmask ifr_addr
156 # endif /* !ifr_netmask */
157
158 struct ifaddrs /**** Interface Structure ****/
159 {
160 struct ifaddrs *ifa_next; /* Next interface in list */
161 char *ifa_name; /* Name of interface */
162 unsigned int ifa_flags; /* Flags (up, point-to-point, etc.) */
163 struct sockaddr *ifa_addr, /* Network address */
164 *ifa_netmask; /* Address mask */
165 union
166 {
167 struct sockaddr *ifu_broadaddr; /* Broadcast address of this interface. */
168 struct sockaddr *ifu_dstaddr; /* Point-to-point destination address. */
169 } ifa_ifu;
170
171 void *ifa_data; /* Interface statistics */
172 };
173
174 # ifndef ifa_broadaddr
175 # define ifa_broadaddr ifa_ifu.ifu_broadaddr
176 # endif /* !ifa_broadaddr */
177 # ifndef ifa_dstaddr
178 # define ifa_dstaddr ifa_ifu.ifu_dstaddr
179 # endif /* !ifa_dstaddr */
180
181 extern int _cups_getifaddrs(struct ifaddrs **addrs);
182 # define getifaddrs _cups_getifaddrs
183 extern void _cups_freeifaddrs(struct ifaddrs *addrs);
184 # define freeifaddrs _cups_freeifaddrs
185 # endif /* HAVE_GETIFADDRS */
186 # endif /* !WIN32 */
187
188 #endif /* !_CUPS_HTTP_PRIVATE_H_ */
189
190 /*
191 * End of "$Id: http-private.h 6188 2007-01-10 16:23:06Z mike $".
192 */