aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-06-08 13:56:45 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-06-08 13:57:19 +0200
commitad53ffaf6a9033e45cab76ce4a5bc8e2f625af25 (patch)
tree7577d450b7f0be3070be1f1ad8a4bd260d5beb5f
parentbbe51c5ce25583a66b57ab7df0b2af3e197668bc (diff)
tbf: Remove copy and paste between several call siteshfreyther/remove-ts-trx-params
-rw-r--r--src/bts.cpp14
-rw-r--r--src/tbf.cpp32
-rw-r--r--src/tbf.h4
3 files changed, 25 insertions, 25 deletions
diff --git a/src/bts.cpp b/src/bts.cpp
index d7a3317..ba0bf99 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -414,19 +414,9 @@ bool BTS::rcv_rach_sba(uint8_t ra, uint32_t Fn, int16_t qta, bitvec *immediate_a
bool BTS::rcv_rach_tbf(uint8_t ra, uint32_t Fn, int16_t qta, bitvec *immediate_assignment, uint8_t *plen)
{
struct gprs_rlcmac_tbf *tbf;
- uint8_t trx_no;
- int8_t tfi; /* must be signed */
- // Create new TBF
- #warning "Copy and pate with other routines.."
- tfi = tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1);
- if (tfi < 0) {
- LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH resource\n");
- /* FIXME: send reject */
- return false;
- }
- /* set class to 0, since we don't know the multislot class yet */
- tbf = tbf_alloc(&m_bts, NULL, GPRS_RLCMAC_UL_TBF, tfi, trx_no, 0, 1);
+ // Create new TBF with unknown ms class
+ tbf = gprs_rlcmac_tbf::allocate(this, NULL, GPRS_RLCMAC_UL_TBF, -1, 0, 1);
if (!tbf) {
LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH resource\n");
/* FIXME: send reject */
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 5979751..758e7f6 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -2,7 +2,7 @@
*
* Copyright (C) 2012 Ivan Klyuchnikov
* Copyright (C) 2012 Andreas Eversberg <jolly@eversberg.eu>
- * Copyright (C) 2013 by Holger Hans Peter Freyther
+ * Copyright (C) 2013-2014 by Holger Hans Peter Freyther
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -121,10 +121,9 @@ static int tbf_new_dl_assignment(struct gprs_rlcmac_bts *bts,
const uint32_t tlli, const uint8_t ms_class,
const uint8_t *data, const uint16_t len)
{
- uint8_t trx, ta, ss;
+ uint8_t ta, ss;
int8_t use_trx;
struct gprs_rlcmac_tbf *old_tbf, *tbf;
- int8_t tfi; /* must be signed */
int rc;
/* check for uplink data, so we copy our informations */
@@ -157,15 +156,8 @@ static int tbf_new_dl_assignment(struct gprs_rlcmac_bts *bts,
}
// Create new TBF (any TRX)
-#warning "Copy and paste with alloc_ul_tbf"
- tfi = bts->bts->tfi_find_free(GPRS_RLCMAC_DL_TBF, &trx, use_trx);
- if (tfi < 0) {
- LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH resource\n");
- /* FIXME: send reject */
- return -EBUSY;
- }
- /* set number of downlink slots according to multislot class */
- tbf = tbf_alloc(bts, tbf, GPRS_RLCMAC_DL_TBF, tfi, trx, ms_class, ss);
+ tbf = gprs_rlcmac_tbf::allocate(bts->bts, tbf, GPRS_RLCMAC_DL_TBF,
+ use_trx, ms_class, ss);
if (!tbf) {
LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH resource\n");
/* FIXME: send reject */
@@ -1794,3 +1786,19 @@ void tbf_print_vty_info(struct vty *vty, llist_head *ltbf)
}
vty_out(vty, " CS=%d%s%s", tbf->cs, VTY_NEWLINE, VTY_NEWLINE);
}
+
+gprs_rlcmac_tbf *gprs_rlcmac_tbf::allocate(BTS *bts, gprs_rlcmac_tbf *old_tbf,
+ enum gprs_rlcmac_tbf_direction dir, int use_trx,
+ int ms_class, int single_slot)
+{
+ uint8_t trx_no;
+ int8_t tfi;
+
+ tfi = bts->tfi_find_free(dir, &trx_no, use_trx);
+ if (tfi < 0) {
+ LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH resource\n");
+ return 0;
+ }
+
+ return tbf_alloc(bts->bts_data(), old_tbf, dir, tfi, trx_no, ms_class, single_slot);
+}
diff --git a/src/tbf.h b/src/tbf.h
index f0c819a..819607d 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 by Holger Hans Peter Freyther
+ * Copyright (C) 2013-2014 by Holger Hans Peter Freyther
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -89,6 +89,8 @@ struct gprs_rlcmac_tbf {
static void free_all(struct gprs_rlcmac_trx *trx);
static void free_all(struct gprs_rlcmac_pdch *pdch);
+ static gprs_rlcmac_tbf *allocate(BTS *bts, gprs_rlcmac_tbf *tbf, enum gprs_rlcmac_tbf_direction, int use_trx, int ms_class, int single_slot);
+
bool state_is(enum gprs_rlcmac_tbf_state rhs) const;
bool state_is_not(enum gprs_rlcmac_tbf_state rhs) const;
void set_state(enum gprs_rlcmac_tbf_state new_state);