blob: 71050df5b411779a459bf12cca89a159f3e055a3 [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>
10#include <osmocom/gsm/tlv.h>
11#include <osmocom/gsm/mncc.h>
12#include <osmocom/gsm/protocol/gsm_04_08.h>
Harald Welte1e908662010-03-07 23:39:54 +010013
14/* decode a 'called/calling/connect party BCD number' as in 10.5.4.7 */
15int gsm48_decode_bcd_number(char *output, int output_len,
Neels Hofmeyr8212fc62019-04-01 14:34:37 +020016 const uint8_t *bcd_lv, int h_len)
17 OSMO_DEPRECATED("Use gsm48_decode_bcd_number2() for improved bounds checking");
18int gsm48_decode_bcd_number2(char *output, size_t output_len,
19 const uint8_t *bcd_lv, size_t input_len,
20 size_t h_len);
Harald Welte1e908662010-03-07 23:39:54 +010021
22/* convert a ASCII phone number to 'called/calling/connect party BCD number' */
23int gsm48_encode_bcd_number(uint8_t *bcd_lv, uint8_t max_len,
24 int h_len, const char *input);
25/* decode 'bearer capability' */
26int gsm48_decode_bearer_cap(struct gsm_mncc_bearer_cap *bcap,
27 const uint8_t *lv);
28/* encode 'bearer capability' */
29int gsm48_encode_bearer_cap(struct msgb *msg, int lv_only,
30 const struct gsm_mncc_bearer_cap *bcap);
31/* decode 'call control cap' */
32int gsm48_decode_cccap(struct gsm_mncc_cccap *ccap, const uint8_t *lv);
33/* encode 'call control cap' */
34int gsm48_encode_cccap(struct msgb *msg,
35 const struct gsm_mncc_cccap *ccap);
36/* decode 'called party BCD number' */
37int gsm48_decode_called(struct gsm_mncc_number *called,
38 const uint8_t *lv);
39/* encode 'called party BCD number' */
40int gsm48_encode_called(struct msgb *msg,
41 const struct gsm_mncc_number *called);
42/* decode callerid of various IEs */
43int gsm48_decode_callerid(struct gsm_mncc_number *callerid,
44 const uint8_t *lv);
45/* encode callerid of various IEs */
46int gsm48_encode_callerid(struct msgb *msg, int ie, int max_len,
47 const struct gsm_mncc_number *callerid);
48/* decode 'cause' */
49int gsm48_decode_cause(struct gsm_mncc_cause *cause,
50 const uint8_t *lv);
51/* encode 'cause' */
52int gsm48_encode_cause(struct msgb *msg, int lv_only,
53 const struct gsm_mncc_cause *cause);
54/* decode 'calling number' */
55int gsm48_decode_calling(struct gsm_mncc_number *calling,
56 const uint8_t *lv);
57/* encode 'calling number' */
58int gsm48_encode_calling(struct msgb *msg,
59 const struct gsm_mncc_number *calling);
60/* decode 'connected number' */
61int gsm48_decode_connected(struct gsm_mncc_number *connected,
62 const uint8_t *lv);
63/* encode 'connected number' */
64int gsm48_encode_connected(struct msgb *msg,
65 const struct gsm_mncc_number *connected);
66/* decode 'redirecting number' */
67int gsm48_decode_redirecting(struct gsm_mncc_number *redirecting,
68 const uint8_t *lv);
69/* encode 'redirecting number' */
70int gsm48_encode_redirecting(struct msgb *msg,
71 const struct gsm_mncc_number *redirecting);
72/* decode 'facility' */
73int gsm48_decode_facility(struct gsm_mncc_facility *facility,
74 const uint8_t *lv);
75/* encode 'facility' */
76int gsm48_encode_facility(struct msgb *msg, int lv_only,
77 const struct gsm_mncc_facility *facility);
78/* decode 'notify' */
79int gsm48_decode_notify(int *notify, const uint8_t *v);
80/* encode 'notify' */
81int gsm48_encode_notify(struct msgb *msg, int notify);
82/* decode 'signal' */
83int gsm48_decode_signal(int *signal, const uint8_t *v);
84/* encode 'signal' */
85int gsm48_encode_signal(struct msgb *msg, int signal);
86/* decode 'keypad' */
87int gsm48_decode_keypad(int *keypad, const uint8_t *lv);
88/* encode 'keypad' */
89int gsm48_encode_keypad(struct msgb *msg, int keypad);
90/* decode 'progress' */
91int gsm48_decode_progress(struct gsm_mncc_progress *progress,
92 const uint8_t *lv);
93/* encode 'progress' */
94int gsm48_encode_progress(struct msgb *msg, int lv_only,
95 const struct gsm_mncc_progress *p);
96/* decode 'user-user' */
97int gsm48_decode_useruser(struct gsm_mncc_useruser *uu,
98 const uint8_t *lv);
99/* encode 'useruser' */
100int gsm48_encode_useruser(struct msgb *msg, int lv_only,
101 const struct gsm_mncc_useruser *uu);
102/* decode 'ss version' */
103int gsm48_decode_ssversion(struct gsm_mncc_ssversion *ssv,
104 const uint8_t *lv);
105/* encode 'ss version' */
106int gsm48_encode_ssversion(struct msgb *msg,
107 const struct gsm_mncc_ssversion *ssv);
108/* decode 'more data' does not require a function, because it has no value */
109/* encode 'more data' */
110int gsm48_encode_more(struct msgb *msg);
111
Harald Welte1523d702010-08-04 11:46:44 +0200112/* structure of one frequency */
113struct gsm_sysinfo_freq {
114 /* if the frequency included in the sysinfo */
115 uint8_t mask;
116};
117
118/* decode "Cell Channel Description" (10.5.2.1b) and other frequency lists */
119int gsm48_decode_freq_list(struct gsm_sysinfo_freq *f, uint8_t *cd,
120 uint8_t len, uint8_t mask, uint8_t frqt);