mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-24 04:04:16 +00:00
implemented freetdm config nodes and ss7 initial configuration
This commit is contained in:
1 parent
e3c1906c81
commit
99402dd4e0
4 files changed
+246
-13
No files matched your search
@@ -29,6 +29,10 @@
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Contributors:
|
||||
*
|
||||
* Moises Silva <moy@sangoma.com>
|
||||
*/
|
||||
|
||||
#include "freetdm.h"
|
||||
@@ -239,6 +243,82 @@ FT_DECLARE (int) ftdm_config_get_cas_bits(char *strvalue, unsigned char *outbits
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define PARAMETERS_CHUNK_SIZE 20
|
||||
FT_DECLARE(ftdm_status_t) ftdm_conf_node_create(const char *name, ftdm_conf_node_t **node, ftdm_conf_node_t *parent)
|
||||
{
|
||||
ftdm_conf_node_t *newnode;
|
||||
ftdm_conf_node_t *sibling = NULL;
|
||||
|
||||
ftdm_assert_return(name != NULL, FTDM_FAIL, "null node name");
|
||||
|
||||
newnode = ftdm_calloc(1, sizeof(**node));
|
||||
if (!newnode) {
|
||||
return FTDM_MEMERR;
|
||||
}
|
||||
|
||||
strncpy(newnode->name, name, sizeof(newnode->name)-1);
|
||||
newnode->name[sizeof(newnode->name)-1] = 0;
|
||||
|
||||
newnode->parameters = ftdm_calloc(PARAMETERS_CHUNK_SIZE, sizeof(*newnode->parameters));
|
||||
if (!newnode->parameters) {
|
||||
ftdm_safe_free(newnode);
|
||||
return FTDM_MEMERR;
|
||||
}
|
||||
newnode->t_parameters = PARAMETERS_CHUNK_SIZE;
|
||||
|
||||
if (parent) {
|
||||
/* store who my parent is */
|
||||
newnode->parent = parent;
|
||||
/* save any siblings */
|
||||
sibling = parent->child;
|
||||
/* as a newborn I am first */
|
||||
parent->child = newnode;
|
||||
if (sibling) {
|
||||
/* store a pointer to my next sibling */
|
||||
newnode->next = sibling;
|
||||
}
|
||||
}
|
||||
|
||||
*node = newnode;
|
||||
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
FT_DECLARE(ftdm_status_t) ftdm_conf_node_add_param(ftdm_conf_node_t *node, const char *param, const char *val)
|
||||
{
|
||||
void *newparameters;
|
||||
|
||||
ftdm_assert_return(param != NULL, FTDM_FAIL, "param is null");
|
||||
ftdm_assert_return(val != NULL, FTDM_FAIL, "val is null");
|
||||
|
||||
if (node->n_parameters == node->t_parameters) {
|
||||
newparameters = ftdm_realloc(node->parameters, (node->t_parameters + PARAMETERS_CHUNK_SIZE) * sizeof(*node->parameters));
|
||||
if (!newparameters) {
|
||||
return FTDM_MEMERR;
|
||||
}
|
||||
node->parameters = newparameters;
|
||||
node->t_parameters = node->n_parameters + PARAMETERS_CHUNK_SIZE;
|
||||
}
|
||||
node->parameters[node->n_parameters].var = param;
|
||||
node->parameters[node->n_parameters].val = val;
|
||||
node->n_parameters++;
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
FT_DECLARE(ftdm_status_t) ftdm_conf_node_destroy(ftdm_conf_node_t *node)
|
||||
{
|
||||
ftdm_conf_node_t *curr = NULL;
|
||||
ftdm_conf_node_t *child = node->child;
|
||||
while (child) {
|
||||
curr = child;
|
||||
child = curr->next;
|
||||
ftdm_conf_node_destroy(curr);
|
||||
}
|
||||
ftdm_free(node->parameters);
|
||||
ftdm_free(node);
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
||||
@@ -827,6 +827,9 @@ FT_DECLARE(char *) ftdm_api_execute(const char *type, const char *cmd);
|
||||
FT_DECLARE(int) ftdm_vasprintf(char **ret, const char *fmt, va_list ap);
|
||||
FT_DECLARE(ftdm_status_t) ftdm_channel_set_caller_data(ftdm_channel_t *ftdmchan, ftdm_caller_data_t *caller_data);
|
||||
FT_DECLARE(void) ftdm_cpu_monitor_disable(void);
|
||||
FT_DECLARE(ftdm_status_t) ftdm_conf_node_create(const char *name, ftdm_conf_node_t **node, ftdm_conf_node_t *parent);
|
||||
FT_DECLARE(ftdm_status_t) ftdm_conf_node_add_param(ftdm_conf_node_t *node, const char *param, const char *val);
|
||||
FT_DECLARE(ftdm_status_t) ftdm_conf_node_destroy(ftdm_conf_node_t *node);
|
||||
|
||||
FIO_CODEC_FUNCTION(fio_slin2ulaw);
|
||||
FIO_CODEC_FUNCTION(fio_ulaw2slin);
|
||||
|
||||
@@ -572,12 +572,28 @@ typedef ftdm_status_t (*fio_api_t) FIO_API_ARGS ;
|
||||
|
||||
#include "ftdm_dso.h"
|
||||
|
||||
#define FTDM_NODE_NAME_SIZE 50
|
||||
typedef struct ftdm_conf_node_s {
|
||||
char name[255];
|
||||
ftdm_conf_parameter_t attr[10];
|
||||
ftdm_conf_parameter_t settings[100];
|
||||
struct ftdm_conf_node_t *childs;
|
||||
struct ftdm_config_node_s *next;
|
||||
/* node name */
|
||||
char name[FTDM_NODE_NAME_SIZE];
|
||||
|
||||
/* total slots for parameters */
|
||||
unsigned int t_parameters;
|
||||
|
||||
/* current number of parameters */
|
||||
unsigned int n_parameters;
|
||||
|
||||
/* array of parameters */
|
||||
ftdm_conf_parameter_t *parameters;
|
||||
|
||||
/* first node child */
|
||||
struct ftdm_conf_node_s *child;
|
||||
|
||||
/* next node sibling */
|
||||
struct ftdm_conf_node_s *next;
|
||||
|
||||
/* my parent if any */
|
||||
struct ftdm_conf_node_s *parent;
|
||||
} ftdm_conf_node_t;
|
||||
|
||||
typedef struct {
|
||||
|
||||
Reference in new issue
Block a user