From 9c9ef7796aa6848529a7f2c06928f5efc46b07ed Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Wed, 12 May 2010 00:33:38 +0800 Subject: nat: Store the creation time of a sccp connection. Generate it when creating the connection but also when reusing an existing connection. --- openbsc/include/openbsc/bsc_nat.h | 3 +++ openbsc/src/Makefile.am | 2 +- openbsc/src/nat/bsc_sccp.c | 3 +++ openbsc/tests/bsc-nat/Makefile.am | 2 +- 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 #include +#include 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 -- cgit v1.2.3