[SR-Users] how to m_store to database not just a "body" with MSILO?

Carsten Bock carsten at ng-voice.com
Fri Jul 18 09:44:17 CEST 2014


Hi,

actually, you can replace the m_store() and m_dump() with some
scripting. This gives you quite some flexibility on message
storage/message retrieval.
I didn't test this too much so far, the basic tests i did with Bria were fine:

m_store
-------------------------------------------------
// xlog("insert into silo (src_addr, dst_addr, username, inc_time,
ctype, body) values ('$fu', '$tu',  '$tU', unix_timestamp(), '$cT',
'$rb');\n");
if (sql_query("msilo", "insert into silo (src_addr, dst_addr,
username, inc_time, ctype, body) values ('$fu', '$tu',  '$tU',
unix_timestamp(), '$cT', '$rb');")) {
  t_reply("202", "Accepted");
} else {
  t_reply("503", "Service Unavailable");
}

m_dump
-------------------------------------------------
if (is_method("REGISTER") && is_present_hf("Expires") &&
$(hdr(Expires){s.int})==0) {
  xlog("This is an un-registration\n");
  return;
} else {
  xlog("Dumping offline messages...\n");
  async_sleep("3");
  // xlog("select src_addr, dst_addr, inc_time, ctype, body from silo
where username='$fU';");
  sql_query("msilo", "select src_addr, dst_addr, inc_time, ctype, body
from silo where username='$fU' order by inc_time asc;", "msgs");
  // xlog("rows: $dbr(msgs=>rows) cols: $dbr(msgs=>cols)\n");
  if($dbr(msgs=>rows)>0) {
    $var(i) = 0;
    while ($var(i)<$dbr(msgs=>rows)) {
      $uac_req(method) = "MESSAGE";
      $uac_req(ruri) = $(ct{tobody.uri});
      $uac_req(furi) = $dbr(msgs=>[$var(i),0]);
      $uac_req(turi) = $dbr(msgs=>[$var(i),1]);
      $uac_req(ouri) = "sip:"+$si+":"+$sp;
      $uac_req(hdrs) = "Content-Type: "+$dbr(msgs=>[$var(i),3])+"\r\n";
      $uac_req(body) = $dbr(msgs=>[$var(i),4]);
      uac_req_send();
      $var(i) = $var(i) + 1;
    }
  }
  sql_result_free("msgs");
  sql_query("msilo", "delete from silo where username='$fU';");
}

Greetings from Singapore,
Carsten

2014-07-18 15:27 GMT+08:00 Daniel-Constantin Mierla <miconda at gmail.com>:
> Hello,
>
> perhaps the module needs to be refactored to store the full body for
> content-type. Not it doesn't store the parameters in that header.
>
> I will look over it soon if nobody else does it. Maybe you should open an
> issue on tracker so we don't forget about it:
>
> - http://sip-router.org/tracker/
>
> Cheers,
> Daniel
>
> On 03/07/14 16:38, denis kremov wrote:
>
> Hello All,
>
> Subj, need you help,
>
> How to store this type of message to MSILO database?
>
> Content-Type:
> message/external-body;access-type=URL;URL="https://xxx.com//download/539c28884_3e071c9db68044f687bf.jpg"
>
> I modified and recompiled msilo.c to resolve this error:
> ERROR: msilo [msilo.c:626]: m_store(): body of the message is empty!
>
> but after that - m_store just store this information to database:
>
> mysql> select * from silo;
> +----+-------------------------+-------------------------+-----------+-----------+------------+------------+----------+-----------------------+------+------------+--------+--------+
> | id | src_addr | dst_addr | username | domain | inc_time | exp_time |
> snd_time | ctype | body | extra_hdrs | callid | status |
> +----+-------------------------+-------------------------+-----------+-----------+------------+------------+----------+-----------------------+------+------------+--------+--------+
> | 30 | sip:777351300 at xxx.in | sip:777581288 at xxx.in | 777581288 | xxx.in |
> 1402479947 | 1403479946 | 0 | message/external-body | | | | 0 |
> +----+-------------------------+-------------------------+-----------+-----------+------------+------------+----------+-----------------------+------+------------+--------+--------+
> 1 row in set (0.00 sec)
>
> How can I store to database "access-type=URL" and  and URL="xxxx" ?
>
> Thanks All!
>
>
> --
> denis kremov
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>
>
> --
> Daniel-Constantin Mierla - http://www.asipto.com
> http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
>
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>



-- 
Carsten Bock
CEO (Geschäftsführer)

ng-voice GmbH
Schomburgstr. 80
D-22767 Hamburg / Germany

http://www.ng-voice.com
mailto:carsten at ng-voice.com

Office +49 40 34927219
Fax +49 40 34927220

Sitz der Gesellschaft: Hamburg
Registergericht: Amtsgericht Hamburg, HRB 120189
Geschäftsführer: Carsten Bock
Ust-ID: DE279344284

Hier finden Sie unsere handelsrechtlichen Pflichtangaben:
http://www.ng-voice.com/imprint/



More information about the sr-users mailing list