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> |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 4 | * (C) 2010 by On-Waves |
Harald Welte | e661b27 | 2010-05-03 19:28:05 +0200 | [diff] [blame] | 5 | * |
| 6 | * All Rights Reserved |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
Harald Welte | 0e3e88e | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 9 | * it under the terms of the GNU Affero General Public License as published by |
| 10 | * the Free Software Foundation; either version 3 of the License, or |
Harald Welte | e661b27 | 2010-05-03 19:28:05 +0200 | [diff] [blame] | 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Harald Welte | 0e3e88e | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 16 | * GNU Affero General Public License for more details. |
Harald Welte | e661b27 | 2010-05-03 19:28:05 +0200 | [diff] [blame] | 17 | * |
Harald Welte | 0e3e88e | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 18 | * You should have received a copy of the GNU Affero General Public License |
| 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
Harald Welte | e661b27 | 2010-05-03 19:28:05 +0200 | [diff] [blame] | 20 | * |
| 21 | */ |
| 22 | |
| 23 | #include <errno.h> |
| 24 | #include <stdint.h> |
| 25 | |
Pablo Neira Ayuso | dd5fff4 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 26 | #include <osmocom/core/msgb.h> |
| 27 | #include <osmocom/core/linuxlist.h> |
| 28 | #include <osmocom/core/timer.h> |
| 29 | #include <osmocom/core/talloc.h> |
Harald Welte | cfb6b28 | 2012-06-16 14:59:56 +0800 | [diff] [blame] | 30 | #include <osmocom/gprs/gprs_bssgp.h> |
Harald Welte | e661b27 | 2010-05-03 19:28:05 +0200 | [diff] [blame] | 31 | |
| 32 | #include <openbsc/gsm_data.h> |
| 33 | #include <openbsc/debug.h> |
Harald Welte | e661b27 | 2010-05-03 19:28:05 +0200 | [diff] [blame] | 34 | #include <openbsc/gprs_llc.h> |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 35 | #include <openbsc/sgsn.h> |
Harald Welte | e661b27 | 2010-05-03 19:28:05 +0200 | [diff] [blame] | 36 | |
Harald Welte | 9413503 | 2010-06-30 17:21:19 +0200 | [diff] [blame] | 37 | #include "gprs_sndcp.h" |
| 38 | |
Harald Welte | e661b27 | 2010-05-03 19:28:05 +0200 | [diff] [blame] | 39 | /* Chapter 7.2: SN-PDU Formats */ |
| 40 | struct sndcp_common_hdr { |
| 41 | /* octet 1 */ |
| 42 | uint8_t nsapi:4; |
| 43 | uint8_t more:1; |
| 44 | uint8_t type:1; |
| 45 | uint8_t first:1; |
| 46 | uint8_t spare:1; |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 47 | } __attribute__((packed)); |
| 48 | |
| 49 | /* PCOMP / DCOMP only exist in first fragment */ |
| 50 | struct sndcp_comp_hdr { |
Harald Welte | e661b27 | 2010-05-03 19:28:05 +0200 | [diff] [blame] | 51 | /* octet 2 */ |
Harald Welte | cc2279b | 2010-06-02 23:17:05 +0200 | [diff] [blame] | 52 | uint8_t pcomp:4; |
| 53 | uint8_t dcomp:4; |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 54 | } __attribute__((packed)); |
Harald Welte | e661b27 | 2010-05-03 19:28:05 +0200 | [diff] [blame] | 55 | |
| 56 | struct sndcp_udata_hdr { |
| 57 | /* octet 3 */ |
| 58 | uint8_t npdu_high:4; |
| 59 | uint8_t seg_nr:4; |
| 60 | /* octet 4 */ |
| 61 | uint8_t npdu_low; |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 62 | } __attribute__((packed)); |
| 63 | |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 64 | |
| 65 | static void *tall_sndcp_ctx; |
| 66 | |
| 67 | /* A fragment queue entry, containing one framgent of a N-PDU */ |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 68 | struct defrag_queue_entry { |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 69 | struct llist_head list; |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 70 | /* segment number of this fragment */ |
| 71 | uint32_t seg_nr; |
| 72 | /* length of the data area of this fragment */ |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 73 | uint32_t data_len; |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 74 | /* pointer to the data of this fragment */ |
| 75 | uint8_t *data; |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 76 | }; |
| 77 | |
Harald Welte | 9413503 | 2010-06-30 17:21:19 +0200 | [diff] [blame] | 78 | LLIST_HEAD(gprs_sndcp_entities); |
Harald Welte | e661b27 | 2010-05-03 19:28:05 +0200 | [diff] [blame] | 79 | |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 80 | /* Enqueue a fragment into the defragment queue */ |
Harald Welte | 9413503 | 2010-06-30 17:21:19 +0200 | [diff] [blame] | 81 | static int defrag_enqueue(struct gprs_sndcp_entity *sne, uint8_t seg_nr, |
Harald Welte | 80b97ab | 2010-07-02 17:16:07 +0200 | [diff] [blame] | 82 | uint8_t *data, uint32_t data_len) |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 83 | { |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 84 | struct defrag_queue_entry *dqe; |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 85 | |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 86 | dqe = talloc_zero(tall_sndcp_ctx, struct defrag_queue_entry); |
| 87 | if (!dqe) |
| 88 | return -ENOMEM; |
| 89 | dqe->data = talloc_zero_size(dqe, data_len); |
| 90 | if (!dqe->data) { |
| 91 | talloc_free(dqe); |
| 92 | return -ENOMEM; |
| 93 | } |
| 94 | dqe->seg_nr = seg_nr; |
| 95 | dqe->data_len = data_len; |
| 96 | |
| 97 | llist_add(&dqe->list, &sne->defrag.frag_list); |
| 98 | |
| 99 | if (seg_nr > sne->defrag.highest_seg) |
| 100 | sne->defrag.highest_seg = seg_nr; |
| 101 | |
| 102 | sne->defrag.seg_have |= (1 << seg_nr); |
| 103 | sne->defrag.tot_len += data_len; |
| 104 | |
Harald Welte | cb26ed3 | 2010-07-02 10:29:06 +0200 | [diff] [blame] | 105 | memcpy(dqe->data, data, data_len); |
| 106 | |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 107 | return 0; |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 108 | } |
| 109 | |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 110 | /* return if we have all segments of this N-PDU */ |
Harald Welte | 9413503 | 2010-06-30 17:21:19 +0200 | [diff] [blame] | 111 | static int defrag_have_all_segments(struct gprs_sndcp_entity *sne) |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 112 | { |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 113 | uint32_t seg_needed = 0; |
| 114 | unsigned int i; |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 115 | |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 116 | /* create a bitmask of needed segments */ |
Harald Welte | f2e790f | 2010-07-01 15:09:45 +0200 | [diff] [blame] | 117 | for (i = 0; i <= sne->defrag.highest_seg; i++) |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 118 | seg_needed |= (1 << i); |
| 119 | |
| 120 | if (seg_needed == sne->defrag.seg_have) |
| 121 | return 1; |
| 122 | |
| 123 | return 0; |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 124 | } |
| 125 | |
Harald Welte | 9413503 | 2010-06-30 17:21:19 +0200 | [diff] [blame] | 126 | static struct defrag_queue_entry *defrag_get_seg(struct gprs_sndcp_entity *sne, |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 127 | uint32_t seg_nr) |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 128 | { |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 129 | struct defrag_queue_entry *dqe; |
| 130 | |
| 131 | llist_for_each_entry(dqe, &sne->defrag.frag_list, list) { |
| 132 | if (dqe->seg_nr == seg_nr) { |
| 133 | llist_del(&dqe->list); |
| 134 | return dqe; |
| 135 | } |
| 136 | } |
| 137 | return NULL; |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 138 | } |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 139 | |
Harald Welte | f4ffbf7 | 2010-07-02 16:18:59 +0200 | [diff] [blame] | 140 | /* Perform actual defragmentation and create an output packet */ |
Harald Welte | 9413503 | 2010-06-30 17:21:19 +0200 | [diff] [blame] | 141 | static int defrag_segments(struct gprs_sndcp_entity *sne) |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 142 | { |
| 143 | struct msgb *msg; |
| 144 | unsigned int seg_nr; |
| 145 | uint8_t *npdu; |
| 146 | |
Harald Welte | e6ae273 | 2010-07-02 16:01:47 +0200 | [diff] [blame] | 147 | LOGP(DSNDCP, LOGL_DEBUG, "TLLI=0x%08x NSAPI=%u: Defragment output PDU %u " |
| 148 | "num_seg=%u tot_len=%u\n", sne->lle->llme->tlli, sne->nsapi, |
| 149 | sne->defrag.npdu, sne->defrag.highest_seg, sne->defrag.tot_len); |
Sylvain Munaut | 7eec315 | 2010-06-09 20:56:52 +0200 | [diff] [blame] | 150 | msg = msgb_alloc_headroom(sne->defrag.tot_len+256, 128, "SNDCP Defrag"); |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 151 | if (!msg) |
| 152 | return -ENOMEM; |
| 153 | |
| 154 | /* FIXME: message headers + identifiers */ |
| 155 | |
| 156 | npdu = msg->data; |
| 157 | |
Harald Welte | 5deda42 | 2010-07-02 10:11:42 +0200 | [diff] [blame] | 158 | for (seg_nr = 0; seg_nr <= sne->defrag.highest_seg; seg_nr++) { |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 159 | struct defrag_queue_entry *dqe; |
| 160 | uint8_t *data; |
| 161 | |
| 162 | dqe = defrag_get_seg(sne, seg_nr); |
| 163 | if (!dqe) { |
| 164 | LOGP(DSNDCP, LOGL_ERROR, "Segment %u missing\n", seg_nr); |
Holger Hans Peter Freyther | 1bcd637 | 2012-03-01 20:30:32 +0100 | [diff] [blame] | 165 | msgb_free(msg); |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 166 | return -EIO; |
| 167 | } |
| 168 | /* actually append the segment to the N-PDU */ |
| 169 | data = msgb_put(msg, dqe->data_len); |
| 170 | memcpy(data, dqe->data, dqe->data_len); |
| 171 | |
| 172 | /* release memory for the fragment queue entry */ |
| 173 | talloc_free(dqe); |
| 174 | } |
| 175 | |
Harald Welte | f4ffbf7 | 2010-07-02 16:18:59 +0200 | [diff] [blame] | 176 | /* FIXME: cancel timer */ |
| 177 | |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 178 | /* actually send the N-PDU to the SGSN core code, which then |
| 179 | * hands it off to the correct GTP tunnel + GGSN via gtp_data_req() */ |
Harald Welte | 3322cb3 | 2010-07-01 19:56:19 +0200 | [diff] [blame] | 180 | return sgsn_rx_sndcp_ud_ind(&sne->ra_id, sne->lle->llme->tlli, |
| 181 | sne->nsapi, msg, sne->defrag.tot_len, npdu); |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 182 | } |
| 183 | |
Harald Welte | 62f07d3 | 2010-07-02 15:45:12 +0200 | [diff] [blame] | 184 | static int defrag_input(struct gprs_sndcp_entity *sne, struct msgb *msg, uint8_t *hdr, |
| 185 | unsigned int len) |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 186 | { |
| 187 | struct sndcp_common_hdr *sch; |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 188 | struct sndcp_udata_hdr *suh; |
| 189 | uint16_t npdu_num; |
| 190 | uint8_t *data; |
| 191 | int rc; |
| 192 | |
| 193 | sch = (struct sndcp_common_hdr *) hdr; |
| 194 | if (sch->first) { |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 195 | suh = (struct sndcp_udata_hdr *) (hdr + 1 + sizeof(struct sndcp_common_hdr)); |
| 196 | } else |
| 197 | suh = (struct sndcp_udata_hdr *) (hdr + sizeof(struct sndcp_common_hdr)); |
| 198 | |
| 199 | data = (uint8_t *)suh + sizeof(struct sndcp_udata_hdr); |
| 200 | |
| 201 | npdu_num = (suh->npdu_high << 8) | suh->npdu_low; |
| 202 | |
Harald Welte | e6ae273 | 2010-07-02 16:01:47 +0200 | [diff] [blame] | 203 | LOGP(DSNDCP, LOGL_DEBUG, "TLLI=0x%08x NSAPI=%u: Input PDU %u Segment %u " |
| 204 | "Length %u %s %s\n", sne->lle->llme->tlli, sne->nsapi, npdu_num, |
| 205 | suh->seg_nr, len, sch->first ? "F " : "", sch->more ? "M" : ""); |
Harald Welte | 723319b | 2010-07-01 20:29:20 +0200 | [diff] [blame] | 206 | |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 207 | if (sch->first) { |
| 208 | /* first segment of a new packet. Discard all leftover fragments of |
| 209 | * previous packet */ |
| 210 | if (!llist_empty(&sne->defrag.frag_list)) { |
Harald Welte | 2b6a9da | 2010-07-01 12:19:02 +0200 | [diff] [blame] | 211 | struct defrag_queue_entry *dqe, *dqe2; |
Harald Welte | 723319b | 2010-07-01 20:29:20 +0200 | [diff] [blame] | 212 | LOGP(DSNDCP, LOGL_INFO, "TLLI=0x%08x NSAPI=%u: Dropping " |
| 213 | "SN-PDU %u due to insufficient segments (%04x)\n", |
| 214 | sne->lle->llme->tlli, sne->nsapi, sne->defrag.npdu, |
| 215 | sne->defrag.seg_have); |
Harald Welte | 2b6a9da | 2010-07-01 12:19:02 +0200 | [diff] [blame] | 216 | llist_for_each_entry_safe(dqe, dqe2, &sne->defrag.frag_list, list) { |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 217 | llist_del(&dqe->list); |
| 218 | talloc_free(dqe); |
| 219 | } |
| 220 | } |
| 221 | /* store the currently de-fragmented PDU number */ |
| 222 | sne->defrag.npdu = npdu_num; |
Harald Welte | f4ffbf7 | 2010-07-02 16:18:59 +0200 | [diff] [blame] | 223 | |
| 224 | /* Re-set fragmentation state */ |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 225 | sne->defrag.no_more = sne->defrag.highest_seg = sne->defrag.seg_have = 0; |
Harald Welte | f4ffbf7 | 2010-07-02 16:18:59 +0200 | [diff] [blame] | 226 | sne->defrag.tot_len = 0; |
| 227 | /* FIXME: (re)start timer */ |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | if (sne->defrag.npdu != npdu_num) { |
| 231 | LOGP(DSNDCP, LOGL_INFO, "Segment for different SN-PDU " |
| 232 | "(%u != %u)\n", npdu_num, sne->defrag.npdu); |
| 233 | /* FIXME */ |
| 234 | } |
| 235 | |
| 236 | /* FIXME: check if seg_nr already exists */ |
Harald Welte | 80b97ab | 2010-07-02 17:16:07 +0200 | [diff] [blame] | 237 | /* make sure to subtract length of SNDCP header from 'len' */ |
| 238 | rc = defrag_enqueue(sne, suh->seg_nr, data, len - (data - hdr)); |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 239 | if (rc < 0) |
| 240 | return rc; |
| 241 | |
| 242 | if (!sch->more) { |
| 243 | /* this is suppsed to be the last segment of the N-PDU, but it |
| 244 | * might well be not the last to arrive */ |
| 245 | sne->defrag.no_more = 1; |
| 246 | } |
| 247 | |
| 248 | if (sne->defrag.no_more) { |
| 249 | /* we have already received the last segment before, let's check |
| 250 | * if all the previous segments exist */ |
| 251 | if (defrag_have_all_segments(sne)) |
| 252 | return defrag_segments(sne); |
| 253 | } |
| 254 | |
| 255 | return 0; |
| 256 | } |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 257 | |
Harald Welte | 9413503 | 2010-06-30 17:21:19 +0200 | [diff] [blame] | 258 | static struct gprs_sndcp_entity *gprs_sndcp_entity_by_lle(const struct gprs_llc_lle *lle, |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 259 | uint8_t nsapi) |
| 260 | { |
Harald Welte | 9413503 | 2010-06-30 17:21:19 +0200 | [diff] [blame] | 261 | struct gprs_sndcp_entity *sne; |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 262 | |
Harald Welte | 9413503 | 2010-06-30 17:21:19 +0200 | [diff] [blame] | 263 | llist_for_each_entry(sne, &gprs_sndcp_entities, list) { |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 264 | if (sne->lle == lle && sne->nsapi == nsapi) |
| 265 | return sne; |
| 266 | } |
| 267 | return NULL; |
| 268 | } |
| 269 | |
Harald Welte | 9413503 | 2010-06-30 17:21:19 +0200 | [diff] [blame] | 270 | static struct gprs_sndcp_entity *gprs_sndcp_entity_alloc(struct gprs_llc_lle *lle, |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 271 | uint8_t nsapi) |
| 272 | { |
Harald Welte | 9413503 | 2010-06-30 17:21:19 +0200 | [diff] [blame] | 273 | struct gprs_sndcp_entity *sne; |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 274 | |
Harald Welte | 9413503 | 2010-06-30 17:21:19 +0200 | [diff] [blame] | 275 | sne = talloc_zero(tall_sndcp_ctx, struct gprs_sndcp_entity); |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 276 | if (!sne) |
| 277 | return NULL; |
| 278 | |
| 279 | sne->lle = lle; |
| 280 | sne->nsapi = nsapi; |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 281 | sne->defrag.timer.data = sne; |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 282 | //sne->fqueue.timer.cb = FIXME; |
| 283 | sne->rx_state = SNDCP_RX_S_FIRST; |
Harald Welte | ae33cd2 | 2010-07-01 12:31:10 +0200 | [diff] [blame] | 284 | INIT_LLIST_HEAD(&sne->defrag.frag_list); |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 285 | |
Harald Welte | 9413503 | 2010-06-30 17:21:19 +0200 | [diff] [blame] | 286 | llist_add(&sne->list, &gprs_sndcp_entities); |
Harald Welte | d5b31a8 | 2010-06-02 12:40:48 +0200 | [diff] [blame] | 287 | |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 288 | return sne; |
| 289 | } |
| 290 | |
| 291 | /* Entry point for the SNSM-ACTIVATE.indication */ |
| 292 | int sndcp_sm_activate_ind(struct gprs_llc_lle *lle, uint8_t nsapi) |
| 293 | { |
Harald Welte | d5b31a8 | 2010-06-02 12:40:48 +0200 | [diff] [blame] | 294 | LOGP(DSNDCP, LOGL_INFO, "SNSM-ACTIVATE.ind (lle=%p TLLI=%08x, " |
| 295 | "SAPI=%u, NSAPI=%u)\n", lle, lle->llme->tlli, lle->sapi, nsapi); |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 296 | |
Harald Welte | 9413503 | 2010-06-30 17:21:19 +0200 | [diff] [blame] | 297 | if (gprs_sndcp_entity_by_lle(lle, nsapi)) { |
Harald Welte | f6554f7 | 2010-06-02 10:25:40 +0200 | [diff] [blame] | 298 | LOGP(DSNDCP, LOGL_ERROR, "Trying to ACTIVATE " |
| 299 | "already-existing entity (TLLI=%08x, NSAPI=%u)\n", |
| 300 | lle->llme->tlli, nsapi); |
| 301 | return -EEXIST; |
| 302 | } |
| 303 | |
Harald Welte | 9413503 | 2010-06-30 17:21:19 +0200 | [diff] [blame] | 304 | if (!gprs_sndcp_entity_alloc(lle, nsapi)) { |
Harald Welte | f6554f7 | 2010-06-02 10:25:40 +0200 | [diff] [blame] | 305 | LOGP(DSNDCP, LOGL_ERROR, "Out of memory during ACTIVATE\n"); |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 306 | return -ENOMEM; |
Harald Welte | f6554f7 | 2010-06-02 10:25:40 +0200 | [diff] [blame] | 307 | } |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 308 | |
| 309 | return 0; |
| 310 | } |
| 311 | |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 312 | /* Entry point for the SNSM-DEACTIVATE.indication */ |
| 313 | int sndcp_sm_deactivate_ind(struct gprs_llc_lle *lle, uint8_t nsapi) |
| 314 | { |
Harald Welte | 9413503 | 2010-06-30 17:21:19 +0200 | [diff] [blame] | 315 | struct gprs_sndcp_entity *sne; |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 316 | |
| 317 | LOGP(DSNDCP, LOGL_INFO, "SNSM-DEACTIVATE.ind (lle=%p, TLLI=%08x, " |
| 318 | "SAPI=%u, NSAPI=%u)\n", lle, lle->llme->tlli, lle->sapi, nsapi); |
| 319 | |
Harald Welte | 9413503 | 2010-06-30 17:21:19 +0200 | [diff] [blame] | 320 | sne = gprs_sndcp_entity_by_lle(lle, nsapi); |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 321 | if (!sne) { |
| 322 | LOGP(DSNDCP, LOGL_ERROR, "SNSM-DEACTIVATE.ind for non-" |
| 323 | "existing TLLI=%08x SAPI=%u NSAPI=%u\n", lle->llme->tlli, |
| 324 | lle->sapi, nsapi); |
| 325 | return -ENOENT; |
| 326 | } |
| 327 | llist_del(&sne->list); |
| 328 | /* frag queue entries are hierarchically allocated, so no need to |
| 329 | * free them explicitly here */ |
| 330 | talloc_free(sne); |
| 331 | |
| 332 | return 0; |
| 333 | } |
| 334 | |
| 335 | /* Fragmenter state */ |
| 336 | struct sndcp_frag_state { |
| 337 | uint8_t frag_nr; |
| 338 | struct msgb *msg; /* original message */ |
| 339 | uint8_t *next_byte; /* first byte of next fragment */ |
| 340 | |
Harald Welte | 9413503 | 2010-06-30 17:21:19 +0200 | [diff] [blame] | 341 | struct gprs_sndcp_entity *sne; |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 342 | void *mmcontext; |
| 343 | }; |
| 344 | |
| 345 | /* returns '1' if there are more fragments to send, '0' if none */ |
| 346 | static int sndcp_send_ud_frag(struct sndcp_frag_state *fs) |
| 347 | { |
Harald Welte | 9413503 | 2010-06-30 17:21:19 +0200 | [diff] [blame] | 348 | struct gprs_sndcp_entity *sne = fs->sne; |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 349 | struct gprs_llc_lle *lle = sne->lle; |
| 350 | struct sndcp_common_hdr *sch; |
| 351 | struct sndcp_comp_hdr *scomph; |
| 352 | struct sndcp_udata_hdr *suh; |
| 353 | struct msgb *fmsg; |
| 354 | unsigned int max_payload_len; |
| 355 | unsigned int len; |
| 356 | uint8_t *data; |
| 357 | int rc, more; |
| 358 | |
Sylvain Munaut | 7eec315 | 2010-06-09 20:56:52 +0200 | [diff] [blame] | 359 | fmsg = msgb_alloc_headroom(fs->sne->lle->params.n201_u+256, 128, |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 360 | "SNDCP Frag"); |
Holger Hans Peter Freyther | 13293f3 | 2014-10-10 17:35:54 +0200 | [diff] [blame] | 361 | if (!fmsg) { |
| 362 | msgb_free(fs->msg); |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 363 | return -ENOMEM; |
Holger Hans Peter Freyther | 13293f3 | 2014-10-10 17:35:54 +0200 | [diff] [blame] | 364 | } |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 365 | |
| 366 | /* make sure lower layers route the fragment like the original */ |
| 367 | msgb_tlli(fmsg) = msgb_tlli(fs->msg); |
| 368 | msgb_bvci(fmsg) = msgb_bvci(fs->msg); |
| 369 | msgb_nsei(fmsg) = msgb_nsei(fs->msg); |
| 370 | |
| 371 | /* prepend common SNDCP header */ |
| 372 | sch = (struct sndcp_common_hdr *) msgb_put(fmsg, sizeof(*sch)); |
| 373 | sch->nsapi = sne->nsapi; |
| 374 | /* Set FIRST bit if we are the first fragment in a series */ |
| 375 | if (fs->frag_nr == 0) |
| 376 | sch->first = 1; |
| 377 | sch->type = 1; |
| 378 | |
| 379 | /* append the compression header for first fragment */ |
| 380 | if (sch->first) { |
| 381 | scomph = (struct sndcp_comp_hdr *) |
| 382 | msgb_put(fmsg, sizeof(*scomph)); |
| 383 | scomph->pcomp = 0; |
| 384 | scomph->dcomp = 0; |
| 385 | } |
| 386 | |
| 387 | /* append the user-data header */ |
| 388 | suh = (struct sndcp_udata_hdr *) msgb_put(fmsg, sizeof(*suh)); |
| 389 | suh->npdu_low = sne->tx_npdu_nr & 0xff; |
| 390 | suh->npdu_high = (sne->tx_npdu_nr >> 8) & 0xf; |
| 391 | suh->seg_nr = fs->frag_nr % 0xf; |
| 392 | |
| 393 | /* calculate remaining length to be sent */ |
| 394 | len = (fs->msg->data + fs->msg->len) - fs->next_byte; |
| 395 | /* how much payload can we actually send via LLC? */ |
| 396 | max_payload_len = lle->params.n201_u - (sizeof(*sch) + sizeof(*suh)); |
| 397 | if (sch->first) |
| 398 | max_payload_len -= sizeof(*scomph); |
| 399 | /* check if we're exceeding the max */ |
| 400 | if (len > max_payload_len) |
| 401 | len = max_payload_len; |
| 402 | |
| 403 | /* copy the actual fragment data into our fmsg */ |
| 404 | data = msgb_put(fmsg, len); |
| 405 | memcpy(data, fs->next_byte, len); |
| 406 | |
| 407 | /* Increment fragment number and data pointer to next fragment */ |
| 408 | fs->frag_nr++; |
| 409 | fs->next_byte += len; |
| 410 | |
| 411 | /* determine if we have more fragemnts to send */ |
| 412 | if ((fs->msg->data + fs->msg->len) <= fs->next_byte) |
| 413 | more = 0; |
| 414 | else |
| 415 | more = 1; |
| 416 | |
| 417 | /* set the MORE bit of the SNDCP header accordingly */ |
| 418 | sch->more = more; |
| 419 | |
| 420 | rc = gprs_llc_tx_ui(fmsg, lle->sapi, 0, fs->mmcontext); |
Holger Hans Peter Freyther | 13293f3 | 2014-10-10 17:35:54 +0200 | [diff] [blame] | 421 | /* abort in case of error, do not advance frag_nr / next_byte */ |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 422 | if (rc < 0) { |
Holger Hans Peter Freyther | 13293f3 | 2014-10-10 17:35:54 +0200 | [diff] [blame] | 423 | msgb_free(fs->msg); |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 424 | return rc; |
| 425 | } |
| 426 | |
| 427 | if (!more) { |
| 428 | /* we've sent all fragments */ |
| 429 | msgb_free(fs->msg); |
| 430 | memset(fs, 0, sizeof(*fs)); |
| 431 | /* increment NPDU number for next frame */ |
| 432 | sne->tx_npdu_nr = (sne->tx_npdu_nr + 1) % 0xfff; |
| 433 | return 0; |
| 434 | } |
| 435 | |
| 436 | /* default: more fragments to send */ |
| 437 | return 1; |
| 438 | } |
| 439 | |
Harald Welte | d14be78 | 2010-06-03 07:14:59 +0200 | [diff] [blame] | 440 | /* Request transmission of a SN-PDU over specified LLC Entity + SAPI */ |
Harald Welte | ef1bef7 | 2010-06-03 06:38:38 +0200 | [diff] [blame] | 441 | int sndcp_unitdata_req(struct msgb *msg, struct gprs_llc_lle *lle, uint8_t nsapi, |
| 442 | void *mmcontext) |
| 443 | { |
Harald Welte | 9413503 | 2010-06-30 17:21:19 +0200 | [diff] [blame] | 444 | struct gprs_sndcp_entity *sne; |
Harald Welte | ef1bef7 | 2010-06-03 06:38:38 +0200 | [diff] [blame] | 445 | struct sndcp_common_hdr *sch; |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 446 | struct sndcp_comp_hdr *scomph; |
Harald Welte | ef1bef7 | 2010-06-03 06:38:38 +0200 | [diff] [blame] | 447 | struct sndcp_udata_hdr *suh; |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 448 | struct sndcp_frag_state fs; |
Harald Welte | ef1bef7 | 2010-06-03 06:38:38 +0200 | [diff] [blame] | 449 | |
| 450 | /* Identifiers from UP: (TLLI, SAPI) + (BVCI, NSEI) */ |
| 451 | |
Harald Welte | 9413503 | 2010-06-30 17:21:19 +0200 | [diff] [blame] | 452 | sne = gprs_sndcp_entity_by_lle(lle, nsapi); |
Harald Welte | ef1bef7 | 2010-06-03 06:38:38 +0200 | [diff] [blame] | 453 | if (!sne) { |
| 454 | LOGP(DSNDCP, LOGL_ERROR, "Cannot find SNDCP Entity\n"); |
Holger Hans Peter Freyther | 13293f3 | 2014-10-10 17:35:54 +0200 | [diff] [blame] | 455 | msgb_free(msg); |
Harald Welte | ef1bef7 | 2010-06-03 06:38:38 +0200 | [diff] [blame] | 456 | return -EIO; |
| 457 | } |
| 458 | |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 459 | /* Check if we need to fragment this N-PDU into multiple SN-PDUs */ |
| 460 | if (msg->len > lle->params.n201_u - |
| 461 | (sizeof(*sch) + sizeof(*suh) + sizeof(*scomph))) { |
| 462 | /* initialize the fragmenter state */ |
| 463 | fs.msg = msg; |
| 464 | fs.frag_nr = 0; |
| 465 | fs.next_byte = msg->data; |
| 466 | fs.sne = sne; |
| 467 | fs.mmcontext = mmcontext; |
| 468 | |
| 469 | /* call function to generate and send fragments until all |
| 470 | * of the N-PDU has been sent */ |
| 471 | while (1) { |
| 472 | int rc = sndcp_send_ud_frag(&fs); |
| 473 | if (rc == 0) |
| 474 | return 0; |
| 475 | if (rc < 0) |
| 476 | return rc; |
| 477 | } |
| 478 | /* not reached */ |
| 479 | return 0; |
| 480 | } |
| 481 | |
| 482 | /* this is the non-fragmenting case where we only build 1 SN-PDU */ |
| 483 | |
Harald Welte | ef1bef7 | 2010-06-03 06:38:38 +0200 | [diff] [blame] | 484 | /* prepend the user-data header */ |
| 485 | suh = (struct sndcp_udata_hdr *) msgb_push(msg, sizeof(*suh)); |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 486 | suh->npdu_low = sne->tx_npdu_nr & 0xff; |
| 487 | suh->npdu_high = (sne->tx_npdu_nr >> 8) & 0xf; |
| 488 | suh->seg_nr = 0; |
| 489 | sne->tx_npdu_nr = (sne->tx_npdu_nr + 1) % 0xfff; |
| 490 | |
| 491 | scomph = (struct sndcp_comp_hdr *) msgb_push(msg, sizeof(*scomph)); |
| 492 | scomph->pcomp = 0; |
| 493 | scomph->dcomp = 0; |
Harald Welte | ef1bef7 | 2010-06-03 06:38:38 +0200 | [diff] [blame] | 494 | |
| 495 | /* prepend common SNDCP header */ |
| 496 | sch = (struct sndcp_common_hdr *) msgb_push(msg, sizeof(*sch)); |
| 497 | sch->first = 1; |
| 498 | sch->type = 1; |
| 499 | sch->nsapi = nsapi; |
| 500 | |
| 501 | return gprs_llc_tx_ui(msg, lle->sapi, 0, mmcontext); |
| 502 | } |
| 503 | |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 504 | /* Section 5.1.2.17 LL-UNITDATA.ind */ |
Harald Welte | 8628983 | 2010-07-02 16:44:24 +0200 | [diff] [blame] | 505 | int sndcp_llunitdata_ind(struct msgb *msg, struct gprs_llc_lle *lle, |
| 506 | uint8_t *hdr, uint16_t len) |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 507 | { |
Harald Welte | 9413503 | 2010-06-30 17:21:19 +0200 | [diff] [blame] | 508 | struct gprs_sndcp_entity *sne; |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 509 | struct sndcp_common_hdr *sch = (struct sndcp_common_hdr *)hdr; |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 510 | struct sndcp_comp_hdr *scomph = NULL; |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 511 | struct sndcp_udata_hdr *suh; |
Harald Welte | f6554f7 | 2010-06-02 10:25:40 +0200 | [diff] [blame] | 512 | uint8_t *npdu; |
Holger Hans Peter Freyther | 82151f9 | 2014-04-04 12:43:08 +0200 | [diff] [blame] | 513 | uint16_t npdu_num __attribute__((unused)); |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 514 | int npdu_len; |
| 515 | |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 516 | sch = (struct sndcp_common_hdr *) hdr; |
| 517 | if (sch->first) { |
| 518 | scomph = (struct sndcp_comp_hdr *) (hdr + 1); |
| 519 | suh = (struct sndcp_udata_hdr *) (hdr + 1 + sizeof(struct sndcp_common_hdr)); |
| 520 | } else |
| 521 | suh = (struct sndcp_udata_hdr *) (hdr + sizeof(struct sndcp_common_hdr)); |
| 522 | |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 523 | if (sch->type == 0) { |
Harald Welte | d83e324 | 2010-06-02 10:26:19 +0200 | [diff] [blame] | 524 | LOGP(DSNDCP, LOGL_ERROR, "SN-DATA PDU at unitdata_ind() function\n"); |
Harald Welte | e661b27 | 2010-05-03 19:28:05 +0200 | [diff] [blame] | 525 | return -EINVAL; |
| 526 | } |
| 527 | |
Harald Welte | f6554f7 | 2010-06-02 10:25:40 +0200 | [diff] [blame] | 528 | if (len < sizeof(*sch) + sizeof(*suh)) { |
Harald Welte | d83e324 | 2010-06-02 10:26:19 +0200 | [diff] [blame] | 529 | LOGP(DSNDCP, LOGL_ERROR, "SN-UNITDATA PDU too short (%u)\n", len); |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 530 | return -EIO; |
| 531 | } |
| 532 | |
Harald Welte | 9413503 | 2010-06-30 17:21:19 +0200 | [diff] [blame] | 533 | sne = gprs_sndcp_entity_by_lle(lle, sch->nsapi); |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 534 | if (!sne) { |
Harald Welte | d83e324 | 2010-06-02 10:26:19 +0200 | [diff] [blame] | 535 | LOGP(DSNDCP, LOGL_ERROR, "Message for non-existing SNDCP Entity " |
Harald Welte | d5b31a8 | 2010-06-02 12:40:48 +0200 | [diff] [blame] | 536 | "(lle=%p, TLLI=%08x, SAPI=%u, NSAPI=%u)\n", lle, |
| 537 | lle->llme->tlli, lle->sapi, sch->nsapi); |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 538 | return -EIO; |
| 539 | } |
Harald Welte | 3322cb3 | 2010-07-01 19:56:19 +0200 | [diff] [blame] | 540 | /* FIXME: move this RA_ID up to the LLME or even higher */ |
| 541 | bssgp_parse_cell_id(&sne->ra_id, msgb_bcid(msg)); |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 542 | |
Harald Welte | e6ae273 | 2010-07-02 16:01:47 +0200 | [diff] [blame] | 543 | /* any non-first segment is by definition something to defragment |
| 544 | * as is any segment that tells us there are more segments */ |
| 545 | if (!sch->first || sch->more) |
Harald Welte | 62f07d3 | 2010-07-02 15:45:12 +0200 | [diff] [blame] | 546 | return defrag_input(sne, msg, hdr, len); |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 547 | |
Harald Welte | 0896568 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 548 | if (scomph && (scomph->pcomp || scomph->dcomp)) { |
Harald Welte | d83e324 | 2010-06-02 10:26:19 +0200 | [diff] [blame] | 549 | LOGP(DSNDCP, LOGL_ERROR, "We don't support compression yet\n"); |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 550 | return -EIO; |
| 551 | } |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 552 | |
Harald Welte | f6554f7 | 2010-06-02 10:25:40 +0200 | [diff] [blame] | 553 | npdu_num = (suh->npdu_high << 8) | suh->npdu_low; |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 554 | npdu = (uint8_t *)suh + sizeof(*suh); |
| 555 | npdu_len = (msg->data + msg->len) - npdu; |
Harald Welte | d5b31a8 | 2010-06-02 12:40:48 +0200 | [diff] [blame] | 556 | if (npdu_len <= 0) { |
Harald Welte | d83e324 | 2010-06-02 10:26:19 +0200 | [diff] [blame] | 557 | LOGP(DSNDCP, LOGL_ERROR, "Short SNDCP N-PDU: %d\n", npdu_len); |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 558 | return -EIO; |
| 559 | } |
| 560 | /* actually send the N-PDU to the SGSN core code, which then |
| 561 | * hands it off to the correct GTP tunnel + GGSN via gtp_data_req() */ |
Harald Welte | 3322cb3 | 2010-07-01 19:56:19 +0200 | [diff] [blame] | 562 | return sgsn_rx_sndcp_ud_ind(&sne->ra_id, lle->llme->tlli, sne->nsapi, msg, npdu_len, npdu); |
Harald Welte | e661b27 | 2010-05-03 19:28:05 +0200 | [diff] [blame] | 563 | } |
| 564 | |
Holger Hans Peter Freyther | 82151f9 | 2014-04-04 12:43:08 +0200 | [diff] [blame] | 565 | #if 0 |
Harald Welte | 8f77f19 | 2010-05-17 00:44:57 +0200 | [diff] [blame] | 566 | /* Section 5.1.2.1 LL-RESET.ind */ |
Harald Welte | 9413503 | 2010-06-30 17:21:19 +0200 | [diff] [blame] | 567 | static int sndcp_ll_reset_ind(struct gprs_sndcp_entity *se) |
Harald Welte | 8f77f19 | 2010-05-17 00:44:57 +0200 | [diff] [blame] | 568 | { |
| 569 | /* treat all outstanding SNDCP-LLC request type primitives as not sent */ |
| 570 | /* reset all SNDCP XID parameters to default values */ |
Holger Hans Peter Freyther | 8e621dc | 2011-10-14 23:37:27 +0200 | [diff] [blame] | 571 | LOGP(DSNDCP, LOGL_NOTICE, "not implemented.\n"); |
| 572 | return 0; |
Harald Welte | 8f77f19 | 2010-05-17 00:44:57 +0200 | [diff] [blame] | 573 | } |
| 574 | |
Harald Welte | 8f77f19 | 2010-05-17 00:44:57 +0200 | [diff] [blame] | 575 | static int sndcp_ll_status_ind() |
| 576 | { |
| 577 | /* inform the SM sub-layer by means of SNSM-STATUS.req */ |
Holger Hans Peter Freyther | 8e621dc | 2011-10-14 23:37:27 +0200 | [diff] [blame] | 578 | LOGP(DSNDCP, LOGL_NOTICE, "not implemented.\n"); |
| 579 | return 0; |
Harald Welte | 8f77f19 | 2010-05-17 00:44:57 +0200 | [diff] [blame] | 580 | } |
| 581 | |
| 582 | static struct sndcp_state_list {{ |
| 583 | uint32_t states; |
| 584 | unsigned int type; |
Harald Welte | 9413503 | 2010-06-30 17:21:19 +0200 | [diff] [blame] | 585 | int (*rout)(struct gprs_sndcp_entity *se, struct msgb *msg); |
Harald Welte | 8f77f19 | 2010-05-17 00:44:57 +0200 | [diff] [blame] | 586 | } sndcp_state_list[] = { |
| 587 | { ALL_STATES, |
| 588 | LL_RESET_IND, sndcp_ll_reset_ind }, |
| 589 | { ALL_STATES, |
| 590 | LL_ESTABLISH_IND, sndcp_ll_est_ind }, |
| 591 | { SBIT(SNDCP_S_EST_RQD), |
| 592 | LL_ESTABLISH_RESP, sndcp_ll_est_ind }, |
| 593 | { SBIT(SNDCP_S_EST_RQD), |
| 594 | LL_ESTABLISH_CONF, sndcp_ll_est_conf }, |
| 595 | { SBIT(SNDCP_S_ |
| 596 | }; |
| 597 | |
| 598 | static int sndcp_rx_llc_prim() |
| 599 | { |
| 600 | case LL_ESTABLISH_REQ: |
| 601 | case LL_RELEASE_REQ: |
| 602 | case LL_XID_REQ: |
| 603 | case LL_DATA_REQ: |
| 604 | LL_UNITDATA_REQ, /* TLLI, SN-PDU, Ref, QoS, Radio Prio, Ciph */ |
| 605 | |
| 606 | switch (prim) { |
| 607 | case LL_RESET_IND: |
| 608 | case LL_ESTABLISH_IND: |
| 609 | case LL_ESTABLISH_RESP: |
| 610 | case LL_ESTABLISH_CONF: |
| 611 | case LL_RELEASE_IND: |
| 612 | case LL_RELEASE_CONF: |
| 613 | case LL_XID_IND: |
| 614 | case LL_XID_RESP: |
| 615 | case LL_XID_CONF: |
| 616 | case LL_DATA_IND: |
| 617 | case LL_DATA_CONF: |
| 618 | case LL_UNITDATA_IND: |
| 619 | case LL_STATUS_IND: |
| 620 | } |
Harald Welte | d0e36dc | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 621 | #endif |