Import from old repository commit 61ef2b42a9c4ba8e1600f15bb0236765edc2ad45.
[openvswitch] / lib / vconn-ssl.h
1 /*
2  * Copyright (c) 2008 Nicira Networks.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 #ifndef VCONN_SSL_H
17 #define VCONN_SSL_H 1
18
19 #include <stdbool.h>
20
21 #ifdef HAVE_OPENSSL
22 bool vconn_ssl_is_configured(void);
23 void vconn_ssl_set_private_key_file(const char *file_name);
24 void vconn_ssl_set_certificate_file(const char *file_name);
25 void vconn_ssl_set_ca_cert_file(const char *file_name, bool bootstrap);
26 void vconn_ssl_set_peer_ca_cert_file(const char *file_name);
27
28 #define VCONN_SSL_LONG_OPTIONS                      \
29         {"private-key", required_argument, 0, 'p'}, \
30         {"certificate", required_argument, 0, 'c'}, \
31         {"ca-cert",     required_argument, 0, 'C'},
32
33 #define VCONN_SSL_OPTION_HANDLERS                       \
34         case 'p':                                       \
35             vconn_ssl_set_private_key_file(optarg);     \
36             break;                                      \
37                                                         \
38         case 'c':                                       \
39             vconn_ssl_set_certificate_file(optarg);     \
40             break;                                      \
41                                                         \
42         case 'C':                                       \
43             vconn_ssl_set_ca_cert_file(optarg, false);  \
44             break;
45 #else /* !HAVE_OPENSSL */
46 static inline bool vconn_ssl_is_configured(void) 
47 {
48     return false;
49 }
50 #define VCONN_SSL_LONG_OPTIONS
51 #define VCONN_SSL_OPTION_HANDLERS
52 #endif /* !HAVE_OPENSSL */
53
54 #endif /* vconn-ssl.h */