1
0
Fork 0

fix for DLR in MM4

This commit is contained in:
bagyenda 2008-07-09 04:40:35 +00:00
parent f7fa35d3ea
commit 0cb6626339
5 changed files with 32 additions and 21 deletions

View File

@ -1,3 +1,5 @@
2008-07-09 P. A. Bagyenda <bagyenda@dsmagic.com>
* Fix for FROM address in MM4_delivery_report.REQ packet
2008-07-07 P. A. Bagyenda <bagyenda@dsmagic.com>
* Move to compile against Kannel-CVS
2008-07-07 P. A. Bagyenda <bagyenda@dsmagic.com>

View File

@ -60,6 +60,7 @@ static int pgq_cleanup_module(void)
gw_assert(free_conns);
gwlist_remove_producer(free_conns);
sleep(2);
gwlist_destroy(free_conns, (void *)PQfinish);
free_conns = NULL;
@ -71,19 +72,22 @@ static PGconn *get_conn(void)
{
PGconn *c;
PGresult *r;
gw_assert(free_conns);
if (free_conns == NULL) return NULL;
c = gwlist_consume(free_conns);
r = PQexec(c, "BEGIN"); /* start a transaction. */
PQclear(r);
if (c) { /* might fail if we are shutting down. */
r = PQexec(c, "BEGIN"); /* start a transaction. */
PQclear(r);
}
return c;
}
static void return_conn(PGconn *c)
{
PGresult *r;
gw_assert(free_conns);
if (free_conns == NULL) return;
/* commit or destroy transaction. */
if (PQtransactionStatus(c) == PQTRANS_INERROR)
@ -432,7 +436,7 @@ static int _puthdr(PGconn *c, int64_t qid, char *hname, char *val)
static int writeenvelope(MmsEnvelope *e, int newenv)
{
char *s, buf[512], cmd[QFNAMEMAX*4 + 1], lastt[128], sendt[128], expiryt[128], *xfrom;
int i, n, res = 0;
int i, n;
struct pgfile_t *qfs = e ? e->qfs_data : NULL;
PGresult *r;
@ -573,7 +577,7 @@ static int writeenvelope(MmsEnvelope *e, int newenv)
_puthdr(qfs->conn, qfs->qid,"b", buf);
}
return res;
return 0;
}

View File

@ -751,9 +751,8 @@ int mms_sendtoemail(Octstr *from, Octstr *to,
} else {
char *x, tmp[32];
Octstr *xsender = octstr_format("system-user@%S", myhostname);
Octstr *y;
if (msgid) {
y = (octstr_get_char(msgid, 0) == '"') ? octstr_duplicate(msgid) :
octstr_format("\"%S\"", msgid);
@ -787,7 +786,9 @@ int mms_sendtoemail(Octstr *from, Octstr *to,
else if (mtype == MMS_MSGTYPE_DELIVERY_IND) {
Octstr *s = http_header_value(headers, octstr_imm("X-Mms-Status"));
x = "MM4_delivery_report.REQ";
/* insert FROM address as recipient as per spec */
http_header_add(newhdrs, "From", octstr_get_cstr(to));
/* rename status header. */
http_header_remove_all(headers, "X-Mms-Status");
http_header_add(newhdrs, "X-Mms-MM-Status-Code",
@ -795,9 +796,11 @@ int mms_sendtoemail(Octstr *from, Octstr *to,
if (!s)
warning(0, "MMS Delivery report with missing Status!");
octstr_destroy(s);
} else if (mtype == MMS_MSGTYPE_READ_REC_IND)
} else if (mtype == MMS_MSGTYPE_READ_REC_IND) {
x = "MM4_read_reply_report.REQ";
else {
/* insert FROM address as recipient as per spec */
http_header_add(newhdrs, "From", octstr_get_cstr(to));
} else {
*error = octstr_format("Invalid message type %s on MM4 outgoing interface!",
mms_message_type_to_cstr(mtype));
x = "";

View File

@ -12,6 +12,8 @@
* the GNU General Public License, with a few exceptions granted (see LICENSE)
*/
#include "mmsrelay.h"
#include <errno.h>
#include <strings.h>
#define WAPPUSH_PORT 2948
@ -138,7 +140,7 @@ static void start_push(Octstr *rcpt_to, int isphonenum, MmsEnvelope *e, MmsMsg *
e = update_env_success(e, xto);
} else {
e = update_env_failed(e);
error(0, "push to %s:%d failed, no reason found", octstr_get_cstr(to), WAPPUSH_PORT);
error(0, "push to %s:%d failed: %s", octstr_get_cstr(to), WAPPUSH_PORT, strerror(errno));
}
octstr_destroy(addr);
if (e)
@ -462,15 +464,15 @@ static int sendNotify(MmsEnvelope *e)
e ? e->msgId : NULL, NULL, NULL);
if (msg) mms_destroy(msg);
if (phonenum)
octstr_destroy(phonenum);
if (rcpt_ip)
octstr_destroy(rcpt_ip);
octstr_destroy(phonenum);
octstr_destroy(rcpt_ip);
octstr_destroy(to);
if (msgId) octstr_destroy(msgId);
if (fromproxy) octstr_destroy(fromproxy);
octstr_destroy(msgId);
octstr_destroy(fromproxy);
octstr_destroy(from);
if (err) octstr_destroy(err);
octstr_destroy(err);
return 1;
}

View File

@ -983,7 +983,7 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
|| octstr_case_compare(allow_report, octstr_imm("Yes")) == 0) &&
e->dlr) {
Octstr *x;
Octstr *from = h->client_addr ? h->client_addr : settings->system_user;
Octstr *from = h->client_addr ? h->client_addr : settings->system_user;
List *l = gwlist_create();
mrpt = mms_deliveryreport(e->msgId, h->client_addr, time(NULL), status);