66 #include <sys/types.h> 67 #include <sys/socket.h> 96 error(0,
"smsc_fake: could not create listening socket in port %d",
101 error(0,
"smsc_fake: couldn't make listening socket port %d non-blocking",
115 debug(
"bb.sms", 0,
"smsc_fake: sending message to client");
190 warning(0,
"smsc_fake: url-encoded data from client looks malformed");
196 warning(0,
"smsc_fake: url-encoded data from client looks malformed");
202 warning(0,
"smsc_fake: url-encoded data from client looks malformed");
221 warning(0,
"smsc_fake: url-encoded data from client looks malformed");
232 warning(0,
"smsc_fake: url-encoded udh data from client looks malformed");
248 time(&
msg->sms.time);
251 debug(
"bb.sms", 0,
"smsc_fake: new message received");
256 warning(0,
"smsc_fake: invalid message syntax from client, ignored");
320 if (dlrmsg != NULL) {
324 error(0,
"smsc_fale: got DLR but could not find message or " 325 "was not interested in it");
343 debug(
"bb.sms", 0,
"smsc_fake shutting down, closing client socket");
354 info(0,
"IO error to fakesmsc client. Closing connection.");
358 info(0,
"EOF from fakesmsc client. Closing connection.");
368 struct sockaddr_in client_addr;
379 client_addr_len =
sizeof(client_addr);
384 error(0,
"Poll for fakesmsc connections failed, shutting down");
398 warning(errno,
"fake_listener: accept() failed, retrying...");
403 info(0,
"Fakesmsc connection tried from denied host <%s>, " 411 error(0,
"fake_listener: conn_wrap_fd failed on accept()ed fd");
437 warning(errno,
"smsc_fake: couldn't close listening socket at shutdown");
452 debug(
"bb.sms", 0,
"smsc_fake connection has completed shutdown.");
490 debug(
"bb.sms", 0,
"Shutting down SMSCConn FAKE, %s",
491 finish_sending ?
"slow" :
"instant");
504 if (finish_sending == 0) {
522 debug(
"bb.sms", 0,
"smsc_fake: start called");
555 error(0,
"'port' invalid in 'fake' record.");
592 error(0,
"Failed to create fake smsc connection");
596 error(errno,
"smsc_fake: closing listening socket port %d failed",
Octstr * conn_read_line(Connection *conn)
void error(int err, const char *fmt,...)
void info(int err, const char *fmt,...)
Msg * msg_duplicate(Msg *msg)
void bb_smscconn_connected(SMSCConn *conn)
int socket_set_blocking(int fd, int blocking)
static void main_connection_loop(SMSCConn *conn, Connection *client)
static int sms_to_client(Connection *client, Msg *msg)
void bb_smscconn_killed(void)
void octstr_append(Octstr *ostr1, const Octstr *ostr2)
void gwlist_produce(List *list, void *item)
long gwlist_len(List *list)
static void client(int port)
int octstr_url_decode(Octstr *ostr)
void octstr_append_char(Octstr *ostr, int ch)
static void msg_to_bb(SMSCConn *conn, Octstr *line)
static void start_cb(SMSCConn *conn)
#define cfg_get(grp, varname)
void uuid_unparse(const uuid_t uu, char *out)
int conn_eof(Connection *conn)
Msg * dlr_find(const Octstr *smsc, const Octstr *ts, const Octstr *dst, int typ, int use_dst)
void dlr_add(const Octstr *smsc, const Octstr *ts, Msg *msg, int use_dst)
#define octstr_get_cstr(ostr)
#define octstr_copy(ostr, from, len)
void(* start_conn)(SMSCConn *conn)
long octstr_search_char(const Octstr *ostr, int ch, long pos)
void log_thread_to(int idx)
int is_allowed_ip(Octstr *allow_ip, Octstr *deny_ip, Octstr *ip)
smscconn_killed_t why_killed
void conn_claim(Connection *conn)
static void fake_listener(void *arg)
Octstr * octstr_imm(const char *cstr)
int conn_write(Connection *conn, Octstr *data)
void * gwlist_extract_first(List *list)
long bb_smscconn_receive(SMSCConn *conn, Msg *sms)
void conn_destroy(Connection *conn)
static int shutdown_cb(SMSCConn *conn, int finish_sending)
#define octstr_duplicate(ostr)
void msg_destroy(Msg *msg)
int make_server_socket(int port, const char *interface_name)
void warning(int err, const char *fmt,...)
Octstr * octstr_format(const char *fmt,...)
void octstr_destroy(Octstr *ostr)
#define gwthread_create(func, arg)
#define octstr_create(cstr)
void gwthread_sleep(double seconds)
volatile sig_atomic_t is_stopped
int gwthread_pollfd(int fd, int events, double timeout)
static int add_msg_cb(SMSCConn *conn, Msg *sms)
int smsc_fake_create(SMSCConn *conn, CfgGroup *cfg)
long octstr_len(const Octstr *ostr)
void bb_smscconn_sent(SMSCConn *conn, Msg *sms, Octstr *reply)
int conn_wait(Connection *conn, double seconds)
int(* shutdown)(SMSCConn *conn, int finish_sending)
Octstr * host_ip(struct sockaddr_in addr)
void debug(const char *place, int err, const char *fmt,...)
int cfg_get_integer(long *n, CfgGroup *grp, Octstr *varname)
void gwthread_wakeup(long thread)
long(* queued)(SMSCConn *conn)
int(* send_msg)(SMSCConn *conn, Msg *msg)
void bb_smscconn_send_failed(SMSCConn *conn, Msg *sms, int reason, Octstr *reply)
int conn_error(Connection *conn)
static int fake_open_connection(SMSCConn *conn, PrivData *privdata)
#define DLR_IS_ENABLED_DEVICE(dlr)
static long queued_cb(SMSCConn *conn)
#define DLR_IS_SUCCESS_OR_FAIL(dlr)
static XMLRPCDocument * msg
void octstr_url_encode(Octstr *ostr)
Connection * conn_wrap_fd(int fd, int ssl)
int octstr_compare(const Octstr *ostr1, const Octstr *ostr2)
void gwlist_destroy(List *list, gwlist_item_destructor_t *destructor)