mirror of
https://passt.top/passt
synced 2025-06-08 00:35:33 +02:00
Clarify semantics of c->v4 and c->v6 variables
The v4 and v6 fields of the context structure can be confusing, because they change meaning part way through the code: Before conf_ip(), they are booleans which indicate whether the -4 or -6 options have been given. After conf_ip() they are DISABLED|ENABLED|PROBE enums which indicate whether the IP version is available (which means both that it was allowed on the command line and we were able to configure it). The PROBE variant of the enum is only used locally within conf_ip() and since recent changes there it no longer has a real purpose different from ENABLED. Simplify this all by making the context fields always just a boolean indicating the availability of the IP version. They both default to 1, but can be set to 0 by either command line options or configuration failures. We use some local variables in conf() for tracking the state of the command line options on their own. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> [sbrivio: Minor coding style fix in conf.c] Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
4bc883aeab
commit
c984ee5afd
2 changed files with 20 additions and 45 deletions
6
util.h
6
util.h
|
@ -74,12 +74,6 @@ void trace_init(int enable);
|
|||
#define V6 1
|
||||
#define IP_VERSIONS 2
|
||||
|
||||
enum {
|
||||
IP_VERSION_DISABLED = 0,
|
||||
IP_VERSION_ENABLED,
|
||||
IP_VERSION_PROBE,
|
||||
};
|
||||
|
||||
#define ARRAY_SIZE(a) ((int)(sizeof(a) / sizeof((a)[0])))
|
||||
|
||||
#define IN_INTERVAL(a, b, x) ((x) >= (a) && (x) <= (b))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue