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