libosmogsm  1.3.0.107-6370
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). Data here is *not* formatted
10  * like the * on-the-wire format. Any similarities are coincidetial ;) */
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  * You should have received a copy of the GNU General Public License along
29  * with this program; if not, write to the Free Software Foundation, Inc.,
30  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31  */
32 
33 /* Decoded 8.2.3 Message Content */
35  struct llist_head list;
36  uint8_t user_len;
37  uint8_t data[82];
38 };
39 
40 /* Decoded Entry in a 8.2.6 Cell List */
42  struct llist_head list; /* entry in osmo_cbsp_cell_list.list */
43  union gsm0808_cell_id_u cell_id;
44 };
46  enum CELL_IDENT id_discr;
47  struct llist_head list; /* list of osmo_cbsp_cell_ent */
48 };
49 
50 /* Decoded Entry in a 8.2.10 Completed List */
52  struct llist_head list; /* entry in osmo_cbsp_num_compl_list.list */
53  union gsm0808_cell_id_u cell_id;
54  uint16_t num_compl;
55  uint8_t num_bcast_info;
56 };
58  enum CELL_IDENT id_discr;
59  struct llist_head list; /* list of osmo_cbsp_num_compl_ent */
60 };
61 
62 /* Decoded Entry in a 8.2.12 Radio Resource Loading List */
64  struct llist_head list; /* entry in osmo_cbsp_loading_list */
65  union gsm0808_cell_id_u cell_id;
66  uint8_t load[2];
67 };
69  enum CELL_IDENT id_discr;
70  struct llist_head list; /* list of osmo_cbsp_loading_ent */
71 };
72 
73 /* Decoded Entry in a 8.2.11 Failure List */
75  struct llist_head list; /* entry in a fail_list below */
76  enum CELL_IDENT id_discr;
77  union gsm0808_cell_id_u cell_id;
78  uint8_t cause;
79 };
80 
81 
82 /* 8.1.3.1 */
84  uint16_t msg_id; /* 8.2.16 M */
85  uint16_t new_serial_nr; /* 8.2.5 M */
86  uint16_t *old_serial_nr; /* 8.2.4 */
87  struct osmo_cbsp_cell_list cell_list;
88 
89  bool is_cbs;
90  union {
91  struct {
92  enum cbsp_channel_ind channel_ind;
93  enum cbsp_category category;
94  uint16_t rep_period;
95  uint16_t num_bcast_req;
96  /* num_of_pages implicit as llist_count(msg_content) */
97  uint8_t dcs;
98  struct llist_head msg_content;
99  } cbs;
100  struct {
101  uint8_t indicator;
102  uint16_t warning_type;
103  uint8_t warning_sec_info[50];
104  uint32_t warning_period; /* in seconds; 0xffffffff = unlimited */
105  } emergency;
106  } u;
107 };
108 
109 /* 8.1.3.2 */
111  uint16_t msg_id;
112  uint16_t new_serial_nr;
113  uint16_t *old_serial_nr;
114  struct osmo_cbsp_num_compl_list num_compl_list;
115  struct osmo_cbsp_cell_list cell_list;
117 };
118 
119 /* 8.1.3.3 */
121  uint16_t msg_id;
122  uint16_t new_serial_nr;
123  uint16_t *old_serial_nr;
124  struct llist_head fail_list; /* list of osmo_cbsp_fail_ent */
125  struct osmo_cbsp_num_compl_list num_compl_list;
126  struct osmo_cbsp_cell_list cell_list;
128 };
129 
130 /* 8.1.3.4 */
132  uint16_t msg_id;
133  uint16_t old_serial_nr;
134  struct osmo_cbsp_cell_list cell_list;
136 };
137 
138 /* 8.1.3.5 */
140  uint16_t msg_id;
141  uint16_t old_serial_nr;
142  struct osmo_cbsp_num_compl_list num_compl_list;
143  struct osmo_cbsp_cell_list cell_list;
145 };
146 
147 /* 8.1.3.6 */
149  uint16_t msg_id;
150  uint16_t old_serial_nr;
151  struct llist_head fail_list; /* list of osmo_cbsp_fail_ent */
152  struct osmo_cbsp_num_compl_list num_compl_list;
153  struct osmo_cbsp_cell_list cell_list;
155 };
156 
157 /* 8.1.3.7 */
159  struct osmo_cbsp_cell_list cell_list;
160  enum cbsp_channel_ind channel_ind;
161 };
162 
163 /* 8.1.3.8 */
165  struct osmo_cbsp_loading_list loading_list;
166  enum cbsp_channel_ind channel_ind;
167 };
168 
169 /* 8.1.3.9 */
171  struct llist_head fail_list; /* list of osmo_cbsp_fail_ent */
172  enum cbsp_channel_ind channel_ind;
173  struct osmo_cbsp_loading_list loading_list;
174 };
175 
176 /* 8.1.3.10 */
178  uint16_t msg_id;
179  uint16_t old_serial_nr;
180  struct osmo_cbsp_cell_list cell_list;
181  enum cbsp_channel_ind channel_ind;
182 };
183 
184 /* 8.1.3.11 */
186  uint16_t msg_id;
187  uint16_t old_serial_nr;
188  struct osmo_cbsp_num_compl_list num_compl_list;
189  enum cbsp_channel_ind channel_ind;
190 };
191 
192 /* 8.1.3.12 */
194  uint16_t msg_id;
195  uint16_t old_serial_nr;
196  struct llist_head fail_list; /* list of osmo_cbsp_fail_ent */
197  enum cbsp_channel_ind channel_ind;
198  struct osmo_cbsp_num_compl_list num_compl_list;
199 };
200 
201 /* 8.1.3.16 */
203  struct osmo_cbsp_cell_list cell_list;
204 };
205 
206 /* 8.1.3.17 */
208  struct osmo_cbsp_cell_list cell_list;
209 };
210 
211 /* 8.1.3.18 */
213  struct llist_head fail_list; /* list of osmo_cbsp_fail_ent */
214  struct osmo_cbsp_cell_list cell_list;
215 };
216 
217 /* 8.1.3.18a */
220 };
221 
222 /* 8.1.3.18b */
224 };
225 
226 /* 8.1.3.19 */
228  struct osmo_cbsp_cell_list cell_list;
229  uint8_t bcast_msg_type;
230  uint8_t recovery_ind;
231 };
232 
233 /* 8.1.3.20 */
235  struct llist_head fail_list; /* list of osmo_cbsp_fail_ent */
236  uint8_t bcast_msg_type;
237 };
238 
239 /* 8.1.3.21 */
242  uint16_t *msg_id;
243  uint16_t *new_serial_nr;
244  uint16_t *old_serial_nr;
246 };
247 
248 
249 /* decoded CBSP message */
252  union {
253  struct osmo_cbsp_write_replace write_replace;
254  struct osmo_cbsp_write_replace_complete write_replace_compl;
255  struct osmo_cbsp_write_replace_failure write_replace_fail;
256 
257  struct osmo_cbsp_kill kill;
258  struct osmo_cbsp_kill_complete kill_compl;
259  struct osmo_cbsp_kill_failure kill_fail;
260 
261  struct osmo_cbsp_load_query load_query;
262  struct osmo_cbsp_load_query_complete load_query_compl;
263  struct osmo_cbsp_load_query_failure load_query_fail;
264 
265  struct osmo_cbsp_msg_status_query msg_status_query;
266  struct osmo_cbsp_msg_status_query_complete msg_status_query_compl;
267  struct osmo_cbsp_msg_status_query_failure msg_status_query_fail;
268 
269  /* TODO: set DRX */
270 
271  struct osmo_cbsp_reset reset;
272  struct osmo_cbsp_reset_complete reset_compl;
273  struct osmo_cbsp_reset_failure reset_fail;
274 
275  struct osmo_cbsp_restart restart;
276 
277  struct osmo_cbsp_failure failure;
278 
279  struct osmo_cbsp_error_ind error_ind;
280 
281  struct osmo_cbsp_keep_alive keep_alive;
282  struct osmo_cbsp_keep_alive_complete keep_alive_compl;
283  } u;
284 };
285 
286 extern const __thread char *osmo_cbsp_errstr;
287 
288 struct msgb *osmo_cbsp_msgb_alloc(void *ctx, const char *name);
289 struct msgb *osmo_cbsp_encode(void *ctx, const struct osmo_cbsp_decoded *in);
290 struct osmo_cbsp_decoded *osmo_cbsp_decode(void *ctx, struct msgb *in);
293 
294 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:589
int osmo_cbsp_recv_buffered(void *ctx, int fd, struct msgb **rmsg, struct msgb **tmp_msg)
Definition: cbsp.h:110
Definition: cbsp.h:212
Definition: cbsp.h:177
Definition: cbsp.h:83
const __thread char * osmo_cbsp_errstr
Definition: cbsp.c:36
enum cbsp_channel_ind * channel_ind
Definition: cbsp.h:144
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:397
uint8_t warning_sec_info[50]
Definition: gsm_23_041.h:801
struct llist_head list
Definition: cbsp.h:35
uint8_t recovery_ind
Definition: cbsp.h:230
uint8_t num_bcast_info
Definition: cbsp.h:55
Definition: cbsp.h:34
uint16_t * msg_id
Definition: cbsp.h:242
uint16_t old_serial_nr
Definition: cbsp.h:187
Definition: cbsp.h:74
enum cbsp_channel_ind * channel_ind
Definition: cbsp.h:116
Definition: cbsp.h:227
uint16_t new_serial_nr
Definition: cbsp.h:122
uint8_t bcast_msg_type
Definition: cbsp.h:236
Definition: cbsp.h:120
uint16_t msg_id
Definition: cbsp.h:149
uint16_t num_bcast_req
Definition: cbsp.h:95
enum cbsp_channel_ind * channel_ind
Definition: cbsp.h:154
Definition: cbsp.h:139
Instead of this, use either struct gsm0808_cell_id or gsm0808_cell_id_list2.
Definition: gsm0808_utils.h:41
void osmo_cbsp_init_struct(struct osmo_cbsp_decoded *cbsp, enum cbsp_msg_type msg_type)
Definition: cbsp.c:1287
Definition: cbsp.h:164
uint8_t cause
Definition: gsm_04_08.h:589
Definition: cbsp.h:234
uint16_t msg_id
Definition: cbsp.h:140
Definition: cbsp.h:158
Definition: cbsp.h:148
Definition: cbsp.h:131
cbsp_msg_type
Definition: gsm_48_049.h:50
uint16_t msg_id
Definition: cbsp.h:121
uint16_t * old_serial_nr
Definition: cbsp.h:86
uint16_t old_serial_nr
Definition: cbsp.h:150
uint16_t new_serial_nr
Definition: cbsp.h:112
Definition: cbsp.h:170
uint16_t msg_id
Definition: cbsp.h:186
uint16_t * old_serial_nr
Definition: cbsp.h:244
enum cbsp_channel_ind * channel_ind
Definition: cbsp.h:127
bool is_cbs
Definition: cbsp.h:89
Definition: cbsp.h:223
uint16_t msg_id
Definition: cbsp.h:178
Definition: cbsp.h:250
uint16_t * old_serial_nr
Definition: cbsp.h:113
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:1169
uint16_t old_serial_nr
Definition: cbsp.h:133
Definition: cbsp.h:63
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:1361
uint32_t warning_period
Definition: cbsp.h:104
cbsp_category
Definition: gsm_48_049.h:77
uint16_t rep_period
Definition: cbsp.h:94
Definition: cbsp.h:51
uint8_t user_len
Definition: cbsp.h:36
uint16_t * new_serial_nr
Definition: cbsp.h:243
uint8_t bcast_msg_type
Definition: cbsp.h:229
uint8_t dcs
Definition: cbsp.h:97
cbsp_cell_id_cause
Definition: gsm_48_049.h:94
Definition: cbsp.h:240
uint8_t repetition_period
Definition: cbsp.h:219
Definition: cbsp.h:218
enum cbsp_channel_ind * channel_ind
Definition: cbsp.h:245
Definition: cbsp.h:57
enum cbsp_channel_ind * channel_ind
Definition: cbsp.h:135
Definition: cbsp.h:41
uint16_t msg_id
Definition: cbsp.h:194
uint16_t * old_serial_nr
Definition: cbsp.h:123
cbsp_channel_ind
Definition: gsm_48_049.h:114
uint16_t msg_id
Definition: cbsp.h:84
uint16_t msg_id
Definition: cbsp.h:111
Definition: cbsp.h:202
Definition: cbsp.h:45
CELL_IDENT
Definition: gsm_08_08.h:17
uint16_t old_serial_nr
Definition: cbsp.h:179
uint16_t old_serial_nr
Definition: cbsp.h:141
uint8_t indicator
Definition: cbsp.h:101
struct msgb * osmo_cbsp_msgb_alloc(void *ctx, const char *name)
Definition: cbsp.c:38
uint16_t warning_type
Definition: cbsp.h:102
uint16_t num_compl
Definition: cbsp.h:54
uint8_t data[82]
Definition: cbsp.h:37
Definition: cbsp.h:207
Definition: cbsp.h:68
uint8_t cause
Definition: cbsp.h:78
uint16_t msg_id
Definition: cbsp.h:132
uint16_t new_serial_nr
Definition: cbsp.h:85
uint16_t old_serial_nr
Definition: cbsp.h:195