[Openvpn-devel,2/3] Use buffer to prepare protocol-flags push-reply
Commit Message
The current approach of checking a string buffer is a bit clunky and
also not very extensible. Refactor this by collecting the flags in
a buffer.
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
---
src/openvpn/push.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
Comments
Hi,
On Fri, Sep 09, 2022 at 09:59:01PM +0200, Arne Schwabe wrote:
> The current approach of checking a string buffer is a bit clunky and
> also not very extensible. Refactor this by collecting the flags in
> a buffer.
I think that this one is obsolete, aka, already included in
commit 179b3728b71013413885e453e477997f5a396f78
Author: Arne Schwabe <arne@rfc2549.org>
Date: Wed Sep 14 18:50:41 2022 +0200
Implement exit notification via control channel
Patch v4: rebase, use a buffer for the code that prepares the push reply
can you confirm?
thanks,
gert
Am 05.10.2022 um 22:19 schrieb Gert Doering:
> Hi,
>
> On Fri, Sep 09, 2022 at 09:59:01PM +0200, Arne Schwabe wrote:
>> The current approach of checking a string buffer is a bit clunky and
>> also not very extensible. Refactor this by collecting the flags in
>> a buffer.
> I think that this one is obsolete, aka, already included in
>
> commit 179b3728b71013413885e453e477997f5a396f78
> Author: Arne Schwabe <arne@rfc2549.org>
> Date: Wed Sep 14 18:50:41 2022 +0200
>
> Implement exit notification via control channel
>
> Patch v4: rebase, use a buffer for the code that prepares the push reply
>
> can you confirm?
Yes. You are right. During the rebase of cc exit, I included it there.
Arne
@@ -647,14 +647,18 @@ prepare_push_reply(struct context *c, struct gc_arena *gc,
}
}
+ struct buffer proto_flags = alloc_buf_gc(128, gc);
+
if (o->imported_protocol_flags & CO_USE_CC_EXIT_NOTIFY)
{
- const char *ekm = "";
+ buf_printf(&proto_flags, " cc-exit");
+
+ /* if the cc exit flag is supported, pushing tls-ekm via protocol-flags
+ * is also supported */
if (o->imported_protocol_flags & CO_USE_TLS_KEY_MATERIAL_EXPORT)
{
- ekm = " tls-ekm";
+ buf_printf(&proto_flags, " tls-ekm");
}
- push_option_fmt(gc, push_list, M_USAGE, "protocol-flags cc-exit%s", ekm);
}
else if (o->imported_protocol_flags & CO_USE_TLS_KEY_MATERIAL_EXPORT)
{
@@ -662,6 +666,10 @@ prepare_push_reply(struct context *c, struct gc_arena *gc,
}
+ if (buf_len(&proto_flags) > 0)
+ {
+ push_option_fmt(gc, push_list, M_USAGE, "protocol-flags%s", buf_str(&proto_flags));
+ }
return true;
}