aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-05-12 00:33:38 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-05-12 00:33:38 +0800
commit9c9ef7796aa6848529a7f2c06928f5efc46b07ed (patch)
tree2aa67d31c23a1319e3fd1ef9ca4b70fa9faab1cf
parent49fcc8fc90e3a3608a44b77b2619bb275a4d559b (diff)
nat: Store the creation time of a sccp connection.
Generate it when creating the connection but also when reusing an existing connection.
-rw-r--r--openbsc/include/openbsc/bsc_nat.h3
-rw-r--r--openbsc/src/Makefile.am2
-rw-r--r--openbsc/src/nat/bsc_sccp.c3
-rw-r--r--openbsc/tests/bsc-nat/Makefile.am2
4 files changed, 8 insertions, 2 deletions
diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h
index 4be7e3a67..61df38930 100644
--- a/openbsc/include/openbsc/bsc_nat.h
+++ b/openbsc/include/openbsc/bsc_nat.h
@@ -120,6 +120,9 @@ struct sccp_connections {
int crcx;
int msc_timeslot;
int bsc_timeslot;
+
+ /* timeout handling */
+ struct timespec creation_time;
};
/**
diff --git a/openbsc/src/Makefile.am b/openbsc/src/Makefile.am
index 79db36426..44b0027ec 100644
--- a/openbsc/src/Makefile.am
+++ b/openbsc/src/Makefile.am
@@ -56,4 +56,4 @@ bsc_nat_SOURCES = nat/bsc_nat.c nat/bsc_filter.c nat/bsc_sccp.c \
nat/bsc_nat_utils.c nat/bsc_nat_vty.c nat/bsc_mgcp_utils.c \
mgcp/mgcp_protocol.c mgcp/mgcp_network.c mgcp/mgcp_vty.c \
bsc_msc.c bssap.c
-bsc_nat_LDADD = libvty.a libbsc.a libsccp.a
+bsc_nat_LDADD = libvty.a libbsc.a libsccp.a -lrt
diff --git a/openbsc/src/nat/bsc_sccp.c b/openbsc/src/nat/bsc_sccp.c
index ebe108604..f9ddd64fb 100644
--- a/openbsc/src/nat/bsc_sccp.c
+++ b/openbsc/src/nat/bsc_sccp.c
@@ -28,6 +28,7 @@
#include <osmocore/talloc.h>
#include <string.h>
+#include <time.h>
static int equal(struct sccp_source_reference *ref1, struct sccp_source_reference *ref2)
{
@@ -101,6 +102,7 @@ int create_sccp_src_ref(struct bsc_connection *bsc, struct msgb *msg, struct bsc
talloc_free(conn);
return -1;
} else {
+ clock_gettime(CLOCK_MONOTONIC, &conn->creation_time);
bsc_mgcp_dlcx(conn);
return 0;
}
@@ -114,6 +116,7 @@ int create_sccp_src_ref(struct bsc_connection *bsc, struct msgb *msg, struct bsc
}
conn->bsc = bsc;
+ clock_gettime(CLOCK_MONOTONIC, &conn->creation_time);
conn->real_ref = *parsed->src_local_ref;
if (assign_src_local_reference(&conn->patched_ref, bsc->nat) != 0) {
LOGP(DNAT, LOGL_ERROR, "Failed to assign a ref.\n");
diff --git a/openbsc/tests/bsc-nat/Makefile.am b/openbsc/tests/bsc-nat/Makefile.am
index 5a066a491..091c8fec7 100644
--- a/openbsc/tests/bsc-nat/Makefile.am
+++ b/openbsc/tests/bsc-nat/Makefile.am
@@ -13,5 +13,5 @@ bsc_nat_test_SOURCES = bsc_nat_test.c \
$(top_srcdir)/src/mgcp/mgcp_protocol.c \
$(top_srcdir)/src/mgcp/mgcp_network.c \
$(top_srcdir)/src/bssap.c
-bsc_nat_test_LDADD = $(top_builddir)/src/libbsc.a $(top_builddir)/src/libsccp.a $(LIBOSMOCORE_LIBS)
+bsc_nat_test_LDADD = $(top_builddir)/src/libbsc.a $(top_builddir)/src/libsccp.a $(LIBOSMOCORE_LIBS) -lrt