This source file includes following definitions.
- FT_DECLARE
- FT_DECLARE
- FT_DECLARE
- FT_DECLARE
- FT_DECLARE
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 #include "private/ftdm_core.h"
36 #include <ctype.h>
37
38
39 FT_DECLARE(ftdm_status_t) ftdm_span_set_npi(const char *npi_string, uint8_t *target)
40 {
41 if (!strcasecmp(npi_string, "isdn") || !strcasecmp(npi_string, "e164")) {
42 *target = FTDM_NPI_ISDN;
43 } else if (!strcasecmp(npi_string, "data")) {
44 *target = FTDM_NPI_DATA;
45 } else if (!strcasecmp(npi_string, "telex")) {
46 *target = FTDM_NPI_TELEX;
47 } else if (!strcasecmp(npi_string, "national")) {
48 *target = FTDM_NPI_NATIONAL;
49 } else if (!strcasecmp(npi_string, "private")) {
50 *target = FTDM_NPI_PRIVATE;
51 } else if (!strcasecmp(npi_string, "reserved")) {
52 *target = FTDM_NPI_RESERVED;
53 } else if (!strcasecmp(npi_string, "unknown")) {
54 *target = FTDM_NPI_UNKNOWN;
55 } else {
56 ftdm_log(FTDM_LOG_WARNING, "Invalid NPI value (%s)\n", npi_string);
57 *target = FTDM_NPI_UNKNOWN;
58 return FTDM_FAIL;
59 }
60 return FTDM_SUCCESS;
61 }
62
63 FT_DECLARE(ftdm_status_t) ftdm_span_set_ton(const char *ton_string, uint8_t *target)
64 {
65 if (!strcasecmp(ton_string, "national")) {
66 *target = FTDM_TON_NATIONAL;
67 } else if (!strcasecmp(ton_string, "international")) {
68 *target = FTDM_TON_INTERNATIONAL;
69 } else if (!strcasecmp(ton_string, "local")) {
70 *target = FTDM_TON_SUBSCRIBER_NUMBER;
71 } else if (!strcasecmp(ton_string, "unknown")) {
72 *target = FTDM_TON_UNKNOWN;
73 } else {
74 ftdm_log(FTDM_LOG_WARNING, "Invalid TON value (%s)\n", ton_string);
75 *target = FTDM_TON_UNKNOWN;
76 return FTDM_FAIL;
77 }
78 return FTDM_SUCCESS;
79 }
80
81 FT_DECLARE(ftdm_status_t) ftdm_span_set_bearer_capability(const char *bc_string, ftdm_bearer_cap_t *target)
82 {
83 if (!strcasecmp(bc_string, "speech")) {
84 *target = FTDM_BEARER_CAP_SPEECH;
85 } else if (!strcasecmp(bc_string, "unrestricted-digital")) {
86 *target = FTDM_BEARER_CAP_64K_UNRESTRICTED;
87 } else if (!strcasecmp(bc_string, "3.1Khz")) {
88 *target = FTDM_BEARER_CAP_3_1KHZ_AUDIO;
89 } else {
90 ftdm_log(FTDM_LOG_WARNING, "Unsupported Bearer Capability value (%s)\n", bc_string);
91 return FTDM_FAIL;
92 }
93 return FTDM_SUCCESS;
94 }
95
96 FT_DECLARE(ftdm_status_t) ftdm_span_set_bearer_layer1(const char *bc_string, ftdm_user_layer1_prot_t *target)
97 {
98 if (!strcasecmp(bc_string, "v110")) {
99 *target = FTDM_USER_LAYER1_PROT_V110;
100 } else if (!strcasecmp(bc_string, "ulaw")) {
101 *target = FTDM_USER_LAYER1_PROT_ULAW;
102 } else if (!strcasecmp(bc_string, "alaw")) {
103 *target =FTDM_USER_LAYER1_PROT_ALAW ;
104 } else {
105 ftdm_log(FTDM_LOG_WARNING, "Unsupported Bearer Layer1 Prot value (%s)\n", bc_string);
106 return FTDM_FAIL;
107 }
108 return FTDM_SUCCESS;
109 }
110
111
112 FT_DECLARE(ftdm_status_t) ftdm_is_number(char *number)
113 {
114 if (!number) {
115 return FTDM_FAIL;
116 }
117
118 for ( ; *number; number++) {
119 if (!isdigit(*number)) {
120 return FTDM_FAIL;
121 }
122 }
123 return FTDM_SUCCESS;
124 }
125