1
0
Fork 0

mmsbox cdr changes

This commit is contained in:
bagyenda 2008-11-26 09:16:20 +00:00
parent f10b0e4e41
commit d93be7fce5
6 changed files with 87 additions and 37 deletions

View File

@ -1,3 +1,6 @@
2008-11-26 P. A. Bagyenda <bagyenda@dsmagic.com>
* Added validityperiod sendmms cgi param
* Minor changes to mmsbox CDR logging to improve clarity
2008-11-21 P. A. Bagyenda <bagyenda@dsmagic.com>
* Minor improvements in DLR processing (mmsbox)
2008-11-20 P. A. Bagyenda <bagyenda@dsmagic.com>

View File

@ -3021,6 +3021,16 @@ faked-sender = 100<br>
</td>
</tr>
<tr>
<td valign=top >
<tt>validityperiod</tt>
</td>
<td valign=top>
Optional. Should be an integer, giving the number of minutes before
this message is considered expired by the receiving MMSC.
</td>
</tr>
</table>
</p>

View File

@ -21,6 +21,7 @@ static Octstr *shell_cmd;
#undef info
static void default_logger(enum mbuni_event_type_t type, const char *subtype, int level, const char *file,
int line,
const char *function,
const char *interface, Octstr *id,
Octstr *msg)
{
@ -37,8 +38,8 @@ static void default_logger(enum mbuni_event_type_t type, const char *subtype, in
break;
}
f(level, "%s:%d [%s] [%s] %s",
file, line,
f(level, "%s:%d <%s> [%s] [%s] %s",
file, line, function,
interface ? interface : "n/a",
id ? octstr_get_cstr(id) : "n/a",
octstr_get_cstr(msg));
@ -46,9 +47,9 @@ static void default_logger(enum mbuni_event_type_t type, const char *subtype, in
static void shell_logger(enum mbuni_event_type_t type, const char *subtype, int level, const char *file,
int line,
const char *interface, Octstr *id,
Octstr *msg)
int line, const char *function,
const char *interface, Octstr *id,
Octstr *msg)
{
char *xtype;
Octstr *cmd, *xid = octstr_duplicate(id);
@ -122,7 +123,7 @@ int mms_event_logger_init(MmsEventLoggerFuncs *funcs, Octstr *init_param)
}
extern void mms_event_logger(enum mbuni_event_type_t type, const char *subtype, int level, const char *file,
int line, char *interface, Octstr *id,
int line, const char *function, char *interface, Octstr *id,
char *fmt,...)
{
Octstr *x;
@ -133,7 +134,7 @@ extern void mms_event_logger(enum mbuni_event_type_t type, const char *subtype,
va_end(ap);
log_handler->log_event(type,subtype, level, file, line, interface, id, x);
log_handler->log_event(type,subtype, level, file, line, function, interface, id, x);
octstr_destroy(x);
}

View File

@ -19,7 +19,9 @@
typedef enum mbuni_event_type_t {MBUNI_ERROR, MBUNI_INFO, MBUNI_WARNING} mbuni_event_type_t;
typedef struct MmsEventLoggerFuncs {
int (*init)(Octstr *init_param);
void (*log_event)(enum mbuni_event_type_t type, const char *subtype, int level, const char *file, int line,
void (*log_event)(enum mbuni_event_type_t type, const char *subtype, int level, const char *file,
int line,
const char *function,
const char *interface, Octstr *id,
Octstr *msg);
int (*cleanup)(void);
@ -34,16 +36,17 @@ extern int mms_event_logger_init(MmsEventLoggerFuncs *funcs, Octstr *init_param)
extern void mms_event_logger_cleanup(void);
extern void mms_event_logger(enum mbuni_event_type_t type, const char *subtype,
int level, const char *file,
int line, char *interface, Octstr *id,
int line, const char *function,
char *interface, Octstr *id,
char *fmt,...);
#define mms_error(level,intf,id,fmt,...) mms_event_logger(MBUNI_ERROR, NULL, (level), __FILE__, __LINE__,(intf), (id),(fmt),##__VA_ARGS__)
#define mms_info(level,intf,id,fmt,...) mms_event_logger(MBUNI_INFO, NULL, (level), __FILE__, __LINE__,(intf), (id),(fmt),##__VA_ARGS__)
#define mms_warning(level,intf,id,fmt,...) mms_event_logger(MBUNI_WARNING, NULL, (level), __FILE__, __LINE__,(intf), (id),(fmt),##__VA_ARGS__)
#define mms_error(level,intf,id,fmt,...) mms_event_logger(MBUNI_ERROR, NULL, (level), __FILE__, __LINE__,__FUNCTION__,(intf), (id),(fmt),##__VA_ARGS__)
#define mms_info(level,intf,id,fmt,...) mms_event_logger(MBUNI_INFO, NULL, (level), __FILE__, __LINE__,__FUNCTION__,(intf), (id),(fmt),##__VA_ARGS__)
#define mms_warning(level,intf,id,fmt,...) mms_event_logger(MBUNI_WARNING, NULL, (level), __FILE__, __LINE__,__FUNCTION__,(intf), (id),(fmt),##__VA_ARGS__)
#define mms_error_ex(subtype,level,intf,id,fmt,...) mms_event_logger(MBUNI_ERROR, (subtype), (level), __FILE__, __LINE__,(intf), (id),(fmt),##__VA_ARGS__)
#define mms_info_ex(subtype,level,intf,id,fmt,...) mms_event_logger(MBUNI_INFO, (subtype), (level), __FILE__, __LINE__,(intf), (id),(fmt),##__VA_ARGS__)
#define mms_warning_ex(subtype,level,intf,id,fmt,...) mms_event_logger(MBUNI_WARNING, (subtype), (level), __FILE__, __LINE__,(intf), (id),(fmt),##__VA_ARGS__)
#define mms_error_ex(subtype,level,intf,id,fmt,...) mms_event_logger(MBUNI_ERROR, (subtype), (level), __FILE__, __LINE__,__FUNCTION__,(intf), (id),(fmt),##__VA_ARGS__)
#define mms_info_ex(subtype,level,intf,id,fmt,...) mms_event_logger(MBUNI_INFO, (subtype), (level), __FILE__, __LINE__,__FUNCTION__,(intf), (id),(fmt),##__VA_ARGS__)
#define mms_warning_ex(subtype,level,intf,id,fmt,...) mms_event_logger(MBUNI_WARNING, (subtype), (level), __FILE__, __LINE__,__FUNCTION__,(intf), (id),(fmt),##__VA_ARGS__)
MmsEventLoggerFuncs shell_event_logger; /* For logging using a shell command. */

View File

@ -1295,17 +1295,24 @@ static Octstr *mm7http_send(MmscGrp *mmc, Octstr *from, Octstr *to,
}
static int mms_sendtommsc(MmscGrp *mmc, Octstr *from, Octstr *to, Octstr *transid,
static int mms_sendtommsc(MmscGrp *mmc, MmsEnvelope *e, Octstr *to,
Octstr *orig_transid,
Octstr *linkedid, char *vasid, Octstr *service_code,
MmsMsg *m, Octstr *dlr_url, Octstr *rr_url,
List *hdrs,
MmsMsg *m,
Octstr **new_msgid,
List **errhdrs)
{
Octstr *id = NULL, *groupid = NULL;
int ret = 0, retry = 0;
double throughput = 0;
Octstr *from = e->from;
Octstr *transid = e->msgId;
Octstr *linkedid = e->token; /* token = linkedid */
char *vasid = e->vasid ? octstr_get_cstr(e->vasid) : NULL;
Octstr *service_code = e->vaspid;
Octstr *dlr_url = e->url1;
Octstr *rr_url = e->url2;
List *hdrs = e->hdrs;
mutex_lock(mmc->mutex); { /* Grab a lock on it. */
Octstr *err = NULL;
@ -1344,7 +1351,7 @@ static int mms_sendtommsc(MmscGrp *mmc, Octstr *from, Octstr *to, Octstr *transi
ret = retry ? MMS_SEND_ERROR_TRANSIENT : MMS_SEND_ERROR_FATAL;
*new_msgid = id;
octstr_destroy(groupid);
if (throughput > 0)
gwthread_sleep(1.0/throughput);
@ -1425,15 +1432,10 @@ static int sendMsg(MmsEnvelope *e)
e->hdrs);
octstr_destroy(pfrom);
} else {
res = mms_sendtommsc(mmc, e->from, to->rcpt,
e->msgId,
res = mms_sendtommsc(mmc, e,
to->rcpt,
otransid,
e->token, /* token = linkedid */
e->vasid ? octstr_get_cstr(e->vasid) : NULL,
e->vaspid,
msg,
e->url1, e->url2,
e->hdrs,
&new_msgid,
&errl);
if (errl)
@ -1466,7 +1468,10 @@ static int sendMsg(MmsEnvelope *e)
/* handle CDR */
if (res == MMS_SEND_OK || res == MMS_SEND_QUEUED || res == MMS_SEND_ERROR_FATAL) {
Octstr *mclass = mms_get_header_value(msg, octstr_imm("X-Mms-Message-Class"));
Octstr *prio = mms_get_header_value(msg, octstr_imm("X-Mms-Priority"));
Octstr *mstatus = mms_get_header_value(msg, octstr_imm("X-Mms-Status"));
/* Do CDR */
cdrfs->logcdr(e->created,
octstr_get_cstr(e->from),
@ -1477,10 +1482,16 @@ static int sendMsg(MmsEnvelope *e)
"MM7",
e->msize,
(char *)mms_message_type_to_cstr(e->msgtype),
NULL, NULL, /* XXX will add these later. */
res == MMS_SEND_ERROR_FATAL ? "dropped" : "sent",
prio ? octstr_get_cstr(prio) : NULL,
mclass ? octstr_get_cstr(mclass) : NULL,
res == MMS_SEND_ERROR_FATAL ? "dropped" : (mstatus ? octstr_get_cstr(mstatus) : "sent"),
e->dlr,
0);
octstr_destroy(mclass);
octstr_destroy(prio);
octstr_destroy(mstatus);
}
if (err == NULL)

View File

@ -553,7 +553,8 @@ static int mmsbox_send_report(Octstr *from, char *report_type,
http_destroy_headers(rph);
http_destroy_headers(rh);
return ret == HTTP_OK ? 0 : -1;
return http_status_class(ret) == HTTP_STATUS_SUCCESSFUL ? 0 : -1;
}
static int mmsbox_service_dispatch(MmsEnvelope *e)
@ -565,7 +566,7 @@ static int mmsbox_service_dispatch(MmsEnvelope *e)
Octstr *err = NULL, *keyword = NULL;
MmsService *ms;
MmsEnvelopeTo *xto;
Octstr *prio = NULL, *mclass = NULL, *mstatus = NULL;
gw_assert(e->msgtype == MMS_MSGTYPE_SEND_REQ ||
e->msgtype == MMS_MSGTYPE_RETRIEVE_CONF ||
@ -593,8 +594,10 @@ static int mmsbox_service_dispatch(MmsEnvelope *e)
goto done;
}
mclass = mms_get_header_value(msg, octstr_imm("X-Mms-Message-Class"));
prio = mms_get_header_value(msg, octstr_imm("X-Mms-Priority"));
mstatus = mms_get_header_value(msg, octstr_imm("X-Mms-Status"));
if (e->msgtype == MMS_MSGTYPE_DELIVERY_IND ||
e->msgtype == MMS_MSGTYPE_READ_ORIG_IND) {
char *report_type = (e->msgtype == MMS_MSGTYPE_DELIVERY_IND) ? "delivery-report" : "read-report";
@ -688,8 +691,10 @@ done:
"mms-service",
e->msize,
(char *)mms_message_type_to_cstr(e->msgtype),
NULL, NULL, /* XXX will add these later. */
res == 0 ? "forwarded" : "dropped",
prio ? octstr_get_cstr(prio) : NULL,
mclass ? octstr_get_cstr(mclass) : NULL,
mstatus ? octstr_get_cstr(mstatus) :
(res == 0 ? "forwarded" : "dropped"),
e->dlr,
0);
}
@ -705,6 +710,11 @@ done:
octstr_destroy(err);
octstr_destroy(keyword);
mms_destroy(msg);
octstr_destroy(prio);
octstr_destroy(mclass);
octstr_destroy(mstatus);
if (me)
mime_entity_destroy(me);
return 1;
@ -1397,12 +1407,14 @@ static void dispatch_sendmms_recv(List *rl)
Octstr *distro = http_cgi_variable(h->cgivars, "distribution");
Octstr *send_type = http_cgi_variable(h->cgivars, "mms-direction");
Octstr *sheader = http_cgi_variable(h->cgivars, "extra-content-header");
Octstr *validity = http_cgi_variable(h->cgivars, "validityperiod");
Octstr *data_url = NULL;
dlr_url = http_cgi_variable(h->cgivars, "dlr-url");
rr_url = http_cgi_variable(h->cgivars, "rr-url");
allow_adaptations = http_cgi_variable(h->cgivars, "allow-adaptations");
if ((mmc = http_cgi_variable(h->cgivars, "mmsc")) == NULL) {
mmc = octstr_duplicate(u->mmsc); /* could still be NULL */
}
@ -1513,6 +1525,16 @@ static void dispatch_sendmms_recv(List *rl)
if (sheader)
HTTP_REPLACE_HEADER(rh, "X-Mbuni-Content-Header", octstr_get_cstr(sheader));
if (validity) {
int diff = atoi(octstr_get_cstr(validity));
time_t t = time(NULL) + (diff *60);
Octstr *xt = date_format_http(t);
HTTP_REPLACE_HEADER(rh, "X-Mbuni-Expiry", octstr_get_cstr(xt));
octstr_destroy(xt);
}
/* Requests to make_and_queue below can block, but for now we don't care. */
if (ctype && data && !rb) { /* only send if no error. */
int send_as_incoming = (send_type &&