Show OML link uptime in vty

Save the time when OML link to BTS was established and show it in
vty. That's useful when troubleshooting issues like periodic/sporadic
BTS restart.

Related: SYS#3889
Change-Id: I9e4e8504afe8ca467b68d41826f61654e24d9600
diff --git a/src/libbsc/e1_config.c b/src/libbsc/e1_config.c
index 1923efd..3656315 100644
--- a/src/libbsc/e1_config.c
+++ b/src/libbsc/e1_config.c
@@ -20,7 +20,7 @@
 
 #include <string.h>
 #include <errno.h>
-
+#include <time.h>
 #include <netinet/in.h>
 
 #include <osmocom/bsc/gsm_data.h>
@@ -160,6 +160,8 @@
 	struct e1inp_line *line;
 	struct e1inp_sign_link *oml_link;
 	struct gsm_bts_trx *trx;
+	struct timespec tp;
+	int rc;
 
 	DEBUGP(DLMI, "e1_reconfig_bts(%u)\n", bts->nr);
 
@@ -201,6 +203,8 @@
 	if (bts->oml_link)
 		e1inp_sign_link_destroy(bts->oml_link);
 	bts->oml_link = oml_link;
+	rc = clock_gettime(CLOCK_MONOTONIC, &tp);
+	bts->uptime = (rc < 0) ? 0 : tp.tv_sec; /* we don't need sub-second precision for uptime */
 
 	llist_for_each_entry(trx, &bts->trx_list, list)
 		e1_reconfig_trx(trx);