libosmogsm  1.9.0.20-4ca0f.202310292026
Osmocom GSM library
cbsp.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <stdint.h>
7 
8 /* Definitions for parsed / abstract representation of messages in the
9  * CBSP (Cell Broadcast Service Protocol, 3GPP TS 48.049). Data here is *not* formatted
10  * like the on-the-wire format. Any similarities are coincidential ;) */
11 
12 /* Copyright (C) 2019 Harald Welte <laforge@gnumonks.org>
13  *
14  * All Rights Reserved
15  *
16  * SPDX-License-Identifier: GPL-2.0+
17  *
18  * This program is free software; you can redistribute it and/or modify
19  * it under the terms of the GNU General Public License as published by
20  * the Free Software Foundation; either version 2 of the License, or
21  * (at your option) any later version.
22  *
23  * This program is distributed in the hope that it will be useful,
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26  * GNU General Public License for more details.
27  */
28 
29 /* Decoded 8.2.3 Message Content */
31  struct llist_head list;
32  uint8_t user_len;
33  uint8_t data[82];
34 };
35 
36 /* Decoded Entry in a 8.2.6 Cell List */
38  struct llist_head list; /* entry in osmo_cbsp_cell_list.list */
39  union gsm0808_cell_id_u cell_id;
40 };
42  enum CELL_IDENT id_discr;
43  struct llist_head list; /* list of osmo_cbsp_cell_ent */
44 };
45 
46 /* Decoded Entry in a 8.2.10 Completed List */
48  struct llist_head list; /* entry in osmo_cbsp_num_compl_list.list */
49  union gsm0808_cell_id_u cell_id;
50  uint16_t num_compl;
51  uint8_t num_bcast_info;
52 };
54  enum CELL_IDENT id_discr;
55  struct llist_head list; /* list of osmo_cbsp_num_compl_ent */
56 };
57 
58 /* Decoded Entry in a 8.2.12 Radio Resource Loading List */
60  struct llist_head list; /* entry in osmo_cbsp_loading_list */
61  union gsm0808_cell_id_u cell_id;
62  uint8_t load[2];
63 };
65  enum CELL_IDENT id_discr;
66  struct llist_head list; /* list of osmo_cbsp_loading_ent */
67 };
68 
69 /* Decoded Entry in a 8.2.11 Failure List */
71  struct llist_head list; /* entry in a fail_list below */
72  enum CELL_IDENT id_discr;
73  union gsm0808_cell_id_u cell_id;
74  uint8_t cause; /* enum osmo_cbsp_cause */
75 };
76 
77 
78 /* 8.1.3.1 */
80  uint16_t msg_id; /* 8.2.16 M */
81  uint16_t new_serial_nr; /* 8.2.5 M */
82  uint16_t *old_serial_nr; /* 8.2.4 */
83  struct osmo_cbsp_cell_list cell_list;
84 
85  bool is_cbs;
86  union {
87  struct {
88  enum cbsp_channel_ind channel_ind;
89  enum cbsp_category category;
90  uint16_t rep_period;
91  uint16_t num_bcast_req;
92  /* num_of_pages implicit as llist_count(msg_content) */
93  uint8_t dcs;
94  struct llist_head msg_content;
95  } cbs;
96  struct {
97  uint8_t indicator;
98  uint16_t warning_type;
99  uint8_t warning_sec_info[50];
100  uint32_t warning_period; /* in seconds; 0xffffffff = unlimited */
101  } emergency;
102  } u;
103 };
104 
105 /* 8.1.3.2 */
107  uint16_t msg_id;
108  uint16_t new_serial_nr;
109  uint16_t *old_serial_nr;
110  struct osmo_cbsp_num_compl_list num_compl_list;
111  struct osmo_cbsp_cell_list cell_list;
113 };
114 
115 /* 8.1.3.3 */
117  uint16_t msg_id;
118  uint16_t new_serial_nr;
119  uint16_t *old_serial_nr;
120  struct llist_head fail_list; /* list of osmo_cbsp_fail_ent */
121  struct osmo_cbsp_num_compl_list num_compl_list;
122  struct osmo_cbsp_cell_list cell_list;
124 };
125 
126 /* 8.1.3.4 */
128  uint16_t msg_id;
129  uint16_t old_serial_nr;
130  struct osmo_cbsp_cell_list cell_list;
132 };
133 
134 /* 8.1.3.5 */
136  uint16_t msg_id;
137  uint16_t old_serial_nr;
138  struct osmo_cbsp_num_compl_list num_compl_list;
139  struct osmo_cbsp_cell_list cell_list;
141 };
142 
143 /* 8.1.3.6 */
145  uint16_t msg_id;
146  uint16_t old_serial_nr;
147  struct llist_head fail_list; /* list of osmo_cbsp_fail_ent */
148  struct osmo_cbsp_num_compl_list num_compl_list;
149  struct osmo_cbsp_cell_list cell_list;
151 };
152 
153 /* 8.1.3.7 */
155  struct osmo_cbsp_cell_list cell_list;
156  enum cbsp_channel_ind channel_ind;
157 };
158 
159 /* 8.1.3.8 */
161  struct osmo_cbsp_loading_list loading_list;
162  enum cbsp_channel_ind channel_ind;
163 };
164 
165 /* 8.1.3.9 */
167  struct llist_head fail_list; /* list of osmo_cbsp_fail_ent */
168  enum cbsp_channel_ind channel_ind;
169  struct osmo_cbsp_loading_list loading_list;
170 };
171 
172 /* 8.1.3.10 */
174  uint16_t msg_id;
175  uint16_t old_serial_nr;
176  struct osmo_cbsp_cell_list cell_list;
177  enum cbsp_channel_ind channel_ind;
178 };
179 
180 /* 8.1.3.11 */
182  uint16_t msg_id;
183  uint16_t old_serial_nr;
184  struct osmo_cbsp_num_compl_list num_compl_list;
185  enum cbsp_channel_ind channel_ind;
186 };
187 
188 /* 8.1.3.12 */
190  uint16_t msg_id;
191  uint16_t old_serial_nr;
192  struct llist_head fail_list; /* list of osmo_cbsp_fail_ent */
193  enum cbsp_channel_ind channel_ind;
194  struct osmo_cbsp_num_compl_list num_compl_list;
195 };
196 
197 /* 8.1.3.16 */
199  struct osmo_cbsp_cell_list cell_list;
200 };
201 
202 /* 8.1.3.17 */
204  struct osmo_cbsp_cell_list cell_list;
205 };
206 
207 /* 8.1.3.18 */
209  struct llist_head fail_list; /* list of osmo_cbsp_fail_ent */
210  struct osmo_cbsp_cell_list cell_list;
211 };
212 
213 /* 8.1.3.18a */
216 };
217 
218 /* 8.1.3.18b */
220 };
221 
222 /* 8.1.3.19 */
224  struct osmo_cbsp_cell_list cell_list;
225  uint8_t bcast_msg_type;
226  uint8_t recovery_ind;
227 };
228 
229 /* 8.1.3.20 */
231  struct llist_head fail_list; /* list of osmo_cbsp_fail_ent */
232  uint8_t bcast_msg_type;
233 };
234 
235 /* 8.1.3.21 */
238  uint16_t *msg_id;
239  uint16_t *new_serial_nr;
240  uint16_t *old_serial_nr;
242 };
243 
244 /* 8.2.13 Cause */
262 };
263 extern const struct value_string osmo_cbsp_cause_names[];
264 static inline const char *osmo_cbsp_cause_name(enum osmo_cbsp_cause cause)
265 {
267 }
268 
269 /* decoded CBSP message */
272  union {
273  struct osmo_cbsp_write_replace write_replace;
274  struct osmo_cbsp_write_replace_complete write_replace_compl;
275  struct osmo_cbsp_write_replace_failure write_replace_fail;
276 
277  struct osmo_cbsp_kill kill;
278  struct osmo_cbsp_kill_complete kill_compl;
279  struct osmo_cbsp_kill_failure kill_fail;
280 
281  struct osmo_cbsp_load_query load_query;
282  struct osmo_cbsp_load_query_complete load_query_compl;
283  struct osmo_cbsp_load_query_failure load_query_fail;
284 
285  struct osmo_cbsp_msg_status_query msg_status_query;
286  struct osmo_cbsp_msg_status_query_complete msg_status_query_compl;
287  struct osmo_cbsp_msg_status_query_failure msg_status_query_fail;
288 
289  /* TODO: set DRX */
290 
291  struct osmo_cbsp_reset reset;
292  struct osmo_cbsp_reset_complete reset_compl;
293  struct osmo_cbsp_reset_failure reset_fail;
294 
295  struct osmo_cbsp_restart restart;
296 
297  struct osmo_cbsp_failure failure;
298 
299  struct osmo_cbsp_error_ind error_ind;
300 
301  struct osmo_cbsp_keep_alive keep_alive;
302  struct osmo_cbsp_keep_alive_complete keep_alive_compl;
303  } u;
304 };
305 
306 extern __thread const char *osmo_cbsp_errstr;
307 
308 struct msgb *osmo_cbsp_msgb_alloc(void *ctx, const char *name);
309 struct msgb *osmo_cbsp_encode(void *ctx, const struct osmo_cbsp_decoded *in);
310 struct osmo_cbsp_decoded *osmo_cbsp_decode(void *ctx, struct msgb *in);
313 
314 int osmo_cbsp_recv_buffered(void *ctx, int fd, struct msgb **rmsg, struct msgb **tmp_msg);
uint8_t msg_type
Definition: gsm_04_08.h:808
int osmo_cbsp_recv_buffered(void *ctx, int fd, struct msgb **rmsg, struct msgb **tmp_msg)
Definition: cbsp.h:106
Definition: cbsp.h:208
Definition: cbsp.h:173
Definition: cbsp.h:79
enum cbsp_channel_ind * channel_ind
Definition: cbsp.h:140
struct msgb * osmo_cbsp_encode(void *ctx, const struct osmo_cbsp_decoded *in)
Encode a CBSP message from the decoded/parsed structure representation to binary PDU.
Definition: cbsp.c:402
const char * get_value_string(const struct value_string *vs, uint32_t val)
uint8_t warning_sec_info[50]
Definition: gsm_23_041.h:962
struct llist_head list
Definition: cbsp.h:31
uint8_t recovery_ind
Definition: cbsp.h:226
uint8_t num_bcast_info
Definition: cbsp.h:51
Definition: cbsp.h:30
uint16_t * msg_id
Definition: cbsp.h:238
uint16_t old_serial_nr
Definition: cbsp.h:183
Definition: cbsp.h:70
enum cbsp_channel_ind * channel_ind
Definition: cbsp.h:112
Definition: cbsp.h:223
uint16_t new_serial_nr
Definition: cbsp.h:118
uint8_t bcast_msg_type
Definition: cbsp.h:232
Definition: cbsp.h:116
uint16_t msg_id
Definition: cbsp.h:145
uint16_t num_bcast_req
Definition: cbsp.h:91
enum cbsp_channel_ind * channel_ind
Definition: cbsp.h:150
Definition: cbsp.h:135
Instead of this, use either struct gsm0808_cell_id or gsm0808_cell_id_list2.
Definition: gsm0808_utils.h:43
void osmo_cbsp_init_struct(struct osmo_cbsp_decoded *cbsp, enum cbsp_msg_type msg_type)
Definition: cbsp.c:1381
Definition: cbsp.h:160
uint8_t cause
Definition: gsm_04_08.h:808
Definition: cbsp.h:230
uint16_t msg_id
Definition: cbsp.h:136
Definition: cbsp.h:154
Definition: cbsp.h:144
Definition: cbsp.h:127
cbsp_msg_type
Definition: gsm_48_049.h:50
uint16_t msg_id
Definition: cbsp.h:117
uint16_t * old_serial_nr
Definition: cbsp.h:82
uint16_t old_serial_nr
Definition: cbsp.h:146
uint16_t new_serial_nr
Definition: cbsp.h:108
Definition: cbsp.h:166
uint16_t msg_id
Definition: cbsp.h:182
uint16_t * old_serial_nr
Definition: cbsp.h:240
enum cbsp_channel_ind * channel_ind
Definition: cbsp.h:123
bool is_cbs
Definition: cbsp.h:85
Definition: cbsp.h:219
uint16_t msg_id
Definition: cbsp.h:174
Definition: cbsp.h:270
uint16_t * old_serial_nr
Definition: cbsp.h:109
struct osmo_cbsp_decoded * osmo_cbsp_decode(void *ctx, struct msgb *in)
Decode a CBSP message from wire formwat to pased structure.
Definition: cbsp.c:1262
uint16_t old_serial_nr
Definition: cbsp.h:129
Definition: cbsp.h:59
struct osmo_cbsp_decoded * osmo_cbsp_decoded_alloc(void *ctx, enum cbsp_msg_type msg_type)
Dynamically allocate and initialize decoded CBSP structure.
Definition: cbsp.c:1455
uint32_t warning_period
Definition: cbsp.h:100
cbsp_category
Definition: gsm_48_049.h:77
uint16_t rep_period
Definition: cbsp.h:90
Definition: cbsp.h:47
uint8_t user_len
Definition: cbsp.h:32
uint16_t * new_serial_nr
Definition: cbsp.h:239
Definition: cbsp.h:249
uint8_t bcast_msg_type
Definition: cbsp.h:225
uint8_t dcs
Definition: cbsp.h:93
osmo_cbsp_cause
Definition: cbsp.h:245
cbsp_cell_id_cause
Definition: gsm_48_049.h:94
Definition: cbsp.h:236
uint8_t repetition_period
Definition: cbsp.h:215
Definition: cbsp.h:214
enum cbsp_channel_ind * channel_ind
Definition: cbsp.h:241
Definition: cbsp.h:53
enum cbsp_channel_ind * channel_ind
Definition: cbsp.h:131
Definition: cbsp.h:37
uint16_t msg_id
Definition: cbsp.h:190
uint16_t * old_serial_nr
Definition: cbsp.h:119
cbsp_channel_ind
Definition: gsm_48_049.h:114
uint16_t msg_id
Definition: cbsp.h:80
static const char * osmo_cbsp_cause_name(enum osmo_cbsp_cause cause)
Definition: cbsp.h:264
uint16_t msg_id
Definition: cbsp.h:107
Definition: cbsp.h:198
Definition: cbsp.h:41
CELL_IDENT
Definition: gsm_08_08.h:17
uint16_t old_serial_nr
Definition: cbsp.h:175
uint16_t old_serial_nr
Definition: cbsp.h:137
uint8_t indicator
Definition: cbsp.h:97
struct msgb * osmo_cbsp_msgb_alloc(void *ctx, const char *name)
Definition: cbsp.c:35
const struct value_string osmo_cbsp_cause_names[]
uint16_t warning_type
Definition: cbsp.h:98
uint16_t num_compl
Definition: cbsp.h:50
uint8_t data[82]
Definition: cbsp.h:33
Definition: cbsp.h:203
Definition: cbsp.h:260
Definition: cbsp.h:64
uint8_t cause
Definition: cbsp.h:74
uint16_t msg_id
Definition: cbsp.h:128
uint16_t new_serial_nr
Definition: cbsp.h:81
__thread const char * osmo_cbsp_errstr
Definition: cbsp.c:33
uint16_t old_serial_nr
Definition: cbsp.h:191