blob: 02945e16430b9ab5202673814c4a9c8d939873b0 [file] [log] [blame]
Jonathan Santos03fd8d02011-05-25 13:54:02 -04001#ifndef _GPRS_LLC_H
2#define _GPRS_LLC_H
3
4#include <stdint.h>
5#include <openbsc/gprs_sgsn.h>
6
7/* Section 4.7 LLC Layer Structure */
8enum gprs_llc_sapi {
9 GPRS_SAPI_GMM = 1,
10 GPRS_SAPI_TOM2 = 2,
11 GPRS_SAPI_SNDCP3 = 3,
12 GPRS_SAPI_SNDCP5 = 5,
13 GPRS_SAPI_SMS = 7,
14 GPRS_SAPI_TOM8 = 8,
15 GPRS_SAPI_SNDCP9 = 9,
16 GPRS_SAPI_SNDCP11 = 11,
17};
18
19/* Section 6.4 Commands and Responses */
20enum gprs_llc_u_cmd {
21 GPRS_LLC_U_DM_RESP = 0x01,
22 GPRS_LLC_U_DISC_CMD = 0x04,
23 GPRS_LLC_U_UA_RESP = 0x06,
24 GPRS_LLC_U_SABM_CMD = 0x07,
25 GPRS_LLC_U_FRMR_RESP = 0x08,
26 GPRS_LLC_U_XID = 0x0b,
27 GPRS_LLC_U_NULL_CMD = 0x00,
28};
29
30/* TS 04.64 Section 7.1.2 Table 7: LLC layer primitives (GMM/SNDCP/SMS/TOM) */
31/* TS 04.65 Section 5.1.2 Table 2: Service primitives used by SNDCP */
32enum gprs_llc_primitive {
33 /* GMM <-> LLME */
34 LLGMM_ASSIGN_REQ, /* GMM tells us new TLLI: TLLI old, TLLI new, Kc, CiphAlg */
35 LLGMM_RESET_REQ, /* GMM tells us to perform XID negotiation: TLLI */
36 LLGMM_RESET_CNF, /* LLC informs GMM that XID has completed: TLLI */
37 LLGMM_SUSPEND_REQ, /* GMM tells us MS has suspended: TLLI, Page */
38 LLGMM_RESUME_REQ, /* GMM tells us MS has resumed: TLLI */
39 LLGMM_PAGE_IND, /* LLC asks GMM to page MS: TLLI */
40 LLGMM_IOV_REQ, /* GMM tells us to perform XID: TLLI */
41 LLGMM_STATUS_IND, /* LLC informs GMM about error: TLLI, Cause */
42 /* LLE <-> (GMM/SNDCP/SMS/TOM) */
43 LL_RESET_IND, /* TLLI */
44 LL_ESTABLISH_REQ, /* TLLI, XID Req */
45 LL_ESTABLISH_IND, /* TLLI, XID Req, N201-I, N201-U */
46 LL_ESTABLISH_RESP, /* TLLI, XID Negotiated */
47 LL_ESTABLISH_CONF, /* TLLI, XID Neg, N201-i, N201-U */
48 LL_RELEASE_REQ, /* TLLI, Local */
49 LL_RELEASE_IND, /* TLLI, Cause */
50 LL_RELEASE_CONF, /* TLLI */
51 LL_XID_REQ, /* TLLI, XID Requested */
52 LL_XID_IND, /* TLLI, XID Req, N201-I, N201-U */
53 LL_XID_RESP, /* TLLI, XID Negotiated */
54 LL_XID_CONF, /* TLLI, XID Neg, N201-I, N201-U */
55 LL_DATA_REQ, /* TLLI, SN-PDU, Ref, QoS, Radio Prio, Ciph */
56 LL_DATA_IND, /* TLLI, SN-PDU */
57 LL_DATA_CONF, /* TLLI, Ref */
58 LL_UNITDATA_REQ, /* TLLI, SN-PDU, Ref, QoS, Radio Prio, Ciph */
59 LL_UNITDATA_IND, /* TLLI, SN-PDU */
60 LL_STATUS_IND, /* TLLI, Cause */
61};
62
63/* Section 4.5.2 Logical Link States + Annex C.2 */
64enum gprs_llc_lle_state {
65 GPRS_LLES_UNASSIGNED = 1, /* No TLLI yet */
66 GPRS_LLES_ASSIGNED_ADM = 2, /* TLLI assigned */
67 GPRS_LLES_LOCAL_EST = 3, /* Local Establishment */
68 GPRS_LLES_REMOTE_EST = 4, /* Remote Establishment */
69 GPRS_LLES_ABM = 5,
70 GPRS_LLES_LOCAL_REL = 6, /* Local Release */
71 GPRS_LLES_TIMER_REC = 7, /* Timer Recovery */
72};
73
74enum gprs_llc_llme_state {
75 GPRS_LLMS_UNASSIGNED = 1, /* No TLLI yet */
76 GPRS_LLMS_ASSIGNED = 2, /* TLLI assigned */
77};
78
79/* Section 8.9.9 LLC layer parameter default values */
80struct gprs_llc_params {
81 uint16_t iov_i_exp;
82 uint16_t t200_201;
83 uint16_t n200;
84 uint16_t n201_u;
85 uint16_t n201_i;
86 uint16_t mD;
87 uint16_t mU;
88 uint16_t kD;
89 uint16_t kU;
90};
91
92/* Section 4.7.1: Logical Link Entity: One per DLCI (TLLI + SAPI) */
93struct gprs_llc_lle {
94 struct llist_head list;
95
96 uint32_t sapi;
97
98 struct gprs_llc_llme *llme;
99
100 enum gprs_llc_lle_state state;
101
102 struct timer_list t200;
103 struct timer_list t201; /* wait for acknowledgement */
104
105 uint16_t v_sent;
106 uint16_t v_ack;
107 uint16_t v_recv;
108
109 uint16_t vu_send;
110 uint16_t vu_recv;
111
112 /* Overflow Counter for ABM */
113 uint32_t oc_i_send;
114 uint32_t oc_i_recv;
115
116 /* Overflow Counter for unconfirmed transfer */
117 uint32_t oc_ui_send;
118 uint32_t oc_ui_recv;
119
120 unsigned int retrans_ctr;
121
122 struct gprs_llc_params params;
123};
124
125#define NUM_SAPIS 16
126
127struct gprs_llc_llme {
128 struct llist_head list;
129
130 enum gprs_llc_llme_state state;
131
132 uint32_t tlli;
133 uint32_t old_tlli;
134
135 /* Crypto parameters */
136 enum gprs_ciph_algo algo;
137 uint8_t kc[8];
138
139 /* over which BSSGP BTS ctx do we need to transmit */
140 uint16_t bvci;
141 uint16_t nsei;
142 struct gprs_llc_lle lle[NUM_SAPIS];
143};
144
145extern struct llist_head gprs_llc_llmes;
146
147/* BSSGP-UL-UNITDATA.ind */
148int gprs_llc_rcvmsg(struct msgb *msg, struct tlv_parsed *tv);
149
150/* LL-UNITDATA.req */
151int gprs_llc_tx_ui(struct msgb *msg, uint8_t sapi, int command,
152 void *mmctx);
153
154/* 04.64 Chapter 7.2.1.1 LLGMM-ASSIGN */
155int gprs_llgmm_assign(struct gprs_llc_llme *llme,
156 uint32_t old_tlli, uint32_t new_tlli,
157 enum gprs_ciph_algo alg, const uint8_t *kc);
158
159int gprs_llc_init(const char *cipher_plugin_path);
160int gprs_llc_vty_init(void);
161
162#endif