127 #define TYPE(name) case name: return #name; 135 TYPE(got_enquire_link)
146 e = gw_malloc(
sizeof(*e));
332 case bind_transmitter:
334 pdu->
u.bind_transmitter.sequence_number);
339 pdu->
u.bind_receiver.sequence_number);
344 panic(0,
"Couldn't create SMPP helper thread.");
350 pdu->
u.submit_sm.short_message));
353 case deliver_sm_resp:
361 pdu->
u.enquire_link.sequence_number);
366 pdu->
u.unbind.sequence_number);
398 error(0,
"Client sent garbage, closing connection.");
400 }
else if (len == 0) {
413 error(0,
"PDU unpacking failed!");
454 panic(0,
"Couldn't create SMPP listen port.");
463 warning(0,
"Too many SMPP client connections.");
464 (void) close(new_fd);
466 thread[num_threads] = gw_malloc(
sizeof(*thread[0]));
468 thread[num_threads]->
eq =
eq;
469 thread[num_threads]->
quit = 0;
473 thread[num_threads]->
id =
475 if (thread[num_threads]->
id == -1)
476 panic(0,
"Couldn't start SMPP subthread.");
481 for (i = 0; i < num_threads; ++i) {
511 arg = gw_malloc(
sizeof(*arg));
516 panic(0,
"Couldn't start SMPP emulator thread.");
639 arg = gw_malloc(
sizeof(*arg));
645 panic(0,
"Can't start the HTTP server emulator thread.");
705 &reply_headers, &reply_body);
744 debug(
"test_smsc", 0,
"Discarding event of type %s",
eq_type(e));
745 debug(
"test_smsc", 0,
"Got event got_smsc.");
786 time_sum -= times[next_time];
787 times[next_time] = rtt;
788 time_sum += times[next_time];
789 debug(
"", 0,
"RTT = %ld", rtt);
796 case got_enquire_link:
800 debug(
"test_smsc", 0,
"Ignoring event of type %s",
eq_type(e));
809 debug(
"test_smsc", 0,
"Terminating benchmark.");
838 debug(
"test_smsc", 0,
"Discarding event of type %s",
eq_type(e));
839 debug(
"test_smsc", 0,
"Got event got_smsc.");
877 case got_enquire_link:
881 debug(
"test_smsc", 0,
"Ignoring event of type %s",
eq_type(e));
890 debug(
"test_smsc", 0,
"Terminating benchmark.");
902 int main(
int argc,
char **argv)
920 main_name =
"n_messages_benchmark";
922 while ((opt =
getopt(argc, argv,
"m:r:")) != EOF) {
933 for (i = 0; (size_t) i <
sizeof(tab) /
sizeof(tab[0]); ++i) {
934 if (strcmp(main_name, tab[i].
name) == 0) {
void smpp_pdu_destroy(SMPP_PDU *pdu)
static Event * eq_extract(EventQueue *eq)
void error(int err, const char *fmt,...)
void info(int err, const char *fmt,...)
void http_header_add(List *headers, char *name, char *contents)
gw_assert(wtls_machine->packet_to_send !=NULL)
void counter_destroy(Counter *counter)
int main(int argc, char **argv)
static void smpp_emu_writer(void *arg)
static void smsc_emu_shutdown(void)
static void n_messages_benchmark(void)
void semaphore_destroy(Semaphore *semaphore)
void gwlist_produce(List *list, void *item)
void gwthread_join(long thread)
static void client(int port)
static void eq_log(Event *e)
static void smpp_emu_handle_pdu(struct smpp_emu_arg *p, SMPP_PDU *pdu)
static void eq_destroy_event(Event *e)
static long httpd_emu_tid
long smpp_pdu_read_len(Connection *conn)
static Counter * smpp_emu_counter
static void httpd_emu_destroy(void)
int conn_eof(Connection *conn)
static void smsc_emu_deliver(void)
static void httpd_emu_create(EventQueue *eq)
unsigned long counter_increase(Counter *counter)
static void eq_append(EventQueue *eq, Event *e)
static void eq_add_producer(EventQueue *eq)
Octstr * http_cgi_variable(List *list, char *name)
static void smsc_emu_destroy(void)
void semaphore_down(Semaphore *semaphore)
static char * admin_password
void http_destroy_headers(List *headers)
static void httpd_emu(void *arg)
int getopt(int argc, char **argv, char *opts)
void http_destroy_cgiargs(List *args)
static void httpd_emu_shutdown(void)
void http_send_reply(HTTPClient *client, int status, List *headers, Octstr *body)
int conn_write(Connection *conn, Octstr *data)
static Event * eq_create_event(enum event_type type)
Counter * counter_create(void)
int gw_accept(int fd, Octstr **client_addr)
HTTPClient * http_accept_request(int port, Octstr **client_ip, Octstr **url, List **headers, Octstr **body, List **cgivars)
static EventQueue * eq_create(void)
void gwlist_remove_producer(List *list)
void conn_destroy(Connection *conn)
List * http_create_empty_headers(void)
static void smsc_emu_init(void)
static void eq_shutdown(void)
#define octstr_duplicate(ostr)
#define octstr_dump(ostr, level,...)
Octstr * smpp_pdu_pack(Octstr *smsc_id, SMPP_PDU *pdu)
static void eq_remove_producer(EventQueue *eq)
SMPP_PDU * smpp_pdu_unpack(Octstr *smsc_id, Octstr *data_without_len)
static void httpd_emu_init(void)
static void sustained_level_benchmark(void)
int make_server_socket(int port, const char *interface_name)
void warning(int err, const char *fmt,...)
static void eq_init(void)
Octstr * octstr_format(const char *fmt,...)
void octstr_destroy(Octstr *ostr)
#define gwthread_create(func, arg)
#define octstr_create(cstr)
static Event * eq_create_http_request(HTTPClient *client, Octstr *body)
int http_open_port(int port, int ssl)
static void smpp_emu(void *arg)
static void smsc_emu_submit_ack(Event *e)
static const char * eq_type(Event *e)
static EventQueue * undelivered_messages
long date_universal_now(void)
Octstr * smpp_pdu_read_data(Connection *conn, long len)
void semaphore_up(Semaphore *semaphore)
void http_close_all_ports(void)
static void kill_kannel(void)
static void smsc_emu_create(EventQueue *eq)
int http_get_real(int method, Octstr *url, List *request_headers, Octstr **final_url, List **reply_headers, Octstr **reply_body)
static List * httpd_emu_headers
enum Event::event_type type
int conn_wait(Connection *conn, double seconds)
void * gwlist_consume(List *list)
void debug(const char *place, int err, const char *fmt,...)
static void httpd_emu_reply(Event *e)
void gwthread_wakeup(long thread)
static void eq_destroy(EventQueue *eq)
long octstr_parse_long(long *nump, Octstr *ostr, long pos, int base)
void gwlib_shutdown(void)
int conn_error(Connection *conn)
static void smpp_emu_reader(void *arg)
static Counter * event_id_counter
void gwlist_add_producer(List *list)
Semaphore * semaphore_create(long n)
static Event * eq_create_submit(Connection *conn, long sequence_number, Octstr *body)
SMPP_PDU * smpp_pdu_create(unsigned long type, unsigned long seq_no)
static long eq_round_trip_time(Event *e)
Connection * conn_wrap_fd(int fd, int ssl)
void gwlist_destroy(List *list, gwlist_item_destructor_t *destructor)