blob: b3cc033ac7afb27ab2ed8c481258281004c7c4fe [file] [log] [blame]
Holger Hans Peter Freytherbc1e52c2013-08-22 08:44:38 +02001/* (C) 2009-2010 by Harald Welte <laforge@gnumonks.org>
2 *
3 * All Rights Reserved
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 */
19#ifndef OPENBSC_CLONE_H
20#define OPENBSC_CLONE_H
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
Holger Hans Peter Freyther9d938382013-07-31 21:59:29 +020026#include <osmocom/gsm/protocol/gsm_04_08.h>
27
Holger Hans Peter Freytherbc1e52c2013-08-22 08:44:38 +020028#include <stdint.h>
29
30enum gprs_llc_cmd {
31 GPRS_LLC_NULL,
32 GPRS_LLC_RR,
33 GPRS_LLC_ACK,
34 GPRS_LLC_RNR,
35 GPRS_LLC_SACK,
36 GPRS_LLC_DM,
37 GPRS_LLC_DISC,
38 GPRS_LLC_UA,
39 GPRS_LLC_SABM,
40 GPRS_LLC_FRMR,
41 GPRS_LLC_XID,
42 GPRS_LLC_UI,
43};
44
45struct gprs_llc_hdr_parsed {
46 uint8_t sapi;
47 uint8_t is_cmd:1,
48 ack_req:1,
49 is_encrypted:1;
50 uint32_t seq_rx;
51 uint32_t seq_tx;
52 uint32_t fcs;
53 uint32_t fcs_calc;
54 const uint8_t *data;
55 uint16_t data_len;
56 uint16_t crc_length;
57 enum gprs_llc_cmd cmd;
58};
59
60int gprs_llc_hdr_parse(struct gprs_llc_hdr_parsed *ghp, const uint8_t *llc_hdr, int len);
61
Holger Hans Peter Freyther9d938382013-07-31 21:59:29 +020062/* Table 10.4 / 10.4a, GPRS Mobility Management (GMM) */
63#define GSM48_MT_GMM_ATTACH_ACK 0x02
64
65/* Chapter 9.4.2 / Table 9.4.2 */
66struct gsm48_attach_ack {
67 uint8_t att_result:4, /* 10.5.5.7 */
68 force_stby:4; /* 10.5.5.1 */
69 uint8_t ra_upd_timer; /* 10.5.7.3 */
70 uint8_t radio_prio; /* 10.5.7.2 */
71 struct gsm48_ra_id ra_id; /* 10.5.5.15 */
72 uint8_t data[0];
73} __attribute__((packed));
74
75enum gsm48_gprs_ie_mm {
76 GSM48_IE_GMM_CIPH_CKSN = 0x08, /* 10.5.1.2 */
77 GSM48_IE_GMM_TIMER_READY = 0x17, /* 10.5.7.3 */
78 GSM48_IE_GMM_ALLOC_PTMSI = 0x18, /* 10.5.1.4 */
79 GSM48_IE_GMM_PTMSI_SIG = 0x19, /* 10.5.5.8 */
80 GSM48_IE_GMM_AUTH_RAND = 0x21, /* 10.5.3.1 */
81 GSM48_IE_GMM_AUTH_SRES = 0x22, /* 10.5.3.2 */
82 GSM48_IE_GMM_IMEISV = 0x23, /* 10.5.1.4 */
83 GSM48_IE_GMM_DRX_PARAM = 0x27, /* 10.5.5.6 */
84 GSM48_IE_GMM_MS_NET_CAPA = 0x31, /* 10.5.5.12 */
85 GSM48_IE_GMM_PDP_CTX_STATUS = 0x32, /* 10.5.7.1 */
86 GSM48_IE_GMM_PS_LCS_CAPA = 0x33, /* 10.5.5.22 */
87 GSM48_IE_GMM_GMM_MBMS_CTX_ST = 0x35, /* 10.5.7.6 */
88};
89
90extern const struct tlv_definition gsm48_gmm_att_tlvdef;
91
Holger Hans Peter Freytherbc1e52c2013-08-22 08:44:38 +020092#ifdef __cplusplus
93}
94#endif
95
96#endif