blob: 4768283f3f4144152e9f356c18516a487aa1891a [file] [log] [blame]
Neels Hofmeyr17518fe2017-06-20 04:35:06 +02001/*! \file gsm48_ie.h */
2
Sylvain Munaut12ba7782014-06-16 10:13:40 +02003#pragma once
Harald Welte1e908662010-03-07 23:39:54 +01004
5#include <stdint.h>
6#include <string.h>
7#include <errno.h>
8
Pablo Neira Ayuso83419342011-03-22 16:36:13 +01009#include <osmocom/core/msgb.h>
Vadim Yanitskiy87b51432019-11-07 22:15:13 +070010#include <osmocom/core/defs.h>
Pablo Neira Ayuso83419342011-03-22 16:36:13 +010011#include <osmocom/gsm/tlv.h>
12#include <osmocom/gsm/mncc.h>
13#include <osmocom/gsm/protocol/gsm_04_08.h>
Harald Welte1e908662010-03-07 23:39:54 +010014
15/* decode a 'called/calling/connect party BCD number' as in 10.5.4.7 */
16int gsm48_decode_bcd_number(char *output, int output_len,
Neels Hofmeyr8212fc62019-04-01 14:34:37 +020017 const uint8_t *bcd_lv, int h_len)
Vadim Yanitskiy87b51432019-11-07 22:15:13 +070018 OSMO_DEPRECATED_OUTSIDE("Use gsm48_decode_bcd_number2() for improved bounds checking");
Neels Hofmeyr8212fc62019-04-01 14:34:37 +020019int gsm48_decode_bcd_number2(char *output, size_t output_len,
20 const uint8_t *bcd_lv, size_t input_len,
21 size_t h_len);
Harald Welte1e908662010-03-07 23:39:54 +010022
23/* convert a ASCII phone number to 'called/calling/connect party BCD number' */
24int gsm48_encode_bcd_number(uint8_t *bcd_lv, uint8_t max_len,
25 int h_len, const char *input);
26/* decode 'bearer capability' */
27int gsm48_decode_bearer_cap(struct gsm_mncc_bearer_cap *bcap,
28 const uint8_t *lv);
29/* encode 'bearer capability' */
30int gsm48_encode_bearer_cap(struct msgb *msg, int lv_only,
31 const struct gsm_mncc_bearer_cap *bcap);
32/* decode 'call control cap' */
33int gsm48_decode_cccap(struct gsm_mncc_cccap *ccap, const uint8_t *lv);
34/* encode 'call control cap' */
35int gsm48_encode_cccap(struct msgb *msg,
36 const struct gsm_mncc_cccap *ccap);
37/* decode 'called party BCD number' */
38int gsm48_decode_called(struct gsm_mncc_number *called,
39 const uint8_t *lv);
40/* encode 'called party BCD number' */
41int gsm48_encode_called(struct msgb *msg,
42 const struct gsm_mncc_number *called);
43/* decode callerid of various IEs */
44int gsm48_decode_callerid(struct gsm_mncc_number *callerid,
45 const uint8_t *lv);
46/* encode callerid of various IEs */
47int gsm48_encode_callerid(struct msgb *msg, int ie, int max_len,
48 const struct gsm_mncc_number *callerid);
49/* decode 'cause' */
50int gsm48_decode_cause(struct gsm_mncc_cause *cause,
51 const uint8_t *lv);
52/* encode 'cause' */
53int gsm48_encode_cause(struct msgb *msg, int lv_only,
54 const struct gsm_mncc_cause *cause);
55/* decode 'calling number' */
56int gsm48_decode_calling(struct gsm_mncc_number *calling,
57 const uint8_t *lv);
58/* encode 'calling number' */
59int gsm48_encode_calling(struct msgb *msg,
60 const struct gsm_mncc_number *calling);
61/* decode 'connected number' */
62int gsm48_decode_connected(struct gsm_mncc_number *connected,
63 const uint8_t *lv);
64/* encode 'connected number' */
65int gsm48_encode_connected(struct msgb *msg,
66 const struct gsm_mncc_number *connected);
67/* decode 'redirecting number' */
68int gsm48_decode_redirecting(struct gsm_mncc_number *redirecting,
69 const uint8_t *lv);
70/* encode 'redirecting number' */
71int gsm48_encode_redirecting(struct msgb *msg,
72 const struct gsm_mncc_number *redirecting);
73/* decode 'facility' */
74int gsm48_decode_facility(struct gsm_mncc_facility *facility,
75 const uint8_t *lv);
76/* encode 'facility' */
77int gsm48_encode_facility(struct msgb *msg, int lv_only,
78 const struct gsm_mncc_facility *facility);
79/* decode 'notify' */
80int gsm48_decode_notify(int *notify, const uint8_t *v);
81/* encode 'notify' */
82int gsm48_encode_notify(struct msgb *msg, int notify);
83/* decode 'signal' */
84int gsm48_decode_signal(int *signal, const uint8_t *v);
85/* encode 'signal' */
86int gsm48_encode_signal(struct msgb *msg, int signal);
87/* decode 'keypad' */
88int gsm48_decode_keypad(int *keypad, const uint8_t *lv);
89/* encode 'keypad' */
90int gsm48_encode_keypad(struct msgb *msg, int keypad);
91/* decode 'progress' */
92int gsm48_decode_progress(struct gsm_mncc_progress *progress,
93 const uint8_t *lv);
94/* encode 'progress' */
95int gsm48_encode_progress(struct msgb *msg, int lv_only,
96 const struct gsm_mncc_progress *p);
97/* decode 'user-user' */
98int gsm48_decode_useruser(struct gsm_mncc_useruser *uu,
99 const uint8_t *lv);
100/* encode 'useruser' */
101int gsm48_encode_useruser(struct msgb *msg, int lv_only,
102 const struct gsm_mncc_useruser *uu);
103/* decode 'ss version' */
104int gsm48_decode_ssversion(struct gsm_mncc_ssversion *ssv,
105 const uint8_t *lv);
106/* encode 'ss version' */
107int gsm48_encode_ssversion(struct msgb *msg,
108 const struct gsm_mncc_ssversion *ssv);
109/* decode 'more data' does not require a function, because it has no value */
110/* encode 'more data' */
111int gsm48_encode_more(struct msgb *msg);
112
Harald Welte1523d702010-08-04 11:46:44 +0200113/* structure of one frequency */
114struct gsm_sysinfo_freq {
115 /* if the frequency included in the sysinfo */
116 uint8_t mask;
117};
118
119/* decode "Cell Channel Description" (10.5.2.1b) and other frequency lists */
Vadim Yanitskiy179dec02022-12-31 02:17:56 +0700120int gsm48_decode_freq_list(struct gsm_sysinfo_freq *f,
121 const uint8_t *cd, uint8_t len,
122 uint8_t mask, uint8_t frqt);
Philipp Maiere36be562020-11-12 11:33:54 +0100123
124/* decode "CSN.1 encoded Classmark 3" (10.5.1.7) */
125int gsm48_decode_classmark3(struct gsm48_classmark3 *classmark3_out,
126 const uint8_t *classmark3, size_t classmark3_len);