Ejemplo n.º 1
0
static void init_smpp_server_box(Cfg *cfg) {
	CfgGroup *cfg_group;
	Octstr *log_file;
	long log_level;

	log_file = NULL;
	log_level = 0;

	debug("httpClient", 0, "********** HTTP Client Box Configuration Initialization **********");

	/* initialize low level PDUs */
	if (smpp_pdu_init(cfg) == -1)
		panic(0, "Connot start with PDU init failed.");

	/*
	 * first we take the port number in bearerbox and other values from the
	 * httpClient group in configuration file
	 */

	cfg_group = cfg_get_single_group(cfg, octstr_imm("httpClient"));
	if (cfg_group == NULL)
		panic(0, "No 'httpClient' group in configuration");

	httpBoxId = cfg_get(cfg_group, octstr_imm("httpClient-id"));

	/* setup logfile stuff */
	log_file = cfg_get(cfg_group, octstr_imm("log-file"));

	cfg_get_integer(&log_level, cfg_group, octstr_imm("log-level"));

	if (log_file != NULL) {
		info(0, "Starting to log to file %s level %ld", octstr_get_cstr(log_file), log_level);
		log_open(octstr_get_cstr(log_file), log_level, GW_NON_EXCL);

	}

	if (cfg_get_integer(&timeOut, cfg_group, octstr_imm("time-out")) == -1)
		timeOut = TIMEOUT_SECONDS;

	integratorId = cfg_get(cfg_group, octstr_imm("integrator-id"));
	integratorQueueId = cfg_get(cfg_group, octstr_imm("integrator-queue-id"));

	debug("httpClient", 0, "==========Configuration Parameters============");
	debug("httpClient", 0, "===> httpClient-id:          %s ", octstr_get_cstr(httpBoxId));
	debug("httpClient", 0, "===> integrator-id:          %s ", octstr_get_cstr(integratorId));
	debug("httpClient", 0, "===> integrator-queue-id:    %s ", octstr_get_cstr(integratorQueueId));
	debug("httpClient", 0, "===> log-file:               %s ", octstr_get_cstr(log_file));
	debug("httpClient", 0, "===> log-level:              %ld", log_level);
	debug("httpClient", 0, "===> timeout:                %ld ", timeOut);
	debug("httpClient", 0, "==============================================");

	octstr_destroy(log_file);
	gw_smpp_enter(cfg);
	httpbox_status = SMPP_RUNNING;
	debug("httpClient", 0, "http_status: %d ", httpbox_status);
	debug("httpClient", 0, "********** HTTP Client Box Configuration End **********");
}
Ejemplo n.º 2
0
int main(int argc, char **argv)
{
    struct sigaction act;
    int port;
    int opt;
    double run_time;
    char *log_file;
    char *config_file;

    gwlib_init();

    act.sa_handler = handler;
    sigemptyset(&act.sa_mask);
    act.sa_flags = 0;
    sigaction(SIGTERM, &act, NULL);
    sigaction(SIGINT, &act, NULL);

    port = 2345;
    smsc_system_id = octstr_create("kannel_smpp");
    smsc_source_addr = octstr_create("123456");
    message_id_counter = counter_create();
    bearerbox_host = octstr_create("127.0.0.1");
    port_for_smsbox = 13001;
    max_to_esme = 1;
    num_to_esme = counter_create();
    num_from_esme = counter_create();
    num_to_bearerbox = counter_create();
    num_from_bearerbox = counter_create();
    log_file = config_file = NULL;

    while ((opt = getopt(argc, argv, "hv:p:m:l:c:")) != EOF) {
	switch (opt) {
	case 'v':
	    log_set_output_level(atoi(optarg));
	    break;

	case 'h':
	    help();
	    exit(0);

	case 'm':
	    max_to_esme = atoi(optarg);
	    break;

	case 'p':
	    port = atoi(optarg);
	    break;

	case 'l':
        log_file = optarg;
        break;
    
    case 'c':
        config_file = optarg;
        break;

	case '?':
	default:
	    error(0, "Invalid option %c", opt);
	    help();
	    panic(0, "Stopping.");
	}
    }

    if (log_file != NULL)
    	log_open(log_file, GW_DEBUG, GW_NON_EXCL);

    if (config_file != NULL) {
        Cfg *cfg;
        Octstr *tmp = octstr_create(config_file);
        
        cfg = cfg_create(tmp);
        octstr_destroy(tmp);
        if (cfg_read(cfg) == -1)
            panic(0, "Errors in config file.");
        smpp_pdu_init(cfg);
        cfg_destroy(cfg);
    }
            
    info(0, "Starting drive_smpp test.");
    gwthread_create(accept_thread, &port);
    gwthread_join_all();
    debug("test.smpp", 0, "Program exiting normally.");

    run_time = difftime(last_from_esme, first_to_esme);

    info(0, "Number of messages sent to ESME: %ld",
    	 counter_value(num_to_esme));
    info(0, "Number of messages sent to smsbox: %ld",
    	 counter_value(num_from_bearerbox));
    info(0, "Number of messages sent to bearerbox: %ld",
    	 counter_value(num_to_bearerbox));
    info(0, "Number of messages sent to SMSC: %ld",
    	 counter_value(num_from_esme));
    info(0, "Time: %.0f secs", run_time);
    info(0, "Time until all sent to ESME: %.0f secs", 
    	 difftime(last_to_esme, start_time));
    info(0, "Time from first from bb to last to bb: %.0f secs", 
    	 difftime(last_to_bb, first_from_bb));
    info(0, "Time until all sent to SMSC: %.0f secs", 
    	 difftime(last_from_esme, start_time));
    info(0, "SMPP messages SMSC to ESME: %.1f msgs/sec",
    	 counter_value(num_to_esme) / run_time);
    info(0, "SMPP messages ESME to SMSC: %.1f msgs/sec",
    	 counter_value(num_from_esme) / run_time);

    octstr_destroy(smsc_system_id);
    octstr_destroy(smsc_source_addr);
    octstr_destroy(bearerbox_host);
    counter_destroy(num_to_esme);
    counter_destroy(num_from_esme);
    counter_destroy(num_to_bearerbox);
    counter_destroy(num_from_bearerbox);
    counter_destroy(message_id_counter);

    gwlib_shutdown();
    return 0;
}