aboutsummaryrefslogtreecommitdiffstats
path: root/include/osmocom/gsm/gsm0411_utils.h
blob: f563158a8aa958323fe6f66b6254379b8dabd976 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef _GSM0411_UTILS_H
#define _GSM0411_UTILS_H

#include <time.h>
#include <osmocom/core/defs.h>

/* Default SMS validity period is 2 days */
#define SMS_DEFAULT_VALIDITY_PERIOD	(2 * 24 * 60 * 60)

/* Turn int into semi-octet representation: 98 => 0x89 */
uint8_t gsm411_bcdify(uint8_t value);

/* Turn semi-octet representation into int: 0x89 => 98 */
uint8_t gsm411_unbcdify(uint8_t value);

struct msgb *gsm411_msgb_alloc(void);

/* Generate 03.40 TP-SCTS */
void gsm340_gen_scts(uint8_t *scts, time_t time);

/* Decode 03.40 TP-SCTS (into utc/gmt timestamp) */
time_t gsm340_scts(uint8_t *scts);

/* decode validity period. return absolute time */
time_t gsm340_validity_time(time_t now, uint8_t sms_vpf, uint8_t *sms_vp);
/* decode validity period. return relative minutes */
unsigned long gsm340_validity_period(uint8_t sms_vpf, uint8_t *sms_vp)
	OSMO_DEPRECATED("Use gsm340_validity_time() instead.");

/* determine coding alphabet dependent on GSM 03.38 Section 4 DCS */
enum sms_alphabet gsm338_get_sms_alphabet(uint8_t dcs);

/* generate a TPDU address field compliant with 03.40 sec. 9.1.2.5 */
int gsm340_gen_oa(uint8_t *oa, unsigned int oa_len, uint8_t type,
	uint8_t plan, const char *number);

/* Prefix msg with a RP header */
int gsm411_push_rp_header(struct msgb *msg, uint8_t rp_msg_type,
	uint8_t rp_msg_ref);

/* Prefix msg with a 04.08/04.11 CP header */
int gsm411_push_cp_header(struct msgb *msg, uint8_t proto, uint8_t trans,
			     uint8_t msg_type);

#endif /* _GSM0411_UTILS_H */