Change in openvpn[master]: Reformat the whole project with clang-format
A message that is not in the archive (sent off-list or not yet received): gerrit.1730386897000.I2566ad493629e1f5fdfa6f6483b8973463404e3e@...2715...
Attention is currently required from: flichtenheld, plaisthos.
ordex has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/791?usp=email )
Change subject: Reformat the whole project with clang-format
......................................................................
Patch Set 14:
(8 comments)
Patchset:
PS14:
the change is extremely long, so not easy to comment to everything, but I threw a few concerns worth checking.
File sample/sample-plugins/client-connect/sample-client-connect.c:
http://gerrit.openvpn.net/c/openvpn/+/791/comment/c6e0d1ce_30cbe3ba :
PS14, Line 135: stderr,
this hurts me a bit, for two reasons:
1) "stderr," should just stay on the same line as fprintf, given that there is enough space;
2) when going to a new line, I personally prefer to see the text aligned to the opening parenthesis.
http://gerrit.openvpn.net/c/openvpn/+/791/comment/27a22e79_01461376 :
PS14, Line 251: MODULE,
same as above, I expected MODULE to be on the line above
NOTE: I won't report any other occurrence of this in the rest of the patch
http://gerrit.openvpn.net/c/openvpn/+/791/comment/3682efec_128649c3 :
PS14, Line 252: "env has UV_WANT_CC_ASYNC=%d, but "
here there is a more generic question to answer: do we want to keep string on the same line, even if they are too long? Pro being that the casual reader could be reasonably able to grep an error message (with some magic, due to format patterns).
File sample/sample-plugins/defer/multi-auth.c:
http://gerrit.openvpn.net/c/openvpn/+/791/comment/e5889e88_f1a4caaa :
PS14, Line 267: np(context->test_valid_user),
I'd vote for putting these arguments on the same line, if there is enough space.
http://gerrit.openvpn.net/c/openvpn/+/791/comment/8f6e4102_5edbebdb :
PS14, Line 294: const char *envp[])
ratio behind this change? one arg per line?
http://gerrit.openvpn.net/c/openvpn/+/791/comment/99dbd0d9_8682fdd3 :
PS14, Line 418: plog(context, PLOG_NOTE, "FUNC: openvpn_plugin_client_constructor_v1");
how about forcing a new line after variables declaration?
File sample/sample-plugins/log/log_v3.c:
http://gerrit.openvpn.net/c/openvpn/+/791/comment/c1025c39_05185d3b :
PS14, Line 87: "log_v3: ** ERROR ** Incompatible plug-in interface between this plug-in and OpenVPN\n");
this is probably another instance of the same situation as before.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/791?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I2566ad493629e1f5fdfa6f6483b8973463404e3e
Gerrit-Change-Number: 791
Gerrit-PatchSet: 14
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Mon, 14 Apr 2025 19:21:32 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: ordex, plaisthos.
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/791?usp=email )
Change subject: Reformat the whole project with clang-format
......................................................................
Patch Set 14:
(6 comments)
File sample/sample-plugins/client-connect/sample-client-connect.c:
http://gerrit.openvpn.net/c/openvpn/+/791/comment/1bf6c87b_4e6169ab :
PS14, Line 135: stderr,
Quoted 1 line
this hurts me a bit, for two reasons: […]
Not quite sure why it doesn't align to "(", it does for almost all other occurences. I think it might have a trade-off here between trying to align and trying to get the string in the colum limit.
http://gerrit.openvpn.net/c/openvpn/+/791/comment/4cf494a4_79f7b8ce :
PS14, Line 251: MODULE,
Quoted 1 line
same as above, I expected MODULE to be on the line above […]
So basically what you want is "BinPackArguments: true", will apply that.
http://gerrit.openvpn.net/c/openvpn/+/791/comment/d9dba330_b8c72914 :
PS14, Line 252: "env has UV_WANT_CC_ASYNC=%d, but "
Quoted 1 line
here there is a more generic question to answer: do we want to keep string on the same line, even if […]
Has nothing to do with this patch though, AFAICT
File sample/sample-plugins/defer/multi-auth.c:
http://gerrit.openvpn.net/c/openvpn/+/791/comment/8b72fd16_d619cd73 :
PS14, Line 294: const char *envp[])
Quoted 1 line
ratio behind this change? one arg per line?
yes. This is BinPackParameters. Do you also want that set to "true"?
http://gerrit.openvpn.net/c/openvpn/+/791/comment/d94e4661_457ff043 :
PS14, Line 418: plog(context, PLOG_NOTE, "FUNC: openvpn_plugin_client_constructor_v1");
Quoted 1 line
how about forcing a new line after variables declaration?
Doesn't seem to be supported. There is a feature request for it: https://github.com/llvm/llvm-project/issues/97303
File sample/sample-plugins/log/log_v3.c:
http://gerrit.openvpn.net/c/openvpn/+/791/comment/c9c800e4_6ecdeccd :
PS14, Line 87: "log_v3: ** ERROR ** Incompatible plug-in interface between this plug-in and OpenVPN\n");
Quoted 1 line
this is probably another instance of the same situation as before.
yes
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/791?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I2566ad493629e1f5fdfa6f6483b8973463404e3e
Gerrit-Change-Number: 791
Gerrit-PatchSet: 14
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Wed, 16 Apr 2025 11:47:43 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: ordex <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: flichtenheld, plaisthos.
ordex has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/791?usp=email )
Change subject: Reformat the whole project with clang-format
......................................................................
Patch Set 14:
(2 comments)
File sample/sample-plugins/client-connect/sample-client-connect.c:
http://gerrit.openvpn.net/c/openvpn/+/791/comment/cd08c6bb_0b6173ee :
PS14, Line 252: "env has UV_WANT_CC_ASYNC=%d, but "
Quoted 1 line
Has nothing to do with this patch though, AFAICT
You're right. I thought it was the right moment to trigger the discussion, so we can possibly find a clang-format option that addresses this.
File sample/sample-plugins/defer/multi-auth.c:
http://gerrit.openvpn.net/c/openvpn/+/791/comment/6b1aef69_72e254a0 :
PS14, Line 294: const char *envp[])
Quoted 1 line
yes. This is BinPackParameters. […]
I think we should. It will also make BinPackParameters consistent with BinPackArguments
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/791?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I2566ad493629e1f5fdfa6f6483b8973463404e3e
Gerrit-Change-Number: 791
Gerrit-PatchSet: 14
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Wed, 16 Apr 2025 11:52:42 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: flichtenheld <[email protected]...>
Comment-In-Reply-To: ordex <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: ordex, plaisthos.
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/791?usp=email )
Change subject: Reformat the whole project with clang-format
......................................................................
Patch Set 16:
(4 comments)
File sample/sample-plugins/client-connect/sample-client-connect.c:
http://gerrit.openvpn.net/c/openvpn/+/791/comment/763d178b_37f47877 :
PS14, Line 251: MODULE,
Quoted 1 line
So basically what you want is "BinPackArguments: true", will apply that.
Done
File sample/sample-plugins/defer/multi-auth.c:
http://gerrit.openvpn.net/c/openvpn/+/791/comment/e720aaa5_9dff2c4a :
PS14, Line 267: np(context->test_valid_user),
Quoted 1 line
I'd vote for putting these arguments on the same line, if there is enough space.
Done
http://gerrit.openvpn.net/c/openvpn/+/791/comment/6d71e7fc_faa3fc2d :
PS14, Line 418: plog(context, PLOG_NOTE, "FUNC: openvpn_plugin_client_constructor_v1");
Quoted 1 line
Doesn't seem to be supported. There is a feature request for it: https://github. […]
Acknowledged
File sample/sample-plugins/log/log_v3.c:
http://gerrit.openvpn.net/c/openvpn/+/791/comment/5a59375c_600cff63 :
PS14, Line 87: "log_v3: ** ERROR ** Incompatible plug-in interface between this plug-in and OpenVPN\n");
Quoted 1 line
yes
Acknowledged
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/791?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I2566ad493629e1f5fdfa6f6483b8973463404e3e
Gerrit-Change-Number: 791
Gerrit-PatchSet: 16
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Wed, 16 Apr 2025 13:48:29 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: flichtenheld <[email protected]...>
Comment-In-Reply-To: ordex <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: ordex, plaisthos.
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/791?usp=email )
Change subject: Reformat the whole project with clang-format
......................................................................
Patch Set 16:
(1 comment)
File sample/sample-plugins/defer/multi-auth.c:
http://gerrit.openvpn.net/c/openvpn/+/791/comment/d4a601b3_b1efe856 :
PS14, Line 294: const char *envp[])
Quoted 1 line
I think we should. […]
I disagree. Note that when setting BinPackParameters to true this will apply to all functions and all parameters. I think in general if the parameters to do fit on one line, it is better to put them one per line. Let's see what others think.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/791?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I2566ad493629e1f5fdfa6f6483b8973463404e3e
Gerrit-Change-Number: 791
Gerrit-PatchSet: 16
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Wed, 16 Apr 2025 13:55:23 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: flichtenheld <[email protected]...>
Comment-In-Reply-To: ordex <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: ordex, plaisthos.
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/791?usp=email )
Change subject: Reformat the whole project with clang-format
......................................................................
Patch Set 17:
(1 comment)
File sample/sample-plugins/defer/multi-auth.c:
http://gerrit.openvpn.net/c/openvpn/+/791/comment/86c264e5_529758c0 :
PS14, Line 294: const char *envp[])
Quoted 1 line
I disagree. […]
BinPackParameter is set to true now after cron2 agreed with you.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/791?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I2566ad493629e1f5fdfa6f6483b8973463404e3e
Gerrit-Change-Number: 791
Gerrit-PatchSet: 17
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Wed, 30 Apr 2025 13:04:34 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: flichtenheld <[email protected]...>
Comment-In-Reply-To: ordex <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: flichtenheld, ordex, plaisthos.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/791?usp=email )
Change subject: Reformat the whole project with clang-format
......................................................................
Patch Set 18:
(5 comments)
Patchset:
PS18:
Overall this is impressively good. Some changes (struct opening bracket) should have been done all along :-) - others just make sense. I have a few that I do not like and I think one actual bug in the ruleset (do...while() in buffer.c).
File src/openvpn/buffer.c:
http://gerrit.openvpn.net/c/openvpn/+/791/comment/e228108e_a877cddf :
PS18, Line 850: } while (c);
it should not do that
http://gerrit.openvpn.net/c/openvpn/+/791/comment/450ac52e_57fa1b4a :
PS18, Line 915: && c != 127)) /* allow ascii non-control and UTF-8, consider DEL to be a control */
this is ugly, but I guess the best way to fix it is to manually move the comment before the if() line
File src/openvpn/comp.h:
http://gerrit.openvpn.net/c/openvpn/+/791/comment/07c11cf5_a35c47d6 :
PS18, Line 93: bool check_compression_settings_valid(struct compress_options *info, int msglevel);
this is one of the changes I'm not sure we want - having the return type on the line before gives us more line length for the actual prototype, and also it eases "grep ^function" to find prototype + function implementation (my use case, which I could certainly solve differently)
File src/openvpn/console_builtin.c:
http://gerrit.openvpn.net/c/openvpn/+/791/comment/ecc1640a_115b4d7b :
PS18, Line 74: msg(M_WARN | M_ERRNO, "get_console_input_win32(): unexpected error");
the extra spaces around foo|bar are not really to my liking ("this belongs together" vibes)
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/791?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I2566ad493629e1f5fdfa6f6483b8973463404e3e
Gerrit-Change-Number: 791
Gerrit-PatchSet: 18
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Sat, 24 May 2025 14:14:08 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: cron2, ordex, plaisthos.
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/791?usp=email )
Change subject: Reformat the whole project with clang-format
......................................................................
Patch Set 18:
(3 comments)
File src/openvpn/buffer.c:
http://gerrit.openvpn.net/c/openvpn/+/791/comment/6892fcb6_41f2daaf :
PS18, Line 850: } while (c);
Quoted 1 line
it should not do that
Why?
http://gerrit.openvpn.net/c/openvpn/+/791/comment/18dc39e2_b722d6bf :
PS18, Line 915: && c != 127)) /* allow ascii non-control and UTF-8, consider DEL to be a control */
Quoted 1 line
this is ugly, but I guess the best way to fix it is to manually move the comment before the
if()lin […]
Yes.
File src/openvpn/console_builtin.c:
http://gerrit.openvpn.net/c/openvpn/+/791/comment/e785d1b2_41139a46 :
PS18, Line 74: msg(M_WARN | M_ERRNO, "get_console_input_win32(): unexpected error");
Quoted 1 line
the extra spaces around
foo|barare not really to my liking ("this belongs together" vibes)
Interestingly one of the things we can't configure in clang-format. The space around binary operators is not optional.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/791?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I2566ad493629e1f5fdfa6f6483b8973463404e3e
Gerrit-Change-Number: 791
Gerrit-PatchSet: 18
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Mon, 26 May 2025 09:54:45 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: cron2, ordex, plaisthos.
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/791?usp=email )
Change subject: Reformat the whole project with clang-format
......................................................................
Patch Set 19:
(4 comments)
File src/openvpn/buffer.c:
http://gerrit.openvpn.net/c/openvpn/+/791/comment/5fa573c3_de511cf1 :
PS18, Line 850: } while (c);
Quoted 1 line
Why?
As discussed on IRC this is actually correct for our current formatting.
http://gerrit.openvpn.net/c/openvpn/+/791/comment/5173a895_ec42235c :
PS18, Line 915: && c != 127)) /* allow ascii non-control and UTF-8, consider DEL to be a control */
Quoted 1 line
Yes.
Done in separate commit.
File src/openvpn/comp.h:
http://gerrit.openvpn.net/c/openvpn/+/791/comment/ca6252bf_a8b50dfe :
PS18, Line 93: bool check_compression_settings_valid(struct compress_options *info, int msglevel);
Quoted 1 line
this is one of the changes I'm not sure we want - having the return type on the line before gives us […]
As discussed in IRC this is consistent with what we have. Switched the .clang-format to use "AllDefinitions" instead which doesn't change anything but better matches our policy.
File src/openvpn/console_builtin.c:
http://gerrit.openvpn.net/c/openvpn/+/791/comment/9b83c0b1_41c7cd5f :
PS18, Line 74: msg(M_WARN | M_ERRNO, "get_console_input_win32(): unexpected error");
Quoted 1 line
Interestingly one of the things we can't configure in clang-format. […]
Done
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/791?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I2566ad493629e1f5fdfa6f6483b8973463404e3e
Gerrit-Change-Number: 791
Gerrit-PatchSet: 19
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Mon, 26 May 2025 10:40:42 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>
Comment-In-Reply-To: flichtenheld <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: cron2, ordex, plaisthos.
Hello plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/791?usp=email
to look at the new patch set (#22).
Change subject: Reformat the whole project with clang-format
......................................................................
Reformat the whole project with clang-format
Done with pre-commit run -a, so the version
defined in pre-commit config is used.
---
M include/openvpn-msg.h
M sample/sample-plugins/client-connect/sample-client-connect.c
M sample/sample-plugins/defer/multi-auth.c
M sample/sample-plugins/keying-material-exporter-demo/keyingmaterialexporter.c M sample/sample-plugins/log/log.c
M sample/sample-plugins/log/log_v3.c
M sample/sample-plugins/simple/base64.c
M sample/sample-plugins/simple/simple.c
M src/compat/compat-basename.c
M src/compat/compat-dirname.c
M src/compat/compat-gettimeofday.c
M src/openvpn/argv.c
M src/openvpn/argv.h
M src/openvpn/auth_token.c
M src/openvpn/auth_token.h
M src/openvpn/base64.c
M src/openvpn/base64.h
M src/openvpn/basic.h
M src/openvpn/buffer.c
M src/openvpn/buffer.h
M src/openvpn/circ_list.h
M src/openvpn/clinat.c
M src/openvpn/clinat.h
M src/openvpn/common.h
M src/openvpn/comp-lz4.c
M src/openvpn/comp.c
M src/openvpn/comp.h
M src/openvpn/compstub.c
M src/openvpn/console.c
M src/openvpn/console.h
M src/openvpn/console_builtin.c
M src/openvpn/console_systemd.c
M src/openvpn/crypto.c
M src/openvpn/crypto.h
M src/openvpn/crypto_backend.h
M src/openvpn/crypto_epoch.c
M src/openvpn/crypto_epoch.h
M src/openvpn/crypto_mbedtls.c
M src/openvpn/crypto_mbedtls.h
M src/openvpn/crypto_openssl.c
M src/openvpn/crypto_openssl.h
M src/openvpn/cryptoapi.c
M src/openvpn/dco.c
M src/openvpn/dco.h
M src/openvpn/dco_freebsd.c
M src/openvpn/dco_freebsd.h
M src/openvpn/dco_internal.h
M src/openvpn/dco_linux.c
M src/openvpn/dco_linux.h
M src/openvpn/dco_win.c
M src/openvpn/dco_win.h
M src/openvpn/dhcp.c
M src/openvpn/dhcp.h
M src/openvpn/dns.c
M src/openvpn/dns.h
M src/openvpn/env_set.c
M src/openvpn/env_set.h
M src/openvpn/errlevel.h
M src/openvpn/error.c
M src/openvpn/error.h
M src/openvpn/event.c
M src/openvpn/event.h
M src/openvpn/fdmisc.c
M src/openvpn/fdmisc.h
M src/openvpn/forward.c
M src/openvpn/forward.h
M src/openvpn/fragment.c
M src/openvpn/fragment.h
M src/openvpn/gremlin.c
M src/openvpn/gremlin.h
M src/openvpn/helper.c
M src/openvpn/httpdigest.c
M src/openvpn/httpdigest.h
M src/openvpn/init.c
M src/openvpn/init.h
M src/openvpn/integer.h
M src/openvpn/interval.c
M src/openvpn/interval.h
M src/openvpn/list.c
M src/openvpn/list.h
M src/openvpn/lladdr.c
M src/openvpn/lzo.c
M src/openvpn/lzo.h
M src/openvpn/manage.c
M src/openvpn/manage.h
M src/openvpn/mbedtls_compat.h
M src/openvpn/mbuf.c
M src/openvpn/mbuf.h
M src/openvpn/memdbg.h
M src/openvpn/misc.c
M src/openvpn/misc.h
M src/openvpn/mroute.c
M src/openvpn/mroute.h
M src/openvpn/mss.c
M src/openvpn/mss.h
M src/openvpn/mstats.c
M src/openvpn/mstats.h
M src/openvpn/mtcp.c
M src/openvpn/mtcp.h
M src/openvpn/mtu.c
M src/openvpn/mtu.h
M src/openvpn/mudp.c
M src/openvpn/multi.c
M src/openvpn/multi.h
M src/openvpn/multi_io.c
M src/openvpn/networking.h
M src/openvpn/networking_freebsd.c
M src/openvpn/networking_iproute2.c
M src/openvpn/networking_sitnl.c
M src/openvpn/ntlm.c
M src/openvpn/occ.c
M src/openvpn/occ.h
M src/openvpn/openssl_compat.h
M src/openvpn/openvpn.c
M src/openvpn/openvpn.h
M src/openvpn/options.c
M src/openvpn/options.h
M src/openvpn/options_util.c
M src/openvpn/options_util.h
M src/openvpn/otime.c
M src/openvpn/otime.h
M src/openvpn/ovpn_dco_freebsd.h
M src/openvpn/packet_id.c
M src/openvpn/packet_id.h
M src/openvpn/perf.c
M src/openvpn/perf.h
M src/openvpn/ping.c
M src/openvpn/ping.h
M src/openvpn/pkcs11.c
M src/openvpn/pkcs11.h
M src/openvpn/pkcs11_backend.h
M src/openvpn/pkcs11_mbedtls.c
M src/openvpn/pkcs11_openssl.c
M src/openvpn/platform.c
M src/openvpn/platform.h
M src/openvpn/plugin.c
M src/openvpn/plugin.h
M src/openvpn/pool.c
M src/openvpn/pool.h
M src/openvpn/proto.c
M src/openvpn/proto.h
M src/openvpn/proxy.c
M src/openvpn/proxy.h
M src/openvpn/ps.c
M src/openvpn/ps.h
M src/openvpn/push.c
M src/openvpn/push.h
M src/openvpn/pushlist.h
M src/openvpn/reflect_filter.c
M src/openvpn/reflect_filter.h
M src/openvpn/reliable.c
M src/openvpn/reliable.h
A src/openvpn/ring_buffer.h
M src/openvpn/route.c
M src/openvpn/route.h
M src/openvpn/run_command.c
M src/openvpn/run_command.h
M src/openvpn/schedule.c
M src/openvpn/schedule.h
M src/openvpn/session_id.h
M src/openvpn/shaper.c
M src/openvpn/shaper.h
M src/openvpn/sig.c
M src/openvpn/sig.h
M src/openvpn/socket.c
M src/openvpn/socket.h
M src/openvpn/socks.c
M src/openvpn/socks.h
M src/openvpn/ssl.c
M src/openvpn/ssl.h
M src/openvpn/ssl_backend.h
M src/openvpn/ssl_common.h
M src/openvpn/ssl_mbedtls.c
M src/openvpn/ssl_mbedtls.h
M src/openvpn/ssl_ncp.c
M src/openvpn/ssl_ncp.h
M src/openvpn/ssl_openssl.c
M src/openvpn/ssl_openssl.h
M src/openvpn/ssl_pkt.c
M src/openvpn/ssl_pkt.h
M src/openvpn/ssl_util.c
M src/openvpn/ssl_util.h
M src/openvpn/ssl_verify.c
M src/openvpn/ssl_verify.h
M src/openvpn/ssl_verify_backend.h
M src/openvpn/ssl_verify_mbedtls.c
M src/openvpn/ssl_verify_mbedtls.h
M src/openvpn/ssl_verify_openssl.c
M src/openvpn/status.c
M src/openvpn/status.h
M src/openvpn/syshead.h
M src/openvpn/tls_crypt.c
M src/openvpn/tls_crypt.h
M src/openvpn/tun.c
M src/openvpn/tun.h
M src/openvpn/tun_afunix.c
M src/openvpn/tun_afunix.h
M src/openvpn/vlan.c
M src/openvpn/vlan.h
M src/openvpn/wfp_block.c
M src/openvpn/wfp_block.h
M src/openvpn/win32-util.c
M src/openvpn/win32.c
M src/openvpn/win32.h
M src/openvpn/xkey_common.h
M src/openvpn/xkey_helper.c
M src/openvpn/xkey_provider.c
M src/openvpnmsica/dllmain.c
M src/openvpnmsica/msica_arg.c
M src/openvpnmsica/msica_arg.h
M src/openvpnmsica/msiex.c
M src/openvpnmsica/msiex.h
M src/openvpnmsica/openvpnmsica.c
M src/openvpnmsica/openvpnmsica.h
M src/openvpnserv/common.c
M src/openvpnserv/interactive.c
M src/openvpnserv/service.c
M src/openvpnserv/service.h
M src/openvpnserv/validate.c
M src/openvpnserv/validate.h
M src/plugins/auth-pam/auth-pam.c
M src/plugins/auth-pam/pamdl.c
M src/plugins/auth-pam/utils.c
M src/plugins/auth-pam/utils.h
M src/plugins/down-root/down-root.c
M src/tapctl/basic.h
M src/tapctl/error.h
M src/tapctl/main.c
M src/tapctl/tap.c
M src/tapctl/tap.h
M tests/ntlm_support.c
M tests/unit_tests/example_test/test.c
M tests/unit_tests/example_test/test2.c
M tests/unit_tests/openvpn/cert_data.h
M tests/unit_tests/openvpn/mock_management.c
M tests/unit_tests/openvpn/mock_msg.c
M tests/unit_tests/openvpn/mock_msg.h
M tests/unit_tests/openvpn/mock_ssl_dependencies.c
M tests/unit_tests/openvpn/pkey_test_utils.c
M tests/unit_tests/openvpn/test_argv.c
M tests/unit_tests/openvpn/test_auth_token.c
M tests/unit_tests/openvpn/test_buffer.c
M tests/unit_tests/openvpn/test_crypto.c
M tests/unit_tests/openvpn/test_cryptoapi.c
M tests/unit_tests/openvpn/test_misc.c
M tests/unit_tests/openvpn/test_ncp.c
M tests/unit_tests/openvpn/test_networking.c
M tests/unit_tests/openvpn/test_packet_id.c
M tests/unit_tests/openvpn/test_pkcs11.c
M tests/unit_tests/openvpn/test_pkt.c
M tests/unit_tests/openvpn/test_provider.c
M tests/unit_tests/openvpn/test_ssl.c
M tests/unit_tests/openvpn/test_tls_crypt.c
M tests/unit_tests/openvpn/test_user_pass.c
M tests/unit_tests/plugins/auth-pam/test_search_and_replace.c
255 files changed, 11,864 insertions(+), 15,015 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/91/791/22
include/openvpn-msg.h +41 -22
@@ -27,7 +27,8 @@#include <windef.h> #include <ws2tcpip.h> -typedef enum { +typedef enum +{ msg_acknowledgement, msg_add_address, msg_del_address,
@@ -51,28 +52,33 @@msg_create_adapter } message_type_t; -typedef struct { +typedef struct +{message_type_t type;size_t size;int message_id; }message_header_t ; -typedef union { +typedef union +{struct in_addr ipv4;struct in6_addr ipv6; }inet_address_t ; -typedef struct { +typedef struct +{int index;char name[256 ]; }interface_t ; -typedef enum { - wfp_block_local =1 <<0 , - wfp_block_dns =1 <<1 +typedef enum +{ + wfp_block_local =1 <<0 , + wfp_block_dns =1 <<1 }wfp_block_flags_t ; -typedef struct { +typedef struct +{ message_header_t header; short family; inet_address_t address;
@@ -80,7 +86,8 @@interface_t iface; } address_message_t; -typedef struct { +typedef struct +{ message_header_t header; short family; inet_address_t prefix;
@@ -90,7 +97,8 @@int metric; } route_message_t; -typedef struct { +typedef struct +{ message_header_t header; interface_t iface; char domains[512];
@@ -100,14 +108,16 @@ } dns_cfg_message_t; -typedef enum { +typedef enum +{ nrpt_dnssec }nrpt_flags_t ; -#define NRPT_ADDR_NUM 8/* Max. number of addresses */ +#define NRPT_ADDR_NUM 8/* Max. number of addresses */ #define NRPT_ADDR_SIZE 48/* Max. address strlen + some */ typedef char nrpt_address_t [NRPT_ADDR_SIZE ]; -typedef struct { +typedef struct +{ message_header_t header; interface_t iface; nrpt_address_t addresses[NRPT_ADDR_NUM];
@@ -116,14 +126,16 @@nrpt_flags_t flags; } nrpt_dns_cfg_message_t; -typedef struct { +typedef struct +{message_header_t header;interface_t iface;int addr_len;inet_address_t addr[4 ];/* support up to 4 dns addresses */ }wins_cfg_message_t ; -typedef struct { +typedef struct +{ message_header_t header; interface_t iface; int disable_nbt;
@@ -135,41 +147,48 @@/* TODO: NTP */ -typedef struct { +typedef struct +{message_header_t header;short family;interface_t iface; }flush_neighbors_message_t ; -typedef struct { +typedef struct +{message_header_t header;int error_number; }ack_message_t ; -typedef struct { +typedef struct +{message_header_t header;wfp_block_flags_t flags;interface_t iface; }wfp_block_message_t ; -typedef struct { +typedef struct +{message_header_t header;interface_t iface; }enable_dhcp_message_t ; -typedef struct { +typedef struct +{message_header_t header;interface_t iface;short family;int mtu; }set_mtu_message_t ; -typedef enum { +typedef enum +{ADAPTER_TYPE_DCO ,ADAPTER_TYPE_TAP , }adapter_type_t ; -typedef struct { +typedef struct +{message_header_t header;adapter_type_t adapter_type; }create_adapter_message_t ;
sample/sample-plugins/client-connect/sample-client-connect.c +52 -59
265 lines not on this page · raw message
sample/sample-plugins/defer/multi-auth.c +35 -41
209 lines not on this page · raw message
sample/sample-plugins/keying-material-exporter-demo/keyingmaterialexporter.c +26 -25
119 lines not on this page · raw message
sample/sample-plugins/log/log.c +19 -19
@@ -37,7 +37,8 @@/* * Our context, where we keep our state. */ -struct plugin_context { +struct plugin_context +{const char *username;const char *password; };
@@ -77,7 +78,7 @@/* * Allocate our context */ - context = (struct plugin_context *)calloc (1 ,sizeof (struct plugin_context )); + context = (struct plugin_context *)calloc (1 ,sizeof (struct plugin_context ));if (context ==NULL ) {printf ("PLUGIN: allocating memory for context failed\n" );
@@ -93,19 +94,17 @@/* * Which callbacks to intercept. */ - *type_mask = -OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_UP ) - |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_DOWN ) - |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_ROUTE_UP ) - |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_IPCHANGE ) - |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_TLS_VERIFY ) - |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY ) - |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_CLIENT_CONNECT_V2 ) - |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_CLIENT_DISCONNECT ) - |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_LEARN_ADDRESS ) - |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_TLS_FINAL ); + *type_mask =OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_UP ) |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_DOWN ) + |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_ROUTE_UP ) + |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_IPCHANGE ) + |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_TLS_VERIFY ) + |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY ) + |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_CLIENT_CONNECT_V2 ) + |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_CLIENT_DISCONNECT ) + |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_LEARN_ADDRESS ) + |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_TLS_FINAL ); -return (openvpn_plugin_handle_t ) context; +return (openvpn_plugin_handle_t )context; }void
@@ -173,9 +172,10 @@ } OPENVPN_EXPORT int -openvpn_plugin_func_v1 (openvpn_plugin_handle_t handle,const int type,const char *argv[],const char *envp[]) +openvpn_plugin_func_v1 (openvpn_plugin_handle_t handle,const int type,const char *argv[], +const char *envp[]) { -struct plugin_context *context = (struct plugin_context *) handle; +struct plugin_context *context = (struct plugin_context *)handle;show (type, argv, envp);
@@ -186,8 +186,8 @@const char *username =get_env ("username" , envp);const char *password =get_env ("password" , envp); -if (username && !strcmp (username, context->username) - && password && !strcmp (password, context->password)) +if (username && !strcmp (username, context->username) && password + && !strcmp (password, context->password)) {return OPENVPN_PLUGIN_FUNC_SUCCESS ; }
@@ -205,6 +205,6 @@ OPENVPN_EXPORT voidopenvpn_plugin_close_v1 (openvpn_plugin_handle_t handle) { -struct plugin_context *context = (struct plugin_context *) handle; +struct plugin_context *context = (struct plugin_context *)handle;free (context); }
sample/sample-plugins/log/log_v3.c +24 -27
106 lines not on this page · raw message
sample/sample-plugins/simple/base64.c +15 -17
@@ -100,21 +100,20 @@* */ OPENVPN_EXPORT int -openvpn_plugin_open_v3 (const int v3structver, -struct openvpn_plugin_args_open_in const *args, +openvpn_plugin_open_v3 (const int v3structver,struct openvpn_plugin_args_open_in const *args,struct openvpn_plugin_args_open_return *ret) {/* Check that we are API compatible */ if (v3structver != OPENVPN_PLUGINv3_STRUCTVER) { -printf ("base64.c: ** ERROR ** Incompatible plug-in interface between this plug-in and OpenVPN\n" ); +printf ( +"base64.c: ** ERROR ** Incompatible plug-in interface between this plug-in and OpenVPN\n" );return OPENVPN_PLUGIN_FUNC_ERROR ; }/* Which callbacks to intercept. */ - ret->type_mask = -OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_TLS_VERIFY ) - |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_CLIENT_CONNECT_V2 ); + ret->type_mask =OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_TLS_VERIFY ) + |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_CLIENT_CONNECT_V2 );/* we don't need a plug-in context in this example, but OpenVPN expects "something" */ ret->handle =calloc (1 ,1 );
@@ -127,8 +126,8 @@/* Print some version information about the OpenVPN process using this plug-in */ ovpn_log (PLOG_NOTE ,PLUGIN_NAME ,"OpenVPN %s (Major: %i, Minor: %i, Patch: %s)\n" , - args->ovpn_version, args->ovpn_version_major, - args->ovpn_version_minor, args->ovpn_version_patch); + args->ovpn_version, args->ovpn_version_major, args->ovpn_version_minor, + args->ovpn_version_patch);return OPENVPN_PLUGIN_FUNC_SUCCESS ; }
@@ -156,10 +155,10 @@*/ OPENVPN_EXPORT int -openvpn_plugin_func_v1 (openvpn_plugin_handle_t handle,const int type,const char *argv[],const char *envp[]) +openvpn_plugin_func_v1 (openvpn_plugin_handle_t handle,const int type,const char *argv[], +const char *envp[]) { -if (type !=OPENVPN_PLUGIN_TLS_VERIFY - && type !=OPENVPN_PLUGIN_CLIENT_CONNECT_V2 ) +if (type !=OPENVPN_PLUGIN_TLS_VERIFY && type !=OPENVPN_PLUGIN_CLIENT_CONNECT_V2 ) {ovpn_log (PLOG_ERR ,PLUGIN_NAME ,"Unsupported plug-in hook call attempted" );return OPENVPN_PLUGIN_FUNC_ERROR ;
@@ -176,14 +175,13 @@/* test the BASE64 encode function */ char *buf =NULL ;int r =ovpn_base64_encode (clcert_cn,strlen (clcert_cn), &buf); -ovpn_log (PLOG_NOTE ,PLUGIN_NAME ,"BASE64 encoded '%s' (return value %i): '%s'" , - clcert_cn, r, buf); +ovpn_log (PLOG_NOTE ,PLUGIN_NAME ,"BASE64 encoded '%s' (return value %i): '%s'" , clcert_cn, r, + buf);/* test the BASE64 decode function */ -char buf2[256 ] = {0 }; +char buf2[256 ] = {0 }; r =ovpn_base64_decode (buf, &buf2,255 ); -ovpn_log (PLOG_NOTE ,PLUGIN_NAME ,"BASE64 decoded '%s' (return value %i): '%s'" , - buf, r, buf2); +ovpn_log (PLOG_NOTE ,PLUGIN_NAME ,"BASE64 decoded '%s' (return value %i): '%s'" , buf, r, buf2);/* Verify the result, and free the buffer allocated by ovpn_base64_encode() */ r =strcmp (clcert_cn, buf2);
@@ -203,6 +201,6 @@ OPENVPN_EXPORT voidopenvpn_plugin_close_v1 (openvpn_plugin_handle_t handle) { -struct plugin_context *context = (struct plugin_context *) handle; +struct plugin_context *context = (struct plugin_context *)handle;free (context); }
sample/sample-plugins/simple/simple.c +10 -8
@@ -39,7 +39,8 @@/* * Our context, where we keep our state. */ -struct plugin_context { +struct plugin_context +{const char *username;const char *password; };
@@ -79,7 +80,7 @@/* * Allocate our context */ - context = (struct plugin_context *)calloc (1 ,sizeof (struct plugin_context )); + context = (struct plugin_context *)calloc (1 ,sizeof (struct plugin_context ));if (context ==NULL ) {printf ("PLUGIN: allocating memory for context failed\n" );
@@ -98,21 +99,22 @@*/ *type_mask =OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY ); -return (openvpn_plugin_handle_t ) context; +return (openvpn_plugin_handle_t )context; } OPENVPN_EXPORT int -openvpn_plugin_func_v1 (openvpn_plugin_handle_t handle,const int type,const char *argv[],const char *envp[]) +openvpn_plugin_func_v1 (openvpn_plugin_handle_t handle,const int type,const char *argv[], +const char *envp[]) { -struct plugin_context *context = (struct plugin_context *) handle; +struct plugin_context *context = (struct plugin_context *)handle;/* get username/password from envp string array */ const char *username =get_env ("username" , envp);const char *password =get_env ("password" , envp);/* check entered username/password against what we require */ -if (username && !strcmp (username, context->username) - && password && !strcmp (password, context->password)) +if (username && !strcmp (username, context->username) && password + && !strcmp (password, context->password)) {return OPENVPN_PLUGIN_FUNC_SUCCESS ; }
@@ -125,6 +127,6 @@ OPENVPN_EXPORT voidopenvpn_plugin_close_v1 (openvpn_plugin_handle_t handle) { -struct plugin_context *context = (struct plugin_context *) handle; +struct plugin_context *context = (struct plugin_context *)handle;free (context); }
src/compat/compat-basename.c +1 -1
@@ -42,7 +42,7 @@/* If NULL, check for \ instead ... might be Windows a path */ p = strrchr(filename, '\\'); } -return p ? p +1 : (char *) filename; +return p ? p +1 : (char *)filename; }#endif /* HAVE_BASENAME */
src/compat/compat-dirname.c +2 -2
@@ -90,7 +90,7 @@/* The '/' is the last character, we have to look further. */ if (runp != path) { - last_slash = (char *)__memrchr (path, separator, runp - path); + last_slash = (char *)__memrchr (path, separator, runp - path); } }
@@ -135,7 +135,7 @@/* This assignment is ill-designed but the XPG specs require to * return a string containing "." in any case no directory part is * found and so a static and constant string is required. */ - path = (char *) dot; + path = (char *)dot; }return path;
src/compat/compat-gettimeofday.c +2 -2
@@ -49,7 +49,7 @@ {const time_t t =time (NULL );const DWORD gtc =GetTickCount (); - gtc_base = t - gtc/1000 ; + gtc_base = t - gtc /1000 ; gtc_last = gtc; }
@@ -113,7 +113,7 @@ return 0; } -#else /* ifdef _WIN32 */ +#else /* ifdef _WIN32 */ #include <time.h>
src/openvpn/argv.c +5 -6
@@ -285,8 +285,7 @@* free()d to avoid memory leaks. */ static char * -argv_prep_format (const char *format,const char delim,size_t *count, -struct gc_arena *gc) +argv_prep_format (const char *format,const char delim,size_t *count,struct gc_arena *gc) {if (format ==NULL ) {
@@ -312,7 +311,7 @@* the string is empty; the resulting format string * will never start with a delimiter. */ -if (j >0 )/* Has anything been written to the output string? */ +if (j >0 )/* Has anything been written to the output string? */ { f[j++] = delim; }
@@ -348,7 +347,7 @@static bool argv_printf_arglist (struct argv *argres,const char *format,va_list arglist) { -const char delim =0x1D ;/* ASCII Group Separator (GS) */ +const char delim =0x1D ;/* ASCII Group Separator (GS) */ bool res = false;/*
@@ -485,8 +484,8 @@argv_reset (argres);char *parms[MAX_PARMS +1 ] = {0 }; -int nparms =parse_line (cmdstr, parms,MAX_PARMS ,"SCRIPT-ARGV" ,0 , -D_ARGV_PARSE_CMD , &argres->gc); +int nparms = +parse_line (cmdstr, parms,MAX_PARMS ,"SCRIPT-ARGV" ,0 ,D_ARGV_PARSE_CMD , &argres->gc);if (nparms) {int i;
src/openvpn/argv.h +8 -7
@@ -32,7 +32,8 @@#include "buffer.h" -struct argv { +struct argv +{struct gc_arena gc;size_t capacity;size_t argc;
@@ -56,21 +57,21 @@ bool argv_printf(struct argv *a, const char *format, ...) #ifdef __GNUC__ #if __USE_MINGW_ANSI_STDIO -__attribute__ ((format(gnu_printf, 2, 3))) + __attribute__((format(gnu_printf, 2, 3))) #else -__attribute__ ((format(__printf__, 2, 3))) + __attribute__((format(__printf__, 2, 3))) #endif #endif -; + ; bool argv_printf_cat(struct argv *a, const char *format, ...) #ifdef __GNUC__ #if __USE_MINGW_ANSI_STDIO -__attribute__ ((format(gnu_printf, 2, 3))) + __attribute__((format(gnu_printf, 2, 3))) #else -__attribute__ ((format(__printf__, 2, 3))) + __attribute__((format(__printf__, 2, 3))) #endif #endif -; + ; #endif /* ifndef ARGV_H */
src/openvpn/auth_token.c +42 -49
245 lines not on this page · raw message
src/openvpn/auth_token.h +7 -15
@@ -59,27 +59,22 @@* This function will free() an existing multi->auth_token and keep the * existing initial timestamp and session id contained in that token. */ -void -generate_auth_token (const struct user_pass *up,struct tls_multi *multi); +void generate_auth_token (const struct user_pass *up,struct tls_multi *multi);/** * Verifies the auth token to be in the format that generate_auth_token * create and checks if the token is valid. * */ -unsigned -verify_auth_token (struct user_pass *up,struct tls_multi *multi, -struct tls_session *session); - +unsigned verify_auth_token (struct user_pass *up,struct tls_multi *multi, +struct tls_session *session);/** * Loads an HMAC secret from a file or if no file is present generates a * epheremal secret for the run time of the server and stores it into ctx */ -void -auth_token_init_secret (struct key_ctx *key_ctx,const char *key_file, -bool key_inline); +void auth_token_init_secret (struct key_ctx *key_ctx,const char *key_file,bool key_inline);/**
@@ -126,8 +121,7 @@static inline bool is_auth_token (const char *password) { -return (memcmp_constant_time (SESSION_ID_PREFIX , password, -strlen (SESSION_ID_PREFIX )) ==0 ); +return (memcmp_constant_time (SESSION_ID_PREFIX , password,strlen (SESSION_ID_PREFIX )) ==0 ); }/** * Checks if a client should be sent a new auth token to update its
@@ -135,15 +129,13 @@* @param multi Pointer the multi object of the TLS session * @param session Pointer to the TLS session itself */ -void -resend_auth_token_renegotiation (struct tls_multi *multi,struct tls_session *session); +void resend_auth_token_renegotiation (struct tls_multi *multi,struct tls_session *session);/** * Checks if the timer to resend the auth-token has expired and if a new * auth-token should be send to the client and triggers the resending */ -void -check_send_auth_token (struct context *c); +void check_send_auth_token (struct context *c);#endif /* AUTH_TOKEN_H */
src/openvpn/base64.c +5 -6
@@ -41,8 +41,7 @@#include "memdbg.h" -static char base64_chars[] = -"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ; +static char base64_chars[] ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ;/* * base64 encode input data of length size to malloced * buffer which is returned as *str. Returns string
@@ -60,14 +59,14 @@ {return -1 ; } - p = s = (char *)malloc (size *4 /3 +4 ); + p = s = (char *)malloc (size *4 /3 +4 );if (p ==NULL ) {return -1 ; } - q = (const unsigned char *) data; + q = (const unsigned char *)data; i =0 ; -for (i =0 ; i < size; ) +for (i =0 ; i < size;) { c = q[i++]; c *=256 ;
@@ -196,5 +195,5 @@ *q++ = val &0xff ; } } -return q - (unsigned char *) data; +return q - (unsigned char *)data; }
src/openvpn/base64.h +2 -4
@@ -35,12 +35,10 @@#define _BASE64_H_/** Compute resulting base64 length. 6 bits per byte, padded to 4 bytes. */ -#define OPENVPN_BASE64_LENGTH (binary_length) \ - ((((8 * binary_length) / 6) + 3) & ~3) +#define OPENVPN_BASE64_LENGTH (binary_length) ((((8 * binary_length) / 6) + 3) & ~3)/** Compute the maximal number of bytes encoded in a base64 string. */ -#define OPENVPN_BASE64_DECODED_LENGTH (base64_length) \ - ((base64_length / 4) * 3) +#define OPENVPN_BASE64_DECODED_LENGTH (base64_length) ((base64_length / 4) * 3)int openvpn_base64_encode (const void *data,int size,char **str);
src/openvpn/basic.h +1 -1
@@ -27,7 +27,7 @@#define BOOL_CAST (x) ((x) ? (true) : (false))/* size of an array */ -#define SIZE (x) (sizeof(x)/sizeof(x[0])) +#define SIZE (x) (sizeof(x) / sizeof(x[0]))/* clear an object (may be optimized away, use secure_memzero() to erase secrets) */ #define CLEAR (x) memset(&(x), 0, sizeof(x))
src/openvpn/buffer.c +46 -56
271 lines not on this page · raw message
src/openvpn/buffer.h +101 -113
374 lines not on this page · raw message
src/openvpn/circ_list.h +26 -29
75 lines not on this page · raw message
src/openvpn/clinat.c +7 -16
@@ -33,8 +33,7 @@#include "memdbg.h" static bool -add_entry (struct client_nat_option_list *dest, -const struct client_nat_entry *e) +add_entry (struct client_nat_option_list *dest,const struct client_nat_entry *e) {if (dest->n >=MAX_CLIENT_NAT ) {
@@ -60,9 +59,7 @@for (i =0 ; i < list->n; ++i) {const struct client_nat_entry *e = &list->entries[i]; -msg (msglevel," CNAT[%d] t=%d %s/%s/%s" , - i, - e->type, +msg (msglevel," CNAT[%d] t=%d %s/%s/%s" , i, e->type,print_in_addr_t (e->network,IA_NET_ORDER , &gc),print_in_addr_t (e->netmask,IA_NET_ORDER , &gc),print_in_addr_t (e->foreign_network,IA_NET_ORDER , &gc));
@@ -103,11 +100,8 @@ }void -add_client_nat_to_option_list (struct client_nat_option_list *dest, -const char *type, -const char *network, -const char *netmask, -const char *foreign_network, +add_client_nat_to_option_list (struct client_nat_option_list *dest,const char *type, +const char *network,const char *netmask,const char *foreign_network,int msglevel) {struct client_nat_entry e;
@@ -180,9 +174,7 @@ dirstr ="IN" ; } -msg (msglevel,"** CNAT %s %s %s -> %s" , - dirstr, - prefix, +msg (msglevel,"** CNAT %s %s %s -> %s" , dirstr, prefix,print_in_addr_t (iph->saddr,IA_NET_ORDER , &gc),print_in_addr_t (iph->daddr,IA_NET_ORDER , &gc));
@@ -190,11 +182,10 @@ }void -client_nat_transform (const struct client_nat_option_list *list, -struct buffer *ipbuf, +client_nat_transform (const struct client_nat_option_list *list,struct buffer *ipbuf,const int direction) { -struct ip_tcp_udp_hdr *h = (struct ip_tcp_udp_hdr *)BPTR (ipbuf); +struct ip_tcp_udp_hdr *h = (struct ip_tcp_udp_hdr *)BPTR (ipbuf);int i;uint32_t addr, *addr_ptr;const uint32_t *from, *to;
src/openvpn/clinat.h +12 -12
@@ -31,7 +31,8 @@#define CN_OUTGOING 0#define CN_INCOMING 1 -struct client_nat_entry { +struct client_nat_entry +{#define CN_SNAT 0#define CN_DNAT 1int type;
@@ -40,28 +41,27 @@in_addr_t foreign_network; }; -struct client_nat_option_list { +struct client_nat_option_list +{int n;struct client_nat_entry entries[MAX_CLIENT_NAT ]; };struct client_nat_option_list *new_client_nat_list (struct gc_arena *gc); -struct client_nat_option_list *clone_client_nat_option_list (const struct client_nat_option_list *src,struct gc_arena *gc); +struct client_nat_option_list *clone_client_nat_option_list ( +const struct client_nat_option_list *src,struct gc_arena *gc); -void copy_client_nat_option_list (struct client_nat_option_list *dest,const struct client_nat_option_list *src); +void copy_client_nat_option_list (struct client_nat_option_list *dest, +const struct client_nat_option_list *src);void print_client_nat_list (const struct client_nat_option_list *list,int msglevel); -void add_client_nat_to_option_list (struct client_nat_option_list *dest, -const char *type, -const char *network, -const char *netmask, -const char *foreign_network, -int msglevel); +void add_client_nat_to_option_list (struct client_nat_option_list *dest,const char *type, +const char *network,const char *netmask, +const char *foreign_network,int msglevel); -void client_nat_transform (const struct client_nat_option_list *list, -struct buffer *ipbuf, +void client_nat_transform (const struct client_nat_option_list *list,struct buffer *ipbuf,const int direction);#endif /* if !defined(CLINAT_H) */
src/openvpn/common.h +7 -6
@@ -28,7 +28,7 @@* Statistics counters and associated printf format. */ typedef uint64_t counter_type ; -#define counter_format "%" PRIu64 +#define counter_format "%" PRIu64/* * Time intervals
@@ -38,17 +38,17 @@/* * Used as an upper bound for timeouts. */ -#define BIG_TIMEOUT (60*60*24*7)/* one week (in seconds) */ +#define BIG_TIMEOUT (60 * 60 * 24 * 7)/* one week (in seconds) */ /* * Printf formats for special types */ #ifdef _WIN64 -#define ptr_format "0x%016" PRIx64 +#define ptr_format "0x%016" PRIx64#else -#define ptr_format "0x%08lx" +#define ptr_format "0x%08lx"#endif -#define fragment_header_format "0x%08x" +#define fragment_header_format "0x%08x"/* these are used to cast the arguments * and MUST match the formats above */
@@ -95,6 +95,7 @@/* * Script security warning */ -#define SCRIPT_SECURITY_WARNING "WARNING: External program may not be called unless '--script-security 2' or higher is enabled. See --help text or man page for detailed info." +#define SCRIPT_SECURITY_WARNING \ + "WARNING: External program may not be called unless '--script-security 2' or higher is enabled. See --help text or man page for detailed info."#endif /* ifndef COMMON_H */
src/openvpn/comp-lz4.c +13 -28
86 lines not on this page · raw message
src/openvpn/comp.c +5 -5
@@ -172,10 +172,10 @@ {#ifdef USE_COMP msg (msglevel,"Compression or compression stub framing is not allowed " -"since data-channel offloading is enabled." ); +"since data-channel offloading is enabled." );#else msg (msglevel,"Compression or compression stub framing is not allowed " -"since OpenVPN was built without compression support." ); +"since OpenVPN was built without compression support." );#endif return false; }
@@ -183,14 +183,14 @@if ((info->flags &COMP_F_ALLOW_STUB_ONLY ) &&comp_non_stub_enabled (info)) {msg (msglevel,"Compression is not allowed since allow-compression is " -"set to 'stub-only'" ); +"set to 'stub-only'" );return false; }#ifndef ENABLE_LZ4 if (info->alg ==COMP_ALGV2_LZ4 || info->alg ==COMP_ALG_LZ4 ) {msg (msglevel,"OpenVPN is compiled without LZ4 support. Requested " -"compression cannot be enabled." ); +"compression cannot be enabled." );return false; }#endif
@@ -198,7 +198,7 @@if (info->alg ==COMP_ALG_LZO ) {msg (msglevel,"OpenVPN is compiled without LZO support. Requested " -"compression cannot be enabled." ); +"compression cannot be enabled." );return false; }#endif
src/openvpn/comp.h +21 -24
102 lines not on this page · raw message
src/openvpn/compstub.c +9 -23
@@ -46,8 +46,7 @@ }static void -stub_compress (struct buffer *buf,struct buffer work, -struct compress_context *compctx, +stub_compress (struct buffer *buf,struct buffer work,struct compress_context *compctx,const struct frame *frame) {if (buf->len <=0 )
@@ -57,7 +56,7 @@if (compctx->flags &COMP_F_SWAP ) {uint8_t *head =BPTR (buf); -uint8_t *tail =BEND (buf); +uint8_t *tail =BEND (buf);ASSERT (buf_safe (buf,1 )); ++buf->len;
@@ -73,8 +72,7 @@ }static void -stub_decompress (struct buffer *buf,struct buffer work, -struct compress_context *compctx, +stub_decompress (struct buffer *buf,struct buffer work,struct compress_context *compctx,const struct frame *frame) {uint8_t c;
@@ -108,8 +106,7 @@static void -stubv2_compress (struct buffer *buf,struct buffer work, -struct compress_context *compctx, +stubv2_compress (struct buffer *buf,struct buffer work,struct compress_context *compctx,const struct frame *frame) {if (buf->len <=0 )
@@ -121,8 +118,7 @@ }static void -stubv2_decompress (struct buffer *buf,struct buffer work, -struct compress_context *compctx, +stubv2_decompress (struct buffer *buf,struct buffer work,struct compress_context *compctx,const struct frame *frame) {if (buf->len <=0 )
@@ -158,19 +154,9 @@ } } -const struct compress_alg compv2_stub_alg = { -"stubv2" , - stub_compress_init, - stub_compress_uninit, - stubv2_compress, - stubv2_decompress -}; +const struct compress_alg compv2_stub_alg = {"stubv2" , stub_compress_init, stub_compress_uninit, + stubv2_compress, stubv2_decompress }; -const struct compress_alg comp_stub_alg = { -"stub" , - stub_compress_init, - stub_compress_uninit, - stub_compress, - stub_decompress -}; +const struct compress_alg comp_stub_alg = {"stub" , stub_compress_init, stub_compress_uninit, + stub_compress, stub_decompress };#endif /* USE_STUB */
src/openvpn/console.c +4 -6
@@ -38,7 +38,7 @@#endif -struct _query_user query_user[QUERY_USER_NUMSLOTS ];/* GLOBAL */ +struct _query_user query_user[QUERY_USER_NUMSLOTS ];/* GLOBAL */ void
@@ -54,16 +54,14 @@void -query_user_add (char *prompt,size_t prompt_len, -char *resp,size_t resp_len, -bool echo) +query_user_add (char *prompt,size_t prompt_len,char *resp,size_t resp_len,bool echo) {int i;/* Ensure input is sane. All these must be present otherwise it is * a programming error. */ -ASSERT ( prompt_len >0 && prompt !=NULL && resp_len >0 && resp !=NULL ); +ASSERT (prompt_len >0 && prompt !=NULL && resp_len >0 && resp !=NULL );/* Seek to the last unused slot */ for (i =0 ; i <QUERY_USER_NUMSLOTS ; i++)
@@ -73,7 +71,7 @@break ; } } -ASSERT ( i <QUERY_USER_NUMSLOTS );/* Unlikely, but we want to panic if it happens */ +ASSERT (i <QUERY_USER_NUMSLOTS );/* Unlikely, but we want to panic if it happens */ /* Save the information needed for the user interaction */ query_user[i].prompt = prompt;
src/openvpn/console.h +11 -14
@@ -31,16 +31,17 @@/** * Configuration setup for declaring what kind of information to ask a user for */ -struct _query_user { -char *prompt;/**< Prompt to present to the user */ -size_t prompt_len;/**< Length of the prompt string */ -char *response;/**< The user's response */ -size_t response_len;/**< Length the of the user response */ -bool echo;/**< True: The user should see what is being typed, otherwise mask it */ +struct _query_user +{ +char *prompt;/**< Prompt to present to the user */ +size_t prompt_len;/**< Length of the prompt string */ +char *response;/**< The user's response */ +size_t response_len;/**< Length the of the user response */ +bool echo;/**< True: The user should see what is being typed, otherwise mask it */ };#define QUERY_USER_NUMSLOTS 10 -extern struct _query_user query_user[];/**< Global variable, declared in console.c */ +extern struct _query_user query_user[];/**< Global variable, declared in console.c */ /** * Wipes all data put into all of the query_user structs
@@ -59,9 +60,7 @@* @param echo Should the user input be echoed to the user? If False, input will be masked * */ -void query_user_add (char *prompt,size_t prompt_len, -char *resp,size_t resp_len, -bool echo); +void query_user_add (char *prompt,size_t prompt_len,char *resp,size_t resp_len,bool echo);/**
@@ -108,7 +107,7 @@ {return query_user_exec_builtin (); } -#endif /* defined(ENABLE_SYSTEMD) */ +#endif /* defined(ENABLE_SYSTEMD) */ /**
@@ -119,9 +118,7 @@* */ static inline bool -query_user_SINGLE (char *prompt,size_t prompt_len, -char *resp,size_t resp_len, -bool echo) +query_user_SINGLE (char *prompt,size_t prompt_len,char *resp,size_t resp_len,bool echo) {query_user_clear ();query_user_add (prompt, prompt_len, resp, resp_len, echo);
src/openvpn/console_builtin.c +12 -11
@@ -68,11 +68,10 @@HANDLE in =GetStdHandle (STD_INPUT_HANDLE );int orig_stderr =get_orig_stderr ();/* guaranteed to be always valid */ -if ((in ==INVALID_HANDLE_VALUE ) - ||win32_service_interrupt (&win32_signal) +if ((in ==INVALID_HANDLE_VALUE ) ||win32_service_interrupt (&win32_signal) || (_write (orig_stderr, prompt,strlen (prompt)) ==-1 )) { -msg (M_WARN |M_ERRNO ,"get_console_input_win32(): unexpected error" ); +msg (M_WARN |M_ERRNO ,"get_console_input_win32(): unexpected error" );return false; }
@@ -136,7 +135,7 @@ return false; } -#endif /* _WIN32 */ +#endif /* _WIN32 */ #ifdef HAVE_TERMIOS_H
@@ -178,7 +177,7 @@ } } -#endif /* HAVE_TERMIOS_H */ +#endif /* HAVE_TERMIOS_H */ /**
@@ -210,15 +209,17 @@* (in which case neither stdin or stderr are connected to a tty and * /dev/tty can not be open()ed anymore) */ -if (!isatty (0 ) && !isatty (2 ) ) +if (!isatty (0 ) && !isatty (2 )) { -int fd =open ("/dev/tty" ,O_RDWR ); +int fd =open ("/dev/tty" ,O_RDWR );if (fd <0 ) { -msg (M_FATAL ,"neither stdin nor stderr are a tty device and you have neither a " +msg (M_FATAL , +"neither stdin nor stderr are a tty device and you have neither a " "controlling tty nor systemd - can't ask for '%s'. If you used --daemon, " "you need to use --askpass to make passphrase-protected keys work, and you " -"can not use --auth-nocache." , prompt ); +"can not use --auth-nocache." , + prompt); }close (fd); }
@@ -286,8 +287,8 @@/* Loop through configured query_user slots */ for (i =0 ; i <QUERY_USER_NUMSLOTS && query_user[i].response !=NULL ; i++) { -if (!get_console_input (query_user[i].prompt, query_user[i].echo, - query_user[i].response, query_user[i].response_len) ) +if (!get_console_input (query_user[i].prompt, query_user[i].echo, query_user[i].response, + query_user[i].response_len)) {/* Force the final result state to failed on failure */ ret = false;
src/openvpn/console_systemd.c +4 -6
@@ -51,9 +51,7 @@* mounted, as well as the systemd-ask-password executable * being available */ -return (sd_booted () >0 ) - && (stat (SYSTEMD_ASK_PASSWORD_PATH , &c) ==0 ); - +return (sd_booted () >0 ) && (stat (SYSTEMD_ASK_PASSWORD_PATH , &c) ==0 ); } static bool
@@ -80,7 +78,7 @@return false; }memset (input,0 , capacity); -if (read (std_out, input, capacity-1 ) !=0 ) +if (read (std_out, input, capacity -1 ) !=0 ) {chomp (input); ret = true;
@@ -100,7 +98,7 @@bool query_user_exec_systemd (void ) { -bool ret = true;/* Presume everything goes okay */ +bool ret = true;/* Presume everything goes okay */ int i;/* If systemd is not available, use the default built-in mechanism */
@@ -113,7 +111,7 @@for (i =0 ; i <QUERY_USER_NUMSLOTS && query_user[i].response !=NULL ; i++) {if (!get_console_input_systemd (query_user[i].prompt, query_user[i].echo, - query_user[i].response, query_user[i].response_len) ) + query_user[i].response, query_user[i].response_len)) {/* Force the final result state to failed on failure */ ret = false;
src/openvpn/crypto.c +122 -168
145 lines not on this page · raw message
src/openvpn/crypto.h +88 -102
190 lines not on this page · raw message
src/openvpn/crypto_epoch.c +27 -43
70 lines not on this page · raw message
src/openvpn/crypto_epoch.h +16 -30
46 lines not on this page · raw message
src/openvpn/crypto_mbedtls.c +74 -74
148 lines not on this page · raw message
src/openvpn/crypto_openssl.c +85 -97
182 lines not on this page · raw message
src/openvpn/cryptoapi.c +57 -52
109 lines not on this page · raw message
src/openvpn/dco.c +57 -59
116 lines not on this page · raw message
src/openvpn/dco_linux.c +79 -113
192 lines not on this page · raw message
src/openvpn/dco_win.c +63 -56
119 lines not on this page · raw message
src/openvpn/dco_win.h +20 -23
43 lines not on this page · raw message
src/openvpn/dhcp.c +28 -28
56 lines not on this page · raw message
src/openvpn/dns.c +35 -36
71 lines not on this page · raw message
src/openvpn/errlevel.h +115 -115
230 lines not on this page · raw message
src/openvpn/error.c +51 -86
137 lines not on this page · raw message
src/openvpn/error.h +77 -41
118 lines not on this page · raw message
src/openvpn/event.c +80 -98
178 lines not on this page · raw message
src/openvpn/event.h +34 -31
65 lines not on this page · raw message
src/openvpn/forward.c +113 -152
265 lines not on this page · raw message
src/openvpn/forward.h +32 -33
65 lines not on this page · raw message
src/openvpn/fragment.c +40 -54
94 lines not on this page · raw message
src/openvpn/fragment.h +39 -39
78 lines not on this page · raw message
src/openvpn/helper.c +48 -40
88 lines not on this page · raw message
src/openvpn/httpdigest.c +39 -50
89 lines not on this page · raw message
src/openvpn/init.c +306 -476
782 lines not on this page · raw message
src/openvpn/list.c +59 -57
116 lines not on this page · raw message
src/openvpn/manage.c +278 -355
633 lines not on this page · raw message
src/openvpn/manage.h +114 -143
257 lines not on this page · raw message
src/openvpn/misc.c +139 -138
277 lines not on this page · raw message
src/openvpn/misc.h +36 -41
77 lines not on this page · raw message
src/openvpn/mroute.c +32 -45
77 lines not on this page · raw message
src/openvpn/mroute.h +62 -67
129 lines not on this page · raw message
src/openvpn/mss.c +33 -47
80 lines not on this page · raw message
src/openvpn/mtu.c +20 -29
49 lines not on this page · raw message
src/openvpn/mtu.h +65 -76
141 lines not on this page · raw message
src/openvpn/mudp.c +30 -33
63 lines not on this page · raw message
src/openvpn/multi.c +356 -479
835 lines not on this page · raw message
src/openvpn/multi.h +65 -67
132 lines not on this page · raw message
src/openvpn/multi_io.c +66 -74
140 lines not on this page · raw message
src/openvpn/networking.h +25 -36
61 lines not on this page · raw message
src/openvpn/networking_freebsd.c +20 -34
54 lines not on this page · raw message
src/openvpn/networking_iproute2.c +37 -57
94 lines not on this page · raw message
src/openvpn/networking_sitnl.c +165 -209
374 lines not on this page · raw message
src/openvpn/ntlm.c +50 -55
105 lines not on this page · raw message
src/openvpn/occ.c +96 -111
207 lines not on this page · raw message
src/openvpn/openvpn.h +68 -64
132 lines not on this page · raw message
src/openvpn/options.c +711 -830
1,541 lines not on this page · raw message
src/openvpn/options.h +95 -115
210 lines not on this page · raw message
src/openvpn/ovpn_dco_freebsd.h +28 -24
52 lines not on this page · raw message
src/openvpn/packet_id.c +41 -72
113 lines not on this page · raw message
src/openvpn/packet_id.h +29 -33
62 lines not on this page · raw message
src/openvpn/perf.c +31 -43
74 lines not on this page · raw message
src/openvpn/perf.h +22 -22
44 lines not on this page · raw message
src/openvpn/pkcs11.c +165 -383
548 lines not on this page · raw message
src/openvpn/pkcs11.h +12 -37
49 lines not on this page · raw message
src/openvpn/pkcs11_openssl.c +40 -41
81 lines not on this page · raw message
src/openvpn/platform.c +36 -38
74 lines not on this page · raw message
src/openvpn/plugin.c +85 -116
201 lines not on this page · raw message
src/openvpn/plugin.h +26 -35
61 lines not on this page · raw message
src/openvpn/pool.c +49 -75
124 lines not on this page · raw message
src/openvpn/proto.h +90 -84
174 lines not on this page · raw message
src/openvpn/proxy.c +80 -120
200 lines not on this page · raw message
src/openvpn/ps.c +53 -69
122 lines not on this page · raw message
src/openvpn/push.c +84 -108
192 lines not on this page · raw message
src/openvpn/reliable.c +28 -35
63 lines not on this page · raw message
src/openvpn/reliable.h +25 -29
54 lines not on this page · raw message
src/openvpn/ring_buffer.h new file +124 -0
124 lines not on this page · raw message
src/openvpn/route.c +420 -687
1,107 lines not on this page · raw message
src/openvpn/route.h +108 -115
223 lines not on this page · raw message
src/openvpn/run_command.h +20 -21
41 lines not on this page · raw message
src/openvpn/schedule.c +16 -35
51 lines not on this page · raw message
src/openvpn/sig.c +28 -31
59 lines not on this page · raw message
src/openvpn/socket.c +339 -560
899 lines not on this page · raw message
src/openvpn/socket.h +162 -227
389 lines not on this page · raw message
src/openvpn/socks.c +55 -61
116 lines not on this page · raw message
src/openvpn/ssl.c +265 -427
692 lines not on this page · raw message
src/openvpn/ssl.h +45 -71
116 lines not on this page · raw message
src/openvpn/ssl_backend.h +27 -38
65 lines not on this page · raw message
src/openvpn/ssl_common.h +94 -85
179 lines not on this page · raw message
src/openvpn/ssl_mbedtls.c +122 -181
303 lines not on this page · raw message
src/openvpn/ssl_mbedtls.h +36 -29
65 lines not on this page · raw message
src/openvpn/ssl_ncp.c +44 -57
101 lines not on this page · raw message
src/openvpn/ssl_openssl.c +144 -178
322 lines not on this page · raw message
src/openvpn/ssl_pkt.c +38 -70
108 lines not on this page · raw message
src/openvpn/ssl_pkt.h +44 -62
106 lines not on this page · raw message
src/openvpn/ssl_util.c +152 -141
293 lines not on this page · raw message
src/openvpn/ssl_verify.c +165 -166
331 lines not on this page · raw message
src/openvpn/ssl_verify.h +24 -27
51 lines not on this page · raw message
src/openvpn/ssl_verify_mbedtls.c +55 -67
122 lines not on this page · raw message
src/openvpn/ssl_verify_openssl.c +44 -54
98 lines not on this page · raw message
src/openvpn/syshead.h +25 -23
48 lines not on this page · raw message
src/openvpn/tls_crypt.c +87 -140
227 lines not on this page · raw message
src/openvpn/tls_crypt.h +22 -29
51 lines not on this page · raw message
src/openvpn/tun.c +616 -944
1,560 lines not on this page · raw message
src/openvpn/tun.h +58 -65
123 lines not on this page · raw message
src/openvpn/wfp_block.c +31 -66
97 lines not on this page · raw message
src/openvpn/win32.c +87 -100
187 lines not on this page · raw message
src/openvpn/win32.h +30 -33
63 lines not on this page · raw message
src/openvpn/xkey_helper.c +47 -50
97 lines not on this page · raw message
src/openvpn/xkey_provider.c +154 -146
300 lines not on this page · raw message
src/openvpnmsica/openvpnmsica.c +179 -170
349 lines not on this page · raw message
src/openvpnmsica/openvpnmsica.h +75 -79
154 lines not on this page · raw message
src/openvpnserv/common.c +24 -25
49 lines not on this page · raw message
src/openvpnserv/interactive.c +196 -211
407 lines not on this page · raw message
src/openvpnserv/service.c +21 -25
46 lines not on this page · raw message
src/plugins/auth-pam/auth-pam.c +76 -68
144 lines not on this page · raw message
src/plugins/auth-pam/pamdl.c +29 -37
66 lines not on this page · raw message
src/tapctl/error.h +45 -21
66 lines not on this page · raw message
src/tapctl/main.c +72 -60
132 lines not on this page · raw message
src/tapctl/tap.c +148 -271
419 lines not on this page · raw message
src/tapctl/tap.h +13 -29
42 lines not on this page · raw message
tests/unit_tests/openvpn/cert_data.h +34 -36
70 lines not on this page · raw message
tests/unit_tests/openvpn/mock_management.c +1 -2
Lines of this file are not shown. View the raw message.
tests/unit_tests/openvpn/mock_ssl_dependencies.c +2 -2
Lines of this file are not shown. View the raw message.
tests/unit_tests/openvpn/pkey_test_utils.c +5 -6
Lines of this file are not shown. View the raw message.
tests/unit_tests/openvpn/test_auth_token.c +59 -66
125 lines not on this page · raw message
tests/unit_tests/openvpn/test_buffer.c +28 -37
65 lines not on this page · raw message
tests/unit_tests/openvpn/test_crypto.c +85 -131
216 lines not on this page · raw message
tests/unit_tests/openvpn/test_cryptoapi.c +41 -42
83 lines not on this page · raw message
tests/unit_tests/openvpn/test_misc.c +38 -35
73 lines not on this page · raw message
tests/unit_tests/openvpn/test_ncp.c +34 -46
80 lines not on this page · raw message
tests/unit_tests/openvpn/test_networking.c +4 -10
Lines of this file are not shown. View the raw message.
tests/unit_tests/openvpn/test_packet_id.c +25 -32
57 lines not on this page · raw message
tests/unit_tests/openvpn/test_pkcs11.c +46 -47
93 lines not on this page · raw message
tests/unit_tests/openvpn/test_pkt.c +94 -120
214 lines not on this page · raw message
tests/unit_tests/openvpn/test_provider.c +27 -26
53 lines not on this page · raw message
tests/unit_tests/openvpn/test_ssl.c +24 -31
55 lines not on this page · raw message
tests/unit_tests/openvpn/test_tls_crypt.c +105 -150
255 lines not on this page · raw message
tests/unit_tests/openvpn/test_user_pass.c +17 -14
Lines of this file are not shown. View the raw message.
tests/unit_tests/plugins/auth-pam/test_search_and_replace.c +0 -2
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/791?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I2566ad493629e1f5fdfa6f6483b8973463404e3e
Gerrit-Change-Number: 791
Gerrit-PatchSet: 22
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-MessageType: newpatchset
Part of the diff is not shown here. View the raw message.
Attention is currently required from: cron2, ordex, plaisthos.
Hello plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/791?usp=email
to look at the new patch set (#23).
Change subject: Reformat the whole project with clang-format
......................................................................
Reformat the whole project with clang-format
Done with pre-commit run -a, so the version
defined in pre-commit config is used.
This also changes the Github workflow so that
there is no commit that fails GHA.
---
M .github/workflows/build.yaml
M include/openvpn-msg.h
M sample/sample-plugins/client-connect/sample-client-connect.c
M sample/sample-plugins/defer/multi-auth.c
M sample/sample-plugins/keying-material-exporter-demo/keyingmaterialexporter.c M sample/sample-plugins/log/log.c
M sample/sample-plugins/log/log_v3.c
M sample/sample-plugins/simple/base64.c
M sample/sample-plugins/simple/simple.c
M src/compat/compat-basename.c
M src/compat/compat-dirname.c
M src/compat/compat-gettimeofday.c
M src/openvpn/argv.c
M src/openvpn/argv.h
M src/openvpn/auth_token.c
M src/openvpn/auth_token.h
M src/openvpn/base64.c
M src/openvpn/base64.h
M src/openvpn/basic.h
M src/openvpn/buffer.c
M src/openvpn/buffer.h
M src/openvpn/circ_list.h
M src/openvpn/clinat.c
M src/openvpn/clinat.h
M src/openvpn/common.h
M src/openvpn/comp-lz4.c
M src/openvpn/comp.c
M src/openvpn/comp.h
M src/openvpn/compstub.c
M src/openvpn/console.c
M src/openvpn/console.h
M src/openvpn/console_builtin.c
M src/openvpn/console_systemd.c
M src/openvpn/crypto.c
M src/openvpn/crypto.h
M src/openvpn/crypto_backend.h
M src/openvpn/crypto_epoch.c
M src/openvpn/crypto_epoch.h
M src/openvpn/crypto_mbedtls.c
M src/openvpn/crypto_mbedtls.h
M src/openvpn/crypto_openssl.c
M src/openvpn/crypto_openssl.h
M src/openvpn/cryptoapi.c
M src/openvpn/dco.c
M src/openvpn/dco.h
M src/openvpn/dco_freebsd.c
M src/openvpn/dco_freebsd.h
M src/openvpn/dco_internal.h
M src/openvpn/dco_linux.c
M src/openvpn/dco_linux.h
M src/openvpn/dco_win.c
M src/openvpn/dco_win.h
M src/openvpn/dhcp.c
M src/openvpn/dhcp.h
M src/openvpn/dns.c
M src/openvpn/dns.h
M src/openvpn/env_set.c
M src/openvpn/env_set.h
M src/openvpn/errlevel.h
M src/openvpn/error.c
M src/openvpn/error.h
M src/openvpn/event.c
M src/openvpn/event.h
M src/openvpn/fdmisc.c
M src/openvpn/fdmisc.h
M src/openvpn/forward.c
M src/openvpn/forward.h
M src/openvpn/fragment.c
M src/openvpn/fragment.h
M src/openvpn/gremlin.c
M src/openvpn/gremlin.h
M src/openvpn/helper.c
M src/openvpn/httpdigest.c
M src/openvpn/httpdigest.h
M src/openvpn/init.c
M src/openvpn/init.h
M src/openvpn/integer.h
M src/openvpn/interval.c
M src/openvpn/interval.h
M src/openvpn/list.c
M src/openvpn/list.h
M src/openvpn/lladdr.c
M src/openvpn/lzo.c
M src/openvpn/lzo.h
M src/openvpn/manage.c
M src/openvpn/manage.h
M src/openvpn/mbedtls_compat.h
M src/openvpn/mbuf.c
M src/openvpn/mbuf.h
M src/openvpn/memdbg.h
M src/openvpn/misc.c
M src/openvpn/misc.h
M src/openvpn/mroute.c
M src/openvpn/mroute.h
M src/openvpn/mss.c
M src/openvpn/mss.h
M src/openvpn/mstats.c
M src/openvpn/mstats.h
M src/openvpn/mtcp.c
M src/openvpn/mtcp.h
M src/openvpn/mtu.c
M src/openvpn/mtu.h
M src/openvpn/mudp.c
M src/openvpn/multi.c
M src/openvpn/multi.h
M src/openvpn/multi_io.c
M src/openvpn/networking.h
M src/openvpn/networking_freebsd.c
M src/openvpn/networking_iproute2.c
M src/openvpn/networking_sitnl.c
M src/openvpn/ntlm.c
M src/openvpn/occ.c
M src/openvpn/occ.h
M src/openvpn/openssl_compat.h
M src/openvpn/openvpn.c
M src/openvpn/openvpn.h
M src/openvpn/options.c
M src/openvpn/options.h
M src/openvpn/options_util.c
M src/openvpn/options_util.h
M src/openvpn/otime.c
M src/openvpn/otime.h
M src/openvpn/ovpn_dco_freebsd.h
M src/openvpn/packet_id.c
M src/openvpn/packet_id.h
M src/openvpn/perf.c
M src/openvpn/perf.h
M src/openvpn/ping.c
M src/openvpn/ping.h
M src/openvpn/pkcs11.c
M src/openvpn/pkcs11.h
M src/openvpn/pkcs11_backend.h
M src/openvpn/pkcs11_mbedtls.c
M src/openvpn/pkcs11_openssl.c
M src/openvpn/platform.c
M src/openvpn/platform.h
M src/openvpn/plugin.c
M src/openvpn/plugin.h
M src/openvpn/pool.c
M src/openvpn/pool.h
M src/openvpn/proto.c
M src/openvpn/proto.h
M src/openvpn/proxy.c
M src/openvpn/proxy.h
M src/openvpn/ps.c
M src/openvpn/ps.h
M src/openvpn/push.c
M src/openvpn/push.h
M src/openvpn/push_util.c
M src/openvpn/pushlist.h
M src/openvpn/reflect_filter.c
M src/openvpn/reflect_filter.h
M src/openvpn/reliable.c
M src/openvpn/reliable.h
A src/openvpn/ring_buffer.h
M src/openvpn/route.c
M src/openvpn/route.h
M src/openvpn/run_command.c
M src/openvpn/run_command.h
M src/openvpn/schedule.c
M src/openvpn/schedule.h
M src/openvpn/session_id.h
M src/openvpn/shaper.c
M src/openvpn/shaper.h
M src/openvpn/sig.c
M src/openvpn/sig.h
M src/openvpn/socket.c
M src/openvpn/socket.h
M src/openvpn/socks.c
M src/openvpn/socks.h
M src/openvpn/ssl.c
M src/openvpn/ssl.h
M src/openvpn/ssl_backend.h
M src/openvpn/ssl_common.h
M src/openvpn/ssl_mbedtls.c
M src/openvpn/ssl_mbedtls.h
M src/openvpn/ssl_ncp.c
M src/openvpn/ssl_ncp.h
M src/openvpn/ssl_openssl.c
M src/openvpn/ssl_openssl.h
M src/openvpn/ssl_pkt.c
M src/openvpn/ssl_pkt.h
M src/openvpn/ssl_util.c
M src/openvpn/ssl_util.h
M src/openvpn/ssl_verify.c
M src/openvpn/ssl_verify.h
M src/openvpn/ssl_verify_backend.h
M src/openvpn/ssl_verify_mbedtls.c
M src/openvpn/ssl_verify_mbedtls.h
M src/openvpn/ssl_verify_openssl.c
M src/openvpn/status.c
M src/openvpn/status.h
M src/openvpn/syshead.h
M src/openvpn/tls_crypt.c
M src/openvpn/tls_crypt.h
M src/openvpn/tun.c
M src/openvpn/tun.h
M src/openvpn/tun_afunix.c
M src/openvpn/tun_afunix.h
M src/openvpn/vlan.c
M src/openvpn/vlan.h
M src/openvpn/wfp_block.c
M src/openvpn/wfp_block.h
M src/openvpn/win32-util.c
M src/openvpn/win32.c
M src/openvpn/win32.h
M src/openvpn/xkey_common.h
M src/openvpn/xkey_helper.c
M src/openvpn/xkey_provider.c
M src/openvpnmsica/dllmain.c
M src/openvpnmsica/msica_arg.c
M src/openvpnmsica/msica_arg.h
M src/openvpnmsica/msiex.c
M src/openvpnmsica/msiex.h
M src/openvpnmsica/openvpnmsica.c
M src/openvpnmsica/openvpnmsica.h
M src/openvpnserv/common.c
M src/openvpnserv/interactive.c
M src/openvpnserv/service.c
M src/openvpnserv/service.h
M src/openvpnserv/validate.c
M src/openvpnserv/validate.h
M src/plugins/auth-pam/auth-pam.c
M src/plugins/auth-pam/pamdl.c
M src/plugins/auth-pam/utils.c
M src/plugins/auth-pam/utils.h
M src/plugins/down-root/down-root.c
M src/tapctl/basic.h
M src/tapctl/error.h
M src/tapctl/main.c
M src/tapctl/tap.c
M src/tapctl/tap.h
M tests/ntlm_support.c
M tests/unit_tests/example_test/test.c
M tests/unit_tests/example_test/test2.c
M tests/unit_tests/openvpn/cert_data.h
M tests/unit_tests/openvpn/mock_management.c
M tests/unit_tests/openvpn/mock_msg.c
M tests/unit_tests/openvpn/mock_msg.h
M tests/unit_tests/openvpn/mock_ssl_dependencies.c
M tests/unit_tests/openvpn/pkey_test_utils.c
M tests/unit_tests/openvpn/test_argv.c
M tests/unit_tests/openvpn/test_auth_token.c
M tests/unit_tests/openvpn/test_buffer.c
M tests/unit_tests/openvpn/test_crypto.c
M tests/unit_tests/openvpn/test_cryptoapi.c
M tests/unit_tests/openvpn/test_misc.c
M tests/unit_tests/openvpn/test_ncp.c
M tests/unit_tests/openvpn/test_networking.c
M tests/unit_tests/openvpn/test_packet_id.c
M tests/unit_tests/openvpn/test_pkcs11.c
M tests/unit_tests/openvpn/test_pkt.c
M tests/unit_tests/openvpn/test_provider.c
M tests/unit_tests/openvpn/test_push_update_msg.c
M tests/unit_tests/openvpn/test_ssl.c
M tests/unit_tests/openvpn/test_tls_crypt.c
M tests/unit_tests/openvpn/test_user_pass.c
M tests/unit_tests/plugins/auth-pam/test_search_and_replace.c
258 files changed, 12,008 insertions(+), 15,234 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/91/791/23
.github/workflows/build.yaml +12 -21
@@ -5,35 +5,26 @@ pull_request: jobs: - checkuncrustify: - name: "Check code style with Uncrustify" - # Ubuntu 22.04 has uncrustify 0.72_f - runs-on: ubuntu-22.04 + clang-format: + name: Check code style with clang-format + runs-on: ubuntu-24.04 steps: - name: Install dependencies - run: sudo apt update && sudo apt install -y uncrustify + run: | + sudo apt update && sudo apt install -y python3-pip + pip3 install pre-commit - name: Checkout OpenVPN uses: actions/[email protected]... # v4.2.2 - with: - path: openvpn - - name: Show uncrustify version - run: uncrustify --version - - name: Run uncrustify - run: ./dev-tools/reformat-all.sh - working-directory: openvpn + - name: Run clang-format + run: pre-commit run -a --show-diff-on-failure || true - name: Check for changes - run: git diff --output=uncrustify-changes.patch - working-directory: openvpn - - name: Show changes on standard output - run: git diff - working-directory: openvpn + run: git diff --output=format-changes.patch - uses: actions/[email protected]... # v4.6.2 with: - name: uncrustify-changes.patch - path: 'openvpn/uncrustify-changes.patch' + name: format-changes.patch + path: format-changes.patch - name: Set job status - run: test ! -s uncrustify-changes.patch - working-directory: openvpn + run: test ! -s format-changes.patch android: strategy:
include/openvpn-msg.h +41 -22
159 lines not on this page · raw message
sample/sample-plugins/client-connect/sample-client-connect.c +52 -59
265 lines not on this page · raw message
sample/sample-plugins/defer/multi-auth.c +34 -40
208 lines not on this page · raw message
sample/sample-plugins/keying-material-exporter-demo/keyingmaterialexporter.c +26 -25
119 lines not on this page · raw message
sample/sample-plugins/log/log.c +19 -19
@@ -36,7 +36,8 @@/* * Our context, where we keep our state. */ -struct plugin_context { +struct plugin_context +{const char *username;const char *password; };
@@ -75,7 +76,7 @@/* * Allocate our context */ - context = (struct plugin_context *)calloc (1 ,sizeof (struct plugin_context )); + context = (struct plugin_context *)calloc (1 ,sizeof (struct plugin_context ));if (context ==NULL ) {printf ("PLUGIN: allocating memory for context failed\n" );
@@ -91,19 +92,17 @@/* * Which callbacks to intercept. */ - *type_mask = -OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_UP ) - |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_DOWN ) - |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_ROUTE_UP ) - |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_IPCHANGE ) - |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_TLS_VERIFY ) - |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY ) - |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_CLIENT_CONNECT_V2 ) - |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_CLIENT_DISCONNECT ) - |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_LEARN_ADDRESS ) - |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_TLS_FINAL ); + *type_mask =OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_UP ) |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_DOWN ) + |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_ROUTE_UP ) + |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_IPCHANGE ) + |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_TLS_VERIFY ) + |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY ) + |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_CLIENT_CONNECT_V2 ) + |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_CLIENT_DISCONNECT ) + |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_LEARN_ADDRESS ) + |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_TLS_FINAL ); -return (openvpn_plugin_handle_t ) context; +return (openvpn_plugin_handle_t )context; }void
@@ -171,9 +170,10 @@ } OPENVPN_EXPORT int -openvpn_plugin_func_v1 (openvpn_plugin_handle_t handle,const int type,const char *argv[],const char *envp[]) +openvpn_plugin_func_v1 (openvpn_plugin_handle_t handle,const int type,const char *argv[], +const char *envp[]) { -struct plugin_context *context = (struct plugin_context *) handle; +struct plugin_context *context = (struct plugin_context *)handle;show (type, argv, envp);
@@ -184,8 +184,8 @@const char *username =get_env ("username" , envp);const char *password =get_env ("password" , envp); -if (username && !strcmp (username, context->username) - && password && !strcmp (password, context->password)) +if (username && !strcmp (username, context->username) && password + && !strcmp (password, context->password)) {return OPENVPN_PLUGIN_FUNC_SUCCESS ; }
@@ -203,6 +203,6 @@ OPENVPN_EXPORT voidopenvpn_plugin_close_v1 (openvpn_plugin_handle_t handle) { -struct plugin_context *context = (struct plugin_context *) handle; +struct plugin_context *context = (struct plugin_context *)handle;free (context); }
sample/sample-plugins/log/log_v3.c +24 -27
106 lines not on this page · raw message
sample/sample-plugins/simple/base64.c +15 -17
@@ -98,21 +98,20 @@* */ OPENVPN_EXPORT int -openvpn_plugin_open_v3 (const int v3structver, -struct openvpn_plugin_args_open_in const *args, +openvpn_plugin_open_v3 (const int v3structver,struct openvpn_plugin_args_open_in const *args,struct openvpn_plugin_args_open_return *ret) {/* Check that we are API compatible */ if (v3structver != OPENVPN_PLUGINv3_STRUCTVER) { -printf ("base64.c: ** ERROR ** Incompatible plug-in interface between this plug-in and OpenVPN\n" ); +printf ( +"base64.c: ** ERROR ** Incompatible plug-in interface between this plug-in and OpenVPN\n" );return OPENVPN_PLUGIN_FUNC_ERROR ; }/* Which callbacks to intercept. */ - ret->type_mask = -OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_TLS_VERIFY ) - |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_CLIENT_CONNECT_V2 ); + ret->type_mask =OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_TLS_VERIFY ) + |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_CLIENT_CONNECT_V2 );/* we don't need a plug-in context in this example, but OpenVPN expects "something" */ ret->handle =calloc (1 ,1 );
@@ -125,8 +124,8 @@/* Print some version information about the OpenVPN process using this plug-in */ ovpn_log (PLOG_NOTE ,PLUGIN_NAME ,"OpenVPN %s (Major: %i, Minor: %i, Patch: %s)\n" , - args->ovpn_version, args->ovpn_version_major, - args->ovpn_version_minor, args->ovpn_version_patch); + args->ovpn_version, args->ovpn_version_major, args->ovpn_version_minor, + args->ovpn_version_patch);return OPENVPN_PLUGIN_FUNC_SUCCESS ; }
@@ -154,10 +153,10 @@*/ OPENVPN_EXPORT int -openvpn_plugin_func_v1 (openvpn_plugin_handle_t handle,const int type,const char *argv[],const char *envp[]) +openvpn_plugin_func_v1 (openvpn_plugin_handle_t handle,const int type,const char *argv[], +const char *envp[]) { -if (type !=OPENVPN_PLUGIN_TLS_VERIFY - && type !=OPENVPN_PLUGIN_CLIENT_CONNECT_V2 ) +if (type !=OPENVPN_PLUGIN_TLS_VERIFY && type !=OPENVPN_PLUGIN_CLIENT_CONNECT_V2 ) {ovpn_log (PLOG_ERR ,PLUGIN_NAME ,"Unsupported plug-in hook call attempted" );return OPENVPN_PLUGIN_FUNC_ERROR ;
@@ -174,14 +173,13 @@/* test the BASE64 encode function */ char *buf =NULL ;int r =ovpn_base64_encode (clcert_cn, (int )strlen (clcert_cn), &buf); -ovpn_log (PLOG_NOTE ,PLUGIN_NAME ,"BASE64 encoded '%s' (return value %i): '%s'" , - clcert_cn, r, buf); +ovpn_log (PLOG_NOTE ,PLUGIN_NAME ,"BASE64 encoded '%s' (return value %i): '%s'" , clcert_cn, r, + buf);/* test the BASE64 decode function */ -char buf2[256 ] = {0 }; +char buf2[256 ] = {0 }; r =ovpn_base64_decode (buf, &buf2,255 ); -ovpn_log (PLOG_NOTE ,PLUGIN_NAME ,"BASE64 decoded '%s' (return value %i): '%s'" , - buf, r, buf2); +ovpn_log (PLOG_NOTE ,PLUGIN_NAME ,"BASE64 decoded '%s' (return value %i): '%s'" , buf, r, buf2);/* Verify the result, and free the buffer allocated by ovpn_base64_encode() */ r =strcmp (clcert_cn, buf2);
@@ -201,6 +199,6 @@ OPENVPN_EXPORT voidopenvpn_plugin_close_v1 (openvpn_plugin_handle_t handle) { -struct plugin_context *context = (struct plugin_context *) handle; +struct plugin_context *context = (struct plugin_context *)handle;free (context); }
sample/sample-plugins/simple/simple.c +10 -8
@@ -38,7 +38,8 @@/* * Our context, where we keep our state. */ -struct plugin_context { +struct plugin_context +{const char *username;const char *password; };
@@ -77,7 +78,7 @@/* * Allocate our context */ - context = (struct plugin_context *)calloc (1 ,sizeof (struct plugin_context )); + context = (struct plugin_context *)calloc (1 ,sizeof (struct plugin_context ));if (context ==NULL ) {printf ("PLUGIN: allocating memory for context failed\n" );
@@ -96,21 +97,22 @@*/ *type_mask =OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY ); -return (openvpn_plugin_handle_t ) context; +return (openvpn_plugin_handle_t )context; } OPENVPN_EXPORT int -openvpn_plugin_func_v1 (openvpn_plugin_handle_t handle,const int type,const char *argv[],const char *envp[]) +openvpn_plugin_func_v1 (openvpn_plugin_handle_t handle,const int type,const char *argv[], +const char *envp[]) { -struct plugin_context *context = (struct plugin_context *) handle; +struct plugin_context *context = (struct plugin_context *)handle;/* get username/password from envp string array */ const char *username =get_env ("username" , envp);const char *password =get_env ("password" , envp);/* check entered username/password against what we require */ -if (username && !strcmp (username, context->username) - && password && !strcmp (password, context->password)) +if (username && !strcmp (username, context->username) && password + && !strcmp (password, context->password)) {return OPENVPN_PLUGIN_FUNC_SUCCESS ; }
@@ -123,6 +125,6 @@ OPENVPN_EXPORT voidopenvpn_plugin_close_v1 (openvpn_plugin_handle_t handle) { -struct plugin_context *context = (struct plugin_context *) handle; +struct plugin_context *context = (struct plugin_context *)handle;free (context); }
src/compat/compat-basename.c +1 -1
@@ -41,7 +41,7 @@/* If NULL, check for \ instead ... might be Windows a path */ p = strrchr(filename, '\\'); } -return p ? p +1 : (char *) filename; +return p ? p +1 : (char *)filename; }#endif /* HAVE_BASENAME */
src/compat/compat-dirname.c +2 -2
@@ -89,7 +89,7 @@/* The '/' is the last character, we have to look further. */ if (runp != path) { - last_slash = (char *)__memrchr (path, separator, runp - path); + last_slash = (char *)__memrchr (path, separator, runp - path); } }
@@ -134,7 +134,7 @@/* This assignment is ill-designed but the XPG specs require to * return a string containing "." in any case no directory part is * found and so a static and constant string is required. */ - path = (char *) dot; + path = (char *)dot; }return path;
src/compat/compat-gettimeofday.c +2 -2
@@ -48,7 +48,7 @@ {const time_t t =time (NULL );const DWORD gtc =GetTickCount (); - gtc_base = t - gtc/1000 ; + gtc_base = t - gtc /1000 ; gtc_last = gtc; }
@@ -112,7 +112,7 @@ return 0; } -#else /* ifdef _WIN32 */ +#else /* ifdef _WIN32 */ #include <time.h>
src/openvpn/argv.c +5 -6
@@ -284,8 +284,7 @@* free()d to avoid memory leaks. */ static char * -argv_prep_format (const char *format,const char delim,size_t *count, -struct gc_arena *gc) +argv_prep_format (const char *format,const char delim,size_t *count,struct gc_arena *gc) {if (format ==NULL ) {
@@ -311,7 +310,7 @@* the string is empty; the resulting format string * will never start with a delimiter. */ -if (j >0 )/* Has anything been written to the output string? */ +if (j >0 )/* Has anything been written to the output string? */ { f[j++] = delim; }
@@ -347,7 +346,7 @@static bool argv_printf_arglist (struct argv *argres,const char *format,va_list arglist) { -const char delim =0x1D ;/* ASCII Group Separator (GS) */ +const char delim =0x1D ;/* ASCII Group Separator (GS) */ bool res = false;/*
@@ -484,8 +483,8 @@argv_reset (argres);char *parms[MAX_PARMS +1 ] = {0 }; -int nparms =parse_line (cmdstr, parms,MAX_PARMS ,"SCRIPT-ARGV" ,0 , -D_ARGV_PARSE_CMD , &argres->gc); +int nparms = +parse_line (cmdstr, parms,MAX_PARMS ,"SCRIPT-ARGV" ,0 ,D_ARGV_PARSE_CMD , &argres->gc);if (nparms) {int i;
src/openvpn/argv.h +8 -7
@@ -31,7 +31,8 @@#include "buffer.h" -struct argv { +struct argv +{struct gc_arena gc;size_t capacity;size_t argc;
@@ -55,21 +56,21 @@ bool argv_printf(struct argv *a, const char *format, ...) #ifdef __GNUC__ #if __USE_MINGW_ANSI_STDIO -__attribute__ ((format(gnu_printf, 2, 3))) + __attribute__((format(gnu_printf, 2, 3))) #else -__attribute__ ((format(__printf__, 2, 3))) + __attribute__((format(__printf__, 2, 3))) #endif #endif -; + ; bool argv_printf_cat(struct argv *a, const char *format, ...) #ifdef __GNUC__ #if __USE_MINGW_ANSI_STDIO -__attribute__ ((format(gnu_printf, 2, 3))) + __attribute__((format(gnu_printf, 2, 3))) #else -__attribute__ ((format(__printf__, 2, 3))) + __attribute__((format(__printf__, 2, 3))) #endif #endif -; + ; #endif /* ifndef ARGV_H */
src/openvpn/auth_token.c +42 -49
245 lines not on this page · raw message
src/openvpn/auth_token.h +7 -15
@@ -58,27 +58,22 @@* This function will free() an existing multi->auth_token and keep the * existing initial timestamp and session id contained in that token. */ -void -generate_auth_token (const struct user_pass *up,struct tls_multi *multi); +void generate_auth_token (const struct user_pass *up,struct tls_multi *multi);/** * Verifies the auth token to be in the format that generate_auth_token * create and checks if the token is valid. * */ -unsigned -verify_auth_token (struct user_pass *up,struct tls_multi *multi, -struct tls_session *session); - +unsigned verify_auth_token (struct user_pass *up,struct tls_multi *multi, +struct tls_session *session);/** * Loads an HMAC secret from a file or if no file is present generates a * epheremal secret for the run time of the server and stores it into ctx */ -void -auth_token_init_secret (struct key_ctx *key_ctx,const char *key_file, -bool key_inline); +void auth_token_init_secret (struct key_ctx *key_ctx,const char *key_file,bool key_inline);/**
@@ -125,8 +120,7 @@static inline bool is_auth_token (const char *password) { -return (memcmp_constant_time (SESSION_ID_PREFIX , password, -strlen (SESSION_ID_PREFIX )) ==0 ); +return (memcmp_constant_time (SESSION_ID_PREFIX , password,strlen (SESSION_ID_PREFIX )) ==0 ); }/** * Checks if a client should be sent a new auth token to update its
@@ -134,15 +128,13 @@* @param multi Pointer the multi object of the TLS session * @param session Pointer to the TLS session itself */ -void -resend_auth_token_renegotiation (struct tls_multi *multi,struct tls_session *session); +void resend_auth_token_renegotiation (struct tls_multi *multi,struct tls_session *session);/** * Checks if the timer to resend the auth-token has expired and if a new * auth-token should be send to the client and triggers the resending */ -void -check_send_auth_token (struct context *c); +void check_send_auth_token (struct context *c);#endif /* AUTH_TOKEN_H */
src/openvpn/base64.c +5 -6
@@ -41,8 +41,7 @@#include "memdbg.h" -static char base64_chars[] = -"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ; +static char base64_chars[] ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ;/* * base64 encode input data of length size to malloced * buffer which is returned as *str. Returns string
@@ -60,14 +59,14 @@ {return -1 ; } - p = s = (char *)malloc (size *4 /3 +4 ); + p = s = (char *)malloc (size *4 /3 +4 );if (p ==NULL ) {return -1 ; } - q = (const unsigned char *) data; + q = (const unsigned char *)data; i =0 ; -for (i =0 ; i < size; ) +for (i =0 ; i < size;) { c = q[i++]; c *=256 ;
@@ -196,5 +195,5 @@ *q++ = val &0xff ; } } -return q - (unsigned char *) data; +return q - (unsigned char *)data; }
src/openvpn/base64.h +2 -4
@@ -35,12 +35,10 @@#define _BASE64_H_/** Compute resulting base64 length. 6 bits per byte, padded to 4 bytes. */ -#define OPENVPN_BASE64_LENGTH (binary_length) \ - ((((8 * binary_length) / 6) + 3) & ~3) +#define OPENVPN_BASE64_LENGTH (binary_length) ((((8 * binary_length) / 6) + 3) & ~3)/** Compute the maximal number of bytes encoded in a base64 string. */ -#define OPENVPN_BASE64_DECODED_LENGTH (base64_length) \ - ((base64_length / 4) * 3) +#define OPENVPN_BASE64_DECODED_LENGTH (base64_length) ((base64_length / 4) * 3)int openvpn_base64_encode (const void *data,int size,char **str);
src/openvpn/basic.h +1 -1
@@ -26,7 +26,7 @@#define BOOL_CAST (x) ((x) ? (true) : (false))/* size of an array */ -#define SIZE (x) (sizeof(x)/sizeof(x[0])) +#define SIZE (x) (sizeof(x) / sizeof(x[0]))/* clear an object (may be optimized away, use secure_memzero() to erase secrets) */ #define CLEAR (x) memset(&(x), 0, sizeof(x))
src/openvpn/buffer.c +46 -56
271 lines not on this page · raw message
src/openvpn/buffer.h +101 -113
374 lines not on this page · raw message
src/openvpn/circ_list.h +26 -29
75 lines not on this page · raw message
src/openvpn/clinat.c +7 -16
@@ -32,8 +32,7 @@#include "memdbg.h" static bool -add_entry (struct client_nat_option_list *dest, -const struct client_nat_entry *e) +add_entry (struct client_nat_option_list *dest,const struct client_nat_entry *e) {if (dest->n >=MAX_CLIENT_NAT ) {
@@ -59,9 +58,7 @@for (i =0 ; i < list->n; ++i) {const struct client_nat_entry *e = &list->entries[i]; -msg (msglevel," CNAT[%d] t=%d %s/%s/%s" , - i, - e->type, +msg (msglevel," CNAT[%d] t=%d %s/%s/%s" , i, e->type,print_in_addr_t (e->network,IA_NET_ORDER , &gc),print_in_addr_t (e->netmask,IA_NET_ORDER , &gc),print_in_addr_t (e->foreign_network,IA_NET_ORDER , &gc));
@@ -102,11 +99,8 @@ }void -add_client_nat_to_option_list (struct client_nat_option_list *dest, -const char *type, -const char *network, -const char *netmask, -const char *foreign_network, +add_client_nat_to_option_list (struct client_nat_option_list *dest,const char *type, +const char *network,const char *netmask,const char *foreign_network,int msglevel) {struct client_nat_entry e;
@@ -179,9 +173,7 @@ dirstr ="IN" ; } -msg (msglevel,"** CNAT %s %s %s -> %s" , - dirstr, - prefix, +msg (msglevel,"** CNAT %s %s %s -> %s" , dirstr, prefix,print_in_addr_t (iph->saddr,IA_NET_ORDER , &gc),print_in_addr_t (iph->daddr,IA_NET_ORDER , &gc));
@@ -189,11 +181,10 @@ }void -client_nat_transform (const struct client_nat_option_list *list, -struct buffer *ipbuf, +client_nat_transform (const struct client_nat_option_list *list,struct buffer *ipbuf,const int direction) { -struct ip_tcp_udp_hdr *h = (struct ip_tcp_udp_hdr *)BPTR (ipbuf); +struct ip_tcp_udp_hdr *h = (struct ip_tcp_udp_hdr *)BPTR (ipbuf);int i;uint32_t addr, *addr_ptr;const uint32_t *from, *to;
src/openvpn/clinat.h +12 -12
@@ -30,7 +30,8 @@#define CN_OUTGOING 0#define CN_INCOMING 1 -struct client_nat_entry { +struct client_nat_entry +{#define CN_SNAT 0#define CN_DNAT 1int type;
@@ -39,28 +40,27 @@in_addr_t foreign_network; }; -struct client_nat_option_list { +struct client_nat_option_list +{int n;struct client_nat_entry entries[MAX_CLIENT_NAT ]; };struct client_nat_option_list *new_client_nat_list (struct gc_arena *gc); -struct client_nat_option_list *clone_client_nat_option_list (const struct client_nat_option_list *src,struct gc_arena *gc); +struct client_nat_option_list *clone_client_nat_option_list ( +const struct client_nat_option_list *src,struct gc_arena *gc); -void copy_client_nat_option_list (struct client_nat_option_list *dest,const struct client_nat_option_list *src); +void copy_client_nat_option_list (struct client_nat_option_list *dest, +const struct client_nat_option_list *src);void print_client_nat_list (const struct client_nat_option_list *list,int msglevel); -void add_client_nat_to_option_list (struct client_nat_option_list *dest, -const char *type, -const char *network, -const char *netmask, -const char *foreign_network, -int msglevel); +void add_client_nat_to_option_list (struct client_nat_option_list *dest,const char *type, +const char *network,const char *netmask, +const char *foreign_network,int msglevel); -void client_nat_transform (const struct client_nat_option_list *list, -struct buffer *ipbuf, +void client_nat_transform (const struct client_nat_option_list *list,struct buffer *ipbuf,const int direction);#endif /* if !defined(CLINAT_H) */
src/openvpn/common.h +7 -6
@@ -27,7 +27,7 @@* Statistics counters and associated printf format. */ typedef uint64_t counter_type ; -#define counter_format "%" PRIu64 +#define counter_format "%" PRIu64/* * Time intervals
@@ -37,17 +37,17 @@/* * Used as an upper bound for timeouts. */ -#define BIG_TIMEOUT (60*60*24*7)/* one week (in seconds) */ +#define BIG_TIMEOUT (60 * 60 * 24 * 7)/* one week (in seconds) */ /* * Printf formats for special types */ #ifdef _WIN64 -#define ptr_format "0x%016" PRIx64 +#define ptr_format "0x%016" PRIx64#else -#define ptr_format "0x%08lx" +#define ptr_format "0x%08lx"#endif -#define fragment_header_format "0x%08x" +#define fragment_header_format "0x%08x"/* these are used to cast the arguments * and MUST match the formats above */
@@ -94,6 +94,7 @@/* * Script security warning */ -#define SCRIPT_SECURITY_WARNING "WARNING: External program may not be called unless '--script-security 2' or higher is enabled. See --help text or man page for detailed info." +#define SCRIPT_SECURITY_WARNING \ + "WARNING: External program may not be called unless '--script-security 2' or higher is enabled. See --help text or man page for detailed info."#endif /* ifndef COMMON_H */
src/openvpn/comp-lz4.c +13 -28
86 lines not on this page · raw message
src/openvpn/comp.c +5 -5
@@ -171,10 +171,10 @@ {#ifdef USE_COMP msg (msglevel,"Compression or compression stub framing is not allowed " -"since data-channel offloading is enabled." ); +"since data-channel offloading is enabled." );#else msg (msglevel,"Compression or compression stub framing is not allowed " -"since OpenVPN was built without compression support." ); +"since OpenVPN was built without compression support." );#endif return false; }
@@ -182,14 +182,14 @@if ((info->flags &COMP_F_ALLOW_STUB_ONLY ) &&comp_non_stub_enabled (info)) {msg (msglevel,"Compression is not allowed since allow-compression is " -"set to 'stub-only'" ); +"set to 'stub-only'" );return false; }#ifndef ENABLE_LZ4 if (info->alg ==COMP_ALGV2_LZ4 || info->alg ==COMP_ALG_LZ4 ) {msg (msglevel,"OpenVPN is compiled without LZ4 support. Requested " -"compression cannot be enabled." ); +"compression cannot be enabled." );return false; }#endif
@@ -197,7 +197,7 @@if (info->alg ==COMP_ALG_LZO ) {msg (msglevel,"OpenVPN is compiled without LZO support. Requested " -"compression cannot be enabled." ); +"compression cannot be enabled." );return false; }#endif
src/openvpn/comp.h +21 -24
102 lines not on this page · raw message
src/openvpn/compstub.c +9 -23
@@ -45,8 +45,7 @@ }static void -stub_compress (struct buffer *buf,struct buffer work, -struct compress_context *compctx, +stub_compress (struct buffer *buf,struct buffer work,struct compress_context *compctx,const struct frame *frame) {if (buf->len <=0 )
@@ -56,7 +55,7 @@if (compctx->flags &COMP_F_SWAP ) {uint8_t *head =BPTR (buf); -uint8_t *tail =BEND (buf); +uint8_t *tail =BEND (buf);ASSERT (buf_safe (buf,1 )); ++buf->len;
@@ -72,8 +71,7 @@ }static void -stub_decompress (struct buffer *buf,struct buffer work, -struct compress_context *compctx, +stub_decompress (struct buffer *buf,struct buffer work,struct compress_context *compctx,const struct frame *frame) {uint8_t c;
@@ -107,8 +105,7 @@static void -stubv2_compress (struct buffer *buf,struct buffer work, -struct compress_context *compctx, +stubv2_compress (struct buffer *buf,struct buffer work,struct compress_context *compctx,const struct frame *frame) {if (buf->len <=0 )
@@ -120,8 +117,7 @@ }static void -stubv2_decompress (struct buffer *buf,struct buffer work, -struct compress_context *compctx, +stubv2_decompress (struct buffer *buf,struct buffer work,struct compress_context *compctx,const struct frame *frame) {if (buf->len <=0 )
@@ -157,19 +153,9 @@ } } -const struct compress_alg compv2_stub_alg = { -"stubv2" , - stub_compress_init, - stub_compress_uninit, - stubv2_compress, - stubv2_decompress -}; +const struct compress_alg compv2_stub_alg = {"stubv2" , stub_compress_init, stub_compress_uninit, + stubv2_compress, stubv2_decompress }; -const struct compress_alg comp_stub_alg = { -"stub" , - stub_compress_init, - stub_compress_uninit, - stub_compress, - stub_decompress -}; +const struct compress_alg comp_stub_alg = {"stub" , stub_compress_init, stub_compress_uninit, + stub_compress, stub_decompress };#endif /* USE_STUB */
src/openvpn/console.c +4 -6
@@ -37,7 +37,7 @@#endif -struct _query_user query_user[QUERY_USER_NUMSLOTS ];/* GLOBAL */ +struct _query_user query_user[QUERY_USER_NUMSLOTS ];/* GLOBAL */ void
@@ -53,16 +53,14 @@void -query_user_add (char *prompt,size_t prompt_len, -char *resp,size_t resp_len, -bool echo) +query_user_add (char *prompt,size_t prompt_len,char *resp,size_t resp_len,bool echo) {int i;/* Ensure input is sane. All these must be present otherwise it is * a programming error. */ -ASSERT ( prompt_len >0 && prompt !=NULL && resp_len >0 && resp !=NULL ); +ASSERT (prompt_len >0 && prompt !=NULL && resp_len >0 && resp !=NULL );/* Seek to the last unused slot */ for (i =0 ; i <QUERY_USER_NUMSLOTS ; i++)
@@ -72,7 +70,7 @@break ; } } -ASSERT ( i <QUERY_USER_NUMSLOTS );/* Unlikely, but we want to panic if it happens */ +ASSERT (i <QUERY_USER_NUMSLOTS );/* Unlikely, but we want to panic if it happens */ /* Save the information needed for the user interaction */ query_user[i].prompt = prompt;
src/openvpn/console.h +11 -14
@@ -30,16 +30,17 @@/** * Configuration setup for declaring what kind of information to ask a user for */ -struct _query_user { -char *prompt;/**< Prompt to present to the user */ -size_t prompt_len;/**< Length of the prompt string */ -char *response;/**< The user's response */ -size_t response_len;/**< Length the of the user response */ -bool echo;/**< True: The user should see what is being typed, otherwise mask it */ +struct _query_user +{ +char *prompt;/**< Prompt to present to the user */ +size_t prompt_len;/**< Length of the prompt string */ +char *response;/**< The user's response */ +size_t response_len;/**< Length the of the user response */ +bool echo;/**< True: The user should see what is being typed, otherwise mask it */ };#define QUERY_USER_NUMSLOTS 10 -extern struct _query_user query_user[];/**< Global variable, declared in console.c */ +extern struct _query_user query_user[];/**< Global variable, declared in console.c */ /** * Wipes all data put into all of the query_user structs
@@ -58,9 +59,7 @@* @param echo Should the user input be echoed to the user? If False, input will be masked * */ -void query_user_add (char *prompt,size_t prompt_len, -char *resp,size_t resp_len, -bool echo); +void query_user_add (char *prompt,size_t prompt_len,char *resp,size_t resp_len,bool echo);/**
@@ -107,7 +106,7 @@ {return query_user_exec_builtin (); } -#endif /* defined(ENABLE_SYSTEMD) */ +#endif /* defined(ENABLE_SYSTEMD) */ /**
@@ -118,9 +117,7 @@* */ static inline bool -query_user_SINGLE (char *prompt,size_t prompt_len, -char *resp,size_t resp_len, -bool echo) +query_user_SINGLE (char *prompt,size_t prompt_len,char *resp,size_t resp_len,bool echo) {query_user_clear ();query_user_add (prompt, prompt_len, resp, resp_len, echo);
src/openvpn/console_builtin.c +12 -11
@@ -67,11 +67,10 @@HANDLE in =GetStdHandle (STD_INPUT_HANDLE );int orig_stderr =get_orig_stderr ();/* guaranteed to be always valid */ -if ((in ==INVALID_HANDLE_VALUE ) - ||win32_service_interrupt (&win32_signal) +if ((in ==INVALID_HANDLE_VALUE ) ||win32_service_interrupt (&win32_signal) || (_write (orig_stderr, prompt,strlen (prompt)) ==-1 )) { -msg (M_WARN |M_ERRNO ,"get_console_input_win32(): unexpected error" ); +msg (M_WARN |M_ERRNO ,"get_console_input_win32(): unexpected error" );return false; }
@@ -135,7 +134,7 @@ return false; } -#endif /* _WIN32 */ +#endif /* _WIN32 */ #ifdef HAVE_TERMIOS_H
@@ -177,7 +176,7 @@ } } -#endif /* HAVE_TERMIOS_H */ +#endif /* HAVE_TERMIOS_H */ /**
@@ -209,15 +208,17 @@* (in which case neither stdin or stderr are connected to a tty and * /dev/tty can not be open()ed anymore) */ -if (!isatty (0 ) && !isatty (2 ) ) +if (!isatty (0 ) && !isatty (2 )) { -int fd =open ("/dev/tty" ,O_RDWR ); +int fd =open ("/dev/tty" ,O_RDWR );if (fd <0 ) { -msg (M_FATAL ,"neither stdin nor stderr are a tty device and you have neither a " +msg (M_FATAL , +"neither stdin nor stderr are a tty device and you have neither a " "controlling tty nor systemd - can't ask for '%s'. If you used --daemon, " "you need to use --askpass to make passphrase-protected keys work, and you " -"can not use --auth-nocache." , prompt ); +"can not use --auth-nocache." , + prompt); }close (fd); }
@@ -285,8 +286,8 @@/* Loop through configured query_user slots */ for (i =0 ; i <QUERY_USER_NUMSLOTS && query_user[i].response !=NULL ; i++) { -if (!get_console_input (query_user[i].prompt, query_user[i].echo, - query_user[i].response, query_user[i].response_len) ) +if (!get_console_input (query_user[i].prompt, query_user[i].echo, query_user[i].response, + query_user[i].response_len)) {/* Force the final result state to failed on failure */ ret = false;
src/openvpn/console_systemd.c +4 -6
@@ -50,9 +50,7 @@* mounted, as well as the systemd-ask-password executable * being available */ -return (sd_booted () >0 ) - && (stat (SYSTEMD_ASK_PASSWORD_PATH , &c) ==0 ); - +return (sd_booted () >0 ) && (stat (SYSTEMD_ASK_PASSWORD_PATH , &c) ==0 ); } static bool
@@ -79,7 +77,7 @@return false; }memset (input,0 , capacity); -if (read (std_out, input, capacity-1 ) !=0 ) +if (read (std_out, input, capacity -1 ) !=0 ) {chomp (input); ret = true;
@@ -99,7 +97,7 @@bool query_user_exec_systemd (void ) { -bool ret = true;/* Presume everything goes okay */ +bool ret = true;/* Presume everything goes okay */ int i;/* If systemd is not available, use the default built-in mechanism */
@@ -112,7 +110,7 @@for (i =0 ; i <QUERY_USER_NUMSLOTS && query_user[i].response !=NULL ; i++) {if (!get_console_input_systemd (query_user[i].prompt, query_user[i].echo, - query_user[i].response, query_user[i].response_len) ) + query_user[i].response, query_user[i].response_len)) {/* Force the final result state to failed on failure */ ret = false;
src/openvpn/crypto.c +122 -168
99 lines not on this page · raw message
src/openvpn/crypto.h +88 -102
190 lines not on this page · raw message
src/openvpn/crypto_epoch.c +27 -43
70 lines not on this page · raw message
src/openvpn/crypto_epoch.h +16 -30
46 lines not on this page · raw message
src/openvpn/crypto_mbedtls.c +74 -74
148 lines not on this page · raw message
src/openvpn/crypto_openssl.c +85 -97
182 lines not on this page · raw message
src/openvpn/cryptoapi.c +57 -52
109 lines not on this page · raw message
src/openvpn/dco.c +57 -59
116 lines not on this page · raw message
src/openvpn/dco_linux.c +67 -102
169 lines not on this page · raw message
src/openvpn/dco_win.c +63 -56
119 lines not on this page · raw message
src/openvpn/dco_win.h +20 -23
43 lines not on this page · raw message
src/openvpn/dhcp.c +28 -28
56 lines not on this page · raw message
src/openvpn/dns.c +36 -38
74 lines not on this page · raw message
src/openvpn/errlevel.h +115 -115
230 lines not on this page · raw message
src/openvpn/error.c +51 -86
137 lines not on this page · raw message
src/openvpn/error.h +77 -41
118 lines not on this page · raw message
src/openvpn/event.c +80 -98
178 lines not on this page · raw message
src/openvpn/event.h +34 -31
65 lines not on this page · raw message
src/openvpn/forward.c +116 -156
272 lines not on this page · raw message
src/openvpn/forward.h +34 -37
71 lines not on this page · raw message
src/openvpn/fragment.c +40 -54
94 lines not on this page · raw message
src/openvpn/fragment.h +39 -39
78 lines not on this page · raw message
src/openvpn/helper.c +48 -40
88 lines not on this page · raw message
src/openvpn/httpdigest.c +39 -50
89 lines not on this page · raw message
src/openvpn/init.c +308 -477
785 lines not on this page · raw message
src/openvpn/list.c +59 -57
116 lines not on this page · raw message
src/openvpn/manage.c +278 -355
633 lines not on this page · raw message
src/openvpn/manage.h +114 -143
257 lines not on this page · raw message
src/openvpn/misc.c +139 -138
277 lines not on this page · raw message
src/openvpn/misc.h +36 -41
77 lines not on this page · raw message
src/openvpn/mroute.c +32 -45
77 lines not on this page · raw message
src/openvpn/mroute.h +63 -68
131 lines not on this page · raw message
src/openvpn/mss.c +33 -47
80 lines not on this page · raw message
src/openvpn/mtu.c +20 -29
49 lines not on this page · raw message
src/openvpn/mtu.h +65 -76
141 lines not on this page · raw message
src/openvpn/mudp.c +34 -35
69 lines not on this page · raw message
src/openvpn/multi.c +360 -481
841 lines not on this page · raw message
src/openvpn/multi.h +65 -67
132 lines not on this page · raw message
src/openvpn/multi_io.c +65 -73
138 lines not on this page · raw message
src/openvpn/networking.h +25 -36
61 lines not on this page · raw message
src/openvpn/networking_freebsd.c +20 -34
54 lines not on this page · raw message
src/openvpn/networking_iproute2.c +37 -57
94 lines not on this page · raw message
src/openvpn/networking_sitnl.c +165 -209
374 lines not on this page · raw message
src/openvpn/ntlm.c +50 -55
105 lines not on this page · raw message
src/openvpn/occ.c +96 -111
207 lines not on this page · raw message
src/openvpn/openvpn.h +68 -64
132 lines not on this page · raw message
src/openvpn/options.c +752 -904
1,656 lines not on this page · raw message
src/openvpn/options.h +105 -126
231 lines not on this page · raw message
src/openvpn/ovpn_dco_freebsd.h +28 -24
52 lines not on this page · raw message
src/openvpn/packet_id.c +41 -72
113 lines not on this page · raw message
src/openvpn/packet_id.h +29 -33
62 lines not on this page · raw message
src/openvpn/perf.c +31 -43
74 lines not on this page · raw message
src/openvpn/perf.h +22 -22
44 lines not on this page · raw message
src/openvpn/pkcs11.c +165 -383
548 lines not on this page · raw message
src/openvpn/pkcs11.h +12 -37
49 lines not on this page · raw message
src/openvpn/pkcs11_openssl.c +40 -41
81 lines not on this page · raw message
src/openvpn/platform.c +36 -38
74 lines not on this page · raw message
src/openvpn/plugin.c +85 -116
201 lines not on this page · raw message
src/openvpn/plugin.h +26 -35
61 lines not on this page · raw message
src/openvpn/pool.c +49 -75
124 lines not on this page · raw message
src/openvpn/proto.h +90 -84
174 lines not on this page · raw message
src/openvpn/proxy.c +80 -120
200 lines not on this page · raw message
src/openvpn/ps.c +53 -69
122 lines not on this page · raw message
src/openvpn/push.c +88 -114
202 lines not on this page · raw message
src/openvpn/reliable.c +28 -35
63 lines not on this page · raw message
src/openvpn/reliable.h +25 -29
54 lines not on this page · raw message
src/openvpn/ring_buffer.h new file +124 -0
124 lines not on this page · raw message
src/openvpn/route.c +423 -692
1,115 lines not on this page · raw message
src/openvpn/route.h +112 -123
235 lines not on this page · raw message
src/openvpn/run_command.h +20 -21
41 lines not on this page · raw message
src/openvpn/schedule.c +16 -35
51 lines not on this page · raw message
src/openvpn/sig.c +28 -31
59 lines not on this page · raw message
src/openvpn/socket.c +339 -560
899 lines not on this page · raw message
src/openvpn/socket.h +162 -227
389 lines not on this page · raw message
src/openvpn/socks.c +55 -61
116 lines not on this page · raw message
src/openvpn/ssl.c +265 -427
692 lines not on this page · raw message
src/openvpn/ssl.h +46 -72
118 lines not on this page · raw message
src/openvpn/ssl_backend.h +27 -38
65 lines not on this page · raw message
src/openvpn/ssl_common.h +94 -85
179 lines not on this page · raw message
src/openvpn/ssl_mbedtls.c +122 -181
303 lines not on this page · raw message
src/openvpn/ssl_mbedtls.h +36 -29
65 lines not on this page · raw message
src/openvpn/ssl_ncp.c +44 -57
101 lines not on this page · raw message
src/openvpn/ssl_openssl.c +144 -178
322 lines not on this page · raw message
src/openvpn/ssl_pkt.c +38 -70
108 lines not on this page · raw message
src/openvpn/ssl_pkt.h +44 -62
106 lines not on this page · raw message
src/openvpn/ssl_util.c +152 -141
293 lines not on this page · raw message
src/openvpn/ssl_verify.c +165 -166
331 lines not on this page · raw message
src/openvpn/ssl_verify.h +24 -27
51 lines not on this page · raw message
src/openvpn/ssl_verify_mbedtls.c +55 -67
122 lines not on this page · raw message
src/openvpn/ssl_verify_openssl.c +44 -54
98 lines not on this page · raw message
src/openvpn/syshead.h +25 -23
48 lines not on this page · raw message
src/openvpn/tls_crypt.c +87 -140
227 lines not on this page · raw message
src/openvpn/tls_crypt.h +22 -29
51 lines not on this page · raw message
src/openvpn/tun.c +616 -944
1,560 lines not on this page · raw message
src/openvpn/tun.h +58 -65
123 lines not on this page · raw message
src/openvpn/wfp_block.c +31 -66
97 lines not on this page · raw message
src/openvpn/win32.c +87 -100
187 lines not on this page · raw message
src/openvpn/win32.h +30 -33
63 lines not on this page · raw message
src/openvpn/xkey_helper.c +47 -50
97 lines not on this page · raw message
src/openvpn/xkey_provider.c +154 -146
300 lines not on this page · raw message
src/openvpnmsica/openvpnmsica.c +179 -170
349 lines not on this page · raw message
src/openvpnmsica/openvpnmsica.h +75 -79
154 lines not on this page · raw message
src/openvpnserv/common.c +24 -25
49 lines not on this page · raw message
src/openvpnserv/interactive.c +196 -211
407 lines not on this page · raw message
src/openvpnserv/service.c +21 -25
46 lines not on this page · raw message
src/plugins/auth-pam/auth-pam.c +75 -67
142 lines not on this page · raw message
src/plugins/auth-pam/pamdl.c +29 -37
66 lines not on this page · raw message
src/tapctl/error.h +45 -21
66 lines not on this page · raw message
src/tapctl/main.c +72 -60
132 lines not on this page · raw message
src/tapctl/tap.c +148 -271
419 lines not on this page · raw message
src/tapctl/tap.h +13 -29
42 lines not on this page · raw message
tests/unit_tests/openvpn/cert_data.h +34 -36
70 lines not on this page · raw message
tests/unit_tests/openvpn/mock_management.c +1 -2
Lines of this file are not shown. View the raw message.
tests/unit_tests/openvpn/mock_ssl_dependencies.c +2 -2
Lines of this file are not shown. View the raw message.
tests/unit_tests/openvpn/pkey_test_utils.c +5 -6
Lines of this file are not shown. View the raw message.
tests/unit_tests/openvpn/test_auth_token.c +59 -66
125 lines not on this page · raw message
tests/unit_tests/openvpn/test_buffer.c +28 -37
65 lines not on this page · raw message
tests/unit_tests/openvpn/test_crypto.c +85 -131
216 lines not on this page · raw message
tests/unit_tests/openvpn/test_cryptoapi.c +41 -42
83 lines not on this page · raw message
tests/unit_tests/openvpn/test_misc.c +38 -35
73 lines not on this page · raw message
tests/unit_tests/openvpn/test_ncp.c +34 -46
80 lines not on this page · raw message
tests/unit_tests/openvpn/test_networking.c +4 -10
Lines of this file are not shown. View the raw message.
tests/unit_tests/openvpn/test_packet_id.c +25 -32
57 lines not on this page · raw message
tests/unit_tests/openvpn/test_pkcs11.c +46 -47
93 lines not on this page · raw message
tests/unit_tests/openvpn/test_pkt.c +94 -120
214 lines not on this page · raw message
tests/unit_tests/openvpn/test_provider.c +27 -26
53 lines not on this page · raw message
tests/unit_tests/openvpn/test_push_update_msg.c +44 -48
92 lines not on this page · raw message
tests/unit_tests/openvpn/test_ssl.c +24 -31
55 lines not on this page · raw message
tests/unit_tests/openvpn/test_tls_crypt.c +105 -150
255 lines not on this page · raw message
tests/unit_tests/openvpn/test_user_pass.c +17 -14
Lines of this file are not shown. View the raw message.
tests/unit_tests/plugins/auth-pam/test_search_and_replace.c +0 -2
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/791?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I2566ad493629e1f5fdfa6f6483b8973463404e3e
Gerrit-Change-Number: 791
Gerrit-PatchSet: 23
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-MessageType: newpatchset
Part of the diff is not shown here. View the raw message.
Attention is currently required from: flichtenheld, ordex, plaisthos.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/791?usp=email )
Change subject: Reformat the whole project with clang-format
......................................................................
Patch Set 23: Code-Review+2
(3 comments)
Patchset:
PS23:
So, reviewed most of this, and especially tested this on all the testbeds (nothing fails). As agreed, move to "ColumnLimit: 0" afterwards with a cleanup patch, as the force-unwrapping by "100" creates ugliness and also "surprising submit fails" - we use common sense ;-)
File src/openvpn/crypto.c:
http://gerrit.openvpn.net/c/openvpn/+/791/comment/9105cd07_6cc952af :
PS18, Line 391: epoch);
not sure what happened here...
http://gerrit.openvpn.net/c/openvpn/+/791/comment/ce26f764_3092ba12 :
PS18, Line 1604: msg(M_FATAL,
this is another one where the result is uglier than the start... maybe it needs manual breaking of the string so it can fit "properly" in 2 lines
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/791?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I2566ad493629e1f5fdfa6f6483b8973463404e3e
Gerrit-Change-Number: 791
Gerrit-PatchSet: 23
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Mon, 04 Aug 2025 15:18:30 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
PATCH v23 1/1 Reformat the whole project with clang-format
In reply to a message not in the archiveFrom: Frank Lichtenheld <[email protected]...>
Done with pre-commit run -a, so the version
defined in pre-commit config is used.
This also changes the Github workflow so that
there is no commit that fails GHA.
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/791
This mail reflects revision 23 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
.github/workflows/build.yaml +12 -21
@@ -5,35 +5,26 @@ pull_request: jobs: - checkuncrustify: - name: "Check code style with Uncrustify" - # Ubuntu 22.04 has uncrustify 0.72_f - runs-on: ubuntu-22.04 + clang-format: + name: Check code style with clang-format + runs-on: ubuntu-24.04 steps: - name: Install dependencies - run: sudo apt update && sudo apt install -y uncrustify + run: | + sudo apt update && sudo apt install -y python3-pip + pip3 install pre-commit - name: Checkout OpenVPN uses: actions/[email protected]... # v4.2.2 - with: - path: openvpn - - name: Show uncrustify version - run: uncrustify --version - - name: Run uncrustify - run: ./dev-tools/reformat-all.sh - working-directory: openvpn + - name: Run clang-format + run: pre-commit run -a --show-diff-on-failure || true - name: Check for changes - run: git diff --output=uncrustify-changes.patch - working-directory: openvpn - - name: Show changes on standard output - run: git diff - working-directory: openvpn + run: git diff --output=format-changes.patch - uses: actions/[email protected]... # v4.6.2 with: - name: uncrustify-changes.patch - path: 'openvpn/uncrustify-changes.patch' + name: format-changes.patch + path: format-changes.patch - name: Set job status - run: test ! -s uncrustify-changes.patch - working-directory: openvpn + run: test ! -s format-changes.patch android: strategy:
include/openvpn-msg.h +41 -22
159 lines not on this page · raw message
sample/sample-plugins/client-connect/sample-client-connect.c +52 -59
265 lines not on this page · raw message
sample/sample-plugins/defer/multi-auth.c +34 -40
208 lines not on this page · raw message
sample/sample-plugins/keying-material-exporter-demo/keyingmaterialexporter.c +26 -25
119 lines not on this page · raw message
sample/sample-plugins/log/log.c +19 -19
@@ -36,7 +36,8 @@/* * Our context, where we keep our state. */ -struct plugin_context { +struct plugin_context +{const char *username;const char *password; };
@@ -75,7 +76,7 @@/* * Allocate our context */ - context = (struct plugin_context *)calloc (1 ,sizeof (struct plugin_context )); + context = (struct plugin_context *)calloc (1 ,sizeof (struct plugin_context ));if (context ==NULL ) {printf ("PLUGIN: allocating memory for context failed\n" );
@@ -91,19 +92,17 @@/* * Which callbacks to intercept. */ - *type_mask = -OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_UP ) - |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_DOWN ) - |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_ROUTE_UP ) - |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_IPCHANGE ) - |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_TLS_VERIFY ) - |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY ) - |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_CLIENT_CONNECT_V2 ) - |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_CLIENT_DISCONNECT ) - |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_LEARN_ADDRESS ) - |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_TLS_FINAL ); + *type_mask =OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_UP ) |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_DOWN ) + |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_ROUTE_UP ) + |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_IPCHANGE ) + |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_TLS_VERIFY ) + |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY ) + |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_CLIENT_CONNECT_V2 ) + |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_CLIENT_DISCONNECT ) + |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_LEARN_ADDRESS ) + |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_TLS_FINAL ); -return (openvpn_plugin_handle_t ) context; +return (openvpn_plugin_handle_t )context; }void
@@ -171,9 +170,10 @@ } OPENVPN_EXPORT int -openvpn_plugin_func_v1 (openvpn_plugin_handle_t handle,const int type,const char *argv[],const char *envp[]) +openvpn_plugin_func_v1 (openvpn_plugin_handle_t handle,const int type,const char *argv[], +const char *envp[]) { -struct plugin_context *context = (struct plugin_context *) handle; +struct plugin_context *context = (struct plugin_context *)handle;show (type, argv, envp);
@@ -184,8 +184,8 @@const char *username =get_env ("username" , envp);const char *password =get_env ("password" , envp); -if (username && !strcmp (username, context->username) - && password && !strcmp (password, context->password)) +if (username && !strcmp (username, context->username) && password + && !strcmp (password, context->password)) {return OPENVPN_PLUGIN_FUNC_SUCCESS ; }
@@ -203,6 +203,6 @@ OPENVPN_EXPORT voidopenvpn_plugin_close_v1 (openvpn_plugin_handle_t handle) { -struct plugin_context *context = (struct plugin_context *) handle; +struct plugin_context *context = (struct plugin_context *)handle;free (context); }
sample/sample-plugins/log/log_v3.c +24 -27
106 lines not on this page · raw message
sample/sample-plugins/simple/base64.c +15 -17
@@ -98,21 +98,20 @@* */ OPENVPN_EXPORT int -openvpn_plugin_open_v3 (const int v3structver, -struct openvpn_plugin_args_open_in const *args, +openvpn_plugin_open_v3 (const int v3structver,struct openvpn_plugin_args_open_in const *args,struct openvpn_plugin_args_open_return *ret) {/* Check that we are API compatible */ if (v3structver != OPENVPN_PLUGINv3_STRUCTVER) { -printf ("base64.c: ** ERROR ** Incompatible plug-in interface between this plug-in and OpenVPN\n" ); +printf ( +"base64.c: ** ERROR ** Incompatible plug-in interface between this plug-in and OpenVPN\n" );return OPENVPN_PLUGIN_FUNC_ERROR ; }/* Which callbacks to intercept. */ - ret->type_mask = -OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_TLS_VERIFY ) - |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_CLIENT_CONNECT_V2 ); + ret->type_mask =OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_TLS_VERIFY ) + |OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_CLIENT_CONNECT_V2 );/* we don't need a plug-in context in this example, but OpenVPN expects "something" */ ret->handle =calloc (1 ,1 );
@@ -125,8 +124,8 @@/* Print some version information about the OpenVPN process using this plug-in */ ovpn_log (PLOG_NOTE ,PLUGIN_NAME ,"OpenVPN %s (Major: %i, Minor: %i, Patch: %s)\n" , - args->ovpn_version, args->ovpn_version_major, - args->ovpn_version_minor, args->ovpn_version_patch); + args->ovpn_version, args->ovpn_version_major, args->ovpn_version_minor, + args->ovpn_version_patch);return OPENVPN_PLUGIN_FUNC_SUCCESS ; }
@@ -154,10 +153,10 @@*/ OPENVPN_EXPORT int -openvpn_plugin_func_v1 (openvpn_plugin_handle_t handle,const int type,const char *argv[],const char *envp[]) +openvpn_plugin_func_v1 (openvpn_plugin_handle_t handle,const int type,const char *argv[], +const char *envp[]) { -if (type !=OPENVPN_PLUGIN_TLS_VERIFY - && type !=OPENVPN_PLUGIN_CLIENT_CONNECT_V2 ) +if (type !=OPENVPN_PLUGIN_TLS_VERIFY && type !=OPENVPN_PLUGIN_CLIENT_CONNECT_V2 ) {ovpn_log (PLOG_ERR ,PLUGIN_NAME ,"Unsupported plug-in hook call attempted" );return OPENVPN_PLUGIN_FUNC_ERROR ;
@@ -174,14 +173,13 @@/* test the BASE64 encode function */ char *buf =NULL ;int r =ovpn_base64_encode (clcert_cn, (int )strlen (clcert_cn), &buf); -ovpn_log (PLOG_NOTE ,PLUGIN_NAME ,"BASE64 encoded '%s' (return value %i): '%s'" , - clcert_cn, r, buf); +ovpn_log (PLOG_NOTE ,PLUGIN_NAME ,"BASE64 encoded '%s' (return value %i): '%s'" , clcert_cn, r, + buf);/* test the BASE64 decode function */ -char buf2[256 ] = {0 }; +char buf2[256 ] = {0 }; r =ovpn_base64_decode (buf, &buf2,255 ); -ovpn_log (PLOG_NOTE ,PLUGIN_NAME ,"BASE64 decoded '%s' (return value %i): '%s'" , - buf, r, buf2); +ovpn_log (PLOG_NOTE ,PLUGIN_NAME ,"BASE64 decoded '%s' (return value %i): '%s'" , buf, r, buf2);/* Verify the result, and free the buffer allocated by ovpn_base64_encode() */ r =strcmp (clcert_cn, buf2);
@@ -201,6 +199,6 @@ OPENVPN_EXPORT voidopenvpn_plugin_close_v1 (openvpn_plugin_handle_t handle) { -struct plugin_context *context = (struct plugin_context *) handle; +struct plugin_context *context = (struct plugin_context *)handle;free (context); }
sample/sample-plugins/simple/simple.c +10 -8
@@ -38,7 +38,8 @@/* * Our context, where we keep our state. */ -struct plugin_context { +struct plugin_context +{const char *username;const char *password; };
@@ -77,7 +78,7 @@/* * Allocate our context */ - context = (struct plugin_context *)calloc (1 ,sizeof (struct plugin_context )); + context = (struct plugin_context *)calloc (1 ,sizeof (struct plugin_context ));if (context ==NULL ) {printf ("PLUGIN: allocating memory for context failed\n" );
@@ -96,21 +97,22 @@*/ *type_mask =OPENVPN_PLUGIN_MASK (OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY ); -return (openvpn_plugin_handle_t ) context; +return (openvpn_plugin_handle_t )context; } OPENVPN_EXPORT int -openvpn_plugin_func_v1 (openvpn_plugin_handle_t handle,const int type,const char *argv[],const char *envp[]) +openvpn_plugin_func_v1 (openvpn_plugin_handle_t handle,const int type,const char *argv[], +const char *envp[]) { -struct plugin_context *context = (struct plugin_context *) handle; +struct plugin_context *context = (struct plugin_context *)handle;/* get username/password from envp string array */ const char *username =get_env ("username" , envp);const char *password =get_env ("password" , envp);/* check entered username/password against what we require */ -if (username && !strcmp (username, context->username) - && password && !strcmp (password, context->password)) +if (username && !strcmp (username, context->username) && password + && !strcmp (password, context->password)) {return OPENVPN_PLUGIN_FUNC_SUCCESS ; }
@@ -123,6 +125,6 @@ OPENVPN_EXPORT voidopenvpn_plugin_close_v1 (openvpn_plugin_handle_t handle) { -struct plugin_context *context = (struct plugin_context *) handle; +struct plugin_context *context = (struct plugin_context *)handle;free (context); }
src/compat/compat-basename.c +1 -1
@@ -41,7 +41,7 @@/* If NULL, check for \ instead ... might be Windows a path */ p = strrchr(filename, '\\'); } -return p ? p +1 : (char *) filename; +return p ? p +1 : (char *)filename; }#endif /* HAVE_BASENAME */
src/compat/compat-dirname.c +2 -2
@@ -89,7 +89,7 @@/* The '/' is the last character, we have to look further. */ if (runp != path) { - last_slash = (char *)__memrchr (path, separator, runp - path); + last_slash = (char *)__memrchr (path, separator, runp - path); } }
@@ -134,7 +134,7 @@/* This assignment is ill-designed but the XPG specs require to * return a string containing "." in any case no directory part is * found and so a static and constant string is required. */ - path = (char *) dot; + path = (char *)dot; }return path;
src/compat/compat-gettimeofday.c +2 -2
@@ -48,7 +48,7 @@ {const time_t t =time (NULL );const DWORD gtc =GetTickCount (); - gtc_base = t - gtc/1000 ; + gtc_base = t - gtc /1000 ; gtc_last = gtc; }
@@ -112,7 +112,7 @@ return 0; } -#else /* ifdef _WIN32 */ +#else /* ifdef _WIN32 */ #include <time.h>
src/openvpn/argv.c +5 -6
@@ -284,8 +284,7 @@* free()d to avoid memory leaks. */ static char * -argv_prep_format (const char *format,const char delim,size_t *count, -struct gc_arena *gc) +argv_prep_format (const char *format,const char delim,size_t *count,struct gc_arena *gc) {if (format ==NULL ) {
@@ -311,7 +310,7 @@* the string is empty; the resulting format string * will never start with a delimiter. */ -if (j >0 )/* Has anything been written to the output string? */ +if (j >0 )/* Has anything been written to the output string? */ { f[j++] = delim; }
@@ -347,7 +346,7 @@static bool argv_printf_arglist (struct argv *argres,const char *format,va_list arglist) { -const char delim =0x1D ;/* ASCII Group Separator (GS) */ +const char delim =0x1D ;/* ASCII Group Separator (GS) */ bool res = false;/*
@@ -484,8 +483,8 @@argv_reset (argres);char *parms[MAX_PARMS +1 ] = {0 }; -int nparms =parse_line (cmdstr, parms,MAX_PARMS ,"SCRIPT-ARGV" ,0 , -D_ARGV_PARSE_CMD , &argres->gc); +int nparms = +parse_line (cmdstr, parms,MAX_PARMS ,"SCRIPT-ARGV" ,0 ,D_ARGV_PARSE_CMD , &argres->gc);if (nparms) {int i;
src/openvpn/argv.h +8 -7
@@ -31,7 +31,8 @@#include "buffer.h" -struct argv { +struct argv +{struct gc_arena gc;size_t capacity;size_t argc;
@@ -55,21 +56,21 @@ bool argv_printf(struct argv *a, const char *format, ...) #ifdef __GNUC__ #if __USE_MINGW_ANSI_STDIO -__attribute__ ((format(gnu_printf, 2, 3))) + __attribute__((format(gnu_printf, 2, 3))) #else -__attribute__ ((format(__printf__, 2, 3))) + __attribute__((format(__printf__, 2, 3))) #endif #endif -; + ; bool argv_printf_cat(struct argv *a, const char *format, ...) #ifdef __GNUC__ #if __USE_MINGW_ANSI_STDIO -__attribute__ ((format(gnu_printf, 2, 3))) + __attribute__((format(gnu_printf, 2, 3))) #else -__attribute__ ((format(__printf__, 2, 3))) + __attribute__((format(__printf__, 2, 3))) #endif #endif -; + ; #endif /* ifndef ARGV_H */
src/openvpn/auth_token.c +42 -49
245 lines not on this page · raw message
src/openvpn/auth_token.h +7 -15
@@ -58,27 +58,22 @@* This function will free() an existing multi->auth_token and keep the * existing initial timestamp and session id contained in that token. */ -void -generate_auth_token (const struct user_pass *up,struct tls_multi *multi); +void generate_auth_token (const struct user_pass *up,struct tls_multi *multi);/** * Verifies the auth token to be in the format that generate_auth_token * create and checks if the token is valid. * */ -unsigned -verify_auth_token (struct user_pass *up,struct tls_multi *multi, -struct tls_session *session); - +unsigned verify_auth_token (struct user_pass *up,struct tls_multi *multi, +struct tls_session *session);/** * Loads an HMAC secret from a file or if no file is present generates a * epheremal secret for the run time of the server and stores it into ctx */ -void -auth_token_init_secret (struct key_ctx *key_ctx,const char *key_file, -bool key_inline); +void auth_token_init_secret (struct key_ctx *key_ctx,const char *key_file,bool key_inline);/**
@@ -125,8 +120,7 @@static inline bool is_auth_token (const char *password) { -return (memcmp_constant_time (SESSION_ID_PREFIX , password, -strlen (SESSION_ID_PREFIX )) ==0 ); +return (memcmp_constant_time (SESSION_ID_PREFIX , password,strlen (SESSION_ID_PREFIX )) ==0 ); }/** * Checks if a client should be sent a new auth token to update its
@@ -134,15 +128,13 @@* @param multi Pointer the multi object of the TLS session * @param session Pointer to the TLS session itself */ -void -resend_auth_token_renegotiation (struct tls_multi *multi,struct tls_session *session); +void resend_auth_token_renegotiation (struct tls_multi *multi,struct tls_session *session);/** * Checks if the timer to resend the auth-token has expired and if a new * auth-token should be send to the client and triggers the resending */ -void -check_send_auth_token (struct context *c); +void check_send_auth_token (struct context *c);#endif /* AUTH_TOKEN_H */
src/openvpn/base64.c +5 -6
@@ -41,8 +41,7 @@#include "memdbg.h" -static char base64_chars[] = -"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ; +static char base64_chars[] ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ;/* * base64 encode input data of length size to malloced * buffer which is returned as *str. Returns string
@@ -60,14 +59,14 @@ {return -1 ; } - p = s = (char *)malloc (size *4 /3 +4 ); + p = s = (char *)malloc (size *4 /3 +4 );if (p ==NULL ) {return -1 ; } - q = (const unsigned char *) data; + q = (const unsigned char *)data; i =0 ; -for (i =0 ; i < size; ) +for (i =0 ; i < size;) { c = q[i++]; c *=256 ;
@@ -196,5 +195,5 @@ *q++ = val &0xff ; } } -return q - (unsigned char *) data; +return q - (unsigned char *)data; }
src/openvpn/base64.h +2 -4
@@ -35,12 +35,10 @@#define _BASE64_H_/** Compute resulting base64 length. 6 bits per byte, padded to 4 bytes. */ -#define OPENVPN_BASE64_LENGTH (binary_length) \ - ((((8 * binary_length) / 6) + 3) & ~3) +#define OPENVPN_BASE64_LENGTH (binary_length) ((((8 * binary_length) / 6) + 3) & ~3)/** Compute the maximal number of bytes encoded in a base64 string. */ -#define OPENVPN_BASE64_DECODED_LENGTH (base64_length) \ - ((base64_length / 4) * 3) +#define OPENVPN_BASE64_DECODED_LENGTH (base64_length) ((base64_length / 4) * 3)int openvpn_base64_encode (const void *data,int size,char **str);
src/openvpn/basic.h +1 -1
@@ -26,7 +26,7 @@#define BOOL_CAST (x) ((x) ? (true) : (false))/* size of an array */ -#define SIZE (x) (sizeof(x)/sizeof(x[0])) +#define SIZE (x) (sizeof(x) / sizeof(x[0]))/* clear an object (may be optimized away, use secure_memzero() to erase secrets) */ #define CLEAR (x) memset(&(x), 0, sizeof(x))
src/openvpn/buffer.c +46 -56
271 lines not on this page · raw message
src/openvpn/buffer.h +101 -113
374 lines not on this page · raw message
src/openvpn/circ_list.h +26 -29
75 lines not on this page · raw message
src/openvpn/clinat.c +7 -16
@@ -32,8 +32,7 @@#include "memdbg.h" static bool -add_entry (struct client_nat_option_list *dest, -const struct client_nat_entry *e) +add_entry (struct client_nat_option_list *dest,const struct client_nat_entry *e) {if (dest->n >=MAX_CLIENT_NAT ) {
@@ -59,9 +58,7 @@for (i =0 ; i < list->n; ++i) {const struct client_nat_entry *e = &list->entries[i]; -msg (msglevel," CNAT[%d] t=%d %s/%s/%s" , - i, - e->type, +msg (msglevel," CNAT[%d] t=%d %s/%s/%s" , i, e->type,print_in_addr_t (e->network,IA_NET_ORDER , &gc),print_in_addr_t (e->netmask,IA_NET_ORDER , &gc),print_in_addr_t (e->foreign_network,IA_NET_ORDER , &gc));
@@ -102,11 +99,8 @@ }void -add_client_nat_to_option_list (struct client_nat_option_list *dest, -const char *type, -const char *network, -const char *netmask, -const char *foreign_network, +add_client_nat_to_option_list (struct client_nat_option_list *dest,const char *type, +const char *network,const char *netmask,const char *foreign_network,int msglevel) {struct client_nat_entry e;
@@ -179,9 +173,7 @@ dirstr ="IN" ; } -msg (msglevel,"** CNAT %s %s %s -> %s" , - dirstr, - prefix, +msg (msglevel,"** CNAT %s %s %s -> %s" , dirstr, prefix,print_in_addr_t (iph->saddr,IA_NET_ORDER , &gc),print_in_addr_t (iph->daddr,IA_NET_ORDER , &gc));
@@ -189,11 +181,10 @@ }void -client_nat_transform (const struct client_nat_option_list *list, -struct buffer *ipbuf, +client_nat_transform (const struct client_nat_option_list *list,struct buffer *ipbuf,const int direction) { -struct ip_tcp_udp_hdr *h = (struct ip_tcp_udp_hdr *)BPTR (ipbuf); +struct ip_tcp_udp_hdr *h = (struct ip_tcp_udp_hdr *)BPTR (ipbuf);int i;uint32_t addr, *addr_ptr;const uint32_t *from, *to;
src/openvpn/clinat.h +12 -12
@@ -30,7 +30,8 @@#define CN_OUTGOING 0#define CN_INCOMING 1 -struct client_nat_entry { +struct client_nat_entry +{#define CN_SNAT 0#define CN_DNAT 1int type;
@@ -39,28 +40,27 @@in_addr_t foreign_network; }; -struct client_nat_option_list { +struct client_nat_option_list +{int n;struct client_nat_entry entries[MAX_CLIENT_NAT ]; };struct client_nat_option_list *new_client_nat_list (struct gc_arena *gc); -struct client_nat_option_list *clone_client_nat_option_list (const struct client_nat_option_list *src,struct gc_arena *gc); +struct client_nat_option_list *clone_client_nat_option_list ( +const struct client_nat_option_list *src,struct gc_arena *gc); -void copy_client_nat_option_list (struct client_nat_option_list *dest,const struct client_nat_option_list *src); +void copy_client_nat_option_list (struct client_nat_option_list *dest, +const struct client_nat_option_list *src);void print_client_nat_list (const struct client_nat_option_list *list,int msglevel); -void add_client_nat_to_option_list (struct client_nat_option_list *dest, -const char *type, -const char *network, -const char *netmask, -const char *foreign_network, -int msglevel); +void add_client_nat_to_option_list (struct client_nat_option_list *dest,const char *type, +const char *network,const char *netmask, +const char *foreign_network,int msglevel); -void client_nat_transform (const struct client_nat_option_list *list, -struct buffer *ipbuf, +void client_nat_transform (const struct client_nat_option_list *list,struct buffer *ipbuf,const int direction);#endif /* if !defined(CLINAT_H) */
src/openvpn/common.h +7 -6
@@ -27,7 +27,7 @@* Statistics counters and associated printf format. */ typedef uint64_t counter_type ; -#define counter_format "%" PRIu64 +#define counter_format "%" PRIu64/* * Time intervals
@@ -37,17 +37,17 @@/* * Used as an upper bound for timeouts. */ -#define BIG_TIMEOUT (60*60*24*7)/* one week (in seconds) */ +#define BIG_TIMEOUT (60 * 60 * 24 * 7)/* one week (in seconds) */ /* * Printf formats for special types */ #ifdef _WIN64 -#define ptr_format "0x%016" PRIx64 +#define ptr_format "0x%016" PRIx64#else -#define ptr_format "0x%08lx" +#define ptr_format "0x%08lx"#endif -#define fragment_header_format "0x%08x" +#define fragment_header_format "0x%08x"/* these are used to cast the arguments * and MUST match the formats above */
@@ -94,6 +94,7 @@/* * Script security warning */ -#define SCRIPT_SECURITY_WARNING "WARNING: External program may not be called unless '--script-security 2' or higher is enabled. See --help text or man page for detailed info." +#define SCRIPT_SECURITY_WARNING \ + "WARNING: External program may not be called unless '--script-security 2' or higher is enabled. See --help text or man page for detailed info."#endif /* ifndef COMMON_H */
src/openvpn/comp-lz4.c +13 -28
86 lines not on this page · raw message
src/openvpn/comp.c +5 -5
@@ -171,10 +171,10 @@ {#ifdef USE_COMP msg (msglevel,"Compression or compression stub framing is not allowed " -"since data-channel offloading is enabled." ); +"since data-channel offloading is enabled." );#else msg (msglevel,"Compression or compression stub framing is not allowed " -"since OpenVPN was built without compression support." ); +"since OpenVPN was built without compression support." );#endif return false; }
@@ -182,14 +182,14 @@if ((info->flags &COMP_F_ALLOW_STUB_ONLY ) &&comp_non_stub_enabled (info)) {msg (msglevel,"Compression is not allowed since allow-compression is " -"set to 'stub-only'" ); +"set to 'stub-only'" );return false; }#ifndef ENABLE_LZ4 if (info->alg ==COMP_ALGV2_LZ4 || info->alg ==COMP_ALG_LZ4 ) {msg (msglevel,"OpenVPN is compiled without LZ4 support. Requested " -"compression cannot be enabled." ); +"compression cannot be enabled." );return false; }#endif
@@ -197,7 +197,7 @@if (info->alg ==COMP_ALG_LZO ) {msg (msglevel,"OpenVPN is compiled without LZO support. Requested " -"compression cannot be enabled." ); +"compression cannot be enabled." );return false; }#endif
src/openvpn/comp.h +21 -24
102 lines not on this page · raw message
src/openvpn/compstub.c +9 -23
@@ -45,8 +45,7 @@ }static void -stub_compress (struct buffer *buf,struct buffer work, -struct compress_context *compctx, +stub_compress (struct buffer *buf,struct buffer work,struct compress_context *compctx,const struct frame *frame) {if (buf->len <=0 )
@@ -56,7 +55,7 @@if (compctx->flags &COMP_F_SWAP ) {uint8_t *head =BPTR (buf); -uint8_t *tail =BEND (buf); +uint8_t *tail =BEND (buf);ASSERT (buf_safe (buf,1 )); ++buf->len;
@@ -72,8 +71,7 @@ }static void -stub_decompress (struct buffer *buf,struct buffer work, -struct compress_context *compctx, +stub_decompress (struct buffer *buf,struct buffer work,struct compress_context *compctx,const struct frame *frame) {uint8_t c;
@@ -107,8 +105,7 @@static void -stubv2_compress (struct buffer *buf,struct buffer work, -struct compress_context *compctx, +stubv2_compress (struct buffer *buf,struct buffer work,struct compress_context *compctx,const struct frame *frame) {if (buf->len <=0 )
@@ -120,8 +117,7 @@ }static void -stubv2_decompress (struct buffer *buf,struct buffer work, -struct compress_context *compctx, +stubv2_decompress (struct buffer *buf,struct buffer work,struct compress_context *compctx,const struct frame *frame) {if (buf->len <=0 )
@@ -157,19 +153,9 @@ } } -const struct compress_alg compv2_stub_alg = { -"stubv2" , - stub_compress_init, - stub_compress_uninit, - stubv2_compress, - stubv2_decompress -}; +const struct compress_alg compv2_stub_alg = {"stubv2" , stub_compress_init, stub_compress_uninit, + stubv2_compress, stubv2_decompress }; -const struct compress_alg comp_stub_alg = { -"stub" , - stub_compress_init, - stub_compress_uninit, - stub_compress, - stub_decompress -}; +const struct compress_alg comp_stub_alg = {"stub" , stub_compress_init, stub_compress_uninit, + stub_compress, stub_decompress };#endif /* USE_STUB */
src/openvpn/console.c +4 -6
@@ -37,7 +37,7 @@#endif -struct _query_user query_user[QUERY_USER_NUMSLOTS ];/* GLOBAL */ +struct _query_user query_user[QUERY_USER_NUMSLOTS ];/* GLOBAL */ void
@@ -53,16 +53,14 @@void -query_user_add (char *prompt,size_t prompt_len, -char *resp,size_t resp_len, -bool echo) +query_user_add (char *prompt,size_t prompt_len,char *resp,size_t resp_len,bool echo) {int i;/* Ensure input is sane. All these must be present otherwise it is * a programming error. */ -ASSERT ( prompt_len >0 && prompt !=NULL && resp_len >0 && resp !=NULL ); +ASSERT (prompt_len >0 && prompt !=NULL && resp_len >0 && resp !=NULL );/* Seek to the last unused slot */ for (i =0 ; i <QUERY_USER_NUMSLOTS ; i++)
@@ -72,7 +70,7 @@break ; } } -ASSERT ( i <QUERY_USER_NUMSLOTS );/* Unlikely, but we want to panic if it happens */ +ASSERT (i <QUERY_USER_NUMSLOTS );/* Unlikely, but we want to panic if it happens */ /* Save the information needed for the user interaction */ query_user[i].prompt = prompt;
src/openvpn/console.h +11 -14
@@ -30,16 +30,17 @@/** * Configuration setup for declaring what kind of information to ask a user for */ -struct _query_user { -char *prompt;/**< Prompt to present to the user */ -size_t prompt_len;/**< Length of the prompt string */ -char *response;/**< The user's response */ -size_t response_len;/**< Length the of the user response */ -bool echo;/**< True: The user should see what is being typed, otherwise mask it */ +struct _query_user +{ +char *prompt;/**< Prompt to present to the user */ +size_t prompt_len;/**< Length of the prompt string */ +char *response;/**< The user's response */ +size_t response_len;/**< Length the of the user response */ +bool echo;/**< True: The user should see what is being typed, otherwise mask it */ };#define QUERY_USER_NUMSLOTS 10 -extern struct _query_user query_user[];/**< Global variable, declared in console.c */ +extern struct _query_user query_user[];/**< Global variable, declared in console.c */ /** * Wipes all data put into all of the query_user structs
@@ -58,9 +59,7 @@* @param echo Should the user input be echoed to the user? If False, input will be masked * */ -void query_user_add (char *prompt,size_t prompt_len, -char *resp,size_t resp_len, -bool echo); +void query_user_add (char *prompt,size_t prompt_len,char *resp,size_t resp_len,bool echo);/**
@@ -107,7 +106,7 @@ {return query_user_exec_builtin (); } -#endif /* defined(ENABLE_SYSTEMD) */ +#endif /* defined(ENABLE_SYSTEMD) */ /**
@@ -118,9 +117,7 @@* */ static inline bool -query_user_SINGLE (char *prompt,size_t prompt_len, -char *resp,size_t resp_len, -bool echo) +query_user_SINGLE (char *prompt,size_t prompt_len,char *resp,size_t resp_len,bool echo) {query_user_clear ();query_user_add (prompt, prompt_len, resp, resp_len, echo);
src/openvpn/console_builtin.c +12 -11
@@ -67,11 +67,10 @@HANDLE in =GetStdHandle (STD_INPUT_HANDLE );int orig_stderr =get_orig_stderr ();/* guaranteed to be always valid */ -if ((in ==INVALID_HANDLE_VALUE ) - ||win32_service_interrupt (&win32_signal) +if ((in ==INVALID_HANDLE_VALUE ) ||win32_service_interrupt (&win32_signal) || (_write (orig_stderr, prompt,strlen (prompt)) ==-1 )) { -msg (M_WARN |M_ERRNO ,"get_console_input_win32(): unexpected error" ); +msg (M_WARN |M_ERRNO ,"get_console_input_win32(): unexpected error" );return false; }
@@ -135,7 +134,7 @@ return false; } -#endif /* _WIN32 */ +#endif /* _WIN32 */ #ifdef HAVE_TERMIOS_H
@@ -177,7 +176,7 @@ } } -#endif /* HAVE_TERMIOS_H */ +#endif /* HAVE_TERMIOS_H */ /**
@@ -209,15 +208,17 @@* (in which case neither stdin or stderr are connected to a tty and * /dev/tty can not be open()ed anymore) */ -if (!isatty (0 ) && !isatty (2 ) ) +if (!isatty (0 ) && !isatty (2 )) { -int fd =open ("/dev/tty" ,O_RDWR ); +int fd =open ("/dev/tty" ,O_RDWR );if (fd <0 ) { -msg (M_FATAL ,"neither stdin nor stderr are a tty device and you have neither a " +msg (M_FATAL , +"neither stdin nor stderr are a tty device and you have neither a " "controlling tty nor systemd - can't ask for '%s'. If you used --daemon, " "you need to use --askpass to make passphrase-protected keys work, and you " -"can not use --auth-nocache." , prompt ); +"can not use --auth-nocache." , + prompt); }close (fd); }
@@ -285,8 +286,8 @@/* Loop through configured query_user slots */ for (i =0 ; i <QUERY_USER_NUMSLOTS && query_user[i].response !=NULL ; i++) { -if (!get_console_input (query_user[i].prompt, query_user[i].echo, - query_user[i].response, query_user[i].response_len) ) +if (!get_console_input (query_user[i].prompt, query_user[i].echo, query_user[i].response, + query_user[i].response_len)) {/* Force the final result state to failed on failure */ ret = false;
src/openvpn/console_systemd.c +4 -6
@@ -50,9 +50,7 @@* mounted, as well as the systemd-ask-password executable * being available */ -return (sd_booted () >0 ) - && (stat (SYSTEMD_ASK_PASSWORD_PATH , &c) ==0 ); - +return (sd_booted () >0 ) && (stat (SYSTEMD_ASK_PASSWORD_PATH , &c) ==0 ); } static bool
@@ -79,7 +77,7 @@return false; }memset (input,0 , capacity); -if (read (std_out, input, capacity-1 ) !=0 ) +if (read (std_out, input, capacity -1 ) !=0 ) {chomp (input); ret = true;
@@ -99,7 +97,7 @@bool query_user_exec_systemd (void ) { -bool ret = true;/* Presume everything goes okay */ +bool ret = true;/* Presume everything goes okay */ int i;/* If systemd is not available, use the default built-in mechanism */
@@ -112,7 +110,7 @@for (i =0 ; i <QUERY_USER_NUMSLOTS && query_user[i].response !=NULL ; i++) {if (!get_console_input_systemd (query_user[i].prompt, query_user[i].echo, - query_user[i].response, query_user[i].response_len) ) + query_user[i].response, query_user[i].response_len)) {/* Force the final result state to failed on failure */ ret = false;
src/openvpn/crypto.c +122 -168
99 lines not on this page · raw message
src/openvpn/crypto.h +88 -102
190 lines not on this page · raw message
src/openvpn/crypto_epoch.c +27 -43
70 lines not on this page · raw message
src/openvpn/crypto_epoch.h +16 -30
46 lines not on this page · raw message
src/openvpn/crypto_mbedtls.c +74 -74
148 lines not on this page · raw message
src/openvpn/crypto_openssl.c +85 -97
182 lines not on this page · raw message
src/openvpn/cryptoapi.c +57 -52
109 lines not on this page · raw message
src/openvpn/dco.c +57 -59
116 lines not on this page · raw message
src/openvpn/dco_linux.c +67 -102
169 lines not on this page · raw message
src/openvpn/dco_win.c +63 -56
119 lines not on this page · raw message
src/openvpn/dco_win.h +20 -23
43 lines not on this page · raw message
src/openvpn/dhcp.c +28 -28
56 lines not on this page · raw message
src/openvpn/dns.c +36 -38
74 lines not on this page · raw message
src/openvpn/errlevel.h +115 -115
230 lines not on this page · raw message
src/openvpn/error.c +51 -86
137 lines not on this page · raw message
src/openvpn/error.h +77 -41
118 lines not on this page · raw message
src/openvpn/event.c +80 -98
178 lines not on this page · raw message
src/openvpn/event.h +34 -31
65 lines not on this page · raw message
src/openvpn/forward.c +116 -156
272 lines not on this page · raw message
src/openvpn/forward.h +34 -37
71 lines not on this page · raw message
src/openvpn/fragment.c +40 -54
94 lines not on this page · raw message
src/openvpn/fragment.h +39 -39
78 lines not on this page · raw message
src/openvpn/helper.c +48 -40
88 lines not on this page · raw message
src/openvpn/httpdigest.c +39 -50
89 lines not on this page · raw message
src/openvpn/init.c +308 -477
785 lines not on this page · raw message
src/openvpn/list.c +59 -57
116 lines not on this page · raw message
src/openvpn/manage.c +278 -355
633 lines not on this page · raw message
src/openvpn/manage.h +114 -143
257 lines not on this page · raw message
src/openvpn/misc.c +139 -138
277 lines not on this page · raw message
src/openvpn/misc.h +36 -41
77 lines not on this page · raw message
src/openvpn/mroute.c +32 -45
77 lines not on this page · raw message
src/openvpn/mroute.h +63 -68
131 lines not on this page · raw message
src/openvpn/mss.c +33 -47
80 lines not on this page · raw message
src/openvpn/mtu.c +20 -29
49 lines not on this page · raw message
src/openvpn/mtu.h +65 -76
141 lines not on this page · raw message
src/openvpn/mudp.c +34 -35
69 lines not on this page · raw message
src/openvpn/multi.c +360 -481
841 lines not on this page · raw message
src/openvpn/multi.h +65 -67
132 lines not on this page · raw message
src/openvpn/multi_io.c +65 -73
138 lines not on this page · raw message
src/openvpn/networking.h +25 -36
61 lines not on this page · raw message
src/openvpn/networking_freebsd.c +20 -34
54 lines not on this page · raw message
src/openvpn/networking_iproute2.c +37 -57
94 lines not on this page · raw message
src/openvpn/networking_sitnl.c +165 -209
374 lines not on this page · raw message
src/openvpn/ntlm.c +50 -55
105 lines not on this page · raw message
src/openvpn/occ.c +96 -111
207 lines not on this page · raw message
src/openvpn/openvpn.h +68 -64
132 lines not on this page · raw message
src/openvpn/options.c +752 -904
1,656 lines not on this page · raw message
src/openvpn/options.h +105 -126
231 lines not on this page · raw message
src/openvpn/ovpn_dco_freebsd.h +28 -24
52 lines not on this page · raw message
src/openvpn/packet_id.c +41 -72
113 lines not on this page · raw message
src/openvpn/packet_id.h +29 -33
62 lines not on this page · raw message
src/openvpn/perf.c +31 -43
74 lines not on this page · raw message
src/openvpn/perf.h +22 -22
44 lines not on this page · raw message
src/openvpn/pkcs11.c +165 -383
548 lines not on this page · raw message
src/openvpn/pkcs11.h +12 -37
49 lines not on this page · raw message
src/openvpn/pkcs11_openssl.c +40 -41
81 lines not on this page · raw message
src/openvpn/platform.c +36 -38
74 lines not on this page · raw message
src/openvpn/plugin.c +85 -116
201 lines not on this page · raw message
src/openvpn/plugin.h +26 -35
61 lines not on this page · raw message
src/openvpn/pool.c +49 -75
124 lines not on this page · raw message
src/openvpn/proto.h +90 -84
174 lines not on this page · raw message
src/openvpn/proxy.c +80 -120
200 lines not on this page · raw message
src/openvpn/ps.c +53 -69
122 lines not on this page · raw message
src/openvpn/push.c +88 -114
202 lines not on this page · raw message
src/openvpn/reliable.c +28 -35
63 lines not on this page · raw message
src/openvpn/reliable.h +25 -29
54 lines not on this page · raw message
src/openvpn/ring_buffer.h new file +124 -0
124 lines not on this page · raw message
src/openvpn/route.c +423 -692
1,115 lines not on this page · raw message
src/openvpn/route.h +112 -123
235 lines not on this page · raw message
src/openvpn/run_command.h +20 -21
41 lines not on this page · raw message
src/openvpn/schedule.c +16 -35
51 lines not on this page · raw message
src/openvpn/sig.c +28 -31
59 lines not on this page · raw message
src/openvpn/socket.c +339 -560
899 lines not on this page · raw message
src/openvpn/socket.h +162 -227
389 lines not on this page · raw message
src/openvpn/socks.c +55 -61
116 lines not on this page · raw message
src/openvpn/ssl.c +265 -427
692 lines not on this page · raw message
src/openvpn/ssl.h +46 -72
118 lines not on this page · raw message
src/openvpn/ssl_backend.h +27 -38
65 lines not on this page · raw message
src/openvpn/ssl_common.h +94 -85
179 lines not on this page · raw message
src/openvpn/ssl_mbedtls.c +122 -181
303 lines not on this page · raw message
src/openvpn/ssl_mbedtls.h +36 -29
65 lines not on this page · raw message
src/openvpn/ssl_ncp.c +44 -57
101 lines not on this page · raw message
src/openvpn/ssl_openssl.c +144 -178
322 lines not on this page · raw message
src/openvpn/ssl_pkt.c +38 -70
108 lines not on this page · raw message
src/openvpn/ssl_pkt.h +44 -62
106 lines not on this page · raw message
src/openvpn/ssl_util.c +152 -141
293 lines not on this page · raw message
src/openvpn/ssl_verify.c +165 -166
331 lines not on this page · raw message
src/openvpn/ssl_verify.h +24 -27
51 lines not on this page · raw message
src/openvpn/ssl_verify_mbedtls.c +55 -67
122 lines not on this page · raw message
src/openvpn/ssl_verify_openssl.c +44 -54
98 lines not on this page · raw message
src/openvpn/syshead.h +25 -23
48 lines not on this page · raw message
src/openvpn/tls_crypt.c +87 -140
227 lines not on this page · raw message
src/openvpn/tls_crypt.h +22 -29
51 lines not on this page · raw message
src/openvpn/tun.c +616 -944
1,560 lines not on this page · raw message
src/openvpn/tun.h +58 -65
123 lines not on this page · raw message
src/openvpn/wfp_block.c +31 -66
97 lines not on this page · raw message
src/openvpn/win32.c +87 -100
187 lines not on this page · raw message
src/openvpn/win32.h +30 -33
63 lines not on this page · raw message
src/openvpn/xkey_helper.c +47 -50
97 lines not on this page · raw message
src/openvpn/xkey_provider.c +154 -146
300 lines not on this page · raw message
src/openvpnmsica/openvpnmsica.c +179 -170
349 lines not on this page · raw message
src/openvpnmsica/openvpnmsica.h +75 -79
154 lines not on this page · raw message
src/openvpnserv/common.c +24 -25
49 lines not on this page · raw message
src/openvpnserv/interactive.c +196 -211
407 lines not on this page · raw message
src/openvpnserv/service.c +21 -25
46 lines not on this page · raw message
src/plugins/auth-pam/auth-pam.c +75 -67
142 lines not on this page · raw message
src/plugins/auth-pam/pamdl.c +29 -37
66 lines not on this page · raw message
src/tapctl/error.h +45 -21
66 lines not on this page · raw message
src/tapctl/main.c +72 -60
132 lines not on this page · raw message
src/tapctl/tap.c +148 -271
419 lines not on this page · raw message
src/tapctl/tap.h +13 -29
42 lines not on this page · raw message
tests/unit_tests/openvpn/cert_data.h +34 -36
70 lines not on this page · raw message
tests/unit_tests/openvpn/mock_management.c +1 -2
Lines of this file are not shown. View the raw message.
tests/unit_tests/openvpn/mock_ssl_dependencies.c +2 -2
Lines of this file are not shown. View the raw message.
tests/unit_tests/openvpn/pkey_test_utils.c +5 -6
Lines of this file are not shown. View the raw message.
tests/unit_tests/openvpn/test_auth_token.c +59 -66
125 lines not on this page · raw message
tests/unit_tests/openvpn/test_buffer.c +28 -37
65 lines not on this page · raw message
tests/unit_tests/openvpn/test_crypto.c +85 -131
216 lines not on this page · raw message
tests/unit_tests/openvpn/test_cryptoapi.c +41 -42
83 lines not on this page · raw message
tests/unit_tests/openvpn/test_misc.c +38 -35
73 lines not on this page · raw message
tests/unit_tests/openvpn/test_ncp.c +34 -46
80 lines not on this page · raw message
tests/unit_tests/openvpn/test_networking.c +4 -10
Lines of this file are not shown. View the raw message.
tests/unit_tests/openvpn/test_packet_id.c +25 -32
57 lines not on this page · raw message
tests/unit_tests/openvpn/test_pkcs11.c +46 -47
93 lines not on this page · raw message
tests/unit_tests/openvpn/test_pkt.c +94 -120
214 lines not on this page · raw message
tests/unit_tests/openvpn/test_provider.c +27 -26
53 lines not on this page · raw message
tests/unit_tests/openvpn/test_push_update_msg.c +44 -48
92 lines not on this page · raw message
tests/unit_tests/openvpn/test_ssl.c +24 -31
55 lines not on this page · raw message
tests/unit_tests/openvpn/test_tls_crypt.c +105 -150
255 lines not on this page · raw message
tests/unit_tests/openvpn/test_user_pass.c +17 -14
Lines of this file are not shown. View the raw message.
tests/unit_tests/plugins/auth-pam/test_search_and_replace.c +0 -2
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
[Openvpn-devel] [PATCH applied] Re: Reformat the whole project with clang-format
So this patch is huge, touches almost all files, and has the potential to sneak in "innocent" changes - which is why we have the clang-format rules published beforehand, so whoever wants can verify that this patch is, indeed, only the result of clang-format (checkout the commit before that, run "clang-format -i *.c *.h", then "diff" to the files after this commit).
This said, I have pushed it to all test instruments we have, and everything still compiles *and tests* fine. Just to be sure.
It has a few ugly warts where the code "as it was before" did not make it possible to apply the rules in a non-ugly way (like some SetLastError() calls with long /* comments */ after them) - there will be a few more commits coming that clean up these accidents, for example by moving the comment before the line so it does not need wrapping.
Also, we'll change the setting of "ColumnLimit" to "0" in a subsequent patch, as it turns out that the setting of "100" will also make clang-format un-wrap some multi-line statements in most interesting ways - so these are better left to human common sense. The limit we try to achieve is still "80, if you can, 100, if wrapping at 80 would be more ugly" (and we had heated discussions on which constructs are "ugly"... as they say, the beauty lies in the eyes of the beholder).
For whatever reason, error.h, openvpnmsica.c and tapctl/main.c differ here in function return type wrapping, but this will be addressed in a followup patch.
Your patch has been applied to the master branch.
commit 3cca3367e6e0ffeccb8e39cb2c739d1dcb086701
Author: Frank Lichtenheld Date: Mon Aug 4 17:18:47 2025 +0200
Reformat the whole project with clang-format
Signed-off-by: Frank Lichtenheld <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://gerrit.openvpn.net/c/openvpn/+/791
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering