Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200810143707.5834-17-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20679.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
| ... | ... |
@@ -1772,6 +1772,28 @@ multi_client_connect_setenv(struct multi_context *m, |
| 1772 | 1772 |
} |
| 1773 | 1773 |
|
| 1774 | 1774 |
/** |
| 1775 |
+ * Extracts the IV_PROTO variable and returns its value or 0 |
|
| 1776 |
+ * if it cannot be extracted. |
|
| 1777 |
+ * |
|
| 1778 |
+ */ |
|
| 1779 |
+static unsigned int |
|
| 1780 |
+extract_iv_proto(const char *peer_info) |
|
| 1781 |
+{
|
|
| 1782 |
+ |
|
| 1783 |
+ const char *optstr = peer_info ? strstr(peer_info, "IV_PROTO=") : NULL; |
|
| 1784 |
+ if (optstr) |
|
| 1785 |
+ {
|
|
| 1786 |
+ int proto = 0; |
|
| 1787 |
+ int r = sscanf(optstr, "IV_PROTO=%d", &proto); |
|
| 1788 |
+ if (r == 1 && proto > 0) |
|
| 1789 |
+ {
|
|
| 1790 |
+ return proto; |
|
| 1791 |
+ } |
|
| 1792 |
+ } |
|
| 1793 |
+ return 0; |
|
| 1794 |
+} |
|
| 1795 |
+ |
|
| 1796 |
+/** |
|
| 1775 | 1797 |
* Calculates the options that depend on the client capabilities |
| 1776 | 1798 |
* based on local options and available peer info |
| 1777 | 1799 |
* - choosen cipher |
| ... | ... |
@@ -1780,30 +1802,19 @@ multi_client_connect_setenv(struct multi_context *m, |
| 1780 | 1780 |
static bool |
| 1781 | 1781 |
multi_client_set_protocol_options(struct context *c) |
| 1782 | 1782 |
{
|
| 1783 |
- |
|
| 1784 |
- const char *optstr = NULL; |
|
| 1785 | 1783 |
struct tls_multi *tls_multi = c->c2.tls_multi; |
| 1786 | 1784 |
const char *const peer_info = tls_multi->peer_info; |
| 1787 | 1785 |
struct options *o = &c->options; |
| 1788 | 1786 |
|
| 1789 |
- /* Send peer-id if client supports it */ |
|
| 1790 |
- optstr = peer_info ? strstr(peer_info, "IV_PROTO=") : NULL; |
|
| 1791 |
- if (optstr) |
|
| 1792 |
- {
|
|
| 1793 |
- int proto = 0; |
|
| 1794 |
- int r = sscanf(optstr, "IV_PROTO=%d", &proto); |
|
| 1795 |
- if (r == 1) |
|
| 1796 |
- {
|
|
| 1797 |
- if (proto & IV_PROTO_DATA_V2) |
|
| 1798 |
- {
|
|
| 1799 |
- tls_multi->use_peer_id = true; |
|
| 1800 |
- } |
|
| 1801 |
- if (proto & IV_PROTO_REQUEST_PUSH) |
|
| 1802 |
- {
|
|
| 1803 |
- c->c2.push_request_received = true; |
|
| 1804 |
- } |
|
| 1805 |
- } |
|
| 1806 | 1787 |
|
| 1788 |
+ unsigned int proto = extract_iv_proto(peer_info); |
|
| 1789 |
+ if (proto & IV_PROTO_DATA_V2) |
|
| 1790 |
+ {
|
|
| 1791 |
+ tls_multi->use_peer_id = true; |
|
| 1792 |
+ } |
|
| 1793 |
+ if (proto & IV_PROTO_REQUEST_PUSH) |
|
| 1794 |
+ {
|
|
| 1795 |
+ c->c2.push_request_received = true; |
|
| 1807 | 1796 |
} |
| 1808 | 1797 |
|
| 1809 | 1798 |
/* Select cipher if client supports Negotiable Crypto Parameters */ |