Kannel: Open Source WAP and SMS gateway
svn-r5336
|
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <stdarg.h>
#include <limits.h>
#include <unistd.h>
#include <time.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "gwlib/gwlib.h"
Go to the source code of this file.
Typedefs | |
typedef void(* | packet_handler) (Octstr *, Octstr *, int) |
Enumerations | |
enum | { TIMESTAMP_MAXLEN = 13 } |
enum | ACT { ACT_listen = 0, ACT_reply = 1, ACT_deliver = 2, ACT_flood = 3 } |
enum | SPEW { SPEW_nothing = 0, SPEW_binary = 1, SPEW_characters = 2, SPEW_packets = 3 } |
enum | LOG { LOG_nothing = 0, LOG_data = 1, LOG_packets = 2, LOG_sms = 3 } |
enum | CHK { CHK_nothing = 0, CHK_packets = 1, CHK_sums = 2, CHK_protocol = 3, CHK_sms = 4 } |
enum | { OUTBUFFER_LIMIT = 65536 } |
enum | { EVIL_BUFSIZE = 1021 } |
enum | CHARS { STX = 2, ETX = 3, TAB = 9, LF = 10, CR = 13 } |
Functions | |
static void | usage (FILE *out) |
static void | pretty_print (unsigned char *data, size_t length) |
static void | read_data (Octstr *in, int fd) |
static void | write_data (Octstr *out, int fd) |
static void | gen_message (Octstr *out) |
static long | gen_data (Octstr *out) |
static void | make_timestamp (unsigned char *buf, time_t fortime) |
static void | send_packet (Octstr *out, int opcode, int sequence,...) |
static void | send_error (Octstr *out, int opcode, int sequence, unsigned char *errorcode, unsigned char *errortext) |
static int | eat_char (Octstr *packet, int ch) |
static Octstr * | eat_string_parm (Octstr *packet, int parm, int maxlen) |
static long | eat_number (Octstr *ostr) |
static long | eat_int_parm (Octstr *packet, int parm, int maxlen) |
static void | eat_checksum (Octstr *packet) |
static void | handle_login (Octstr *packet, Octstr *out, int sequence) |
static void | handle_logout (Octstr *packet, Octstr *out, int sequence) |
static void | handle_submit (Octstr *packet, Octstr *out, int sequence) |
static void | handle_enquire (Octstr *packet, Octstr *out, int sequence) |
static void | handle_delivery_request (Octstr *packet, Octstr *out, int sequence) |
static void | handle_cancel (Octstr *packet, Octstr *out, int sequence) |
static void | handle_set (Octstr *packet, Octstr *out, int sequence) |
static void | handle_get (Octstr *packet, Octstr *out, int sequence) |
static void | handle_alive (Octstr *packet, Octstr *out, int sequence) |
static void | handle_deliver_response (Octstr *packet, Octstr *out, int sequence) |
static void | handle_deliver_status_report_response (Octstr *packet, Octstr *out, int sequence) |
static void | handle_alive_response (Octstr *packet, Octstr *out, int sequence) |
static void | handle_nack (Octstr *packet, Octstr *out, int sequence) |
static void | parse_packet (Octstr *packet, Octstr *out) |
static void | parse_data (Octstr *in, Octstr *out) |
static void | random_address (unsigned char *buf, int size) |
static void | random_message (unsigned char *buf, int size) |
static void | random_hex (unsigned char *buf, int size) |
static void | main_loop (void) |
static int | wait_for_client (int port) |
int | main (int argc, char *argv[]) |
Variables | |
unsigned char * | progname |
unsigned char * | username = "foo" |
unsigned char * | password = "bar" |
int | port = 6789 |
unsigned char * | intro = "" |
int | activity = ACT_listen |
int | spew = SPEW_nothing |
int | logging = LOG_nothing |
int | checking = CHK_nothing |
int | max_deliveries = -1 |
int | deliveries = 0 |
time_t | start_time = 0 |
int | sockfd = -1 |
Octstr * | inbuffer |
Octstr * | outbuffer |
int | awaiting_response = 0 |
struct { | |
int opcode | |
packet_handler handler | |
} | handlers [] |
struct { | |
unsigned char * option | |
void * location | |
int number | |
} | options [] |
Definition at line 766 of file test_cimd2.c.
anonymous enum |
anonymous enum |
anonymous enum |
enum ACT |
Enumerator | |
---|---|
ACT_listen | |
ACT_reply | |
ACT_deliver | |
ACT_flood |
Definition at line 107 of file test_cimd2.c.
enum CHARS |
Enumerator | |
---|---|
STX | |
ETX | |
TAB | |
LF | |
CR |
Definition at line 159 of file test_cimd2.c.
enum CHK |
Enumerator | |
---|---|
CHK_nothing | |
CHK_packets | |
CHK_sums | |
CHK_protocol | |
CHK_sms |
Definition at line 128 of file test_cimd2.c.
enum LOG |
Enumerator | |
---|---|
LOG_nothing | |
LOG_data | |
LOG_packets | |
LOG_sms |
Definition at line 121 of file test_cimd2.c.
enum SPEW |
Enumerator | |
---|---|
SPEW_nothing | |
SPEW_binary | |
SPEW_characters | |
SPEW_packets |
Definition at line 114 of file test_cimd2.c.
|
static |
Definition at line 368 of file test_cimd2.c.
References octstr_delete(), and octstr_get_char().
Referenced by parse_packet().
|
static |
Definition at line 429 of file test_cimd2.c.
References octstr_delete(), octstr_get_char(), octstr_len(), and TAB.
Referenced by parse_packet().
|
static |
Definition at line 413 of file test_cimd2.c.
References eat_number(), eat_string_parm(), maxlen, octstr_destroy(), and octstr_len().
Referenced by handle_cancel(), handle_delivery_request(), handle_get(), and handle_submit().
|
static |
Definition at line 401 of file test_cimd2.c.
References octstr_delete(), and octstr_parse_long().
Referenced by eat_int_parm(), and parse_packet().
Definition at line 376 of file test_cimd2.c.
References octstr_copy, octstr_delete(), octstr_destroy(), octstr_format(), octstr_len(), octstr_search(), octstr_search_char(), start, and TAB.
Referenced by eat_int_parm(), handle_cancel(), handle_enquire(), handle_login(), handle_set(), and handle_submit().
|
static |
Definition at line 275 of file test_cimd2.c.
References ACT_deliver, ACT_flood, activity, deliveries, EVIL_BUFSIZE, gen_message(), interval, max_deliveries, octstr_append_data(), spew, and SPEW_binary.
Referenced by main_loop().
|
static |
Definition at line 886 of file test_cimd2.c.
References awaiting_response, LOG_packets, logging, make_timestamp(), random_address(), random_hex(), random_message(), send_packet(), and TIMESTAMP_MAXLEN.
Referenced by gen_data().
Definition at line 723 of file test_cimd2.c.
References LOG_packets, logging, and send_packet().
Definition at line 751 of file test_cimd2.c.
References awaiting_response, LOG_packets, and logging.
Definition at line 659 of file test_cimd2.c.
References eat_int_parm(), eat_string_parm(), LOG_packets, logging, octstr_get_cstr, send_error(), and send_packet().
Definition at line 731 of file test_cimd2.c.
References awaiting_response, deliveries, LOG_packets, logging, max_deliveries, and start_time.
|
static |
Definition at line 744 of file test_cimd2.c.
References awaiting_response, LOG_packets, and logging.
Definition at line 614 of file test_cimd2.c.
References eat_int_parm(), LOG_packets, logging, send_error(), and send_packet().
Definition at line 588 of file test_cimd2.c.
References eat_string_parm(), LOG_packets, logging, octstr_destroy(), octstr_get_cstr, send_error(), and send_packet().
Definition at line 702 of file test_cimd2.c.
References eat_int_parm(), LOG_packets, logging, make_timestamp(), number, send_error(), send_packet(), and TIMESTAMP_MAXLEN.
Definition at line 446 of file test_cimd2.c.
References eat_string_parm(), LOG_packets, logging, octstr_create, octstr_destroy(), octstr_get_cstr, octstr_str_compare(), password, send_error(), send_packet(), and username.
Definition at line 472 of file test_cimd2.c.
References LOG_packets, logging, and send_packet().
Definition at line 758 of file test_cimd2.c.
References awaiting_response, LOG_packets, and logging.
Definition at line 685 of file test_cimd2.c.
References eat_string_parm(), LOG_packets, logging, octstr_get_cstr, and send_error().
Definition at line 480 of file test_cimd2.c.
References eat_int_parm(), eat_string_parm(), gwlist_append(), gwlist_create, gwlist_destroy(), gwlist_get(), gwlist_len(), LOG_packets, logging, make_timestamp(), octstr_destroy(), octstr_destroy_item(), octstr_get_cstr, send_error(), send_packet(), text, and TIMESTAMP_MAXLEN.
int main | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 1053 of file test_cimd2.c.
References gwlib_init(), main_loop(), number, option, options, progname, sockfd, usage(), and wait_for_client().
|
static |
Definition at line 935 of file test_cimd2.c.
References error(), gen_data(), inbuffer, interval, intro, octstr_create, octstr_len(), outbuffer, OUTBUFFER_LIMIT, parse_data(), read_data(), sockfd, start_time, warning(), and write_data().
Referenced by main().
|
static |
Definition at line 320 of file test_cimd2.c.
References gw_gmtime().
Referenced by gen_message(), handle_get(), and handle_submit().
Definition at line 817 of file test_cimd2.c.
References ETX, octstr_copy, octstr_delete(), octstr_destroy(), octstr_len(), octstr_search_char(), parse_packet(), and STX.
Referenced by main_loop().
Definition at line 788 of file test_cimd2.c.
References eat_char(), eat_checksum(), eat_number(), handlers, LOG_packets, logging, opcode, and send_error().
Referenced by parse_data().
|
static |
Definition at line 201 of file test_cimd2.c.
References CR, ETX, LF, STX, and TAB.
Referenced by read_data(), and write_data().
|
static |
Definition at line 846 of file test_cimd2.c.
References size.
Referenced by gen_message().
|
static |
Definition at line 869 of file test_cimd2.c.
References size.
Referenced by gen_message().
|
static |
Definition at line 856 of file test_cimd2.c.
References ETX, size, STX, and TAB.
Referenced by gen_message().
|
static |
Definition at line 224 of file test_cimd2.c.
References error(), EVIL_BUFSIZE, LOG_data, logging, octstr_append_data(), and pretty_print().
Referenced by main_loop().
|
static |
Definition at line 360 of file test_cimd2.c.
References LOG_packets, logging, opcode, and send_packet().
Referenced by handle_cancel(), handle_delivery_request(), handle_enquire(), handle_get(), handle_login(), handle_set(), handle_submit(), and parse_packet().
|
static |
Definition at line 330 of file test_cimd2.c.
References ACT_listen, activity, ETX, octstr_format_append(), octstr_get_char(), octstr_len(), opcode, STX, and TAB.
Referenced by gen_message(), handle_alive(), handle_cancel(), handle_delivery_request(), handle_enquire(), handle_get(), handle_login(), handle_logout(), handle_submit(), and send_error().
|
static |
|
static |
Definition at line 1016 of file test_cimd2.c.
References error(), gw_netaddr_to_octstr(), info(), make_server_socket(), octstr_destroy(), octstr_get_cstr, panic, progname, and socket_set_blocking().
Referenced by main().
|
static |
Definition at line 244 of file test_cimd2.c.
References error(), EVIL_BUFSIZE, LOG_data, logging, octstr_delete(), octstr_get_many_chars(), octstr_len(), pretty_print(), and warning().
Referenced by main_loop().
int activity = ACT_listen |
Definition at line 136 of file test_cimd2.c.
Referenced by gen_data(), send_packet(), and usage().
int awaiting_response = 0 |
Definition at line 317 of file test_cimd2.c.
Referenced by gen_message(), handle_alive_response(), handle_deliver_response(), handle_deliver_status_report_response(), and handle_nack().
int checking = CHK_nothing |
Definition at line 139 of file test_cimd2.c.
Referenced by usage().
int deliveries = 0 |
Definition at line 142 of file test_cimd2.c.
Referenced by gen_data(), and handle_deliver_response().
packet_handler handler |
Definition at line 770 of file test_cimd2.c.
struct { ... } handlers[] |
Referenced by parse_packet().
Octstr* inbuffer |
Definition at line 147 of file test_cimd2.c.
Referenced by main_loop().
unsigned char* intro = "" |
Definition at line 105 of file test_cimd2.c.
Referenced by main_loop().
void* location |
Definition at line 1001 of file test_cimd2.c.
Referenced by at2_read_pending_incoming_messages().
int logging = LOG_nothing |
Definition at line 138 of file test_cimd2.c.
Referenced by gen_message(), handle_alive(), handle_alive_response(), handle_cancel(), handle_deliver_response(), handle_deliver_status_report_response(), handle_delivery_request(), handle_enquire(), handle_get(), handle_login(), handle_logout(), handle_nack(), handle_set(), handle_submit(), parse_packet(), read_data(), send_error(), usage(), and write_data().
int max_deliveries = -1 |
Definition at line 141 of file test_cimd2.c.
Referenced by gen_data(), and handle_deliver_response().
int number |
Definition at line 1002 of file test_cimd2.c.
Referenced by handle_get(), and main().
int opcode |
Definition at line 769 of file test_cimd2.c.
Referenced by parse_packet(), send_error(), send_packet(), and ws_asm_ins().
unsigned char* option |
Definition at line 1000 of file test_cimd2.c.
Referenced by main(), and parse_options().
struct { ... } options[] |
Referenced by main().
Octstr* outbuffer |
Definition at line 148 of file test_cimd2.c.
Referenced by main_loop().
unsigned char* password = "bar" |
Definition at line 100 of file test_cimd2.c.
Referenced by authorise_username(), check_login(), cimd_open(), emi_open(), handle_login(), http_add_basic_auth(), http_use_proxy(), httpd_check_authorization(), init_wapbox(), pack_credentials(), parse_cgivars_for_password(), password_matches(), proxy_unpack_credentials(), response(), smpp_create(), smsc_open(), smsc_smpp_create(), unpack_credentials(), usage(), and wap_push_ppg_pushuser_authenticate().
int port = 6789 |
Definition at line 102 of file test_cimd2.c.
unsigned char* progname |
Definition at line 96 of file test_cimd2.c.
Referenced by main(), usage(), and wait_for_client().
int sockfd = -1 |
Definition at line 145 of file test_cimd2.c.
Referenced by conn_open_tcp_nb_with_port(), conn_open_tcp_with_port(), main(), and main_loop().
int spew = SPEW_nothing |
Definition at line 137 of file test_cimd2.c.
Referenced by gen_data(), and usage().
time_t start_time = 0 |
Definition at line 143 of file test_cimd2.c.
Referenced by handle_deliver_response(), and main_loop().
unsigned char* username = "foo" |
Definition at line 99 of file test_cimd2.c.
Referenced by authorise_username(), cimd_open(), emi_open(), handle_login(), http_add_basic_auth(), http_use_proxy(), ota_tokenize_settings(), pap_request_thread(), parse_cgivars_for_username(), response(), set_dlr_url(), set_smsbox_id(), set_smsc_id(), smpp_create(), smsc_open(), smsc_smpp_create(), usage(), user_find_by_username(), wap_push_ppg_pushuser_authenticate(), wap_push_ppg_pushuser_client_phone_number_acceptable(), wap_push_ppg_pushuser_dlr_url_get(), wap_push_ppg_pushuser_smsbox_id_get(), and wap_push_ppg_pushuser_smsc_id_get().