Harald Welte | e661b27 | 2010-05-03 19:28:05 +0200 | [diff] [blame] | 1 | /* GPRS SNDCP protocol implementation as per 3GPP TS 04.65 */ |
| 2 | |
| 3 | /* (C) 2010 by Harald Welte <laforge@gnumonks.org> |
| 4 | * |
| 5 | * All Rights Reserved |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along |
| 18 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | #include <errno.h> |
| 24 | #include <stdint.h> |
| 25 | |
| 26 | #include <osmocore/msgb.h> |
| 27 | #include <osmocore/linuxlist.h> |
| 28 | #include <osmocore/timer.h> |
| 29 | #include <osmocore/talloc.h> |
| 30 | |
| 31 | #include <openbsc/gsm_data.h> |
| 32 | #include <openbsc/debug.h> |
| 33 | #include <openbsc/gprs_bssgp.h> |
| 34 | #include <openbsc/gprs_llc.h> |
| 35 | |
| 36 | /* Chapter 7.2: SN-PDU Formats */ |
| 37 | struct sndcp_common_hdr { |
| 38 | /* octet 1 */ |
| 39 | uint8_t nsapi:4; |
| 40 | uint8_t more:1; |
| 41 | uint8_t type:1; |
| 42 | uint8_t first:1; |
| 43 | uint8_t spare:1; |
| 44 | /* octet 2 */ |
| 45 | uint8_t pcomp; |
| 46 | uint8_t dcomp; |
| 47 | }; |
| 48 | |
| 49 | struct sndcp_udata_hdr { |
| 50 | /* octet 3 */ |
| 51 | uint8_t npdu_high:4; |
| 52 | uint8_t seg_nr:4; |
| 53 | /* octet 4 */ |
| 54 | uint8_t npdu_low; |
| 55 | }; |
| 56 | |
| 57 | /* Entry point for the LL-UNITDATA.indication */ |
| 58 | int sndcp_unitdata_ind(struct msgb *msg, uint8_t sapi, uint8_t *hdr, uint8_t len) |
| 59 | { |
| 60 | struct sndcp_udata_hdr *suh; |
| 61 | uint16_t npdu; |
| 62 | |
| 63 | if (suh->type == 0) { |
| 64 | LOGP(DGPRS, LOGL_ERROR, "SN-DATA PDU at unitdata_ind() function\n"); |
| 65 | return -EINVAL; |
| 66 | } |
| 67 | |
| 68 | npdu = (suh->npdu_high << 8) | suh->npdu_low; |
| 69 | } |
| 70 | |