summaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2010-05-03 20:16:13 +0200
committerHarald Welte <laforge@gnumonks.org>2010-05-04 07:20:45 +0200
commit80405458a0c325e11e55133065df9b767bb0edc4 (patch)
tree0a293cc4c6a79b817d167b87ec3d81b63e35696c /openbsc
parentbbc9fac7b731dee4c3e60c5b6a9aadf0a3141dcf (diff)
[gprs] NS: replace nsvc->timer_is_tns_alive with nsvc->timer_mode
This will allow to use the timer in more than 2 modes
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/include/openbsc/gprs_ns.h12
-rw-r--r--openbsc/src/gprs_ns.c25
2 files changed, 24 insertions, 13 deletions
diff --git a/openbsc/include/openbsc/gprs_ns.h b/openbsc/include/openbsc/gprs_ns.h
index 573536d1..40784049 100644
--- a/openbsc/include/openbsc/gprs_ns.h
+++ b/openbsc/include/openbsc/gprs_ns.h
@@ -118,6 +118,14 @@ struct gprs_ns_inst {
};
};
+enum nsvc_timer_mode {
+ /* standard timers */
+ NSVC_TIMER_TNS_TEST,
+ NSVC_TIMER_TNS_ALIVE,
+ /* custom timer */
+ NSVC_TIMER_RESET,
+};
+
struct gprs_nsvc {
struct llist_head list;
struct gprs_ns_inst *nsi;
@@ -128,8 +136,8 @@ struct gprs_nsvc {
uint32_t state;
uint32_t remote_state;
- struct timer_list alive_timer;
- int timer_is_tns_alive;
+ struct timer_list timer;
+ enum nsvc_timer_mode timer_mode;
int alive_retries;
int remote_end_is_sgsn;
diff --git a/openbsc/src/gprs_ns.c b/openbsc/src/gprs_ns.c
index 619a8290..9c198ad9 100644
--- a/openbsc/src/gprs_ns.c
+++ b/openbsc/src/gprs_ns.c
@@ -182,11 +182,12 @@ static int gprs_ns_tx_simple(struct gprs_nsvc *nsvc, uint8_t pdu_type)
#define NS_TIMER_TEST 30, 0 /* every 10 seconds we check if the BTS is still alive */
#define NS_ALIVE_RETRIES 10 /* after 3 failed retransmit we declare BTS as dead */
-static void gprs_ns_alive_cb(void *data)
+static void gprs_ns_timer_cb(void *data)
{
struct gprs_nsvc *nsvc = data;
- if (nsvc->timer_is_tns_alive) {
+ switch (nsvc->timer_mode) {
+ case NSVC_TIMER_TNS_ALIVE:
/* Tns-alive case: we expired without response ! */
nsvc->alive_retries++;
if (nsvc->alive_retries > NS_ALIVE_RETRIES) {
@@ -197,13 +198,15 @@ static void gprs_ns_alive_cb(void *data)
/* FIXME: inform higher layers */
return;
}
- } else {
+ break;
+ case NSVC_TIMER_TNS_TEST:
/* Tns-test case: send NS-ALIVE PDU */
gprs_ns_tx_simple(nsvc, NS_PDUT_ALIVE);
/* start Tns-alive timer */
- nsvc->timer_is_tns_alive = 1;
+ nsvc->timer_mode = NSVC_TIMER_TNS_ALIVE;
+ break;
}
- bsc_schedule_timer(&nsvc->alive_timer, NS_TIMER_ALIVE);
+ bsc_schedule_timer(&nsvc->timer, NS_TIMER_ALIVE);
}
/* Section 9.2.6 */
@@ -330,9 +333,9 @@ static int gprs_ns_rx_reset(struct gprs_nsvc *nsvc, struct msgb *msg)
/* mark the NS-VC as blocked and alive */
/* start the test procedure */
- nsvc->alive_timer.cb = gprs_ns_alive_cb;
- nsvc->alive_timer.data = nsvc;
- bsc_schedule_timer(&nsvc->alive_timer, NS_TIMER_ALIVE);
+ nsvc->timer.cb = gprs_ns_timer_cb;
+ nsvc->timer.data = nsvc;
+ bsc_schedule_timer(&nsvc->timer, NS_TIMER_ALIVE);
return gprs_ns_tx_reset_ack(nsvc);
}
@@ -370,10 +373,10 @@ int gprs_ns_rcvmsg(struct gprs_ns_inst *nsi, struct msgb *msg,
break;
case NS_PDUT_ALIVE_ACK:
/* stop Tns-alive */
- bsc_del_timer(&nsvc->alive_timer);
+ bsc_del_timer(&nsvc->timer);
/* start Tns-test */
- nsvc->timer_is_tns_alive = 0;
- bsc_schedule_timer(&nsvc->alive_timer, NS_TIMER_TEST);
+ nsvc->timer_mode = NSVC_TIMER_TNS_TEST;
+ bsc_schedule_timer(&nsvc->timer, NS_TIMER_TEST);
break;
case NS_PDUT_UNITDATA:
/* actual user data */