Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 1 | /* gprs_rlcmac.cpp |
| 2 | * |
| 3 | * Copyright (C) 2012 Ivan Klyuchnikov |
Andreas Eversberg | 5dac2f0 | 2012-06-27 15:52:04 +0200 | [diff] [blame] | 4 | * Copyright (C) 2012 Andreas Eversberg <jolly@eversberg.eu> |
Holger Hans Peter Freyther | d6bd91e | 2013-08-24 21:16:55 +0200 | [diff] [blame] | 5 | * Copyright (C) 2013 by Holger Hans Peter Freyther |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License |
| 9 | * as published by the Free Software Foundation; either version 2 |
| 10 | * of the License, or (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 |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 20 | */ |
Pau Espin Pedrol | 585cfb2 | 2019-12-10 17:09:51 +0100 | [diff] [blame] | 21 | |
Pau Espin Pedrol | 5530f12 | 2019-12-10 19:26:27 +0100 | [diff] [blame] | 22 | extern "C" { |
| 23 | #include <osmocom/gsm/gsm48.h> |
| 24 | } |
| 25 | |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 26 | #include <pcu_l1_if.h> |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 27 | #include <gprs_rlcmac.h> |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 28 | #include <bts.h> |
Oliver Smith | d3c7591 | 2021-07-09 16:37:16 +0200 | [diff] [blame] | 29 | #include <bts_pch_timer.h> |
Holger Hans Peter Freyther | 63f29d6 | 2013-10-19 19:04:03 +0200 | [diff] [blame] | 30 | #include <encoding.h> |
Holger Hans Peter Freyther | 099535a | 2013-10-16 17:42:31 +0200 | [diff] [blame] | 31 | #include <tbf.h> |
Max | 1187a77 | 2018-01-26 13:31:42 +0100 | [diff] [blame] | 32 | #include <gprs_debug.h> |
Andreas Eversberg | 53f4725 | 2012-07-15 07:10:10 +0200 | [diff] [blame] | 33 | |
Andreas Eversberg | 6681bb8 | 2012-07-25 08:48:44 +0200 | [diff] [blame] | 34 | extern void *tall_pcu_ctx; |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 35 | |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 36 | int gprs_rlcmac_paging_request(struct gprs_rlcmac_bts *bts, const struct osmo_mobile_identity *mi, |
| 37 | uint16_t pgroup) |
Andreas Eversberg | 8c3680d | 2012-10-08 12:30:56 +0200 | [diff] [blame] | 38 | { |
Neels Hofmeyr | 0052051 | 2020-08-21 15:44:58 +0200 | [diff] [blame] | 39 | if (log_check_level(DRLCMAC, LOGL_NOTICE)) { |
Neels Hofmeyr | 0052051 | 2020-08-21 15:44:58 +0200 | [diff] [blame] | 40 | char str[64]; |
Neels Hofmeyr | 59fc0bd | 2020-08-21 16:21:23 +0200 | [diff] [blame] | 41 | osmo_mobile_identity_to_str_buf(str, sizeof(str), mi); |
Neels Hofmeyr | 0052051 | 2020-08-21 15:44:58 +0200 | [diff] [blame] | 42 | LOGP(DRLCMAC, LOGL_NOTICE, "TX: [PCU -> BTS] Paging Request (CCCH) MI=%s\n", str); |
| 43 | } |
Pau Espin Pedrol | 05bca35 | 2019-10-16 14:36:26 +0200 | [diff] [blame] | 44 | bitvec *paging_request = bitvec_alloc(22, tall_pcu_ctx); |
Max | 7426c5f | 2019-02-18 20:42:42 +0100 | [diff] [blame] | 45 | bitvec_unhex(paging_request, DUMMY_VEC); |
Neels Hofmeyr | 59fc0bd | 2020-08-21 16:21:23 +0200 | [diff] [blame] | 46 | int plen = Encoding::write_paging_request(paging_request, mi); |
| 47 | if (plen <= 0) { |
| 48 | LOGP(DRLCMAC, LOGL_ERROR, "TX: [PCU -> BTS] Failed to encode Paging Request\n"); |
| 49 | return -1; |
| 50 | } |
Oliver Smith | 4df959d | 2021-06-24 17:01:41 +0200 | [diff] [blame] | 51 | bts_do_rate_ctr_inc(bts, CTR_PCH_REQUESTS); |
Oliver Smith | d3c7591 | 2021-07-09 16:37:16 +0200 | [diff] [blame] | 52 | bts_pch_timer_start(bts, mi->imsi); |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 53 | pcu_l1if_tx_pch(bts, paging_request, plen, pgroup); |
Andreas Eversberg | 8c3680d | 2012-10-08 12:30:56 +0200 | [diff] [blame] | 54 | bitvec_free(paging_request); |
| 55 | |
| 56 | return 0; |
| 57 | } |
Andreas Eversberg | a004e6a | 2013-05-13 16:45:21 +0200 | [diff] [blame] | 58 | |
Oliver Smith | cfb6321 | 2019-09-05 17:13:33 +0200 | [diff] [blame] | 59 | /* Encode Application Information Request to Packet Application Information (3GPP TS 44.060 11.2.47) */ |
| 60 | struct msgb *gprs_rlcmac_app_info_msg(const struct gsm_pcu_if_app_info_req *req) { |
| 61 | struct msgb *msg; |
| 62 | uint16_t msgb_len = req->len + 1; |
| 63 | struct bitvec bv = {0, msgb_len, NULL}; |
| 64 | const enum bit_value page_mode[] = {ZERO, ZERO}; /* Normal Paging (3GPP TS 44.060 12.20) */ |
Andreas Eversberg | a004e6a | 2013-05-13 16:45:21 +0200 | [diff] [blame] | 65 | |
Oliver Smith | cfb6321 | 2019-09-05 17:13:33 +0200 | [diff] [blame] | 66 | if (!req->len) { |
| 67 | LOGP(DRLCMAC, LOGL_ERROR, "Application Information Request with zero length received!\n"); |
| 68 | return NULL; |
| 69 | } |
| 70 | |
| 71 | msg = msgb_alloc(msgb_len, "app_info_msg"); |
| 72 | if (!msg) |
| 73 | return NULL; |
| 74 | |
| 75 | bv.data = msgb_put(msg, msgb_len); |
| 76 | bitvec_set_bits(&bv, page_mode, 2); |
| 77 | bitvec_set_uint(&bv, req->application_type, 4); |
| 78 | bitvec_set_bytes(&bv, req->data, req->len); |
| 79 | return msg; |
| 80 | } |