sccp: Move the destruction of the sccp connection to a new place
diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h
index f354842..bdea434 100644
--- a/openbsc/include/openbsc/bsc_nat.h
+++ b/openbsc/include/openbsc/bsc_nat.h
@@ -139,6 +139,7 @@
 struct bsc_nat *bsc_nat_alloc(void);
 struct bsc_connection *bsc_connection_alloc(struct bsc_nat *nat);
 
+void sccp_connection_destroy(struct sccp_connections *);
 
 /**
  * parse the given message into the above structure
diff --git a/openbsc/src/nat/bsc_nat.c b/openbsc/src/nat/bsc_nat.c
index 7d9cd89..c7c6c41 100644
--- a/openbsc/src/nat/bsc_nat.c
+++ b/openbsc/src/nat/bsc_nat.c
@@ -334,8 +334,7 @@
 			continue;
 
 #warning "TODO: Send a RLSD to the MSC. Or at least a clear command."
-		llist_del(&sccp_patch->list_entry);
-		talloc_free(sccp_patch);
+		sccp_connection_destroy(sccp_patch);
 	}
 
 	talloc_free(connection);
diff --git a/openbsc/src/nat/bsc_nat_utils.c b/openbsc/src/nat/bsc_nat_utils.c
index bbbc6e2..3e44193 100644
--- a/openbsc/src/nat/bsc_nat_utils.c
+++ b/openbsc/src/nat/bsc_nat_utils.c
@@ -30,6 +30,8 @@
 #include <osmocore/linuxlist.h>
 #include <osmocore/talloc.h>
 
+#include <sccp/sccp.h>
+
 #include <netinet/in.h>
 #include <arpa/inet.h>
 
@@ -72,6 +74,15 @@
 	return conf;
 }
 
+void sccp_connection_destroy(struct sccp_connections *conn)
+{
+	LOGP(DNAT, LOGL_DEBUG, "Destroy 0x%x <-> 0x%x mapping for con %p\n",
+	     sccp_src_ref_to_int(&conn->real_ref),
+	     sccp_src_ref_to_int(&conn->patched_ref), conn->bsc);
+	llist_del(&conn->list_entry);
+	talloc_free(conn);
+}
+
 struct bsc_connection *bsc_nat_find_bsc(struct bsc_nat *nat, struct msgb *msg)
 {
 	struct bsc_connection *bsc;
diff --git a/openbsc/src/nat/bsc_sccp.c b/openbsc/src/nat/bsc_sccp.c
index 5f0809d..40676b3 100644
--- a/openbsc/src/nat/bsc_sccp.c
+++ b/openbsc/src/nat/bsc_sccp.c
@@ -135,11 +135,7 @@
 			if (bsc != conn->bsc)
 				continue;
 
-			LOGP(DNAT, LOGL_DEBUG, "Destroy 0x%x <-> 0x%x mapping for con %p\n",
-				sccp_src_ref_to_int(&conn->real_ref),
-				sccp_src_ref_to_int(&conn->patched_ref), bsc);
-			llist_del(&conn->list_entry);
-			talloc_free(conn);
+			sccp_connection_destroy(conn);
 			return;
 		}
 	}