[nat] Make create_sccp_src_ref return the SCCP Connection.

Right now it was not possible to just find a connection, by returning
the connection that is created we will have direct access to it. It
will be used by the local connection handling.
diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h
index bcd6f8e..64be6b3 100644
--- a/openbsc/include/openbsc/bsc_nat.h
+++ b/openbsc/include/openbsc/bsc_nat.h
@@ -281,7 +281,7 @@
 /**
  * SCCP patching and handling
  */
-int create_sccp_src_ref(struct bsc_connection *bsc, struct bsc_nat_parsed *parsed);
+struct sccp_connections *create_sccp_src_ref(struct bsc_connection *bsc, struct bsc_nat_parsed *parsed);
 int update_sccp_src_ref(struct sccp_connections *sccp, struct bsc_nat_parsed *parsed);
 void remove_sccp_src_ref(struct bsc_connection *bsc, struct msgb *msg, struct bsc_nat_parsed *parsed);
 struct sccp_connections *patch_sccp_src_ref_to_bsc(struct msgb *, struct bsc_nat_parsed *, struct bsc_nat *);
diff --git a/openbsc/src/nat/bsc_nat.c b/openbsc/src/nat/bsc_nat.c
index 0fa5713..3beefc5 100644
--- a/openbsc/src/nat/bsc_nat.c
+++ b/openbsc/src/nat/bsc_nat.c
@@ -644,7 +644,7 @@
 		case SCCP_MSG_TYPE_CR:
 			if (bsc_nat_filter_sccp_cr(bsc, msg, parsed, &con_type) != 0)
 				goto exit3;
-			if (create_sccp_src_ref(bsc, parsed) != 0)
+			if (!create_sccp_src_ref(bsc, parsed))
 				goto exit2;
 			con = patch_sccp_src_ref_to_msc(msg, parsed, bsc);
 			con->con_type = con_type;
diff --git a/openbsc/src/nat/bsc_sccp.c b/openbsc/src/nat/bsc_sccp.c
index 47cd9ce..94b332a 100644
--- a/openbsc/src/nat/bsc_sccp.c
+++ b/openbsc/src/nat/bsc_sccp.c
@@ -82,7 +82,8 @@
 	return -1;
 }
 
-int create_sccp_src_ref(struct bsc_connection *bsc, struct bsc_nat_parsed *parsed)
+struct sccp_connections *create_sccp_src_ref(struct bsc_connection *bsc,
+					     struct bsc_nat_parsed *parsed)
 {
 	struct sccp_connections *conn;
 
@@ -101,11 +102,11 @@
 			bsc_mgcp_dlcx(conn);
 			llist_del(&conn->list_entry);
 			talloc_free(conn);
-			return -1;
+			return NULL;
 		} else {
 			clock_gettime(CLOCK_MONOTONIC, &conn->creation_time);
 			bsc_mgcp_dlcx(conn);
-			return 0;
+			return conn;
 		}
 	}
 
@@ -113,7 +114,7 @@
 	conn = talloc_zero(bsc->nat, struct sccp_connections);
 	if (!conn) {
 		LOGP(DNAT, LOGL_ERROR, "Memory allocation failure.\n");
-		return -1;
+		return NULL;
 	}
 
 	conn->bsc = bsc;
@@ -122,7 +123,7 @@
 	if (assign_src_local_reference(&conn->patched_ref, bsc->nat) != 0) {
 		LOGP(DNAT, LOGL_ERROR, "Failed to assign a ref.\n");
 		talloc_free(conn);
-		return -1;
+		return NULL;
 	}
 
 	bsc_mgcp_init(conn);
@@ -134,7 +135,7 @@
 	     sccp_src_ref_to_int(&conn->real_ref),
 	     sccp_src_ref_to_int(&conn->patched_ref), bsc);
 
-	return 0;
+	return conn;
 }
 
 int update_sccp_src_ref(struct sccp_connections *sccp, struct bsc_nat_parsed *parsed)
diff --git a/openbsc/tests/bsc-nat/bsc_nat_test.c b/openbsc/tests/bsc-nat/bsc_nat_test.c
index ca9fbd4..6ad9870 100644
--- a/openbsc/tests/bsc-nat/bsc_nat_test.c
+++ b/openbsc/tests/bsc-nat/bsc_nat_test.c
@@ -273,10 +273,10 @@
 /* test conn tracking once */
 static void test_contrack()
 {
-	int rc;
 	struct bsc_nat *nat;
 	struct bsc_connection *con;
 	struct sccp_connections *con_found;
+	struct sccp_connections *rc_con;
 	struct bsc_nat_parsed *parsed;
 	struct msgb *msg;
 
@@ -294,8 +294,8 @@
 		fprintf(stderr, "Con should not exist %p\n", con_found);
 		abort();
 	}
-	rc = create_sccp_src_ref(con, parsed);
-	if (rc != 0) {
+	rc_con = create_sccp_src_ref(con, parsed);
+	if (!rc_con) {
 		fprintf(stderr, "Failed to create a ref\n");
 		abort();
 	}
@@ -304,6 +304,10 @@
 		fprintf(stderr, "Failed to find the con: %p\n", con_found);
 		abort();
 	}
+	if (con_found != rc_con) {
+		fprintf(stderr, "Failed to find the right connection.\n");
+		abort();
+	}
 	if (memcmp(msg->data, bsc_cr_patched, sizeof(bsc_cr_patched)) != 0) {
 		fprintf(stderr, "Failed to patch the BSC CR msg.\n");
 		abort();