blob: 99a7638bed4c85468e4dce6c8d8301af4a235c19 [file] [log] [blame]
Harald Welte96f71f22010-05-03 19:28:05 +02001/* 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 */
37struct 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
49struct 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
Harald Welte2720e732010-05-17 00:44:57 +020057struct sndcp_entity {
58};
59
Harald Welte96f71f22010-05-03 19:28:05 +020060/* Entry point for the LL-UNITDATA.indication */
61int sndcp_unitdata_ind(struct msgb *msg, uint8_t sapi, uint8_t *hdr, uint8_t len)
62{
63 struct sndcp_udata_hdr *suh;
64 uint16_t npdu;
65
66 if (suh->type == 0) {
67 LOGP(DGPRS, LOGL_ERROR, "SN-DATA PDU at unitdata_ind() function\n");
68 return -EINVAL;
69 }
70
71 npdu = (suh->npdu_high << 8) | suh->npdu_low;
72}
73
Harald Welte2720e732010-05-17 00:44:57 +020074/* Section 5.1.2.1 LL-RESET.ind */
75static int sndcp_ll_reset_ind(struct sndcp_entity *se,)
76{
77 /* treat all outstanding SNDCP-LLC request type primitives as not sent */
78 /* reset all SNDCP XID parameters to default values */
79}
80
81/* Section 5.1.2.17 LL-UNITDATA.ind */
82static int sndcp_ll_unitdata_ind()
83{
84}
85
86static int sndcp_ll_status_ind()
87{
88 /* inform the SM sub-layer by means of SNSM-STATUS.req */
89}
90
91static struct sndcp_state_list {{
92 uint32_t states;
93 unsigned int type;
94 int (*rout)(struct sndcp_entity *se, struct msgb *msg);
95} sndcp_state_list[] = {
96 { ALL_STATES,
97 LL_RESET_IND, sndcp_ll_reset_ind },
98 { ALL_STATES,
99 LL_ESTABLISH_IND, sndcp_ll_est_ind },
100 { SBIT(SNDCP_S_EST_RQD),
101 LL_ESTABLISH_RESP, sndcp_ll_est_ind },
102 { SBIT(SNDCP_S_EST_RQD),
103 LL_ESTABLISH_CONF, sndcp_ll_est_conf },
104 { SBIT(SNDCP_S_
105};
106
107static int sndcp_rx_llc_prim()
108{
109 case LL_ESTABLISH_REQ:
110 case LL_RELEASE_REQ:
111 case LL_XID_REQ:
112 case LL_DATA_REQ:
113 LL_UNITDATA_REQ, /* TLLI, SN-PDU, Ref, QoS, Radio Prio, Ciph */
114
115 switch (prim) {
116 case LL_RESET_IND:
117 case LL_ESTABLISH_IND:
118 case LL_ESTABLISH_RESP:
119 case LL_ESTABLISH_CONF:
120 case LL_RELEASE_IND:
121 case LL_RELEASE_CONF:
122 case LL_XID_IND:
123 case LL_XID_RESP:
124 case LL_XID_CONF:
125 case LL_DATA_IND:
126 case LL_DATA_CONF:
127 case LL_UNITDATA_IND:
128 case LL_STATUS_IND:
129}