171 lines
4.9 KiB
C
171 lines
4.9 KiB
C
#ifndef __MMS_GLOBAL__INCLUDED__
|
|
#define __MMS_GLOBAL__INCLUDED__
|
|
|
|
#include "gwlib/gwlib.h"
|
|
#include "gwlib/mime.h"
|
|
|
|
#include "config.h"
|
|
#include "mms_strings.h"
|
|
#include "mms_msg.h"
|
|
#include "mms_billing.h"
|
|
#include "mms_resolve.h"
|
|
#include "mms_detokenize.h"
|
|
|
|
/* Send errors */
|
|
#define MMS_SEND_OK 0
|
|
#define MMS_SEND_ERROR_TRANSIENT -1
|
|
#define MMS_SEND_ERROR_FATAL -2
|
|
|
|
#define SEND_ERROR_STR(e) ((e) == MMS_SEND_OK ? "Sent" : (e) == MMS_SEND_ERROR_TRANSIENT ? "Retry later" : "Failed")
|
|
/* Useful headers. */
|
|
#define XMSISDN_HEADER "X-WAP-Network-Client-MSISDN"
|
|
#define XIP_HEADER "X-WAP-Network-Client-Address"
|
|
#define MM_NAME "DS_MM"
|
|
|
|
typedef struct MmsProxyRelay {
|
|
Octstr *host;
|
|
Octstr *name;
|
|
Octstr *allowed_prefix;
|
|
Octstr *denied_prefix;
|
|
} MmsProxyRelay;
|
|
|
|
typedef struct MmsBoxSettings {
|
|
Octstr *system_user;
|
|
Octstr *name, *hostname, *host_alias;
|
|
List *local_domains;
|
|
Octstr *unified_prefix, *local_prefix;
|
|
Octstr *sendmail;
|
|
Octstr *global_queuedir, *mm1_queuedir, *mm4_queuedir;
|
|
|
|
Octstr *ua_profile_cache_dir;
|
|
|
|
long maxthreads;
|
|
long maxsendattempts;
|
|
long default_msgexpiry;
|
|
double queue_interval;
|
|
long send_back_off;
|
|
|
|
long port;
|
|
|
|
Octstr *allow_ip;
|
|
Octstr *deny_ip;
|
|
|
|
Octstr *email2mmsrelay_prefixes;
|
|
Octstr *sendsms_url;
|
|
#if 0
|
|
Octstr *sendsms_user, *sendsms_pass, *sendsms_globalsender;
|
|
#endif
|
|
Octstr *billing_params;
|
|
|
|
MmsBillingFuncStruct *mms_billfuncs; /* Link to billing funcs. */
|
|
void *mms_bill_module_data;
|
|
|
|
Octstr *resolver_params;
|
|
MmsResolverFuncStruct *mms_resolvefuncs; /* Link to resolver funcs. */
|
|
void *mms_resolver_module_data;
|
|
|
|
Octstr *detokenizer_params;
|
|
MmsDetokenizerFuncStruct *mms_detokenizefuncs; /* Link to detokenizer funcs. */
|
|
void *mms_detokenizer_module_data;
|
|
|
|
int allow_ip_type;
|
|
|
|
int optimize_notification_size;
|
|
|
|
Octstr *prov_notify;
|
|
Octstr *prov_notify_arg;
|
|
Octstr *prov_getstatus;
|
|
int notify_unprovisioned;
|
|
Octstr *mms_notify_txt;
|
|
Octstr *mms_notify_unprov_txt;
|
|
Octstr *mms_toolarge;
|
|
Octstr *mmbox_host;
|
|
|
|
Octstr *mms_email_txt;
|
|
Octstr *mms_email_html;
|
|
Octstr *wap_gw_msisdn_header;
|
|
Octstr *wap_gw_ip_header;
|
|
} MmsBoxSettings;
|
|
|
|
/* Global variables and shared code used by all modules. */
|
|
|
|
|
|
extern char *mms_hostname; /* Our hostname. */
|
|
#define MMSC_VERSION VERSION
|
|
#define MMS_NAME PACKAGE
|
|
|
|
#if 0
|
|
#define EMAILPROFILE "http://localhost/email.xml" /* For now we hard code it. */
|
|
#define MMBOXPROFILE "http://localhost/mmbox.xml"
|
|
#endif
|
|
|
|
/* Returns mmsbox settings. */
|
|
MmsBoxSettings *mms_load_mmsbox_settings(Cfg *cfg);
|
|
|
|
|
|
/* Returns list of MmsProxyRelay */
|
|
extern List *mms_proxy_relays(Cfg *cfg);
|
|
|
|
extern Octstr *mms_makefetchurl(char *qf, Octstr *token,
|
|
MmsBoxSettings *settings);
|
|
|
|
extern Octstr *mms_maketransid(char *qf, Octstr *mmscname);
|
|
|
|
extern Octstr *mms_getqf_fromtransid(Octstr *transid);
|
|
|
|
extern int mms_decodefetchurl(Octstr *fetch_url,
|
|
Octstr **qf, Octstr **token);
|
|
|
|
Octstr *mms_find_sender_msisdn(Octstr **send_url, List *request_hdrs, Octstr *msisdn_header, MmsDetokenizerFuncStruct *detokenizerfuncs);
|
|
Octstr *mms_find_sender_ip(List *request_hdrs, Octstr *ip_header, Octstr *ip, int *isv6);
|
|
|
|
extern Octstr *mms_isodate(time_t t);
|
|
void mms_lib_init(void);
|
|
|
|
/* get content type while stripping params. If any param is null, fails. */
|
|
int get_content_type(List *hdrs, Octstr **type, Octstr **params);
|
|
|
|
/* Takes a header value, returns the value proper and any parameters... */
|
|
int split_header_value(Octstr *value, Octstr **base_value, Octstr **params);
|
|
/* Returns a list of parameters as http_headers given the semi-comma delimited string.*/
|
|
List *get_value_parameters(Octstr *params);
|
|
|
|
Octstr *make_value_parameters(List *params);
|
|
|
|
/* Where value is comma-separated, make separate header items. */
|
|
void unpack_mimeheaders(MIMEEntity *m);
|
|
|
|
/* Where element has base64 encoding, decode. */
|
|
void unbase64_mimeparts(MIMEEntity *m);
|
|
|
|
/* Where element contains binary data, encode it base64. */
|
|
void base64_mimeparts(MIMEEntity *m);
|
|
|
|
void notify_prov_server(char *cmd, char *from, char *event, char *arg);
|
|
int mms_ind_send(Octstr *prov_cmd, Octstr *to);
|
|
|
|
|
|
/* Send this message to email recipient: Returns 0 on success 1 or 2 on profile error
|
|
* (negate to get right one), -ve on some other error
|
|
*/
|
|
int mms_sendtoemail(Octstr *from, Octstr *to,
|
|
Octstr *subject, Octstr *msgid,
|
|
MmsMsg *msg, int dlr, Octstr **error,
|
|
char *sendmail_cmd, Octstr *myhostname,
|
|
int trans_msg,
|
|
int trans_smil, char *txt, char *html, int append_hostname);
|
|
|
|
/* log to access log. */
|
|
void mms_log(char *logmsg, Octstr *from, List *to,
|
|
int msize, Octstr *msgid,
|
|
Octstr *acct,
|
|
Octstr *viaproxy,
|
|
char *interface, Octstr *ua);
|
|
|
|
void mms_log2(char *logmsg, Octstr *from, Octstr *to,
|
|
int msize, Octstr *msgid,
|
|
Octstr *acct,
|
|
Octstr *viaproxy,
|
|
char *interface, Octstr *ua);
|
|
#endif
|