blob: f6c36cadb7a5d7ad617b40293ffef0c6ad778e20 [file] [log] [blame]
Neels Hofmeyr17518fe2017-06-20 04:35:06 +02001/*! \file gsm_03_41.h
2 * GSM TS 03.41 definitions also TS 23.041. */
3
Sylvain Munaut12ba7782014-06-16 10:13:40 +02004#pragma once
Alex Badeaab1246e2010-11-27 23:35:08 +02005
6#include <stdint.h>
7
Ruben Undheim771a58f2015-12-09 20:22:42 +01008#include <osmocom/core/endian.h>
Harald Welte61ced832014-12-30 13:18:26 +01009#include <osmocom/gsm/protocol/gsm_04_12.h>
10
Ruben Undheim771a58f2015-12-09 20:22:42 +010011#ifndef OSMO_IS_LITTLE_ENDIAN
12 #define OSMO_IS_LITTLE_ENDIAN 0
13#endif
14
Harald Welte61ced832014-12-30 13:18:26 +010015#define GSM341_MAX_PAYLOAD (GSM412_MSG_LEN-sizeof(struct gsm341_ms_message))
16#define GSM341_MAX_CHARS (GSM341_MAX_PAYLOAD*8/7)
Harald Weltec13cf8b2014-12-30 13:25:44 +010017#define GSM341_7BIT_PADDING '\r'
Harald Welte61ced832014-12-30 13:18:26 +010018
Alex Badeaab1246e2010-11-27 23:35:08 +020019/* Chapter 9.3.2 */
20struct gsm341_ms_message {
21 struct {
Neels Hofmeyrb2600392018-11-16 00:20:39 +010022#if OSMO_IS_LITTLE_ENDIAN
Alex Badeaab1246e2010-11-27 23:35:08 +020023 uint8_t code_hi:6;
24 uint8_t gs:2;
Holger Hans Peter Freythera1e8bf72010-12-29 12:00:01 +010025 uint8_t update:4;
26 uint8_t code_lo:4;
Neels Hofmeyrb2600392018-11-16 00:20:39 +010027#elif OSMO_IS_BIG_ENDIAN
Oliver Smith0b5c09b2023-02-17 10:35:38 +010028/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */
Neels Hofmeyrb2600392018-11-16 00:20:39 +010029 uint8_t gs:2, code_hi:6;
30 uint8_t code_lo:4, update:4;
Ruben Undheim771a58f2015-12-09 20:22:42 +010031#endif
Alex Badeaab1246e2010-11-27 23:35:08 +020032 } serial;
33 uint16_t msg_id;
34 struct {
Neels Hofmeyrb2600392018-11-16 00:20:39 +010035#if OSMO_IS_LITTLE_ENDIAN
Alex Badeaab1246e2010-11-27 23:35:08 +020036 uint8_t language:4;
37 uint8_t group:4;
Neels Hofmeyrb2600392018-11-16 00:20:39 +010038#elif OSMO_IS_BIG_ENDIAN
Oliver Smith0b5c09b2023-02-17 10:35:38 +010039/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */
Neels Hofmeyrb2600392018-11-16 00:20:39 +010040 uint8_t group:4, language:4;
Ruben Undheim771a58f2015-12-09 20:22:42 +010041#endif
Alex Badeaab1246e2010-11-27 23:35:08 +020042 } dcs;
43 struct {
Neels Hofmeyrb2600392018-11-16 00:20:39 +010044#if OSMO_IS_LITTLE_ENDIAN
Alex Badeaab1246e2010-11-27 23:35:08 +020045 uint8_t total:4;
46 uint8_t current:4;
Neels Hofmeyrb2600392018-11-16 00:20:39 +010047#elif OSMO_IS_BIG_ENDIAN
Oliver Smith0b5c09b2023-02-17 10:35:38 +010048/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */
Neels Hofmeyrb2600392018-11-16 00:20:39 +010049 uint8_t current:4, total:4;
Ruben Undheim771a58f2015-12-09 20:22:42 +010050#endif
Alex Badeaab1246e2010-11-27 23:35:08 +020051 } page;
52 uint8_t data[0];
53} __attribute__((packed));
54
Holger Hans Peter Freyther9c559142010-12-29 21:14:20 +010055/* Chapter 9.4.1.3 */
56struct gsm341_etws_message {
57 struct {
Neels Hofmeyrb2600392018-11-16 00:20:39 +010058#if OSMO_IS_LITTLE_ENDIAN
Holger Hans Peter Freyther9c559142010-12-29 21:14:20 +010059 uint8_t code_hi:4;
60 uint8_t popup:1;
61 uint8_t alert:1;
62 uint8_t gs:2;
63 uint8_t update:4;
64 uint8_t code_lo:4;
Neels Hofmeyrb2600392018-11-16 00:20:39 +010065#elif OSMO_IS_BIG_ENDIAN
Oliver Smith0b5c09b2023-02-17 10:35:38 +010066/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */
Neels Hofmeyrb2600392018-11-16 00:20:39 +010067 uint8_t gs:2, alert:1, popup:1, code_hi:4;
68 uint8_t code_lo:4, update:4;
Ruben Undheim771a58f2015-12-09 20:22:42 +010069#endif
Holger Hans Peter Freyther9c559142010-12-29 21:14:20 +010070 } serial;
71 uint16_t msg_id;
72 uint16_t warning_type;
73 uint8_t data[0];
74} __attribute__((packed));
75
Alex Badead126ab92011-01-15 19:43:42 +020076#define GSM341_MSG_CODE(ms) ((ms)->serial.code_lo | ((ms)->serial.code_hi << 4))
Holger Hans Peter Freythere05c7df2010-12-29 11:57:48 +010077
Alex Badeaab1246e2010-11-27 23:35:08 +020078/* Section 9.3.2.1 - Geographical Scope */
79#define GSM341_GS_CELL_WIDE_IMMED 0
80#define GSM341_GS_PLMN_WIDE 1
81#define GSM341_GS_LA_WIDE 2
82#define GSM341_GS_CELL_WIDE 3
Harald Weltea19717a2014-12-29 13:14:01 +010083
84/* Section 9.4.1.2.2 */
85#define GSM341_MSGID_EOTD_ASSISTANCE 0x03E8
86#define GSM341_MSGID_DGPS_CORRECTION 0x03E9
87#define GSM341_MSGID_DGPS_EPH_CLOCK_COR 0x03EA
88#define GSM341_MSGID_GPS_ALMANAC_OTHER 0x03EB
89#define GSM341_MSGID_ETWS_EARTHQUAKE 0x1100
90#define GSM341_MSGID_ETWS_TSUNAMI 0x1101
91#define GSM341_MSGID_ETWS_QUAKE_AND_TSUNAMI 0x1102
92#define GSM341_MSGID_ETWS_TEST 0x1103
93#define GSM341_MSGID_ETWS_OTHER 0x1104
94#define GSM341_MSGID_ETWS_CMAS_PRESIDENTIAL 0x1112
95#define GSM341_MSGID_ETWS_CMAS_EXTREME_IMM_OBSERVED 0x1113
96#define GSM341_MSGID_ETWS_CMAS_EXTREME_IMM_LIKELY 0x1114
97#define GSM341_MSGID_ETWS_CMAS_EXTREME_EXP_OBSERVED 0x1115
98#define GSM341_MSGID_ETWS_CMAS_EXTREME_EXP_LIKELY 0x1116
99#define GSM341_MSGID_ETWS_CMAS_SEVERE_IMM_OBSERVED 0x1117
100#define GSM341_MSGID_ETWS_CMAS_SEVERE_IMM_LIKELY 0x1118
101#define GSM341_MSGID_ETWS_CMAS_SEVERE_EXP_OBSERVED 0x1119
102#define GSM341_MSGID_ETWS_CMAS_SEVERE_EXP_LIKELY 0x111A
103#define GSM341_MSGID_ETWS_CMAS_AMBER 0x111B
104#define GSM341_MSGID_ETWS_CMAS_MONTHLY_TEST 0x111C
105#define GSM341_MSGID_ETWS_CMAS_EXERCISE 0x111D
106#define GSM341_MSGID_ETWS_CMAS_OPERATOR_DEFINED 0x111E
107#define GSM341_MSGID_ETWS_CMAS_PRESIDENTIAL_AL 0x111F
108#define GSM341_MSGID_ETWS_CMAS_EXTREME_IMM_OBSERVED_AL 0x1120
109#define GSM341_MSGID_ETWS_CMAS_EXTREME_IMM_LIKELY_AL 0x1121
110#define GSM341_MSGID_ETWS_CMAS_EXTREME_EXP_OBSERVED_AL 0x1122
111#define GSM341_MSGID_ETWS_CMAS_EXTREME_EXP_LIKELY_AL 0x1123
112#define GSM341_MSGID_ETWS_CMAS_SEVERE_IMM_OBSERVED_AL 0x1124
113#define GSM341_MSGID_ETWS_CMAS_SEVERE_IMM_LIKELY_AL 0x1125
114#define GSM341_MSGID_ETWS_CMAS_SEVERE_EXP_OBSERVED_AL 0x1126
115#define GSM341_MSGID_ETWS_CMAS_SEVERE_EXP_LIKELY_AL 0x1127
116#define GSM341_MSGID_ETWS_CMAS_AMBER_AL 0x1128
117#define GSM341_MSGID_ETWS_CMAS_MONTHLY_TEST_AL 0x1129
118#define GSM341_MSGID_ETWS_CMAS_EXERCISE_AL 0x112A
119#define GSM341_MSGID_ETWS_CMAS_OPERATOR_DEFINED_AL 0x112B
120#define GSM341_MSGID_ETWS_EU_INFO_LOCAL_LANGUAGE 0x1900