]> git.ipfire.org Git - thirdparty/openvpn.git/commit
tun: create tun_name_is_fixed helper
authorAntonio Quartulli <a@unstable.cc>
Tue, 12 Jul 2022 22:16:55 +0000 (00:16 +0200)
committerGert Doering <gert@greenie.muc.de>
Thu, 14 Jul 2022 16:50:58 +0000 (18:50 +0200)
commit4a88d2fbe73a64f8f3861089a2b6e3b8e583e71b
treec6cf98f211478906e293c045d5ec5784686d6a9e
parent26b6b6f0673fa1f3806c447a18bb0f705b231b35
tun: create tun_name_is_fixed helper

This helper encloses the (simple) logic used by OpenVPN to determine if
the name passed to --dev has to be considered a fixed interface name or
just a pattern.

Having a helper is useful because when this logic is required elsewhere,
we can just re-use this logic without duplicating the code (which may
mean introducing bugs if a future logic change should not update all
spots).

The logic is actually fairly simple: check if the name contains a number
(i.e. tun0). If so, consider the name a fixed device name.

While at it make has_digit() accept a signed argument because strings
are normally signed (also isdigit() accepts a signed argument).

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220712221655.19333-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24676.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/buffer.h
src/openvpn/tun.c
src/openvpn/tun.h