blob: 40051cd4abaa55ecacb7b118952491dc82baf6cd [file] [log] [blame]
Sylvain Munaut12ba7782014-06-16 10:13:40 +02001#pragma once
Alex Badeaab1246e2010-11-27 23:35:08 +02002
3#include <stdint.h>
4
Ruben Undheim771a58f2015-12-09 20:22:42 +01005#include <osmocom/core/endian.h>
Harald Welte61ced832014-12-30 13:18:26 +01006#include <osmocom/gsm/protocol/gsm_04_12.h>
7
Ruben Undheim771a58f2015-12-09 20:22:42 +01008#ifndef OSMO_IS_LITTLE_ENDIAN
9 #define OSMO_IS_LITTLE_ENDIAN 0
10#endif
11
Holger Hans Peter Freythera1e8bf72010-12-29 12:00:01 +010012/* GSM TS 03.41 definitions also TS 23.041*/
Alex Badeaab1246e2010-11-27 23:35:08 +020013
Harald Welte61ced832014-12-30 13:18:26 +010014#define GSM341_MAX_PAYLOAD (GSM412_MSG_LEN-sizeof(struct gsm341_ms_message))
15#define GSM341_MAX_CHARS (GSM341_MAX_PAYLOAD*8/7)
Harald Weltec13cf8b2014-12-30 13:25:44 +010016#define GSM341_7BIT_PADDING '\r'
Harald Welte61ced832014-12-30 13:18:26 +010017
Alex Badeaab1246e2010-11-27 23:35:08 +020018/* Chapter 9.3.2 */
19struct gsm341_ms_message {
20 struct {
Ruben Undheim771a58f2015-12-09 20:22:42 +010021#if OSMO_IS_LITTLE_ENDIAN == 1
Alex Badeaab1246e2010-11-27 23:35:08 +020022 uint8_t code_hi:6;
23 uint8_t gs:2;
Holger Hans Peter Freythera1e8bf72010-12-29 12:00:01 +010024 uint8_t update:4;
25 uint8_t code_lo:4;
Ruben Undheim771a58f2015-12-09 20:22:42 +010026#else
27 uint8_t gs:2;
28 uint8_t code_hi:6;
29 uint8_t code_lo:4;
30 uint8_t update:4;
31#endif
Alex Badeaab1246e2010-11-27 23:35:08 +020032 } serial;
33 uint16_t msg_id;
34 struct {
Ruben Undheim771a58f2015-12-09 20:22:42 +010035#if OSMO_IS_LITTLE_ENDIAN == 1
Alex Badeaab1246e2010-11-27 23:35:08 +020036 uint8_t language:4;
37 uint8_t group:4;
Ruben Undheim771a58f2015-12-09 20:22:42 +010038#else
39 uint8_t group:4;
40 uint8_t language:4;
41#endif
Alex Badeaab1246e2010-11-27 23:35:08 +020042 } dcs;
43 struct {
Ruben Undheim771a58f2015-12-09 20:22:42 +010044#if OSMO_IS_LITTLE_ENDIAN == 1
Alex Badeaab1246e2010-11-27 23:35:08 +020045 uint8_t total:4;
46 uint8_t current:4;
Ruben Undheim771a58f2015-12-09 20:22:42 +010047#else
48 uint8_t current:4;
49 uint8_t total:4;
50#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 {
Ruben Undheim771a58f2015-12-09 20:22:42 +010058#if OSMO_IS_LITTLE_ENDIAN == 1
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;
Ruben Undheim771a58f2015-12-09 20:22:42 +010065#else
66 uint8_t gs:2;
67 uint8_t alert:1;
68 uint8_t popup:1;
69 uint8_t code_hi:4;
70 uint8_t code_lo:4;
71 uint8_t update:4;
72#endif
Holger Hans Peter Freyther9c559142010-12-29 21:14:20 +010073 } serial;
74 uint16_t msg_id;
75 uint16_t warning_type;
76 uint8_t data[0];
77} __attribute__((packed));
78
Alex Badead126ab92011-01-15 19:43:42 +020079#define GSM341_MSG_CODE(ms) ((ms)->serial.code_lo | ((ms)->serial.code_hi << 4))
Holger Hans Peter Freythere05c7df2010-12-29 11:57:48 +010080
Alex Badeaab1246e2010-11-27 23:35:08 +020081/* Section 9.3.2.1 - Geographical Scope */
82#define GSM341_GS_CELL_WIDE_IMMED 0
83#define GSM341_GS_PLMN_WIDE 1
84#define GSM341_GS_LA_WIDE 2
85#define GSM341_GS_CELL_WIDE 3
Harald Weltea19717a2014-12-29 13:14:01 +010086
87/* Section 9.4.1.2.2 */
88#define GSM341_MSGID_EOTD_ASSISTANCE 0x03E8
89#define GSM341_MSGID_DGPS_CORRECTION 0x03E9
90#define GSM341_MSGID_DGPS_EPH_CLOCK_COR 0x03EA
91#define GSM341_MSGID_GPS_ALMANAC_OTHER 0x03EB
92#define GSM341_MSGID_ETWS_EARTHQUAKE 0x1100
93#define GSM341_MSGID_ETWS_TSUNAMI 0x1101
94#define GSM341_MSGID_ETWS_QUAKE_AND_TSUNAMI 0x1102
95#define GSM341_MSGID_ETWS_TEST 0x1103
96#define GSM341_MSGID_ETWS_OTHER 0x1104
97#define GSM341_MSGID_ETWS_CMAS_PRESIDENTIAL 0x1112
98#define GSM341_MSGID_ETWS_CMAS_EXTREME_IMM_OBSERVED 0x1113
99#define GSM341_MSGID_ETWS_CMAS_EXTREME_IMM_LIKELY 0x1114
100#define GSM341_MSGID_ETWS_CMAS_EXTREME_EXP_OBSERVED 0x1115
101#define GSM341_MSGID_ETWS_CMAS_EXTREME_EXP_LIKELY 0x1116
102#define GSM341_MSGID_ETWS_CMAS_SEVERE_IMM_OBSERVED 0x1117
103#define GSM341_MSGID_ETWS_CMAS_SEVERE_IMM_LIKELY 0x1118
104#define GSM341_MSGID_ETWS_CMAS_SEVERE_EXP_OBSERVED 0x1119
105#define GSM341_MSGID_ETWS_CMAS_SEVERE_EXP_LIKELY 0x111A
106#define GSM341_MSGID_ETWS_CMAS_AMBER 0x111B
107#define GSM341_MSGID_ETWS_CMAS_MONTHLY_TEST 0x111C
108#define GSM341_MSGID_ETWS_CMAS_EXERCISE 0x111D
109#define GSM341_MSGID_ETWS_CMAS_OPERATOR_DEFINED 0x111E
110#define GSM341_MSGID_ETWS_CMAS_PRESIDENTIAL_AL 0x111F
111#define GSM341_MSGID_ETWS_CMAS_EXTREME_IMM_OBSERVED_AL 0x1120
112#define GSM341_MSGID_ETWS_CMAS_EXTREME_IMM_LIKELY_AL 0x1121
113#define GSM341_MSGID_ETWS_CMAS_EXTREME_EXP_OBSERVED_AL 0x1122
114#define GSM341_MSGID_ETWS_CMAS_EXTREME_EXP_LIKELY_AL 0x1123
115#define GSM341_MSGID_ETWS_CMAS_SEVERE_IMM_OBSERVED_AL 0x1124
116#define GSM341_MSGID_ETWS_CMAS_SEVERE_IMM_LIKELY_AL 0x1125
117#define GSM341_MSGID_ETWS_CMAS_SEVERE_EXP_OBSERVED_AL 0x1126
118#define GSM341_MSGID_ETWS_CMAS_SEVERE_EXP_LIKELY_AL 0x1127
119#define GSM341_MSGID_ETWS_CMAS_AMBER_AL 0x1128
120#define GSM341_MSGID_ETWS_CMAS_MONTHLY_TEST_AL 0x1129
121#define GSM341_MSGID_ETWS_CMAS_EXERCISE_AL 0x112A
122#define GSM341_MSGID_ETWS_CMAS_OPERATOR_DEFINED_AL 0x112B
123#define GSM341_MSGID_ETWS_EU_INFO_LOCAL_LANGUAGE 0x1900