Kannel: Open Source WAP and SMS gateway  $Revision: 5037 $
wapme.c File Reference
#include "gwlib/gwlib.h"

Go to the source code of this file.

Functions

static int wapme_smsproxy_send_sms (SMSCConn *conn, Msg *sms)
 
static void wapme_smsproxy_parse_reply (SMSCConn *conn, Msg *msg, int status, List *headers, Octstr *body)
 
static int wapme_smsproxy_init (SMSCConn *conn, CfgGroup *cfg)
 

Variables

struct smsc_http_fn_callbacks smsc_http_wapme_callback
 

Function Documentation

static int wapme_smsproxy_init ( SMSCConn conn,
CfgGroup cfg 
)
static

Definition at line 111 of file wapme.c.

References smscconn::data, error(), smscconn::id, octstr_get_cstr, conndata::password, and conndata::username.

112 {
113  ConnData *conndata = conn->data;
114 
115  if (conndata->username == NULL || conndata->password == NULL) {
116  error(0, "HTTP[%s]: 'username' and 'password' required for Wapme http smsc",
117  octstr_get_cstr(conn->id));
118  return -1;
119  }
120  return 0;
121 }
void error(int err, const char *fmt,...)
Definition: log.c:612
Octstr * id
Definition: smscconn_p.h:174
void * data
Definition: smscconn_p.h:249
#define octstr_get_cstr(ostr)
Definition: octstr.h:233
Octstr * password
Definition: smsc_http.c:155
Octstr * username
Definition: smsc_http.c:154
static void wapme_smsproxy_parse_reply ( SMSCConn conn,
Msg msg,
int  status,
List headers,
Octstr body 
)
static

Definition at line 90 of file wapme.c.

References bb_smscconn_send_failed(), bb_smscconn_sent(), HTTP_ACCEPTED, HTTP_OK, octstr_duplicate, and SMSCCONN_FAILED_MALFORMED.

92 {
93  if (status == HTTP_OK || status == HTTP_ACCEPTED) {
94  bb_smscconn_sent(conn, msg, NULL);
95  } else {
96  bb_smscconn_send_failed(conn, msg,
98  }
99 }
Definition: http.h:142
#define octstr_duplicate(ostr)
Definition: octstr.h:187
void bb_smscconn_sent(SMSCConn *conn, Msg *sms, Octstr *reply)
Definition: bb_smscconn.c:279
void bb_smscconn_send_failed(SMSCConn *conn, Msg *sms, int reason, Octstr *reply)
Definition: bb_smscconn.c:328
static int wapme_smsproxy_send_sms ( SMSCConn conn,
Msg sms 
)
static

Definition at line 66 of file wapme.c.

References smscconn::data, debug(), gwlist_create, http_destroy_headers(), HTTP_METHOD_GET, conndata::http_ref, http_start_request(), smscconn::id, octstr_destroy(), octstr_format(), octstr_get_cstr, conndata::send_url, and url.

67 {
68  ConnData *conndata = conn->data;
69  Octstr *url;
70  List *headers;
71 
72  url = octstr_format("%S?command=forward&smsText=%E&phoneNumber=%E"
73  "&serviceNumber=%E&smsc=%E",
74  conndata->send_url,
75  sms->sms.msgdata, sms->sms.sender, sms->sms.receiver,
76  sms->sms.smsc_id);
77 
78  headers = gwlist_create();
79  debug("smsc.http.wapme", 0, "HTTP[%s]: Start request",
80  octstr_get_cstr(conn->id));
81  http_start_request(conndata->http_ref, HTTP_METHOD_GET, url, headers,
82  NULL, 0, sms, NULL);
83 
84  octstr_destroy(url);
85  http_destroy_headers(headers);
86 
87  return 0;
88 }
Octstr * id
Definition: smscconn_p.h:174
void * data
Definition: smscconn_p.h:249
HTTPCaller * http_ref
Definition: smsc_http.c:143
#define octstr_get_cstr(ostr)
Definition: octstr.h:233
void http_destroy_headers(List *headers)
Definition: http.c:2856
void http_start_request(HTTPCaller *caller, int method, Octstr *url, List *headers, Octstr *body, int follow, void *id, Octstr *certkeyfile)
Definition: http.c:1745
Octstr * octstr_format(const char *fmt,...)
Definition: octstr.c:2462
void octstr_destroy(Octstr *ostr)
Definition: octstr.c:322
Definition: octstr.c:118
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:690
#define gwlist_create()
Definition: list.h:136
Octstr * send_url
Definition: smsc_http.c:150
static Octstr * url
Definition: test_xmlrpc.c:84
Definition: list.c:102

Variable Documentation

struct smsc_http_fn_callbacks smsc_http_wapme_callback
Initial value:
= {
.receive_sms = kannel_receive_sms,
}
static int wapme_smsproxy_send_sms(SMSCConn *conn, Msg *sms)
Definition: wapme.c:66
static int wapme_smsproxy_init(SMSCConn *conn, CfgGroup *cfg)
Definition: wapme.c:111
static void kannel_receive_sms(SMSCConn *conn, HTTPClient *client, List *headers, Octstr *body, List *cgivars)
Definition: smsc_http.c:631
static void wapme_smsproxy_parse_reply(SMSCConn *conn, Msg *msg, int status, List *headers, Octstr *body)
Definition: wapme.c:90

Definition at line 123 of file wapme.c.

Referenced by smsc_http_create().

See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.