protocol: do not change LCO, when no LCO are present

In the current implementation the LCO parameters are reset. This means
that an MDCX without LCO will reset the LCO that have previously set
via CRCX. But according to RFC 3435 6.8 LocalConnectionOptions, the
LCO parameters should be preserved or left at their defaults if missing.

- Make sure LCO are retained if no LCO string is present.
- Also preserve the values of individual parameters if missing.

Change-Id: Ia0d73f61516618317dcd1d49384818fd8de27aa6
diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index b403be0..ded1552 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -405,10 +405,12 @@
 	char *p_opt, *a_opt;
 	char codec[9];
 
+	if (!options)
+		return 0;
+	if (strlen(options) == 0)
+		return 0;
+
 	talloc_free(lco->string);
-	talloc_free(lco->codec);
-	lco->codec = NULL;
-	lco->pkt_period_min = lco->pkt_period_max = 0;
 	lco->string = talloc_strdup(ctx, options ? options : "");
 
 	p_opt = strstr(lco->string, "p:");
@@ -417,8 +419,10 @@
 		lco->pkt_period_max = lco->pkt_period_min;
 
 	a_opt = strstr(lco->string, "a:");
-	if (a_opt && sscanf(a_opt, "a:%8[^,]", codec) == 1)
+	if (a_opt && sscanf(a_opt, "a:%8[^,]", codec) == 1) {
+		talloc_free(lco->codec);
 		lco->codec = talloc_strdup(ctx, codec);
+	}
 
 	LOGP(DLMGCP, LOGL_DEBUG,
 	     "local CX options: lco->pkt_period_max: %i, lco->codec: %s\n",