bsc/nat: Fix the structure of the identity request message

Unfortunately the basic structure of the response is broken.
There is a two byte length followed by data. The concept of
a 'tag' happens to be the first byte of the data.

This means we want to write strlen of the token, then we
want to write the NUL and then we need to account for the
tag in front.

Introduce a flag if the new or old format should be used.
This will allow to have new BSCs talk to old NATs without
an additional change. In the long run we can clean that up.
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c
index 9216654..841262c 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c
@@ -357,7 +357,7 @@
 
 static void send_id_get_response(struct bsc_msc_connection *msc_con)
 {
-	struct msgb *msg = bsc_msc_id_get_resp(nat->token);
+	struct msgb *msg = bsc_msc_id_get_resp(0, nat->token);
 	if (!msg)
 		return;
 
@@ -960,7 +960,7 @@
 {
 	struct bsc_config *conf;
 	const char *token = (const char *) TLVP_VAL(tvp, IPAC_IDTAG_UNITNAME);
-	const int len = TLVP_LEN(tvp, IPAC_IDTAG_UNITNAME);
+	int len = TLVP_LEN(tvp, IPAC_IDTAG_UNITNAME);
 
 	if (bsc->cfg) {
 		LOGP(DNAT, LOGL_ERROR, "Reauth on fd %d bsc nr %d\n",
@@ -980,11 +980,18 @@
 		return;
 	}
 
+	/*
+	 * New systems have fixed the structure of the message but
+	 * we need to support old ones too.
+	 */
+	if (len >= 2 && token[len - 2] == '\0')
+		len -= 1;
+
 	conf = bsc_config_by_token(bsc->nat, token, len);
 	if (!conf) {
 		LOGP(DNAT, LOGL_ERROR,
-			"No bsc found for token '%s' on fd: %d.\n", token,
-			bsc->write_queue.bfd.fd);
+			"No bsc found for token '%s' len %d on fd: %d.\n", token,
+			bsc->write_queue.bfd.fd, len);
 		bsc_close_connection(bsc);
 		return;
 	}