summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--debian/changelog6
-rw-r--r--debian/control4
-rw-r--r--openbsc/include/openbsc/gprs_llc.h5
-rw-r--r--openbsc/include/openbsc/gprs_sgsn.h18
-rw-r--r--openbsc/include/openbsc/gprs_utils.h5
-rw-r--r--openbsc/include/openbsc/gsm_04_08_gprs.h5
-rw-r--r--openbsc/include/openbsc/sgsn.h2
-rw-r--r--openbsc/src/gprs/Makefile.am2
-rw-r--r--openbsc/src/gprs/gb_proxy_main.c32
-rw-r--r--openbsc/src/gprs/gprs_gmm.c10
-rw-r--r--openbsc/src/gprs/gprs_gsup_client.c8
-rw-r--r--openbsc/src/gprs/gprs_llc.c33
-rw-r--r--openbsc/src/gprs/gprs_llc_vty.c7
-rw-r--r--openbsc/src/gprs/gprs_sgsn.c64
-rw-r--r--openbsc/src/gprs/gprs_subscriber.c14
-rw-r--r--openbsc/src/gprs/gprs_utils.c31
-rw-r--r--openbsc/src/gprs/sgsn_main.c63
-rw-r--r--openbsc/tests/sgsn/Makefile.am2
-rw-r--r--openbsc/tests/sgsn/sgsn_test.c6
19 files changed, 210 insertions, 107 deletions
diff --git a/debian/changelog b/debian/changelog
index bd2c2b61b..03980ee83 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+openbsc (0.13.2+j1) UNRELEASED; urgency=low
+
+ * Reworked SGSN
+
+ -- Jacob Erlbeck <jerlbeck@sysmocom.de> Mon, 19 Jan 2015 18:23:18 +0100
+
openbsc (0.13.0) UNRELEASED; urgency=low
* New upstream tag and additional patches.
diff --git a/debian/control b/debian/control
index a44187d52..1468036ce 100644
--- a/debian/control
+++ b/debian/control
@@ -2,7 +2,7 @@ Source: openbsc
Section: net
Priority: optional
Maintainer: Harald Welte <laforge@gnumonks.org>
-Build-Depends: debhelper (>= 7.0.0~), autotools-dev, pkg-config, libgtp-dev, libosmocore-dev, libosmo-sccp-dev, libdbi0-dev, dh-autoreconf, libosmo-abis-dev, libdbd-sqlite3
+Build-Depends: debhelper (>= 7.0.0~), autotools-dev, pkg-config, libgtp0-dev, libosmocore-dev, libosmo-sccp-dev, libdbi0-dev, dh-autoreconf, libosmo-abis-dev, libosmo-netif-dev, libdbd-sqlite3
Standards-Version: 3.8.4
Homepage: http://openbsc.osmocom.org/
Vcs-Git: git://bs11-abis.gnumonks.org/openbsc.git
@@ -34,7 +34,7 @@ Description: Command line utilities for Siemens BS-11 BTS
Package: osmocom-sgsn
Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, libosmocore, libgtp
+Depends: ${shlibs:Depends}, ${misc:Depends}, libosmocore, libgtp0
Description: Osmocom Serving GPRS Support Node
SGSN implementation.
diff --git a/openbsc/include/openbsc/gprs_llc.h b/openbsc/include/openbsc/gprs_llc.h
index fc6216ccc..d54b72e4a 100644
--- a/openbsc/include/openbsc/gprs_llc.h
+++ b/openbsc/include/openbsc/gprs_llc.h
@@ -161,8 +161,13 @@ struct gprs_llc_llme {
uint16_t bvci;
uint16_t nsei;
struct gprs_llc_lle lle[NUM_SAPIS];
+
+ /* Internal management */
+ uint32_t age_timestamp;
};
+#define GPRS_LLME_RESET_AGE (0)
+
extern struct llist_head gprs_llc_llmes;
/* LLC low level types */
diff --git a/openbsc/include/openbsc/gprs_sgsn.h b/openbsc/include/openbsc/gprs_sgsn.h
index 00cf5ccef..ef9e84474 100644
--- a/openbsc/include/openbsc/gprs_sgsn.h
+++ b/openbsc/include/openbsc/gprs_sgsn.h
@@ -246,6 +246,7 @@ extern struct llist_head sgsn_apn_ctxts;
extern struct llist_head sgsn_pdp_ctxts;
uint32_t sgsn_alloc_ptmsi(void);
+void sgsn_inst_init(void);
/* High-level function to be called in case a GGSN has disappeared or
* ottherwise lost state (recovery procedure) */
@@ -271,6 +272,22 @@ struct imsi_acl_entry {
char imsi[16+1];
};
+/* see GSM 09.02, 17.7.1, PDP-Context and GPRSSubscriptionData */
+/* see GSM 09.02, B.1, gprsSubscriptionData */
+struct sgsn_subscriber_pdp_data {
+ struct llist_head list;
+
+ /* raw binary data */
+ int pdp_context_id;
+ uint8_t pdp_type[2];
+ uint8_t pdp_address[16];
+ size_t pdp_address_size; /* 0: not present */
+ uint8_t qos_subscribed[3];
+ int vplmn_address_allowed;
+ uint8_t apn[63];
+ size_t apn_size;
+};
+
enum sgsn_subscriber_proc {
SGSN_SUBSCR_PROC_NONE = 0,
SGSN_SUBSCR_PROC_PURGE,
@@ -282,6 +299,7 @@ struct sgsn_subscriber_data {
struct sgsn_mm_ctx *mm;
struct gsm_auth_tuple auth_triplets[5];
int auth_triplets_updated;
+ struct llist_head pdp_list;
int error_cause;
struct osmo_timer_list timer;
int retries;
diff --git a/openbsc/include/openbsc/gprs_utils.h b/openbsc/include/openbsc/gprs_utils.h
index 60b55a178..6880e0587 100644
--- a/openbsc/include/openbsc/gprs_utils.h
+++ b/openbsc/include/openbsc/gprs_utils.h
@@ -31,6 +31,11 @@ int gprs_msgb_resize_area(struct msgb *msg, uint8_t *area,
size_t old_size, size_t new_size);
char *gprs_apn_to_str(char *out_str, const uint8_t *apn_enc, size_t rest_chars);
int gprs_str_to_apn(uint8_t *apn_enc, size_t max_len, const char *str);
+
+/* GSM 04.08, 10.5.7.3 GPRS Timer */
+int gprs_tmr_to_secs(uint8_t tmr);
+uint8_t gprs_secs_to_tmr_floor(int secs);
+
int gprs_is_mi_tmsi(const uint8_t *value, size_t value_len);
int gprs_is_mi_imsi(const uint8_t *value, size_t value_len);
int gprs_parse_mi_tmsi(const uint8_t *value, size_t value_len, uint32_t *tmsi);
diff --git a/openbsc/include/openbsc/gsm_04_08_gprs.h b/openbsc/include/openbsc/gsm_04_08_gprs.h
index fb30dff96..3eec98365 100644
--- a/openbsc/include/openbsc/gsm_04_08_gprs.h
+++ b/openbsc/include/openbsc/gsm_04_08_gprs.h
@@ -116,9 +116,12 @@ enum gsm48_gprs_tmr_unit {
GPRS_TMR_2SECONDS = 0 << 5,
GPRS_TMR_MINUTE = 1 << 5,
GPRS_TMR_6MINUTE = 2 << 5,
- GPRS_TMR_DEACTIVATED = 3 << 5,
+ GPRS_TMR_DEACTIVATED = 7 << 5,
};
+#define GPRS_TMR_UNIT_MASK (7 << 5)
+#define GPRS_TMR_FACT_MASK ((1 << 5)-1)
+
/* Chapter 9.4.2 / Table 9.4.2 */
struct gsm48_attach_ack {
uint8_t att_result:4, /* 10.5.5.7 */
diff --git a/openbsc/include/openbsc/sgsn.h b/openbsc/include/openbsc/sgsn.h
index 8a4514627..017bc7fb8 100644
--- a/openbsc/include/openbsc/sgsn.h
+++ b/openbsc/include/openbsc/sgsn.h
@@ -52,6 +52,8 @@ struct sgsn_instance {
struct gsn_t *gsn;
/* Subscriber */
struct gprs_gsup_client *gsup_client;
+ /* LMME inactivity timer */
+ struct osmo_timer_list llme_timer;
};
extern struct sgsn_instance *sgsn;
diff --git a/openbsc/src/gprs/Makefile.am b/openbsc/src/gprs/Makefile.am
index bdbad1921..bc3e21e1b 100644
--- a/openbsc/src/gprs/Makefile.am
+++ b/openbsc/src/gprs/Makefile.am
@@ -27,4 +27,4 @@ osmo_sgsn_SOURCES = gprs_gmm.c gprs_sgsn.c gprs_sndcp.c gprs_sndcp_vty.c \
gsm_04_08_gprs.c
osmo_sgsn_LDADD = \
$(top_builddir)/src/libcommon/libcommon.a \
- -lgtp $(OSMO_LIBS) $(LIBOSMOABIS_LIBS)
+ -lgtp $(OSMO_LIBS) $(LIBOSMOABIS_LIBS) -lrt
diff --git a/openbsc/src/gprs/gb_proxy_main.c b/openbsc/src/gprs/gb_proxy_main.c
index 03299df95..4429eefe8 100644
--- a/openbsc/src/gprs/gb_proxy_main.c
+++ b/openbsc/src/gprs/gb_proxy_main.c
@@ -52,9 +52,6 @@
#include "../../bscconfig.h"
-/* this is here for the vty... it will never be called */
-void subscr_put() { abort(); }
-
#define _GNU_SOURCE
#include <getopt.h>
@@ -201,31 +198,6 @@ static struct vty_app_info vty_info = {
.is_config_node = bsc_vty_is_config_node,
};
-/* default categories */
-static struct log_info_cat gprs_categories[] = {
- [DGPRS] = {
- .name = "DGPRS",
- .description = "GPRS Packet Service",
- .enabled = 1, .loglevel = LOGL_DEBUG,
- },
- [DNS] = {
- .name = "DNS",
- .description = "GPRS Network Service (NS)",
- .enabled = 1, .loglevel = LOGL_INFO,
- },
- [DBSSGP] = {
- .name = "DBSSGP",
- .description = "GPRS BSS Gateway Protocol (BSSGP)",
- .enabled = 1, .loglevel = LOGL_DEBUG,
- },
-};
-
-static const struct log_info gprs_log_info = {
- .filter_fn = gprs_log_filter_fn,
- .cat = gprs_categories,
- .num_cat = ARRAY_SIZE(gprs_categories),
-};
-
int main(int argc, char **argv)
{
struct gsm_network dummy_network;
@@ -240,11 +212,11 @@ int main(int argc, char **argv)
signal(SIGUSR2, &signal_handler);
osmo_init_ignore_signals();
- osmo_init_logging(&gprs_log_info);
+ osmo_init_logging(&log_info);
vty_info.copyright = openbsc_copyright;
vty_init(&vty_info);
- logging_vty_add_cmds(&gprs_log_info);
+ logging_vty_add_cmds(&log_info);
gbproxy_vty_init();
handle_options(argc, argv);
diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c
index 32fb8e49d..5a6aa5b25 100644
--- a/openbsc/src/gprs/gprs_gmm.c
+++ b/openbsc/src/gprs/gprs_gmm.c
@@ -50,6 +50,7 @@
#include <openbsc/gprs_llc.h>
#include <openbsc/gprs_sgsn.h>
#include <openbsc/gprs_gmm.h>
+#include <openbsc/gprs_utils.h>
#include <openbsc/sgsn.h>
#include <pdp.h>
@@ -338,8 +339,12 @@ static int gsm48_tx_gmm_att_ack(struct sgsn_mm_ctx *mm)
ptsig[1] = mm->p_tmsi_sig >> 8;
ptsig[2] = mm->p_tmsi_sig & 0xff;
- /* Optional: Negotiated Ready timer value */
#endif
+ /* Optional: Negotiated Ready timer value
+ * (fixed 44s, default value, GSM 04.08, table 11.4a) to safely limit
+ * the inactivity time READY->STANDBY.
+ */
+ msgb_tv_put(msg, GSM48_IE_GMM_TIMER_READY, gprs_secs_to_tmr_floor(44));
#ifdef PTMSI_ALLOC
/* Optional: Allocated P-TMSI */
@@ -992,6 +997,9 @@ static int gsm48_tx_gmm_ra_upd_ack(struct sgsn_mm_ctx *mm)
mid[0] = GSM48_IE_GMM_ALLOC_PTMSI;
#endif
+ /* Optional: Negotiated READY timer value */
+ msgb_tv_put(msg, GSM48_IE_GMM_TIMER_READY, gprs_secs_to_tmr_floor(44));
+
/* Option: MS ID, ... */
return gsm48_gmm_sendmsg(msg, 0, mm);
}
diff --git a/openbsc/src/gprs/gprs_gsup_client.c b/openbsc/src/gprs/gprs_gsup_client.c
index 523c541b7..bb887a4b8 100644
--- a/openbsc/src/gprs/gprs_gsup_client.c
+++ b/openbsc/src/gprs/gprs_gsup_client.c
@@ -84,13 +84,19 @@ static int gsup_client_connect(struct gprs_gsup_client *gsupc)
osmo_timer_schedule(&gsupc->connect_timer, GPRS_GSUP_RECONNECT_INTERVAL, 0);
- return rc;
+ LOGP(DGPRS, LOGL_INFO, "Scheduled timer to retry GSUP connect to %s:%d\n",
+ gsupc->link->addr, gsupc->link->port);
+
+ return 0;
}
static void connect_timer_cb(void *gsupc_)
{
struct gprs_gsup_client *gsupc = gsupc_;
+ LOGP(DGPRS, LOGL_INFO, "GSUP timer callback (%s)\n",
+ gsupc->is_connected ? "connected" : "not connected");
+
if (gsupc->is_connected)
return;
diff --git a/openbsc/src/gprs/gprs_llc.c b/openbsc/src/gprs/gprs_llc.c
index 0b4613e0f..5cd7ead15 100644
--- a/openbsc/src/gprs/gprs_llc.c
+++ b/openbsc/src/gprs/gprs_llc.c
@@ -65,16 +65,27 @@ static int _bssgp_tx_dl_ud(struct msgb *msg, struct sgsn_mm_ctx *mmctx)
* not yet have a MMC context (e.g. XID negotiation of primarly
* LLC connection fro GMM sapi). */
if (mmctx) {
- dup.imsi = mmctx->imsi;
- dup.drx_parms = mmctx->drx_parms;
- dup.ms_ra_cap.len = mmctx->ms_radio_access_capa.len;
- dup.ms_ra_cap.v = mmctx->ms_radio_access_capa.buf;
-
/* make sure we only send it to the right llme */
- OSMO_ASSERT(msgb_tlli(msg) == mmctx->llme->tlli
- || msgb_tlli(msg) == mmctx->llme->old_tlli
- || tlli_foreign2local(msgb_tlli(msg)) == mmctx->llme->tlli
- || tlli_foreign2local(msgb_tlli(msg)) == mmctx->llme->old_tlli);
+ if (msgb_tlli(msg) != mmctx->llme->tlli &&
+ msgb_tlli(msg) != mmctx->llme->old_tlli &&
+ tlli_foreign2local(msgb_tlli(msg)) != mmctx->llme->tlli &&
+ tlli_foreign2local(msgb_tlli(msg)) != mmctx->llme->old_tlli)
+ {
+ LOGP(DLLC, LOGL_ERROR,
+ "MM context TLLI mismatch when sending DL unitdata, "
+ "msg TLLI = %08x, ctx TLLI = %08x, "
+ "ctx old TLLI = %08x. "
+ "Using default values for IMSI, DRX, RA CAP\n",
+ msgb_tlli(msg),
+ mmctx->llme->tlli,
+ mmctx->llme->old_tlli);
+ osmo_log_backtrace(DLLC, LOGL_INFO);
+ } else {
+ dup.imsi = mmctx->imsi;
+ dup.drx_parms = mmctx->drx_parms;
+ dup.ms_ra_cap.len = mmctx->ms_radio_access_capa.len;
+ dup.ms_ra_cap.v = mmctx->ms_radio_access_capa.buf;
+ }
}
memcpy(&dup.qos_profile, qos_profile_default,
sizeof(qos_profile_default));
@@ -256,6 +267,7 @@ static struct gprs_llc_llme *llme_alloc(uint32_t tlli)
llme->tlli = tlli;
llme->old_tlli = 0xffffffff;
llme->state = GPRS_LLMS_UNASSIGNED;
+ llme->age_timestamp = GPRS_LLME_RESET_AGE;
for (i = 0; i < ARRAY_SIZE(llme->lle); i++)
lle_init(llme, i);
@@ -622,6 +634,9 @@ int gprs_llc_rcvmsg(struct msgb *msg, struct tlv_parsed *tv)
return 0;
}
+ /* reset age computation */
+ lle->llme->age_timestamp = GPRS_LLME_RESET_AGE;
+
/* decrypt information field + FCS, if needed! */
if (llhp.is_encrypted) {
uint32_t iov_ui = 0; /* FIXME: randomly select for TLLI */
diff --git a/openbsc/src/gprs/gprs_llc_vty.c b/openbsc/src/gprs/gprs_llc_vty.c
index ab5269922..f399b2752 100644
--- a/openbsc/src/gprs/gprs_llc_vty.c
+++ b/openbsc/src/gprs/gprs_llc_vty.c
@@ -23,6 +23,7 @@
#include <unistd.h>
#include <errno.h>
#include <stdint.h>
+#include <time.h>
#include <arpa/inet.h>
@@ -69,9 +70,13 @@ static uint8_t valid_sapis[] = { 1, 2, 3, 5, 7, 8, 9, 11 };
static void vty_dump_llme(struct vty *vty, struct gprs_llc_llme *llme)
{
unsigned int i;
+ struct timespec now_tp = {0};
+ clock_gettime(CLOCK_MONOTONIC, &now_tp);
- vty_out(vty, "TLLI %08x (Old TLLI %08x) BVCI=%u NSEI=%u: State %s%s",
+ vty_out(vty, "TLLI %08x (Old TLLI %08x) BVCI=%u NSEI=%u Age=%d: State %s%s",
llme->tlli, llme->old_tlli, llme->bvci, llme->nsei,
+ llme->age_timestamp == GPRS_LLME_RESET_AGE ? 0 :
+ (int)(now_tp.tv_sec - (time_t)llme->age_timestamp),
get_value_string(gprs_llc_state_strs, llme->state), VTY_NEWLINE);
for (i = 0; i < ARRAY_SIZE(valid_sapis); i++) {
diff --git a/openbsc/src/gprs/gprs_sgsn.c b/openbsc/src/gprs/gprs_sgsn.c
index 6f706642d..1427b1afb 100644
--- a/openbsc/src/gprs/gprs_sgsn.c
+++ b/openbsc/src/gprs/gprs_sgsn.c
@@ -37,6 +37,10 @@
#include <openbsc/gprs_gmm.h>
#include "openbsc/gprs_llc.h"
+#include <time.h>
+
+#define GPRS_LLME_CHECK_TICK 30
+
extern struct sgsn_instance *sgsn;
LLIST_HEAD(sgsn_mm_ctxts);
@@ -508,3 +512,63 @@ void sgsn_update_subscriber_data(struct sgsn_mm_ctx *mmctx,
sgsn_auth_update(mmctx);
}
+
+static void sgsn_llme_cleanup_free(struct gprs_llc_llme *llme)
+{
+ struct sgsn_mm_ctx *mmctx = NULL;
+
+ llist_for_each_entry(mmctx, &sgsn_mm_ctxts, list) {
+ if (llme == mmctx->llme) {
+ gsm0408_gprs_access_cancelled(mmctx, SGSN_ERROR_CAUSE_NONE);
+ return;
+ }
+ }
+
+ /* No MM context found */
+ LOGP(DGPRS, LOGL_INFO, "Deleting orphaned LLME, TLLI 0x%08x\n",
+ llme->tlli);
+ gprs_llgmm_assign(llme, llme->tlli, 0xffffffff, GPRS_ALGO_GEA0, NULL);
+}
+
+static void sgsn_llme_check_cb(void *data_)
+{
+ struct gprs_llc_llme *llme, *llme_tmp;
+ struct timespec now_tp;
+ time_t now, age;
+
+ int rc;
+
+ rc = clock_gettime(CLOCK_MONOTONIC, &now_tp);
+ OSMO_ASSERT(rc >= 0);
+ now = now_tp.tv_sec;
+
+ LOGP(DGPRS, LOGL_DEBUG,
+ "Checking for inactive LLMEs, time = %u\n", (unsigned)now);
+
+ llist_for_each_entry_safe(llme, llme_tmp, &gprs_llc_llmes, list) {
+ if (llme->age_timestamp == GPRS_LLME_RESET_AGE)
+ llme->age_timestamp = now;
+
+ age = now - llme->age_timestamp;
+
+ /* TODO: derive time from setting / mmctx.
+ * Currently hard-coded to 10min + 4min + 44s */
+ if (age > 16 * 60 || age < 0) {
+ LOGP(DGPRS, LOGL_INFO,
+ "Inactivity timeout for TLLI 0x%08x, age %d\n",
+ llme->tlli, (int)age);
+ sgsn_llme_cleanup_free(llme);
+ }
+ }
+
+ osmo_timer_schedule(&sgsn->llme_timer, GPRS_LLME_CHECK_TICK, 0);
+}
+
+void sgsn_inst_init()
+{
+ sgsn->llme_timer.cb = sgsn_llme_check_cb;
+ sgsn->llme_timer.data = NULL;
+
+ osmo_timer_schedule(&sgsn->llme_timer, GPRS_LLME_CHECK_TICK, 0);
+}
+
diff --git a/openbsc/src/gprs/gprs_subscriber.c b/openbsc/src/gprs/gprs_subscriber.c
index 5bde6a090..25785d451 100644
--- a/openbsc/src/gprs/gprs_subscriber.c
+++ b/openbsc/src/gprs/gprs_subscriber.c
@@ -172,9 +172,23 @@ static struct sgsn_subscriber_data *sgsn_subscriber_data_alloc(void *ctx)
for (idx = 0; idx < ARRAY_SIZE(sdata->auth_triplets); idx++)
sdata->auth_triplets[idx].key_seq = GSM_KEY_SEQ_INVAL;
+ INIT_LLIST_HEAD(&sdata->pdp_list);
+
return sdata;
}
+struct sgsn_subscriber_pdp_data* sgsn_subscriber_pdp_data_alloc(
+ struct sgsn_subscriber_data *sdata)
+{
+ struct sgsn_subscriber_pdp_data* pdata;
+
+ pdata = talloc_zero(sdata, struct sgsn_subscriber_pdp_data);
+
+ llist_add(&sdata->pdp_list, &pdata->list);
+
+ return pdata;
+}
+
struct gsm_subscriber *gprs_subscr_get_or_create(const char *imsi)
{
struct gsm_subscriber *subscr;
diff --git a/openbsc/src/gprs/gprs_utils.c b/openbsc/src/gprs/gprs_utils.c
index 55bc629e8..17059c84b 100644
--- a/openbsc/src/gprs/gprs_utils.c
+++ b/openbsc/src/gprs/gprs_utils.c
@@ -20,6 +20,7 @@
*
*/
#include <openbsc/gprs_utils.h>
+#include <openbsc/gsm_04_08_gprs.h>
#include <osmocom/core/msgb.h>
#include <osmocom/gprs/gprs_ns.h>
@@ -172,6 +173,36 @@ int gprs_str_to_apn(uint8_t *apn_enc, size_t max_len, const char *str)
return len;
}
+/* GSM 04.08, 10.5.7.3 GPRS Timer */
+int gprs_tmr_to_secs(uint8_t tmr)
+{
+ switch (tmr & GPRS_TMR_UNIT_MASK) {
+ case GPRS_TMR_2SECONDS:
+ return 2 * (tmr & GPRS_TMR_FACT_MASK);
+ default:
+ case GPRS_TMR_MINUTE:
+ return 60 * (tmr & GPRS_TMR_FACT_MASK);
+ case GPRS_TMR_6MINUTE:
+ return 600 * (tmr & GPRS_TMR_FACT_MASK);
+ case GPRS_TMR_DEACTIVATED:
+ return -1;
+ }
+}
+
+uint8_t gprs_secs_to_tmr_floor(int secs)
+{
+ if (secs < 0)
+ return GPRS_TMR_DEACTIVATED;
+ if (secs < 2 * 32)
+ return GPRS_TMR_2SECONDS | (secs / 2);
+ if (secs < 60 * 32)
+ return GPRS_TMR_MINUTE | (secs / 60);
+ if (secs < 600 * 32)
+ return GPRS_TMR_6MINUTE | (secs / 600);
+
+ return GPRS_TMR_6MINUTE | 31;
+}
+
/* GSM 04.08, 10.5.1.4 */
int gprs_is_mi_tmsi(const uint8_t *value, size_t value_len)
{
diff --git a/openbsc/src/gprs/sgsn_main.c b/openbsc/src/gprs/sgsn_main.c
index f26b812a8..5e9fee7f5 100644
--- a/openbsc/src/gprs/sgsn_main.c
+++ b/openbsc/src/gprs/sgsn_main.c
@@ -228,64 +228,6 @@ static void handle_options(int argc, char **argv)
}
}
-/* default categories */
-static struct log_info_cat gprs_categories[] = {
- [DMM] = {
- .name = "DMM",
- .description = "Layer3 Mobility Management (MM)",
- .color = "\033[1;33m",
- .enabled = 1, .loglevel = LOGL_NOTICE,
- },
- [DPAG] = {
- .name = "DPAG",
- .description = "Paging Subsystem",
- .color = "\033[1;38m",
- .enabled = 1, .loglevel = LOGL_NOTICE,
- },
- [DMEAS] = {
- .name = "DMEAS",
- .description = "Radio Measurement Processing",
- .enabled = 0, .loglevel = LOGL_NOTICE,
- },
- [DREF] = {
- .name = "DREF",
- .description = "Reference Counting",
- .enabled = 0, .loglevel = LOGL_NOTICE,
- },
- [DGPRS] = {
- .name = "DGPRS",
- .description = "GPRS Packet Service",
- .enabled = 1, .loglevel = LOGL_DEBUG,
- },
- [DNS] = {
- .name = "DNS",
- .description = "GPRS Network Service (NS)",
- .enabled = 1, .loglevel = LOGL_INFO,
- },
- [DBSSGP] = {
- .name = "DBSSGP",
- .description = "GPRS BSS Gateway Protocol (BSSGP)",
- .enabled = 1, .loglevel = LOGL_DEBUG,
- },
- [DLLC] = {
- .name = "DLLC",
- .description = "GPRS Logical Link Control Protocol (LLC)",
- .enabled = 1, .loglevel = LOGL_DEBUG,
- },
- [DSNDCP] = {
- .name = "DSNDCP",
- .description = "GPRS Sub-Network Dependent Control Protocol (SNDCP)",
- .enabled = 1, .loglevel = LOGL_DEBUG,
- },
-};
-
-static const struct log_info gprs_log_info = {
- .filter_fn = gprs_log_filter_fn,
- .cat = gprs_categories,
- .num_cat = ARRAY_SIZE(gprs_categories),
-};
-
-
int main(int argc, char **argv)
{
struct ctrl_handle *ctrl;
@@ -301,11 +243,11 @@ int main(int argc, char **argv)
signal(SIGUSR2, &signal_handler);
osmo_init_ignore_signals();
- osmo_init_logging(&gprs_log_info);
+ osmo_init_logging(&log_info);
vty_info.copyright = openbsc_copyright;
vty_init(&vty_info);
- logging_vty_add_cmds(&gprs_log_info);
+ logging_vty_add_cmds(&log_info);
sgsn_vty_init();
handle_options(argc, argv);
@@ -337,6 +279,7 @@ int main(int argc, char **argv)
bssgp_nsi = sgsn_inst.cfg.nsi = sgsn_nsi;
gprs_llc_init("/usr/local/lib/osmocom/crypt/");
+ sgsn_inst_init();
gprs_ns_vty_init(bssgp_nsi);
bssgp_vty_init();
diff --git a/openbsc/tests/sgsn/Makefile.am b/openbsc/tests/sgsn/Makefile.am
index c1b5fbda4..693cf792a 100644
--- a/openbsc/tests/sgsn/Makefile.am
+++ b/openbsc/tests/sgsn/Makefile.am
@@ -32,5 +32,5 @@ sgsn_test_LDADD = \
$(LIBOSMOCORE_LIBS) \
$(LIBOSMOGSM_LIBS) \
$(LIBOSMOGB_LIBS) \
- -lgtp
+ -lgtp -lrt
diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c
index 1ae94b0dd..1f0046047 100644
--- a/openbsc/tests/sgsn/sgsn_test.c
+++ b/openbsc/tests/sgsn/sgsn_test.c
@@ -19,6 +19,12 @@
*
*/
+/* TODO:
+ * - add test cases for Detach(reattach)
+ * - add test cases for PDP context deletion
+ * - add test cases for Cancel pending timer in sgsn_mm_ctx_free
+ */
+
#include <openbsc/gprs_llc.h>
#include <openbsc/sgsn.h>
#include <openbsc/gprs_gmm.h>