Ejemplo n.º 1
0
// Commnand API entry point
static FIO_API_FUNCTION(ftdm_gsm_api)
{
	
	char *mycmd = NULL, *argv[10] = { 0 };
	int argc = 0;
	int i;
	ftdm_status_t status = FTDM_FAIL;
	ftdm_status_t syntax = FTDM_FAIL;


	if (data) {
		mycmd = ftdm_strdup(data);
		argc = ftdm_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
	}

	if(argc > 0) {
		for(i=0;i<sizeof(GSM_COMMANDS)/sizeof(GSM_COMMANDS[0]);i++) {
			if(strcasecmp(argv[0],GSM_COMMANDS[i].CMD)==0) {
				
				if(argc -1 >= GSM_COMMANDS[i].Argc) {
					syntax = FTDM_SUCCESS;
					status = GSM_COMMANDS[i].Handler(stream, &argv[1], argc-1);
					
				}
				
				break;
			}

		}
	}

	if(FTDM_SUCCESS != syntax) {
		stream->write_function(stream, "%s", FT_SYNTAX);
	}
	else
	if(FTDM_SUCCESS != status) {
		stream->write_function(stream, "%s Command Failed\r\n", GSM_COMMANDS[i].CMD);
	}
	ftdm_safe_free(mycmd);

	return FTDM_SUCCESS;
}
Ejemplo n.º 2
0
static FIO_API_FUNCTION(ftdm_pritap_api)
{
    char *mycmd = NULL, *argv[10] = { 0 };
    int argc = 0;

    if (data) {
        mycmd = ftdm_strdup(data);
        argc = ftdm_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
    }

    if (argc > 2) {
        if (!strcasecmp(argv[0], "debug")) {
            ftdm_span_t *span = NULL;

            if (ftdm_span_find_by_name(argv[1], &span) == FTDM_SUCCESS) {
                pritap_t *pritap = span->signal_data;
                if (span->start != ftdm_pritap_start) {
                    stream->write_function(stream, "%s: -ERR invalid span.\n", __FILE__);
                    goto done;
                }

                pri_set_debug(pritap->pri, parse_debug(argv[2]));
                stream->write_function(stream, "%s: +OK debug set.\n", __FILE__);
                goto done;
            } else {
                stream->write_function(stream, "%s: -ERR invalid span.\n", __FILE__);
                goto done;
            }
        }

    }

    stream->write_function(stream, "%s: -ERR invalid command.\n", __FILE__);

done:

    ftdm_safe_free(mycmd);

    return FTDM_SUCCESS;
}
Ejemplo n.º 3
0
/**
 * \brief Initialises an freetdm Wanpipe span from a configuration string
 * \param span FreeTDM span
 * \param str Configuration string
 * \param type FreeTDM span type
 * \param name FreeTDM span name
 * \param number FreeTDM span number
 * \return Success or failure
 */
static FIO_CONFIGURE_SPAN_FUNCTION(wanpipe_configure_span)
{
	int items, i;
	char *mydata, *item_list[10];
	char *sp, *ch, *mx;
	unsigned char cas_bits = 0;
	int channo;
	int spanno;
	int top = 0;
	unsigned configured = 0;

	assert(str != NULL);
	

	mydata = ftdm_strdup(str);
	assert(mydata != NULL);


	items = ftdm_separate_string(mydata, ',', item_list, (sizeof(item_list) / sizeof(item_list[0])));

	for(i = 0; i < items; i++) {
		sp = item_list[i];
		if ((ch = strchr(sp, ':'))) {
			*ch++ = '\0';
		}

		if (!(sp && ch)) {
			ftdm_log(FTDM_LOG_ERROR, "No valid wanpipe span and channel was specified\n");
			continue;
		}

		channo = atoi(ch);
		spanno = atoi(sp);

		if (channo < 0) {
			ftdm_log(FTDM_LOG_ERROR, "Invalid channel number %d\n", channo);
			continue;
		}

		if (spanno < 0) {
			ftdm_log(FTDM_LOG_ERROR, "Invalid span number %d\n", channo);
			continue;
		}
		
		if ((mx = strchr(ch, '-'))) {
			mx++;
			top = atoi(mx) + 1;
		} else {
			top = channo + 1;
		}
		
		
		if (top < 0) {
			ftdm_log(FTDM_LOG_ERROR, "Invalid range number %d\n", top);
			continue;
		}
		if (FTDM_CHAN_TYPE_CAS == type && ftdm_config_get_cas_bits(ch, &cas_bits)) {
			ftdm_log(FTDM_LOG_ERROR, "Failed to get CAS bits in CAS channel\n");
			continue;
		}
		configured += wp_open_range(span, spanno, channo, top, type, name, number, cas_bits);

	}
	
	ftdm_safe_free(mydata);

	return configured;
}