diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2013-10-26 17:32:04 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2013-10-30 21:24:11 +0100 |
commit | d11290b90bb5f32a7d57affbe11bdadb24e42db0 (patch) | |
tree | aad9260528d069fab731ec88b59c49b96e15913d /src/decoding.cpp | |
parent | 6f9f434463d6ba0d195f0b36cd67b57e24b1c7e9 (diff) |
pdch/tbf: Move gprs_rlcmac_rcv_data_block_acknowledged into the pdch
Move the method into the PDCH. Extract the finding of TLLI into a
new class called Decoding. Move the assemble and forward LLC frames
into the TBF as it is poking in the internals of the TBF.
Diffstat (limited to 'src/decoding.cpp')
-rw-r--r-- | src/decoding.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/decoding.cpp b/src/decoding.cpp new file mode 100644 index 00000000..596b66eb --- /dev/null +++ b/src/decoding.cpp @@ -0,0 +1,70 @@ +/* decoding + * + * Copyright (C) 2012 Ivan Klyuchnikov + * Copyright (C) 2012 Andreas Eversberg <jolly@eversberg.eu> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include <decoding.h> +#include <rlc.h> +#include <gprs_debug.h> + +#include <arpa/inet.h> + +#include <errno.h> +#include <string.h> + + +int Decoding::tlli_from_ul_data(const uint8_t *data, uint8_t len, + uint32_t *tlli) +{ + struct rlc_ul_header *rh = (struct rlc_ul_header *)data; + struct rlc_li_field *li; + uint8_t e; + uint32_t _tlli; + + if (!rh->ti) + return -EINVAL; + + data += 3; + len -= 3; + e = rh->e; + /* if E is not set (LI follows) */ + while (!e) { + if (!len) { + LOGP(DRLCMACUL, LOGL_NOTICE, "UL DATA LI extended, " + "but no more data\n"); + return -EINVAL; + } + /* get new E */ + li = (struct rlc_li_field *)data; + if (li->e == 0) /* if LI==0, E is interpreted as '1' */ + e = 1; + else + e = li->e; + data++; + len--; + } + if (len < 4) { + LOGP(DRLCMACUL, LOGL_NOTICE, "UL DATA TLLI out of frame " + "border\n"); + return -EINVAL; + } + memcpy(&_tlli, data, 4); + *tlli = ntohl(_tlli); + + return 0; +} + |