use enums consistently instead of falling back to int

The two existing enums defined in gprs_sndcp_xid.h, for protocol
and data compression algorithm numbers respectively, were assigned
to 'int' variables when their values were copied to other structures.

This prevented the compiler from checking the enum value coverage
during switch statements and also tripped up Coverity scans looking
for enum value mismatch problems.

So instead of copying enums to ints, make use of the enums throughout.
Structures which can contain values from both enums now use a union
of both, forcing us to be very explicit about which set of values
we are dealing with.

Change-Id: I3771a5c59f4e6fee24083b3c914965baf192cbd7
Depends: If6f3598cd6da4643ff2214e21c0d21f6eff0eb67
Depends: I8444c1ed052707c76a979fb06cb018ac678defa7
Related: CID#149102
diff --git a/src/gprs/gprs_sndcp_comp.c b/src/gprs/gprs_sndcp_comp.c
index 3e02603..0b4c67c 100644
--- a/src/gprs/gprs_sndcp_comp.c
+++ b/src/gprs/gprs_sndcp_comp.c
@@ -55,32 +55,36 @@
 		memcpy(comp_entity->nsapi,
 		       comp_field->rfc1144_params->nsapi,
 		       sizeof(comp_entity->nsapi));
+		comp_entity->algo.pcomp = comp_field->algo.pcomp;
 	} else if (comp_field->rfc2507_params) {
 		comp_entity->nsapi_len = comp_field->rfc2507_params->nsapi_len;
 		memcpy(comp_entity->nsapi,
 		       comp_field->rfc2507_params->nsapi,
 		       sizeof(comp_entity->nsapi));
+		comp_entity->algo.pcomp = comp_field->algo.pcomp;
 	} else if (comp_field->rohc_params) {
 		comp_entity->nsapi_len = comp_field->rohc_params->nsapi_len;
 		memcpy(comp_entity->nsapi, comp_field->rohc_params->nsapi,
 		       sizeof(comp_entity->nsapi));
+		comp_entity->algo.pcomp = comp_field->algo.pcomp;
 	} else if (comp_field->v42bis_params) {
 		comp_entity->nsapi_len = comp_field->v42bis_params->nsapi_len;
 		memcpy(comp_entity->nsapi,
 		       comp_field->v42bis_params->nsapi,
 		       sizeof(comp_entity->nsapi));
+		comp_entity->algo.dcomp = comp_field->algo.dcomp;
 	} else if (comp_field->v44_params) {
 		comp_entity->nsapi_len = comp_field->v44_params->nsapi_len;
 		memcpy(comp_entity->nsapi,
 		       comp_field->v44_params->nsapi,
 		       sizeof(comp_entity->nsapi));
+		comp_entity->algo.dcomp = comp_field->algo.dcomp;
 	} else {
 		/* The caller is expected to check carefully if the all
 		 * data fields required for compression entity creation
 		 * are present. Otherwise we blow an assertion here */
 		OSMO_ASSERT(false);
 	}
-	comp_entity->algo = comp_field->algo;
 
 	/* Check if an NSAPI is selected, if not, it does not make sense
 	 * to create the compression entity, since the caller should
@@ -93,17 +97,20 @@
 	comp_entity->compclass = gprs_sndcp_get_compression_class(comp_field);
 
 	/* Create an algorithm specific compression context */
-	if (comp_entity->compclass == SNDCP_XID_PROTOCOL_COMPRESSION) {
+	switch (comp_entity->compclass) {
+	case SNDCP_XID_PROTOCOL_COMPRESSION:
 		if (gprs_sndcp_pcomp_init(ctx, comp_entity, comp_field) != 0) {
 			talloc_free(comp_entity);
 			comp_entity = NULL;
 		}
-	} else if (comp_entity->compclass == SNDCP_XID_DATA_COMPRESSION) {
+		break;
+	case SNDCP_XID_DATA_COMPRESSION:
 		if (gprs_sndcp_dcomp_init(ctx, comp_entity, comp_field) != 0) {
 			talloc_free(comp_entity);
 			comp_entity = NULL;
 		}
-	} else {
+		break;
+	default:
 		/* comp_field is somehow invalid */
 		OSMO_ASSERT(false);
 	}