Rename OVS_ARGTYPE_GROUP_ACTIONS_SAMPLE

Into OVS_ARGTYPE_ACTION_SAMPLE_GROUP. And move from section 'groups'
to sections 'actions' in OVS_ARGTYPE enum.

Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com>
Rename OVS_ARGTYPE_GROUP_ACTIONS_SETINFO

Into OVS_ARGTYPE_ACTION_SETINFO_GROUP. And move from section 'groups'
to sections 'actions' in OVS_ARGTYPE enum.

Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com>
Rename OVS_ARGTYPE_FLOW_MASK_GROUP

Into OVS_ARGTYPE_FLOW_MASK_GROUP. And move from section 'groups'
to sections 'actions' in OVS_ARGTYPE enum.

Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com>
Rename OVS_ARGTYPE_GROUP_OFPORT_OPTIONS

Into OVS_ARGTYPE_OFPORT_OPTIONS_GROUP. And move from section 'groups'
to sections 'actions' in OVS_ARGTYPE enum.

Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com>
Change values for arg types main & invalid

invalid is more natural to be zero, while the specific value of pseudo
group called 'main' is irrelevant (it must only be unique).

This change is needed if we change switch cases to arrays: the default
value of uninitialized values in a static variable is 0, which should
correspond with 'invalid' arg type.

Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com>
Correct the names for several first & last arg types

Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com>
Rename NETBUFFER -> PACKET in arg type names

PACKET is a more proper name. NETBUFFER seems to refer more to the NDIS
NET_BUFFER, but we send only the buffer represented by the NET_BUFFER,
with additional info.

Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com>
Refactor ArgToAttribute.c/.h: switch cases

ArgToAttribute.c uses lots of switches with lots of cases, in order to
transform an argument type (used in kernel) to an attribute type (used in
userspace). It is much shorter code if we use arrays instead of switch cases.

Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com>
Correct func IsArgTypeGroup

The argument types for groups no longer follow the same rules
as before. Therefore, we must change the function to reflect this.
Also, GetParentGroupType is Argument.c used a manual check for
'is arg type group'.

Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com>
Renounce OVS_ARGTYPE_GROUP_MAIN

Reason: if we use arrays instead of switch cases for arg types,
it is clearer & shorter if we use specific group types instead
of generic 'main'. I.e. we should use pseudo arg types, datapath,
flow, packet, ofport. This will allow easier lookup of arg type
specific things, because we will be able to store an array of
all groups, identifiable by 'group type' only (msg target type
not being needed at all).

Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com>
Use arrays of groups in _FindGroup

Instead of switch cases.
- Now we can use arrays of groups (we use pseudo arg types instead of arg type
'main'
- we need to update s_argsToAttribs: add the rest of arg groups.
- we need to update s_argsToAttribs: must be an array of structs. Each
struct will hold a ptr to the correspondig group.

The resulting code will be shorter, and clearer.

Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com>
Add attributes MAX in Attribute.h

When converting from attributes to arguments, we will need to know
the boundaries for groups: min attr type and max attr type.
min attr type is always 0.
max attr type must be determined.

For this purpose, we add MAX attr types for each group in Attribute.h

Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com>
Refactor AttrToArgument.c/.h: switch cases

AttrToArgument.c uses lots of switches with lots of cases, in order to
transform an argument type (used in kernel) to an attribute type (used
in userspace). It is much shorter code if we use arrays instead of
switch cases.

Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com>
Move arg verification code in new file

Argument and Argument group verification code is very large (~1400
lines). It is best to move this code into a separate .c file, for better
readability.

Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com>
Move arg list code in new file

It is best to move this code into a separate .c file, for better
readability.

Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com>
Refactor arg size computation in Argument.c

We've got too many switch cases there, and the code there assumes
that the parent arg type is required in order to compute the expected
size of the given arg type. For a very long time, it is no longer the
case.

We should have only one switch, with all the cases, to find the expected
size for a given arg type.

Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com>
Refactor arg dbgprints for arg types in Argument.c

We've got too many switch cases there, and the code there assumes
that the parent arg type is required in order to correctly dbgprint
an arg type. For a very long time, it is no longer the
case.

We should have only one switch, with all the cases, to find the expected
size for a given arg type.

Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com>
Use dbgprints for args, only on OVS_DBGPRINT_ARG

There are several functions that dbg print an arg / arg type / arg
group. But these functions are defined and called, regardless of
OVS_DBGPRINT_ARG.

Macros must be #define-d, for OVS_DBGPRINT_ARG, that wrap these
function calls.
Also, these functions & macros must have as parameter the log level as
well.

Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com>
Add #define-s for message target types

OVS_GENL_TARGET_TO_INDEX: will be used by message verification, when
we will use arrays instead of switch cases.

Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com>
Add debug macro: EXPECT

Check a boolean expression, and if its value is FALSE, it calls OVS_CHECK_RET.
The usage of EXPECT will shorten the code, making it clearer.

Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com>