Kannel: Open Source WAP and SMS gateway  $Revision: 5037 $
wapme.c
Go to the documentation of this file.
1 /* ====================================================================
2  * The Kannel Software License, Version 1.0
3  *
4  * Copyright (c) 2001-2016 Kannel Group
5  * Copyright (c) 1998-2001 WapIT Ltd.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Kannel Group (http://www.kannel.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Kannel" and "Kannel Group" must not be used to
28  * endorse or promote products derived from this software without
29  * prior written permission. For written permission, please
30  * contact org@kannel.org.
31  *
32  * 5. Products derived from this software may not be called "Kannel",
33  * nor may "Kannel" appear in their name, without prior written
34  * permission of the Kannel Group.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE KANNEL GROUP OR ITS CONTRIBUTORS
40  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
41  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
42  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
43  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
44  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
45  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
46  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47  * ====================================================================
48  *
49  * This software consists of voluntary contributions made by many
50  * individuals on behalf of the Kannel Group. For more information on
51  * the Kannel Group, please see <http://www.kannel.org/>.
52  *
53  * Portions of this software are based upon software originally written at
54  * WapIT Ltd., Helsinki, Finland for the Kannel project.
55  */
56 
57 /*----------------------------------------------------------------
58  * Wapme SMS Proxy
59  *
60  * Stipe Tolj <stolj@kannel.org>
61  */
62 
63 #include "gwlib/gwlib.h"
64 
65 
66 static int wapme_smsproxy_send_sms(SMSCConn *conn, Msg *sms)
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 }
89 
91  List *headers, Octstr *body)
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 }
100 
101 /*
102  * static void wapme_smsproxy_receive_sms(SMSCConn *conn, HTTPClient *client,
103  * List *headers, Octstr *body, List *cgivars)
104  *
105  * The HTTP server for MO messages will act with the same interface as smsbox's
106  * sendsms interface, so that the logical difference is hidden and SMS Proxy
107  * can act transparently. So there is no need for an explicite implementation
108  * here.
109  */
110 
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 }
122 
125  .send_sms = wapme_smsproxy_send_sms,
126  .parse_reply = wapme_smsproxy_parse_reply,
127  .receive_sms = kannel_receive_sms,
128 };
129 
void error(int err, const char *fmt,...)
Definition: log.c:612
struct smsc_http_fn_callbacks smsc_http_wapme_callback
Definition: wapme.c:123
Octstr * id
Definition: smscconn_p.h:174
void * data
Definition: smscconn_p.h:249
HTTPCaller * http_ref
Definition: smsc_http.c:143
static int wapme_smsproxy_send_sms(SMSCConn *conn, Msg *sms)
Definition: wapme.c:66
#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
Definition: http.h:142
Definition: msg.h:79
static int wapme_smsproxy_init(SMSCConn *conn, CfgGroup *cfg)
Definition: wapme.c:111
#define octstr_duplicate(ostr)
Definition: octstr.h:187
static void kannel_receive_sms(SMSCConn *conn, HTTPClient *client, List *headers, Octstr *body, List *cgivars)
Definition: smsc_http.c:631
Octstr * octstr_format(const char *fmt,...)
Definition: octstr.c:2462
void octstr_destroy(Octstr *ostr)
Definition: octstr.c:322
static Cfg * cfg
Definition: smsbox.c:115
int(* init)(SMSCConn *conn, CfgGroup *cfg)
Definition: smsc_http.c:135
Definition: octstr.c:118
void bb_smscconn_sent(SMSCConn *conn, Msg *sms, Octstr *reply)
Definition: bb_smscconn.c:279
Octstr * password
Definition: smsc_http.c:155
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:690
Definition: cfg.c:73
#define gwlist_create()
Definition: list.h:136
static void wapme_smsproxy_parse_reply(SMSCConn *conn, Msg *msg, int status, List *headers, Octstr *body)
Definition: wapme.c:90
Octstr * username
Definition: smsc_http.c:154
void bb_smscconn_send_failed(SMSCConn *conn, Msg *sms, int reason, Octstr *reply)
Definition: bb_smscconn.c:328
Octstr * send_url
Definition: smsc_http.c:150
static Octstr * url
Definition: test_xmlrpc.c:84
Definition: list.c:102
static XMLRPCDocument * msg
Definition: test_xmlrpc.c:86
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.