blob: 1a055468a75c5c7901eb1bf77270ee75ebf9852d [file] [log] [blame]
Holger Hans Peter Freyther58db60c2013-11-13 20:45:40 +01001/*
2 * Copyright (C) 2013 by Holger Hans Peter Freyther
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19#include "tbf.h"
20
21extern "C" {
22#include <osmocom/core/utils.h>
23}
24
25
26uint8_t *gprs_rlc_data::prepare(size_t block_data_len)
27{
28 /* todo.. only set it once if it turns out to be a bottleneck */
29 memset(block, 0x0, ARRAY_SIZE(block));
30 memset(block, 0x2b, block_data_len);
31
32 return block;
33}
Holger Hans Peter Freyther321f3c32013-11-23 16:06:54 +010034
35void gprs_rlc_v_b::reset()
36{
37 for (size_t i = 0; i < ARRAY_SIZE(m_v_b); ++i)
38 mark_invalid(i);
39}
Holger Hans Peter Freyther15777792013-11-24 00:18:47 +010040
41int gprs_rlc_v_b::resend_needed(const uint16_t v_a, const uint16_t v_s,
42 const uint16_t mod_sns,
43 const uint16_t mod_sns_half)
44{
45 for (uint8_t bsn = v_a; bsn != v_s; bsn = (bsn + 1) & mod_sns) {
46 uint16_t index = bsn & mod_sns_half;
47 if (is_nacked(index) || is_resend(index))
48 return bsn;
49 }
50
51 return -1;
52}