101 #include "../smsc_http_p.h"   189     fm = gw_malloc(
sizeof(*fm));
   199     if (fm->
from == NULL)
   205     if (fm->
text == NULL)
   218     if (fm->
binfo == NULL)
   233     if (fm->
flash == NULL)
   278     Octstr *tmp_string, *retmsg;
   294             warning(0, 
"HTTP[%s]: Received HTTP POST with wrong content-type `%s', should be `application/x-www-form-urlencoded'.",
   315     debug(
"smsc.http.generic", 0, 
"HTTP[%s]: Received an HTTP request",
   319         (user == NULL || pass == NULL ||
   322         error(0, 
"HTTP[%s]: Authorization failure",
   335         if (dlrmsg != NULL) {
   340             debug(
"smsc.http.generic", 0, 
"HTTP[%s]: Received DLR for DLR-URL <%s>",
   343             if (dlrerr != NULL) {
   345                 if (dlrmsg->sms.meta_data == NULL)
   363             error(0,
"HTTP[%s]: Got DLR but could not find message or was not interested "   364                   "in it id<%s> dst<%s>, type<%d>",
   370     } 
else if (
from == NULL || 
to == NULL || 
text == NULL) {
   371         error(0, 
"HTTP[%s]: Insufficient args",
   376         error(0, 
"HTTP[%s]: UDH field misformed, rejected",
   381         error(0, 
"HTTP[%s]: UDH field is too long, rejected",
   411             msg->sms.validity = time(NULL) + 
msg->sms.validity * 60;
   416             msg->sms.deferred = time(NULL) + 
msg->sms.deferred * 60;
   422         debug(
"smsc.http.generic", 0, 
"HTTP[%s]: Constructing new SMS",
   430             error(0, 
"HTTP[%s]: Charset or body misformed, will leave it as it is.",
   439         msg->sms.time = time(NULL);
   457     debug(
"smsc.http.generic", 0, 
"HTTP[%s]: Sending reply",
   468     switch (
msg->sms.coding) {
   475             error(0, 
"Failed to convert msgdata from UTF-8 to %s, will leave as is",
   485             error(0, 
"Failed to convert msgdata from UCS-2 to %s, will leave as is",
   527         debug(
"smsc.http.generic", 0, 
"HTTP[%s]: Sending POST request <%s>",
   531                            p->
query, 0, sms, NULL);
   534         debug(
"smsc.http.generic", 0, 
"HTTP[%s]: Sending GET request <%s>",
   552     regmatch_t pmatch[2];
   561         (gw_regex_exec(values->
success_regex, body, 0, NULL, 0) == 0)) {
   569                     if (pmatch[1].rm_so != -1 && pmatch[1].rm_eo != -1) {
   570                         msgid = 
octstr_copy(body, pmatch[1].rm_so, pmatch[1].rm_eo - pmatch[1].rm_so);
   571                         debug(
"smsc.http.generic", 0, 
"HTTP[%s]: Found foreign message id <%s> in body.",
   578                     warning(0, 
"HTTP[%s]: Can't get the foreign message id from the HTTP body.",
   599         warning(0, 
"HTTP[%s]: Message temporary not accepted, will retry.",
   605         error(0, 
"HTTP[%s]: Message was rejected. SMSC response was:",
   630         if ((values->
success_regex = gw_regex_comp(os, REG_EXTENDED|REG_NOSUB)) == NULL)
   631             error(0, 
"HTTP[%s]: Could not compile pattern '%s' defined for variable 'status-success-regex'",
   636         error(0, 
"HTTP[%s]: 'status-success-regex' required for generic http smsc",
   641         if ((values->
permfail_regex = gw_regex_comp(os, REG_EXTENDED|REG_NOSUB)) == NULL)
   642             panic(0, 
"Could not compile pattern '%s' defined for variable 'status-permfail-regex'", 
octstr_get_cstr(os));
   646         if ((values->
tempfail_regex = gw_regex_comp(os, REG_EXTENDED|REG_NOSUB)) == NULL)
   647             panic(0, 
"Could not compile pattern '%s' defined for variable 'status-tempfail-regex'", 
octstr_get_cstr(os));
   652             panic(0, 
"Could not compile pattern '%s' defined for variable 'generic-foreign-id-regex'", 
octstr_get_cstr(os));
   661     debug(
"", 0, 
"generic init completed");
   671     if (conn == NULL || conn->
data == NULL)
   690     debug(
"", 0, 
"generic destroy completed");
 void parse_cgivars(List *cgivars, Octstr *pairs)
 
void error(int err, const char *fmt,...)
 
static int generic_send_sms(SMSCConn *conn, Msg *sms)
 
Msg * msg_duplicate(Msg *msg)
 
void http_header_add(List *headers, char *name, char *contents)
 
gw_assert(wtls_machine->packet_to_send !=NULL)
 
static void generic_destroy(SMSCConn *conn)
 
static void generic_receive_sms(SMSCConn *conn, HTTPClient *client, List *headers, Octstr *body, List *cgivars)
 
static void client(int port)
 
#define cfg_get(grp, varname)
 
void uuid_unparse(const uuid_t uu, char *out)
 
void http_header_get_content_type(List *headers, Octstr **type, Octstr **charset)
 
static void generic_parse_reply(SMSCConn *conn, Msg *msg, int status, List *headers, Octstr *body)
 
static void convert_charset(Msg *msg, Octstr *charset, Octstr **content_type)
 
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)
 
long octstr_search_char(const Octstr *ostr, int ch, long pos)
 
Octstr * http_cgi_variable(List *list, char *name)
 
void http_destroy_headers(List *headers)
 
void http_urlparse_destroy(HTTPURLParse *p)
 
void http_start_request(HTTPCaller *caller, int method, Octstr *url, List *headers, Octstr *body, int follow, void *id, Octstr *certkeyfile)
 
void http_send_reply(HTTPClient *client, int status, List *headers, Octstr *body)
 
Octstr * octstr_imm(const char *cstr)
 
long bb_smscconn_receive(SMSCConn *conn, Msg *sms)
 
Octstr * urltrans_fill_escape_codes(Octstr *pattern, Msg *request)
 
#define octstr_duplicate(ostr)
 
#define octstr_dump(ostr, level,...)
 
static int generic_init(SMSCConn *conn, CfgGroup *cfg)
 
struct smsc_http_fn_callbacks smsc_http_generic_callback
 
void msg_destroy(Msg *msg)
 
static struct fieldmap * generic_get_field_map(CfgGroup *grp)
 
int octstr_case_compare(const Octstr *os1, const Octstr *os2)
 
void warning(int err, const char *fmt,...)
 
Octstr * octstr_format(const char *fmt,...)
 
void octstr_destroy(Octstr *ostr)
 
int sms_charset_processing(Octstr *charset, Octstr *body, int coding)
 
#define octstr_create(cstr)
 
#define SMS_PARAM_UNDEFINED
 
const char * content_type
 
long octstr_len(const Octstr *ostr)
 
int(* init)(SMSCConn *conn, CfgGroup *cfg)
 
void bb_smscconn_sent(SMSCConn *conn, Msg *sms, Octstr *reply)
 
void debug(const char *place, int err, const char *fmt,...)
 
int cfg_get_integer(long *n, CfgGroup *grp, Octstr *varname)
 
HTTPURLParse * parse_url(Octstr *url)
 
void bb_smscconn_send_failed(SMSCConn *conn, Msg *sms, int reason, Octstr *reply)
 
static void fieldmap_destroy(struct fieldmap *fieldmap)
 
regex_t * generic_foreign_id_regex
 
int octstr_get_char(const Octstr *ostr, long pos)
 
#define DLR_IS_ENABLED_DEVICE(dlr)
 
static XMLRPCDocument * msg
 
static Octstr * meta_data
 
int charset_convert(Octstr *string, char *charset_from, char *charset_to)
 
int octstr_compare(const Octstr *ostr1, const Octstr *ostr2)