66 #include <sys/types.h>    67 #include <sys/socket.h>   113     esme = gw_malloc(
sizeof(*esme));
   136     esme->
version = pdu->
u.bind_transmitter.interface_version;
   138                             pdu->
u.bind_transmitter.sequence_number);
   140     resp->
u.bind_transmitter_resp.system_id = 
   152     esme->
version = pdu->
u.bind_receiver.interface_version;
   154                             pdu->
u.bind_receiver.sequence_number);
   167     debug(
"test.smpp", 0, 
"submit_sm: short_message = <%s>",
   171         info(0, 
"ESME has submitted all messages to SMSC.");
   176     resp->
u.submit_sm_resp.message_id = 
   201                            pdu->
u.enquire_link.sequence_number);
   215     #define HANDLER(name) { name, handle_ ## name },   234     debug(
"test.smpp", 0, 
"Handling SMPP PDU of type %s", pdu->
type_name);
   237         resp = 
handlers[i].handler(esme, pdu);
   248     error(0, 
"Unhandled SMPP PDU.");
   274             pdu->
u.deliver_sm.receipted_message_id = 
octstr_create(
"receipted_message_id\0");
   281         debug(
"test.smpp", 0, 
"Delivered SMS %ld of %ld to bearerbox via SMPP.",
   290             debug(
"test.smpp", 0, 
"Sent enquire_link to bearerbox.");
   295     info(0, 
"All messages sent to ESME.");
   296     debug(
"test.smpp", 0, 
"%s terminates.", __func__);
   317             error(0, 
"Client sent garbage, closing connection.");
   319         } 
else if (len == 0) {
   332             error(0, 
"PDU unpacking failed!");
   350     if (sender_id != -1) {
   356     debug(
"test.smpp", 0, 
"%s terminates.", __func__);
   381         panic(0, 
"Couldn't connect to bearerbox as smsbox");
   394         if (
msg == NULL || 
msg->type == wdp_datagram)
   395         error(0, 
"Bearerbox sent garbage to smsbox");
   397         if (
msg->type == sms) {
   401         debug(
"test.smpp", 0, 
   402               "Bearerbox sent sms #%ld <%s> to smsbox, sending reply.",
   405             info(0, 
"Bearerbox has sent all messages to smsbox.");
   418     debug(
"test.smpp", 0, 
"%s terminates.", __func__);
   428     struct sockaddr addr;
   429     long smsbox_thread_id;
   434         panic(0, 
"Couldn't create SMPP listen port.");
   436     smsbox_thread_id = -1;
   440     addrlen = 
sizeof(addr);
   441     new_fd = accept(fd, &addr, &addrlen);
   446     if (smsbox_thread_id == -1)
   450     debug(
"test.smpp", 0, 
"%s terminates.", __func__);
   456     panic(0, 
"Caught signal %d.", signal);
   462     info(0, 
"drive_smpp [-h] [-v level][-l logfile][-p port][-m msgs][-c config]");
   466 int main(
int argc, 
char **argv)
   468     struct sigaction act;
   478     sigemptyset(&act.sa_mask);
   480     sigaction(SIGTERM, &act, NULL);
   481     sigaction(SIGINT, &act, NULL);
   494     log_file = config_file = NULL;
   496     while ((opt = 
getopt(argc, argv, 
"hv:p:m:l:c:")) != EOF) {
   524         error(0, 
"Invalid option %c", opt);
   526         panic(0, 
"Stopping.");
   530     if (log_file != NULL)
   533     if (config_file != NULL) {
   540             panic(0, 
"Errors in config file.");
   545     info(0, 
"Starting drive_smpp test.");
   548     debug(
"test.smpp", 0, 
"Program exiting normally.");
   552     info(0, 
"Number of messages sent to ESME: %ld",
   554     info(0, 
"Number of messages sent to smsbox: %ld",
   556     info(0, 
"Number of messages sent to bearerbox: %ld",
   558     info(0, 
"Number of messages sent to SMSC: %ld",
   560     info(0, 
"Time: %.0f secs", run_time);
   561     info(0, 
"Time until all sent to ESME: %.0f secs", 
   563     info(0, 
"Time from first from bb to last to bb: %.0f secs", 
   565     info(0, 
"Time until all sent to SMSC: %.0f secs", 
   567     info(0, 
"SMPP messages SMSC to ESME: %.1f msgs/sec",
   569     info(0, 
"SMPP messages ESME to SMSC: %.1f msgs/sec",
 void smpp_pdu_destroy(SMPP_PDU *pdu)
 
static SMPP_PDU * handle_bind_transmitter(ESME *esme, SMPP_PDU *pdu)
 
void error(int err, const char *fmt,...)
 
void info(int err, const char *fmt,...)
 
void gwthread_join_all(void)
 
Connection * conn_open_tcp(Octstr *host, int port, Octstr *our_host)
 
static Octstr * smsc_source_addr
 
static int port_for_smsbox
 
int main(int argc, char **argv)
 
gw_assert(wtls_machine->packet_to_send !=NULL)
 
void counter_destroy(Counter *counter)
 
static struct @73 handlers[]
 
void gwthread_join(long thread)
 
static SMPP_PDU * handle_enquire_link(ESME *esme, SMPP_PDU *pdu)
 
static Counter * num_from_esme
 
static Octstr * smsc_system_id
 
static void smsbox_thread(void *arg)
 
long smpp_pdu_read_len(Connection *conn)
 
static time_t first_from_bb
 
static Counter * num_from_bearerbox
 
int conn_eof(Connection *conn)
 
#define octstr_get_cstr(ostr)
 
static SMPP_PDU * handle_bind_receiver(ESME *esme, SMPP_PDU *pdu)
 
unsigned long counter_increase(Counter *counter)
 
Cfg * cfg_create(Octstr *filename)
 
int getopt(int argc, char **argv, char *opts)
 
static SMPP_PDU * handle_submit_sm(ESME *esme, SMPP_PDU *pdu)
 
static SMPP_PDU * handle_enquire_link_resp(ESME *esme, SMPP_PDU *pdu)
 
static void receive_smpp_thread(void *arg)
 
Octstr * octstr_imm(const char *cstr)
 
int conn_write(Connection *conn, Octstr *data)
 
static long enquire_interval
 
Counter * counter_create(void)
 
void cfg_destroy(Cfg *cfg)
 
void log_set_output_level(enum output_level level)
 
void conn_destroy(Connection *conn)
 
static Counter * num_to_bearerbox
 
#define octstr_duplicate(ostr)
 
#define octstr_dump(ostr, level,...)
 
Octstr * smpp_pdu_pack(Octstr *smsc_id, SMPP_PDU *pdu)
 
static Counter * num_to_esme
 
SMPP_PDU * smpp_pdu_unpack(Octstr *smsc_id, Octstr *data_without_len)
 
static time_t first_to_esme
 
void msg_destroy(Msg *msg)
 
static void send_smpp_thread(void *arg)
 
static SMPP_PDU * handle_deliver_sm_resp(ESME *esme, SMPP_PDU *pdu)
 
int make_server_socket(int port, const char *interface_name)
 
static SMPP_PDU * handle_unbind(ESME *esme, SMPP_PDU *pdu)
 
static void accept_thread(void *arg)
 
Octstr * octstr_format(const char *fmt,...)
 
void octstr_destroy(Octstr *ostr)
 
#define gwthread_create(func, arg)
 
#define octstr_create(cstr)
 
unsigned long counter_value(Counter *counter)
 
void gwthread_sleep(double seconds)
 
Octstr * conn_read_withlen(Connection *conn)
 
static Counter * message_id_counter
 
void smpp_pdu_dump(Octstr *smsc_id, SMPP_PDU *pdu)
 
static void esme_destroy(ESME *esme)
 
int conn_write_withlen(Connection *conn, Octstr *data)
 
int gwthread_pollfd(int fd, int events, double timeout)
 
static Octstr * bearerbox_host
 
Octstr * smpp_pdu_read_data(Connection *conn, long len)
 
int log_open(char *filename, int level, enum excl_state excl)
 
static time_t last_from_esme
 
int conn_wait(Connection *conn, double seconds)
 
void debug(const char *place, int err, const char *fmt,...)
 
void gwlib_shutdown(void)
 
static void handle_pdu(ESME *esme, SMPP_PDU *pdu)
 
Octstr * msg_pack(Msg *msg)
 
static ESME * esme_create(Connection *conn)
 
int smpp_pdu_init(Cfg *cfg)
 
int conn_error(Connection *conn)
 
SMPP_PDU *(* handler)(ESME *, SMPP_PDU *)
 
static time_t last_to_esme
 
void gwthread_wakeup_all(void)
 
SMPP_PDU * smpp_pdu_create(unsigned long type, unsigned long seq_no)
 
static XMLRPCDocument * msg
 
Connection * conn_wrap_fd(int fd, int ssl)