Kannel: Open Source WAP and SMS gateway
svn-r5336
|
#include <signal.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <string.h>
#include "gwlib/gwlib.h"
Go to the source code of this file.
Data Structures | |
struct | Connection |
Macros | |
#define | DEFAULT_OUTPUT_BUFFERING 0 |
#define | SSL_CONN_TIMEOUT 30 |
#define | unlock_in(conn) unlock_in_real(conn, __FILE__, __LINE__, __func__) |
#define | unlock_out(conn) unlock_out_real(conn, __FILE__, __LINE__, __func__) |
Typedefs | |
typedef unsigned long(* | CRYPTO_CALLBACK_PTR) (void) |
#define DEFAULT_OUTPUT_BUFFERING 0 |
Definition at line 103 of file conn.c.
Referenced by conn_wrap_fd().
#define unlock_in | ( | conn | ) | unlock_in_real(conn, __FILE__, __LINE__, __func__) |
Definition at line 168 of file conn.c.
Referenced by conn_eof(), conn_error(), conn_inbuf_len(), conn_read_everything(), conn_read_fixed(), conn_read_line(), conn_read_packet(), conn_read_withlen(), conn_register_real(), conn_unregister(), conn_wait(), and poll_callback().
#define unlock_out | ( | conn | ) | unlock_out_real(conn, __FILE__, __LINE__, __func__) |
Definition at line 169 of file conn.c.
Referenced by conn_error(), conn_flush(), conn_outbuf_len(), conn_register_real(), conn_set_output_buffering(), conn_unregister(), conn_wait(), conn_write(), conn_write_data(), conn_write_withlen(), and poll_callback().
void conn_claim | ( | Connection * | conn | ) |
Definition at line 671 of file conn.c.
References Connection::claimed, Connection::claiming_thread, gw_assert(), gwthread_self(), and panic.
Referenced by cgw_listener(), emi2_listener(), and fake_listener().
void conn_config_ssl | ( | CfgGroup * | grp | ) |
Definition at line 1546 of file conn.c.
References info().
Referenced by init_bearerbox(), init_smppbox(), init_smsbox(), init_sqlbox(), and init_wapbox().
void conn_destroy | ( | Connection * | conn | ) |
Definition at line 627 of file conn.c.
References Connection::callback_data, Connection::callback_data_destroyer, error(), Connection::fd, fdset_unregister(), Connection::inbuf, Connection::inlock, mutex_destroy(), octstr_destroy(), Connection::outbuf, Connection::outlock, Connection::registered, and unlocked_try_write().
Referenced by boxc_destroy(), cgw_listener(), cgw_open_send_connection(), cgw_sender(), client_destroy(), close_connection_to_bearerbox_real(), conn_pool_get(), conn_pool_item_destroy(), conn_wrap_fd(), emi2_idleprocessing(), emi2_idletimeout_handling(), emi2_listener(), emi2_sender(), esme_destroy(), get_connection(), handle_transaction(), io_thread(), main(), main_connection_loop(), open_receiver(), open_send_connection(), open_transceiver(), open_transmitter(), send_request(), smasi_thread(), smpp_emu(), and smsbox_thread().
int conn_eof | ( | Connection * | conn | ) |
Definition at line 705 of file conn.c.
References lock_in(), Connection::read_eof, and unlock_in.
Referenced by bearerbox_to_smpp(), cgw_receiver(), cgw_wait_command(), client_read_status(), conn_pool_get(), emi2_handle_smscreq(), emi2_receiver(), emi2_send_loop(), http_accept_request(), main(), main_connection_loop(), read_body_until_eof(), read_body_with_length(), read_chunked_body_crlf(), read_chunked_body_data(), read_chunked_body_len(), read_from_bearerbox_real(), read_from_box(), read_pdu(), read_some_headers(), receive_request(), receive_smpp_thread(), run_requests(), smpp_emu_reader(), smsbox_thread(), and wait_for_ack().
int conn_error | ( | Connection * | conn | ) |
Definition at line 716 of file conn.c.
References Connection::io_error, lock_in(), lock_out(), unlock_in, and unlock_out.
Referenced by cgw_receiver(), cgw_wait_command(), client_read_status(), conn_pool_get(), emi2_handle_smscreq(), emi2_receiver(), emi2_send_loop(), http_accept_request(), main(), main_connection_loop(), read_body_until_eof(), read_body_with_length(), read_chunked_body_crlf(), read_chunked_body_data(), read_chunked_body_len(), read_from_bearerbox_real(), read_from_box(), read_pdu(), read_some_headers(), receive_request(), receive_smpp_thread(), smpp_emu_reader(), smsbox_thread(), and wait_for_ack().
int conn_flush | ( | Connection * | conn | ) |
Definition at line 995 of file conn.c.
References error(), Connection::fd, gwthread_pollfd(), lock_out(), POLLERR, POLLHUP, POLLNVAL, POLLOUT, unlock_out, unlocked_outbuf_len(), and unlocked_write().
Referenced by boxc_sender().
int conn_get_connect_result | ( | Connection * | conn | ) |
Definition at line 530 of file conn.c.
References Connection::connected, and Connection::fd.
Referenced by handle_transaction().
int conn_get_id | ( | Connection * | conn | ) |
long conn_inbuf_len | ( | Connection * | conn | ) |
int conn_is_connected | ( | Connection * | conn | ) |
Definition at line 525 of file conn.c.
References Connection::connected.
Referenced by write_request_thread().
Connection* conn_open_tcp | ( | Octstr * | host, |
int | port, | ||
Octstr * | our_host | ||
) |
Definition at line 496 of file conn.c.
References conn_open_tcp_with_port(), host, and our_host.
Referenced by connect_to_bearerbox_real(), main(), open_receiver(), open_transceiver(), open_transmitter(), and smsbox_thread().
Connection* conn_open_tcp_nb | ( | Octstr * | host, |
int | port, | ||
Octstr * | our_host | ||
) |
Definition at line 501 of file conn.c.
References conn_open_tcp_nb_with_port(), host, and our_host.
Referenced by conn_pool_get().
Connection* conn_open_tcp_nb_with_port | ( | Octstr * | host, |
int | port, | ||
int | our_port, | ||
Octstr * | our_host | ||
) |
Definition at line 506 of file conn.c.
References conn_wrap_fd(), Connection::connected, host, octstr_get_cstr, our_host, our_port, sockfd, and tcpip_connect_nb_to_server_with_port().
Referenced by conn_open_tcp_nb().
Connection* conn_open_tcp_with_port | ( | Octstr * | host, |
int | port, | ||
int | our_port, | ||
Octstr * | our_host | ||
) |
Definition at line 548 of file conn.c.
References conn_wrap_fd(), host, octstr_get_cstr, our_host, our_port, sockfd, and tcpip_connect_to_server_with_port().
Referenced by cgw_open_send_connection(), conn_open_tcp(), open_connection(), open_receiver(), open_send_connection(), open_transceiver(), and open_transmitter().
long conn_outbuf_len | ( | Connection * | conn | ) |
Definition at line 683 of file conn.c.
References lock_out(), unlock_out, and unlocked_outbuf_len().
Referenced by receive_request().
Octstr* conn_read_everything | ( | Connection * | conn | ) |
Definition at line 1090 of file conn.c.
References lock_in(), unlock_in, unlocked_get(), unlocked_inbuf_len(), and unlocked_read().
Referenced by read_body_until_eof().
Octstr* conn_read_fixed | ( | Connection * | conn, |
long | length | ||
) |
Definition at line 1110 of file conn.c.
References lock_in(), unlock_in, unlocked_get(), unlocked_inbuf_len(), and unlocked_read().
Referenced by read_body_with_length(), read_chunked_body_data(), smpp_pdu_read_data(), and smpp_pdu_read_len().
Octstr* conn_read_line | ( | Connection * | conn | ) |
Definition at line 1134 of file conn.c.
References Connection::inbuf, Connection::inbufpos, lock_in(), octstr_delete(), octstr_get_char(), octstr_len(), octstr_search_char(), unlock_in, unlocked_get(), and unlocked_read().
Referenced by cgw_read_op(), client_read_status(), main(), main_connection_loop(), read_chunked_body_crlf(), read_chunked_body_len(), read_some_headers(), receive_request(), and smasi_pdu_read().
Octstr* conn_read_packet | ( | Connection * | conn, |
int | startmark, | ||
int | endmark | ||
) |
Definition at line 1214 of file conn.c.
References endmark(), Connection::inbuf, Connection::inbufpos, lock_in(), octstr_len(), octstr_search_char(), startmark(), unlock_in, unlocked_get(), and unlocked_read().
Referenced by emi2_handle_smscreq(), emi2_receiver(), and wait_for_ack().
Octstr* conn_read_withlen | ( | Connection * | conn | ) |
Definition at line 1169 of file conn.c.
References decode_network_long(), Connection::inbuf, Connection::inbufpos, lock_in(), octstr_get_many_chars(), unlock_in, unlocked_get(), unlocked_inbuf_len(), unlocked_read(), and warning().
Referenced by read_from_bearerbox_real(), read_from_box(), run_requests(), and smsbox_thread().
int conn_register_real | ( | Connection * | conn, |
FDSet * | fdset, | ||
conn_callback_t | callback, | ||
void * | data, | ||
conn_callback_data_destroyer_t * | data_destroyer | ||
) |
Definition at line 802 of file conn.c.
References Connection::callback, Connection::callback_data, Connection::callback_data_destroyer, Connection::connected, Connection::fd, fdset_register(), gw_assert(), Connection::io_error, Connection::listening_pollin, Connection::listening_pollout, lock_in(), lock_out(), poll_callback(), POLLIN, POLLOUT, Connection::read_eof, Connection::registered, unlock_in, unlock_out, and unlocked_outbuf_len().
void conn_set_output_buffering | ( | Connection * | conn, |
unsigned int | size | ||
) |
Definition at line 729 of file conn.c.
References lock_out(), Connection::output_buffering, size, unlock_out, and unlocked_try_write().
void conn_unregister | ( | Connection * | conn | ) |
Definition at line 858 of file conn.c.
References Connection::callback, Connection::callback_data, Connection::callback_data_destroyer, Connection::fd, fdset_unregister(), gw_assert(), Connection::listening_pollin, Connection::listening_pollout, lock_in(), lock_out(), Connection::registered, unlock_in, and unlock_out.
Referenced by conn_pool_get(), handle_transaction(), port_remove(), and receive_request().
int conn_wait | ( | Connection * | conn, |
double | seconds | ||
) |
Definition at line 904 of file conn.c.
References error(), Connection::fd, gwthread_pollfd(), Connection::io_error, lock_in(), lock_out(), POLLERR, POLLHUP, POLLIN, POLLNVAL, POLLOUT, Connection::read_eof, unlock_in, unlock_out, unlocked_outbuf_len(), unlocked_read(), and unlocked_write().
Referenced by cgw_receiver(), cgw_wait_command(), conn_pool_get(), emi2_receiver(), emi2_wait(), http_accept_request(), io_thread(), main(), main_connection_loop(), read_from_bearerbox_real(), read_from_box(), receive_smpp_thread(), run_requests(), smasi_thread(), smpp_emu_reader(), smsbox_thread(), and wait_for_ack().
Connection* conn_wrap_fd | ( | int | fd, |
int | ssl | ||
) |
Definition at line 566 of file conn.c.
References Connection::callback, Connection::callback_data, Connection::callback_data_destroyer, Connection::claimed, conn_destroy(), Connection::connected, DEFAULT_OUTPUT_BUFFERING, error(), Connection::fd, Connection::inbuf, Connection::inbufpos, Connection::inlock, Connection::io_error, Connection::listening_pollin, Connection::listening_pollout, mutex_create, octstr_create, Connection::outbuf, Connection::outbufpos, Connection::outlock, Connection::output_buffering, Connection::read_eof, Connection::registered, socket_set_blocking(), and ssl.
Referenced by accept_thread(), boxc_create(), cgw_listener(), conn_open_tcp_nb_with_port(), conn_open_tcp_with_port(), emi2_listener(), fake_listener(), server_thread(), smpp_emu(), and start_wapbox().
int conn_write | ( | Connection * | conn, |
Octstr * | data | ||
) |
Definition at line 1051 of file conn.c.
References lock_out(), octstr_append(), Connection::outbuf, unlock_out, and unlocked_try_write().
Referenced by cgwop_send(), emimsg_send(), handle_pdu(), http_send_reply(), main(), send_enquire_link(), send_gnack(), send_logoff(), send_pdu(), send_request(), send_smpp_thread(), send_unbind(), smpp_emu_handle_pdu(), smpp_emu_writer(), sms_to_client(), and smsc_emu_submit_ack().
int conn_write_data | ( | Connection * | conn, |
unsigned char * | data, | ||
long | length | ||
) |
Definition at line 1063 of file conn.c.
References lock_out(), octstr_append_data(), Connection::outbuf, unlock_out, and unlocked_try_write().
int conn_write_withlen | ( | Connection * | conn, |
Octstr * | data | ||
) |
Definition at line 1075 of file conn.c.
References encode_network_long(), lock_out(), octstr_append(), octstr_append_data(), octstr_len(), Connection::outbuf, unlock_out, and unlocked_try_write().
Referenced by deliver_to_bearerbox_real(), send_msg(), send_pdu(), smsbox_thread(), and write_to_bearerbox_real().
|
inlinestatic |
Definition at line 172 of file conn.c.
References Connection::claimed, Connection::claiming_thread, gw_assert(), gwthread_self(), Connection::inlock, and mutex_lock.
Referenced by conn_eof(), conn_error(), conn_inbuf_len(), conn_read_everything(), conn_read_fixed(), conn_read_line(), conn_read_packet(), conn_read_withlen(), conn_register_real(), conn_unregister(), conn_wait(), and poll_callback().
|
inlinestatic |
Definition at line 197 of file conn.c.
References Connection::claimed, Connection::claiming_thread, gw_assert(), gwthread_self(), mutex_lock, and Connection::outlock.
Referenced by conn_error(), conn_flush(), conn_outbuf_len(), conn_register_real(), conn_set_output_buffering(), conn_unregister(), conn_wait(), conn_write(), conn_write_data(), conn_write_withlen(), and poll_callback().
|
static |
Definition at line 738 of file conn.c.
References Connection::callback, Connection::callback_data, Connection::connected, error(), Connection::fd, Connection::io_error, Connection::listening_pollin, Connection::listening_pollout, lock_in(), lock_out(), POLLERR, POLLHUP, POLLIN, POLLOUT, unlock_in, unlock_out, unlocked_outbuf_len(), unlocked_read(), unlocked_register_pollin(), unlocked_register_pollout(), and unlocked_write().
Referenced by conn_register_real().
|
inlinestatic |
Definition at line 183 of file conn.c.
References Connection::claimed, file, gw_assert(), Connection::inlock, mutex_unlock, and panic.
|
inlinestatic |
Definition at line 208 of file conn.c.
References Connection::claimed, file, gw_assert(), mutex_unlock, Connection::outlock, and panic.
|
static |
Definition at line 361 of file conn.c.
References gw_assert(), Connection::inbuf, Connection::inbufpos, octstr_copy, and unlocked_inbuf_len().
Referenced by conn_read_everything(), conn_read_fixed(), conn_read_line(), conn_read_packet(), and conn_read_withlen().
|
inlinestatic |
Definition at line 228 of file conn.c.
References Connection::inbuf, Connection::inbufpos, and octstr_len().
Referenced by conn_inbuf_len(), conn_read_everything(), conn_read_fixed(), conn_read_withlen(), and unlocked_get().
|
inlinestatic |
Definition at line 222 of file conn.c.
References octstr_len(), Connection::outbuf, and Connection::outbufpos.
Referenced by conn_flush(), conn_outbuf_len(), conn_register_real(), conn_wait(), poll_callback(), unlocked_try_write(), and unlocked_write().
|
static |
Definition at line 310 of file conn.c.
References error(), Connection::fd, Connection::inbuf, Connection::inbufpos, Connection::io_error, octstr_append_data(), octstr_delete(), Connection::read_eof, Connection::registered, and unlocked_register_pollin().
Referenced by conn_read_everything(), conn_read_fixed(), conn_read_line(), conn_read_packet(), conn_read_withlen(), conn_wait(), and poll_callback().
|
static |
Definition at line 377 of file conn.c.
References Connection::fd, fdset_listen(), gw_assert(), Connection::listening_pollin, POLLIN, and Connection::registered.
Referenced by poll_callback(), and unlocked_read().
|
static |
Definition at line 397 of file conn.c.
References Connection::fd, fdset_listen(), gw_assert(), Connection::listening_pollout, POLLOUT, and Connection::registered.
Referenced by poll_callback(), and unlocked_write().
|
static |
Definition at line 289 of file conn.c.
References Connection::output_buffering, unlocked_outbuf_len(), and unlocked_write().
Referenced by conn_destroy(), conn_set_output_buffering(), conn_write(), conn_write_data(), and conn_write_withlen().
|
static |
Definition at line 235 of file conn.c.
References error(), Connection::fd, Connection::io_error, octstr_delete(), octstr_get_cstr, octstr_len(), octstr_write_data(), Connection::outbuf, Connection::outbufpos, Connection::registered, unlocked_outbuf_len(), and unlocked_register_pollout().
Referenced by conn_flush(), conn_wait(), poll_callback(), and unlocked_try_write().