2012-03-05 15:24:57 +00:00
|
|
|
/* gprs_rlcmac.cpp
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Ivan Klyuchnikov
|
2012-06-27 13:52:04 +00:00
|
|
|
* Copyright (C) 2012 Andreas Eversberg <jolly@eversberg.eu>
|
2013-08-24 19:16:55 +00:00
|
|
|
* Copyright (C) 2013 by Holger Hans Peter Freyther
|
2012-03-05 15:24:57 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*/
|
2019-12-10 16:09:51 +00:00
|
|
|
|
2019-12-10 18:26:27 +00:00
|
|
|
extern "C" {
|
|
|
|
#include <osmocom/gsm/gsm48.h>
|
|
|
|
}
|
|
|
|
|
2012-03-05 15:24:57 +00:00
|
|
|
#include <pcu_l1_if.h>
|
|
|
|
#include <gprs_rlcmac.h>
|
2013-10-17 15:01:54 +00:00
|
|
|
#include <bts.h>
|
2013-10-19 17:04:03 +00:00
|
|
|
#include <encoding.h>
|
2013-10-16 15:42:31 +00:00
|
|
|
#include <tbf.h>
|
2018-01-26 12:31:42 +00:00
|
|
|
#include <gprs_debug.h>
|
2012-07-15 05:10:10 +00:00
|
|
|
|
2012-07-25 06:48:44 +00:00
|
|
|
extern void *tall_pcu_ctx;
|
2012-03-05 15:24:57 +00:00
|
|
|
|
2021-01-18 16:14:14 +00:00
|
|
|
int gprs_rlcmac_paging_request(struct gprs_rlcmac_bts *bts, const struct osmo_mobile_identity *mi,
|
|
|
|
uint16_t pgroup)
|
2012-10-08 10:30:56 +00:00
|
|
|
{
|
2020-08-21 13:44:58 +00:00
|
|
|
if (log_check_level(DRLCMAC, LOGL_NOTICE)) {
|
|
|
|
char str[64];
|
paging: pass struct osmo_mobile_identity, not encoded IE bytes
In get_paging_mi(), before this, an encoded buffer of Mobile Identity bytes is
returned. Code paths following this repeatedly decode the Mobile Identity
bytes, e.g. for logging. Also, in get_paging_mi(), since the TMSI is read in
from a different encoding than a typical Mobile Identity IE, the TMSI was
manually encoded into a typical Mobile Identity IE. This is essentially a code
dup of osmo_mobile_identity_encode(). Stop this madness.
Instead, in get_paging_mi(), return a decoded struct osmo_mobile_identity. Code
paths after this use the struct osmo_mobile_identity directly without repeated
decoding.
At the point of finally needing an encoded Mobile Identity IE (in
Encoding::write_paging_request()), do a proper osmo_mobile_identity_encode().
Since this may return errors, add an rc check for the caller of
write_paging_request(), gprs_rlcmac_paging_request().
A side effect is stricter validation of the Mobile Identity passing through the
Paging code path. Before, invalid MI might have passed through unnoticed.
Change-Id: Iad845acb0096b75dc453105c9c16b2252879b4ca
2020-08-21 14:21:23 +00:00
|
|
|
osmo_mobile_identity_to_str_buf(str, sizeof(str), mi);
|
2020-08-21 13:44:58 +00:00
|
|
|
LOGP(DRLCMAC, LOGL_NOTICE, "TX: [PCU -> BTS] Paging Request (CCCH) MI=%s\n", str);
|
|
|
|
}
|
2019-10-16 12:36:26 +00:00
|
|
|
bitvec *paging_request = bitvec_alloc(22, tall_pcu_ctx);
|
2019-02-18 19:42:42 +00:00
|
|
|
bitvec_unhex(paging_request, DUMMY_VEC);
|
paging: pass struct osmo_mobile_identity, not encoded IE bytes
In get_paging_mi(), before this, an encoded buffer of Mobile Identity bytes is
returned. Code paths following this repeatedly decode the Mobile Identity
bytes, e.g. for logging. Also, in get_paging_mi(), since the TMSI is read in
from a different encoding than a typical Mobile Identity IE, the TMSI was
manually encoded into a typical Mobile Identity IE. This is essentially a code
dup of osmo_mobile_identity_encode(). Stop this madness.
Instead, in get_paging_mi(), return a decoded struct osmo_mobile_identity. Code
paths after this use the struct osmo_mobile_identity directly without repeated
decoding.
At the point of finally needing an encoded Mobile Identity IE (in
Encoding::write_paging_request()), do a proper osmo_mobile_identity_encode().
Since this may return errors, add an rc check for the caller of
write_paging_request(), gprs_rlcmac_paging_request().
A side effect is stricter validation of the Mobile Identity passing through the
Paging code path. Before, invalid MI might have passed through unnoticed.
Change-Id: Iad845acb0096b75dc453105c9c16b2252879b4ca
2020-08-21 14:21:23 +00:00
|
|
|
int plen = Encoding::write_paging_request(paging_request, mi);
|
|
|
|
if (plen <= 0) {
|
|
|
|
LOGP(DRLCMAC, LOGL_ERROR, "TX: [PCU -> BTS] Failed to encode Paging Request\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2021-06-24 15:01:41 +00:00
|
|
|
bts_do_rate_ctr_inc(bts, CTR_PCH_REQUESTS);
|
2021-01-18 16:14:14 +00:00
|
|
|
pcu_l1if_tx_pch(bts, paging_request, plen, pgroup);
|
2012-10-08 10:30:56 +00:00
|
|
|
bitvec_free(paging_request);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2013-05-13 14:45:21 +00:00
|
|
|
|
2019-09-05 15:13:33 +00:00
|
|
|
/* Encode Application Information Request to Packet Application Information (3GPP TS 44.060 11.2.47) */
|
|
|
|
struct msgb *gprs_rlcmac_app_info_msg(const struct gsm_pcu_if_app_info_req *req) {
|
|
|
|
struct msgb *msg;
|
|
|
|
uint16_t msgb_len = req->len + 1;
|
|
|
|
struct bitvec bv = {0, msgb_len, NULL};
|
|
|
|
const enum bit_value page_mode[] = {ZERO, ZERO}; /* Normal Paging (3GPP TS 44.060 12.20) */
|
2013-05-13 14:45:21 +00:00
|
|
|
|
2019-09-05 15:13:33 +00:00
|
|
|
if (!req->len) {
|
|
|
|
LOGP(DRLCMAC, LOGL_ERROR, "Application Information Request with zero length received!\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
msg = msgb_alloc(msgb_len, "app_info_msg");
|
|
|
|
if (!msg)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
bv.data = msgb_put(msg, msgb_len);
|
|
|
|
bitvec_set_bits(&bv, page_mode, 2);
|
|
|
|
bitvec_set_uint(&bv, req->application_type, 4);
|
|
|
|
bitvec_set_bytes(&bv, req->data, req->len);
|
|
|
|
return msg;
|
|
|
|
}
|