From 96efd189ccab412b0f42bf4564c72359ef358a1c Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Sat, 27 Dec 2014 19:33:23 +0100 Subject: wip... --- src/common/Makefile.am | 3 +- src/common/etws_p1.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 src/common/etws_p1.c diff --git a/src/common/Makefile.am b/src/common/Makefile.am index 10627e2a..77395020 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -7,4 +7,5 @@ libbts_a_SOURCES = gsm_data_shared.c sysinfo.c logging.c abis.c oml.c bts.c \ rsl.c vty.c paging.c measurement.c amr.c lchan.c \ load_indication.c pcu_sock.c handover.c msg_utils.c \ load_indication.c pcu_sock.c handover.c msg_utils.c \ - tx_power.c bts_ctrl_commands.c bts_ctrl_lookup.c + tx_power.c bts_ctrl_commands.c bts_ctrl_lookup.c \ + etws_p1.c diff --git a/src/common/etws_p1.c b/src/common/etws_p1.c new file mode 100644 index 00000000..47642e4d --- /dev/null +++ b/src/common/etws_p1.c @@ -0,0 +1,106 @@ +/* Paging Rest Octets / ETWS support code */ +/* + * (C) 2014 by Harald Welte + * + * All Rights Reserved + * + * 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. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include +#include + +/*! \brief construct the Paging 1 Rest Octets + * \param[in] bitvec Bit Vector (destionation) + * \param[in] seg_nr segment number 0...n + * \param[in] num_segs total number of segments + * \param[in] payload binary payload for this segment + * \param[in] len_of_seg length of the segment + * + * Put together the P1 Rest Octets according to 10.5.2.23 + */ +int construct_p1_rest_octets(struct bitvec *bv, int etws_will_follow) +{ + + /* no NLN */ + bitvec_set_bit(bv, L); + /* no Priority 1 */ + bitvec_set_bit(bv, L); + /* no Priority 2 */ + bitvec_set_bit(bv, L); + /* Packet Page Indication 1 */ + bitvec_set_bit(bv, L); + /* Packet Page Indication 2 */ + bitvec_set_bit(bv, L); + + /* No Rel6 extensions */ + bitvec_set_bit(bv, L); + + /* No Rel7 extensions */ + bitvec_set_bit(bv, L); + + /* Rel8 extensions */ + bitvec_set_bit(bv, H); + + /* priority_uplink_access bit: Use RACH */ + bitvec_set_bit(bv, L); + + if (etws_will_follow) { + /* We do have ETWS Primary Notification */ + bitvec_set_bit(bv, ONE); + } else { + bitvec_set_bit(bv, ZERO); + } + + return 0; +} + +/*! \brief construct a ETWS Primary Notification struct + * \param[in] bitvec Bit Vector (destionation) + * \param[in] pni Primary Notification Identifier + * \param[in] seg_nr Segment Number 0...n + * \param[in] num_segs Total Number of Segments + * \param[in] payload Binary Payload for this Segment + * \param[in] num_payload_bits Length of the Segment + */ +int construct_etws_prim_notif(struct bitvec *bv, uint8_t pni, + uint8_t seg_nr, uint8_t num_segs, + const uint8_t *payload, + uint8_t num_payload_bits) +{ + uint8_t payload_ubits[num_payload_bits]; + + /* Put together a "ETWS Primary Notification struct" as per TS + * 44.018 */ + + if (seg_nr == 0) { + bitvec_set_bit(bv, ZERO); + bitvec_set_uint(bv, num_segs, 4); + } else { + bitvec_set_bit(bv, ONE); + /* seg_nr is coounting 1..n, not 0..n */ + bitvec_set_uint(bv, seg_nr + 1, 4); + } + bitvec_set_bit(bv, pni ? ONE : ZERO); + bitvec_set_uint(bv, num_payload_bits, 7); + + /* expand packed payload bits to unpacked bits and set them in + * the bit vector */ + osmo_pbit2ubit(payload_ubits, payload, num_payload_bits); + bitvec_set_bits(bv, (enum bit_value *) payload_ubits, num_payload_bits); + + return 0; +} -- cgit v1.2.3