Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 1 | /* GPRS BSSGP protocol implementation as per 3GPP TS 08.18 */ |
| 2 | |
Harald Welte | 6557cd0 | 2010-05-02 09:23:16 +0200 | [diff] [blame] | 3 | /* (C) 2009-2010 by Harald Welte <laforge@gnumonks.org> |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 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 | * |
Harald Welte | d9a55f6 | 2010-05-17 23:41:43 +0200 | [diff] [blame] | 21 | * TODO: |
| 22 | * o properly count incoming BVC-RESET packets in counter group |
| 23 | * o set log context as early as possible for outgoing packets |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 24 | */ |
| 25 | |
| 26 | #include <errno.h> |
Harald Welte | eaa614c | 2010-05-02 11:26:34 +0200 | [diff] [blame] | 27 | #include <stdint.h> |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 28 | |
| 29 | #include <netinet/in.h> |
| 30 | |
| 31 | #include <osmocore/msgb.h> |
| 32 | #include <osmocore/tlv.h> |
Harald Welte | 6557cd0 | 2010-05-02 09:23:16 +0200 | [diff] [blame] | 33 | #include <osmocore/talloc.h> |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 34 | #include <osmocore/rate_ctr.h> |
Harald Welte | 6557cd0 | 2010-05-02 09:23:16 +0200 | [diff] [blame] | 35 | |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 36 | #include <openbsc/debug.h> |
| 37 | #include <openbsc/gsm_data.h> |
| 38 | #include <openbsc/gsm_04_08_gprs.h> |
| 39 | #include <openbsc/gprs_bssgp.h> |
| 40 | #include <openbsc/gprs_llc.h> |
| 41 | #include <openbsc/gprs_ns.h> |
Harald Welte | 56a0145 | 2010-05-31 22:12:30 +0200 | [diff] [blame] | 42 | #include <openbsc/gprs_sgsn.h> |
Harald Welte | 5bfe499 | 2010-06-09 11:22:47 +0200 | [diff] [blame] | 43 | #include <openbsc/gprs_gmm.h> |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 44 | |
Harald Welte | 6557cd0 | 2010-05-02 09:23:16 +0200 | [diff] [blame] | 45 | void *bssgp_tall_ctx = NULL; |
| 46 | |
Harald Welte | 6557cd0 | 2010-05-02 09:23:16 +0200 | [diff] [blame] | 47 | #define BVC_F_BLOCKED 0x0001 |
| 48 | |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 49 | enum bssgp_ctr { |
Harald Welte | b1b2908 | 2010-05-17 23:30:01 +0200 | [diff] [blame] | 50 | BSSGP_CTR_PKTS_IN, |
| 51 | BSSGP_CTR_PKTS_OUT, |
| 52 | BSSGP_CTR_BYTES_IN, |
| 53 | BSSGP_CTR_BYTES_OUT, |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 54 | BSSGP_CTR_BLOCKED, |
| 55 | BSSGP_CTR_DISCARDED, |
| 56 | }; |
| 57 | |
| 58 | static const struct rate_ctr_desc bssgp_ctr_description[] = { |
Harald Welte | b1b2908 | 2010-05-17 23:30:01 +0200 | [diff] [blame] | 59 | { "packets.in", "Packets at BSSGP Level ( In)" }, |
| 60 | { "packets.out","Packets at BSSGP Level (Out)" }, |
| 61 | { "bytes.in", "Bytes at BSSGP Level ( In)" }, |
| 62 | { "bytes.out", "Bytes at BSSGP Level (Out)" }, |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 63 | { "blocked", "BVC Blocking count" }, |
| 64 | { "discarded", "BVC LLC Discarded count" }, |
| 65 | }; |
| 66 | |
| 67 | static const struct rate_ctr_group_desc bssgp_ctrg_desc = { |
| 68 | .group_name_prefix = "bssgp.bss_ctx", |
| 69 | .group_description = "BSSGP Peer Statistics", |
| 70 | .num_ctr = ARRAY_SIZE(bssgp_ctr_description), |
| 71 | .ctr_desc = bssgp_ctr_description, |
| 72 | }; |
| 73 | |
Harald Welte | 5c90e5c | 2010-05-17 23:02:42 +0200 | [diff] [blame] | 74 | LLIST_HEAD(bssgp_bvc_ctxts); |
Harald Welte | 6557cd0 | 2010-05-02 09:23:16 +0200 | [diff] [blame] | 75 | |
| 76 | /* Find a BTS Context based on parsed RA ID and Cell ID */ |
Harald Welte | ada466f | 2010-05-17 22:59:29 +0200 | [diff] [blame] | 77 | struct bssgp_bvc_ctx *btsctx_by_raid_cid(const struct gprs_ra_id *raid, uint16_t cid) |
Harald Welte | 6557cd0 | 2010-05-02 09:23:16 +0200 | [diff] [blame] | 78 | { |
Harald Welte | ada466f | 2010-05-17 22:59:29 +0200 | [diff] [blame] | 79 | struct bssgp_bvc_ctx *bctx; |
Harald Welte | 6557cd0 | 2010-05-02 09:23:16 +0200 | [diff] [blame] | 80 | |
Harald Welte | 5c90e5c | 2010-05-17 23:02:42 +0200 | [diff] [blame] | 81 | llist_for_each_entry(bctx, &bssgp_bvc_ctxts, list) { |
Harald Welte | 6557cd0 | 2010-05-02 09:23:16 +0200 | [diff] [blame] | 82 | if (!memcmp(&bctx->ra_id, raid, sizeof(bctx->ra_id)) && |
| 83 | bctx->cell_id == cid) |
| 84 | return bctx; |
| 85 | } |
| 86 | return NULL; |
| 87 | } |
| 88 | |
| 89 | /* Find a BTS context based on BVCI+NSEI tuple */ |
Harald Welte | ada466f | 2010-05-17 22:59:29 +0200 | [diff] [blame] | 90 | struct bssgp_bvc_ctx *btsctx_by_bvci_nsei(uint16_t bvci, uint16_t nsei) |
Harald Welte | 6557cd0 | 2010-05-02 09:23:16 +0200 | [diff] [blame] | 91 | { |
Harald Welte | ada466f | 2010-05-17 22:59:29 +0200 | [diff] [blame] | 92 | struct bssgp_bvc_ctx *bctx; |
Harald Welte | 6557cd0 | 2010-05-02 09:23:16 +0200 | [diff] [blame] | 93 | |
Harald Welte | 5c90e5c | 2010-05-17 23:02:42 +0200 | [diff] [blame] | 94 | llist_for_each_entry(bctx, &bssgp_bvc_ctxts, list) { |
Harald Welte | 6557cd0 | 2010-05-02 09:23:16 +0200 | [diff] [blame] | 95 | if (bctx->nsei == nsei && bctx->bvci == bvci) |
| 96 | return bctx; |
| 97 | } |
| 98 | return NULL; |
| 99 | } |
| 100 | |
Harald Welte | ada466f | 2010-05-17 22:59:29 +0200 | [diff] [blame] | 101 | struct bssgp_bvc_ctx *btsctx_alloc(uint16_t bvci, uint16_t nsei) |
Harald Welte | 6557cd0 | 2010-05-02 09:23:16 +0200 | [diff] [blame] | 102 | { |
Harald Welte | ada466f | 2010-05-17 22:59:29 +0200 | [diff] [blame] | 103 | struct bssgp_bvc_ctx *ctx; |
Harald Welte | 6557cd0 | 2010-05-02 09:23:16 +0200 | [diff] [blame] | 104 | |
Harald Welte | ada466f | 2010-05-17 22:59:29 +0200 | [diff] [blame] | 105 | ctx = talloc_zero(bssgp_tall_ctx, struct bssgp_bvc_ctx); |
Harald Welte | 6557cd0 | 2010-05-02 09:23:16 +0200 | [diff] [blame] | 106 | if (!ctx) |
| 107 | return NULL; |
| 108 | ctx->bvci = bvci; |
| 109 | ctx->nsei = nsei; |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 110 | /* FIXME: BVCI is not unique, only BVCI+NSEI ?!? */ |
| 111 | ctx->ctrg = rate_ctr_group_alloc(ctx, &bssgp_ctrg_desc, bvci); |
| 112 | |
Harald Welte | 5c90e5c | 2010-05-17 23:02:42 +0200 | [diff] [blame] | 113 | llist_add(&ctx->list, &bssgp_bvc_ctxts); |
Harald Welte | 6557cd0 | 2010-05-02 09:23:16 +0200 | [diff] [blame] | 114 | |
| 115 | return ctx; |
| 116 | } |
| 117 | |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 118 | /* Chapter 10.4.5: Flow Control BVC ACK */ |
Harald Welte | eaa614c | 2010-05-02 11:26:34 +0200 | [diff] [blame] | 119 | static int bssgp_tx_fc_bvc_ack(uint16_t nsei, uint8_t tag, uint16_t ns_bvci) |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 120 | { |
| 121 | struct msgb *msg = bssgp_msgb_alloc(); |
| 122 | struct bssgp_normal_hdr *bgph = |
| 123 | (struct bssgp_normal_hdr *) msgb_put(msg, sizeof(*bgph)); |
| 124 | |
Harald Welte | 44f1c27 | 2010-04-30 19:54:29 +0200 | [diff] [blame] | 125 | msgb_nsei(msg) = nsei; |
| 126 | msgb_bvci(msg) = ns_bvci; |
| 127 | |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 128 | bgph->pdu_type = BSSGP_PDUT_FLOW_CONTROL_BVC_ACK; |
| 129 | msgb_tvlv_put(msg, BSSGP_IE_TAG, 1, &tag); |
| 130 | |
Harald Welte | 44f1c27 | 2010-04-30 19:54:29 +0200 | [diff] [blame] | 131 | return gprs_ns_sendmsg(bssgp_nsi, msg); |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 132 | } |
| 133 | |
Harald Welte | 02ea86f | 2010-05-30 22:00:53 +0200 | [diff] [blame] | 134 | /* 10.3.7 SUSPEND-ACK PDU */ |
| 135 | int bssgp_tx_suspend_ack(uint16_t nsei, uint32_t tlli, |
| 136 | const struct gprs_ra_id *ra_id, uint8_t suspend_ref) |
| 137 | { |
| 138 | struct msgb *msg = bssgp_msgb_alloc(); |
| 139 | struct bssgp_normal_hdr *bgph = |
| 140 | (struct bssgp_normal_hdr *) msgb_put(msg, sizeof(*bgph)); |
| 141 | uint32_t _tlli; |
| 142 | uint8_t ra[6]; |
| 143 | |
| 144 | msgb_nsei(msg) = nsei; |
| 145 | msgb_bvci(msg) = 0; /* Signalling */ |
| 146 | bgph->pdu_type = BSSGP_PDUT_SUSPEND_ACK; |
| 147 | |
| 148 | _tlli = htonl(tlli); |
| 149 | msgb_tvlv_put(msg, BSSGP_IE_TLLI, 4, (uint8_t *) &_tlli); |
| 150 | gsm48_construct_ra(ra, ra_id); |
| 151 | msgb_tvlv_put(msg, BSSGP_IE_ROUTEING_AREA, 6, ra); |
| 152 | msgb_tvlv_put(msg, BSSGP_IE_SUSPEND_REF_NR, 1, &suspend_ref); |
| 153 | |
| 154 | return gprs_ns_sendmsg(bssgp_nsi, msg); |
| 155 | } |
| 156 | |
| 157 | /* 10.3.8 SUSPEND-NACK PDU */ |
| 158 | int bssgp_tx_suspend_nack(uint16_t nsei, uint32_t tlli, |
| 159 | uint8_t *cause) |
| 160 | { |
| 161 | struct msgb *msg = bssgp_msgb_alloc(); |
| 162 | struct bssgp_normal_hdr *bgph = |
| 163 | (struct bssgp_normal_hdr *) msgb_put(msg, sizeof(*bgph)); |
| 164 | uint32_t _tlli; |
| 165 | |
| 166 | msgb_nsei(msg) = nsei; |
| 167 | msgb_bvci(msg) = 0; /* Signalling */ |
| 168 | bgph->pdu_type = BSSGP_PDUT_SUSPEND_NACK; |
| 169 | |
| 170 | _tlli = htonl(tlli); |
| 171 | msgb_tvlv_put(msg, BSSGP_IE_TLLI, 4, (uint8_t *) &_tlli); |
| 172 | if (cause) |
| 173 | msgb_tvlv_put(msg, BSSGP_IE_CAUSE, 1, cause); |
| 174 | |
| 175 | return gprs_ns_sendmsg(bssgp_nsi, msg); |
| 176 | } |
| 177 | |
| 178 | /* 10.3.10 RESUME-ACK PDU */ |
| 179 | int bssgp_tx_resume_ack(uint16_t nsei, uint32_t tlli, |
| 180 | const struct gprs_ra_id *ra_id) |
| 181 | { |
| 182 | struct msgb *msg = bssgp_msgb_alloc(); |
| 183 | struct bssgp_normal_hdr *bgph = |
| 184 | (struct bssgp_normal_hdr *) msgb_put(msg, sizeof(*bgph)); |
| 185 | uint32_t _tlli; |
| 186 | uint8_t ra[6]; |
| 187 | |
| 188 | msgb_nsei(msg) = nsei; |
| 189 | msgb_bvci(msg) = 0; /* Signalling */ |
| 190 | bgph->pdu_type = BSSGP_PDUT_RESUME_ACK; |
| 191 | |
| 192 | _tlli = htonl(tlli); |
| 193 | msgb_tvlv_put(msg, BSSGP_IE_TLLI, 4, (uint8_t *) &_tlli); |
| 194 | gsm48_construct_ra(ra, ra_id); |
| 195 | msgb_tvlv_put(msg, BSSGP_IE_ROUTEING_AREA, 6, ra); |
| 196 | |
| 197 | return gprs_ns_sendmsg(bssgp_nsi, msg); |
| 198 | } |
| 199 | |
| 200 | /* 10.3.11 RESUME-NACK PDU */ |
| 201 | int bssgp_tx_resume_nack(uint16_t nsei, uint32_t tlli, |
| 202 | const struct gprs_ra_id *ra_id, uint8_t *cause) |
| 203 | { |
| 204 | struct msgb *msg = bssgp_msgb_alloc(); |
| 205 | struct bssgp_normal_hdr *bgph = |
| 206 | (struct bssgp_normal_hdr *) msgb_put(msg, sizeof(*bgph)); |
| 207 | uint32_t _tlli; |
| 208 | uint8_t ra[6]; |
| 209 | |
| 210 | msgb_nsei(msg) = nsei; |
| 211 | msgb_bvci(msg) = 0; /* Signalling */ |
| 212 | bgph->pdu_type = BSSGP_PDUT_SUSPEND_NACK; |
| 213 | |
| 214 | _tlli = htonl(tlli); |
| 215 | msgb_tvlv_put(msg, BSSGP_IE_TLLI, 4, (uint8_t *) &_tlli); |
| 216 | gsm48_construct_ra(ra, ra_id); |
| 217 | msgb_tvlv_put(msg, BSSGP_IE_ROUTEING_AREA, 6, ra); |
| 218 | if (cause) |
| 219 | msgb_tvlv_put(msg, BSSGP_IE_CAUSE, 1, cause); |
| 220 | |
| 221 | return gprs_ns_sendmsg(bssgp_nsi, msg); |
| 222 | } |
| 223 | |
Harald Welte | 11d7c10 | 2010-05-02 11:54:55 +0200 | [diff] [blame] | 224 | uint16_t bssgp_parse_cell_id(struct gprs_ra_id *raid, const uint8_t *buf) |
Harald Welte | 6557cd0 | 2010-05-02 09:23:16 +0200 | [diff] [blame] | 225 | { |
| 226 | /* 6 octets RAC */ |
| 227 | gsm48_parse_ra(raid, buf); |
| 228 | /* 2 octets CID */ |
Harald Welte | 11d7c10 | 2010-05-02 11:54:55 +0200 | [diff] [blame] | 229 | return ntohs(*(uint16_t *) (buf+6)); |
Harald Welte | 6557cd0 | 2010-05-02 09:23:16 +0200 | [diff] [blame] | 230 | } |
| 231 | |
Harald Welte | 288be16 | 2010-05-01 16:48:27 +0200 | [diff] [blame] | 232 | /* Chapter 8.4 BVC-Reset Procedure */ |
| 233 | static int bssgp_rx_bvc_reset(struct msgb *msg, struct tlv_parsed *tp, |
| 234 | uint16_t ns_bvci) |
| 235 | { |
Harald Welte | ada466f | 2010-05-17 22:59:29 +0200 | [diff] [blame] | 236 | struct bssgp_bvc_ctx *bctx; |
Harald Welte | 6557cd0 | 2010-05-02 09:23:16 +0200 | [diff] [blame] | 237 | uint16_t nsei = msgb_nsei(msg); |
| 238 | uint16_t bvci; |
Harald Welte | 288be16 | 2010-05-01 16:48:27 +0200 | [diff] [blame] | 239 | int rc; |
| 240 | |
Harald Welte | eaa614c | 2010-05-02 11:26:34 +0200 | [diff] [blame] | 241 | bvci = ntohs(*(uint16_t *)TLVP_VAL(tp, BSSGP_IE_BVCI)); |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 242 | DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx RESET cause=%s\n", bvci, |
Harald Welte | 288be16 | 2010-05-01 16:48:27 +0200 | [diff] [blame] | 243 | bssgp_cause_str(*TLVP_VAL(tp, BSSGP_IE_CAUSE))); |
| 244 | |
Harald Welte | 6557cd0 | 2010-05-02 09:23:16 +0200 | [diff] [blame] | 245 | /* look-up or create the BTS context for this BVC */ |
| 246 | bctx = btsctx_by_bvci_nsei(bvci, nsei); |
| 247 | if (!bctx) |
| 248 | bctx = btsctx_alloc(bvci, nsei); |
| 249 | |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 250 | /* As opposed to NS-VCs, BVCs are NOT blocked after RESET */ |
| 251 | bctx->state &= ~BVC_S_BLOCKED; |
| 252 | |
Harald Welte | 288be16 | 2010-05-01 16:48:27 +0200 | [diff] [blame] | 253 | /* When we receive a BVC-RESET PDU (at least of a PTP BVCI), the BSS |
| 254 | * informs us about its RAC + Cell ID, so we can create a mapping */ |
Harald Welte | 6557cd0 | 2010-05-02 09:23:16 +0200 | [diff] [blame] | 255 | if (bvci != 0 && bvci != 1) { |
| 256 | if (!TLVP_PRESENT(tp, BSSGP_IE_CELL_ID)) { |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 257 | LOGP(DBSSGP, LOGL_ERROR, "BSSGP BVCI=%u RESET " |
Harald Welte | 6557cd0 | 2010-05-02 09:23:16 +0200 | [diff] [blame] | 258 | "missing mandatory IE\n", bvci); |
| 259 | return -EINVAL; |
| 260 | } |
| 261 | /* actually extract RAC / CID */ |
Harald Welte | 11d7c10 | 2010-05-02 11:54:55 +0200 | [diff] [blame] | 262 | bctx->cell_id = bssgp_parse_cell_id(&bctx->ra_id, |
| 263 | TLVP_VAL(tp, BSSGP_IE_CELL_ID)); |
Harald Welte | 6b72cdf | 2010-05-11 05:54:22 +0200 | [diff] [blame] | 264 | LOGP(DBSSGP, LOGL_NOTICE, "Cell %u-%u-%u-%u CI %u on BVCI %u\n", |
Harald Welte | 6557cd0 | 2010-05-02 09:23:16 +0200 | [diff] [blame] | 265 | bctx->ra_id.mcc, bctx->ra_id.mnc, bctx->ra_id.lac, |
| 266 | bctx->ra_id.rac, bctx->cell_id, bvci); |
| 267 | } |
Harald Welte | 288be16 | 2010-05-01 16:48:27 +0200 | [diff] [blame] | 268 | |
Harald Welte | 6557cd0 | 2010-05-02 09:23:16 +0200 | [diff] [blame] | 269 | /* Acknowledge the RESET to the BTS */ |
Harald Welte | 288be16 | 2010-05-01 16:48:27 +0200 | [diff] [blame] | 270 | rc = bssgp_tx_simple_bvci(BSSGP_PDUT_BVC_RESET_ACK, |
Harald Welte | 6557cd0 | 2010-05-02 09:23:16 +0200 | [diff] [blame] | 271 | nsei, bvci, ns_bvci); |
Harald Welte | 288be16 | 2010-05-01 16:48:27 +0200 | [diff] [blame] | 272 | return 0; |
| 273 | } |
| 274 | |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 275 | static int bssgp_rx_bvc_block(struct msgb *msg, struct tlv_parsed *tp) |
| 276 | { |
| 277 | uint16_t bvci; |
Harald Welte | ada466f | 2010-05-17 22:59:29 +0200 | [diff] [blame] | 278 | struct bssgp_bvc_ctx *ptp_ctx; |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 279 | |
| 280 | bvci = ntohs(*(uint16_t *)TLVP_VAL(tp, BSSGP_IE_BVCI)); |
Harald Welte | b3911a0 | 2010-05-18 11:57:08 +0200 | [diff] [blame] | 281 | if (bvci == BVCI_SIGNALLING) { |
Harald Welte | 2b36ae1 | 2010-05-13 21:45:23 +0200 | [diff] [blame] | 282 | /* 8.3.2: Signalling BVC shall never be blocked */ |
| 283 | LOGP(DBSSGP, LOGL_ERROR, "NSEI=%u/BVCI=%u " |
| 284 | "received block for signalling BVC!?!\n", |
| 285 | msgb_nsei(msg), msgb_bvci(msg)); |
| 286 | return 0; |
| 287 | } |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 288 | |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 289 | LOGP(DBSSGP, LOGL_INFO, "BSSGP BVCI=%u BVC-BLOCK\n", bvci); |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 290 | |
| 291 | ptp_ctx = btsctx_by_bvci_nsei(bvci, msgb_nsei(msg)); |
| 292 | if (!ptp_ctx) |
| 293 | return bssgp_tx_status(BSSGP_CAUSE_UNKNOWN_BVCI, &bvci, msg); |
| 294 | |
| 295 | ptp_ctx->state |= BVC_S_BLOCKED; |
| 296 | rate_ctr_inc(&ptp_ctx->ctrg->ctr[BSSGP_CTR_BLOCKED]); |
| 297 | |
| 298 | /* FIXME: Send NM_BVC_BLOCK.ind to NM */ |
| 299 | |
| 300 | /* We always acknowledge the BLOCKing */ |
| 301 | return bssgp_tx_simple_bvci(BSSGP_PDUT_BVC_BLOCK_ACK, msgb_nsei(msg), |
| 302 | bvci, msgb_bvci(msg)); |
| 303 | }; |
| 304 | |
| 305 | static int bssgp_rx_bvc_unblock(struct msgb *msg, struct tlv_parsed *tp) |
| 306 | { |
| 307 | uint16_t bvci; |
Harald Welte | ada466f | 2010-05-17 22:59:29 +0200 | [diff] [blame] | 308 | struct bssgp_bvc_ctx *ptp_ctx; |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 309 | |
| 310 | bvci = ntohs(*(uint16_t *)TLVP_VAL(tp, BSSGP_IE_BVCI)); |
Harald Welte | b3911a0 | 2010-05-18 11:57:08 +0200 | [diff] [blame] | 311 | if (bvci == BVCI_SIGNALLING) { |
Harald Welte | 2b36ae1 | 2010-05-13 21:45:23 +0200 | [diff] [blame] | 312 | /* 8.3.2: Signalling BVC shall never be blocked */ |
| 313 | LOGP(DBSSGP, LOGL_ERROR, "NSEI=%u/BVCI=%u " |
| 314 | "received unblock for signalling BVC!?!\n", |
| 315 | msgb_nsei(msg), msgb_bvci(msg)); |
| 316 | return 0; |
| 317 | } |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 318 | |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 319 | DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx BVC-UNBLOCK\n", bvci); |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 320 | |
| 321 | ptp_ctx = btsctx_by_bvci_nsei(bvci, msgb_nsei(msg)); |
| 322 | if (!ptp_ctx) |
| 323 | return bssgp_tx_status(BSSGP_CAUSE_UNKNOWN_BVCI, &bvci, msg); |
| 324 | |
| 325 | ptp_ctx->state &= ~BVC_S_BLOCKED; |
| 326 | |
| 327 | /* FIXME: Send NM_BVC_UNBLOCK.ind to NM */ |
| 328 | |
| 329 | /* We always acknowledge the unBLOCKing */ |
| 330 | return bssgp_tx_simple_bvci(BSSGP_PDUT_BVC_UNBLOCK_ACK, msgb_nsei(msg), |
| 331 | bvci, msgb_bvci(msg)); |
| 332 | }; |
| 333 | |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 334 | /* Uplink unit-data */ |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 335 | static int bssgp_rx_ul_ud(struct msgb *msg, struct tlv_parsed *tp, |
Harald Welte | ada466f | 2010-05-17 22:59:29 +0200 | [diff] [blame] | 336 | struct bssgp_bvc_ctx *ctx) |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 337 | { |
Harald Welte | fd3fa1d | 2010-05-02 09:50:42 +0200 | [diff] [blame] | 338 | struct bssgp_ud_hdr *budh = (struct bssgp_ud_hdr *) msgb_bssgph(msg); |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 339 | |
Harald Welte | 6557cd0 | 2010-05-02 09:23:16 +0200 | [diff] [blame] | 340 | /* extract TLLI and parse TLV IEs */ |
Harald Welte | 943c5bc | 2010-04-30 16:33:12 +0200 | [diff] [blame] | 341 | msgb_tlli(msg) = ntohl(budh->tlli); |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 342 | |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 343 | DEBUGP(DBSSGP, "BSSGP TLLI=0x%08x UPLINK-UNITDATA\n", msgb_tlli(msg)); |
| 344 | |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 345 | /* Cell ID and LLC_PDU are the only mandatory IE */ |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 346 | if (!TLVP_PRESENT(tp, BSSGP_IE_CELL_ID) || |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 347 | !TLVP_PRESENT(tp, BSSGP_IE_LLC_PDU)) { |
| 348 | LOGP(DBSSGP, LOGL_ERROR, "BSSGP TLLI=0x%08x Rx UL-UD " |
| 349 | "missing mandatory IE\n", msgb_tlli(msg)); |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 350 | return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg); |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 351 | } |
Harald Welte | e6afd60 | 2010-05-02 11:19:37 +0200 | [diff] [blame] | 352 | |
Harald Welte | 11d7c10 | 2010-05-02 11:54:55 +0200 | [diff] [blame] | 353 | /* store pointer to LLC header and CELL ID in msgb->cb */ |
Holger Hans Peter Freyther | 2e22a5d | 2010-05-23 21:11:19 +0800 | [diff] [blame] | 354 | msgb_llch(msg) = (uint8_t *) TLVP_VAL(tp, BSSGP_IE_LLC_PDU); |
| 355 | msgb_bcid(msg) = (uint8_t *) TLVP_VAL(tp, BSSGP_IE_CELL_ID); |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 356 | |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 357 | return gprs_llc_rcvmsg(msg, tp); |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 358 | } |
| 359 | |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 360 | static int bssgp_rx_suspend(struct msgb *msg, struct tlv_parsed *tp, |
Harald Welte | ada466f | 2010-05-17 22:59:29 +0200 | [diff] [blame] | 361 | struct bssgp_bvc_ctx *ctx) |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 362 | { |
Harald Welte | fd3fa1d | 2010-05-02 09:50:42 +0200 | [diff] [blame] | 363 | struct bssgp_normal_hdr *bgph = |
| 364 | (struct bssgp_normal_hdr *) msgb_bssgph(msg); |
Harald Welte | 02ea86f | 2010-05-30 22:00:53 +0200 | [diff] [blame] | 365 | struct gprs_ra_id raid; |
| 366 | uint32_t tlli; |
Harald Welte | 5bfe499 | 2010-06-09 11:22:47 +0200 | [diff] [blame] | 367 | int rc; |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 368 | |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 369 | if (!TLVP_PRESENT(tp, BSSGP_IE_TLLI) || |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 370 | !TLVP_PRESENT(tp, BSSGP_IE_ROUTEING_AREA)) { |
| 371 | LOGP(DBSSGP, LOGL_ERROR, "BSSGP BVCI=%u Rx SUSPEND " |
| 372 | "missing mandatory IE\n", ctx->bvci); |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 373 | return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg); |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 374 | } |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 375 | |
Harald Welte | 02ea86f | 2010-05-30 22:00:53 +0200 | [diff] [blame] | 376 | tlli = ntohl(*(uint32_t *)TLVP_VAL(tp, BSSGP_IE_TLLI)); |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 377 | |
Harald Welte | 3d379ba | 2010-05-31 20:18:35 +0200 | [diff] [blame] | 378 | DEBUGP(DBSSGP, "BSSGP BVCI=%u TLLI=0x%08x Rx SUSPEND\n", |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 379 | ctx->bvci, tlli); |
| 380 | |
Harald Welte | 02ea86f | 2010-05-30 22:00:53 +0200 | [diff] [blame] | 381 | gsm48_parse_ra(&raid, TLVP_VAL(tp, BSSGP_IE_ROUTEING_AREA)); |
| 382 | |
Harald Welte | 5bfe499 | 2010-06-09 11:22:47 +0200 | [diff] [blame] | 383 | /* Inform GMM about the SUSPEND request */ |
| 384 | rc = gprs_gmm_rx_suspend(&raid, tlli); |
| 385 | if (rc < 0) |
| 386 | return bssgp_tx_suspend_nack(msgb_nsei(msg), tlli, NULL); |
| 387 | |
Harald Welte | 02ea86f | 2010-05-30 22:00:53 +0200 | [diff] [blame] | 388 | bssgp_tx_suspend_ack(msgb_nsei(msg), tlli, &raid, 0); |
| 389 | |
Holger Hans Peter Freyther | 9e28ecc | 2010-05-23 21:12:15 +0800 | [diff] [blame] | 390 | return 0; |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 391 | } |
| 392 | |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 393 | static int bssgp_rx_resume(struct msgb *msg, struct tlv_parsed *tp, |
Harald Welte | ada466f | 2010-05-17 22:59:29 +0200 | [diff] [blame] | 394 | struct bssgp_bvc_ctx *ctx) |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 395 | { |
Harald Welte | fd3fa1d | 2010-05-02 09:50:42 +0200 | [diff] [blame] | 396 | struct bssgp_normal_hdr *bgph = |
| 397 | (struct bssgp_normal_hdr *) msgb_bssgph(msg); |
Harald Welte | 02ea86f | 2010-05-30 22:00:53 +0200 | [diff] [blame] | 398 | struct gprs_ra_id raid; |
| 399 | uint32_t tlli; |
Harald Welte | 5bfe499 | 2010-06-09 11:22:47 +0200 | [diff] [blame] | 400 | uint8_t suspend_ref; |
| 401 | int rc; |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 402 | |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 403 | if (!TLVP_PRESENT(tp, BSSGP_IE_TLLI) || |
| 404 | !TLVP_PRESENT(tp, BSSGP_IE_ROUTEING_AREA) || |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 405 | !TLVP_PRESENT(tp, BSSGP_IE_SUSPEND_REF_NR)) { |
| 406 | LOGP(DBSSGP, LOGL_ERROR, "BSSGP BVCI=%u Rx RESUME " |
| 407 | "missing mandatory IE\n", ctx->bvci); |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 408 | return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg); |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 409 | } |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 410 | |
Harald Welte | 02ea86f | 2010-05-30 22:00:53 +0200 | [diff] [blame] | 411 | tlli = ntohl(*(uint32_t *)TLVP_VAL(tp, BSSGP_IE_TLLI)); |
Harald Welte | 5bfe499 | 2010-06-09 11:22:47 +0200 | [diff] [blame] | 412 | suspend_ref = *TLVP_VAL(tp, BSSGP_IE_SUSPEND_REF_NR); |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 413 | |
| 414 | DEBUGP(DBSSGP, "BSSGP BVCI=%u TLLI=0x%08x RESUME\n", ctx->bvci, tlli); |
| 415 | |
Harald Welte | 02ea86f | 2010-05-30 22:00:53 +0200 | [diff] [blame] | 416 | gsm48_parse_ra(&raid, TLVP_VAL(tp, BSSGP_IE_ROUTEING_AREA)); |
| 417 | |
Harald Welte | 5bfe499 | 2010-06-09 11:22:47 +0200 | [diff] [blame] | 418 | /* Inform GMM about the RESUME request */ |
| 419 | rc = gprs_gmm_rx_resume(&raid, tlli, suspend_ref); |
| 420 | if (rc < 0) |
| 421 | return bssgp_tx_resume_nack(msgb_nsei(msg), tlli, &raid, |
| 422 | NULL); |
| 423 | |
Harald Welte | 02ea86f | 2010-05-30 22:00:53 +0200 | [diff] [blame] | 424 | bssgp_tx_resume_ack(msgb_nsei(msg), tlli, &raid); |
Holger Hans Peter Freyther | 9e28ecc | 2010-05-23 21:12:15 +0800 | [diff] [blame] | 425 | return 0; |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 426 | } |
| 427 | |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 428 | |
| 429 | static int bssgp_rx_llc_disc(struct msgb *msg, struct tlv_parsed *tp, |
| 430 | struct bssgp_bvc_ctx *ctx) |
| 431 | { |
| 432 | uint32_t tlli; |
| 433 | |
| 434 | if (!TLVP_PRESENT(tp, BSSGP_IE_TLLI) || |
| 435 | !TLVP_PRESENT(tp, BSSGP_IE_LLC_FRAMES_DISCARDED) || |
| 436 | !TLVP_PRESENT(tp, BSSGP_IE_BVCI) || |
| 437 | !TLVP_PRESENT(tp, BSSGP_IE_NUM_OCT_AFF)) { |
| 438 | LOGP(DBSSGP, LOGL_ERROR, "BSSGP BVCI=%u Rx LLC DISCARDED " |
| 439 | "missing mandatory IE\n", ctx->bvci); |
| 440 | } |
| 441 | |
| 442 | tlli = ntohl(*(uint32_t *)TLVP_VAL(tp, BSSGP_IE_TLLI)); |
| 443 | |
| 444 | DEBUGP(DBSSGP, "BSSGP BVCI=%u TLLI=%u LLC DISCARDED\n", |
| 445 | ctx->bvci, tlli); |
| 446 | |
| 447 | rate_ctr_inc(&ctx->ctrg->ctr[BSSGP_CTR_DISCARDED]); |
| 448 | |
| 449 | /* FIXME: send NM_LLC_DISCARDED to NM */ |
| 450 | return 0; |
| 451 | } |
| 452 | |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 453 | static int bssgp_rx_fc_bvc(struct msgb *msg, struct tlv_parsed *tp, |
Harald Welte | ada466f | 2010-05-17 22:59:29 +0200 | [diff] [blame] | 454 | struct bssgp_bvc_ctx *bctx) |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 455 | { |
| 456 | |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 457 | DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx Flow Control BVC\n", |
| 458 | bctx->bvci); |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 459 | |
| 460 | if (!TLVP_PRESENT(tp, BSSGP_IE_TAG) || |
| 461 | !TLVP_PRESENT(tp, BSSGP_IE_BVC_BUCKET_SIZE) || |
| 462 | !TLVP_PRESENT(tp, BSSGP_IE_BUCKET_LEAK_RATE) || |
| 463 | !TLVP_PRESENT(tp, BSSGP_IE_BMAX_DEFAULT_MS) || |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 464 | !TLVP_PRESENT(tp, BSSGP_IE_R_DEFAULT_MS)) { |
| 465 | LOGP(DBSSGP, LOGL_ERROR, "BSSGP BVCI=%u Rx FC BVC " |
| 466 | "missing mandatory IE\n", bctx->bvci); |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 467 | return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg); |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 468 | } |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 469 | |
Harald Welte | e6afd60 | 2010-05-02 11:19:37 +0200 | [diff] [blame] | 470 | /* FIXME: actually implement flow control */ |
| 471 | |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 472 | /* Send FLOW_CONTROL_BVC_ACK */ |
Harald Welte | 44f1c27 | 2010-04-30 19:54:29 +0200 | [diff] [blame] | 473 | return bssgp_tx_fc_bvc_ack(msgb_nsei(msg), *TLVP_VAL(tp, BSSGP_IE_TAG), |
Harald Welte | e6afd60 | 2010-05-02 11:19:37 +0200 | [diff] [blame] | 474 | msgb_bvci(msg)); |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 475 | } |
Harald Welte | 288be16 | 2010-05-01 16:48:27 +0200 | [diff] [blame] | 476 | |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 477 | /* Receive a BSSGP PDU from a BSS on a PTP BVCI */ |
| 478 | static int gprs_bssgp_rx_ptp(struct msgb *msg, struct tlv_parsed *tp, |
Harald Welte | ada466f | 2010-05-17 22:59:29 +0200 | [diff] [blame] | 479 | struct bssgp_bvc_ctx *bctx) |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 480 | { |
Harald Welte | fd3fa1d | 2010-05-02 09:50:42 +0200 | [diff] [blame] | 481 | struct bssgp_normal_hdr *bgph = |
| 482 | (struct bssgp_normal_hdr *) msgb_bssgph(msg); |
Harald Welte | e6afd60 | 2010-05-02 11:19:37 +0200 | [diff] [blame] | 483 | uint8_t pdu_type = bgph->pdu_type; |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 484 | int rc = 0; |
| 485 | |
Harald Welte | 2b36ae1 | 2010-05-13 21:45:23 +0200 | [diff] [blame] | 486 | /* If traffic is received on a BVC that is marked as blocked, the |
| 487 | * received PDU shall not be accepted and a STATUS PDU (Cause value: |
| 488 | * BVC Blocked) shall be sent to the peer entity on the signalling BVC */ |
| 489 | if (bctx->state & BVC_S_BLOCKED && pdu_type != BSSGP_PDUT_STATUS) { |
| 490 | uint16_t bvci = msgb_bvci(msg); |
| 491 | return bssgp_tx_status(BSSGP_CAUSE_BVCI_BLOCKED, &bvci, msg); |
| 492 | } |
| 493 | |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 494 | switch (pdu_type) { |
| 495 | case BSSGP_PDUT_UL_UNITDATA: |
| 496 | /* some LLC data from the MS */ |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 497 | rc = bssgp_rx_ul_ud(msg, tp, bctx); |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 498 | break; |
| 499 | case BSSGP_PDUT_RA_CAPABILITY: |
| 500 | /* BSS requests RA capability or IMSI */ |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 501 | DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx RA CAPABILITY UPDATE\n", |
| 502 | bctx->bvci); |
Harald Welte | f47dc0b | 2010-05-13 19:41:31 +0200 | [diff] [blame] | 503 | /* FIXME: send GMM_RA_CAPABILITY_UPDATE.ind to GMM */ |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 504 | /* FIXME: send RA_CAPA_UPDATE_ACK */ |
| 505 | break; |
| 506 | case BSSGP_PDUT_RADIO_STATUS: |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 507 | DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx RADIO STATUS\n", bctx->bvci); |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 508 | /* BSS informs us of some exception */ |
Harald Welte | f47dc0b | 2010-05-13 19:41:31 +0200 | [diff] [blame] | 509 | /* FIXME: send GMM_RADIO_STATUS.ind to GMM */ |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 510 | break; |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 511 | case BSSGP_PDUT_FLOW_CONTROL_BVC: |
| 512 | /* BSS informs us of available bandwidth in Gb interface */ |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 513 | rc = bssgp_rx_fc_bvc(msg, tp, bctx); |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 514 | break; |
| 515 | case BSSGP_PDUT_FLOW_CONTROL_MS: |
| 516 | /* BSS informs us of available bandwidth to one MS */ |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 517 | DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx Flow Control MS\n", |
| 518 | bctx->bvci); |
Harald Welte | e6afd60 | 2010-05-02 11:19:37 +0200 | [diff] [blame] | 519 | /* FIXME: actually implement flow control */ |
| 520 | /* FIXME: Send FLOW_CONTROL_MS_ACK */ |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 521 | break; |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 522 | case BSSGP_PDUT_STATUS: |
| 523 | /* Some exception has occurred */ |
Harald Welte | f47dc0b | 2010-05-13 19:41:31 +0200 | [diff] [blame] | 524 | /* FIXME: send NM_STATUS.ind to NM */ |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 525 | case BSSGP_PDUT_DOWNLOAD_BSS_PFC: |
| 526 | case BSSGP_PDUT_CREATE_BSS_PFC_ACK: |
| 527 | case BSSGP_PDUT_CREATE_BSS_PFC_NACK: |
| 528 | case BSSGP_PDUT_MODIFY_BSS_PFC: |
| 529 | case BSSGP_PDUT_DELETE_BSS_PFC_ACK: |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 530 | DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type 0x%02x not [yet] " |
| 531 | "implemented\n", bctx->bvci, pdu_type); |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 532 | rc = bssgp_tx_status(BSSGP_CAUSE_PDU_INCOMP_FEAT, NULL, msg); |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 533 | break; |
| 534 | /* those only exist in the SGSN -> BSS direction */ |
| 535 | case BSSGP_PDUT_DL_UNITDATA: |
| 536 | case BSSGP_PDUT_PAGING_PS: |
| 537 | case BSSGP_PDUT_PAGING_CS: |
| 538 | case BSSGP_PDUT_RA_CAPA_UPDATE_ACK: |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 539 | case BSSGP_PDUT_FLOW_CONTROL_BVC_ACK: |
| 540 | case BSSGP_PDUT_FLOW_CONTROL_MS_ACK: |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 541 | DEBUGP(DBSSGP, "BSSGP BVCI=%u PDU type 0x%02x only exists " |
| 542 | "in DL\n", bctx->bvci, pdu_type); |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 543 | bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg); |
| 544 | rc = -EINVAL; |
| 545 | break; |
| 546 | default: |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 547 | DEBUGP(DBSSGP, "BSSGP BVCI=%u PDU type 0x%02x unknown\n", |
| 548 | bctx->bvci, pdu_type); |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 549 | rc = bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg); |
| 550 | break; |
| 551 | } |
| 552 | |
Holger Hans Peter Freyther | 9e28ecc | 2010-05-23 21:12:15 +0800 | [diff] [blame] | 553 | return rc; |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 554 | } |
| 555 | |
| 556 | /* Receive a BSSGP PDU from a BSS on a SIGNALLING BVCI */ |
| 557 | static int gprs_bssgp_rx_sign(struct msgb *msg, struct tlv_parsed *tp, |
Harald Welte | ada466f | 2010-05-17 22:59:29 +0200 | [diff] [blame] | 558 | struct bssgp_bvc_ctx *bctx) |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 559 | { |
| 560 | struct bssgp_normal_hdr *bgph = |
| 561 | (struct bssgp_normal_hdr *) msgb_bssgph(msg); |
| 562 | uint8_t pdu_type = bgph->pdu_type; |
| 563 | int rc = 0; |
| 564 | uint16_t ns_bvci = msgb_bvci(msg); |
| 565 | uint16_t bvci; |
| 566 | |
| 567 | switch (bgph->pdu_type) { |
| 568 | case BSSGP_PDUT_SUSPEND: |
| 569 | /* MS wants to suspend */ |
| 570 | rc = bssgp_rx_suspend(msg, tp, bctx); |
| 571 | break; |
| 572 | case BSSGP_PDUT_RESUME: |
| 573 | /* MS wants to resume */ |
| 574 | rc = bssgp_rx_resume(msg, tp, bctx); |
| 575 | break; |
| 576 | case BSSGP_PDUT_FLUSH_LL_ACK: |
| 577 | /* BSS informs us it has performed LL FLUSH */ |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 578 | DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx FLUSH LL ACK\n", bctx->bvci); |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 579 | /* FIXME: send NM_FLUSH_LL.res to NM */ |
| 580 | break; |
| 581 | case BSSGP_PDUT_LLC_DISCARD: |
| 582 | /* BSS informs that some LLC PDU's have been discarded */ |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 583 | rc = bssgp_rx_llc_disc(msg, tp, bctx); |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 584 | break; |
| 585 | case BSSGP_PDUT_BVC_BLOCK: |
| 586 | /* BSS tells us that BVC shall be blocked */ |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 587 | if (!TLVP_PRESENT(tp, BSSGP_IE_BVCI) || |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 588 | !TLVP_PRESENT(tp, BSSGP_IE_CAUSE)) { |
| 589 | LOGP(DBSSGP, LOGL_ERROR, "BSSGP Rx BVC-BLOCK " |
| 590 | "missing mandatory IE\n"); |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 591 | goto err_mand_ie; |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 592 | } |
Harald Welte | 72b4b20 | 2010-05-31 17:16:36 +0200 | [diff] [blame] | 593 | rc = bssgp_rx_bvc_block(msg, tp); |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 594 | break; |
| 595 | case BSSGP_PDUT_BVC_UNBLOCK: |
| 596 | /* BSS tells us that BVC shall be unblocked */ |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 597 | if (!TLVP_PRESENT(tp, BSSGP_IE_BVCI)) { |
| 598 | LOGP(DBSSGP, LOGL_ERROR, "BSSGP Rx BVC-UNBLOCK " |
| 599 | "missing mandatory IE\n"); |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 600 | goto err_mand_ie; |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 601 | } |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 602 | rc = bssgp_rx_bvc_unblock(msg, tp); |
| 603 | break; |
| 604 | case BSSGP_PDUT_BVC_RESET: |
| 605 | /* BSS tells us that BVC init is required */ |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 606 | if (!TLVP_PRESENT(tp, BSSGP_IE_BVCI) || |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 607 | !TLVP_PRESENT(tp, BSSGP_IE_CAUSE)) { |
| 608 | LOGP(DBSSGP, LOGL_ERROR, "BSSGP Rx BVC-RESET " |
| 609 | "missing mandatory IE\n"); |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 610 | goto err_mand_ie; |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 611 | } |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 612 | rc = bssgp_rx_bvc_reset(msg, tp, ns_bvci); |
| 613 | break; |
| 614 | case BSSGP_PDUT_STATUS: |
| 615 | /* Some exception has occurred */ |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 616 | DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx BVC STATUS\n", bctx->bvci); |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 617 | /* FIXME: send NM_STATUS.ind to NM */ |
| 618 | break; |
| 619 | /* those only exist in the SGSN -> BSS direction */ |
| 620 | case BSSGP_PDUT_PAGING_PS: |
| 621 | case BSSGP_PDUT_PAGING_CS: |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 622 | case BSSGP_PDUT_SUSPEND_ACK: |
| 623 | case BSSGP_PDUT_SUSPEND_NACK: |
| 624 | case BSSGP_PDUT_RESUME_ACK: |
| 625 | case BSSGP_PDUT_RESUME_NACK: |
Harald Welte | f47dc0b | 2010-05-13 19:41:31 +0200 | [diff] [blame] | 626 | case BSSGP_PDUT_FLUSH_LL: |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 627 | case BSSGP_PDUT_BVC_BLOCK_ACK: |
| 628 | case BSSGP_PDUT_BVC_UNBLOCK_ACK: |
| 629 | case BSSGP_PDUT_SGSN_INVOKE_TRACE: |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 630 | DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type 0x%02x only exists " |
| 631 | "in DL\n", bctx->bvci, pdu_type); |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 632 | bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg); |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 633 | rc = -EINVAL; |
| 634 | break; |
| 635 | default: |
Harald Welte | c91ce1a | 2010-05-31 18:07:17 +0200 | [diff] [blame] | 636 | DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type 0x%02x unknown\n", |
| 637 | bctx->bvci, pdu_type); |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 638 | rc = bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg); |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 639 | break; |
| 640 | } |
| 641 | |
| 642 | return rc; |
| 643 | err_mand_ie: |
| 644 | return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg); |
| 645 | } |
| 646 | |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 647 | /* We expect msgb_bssgph() to point to the BSSGP header */ |
| 648 | int gprs_bssgp_rcvmsg(struct msgb *msg) |
| 649 | { |
| 650 | struct bssgp_normal_hdr *bgph = |
| 651 | (struct bssgp_normal_hdr *) msgb_bssgph(msg); |
| 652 | struct bssgp_ud_hdr *budh = (struct bssgp_ud_hdr *) msgb_bssgph(msg); |
| 653 | struct tlv_parsed tp; |
Harald Welte | ada466f | 2010-05-17 22:59:29 +0200 | [diff] [blame] | 654 | struct bssgp_bvc_ctx *bctx; |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 655 | uint8_t pdu_type = bgph->pdu_type; |
| 656 | uint16_t ns_bvci = msgb_bvci(msg); |
| 657 | int data_len; |
| 658 | int rc = 0; |
| 659 | |
| 660 | /* Identifiers from DOWN: NSEI, BVCI (both in msg->cb) */ |
| 661 | |
| 662 | /* UNITDATA BSSGP headers have TLLI in front */ |
| 663 | if (pdu_type != BSSGP_PDUT_UL_UNITDATA && |
| 664 | pdu_type != BSSGP_PDUT_DL_UNITDATA) { |
| 665 | data_len = msgb_bssgp_len(msg) - sizeof(*bgph); |
| 666 | rc = bssgp_tlv_parse(&tp, bgph->data, data_len); |
| 667 | } else { |
| 668 | data_len = msgb_bssgp_len(msg) - sizeof(*budh); |
| 669 | rc = bssgp_tlv_parse(&tp, budh->data, data_len); |
| 670 | } |
| 671 | |
| 672 | /* look-up or create the BTS context for this BVC */ |
| 673 | bctx = btsctx_by_bvci_nsei(ns_bvci, msgb_nsei(msg)); |
| 674 | /* Only a RESET PDU can create a new BVC context */ |
| 675 | if (!bctx && pdu_type != BSSGP_PDUT_BVC_RESET) { |
| 676 | LOGP(DBSSGP, LOGL_NOTICE, "NSEI=%u/BVCI=%u Rejecting PDU " |
| 677 | "type %u for unknown BVCI\n", msgb_nsei(msg), ns_bvci, |
| 678 | pdu_type); |
| 679 | return bssgp_tx_status(BSSGP_CAUSE_UNKNOWN_BVCI, NULL, msg); |
| 680 | } |
| 681 | |
Harald Welte | b1b2908 | 2010-05-17 23:30:01 +0200 | [diff] [blame] | 682 | if (bctx) { |
Harald Welte | d9a55f6 | 2010-05-17 23:41:43 +0200 | [diff] [blame] | 683 | log_set_context(BSC_CTX_BVC, bctx); |
Harald Welte | b1b2908 | 2010-05-17 23:30:01 +0200 | [diff] [blame] | 684 | rate_ctr_inc(&bctx->ctrg->ctr[BSSGP_CTR_PKTS_IN]); |
| 685 | rate_ctr_add(&bctx->ctrg->ctr[BSSGP_CTR_BYTES_IN], |
| 686 | msgb_bssgp_len(msg)); |
| 687 | } |
| 688 | |
Harald Welte | b3911a0 | 2010-05-18 11:57:08 +0200 | [diff] [blame] | 689 | if (ns_bvci == BVCI_SIGNALLING) |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 690 | rc = gprs_bssgp_rx_sign(msg, &tp, bctx); |
Harald Welte | b3911a0 | 2010-05-18 11:57:08 +0200 | [diff] [blame] | 691 | else if (ns_bvci == BVCI_PTM) |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 692 | rc = bssgp_tx_status(BSSGP_CAUSE_PDU_INCOMP_FEAT, NULL, msg); |
| 693 | else |
| 694 | rc = gprs_bssgp_rx_ptp(msg, &tp, bctx); |
| 695 | |
| 696 | return rc; |
| 697 | } |
| 698 | |
Harald Welte | 6557cd0 | 2010-05-02 09:23:16 +0200 | [diff] [blame] | 699 | /* Entry function from upper level (LLC), asking us to transmit a BSSGP PDU |
Harald Welte | e6afd60 | 2010-05-02 11:19:37 +0200 | [diff] [blame] | 700 | * to a remote MS (identified by TLLI) at a BTS identified by its BVCI and NSEI */ |
Harald Welte | 56a0145 | 2010-05-31 22:12:30 +0200 | [diff] [blame] | 701 | int gprs_bssgp_tx_dl_ud(struct msgb *msg, struct sgsn_mm_ctx *mmctx) |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 702 | { |
Harald Welte | ada466f | 2010-05-17 22:59:29 +0200 | [diff] [blame] | 703 | struct bssgp_bvc_ctx *bctx; |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 704 | struct bssgp_ud_hdr *budh; |
Harald Welte | eaa614c | 2010-05-02 11:26:34 +0200 | [diff] [blame] | 705 | uint8_t llc_pdu_tlv_hdr_len = 2; |
| 706 | uint8_t *llc_pdu_tlv, *qos_profile; |
| 707 | uint16_t pdu_lifetime = 1000; /* centi-seconds */ |
Harald Welte | 807a5d8 | 2010-06-01 11:53:01 +0200 | [diff] [blame] | 708 | uint8_t qos_profile_default[3] = { 0x00, 0x00, 0x20 }; |
Harald Welte | eaa614c | 2010-05-02 11:26:34 +0200 | [diff] [blame] | 709 | uint16_t msg_len = msg->len; |
Harald Welte | e6afd60 | 2010-05-02 11:19:37 +0200 | [diff] [blame] | 710 | uint16_t bvci = msgb_bvci(msg); |
| 711 | uint16_t nsei = msgb_nsei(msg); |
Harald Welte | 56a0145 | 2010-05-31 22:12:30 +0200 | [diff] [blame] | 712 | uint16_t drx_params; |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 713 | |
Harald Welte | e6afd60 | 2010-05-02 11:19:37 +0200 | [diff] [blame] | 714 | /* Identifiers from UP: TLLI, BVCI, NSEI (all in msgb->cb) */ |
Harald Welte | b3911a0 | 2010-05-18 11:57:08 +0200 | [diff] [blame] | 715 | if (bvci <= BVCI_PTM ) { |
Harald Welte | 6b72cdf | 2010-05-11 05:54:22 +0200 | [diff] [blame] | 716 | LOGP(DBSSGP, LOGL_ERROR, "Cannot send DL-UD to BVCI %u\n", |
Harald Welte | e6afd60 | 2010-05-02 11:19:37 +0200 | [diff] [blame] | 717 | bvci); |
| 718 | return -EINVAL; |
| 719 | } |
| 720 | |
| 721 | bctx = btsctx_by_bvci_nsei(bvci, nsei); |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 722 | if (!bctx) { |
| 723 | /* FIXME: don't simply create missing context, but reject message */ |
Harald Welte | e6afd60 | 2010-05-02 11:19:37 +0200 | [diff] [blame] | 724 | bctx = btsctx_alloc(bvci, nsei); |
Harald Welte | 3a1bece | 2010-05-13 21:26:28 +0200 | [diff] [blame] | 725 | } |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 726 | |
| 727 | if (msg->len > TVLV_MAX_ONEBYTE) |
| 728 | llc_pdu_tlv_hdr_len += 1; |
| 729 | |
| 730 | /* prepend the tag and length of the LLC-PDU TLV */ |
| 731 | llc_pdu_tlv = msgb_push(msg, llc_pdu_tlv_hdr_len); |
| 732 | llc_pdu_tlv[0] = BSSGP_IE_LLC_PDU; |
| 733 | if (llc_pdu_tlv_hdr_len > 2) { |
| 734 | llc_pdu_tlv[1] = msg_len >> 8; |
| 735 | llc_pdu_tlv[2] = msg_len & 0xff; |
| 736 | } else { |
| 737 | llc_pdu_tlv[1] = msg_len & 0x3f; |
| 738 | llc_pdu_tlv[1] |= 0x80; |
| 739 | } |
| 740 | |
Harald Welte | 56a0145 | 2010-05-31 22:12:30 +0200 | [diff] [blame] | 741 | /* FIXME: optional elements: Alignment, UTRAN CCO, LSA, PFI */ |
| 742 | |
| 743 | if (mmctx) { |
| 744 | /* Old TLLI to help BSS map from old->new */ |
| 745 | #if 0 |
| 746 | if (mmctx->tlli_old) |
| 747 | msgb_tvlv_push(msg, BSSGP_IE_TLLI, 4, htonl(*tlli_old)); |
| 748 | #endif |
| 749 | |
| 750 | /* IMSI */ |
| 751 | if (strlen(mmctx->imsi)) { |
| 752 | uint8_t mi[10]; |
| 753 | int imsi_len = gsm48_generate_mid_from_imsi(mi, mmctx->imsi); |
| 754 | if (imsi_len > 2) |
| 755 | msgb_tvlv_push(msg, BSSGP_IE_IMSI, |
| 756 | imsi_len-2, mi+2); |
| 757 | } |
| 758 | |
| 759 | /* DRX parameters */ |
| 760 | drx_params = htons(mmctx->drx_parms); |
| 761 | msgb_tvlv_push(msg, BSSGP_IE_DRX_PARAMS, 2, |
| 762 | (uint8_t *) &drx_params); |
| 763 | |
| 764 | /* FIXME: Priority */ |
| 765 | |
| 766 | /* MS Radio Access Capability */ |
| 767 | if (mmctx->ms_radio_access_capa.len) |
| 768 | msgb_tvlv_push(msg, BSSGP_IE_MS_RADIO_ACCESS_CAP, |
| 769 | mmctx->ms_radio_access_capa.len, |
| 770 | mmctx->ms_radio_access_capa.buf); |
| 771 | } |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 772 | |
| 773 | /* prepend the pdu lifetime */ |
| 774 | pdu_lifetime = htons(pdu_lifetime); |
Harald Welte | eaa614c | 2010-05-02 11:26:34 +0200 | [diff] [blame] | 775 | msgb_tvlv_push(msg, BSSGP_IE_PDU_LIFETIME, 2, (uint8_t *)&pdu_lifetime); |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 776 | |
| 777 | /* prepend the QoS profile, TLLI and pdu type */ |
| 778 | budh = (struct bssgp_ud_hdr *) msgb_push(msg, sizeof(*budh)); |
| 779 | memcpy(budh->qos_profile, qos_profile_default, sizeof(qos_profile_default)); |
Harald Welte | 943c5bc | 2010-04-30 16:33:12 +0200 | [diff] [blame] | 780 | budh->tlli = htonl(msgb_tlli(msg)); |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 781 | budh->pdu_type = BSSGP_PDUT_DL_UNITDATA; |
| 782 | |
Harald Welte | b1b2908 | 2010-05-17 23:30:01 +0200 | [diff] [blame] | 783 | rate_ctr_inc(&bctx->ctrg->ctr[BSSGP_CTR_PKTS_OUT]); |
| 784 | rate_ctr_add(&bctx->ctrg->ctr[BSSGP_CTR_BYTES_OUT], msg->len); |
| 785 | |
Harald Welte | e6afd60 | 2010-05-02 11:19:37 +0200 | [diff] [blame] | 786 | /* Identifiers down: BVCI, NSEI (in msgb->cb) */ |
Harald Welte | 44f1c27 | 2010-04-30 19:54:29 +0200 | [diff] [blame] | 787 | |
| 788 | return gprs_ns_sendmsg(bssgp_nsi, msg); |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 789 | } |