1
0
Fork 0

Added request ip to detokenizer interface

This commit is contained in:
bagyenda 2005-09-27 16:46:09 +00:00
parent 88d7ff9a84
commit fdd73ba3b6
6 changed files with 11 additions and 5 deletions

View File

@ -25,7 +25,7 @@ static int mms_detokenizer_fini(void)
return 0;
}
static Octstr *mms_detokenize(Octstr * token)
static Octstr *mms_detokenize(Octstr * token, Octstr *request_ip)
{
/* Return the MSISDN matching the token as a new Octstr */
return octstr_create("+45xxxxxx");

View File

@ -31,7 +31,7 @@ typedef struct MmsDetokenizerFuncStruct {
/* Looks up the token and returns the msisdn as a new Octstr.
* Return NULL on error, otherwise an Octstr
*/
Octstr *(*mms_detokenize)(Octstr * token);
Octstr *(*mms_detokenize)(Octstr * token, Octstr *request_ip);
/* Given an msisdn, returns the token associated
* Return NULL on error, otherwise an Octstr

View File

@ -30,7 +30,7 @@ static int mms_detokenizer_fini(void)
return 0;
}
static Octstr *mms_detokenize(Octstr * token)
static Octstr *mms_detokenize(Octstr * token, Octstr *request_ip)
{
Octstr *cmd = NULL, *msisdn = NULL;
FILE *fp;

View File

@ -373,7 +373,9 @@ Octstr *mms_makefetchurl(char *qf, Octstr *token, int loc,
}
Octstr *mms_find_sender_msisdn(Octstr *send_url, List *request_hdrs, Octstr *msisdn_header,
Octstr *mms_find_sender_msisdn(Octstr *send_url, List *request_hdrs,
Octstr *msisdn_header,
Octstr *requestip_header,
MmsDetokenizerFuncStruct* detokenizerfuncs)
{
/* Either we have a WAP gateway header as defined, or we look for
@ -385,10 +387,12 @@ Octstr *mms_find_sender_msisdn(Octstr *send_url, List *request_hdrs, Octstr *msi
if (!phonenum || octstr_len(phonenum) == 0) {
List *l = octstr_split(send_url, octstr_imm("/"));
Octstr *ip = http_header_value(request_hdrs,
requestip_header);
if (l && list_len(l) > 1) {
if (detokenizerfuncs)
phonenum = detokenizerfuncs->mms_detokenize(list_get(l, list_len(l) - 1));
phonenum = detokenizerfuncs->mms_detokenize(list_get(l, list_len(l) - 1), ip);
}
if (l)
list_destroy(l, (list_item_destructor_t *)octstr_destroy);

View File

@ -106,5 +106,6 @@ extern Octstr *mms_makefetchurl(char *qf, Octstr *token, int loc,
Octstr *mms_find_sender_msisdn(Octstr *send_url, List *request_hdrs,
Octstr *msisdn_header,
Octstr *requestip_header,
MmsDetokenizerFuncStruct *detokenizerfuncs);
#endif

View File

@ -144,6 +144,7 @@ int main(int argc, char *argv[])
h.base_client_addr = mms_find_sender_msisdn(h.url,
h.headers,
settings->wap_gw_msisdn_header,
settings->wap_gw_ip_header,
settings->mms_detokenizefuncs);
if (!h.base_client_addr) { /* Set to IP sender... XXXX assumes ipv4 only for now*/