xref: /onnv-gate/usr/src/lib/libpkg/common/pkgweb.h (revision 9781:ccf49524d5dc)
1*9781SMoriah.Waterland@Sun.COM /*
2*9781SMoriah.Waterland@Sun.COM  * CDDL HEADER START
3*9781SMoriah.Waterland@Sun.COM  *
4*9781SMoriah.Waterland@Sun.COM  * The contents of this file are subject to the terms of the
5*9781SMoriah.Waterland@Sun.COM  * Common Development and Distribution License (the "License").
6*9781SMoriah.Waterland@Sun.COM  * You may not use this file except in compliance with the License.
7*9781SMoriah.Waterland@Sun.COM  *
8*9781SMoriah.Waterland@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*9781SMoriah.Waterland@Sun.COM  * or http://www.opensolaris.org/os/licensing.
10*9781SMoriah.Waterland@Sun.COM  * See the License for the specific language governing permissions
11*9781SMoriah.Waterland@Sun.COM  * and limitations under the License.
12*9781SMoriah.Waterland@Sun.COM  *
13*9781SMoriah.Waterland@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
14*9781SMoriah.Waterland@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*9781SMoriah.Waterland@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
16*9781SMoriah.Waterland@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
17*9781SMoriah.Waterland@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
18*9781SMoriah.Waterland@Sun.COM  *
19*9781SMoriah.Waterland@Sun.COM  * CDDL HEADER END
20*9781SMoriah.Waterland@Sun.COM  */
21*9781SMoriah.Waterland@Sun.COM 
22*9781SMoriah.Waterland@Sun.COM /*
23*9781SMoriah.Waterland@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24*9781SMoriah.Waterland@Sun.COM  * Use is subject to license terms.
25*9781SMoriah.Waterland@Sun.COM  */
26*9781SMoriah.Waterland@Sun.COM 
27*9781SMoriah.Waterland@Sun.COM #ifndef _PKGWEB_H
28*9781SMoriah.Waterland@Sun.COM #define	_PKGWEB_H
29*9781SMoriah.Waterland@Sun.COM 
30*9781SMoriah.Waterland@Sun.COM 
31*9781SMoriah.Waterland@Sun.COM #ifdef __cplusplus
32*9781SMoriah.Waterland@Sun.COM extern "C" {
33*9781SMoriah.Waterland@Sun.COM #endif
34*9781SMoriah.Waterland@Sun.COM 
35*9781SMoriah.Waterland@Sun.COM #include <netdb.h>
36*9781SMoriah.Waterland@Sun.COM #include <boot_http.h>
37*9781SMoriah.Waterland@Sun.COM 
38*9781SMoriah.Waterland@Sun.COM /* shortest backoff delay possible (in seconds) */
39*9781SMoriah.Waterland@Sun.COM #define	MIN_BACKOFF	1
40*9781SMoriah.Waterland@Sun.COM 
41*9781SMoriah.Waterland@Sun.COM /* how much to increase backoff time after each failure */
42*9781SMoriah.Waterland@Sun.COM #define	BACKOFF_FACTOR	2
43*9781SMoriah.Waterland@Sun.COM 
44*9781SMoriah.Waterland@Sun.COM /* Maximum amount of backoff for a heavy network or flaky server */
45*9781SMoriah.Waterland@Sun.COM #define	MAX_BACKOFF	128
46*9781SMoriah.Waterland@Sun.COM 
47*9781SMoriah.Waterland@Sun.COM typedef enum {
48*9781SMoriah.Waterland@Sun.COM 	HTTP_REQ_TYPE_HEAD,
49*9781SMoriah.Waterland@Sun.COM 	HTTP_REQ_TYPE_GET
50*9781SMoriah.Waterland@Sun.COM } HTTPRequestType;
51*9781SMoriah.Waterland@Sun.COM 
52*9781SMoriah.Waterland@Sun.COM typedef enum {
53*9781SMoriah.Waterland@Sun.COM 	OCSPSuccess,
54*9781SMoriah.Waterland@Sun.COM 	OCSPMem,
55*9781SMoriah.Waterland@Sun.COM 	OCSPParse,
56*9781SMoriah.Waterland@Sun.COM 	OCSPConnect,
57*9781SMoriah.Waterland@Sun.COM 	OCSPRequest,
58*9781SMoriah.Waterland@Sun.COM 	OCSPResponder,
59*9781SMoriah.Waterland@Sun.COM 	OCSPUnsupported,
60*9781SMoriah.Waterland@Sun.COM 	OCSPVerify,
61*9781SMoriah.Waterland@Sun.COM 	OCSPInternal,
62*9781SMoriah.Waterland@Sun.COM 	OCSPNoURI
63*9781SMoriah.Waterland@Sun.COM } OCSPStatus;
64*9781SMoriah.Waterland@Sun.COM 
65*9781SMoriah.Waterland@Sun.COM typedef enum {
66*9781SMoriah.Waterland@Sun.COM 	none,
67*9781SMoriah.Waterland@Sun.COM 	web_http,
68*9781SMoriah.Waterland@Sun.COM 	web_https,
69*9781SMoriah.Waterland@Sun.COM 	web_ftp
70*9781SMoriah.Waterland@Sun.COM } WebScheme;
71*9781SMoriah.Waterland@Sun.COM 
72*9781SMoriah.Waterland@Sun.COM typedef enum {
73*9781SMoriah.Waterland@Sun.COM     WEB_OK,
74*9781SMoriah.Waterland@Sun.COM     WEB_TIMEOUT,
75*9781SMoriah.Waterland@Sun.COM     WEB_CONNREFUSED,
76*9781SMoriah.Waterland@Sun.COM     WEB_HOSTDOWN,
77*9781SMoriah.Waterland@Sun.COM     WEB_VERIFY_SETUP,
78*9781SMoriah.Waterland@Sun.COM     WEB_NOCONNECT,
79*9781SMoriah.Waterland@Sun.COM     WEB_GET_FAIL
80*9781SMoriah.Waterland@Sun.COM } WebStatus;
81*9781SMoriah.Waterland@Sun.COM 
82*9781SMoriah.Waterland@Sun.COM typedef struct {
83*9781SMoriah.Waterland@Sun.COM 	ulong_t prev_cont_length;
84*9781SMoriah.Waterland@Sun.COM 	ulong_t content_length;
85*9781SMoriah.Waterland@Sun.COM 	ulong_t cur_pos;
86*9781SMoriah.Waterland@Sun.COM } DwnldData;
87*9781SMoriah.Waterland@Sun.COM 
88*9781SMoriah.Waterland@Sun.COM typedef struct {
89*9781SMoriah.Waterland@Sun.COM 	keystore_handle_t keystore;
90*9781SMoriah.Waterland@Sun.COM 	char *certfile;
91*9781SMoriah.Waterland@Sun.COM 	char *uniqfile;
92*9781SMoriah.Waterland@Sun.COM 	char *link;
93*9781SMoriah.Waterland@Sun.COM 	char *errstr;
94*9781SMoriah.Waterland@Sun.COM 	char *dwnld_dir;
95*9781SMoriah.Waterland@Sun.COM 	boolean_t	spool;
96*9781SMoriah.Waterland@Sun.COM 	void *content;
97*9781SMoriah.Waterland@Sun.COM 	int timeout;
98*9781SMoriah.Waterland@Sun.COM 	url_hport_t proxy;
99*9781SMoriah.Waterland@Sun.COM 	url_t url;
100*9781SMoriah.Waterland@Sun.COM 	DwnldData data;
101*9781SMoriah.Waterland@Sun.COM 	http_respinfo_t *resp;
102*9781SMoriah.Waterland@Sun.COM 	boot_http_ver_t *http_vers;
103*9781SMoriah.Waterland@Sun.COM 	http_handle_t *hps;
104*9781SMoriah.Waterland@Sun.COM } WEB_SESSION;
105*9781SMoriah.Waterland@Sun.COM 
106*9781SMoriah.Waterland@Sun.COM extern boolean_t web_session_control(PKG_ERR *, char *, char *,
107*9781SMoriah.Waterland@Sun.COM     keystore_handle_t, char *, ushort_t, int, int, int, char **);
108*9781SMoriah.Waterland@Sun.COM extern boolean_t get_signature(PKG_ERR *, char *, struct pkgdev *,
109*9781SMoriah.Waterland@Sun.COM     PKCS7 **);
110*9781SMoriah.Waterland@Sun.COM extern boolean_t validate_signature(PKG_ERR *, char *, BIO *, PKCS7 *,
111*9781SMoriah.Waterland@Sun.COM     STACK_OF(X509) *, url_hport_t *, int);
112*9781SMoriah.Waterland@Sun.COM extern boolean_t ds_validate_signature(PKG_ERR *, struct pkgdev *, char **,
113*9781SMoriah.Waterland@Sun.COM     char *, PKCS7 *, STACK_OF(X509) *, url_hport_t *, int);
114*9781SMoriah.Waterland@Sun.COM extern boolean_t get_proxy_port(PKG_ERR *, char **, ushort_t *);
115*9781SMoriah.Waterland@Sun.COM extern boolean_t path_valid(char *);
116*9781SMoriah.Waterland@Sun.COM extern void web_cleanup(void);
117*9781SMoriah.Waterland@Sun.COM extern ushort_t strip_port(char *proxy);
118*9781SMoriah.Waterland@Sun.COM extern void set_web_install(void);
119*9781SMoriah.Waterland@Sun.COM extern int is_web_install(void);
120*9781SMoriah.Waterland@Sun.COM extern void echo_out(int, char *, ...);
121*9781SMoriah.Waterland@Sun.COM extern void backoff(void);
122*9781SMoriah.Waterland@Sun.COM extern void reset_backoff(void);
123*9781SMoriah.Waterland@Sun.COM extern char *get_endof_string(char *, char);
124*9781SMoriah.Waterland@Sun.COM extern char *get_startof_string(char *, char);
125*9781SMoriah.Waterland@Sun.COM 
126*9781SMoriah.Waterland@Sun.COM #ifdef __cplusplus
127*9781SMoriah.Waterland@Sun.COM }
128*9781SMoriah.Waterland@Sun.COM #endif
129*9781SMoriah.Waterland@Sun.COM 
130*9781SMoriah.Waterland@Sun.COM #endif /* _PKGWEB_H */
131