|
@@ -121,7 +121,7 @@ inline int add_contact(struct sip_msg* msg , str* user)
|
|
|
|
|
|
buf = pkg_malloc( len );
|
|
|
if(!buf) {
|
|
|
- LOG(L_ERR,"ERROR:sms_add_contact: out of memory! \n");
|
|
|
+ LM_ERR("out of memory! \n");
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
@@ -136,7 +136,7 @@ inline int add_contact(struct sip_msg* msg , str* user)
|
|
|
|
|
|
lump = build_lump_rpl( buf , len , LUMP_RPL_HDR);
|
|
|
if(!lump) {
|
|
|
- LOG(L_ERR,"ERROR:sms_add_contact: unable to build lump_rpl! \n");
|
|
|
+ LM_ERR("unable to build lump_rpl! \n");
|
|
|
pkg_free( buf );
|
|
|
return -1;
|
|
|
}
|
|
@@ -165,28 +165,28 @@ int push_on_network(struct sip_msg *msg, int net)
|
|
|
* calls of parse_headers function for FROM, CONTENT_LENGTH, TO hdrs */
|
|
|
body.s = get_body( msg );
|
|
|
if (body.s==0) {
|
|
|
- LOG(L_ERR,"ERROR:sms_push_on_net: cannot extract body from msg!\n");
|
|
|
+ LM_ERR("failed to extract body from msg!\n");
|
|
|
goto error;
|
|
|
}
|
|
|
|
|
|
/* content-length (if present) must be already parsed */
|
|
|
if (!msg->content_length) {
|
|
|
- LOG(L_ERR,"ERROR:sms_push_on_net: no Content-Length header found!\n");
|
|
|
+ LM_ERR("no Content-Length header found!\n");
|
|
|
goto error;
|
|
|
}
|
|
|
body.len = get_content_length( msg );
|
|
|
|
|
|
/* parse the content-type header */
|
|
|
if ( (mime=parse_content_type_hdr(msg))<1 ) {
|
|
|
- LOG(L_ERR,"ERROR:sms_push_on_net:cannot parse Content-Type header\n");
|
|
|
+ LM_ERR("failed to parse Content-Type header\n");
|
|
|
goto error;
|
|
|
}
|
|
|
|
|
|
/* check the content-type value */
|
|
|
if ( mime!=(TYPE_TEXT<<16)+SUBTYPE_PLAIN
|
|
|
&& mime!=(TYPE_MESSAGE<<16)+SUBTYPE_CPIM ) {
|
|
|
- LOG(L_ERR,"ERROR:sms_push_on_net: invalid content-type for a "
|
|
|
- "message request! type found=%d\n",mime);
|
|
|
+ LM_ERR("invalid content-type for a message request! type found=%d\n",
|
|
|
+ mime);
|
|
|
goto error;
|
|
|
}
|
|
|
|
|
@@ -195,22 +195,21 @@ int push_on_network(struct sip_msg *msg, int net)
|
|
|
if it's missing there (like in requests generated by MSN MESSENGER),
|
|
|
we go for "to" header
|
|
|
*/
|
|
|
- DBG("DEBUG:sms_push_on_net: string to get user from new_uri\n");
|
|
|
+ LM_DBG("string to get user from new_uri\n");
|
|
|
if ( !msg->new_uri.s||parse_uri( msg->new_uri.s,msg->new_uri.len,&uri)
|
|
|
|| !uri.user.len )
|
|
|
{
|
|
|
- DBG("DEBUG:sms_push_on_net: string to get user from R_uri\n");
|
|
|
+ LM_DBG("string to get user from R_uri\n");
|
|
|
if ( parse_uri( msg->first_line.u.request.uri.s,
|
|
|
msg->first_line.u.request.uri.len ,&uri)||!uri.user.len )
|
|
|
{
|
|
|
- DBG("DEBUG:sms_push_on_net: string to get user from To\n");
|
|
|
+ LM_DBG("string to get user from To\n");
|
|
|
if ( (!msg->to&&((parse_headers(msg,HDR_TO_F,0)==-1) ||
|
|
|
!msg->to)) ||
|
|
|
parse_uri( get_to(msg)->uri.s, get_to(msg)->uri.len, &uri)==-1
|
|
|
|| !uri.user.len)
|
|
|
{
|
|
|
- LOG(L_ERR,"ERROR:sms_push_on_net: unable to extract user"
|
|
|
- " name from RURI and To header!\n");
|
|
|
+ LM_ERR("unable to extract user name from RURI and To header!\n");
|
|
|
goto error;
|
|
|
}
|
|
|
}
|
|
@@ -218,14 +217,14 @@ int push_on_network(struct sip_msg *msg, int net)
|
|
|
/* check the uri.user format = '+(inter code)(number)' */
|
|
|
if (uri.user.len<2 || uri.user.s[0]!='+' || uri.user.s[1]<'1'
|
|
|
|| uri.user.s[1]>'9') {
|
|
|
- LOG(L_ERR,"ERROR:sms_push_on_net: user tel number [%.*s] does not"
|
|
|
- "respect international format\n",uri.user.len,uri.user.s);
|
|
|
+ LM_ERR("user tel number [%.*s] does not respect international format\n"
|
|
|
+ ,uri.user.len,uri.user.s);
|
|
|
goto error;
|
|
|
}
|
|
|
|
|
|
/* parsing from header */
|
|
|
if ( parse_from_header( msg )==-1 ) {
|
|
|
- LOG(L_ERR,"ERROR:sms_push_on_net: cannot get FROM header\n");
|
|
|
+ LM_ERR("failed to get FROM header\n");
|
|
|
goto error;
|
|
|
}
|
|
|
from = (struct to_body*)msg->from->parsed;
|
|
@@ -233,7 +232,7 @@ int push_on_network(struct sip_msg *msg, int net)
|
|
|
#if 0
|
|
|
/* adds contact header into reply */
|
|
|
if (add_contact(msg,&(uri.user))==-1) {
|
|
|
- LOG(L_ERR,"ERROR:sms_push_on_net:can't build contact for reply\n");
|
|
|
+ LM_ERR("can't build contact for reply\n");
|
|
|
goto error;
|
|
|
}
|
|
|
#endif
|
|
@@ -248,7 +247,7 @@ int push_on_network(struct sip_msg *msg, int net)
|
|
|
/* allocs a new sms_msg structure in shared memory */
|
|
|
sms_messg = (struct sms_msg*)shm_malloc(len);
|
|
|
if (!sms_messg) {
|
|
|
- LOG(L_ERR,"ERROR:sms_push_on_net: cannot get shm memory!\n");
|
|
|
+ LM_ERR("failed to get shm memory!\n");
|
|
|
goto error;
|
|
|
}
|
|
|
p = (char*)sms_messg + sizeof(struct sms_msg);
|
|
@@ -280,8 +279,8 @@ int push_on_network(struct sip_msg *msg, int net)
|
|
|
if (write(net_pipes_in[net], &sms_messg, sizeof(sms_messg))!=
|
|
|
sizeof(sms_messg) )
|
|
|
{
|
|
|
- LOG(L_ERR,"ERROR:sms_push_on_net: error when writing for net %d "
|
|
|
- "to pipe [%d] : %s\n",net,net_pipes_in[net],strerror(errno) );
|
|
|
+ LM_ERR("error when writing for net %d to pipe [%d] : %s\n",
|
|
|
+ net,net_pipes_in[net],strerror(errno) );
|
|
|
shm_free(sms_messg);
|
|
|
(*queued_msgs)--;
|
|
|
goto error;
|
|
@@ -303,7 +302,7 @@ int send_sip_msg_request(str *to, str *from_user, str *body)
|
|
|
str hdrs;
|
|
|
int foo;
|
|
|
char *p;
|
|
|
- uac_req_t uac_r;
|
|
|
+ uac_req_t uac_r;
|
|
|
|
|
|
from.s = hdrs.s = 0;
|
|
|
from.len = hdrs.len = 0;
|
|
@@ -363,7 +362,7 @@ int send_sip_msg_request(str *to, str *from_user, str *body)
|
|
|
if (hdrs.s) pkg_free(hdrs.s);
|
|
|
return foo;
|
|
|
error:
|
|
|
- LOG(L_ERR,"ERROR:sms_build_and_send_sip: no free pkg memory!\n");
|
|
|
+ LM_ERR("no free pkg memory!\n");
|
|
|
if (from.s) pkg_free(from.s);
|
|
|
if (hdrs.s) pkg_free(hdrs.s);
|
|
|
return -1;
|
|
@@ -393,7 +392,7 @@ inline int send_error(struct sms_msg *sms_messg, char *msg1_s, int msg1_len,
|
|
|
pkg_free( body.s );
|
|
|
return foo;
|
|
|
error:
|
|
|
- LOG(L_ERR,"ERROR:sms_send_error: no free pkg memory!\n");
|
|
|
+ LM_ERR("no free pkg memory!\n");
|
|
|
return -1;
|
|
|
|
|
|
}
|
|
@@ -500,7 +499,7 @@ int send_as_sms(struct sms_msg *sms_messg, struct modem *mdm)
|
|
|
send_error(sms_messg, ERR_TRUNCATE_TEXT, ERR_TRUNCATE_TEXT_LEN,
|
|
|
p, text.len-(p-text.s)-SMS_FOOTER_LEN);
|
|
|
}
|
|
|
- DBG("---%d--<%d><%d>--\n|%.*s|\n", i, len_array[i], buf_len,
|
|
|
+ LM_DBG("---%d--<%d><%d>--\n|%.*s|\n", i, len_array[i], buf_len,
|
|
|
(int)buf_len, buf);
|
|
|
sms_messg->text.s = buf;
|
|
|
sms_messg->text.len = buf_len;
|
|
@@ -581,16 +580,15 @@ int send_sms_as_sip( struct incame_sms *sms )
|
|
|
p++;
|
|
|
p++;
|
|
|
if (p+9>=sms->ascii+sms->userdatalength) {
|
|
|
- LOG(L_ERR,"ERROR:send_sms_as_sip: unable to find sip_address"
|
|
|
- " start in sms body [%s]!\n",sms->ascii);
|
|
|
+ LM_ERR("unable to find sip_address start in sms body [%s]!\n",
|
|
|
+ sms->ascii);
|
|
|
goto error;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
/* lets get the address */
|
|
|
if (p[0]!='s' || p[1]!='i' || p[2]!='p' || p[3]!=':') {
|
|
|
- LOG(L_ERR,"ERROR:send_sms_as_sip: wrong sip address format in"
|
|
|
- " sms body [%s]!\n",sms->ascii);
|
|
|
+ LM_ERR("wrong sip address format in sms body [%s]!\n",sms->ascii);
|
|
|
goto error;
|
|
|
}
|
|
|
sip_addr.s = p;
|
|
@@ -598,11 +596,11 @@ int send_sms_as_sip( struct incame_sms *sms )
|
|
|
while(p<sms->ascii+sms->userdatalength && is_in_sip_addr(*p) )
|
|
|
p++;
|
|
|
if (p>=sms->ascii+sms->userdatalength) {
|
|
|
- LOG(L_ERR,"ERROR:send_sms_as_sip: cannot find sip address end in"
|
|
|
- "sms body [%s]!\n",sms->ascii);
|
|
|
+ LM_ERR("failed to find sip address end in sms body [%s]!\n",
|
|
|
+ sms->ascii);
|
|
|
}
|
|
|
sip_addr.len = p-sip_addr.s;
|
|
|
- DBG("DEBUG:send_sms_as_sip: sip address found [%.*s]\n",
|
|
|
+ LM_DBG("sip address found [%.*s]\n",
|
|
|
sip_addr.len,sip_addr.s);
|
|
|
/* try to match SMS_HDR_AF_ADDR */
|
|
|
k=0;
|
|
@@ -621,24 +619,24 @@ int send_sms_as_sip( struct incame_sms *sms )
|
|
|
while(p<sms->ascii+sms->userdatalength && is_in_sip_addr(*p) )
|
|
|
p++;
|
|
|
if (p==sms->ascii+sms->userdatalength) {
|
|
|
- LOG(L_ERR,"ERROR:send_sms_as_sip: cannot find sip"
|
|
|
- " address end in sms body [%s]!\n",sms->ascii);
|
|
|
+ LM_ERR("failed to find sip address end in sms body [%s]!\n",
|
|
|
+ sms->ascii);
|
|
|
goto error;
|
|
|
}
|
|
|
sip_addr.len = p-sip_addr.s;
|
|
|
} else {
|
|
|
/* parse to the next word */
|
|
|
- /*DBG("*** Skipping word len=%d\n",sms->userdatalength);*/
|
|
|
+ /*LM_DBG("*** Skipping word len=%d\n",sms->userdatalength);*/
|
|
|
while(p<sms->ascii+sms->userdatalength&&no_sip_addr_begin(*p)){
|
|
|
p++;
|
|
|
}
|
|
|
p++;
|
|
|
if (p+9>=sms->ascii+sms->userdatalength) {
|
|
|
- LOG(L_ERR,"ERROR:send_sms_as_sip: unable to find sip "
|
|
|
- "address start in sms body [%s]!\n",sms->ascii);
|
|
|
+ LM_ERR("unable to find sip address start in sms body [%s]!\n",
|
|
|
+ sms->ascii);
|
|
|
goto error;
|
|
|
}
|
|
|
- /*DBG("*** Done\n");*/
|
|
|
+ /*LM_DBG("*** Done\n");*/
|
|
|
}
|
|
|
}while (!sip_addr.len);
|
|
|
}
|
|
@@ -653,12 +651,10 @@ int send_sms_as_sip( struct incame_sms *sms )
|
|
|
sip_body.len--;
|
|
|
}
|
|
|
if (sip_body.len==0) {
|
|
|
- LOG(L_WARN,"WARNING:send_sms_as_sip: empty body for sms [%s]",
|
|
|
- sms->ascii);
|
|
|
+ LM_WARN("empty body for sms [%s]", sms->ascii);
|
|
|
goto error;
|
|
|
}
|
|
|
- DBG("DEBUG:send_sms_as_sip: extracted body is: [%.*s]\n",
|
|
|
- sip_body.len, sip_body.s);
|
|
|
+ LM_DBG("extracted body is: [%.*s]\n",sip_body.len, sip_body.s);
|
|
|
|
|
|
/* finally, let's send it as sip message */
|
|
|
sip_from.s = sms->sender;
|
|
@@ -711,8 +707,7 @@ int send_sms_as_sip_scan_no(struct incame_sms *sms, char *to)
|
|
|
}
|
|
|
|
|
|
if (sip_body.len == 0) {
|
|
|
- LOG(L_WARN,"WARNING:send_sms_as_sip_scan_no: SMS empty body "
|
|
|
- "for sms [%s]\n",sms->ascii);
|
|
|
+ LM_WARN("SMS empty body for sms [%s]\n",sms->ascii);
|
|
|
goto error;
|
|
|
}
|
|
|
|
|
@@ -729,7 +724,7 @@ int send_sms_as_sip_scan_no(struct incame_sms *sms, char *to)
|
|
|
sip_body.len += CRLF_LEN + DATE_LEN + TIME_LEN + 3;
|
|
|
}
|
|
|
|
|
|
- DBG("DEBUG:send_sms_as_sip_scan_no: SMS from: [%.*s], to: [%.*s], body: [%.*s]\n",
|
|
|
+ LM_DBG("SMS from: [%.*s], to: [%.*s], body: [%.*s]\n",
|
|
|
sip_from.len, sip_from.s, sip_to.len, sip_to.s, sip_body.len, sip_body.s);
|
|
|
|
|
|
/* finally, let's send it as sip message */
|
|
@@ -761,7 +756,7 @@ int _send_sms_as_sip(struct incame_sms *sms, struct modem *mdm)
|
|
|
}
|
|
|
|
|
|
/* CASE IMPOSIBLE!!!!, scan assume default value SMS_BODY_SCAN */
|
|
|
- LOG(L_ERR,"ERROR:_send_sms_as_sip: SMS bad config param scan: %d for modem: %s\n",
|
|
|
+ LM_ERR("SMS bad config param scan: %d for modem: %s\n",
|
|
|
mdm->scan, mdm->name);
|
|
|
|
|
|
return -1;
|
|
@@ -776,7 +771,7 @@ int check_sms_report( struct incame_sms *sms )
|
|
|
int old;
|
|
|
int res;
|
|
|
|
|
|
- DBG("DEBUG:sms:check_sms_report: Report for sms number %d.\n",sms->sms_id);
|
|
|
+ LM_DBG("Report for sms number %d.\n",sms->sms_id);
|
|
|
res=relay_report_to_queue( sms->sms_id, sms->sender, sms->ascii[0], &old);
|
|
|
if (res==3) { /* error */
|
|
|
/* the sms was confirmed with an error code -> we have to send a
|
|
@@ -836,10 +831,10 @@ void modem_process(struct modem *mdm)
|
|
|
cpms_unsuported = 0;
|
|
|
|
|
|
/* let's open/init the modem */
|
|
|
- DBG("DEBUG:modem_process: opening modem\n");
|
|
|
+ LM_DBG("opening modem\n");
|
|
|
if (openmodem(mdm)==-1) {
|
|
|
- LOG(L_ERR,"ERROR:modem_process: cannot open modem %s!"
|
|
|
- " %s \n",mdm->name,strerror(errno));
|
|
|
+ LM_ERR("failed to open modem %s! %s \n",
|
|
|
+ mdm->name,strerror(errno));
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -847,12 +842,11 @@ void modem_process(struct modem *mdm)
|
|
|
initmodem(mdm,check_cds_report);
|
|
|
|
|
|
if ( (max_mem=check_memory(mdm,MAX_MEM))==-1 ) {
|
|
|
- LOG(L_WARN,"WARNING:modem_process: CPMS command unsuported!"
|
|
|
- " using default values (10,10)\n");
|
|
|
+ LM_WARN("CPMS command unsuported! using default values (10,10)\n");
|
|
|
used_mem = max_mem = 10;
|
|
|
cpms_unsuported = 1;
|
|
|
}
|
|
|
- DBG("DEBUG:modem_process: modem maximum memory is %d\n",max_mem);
|
|
|
+ LM_DBG("modem maximum memory is %d\n",max_mem);
|
|
|
|
|
|
set_gettime_function();
|
|
|
|
|
@@ -875,13 +869,12 @@ void modem_process(struct modem *mdm)
|
|
|
sizeof(sms_messg));
|
|
|
if (len!=sizeof(sms_messg)) {
|
|
|
if (len>=0)
|
|
|
- LOG(L_ERR,"ERROR:modem_process: truncated message"
|
|
|
- " read from pipe! -> discarded\n");
|
|
|
+ LM_ERR("truncated message read from pipe!"
|
|
|
+ " -> discarded\n");
|
|
|
else if (errno==EAGAIN)
|
|
|
empty_pipe = 1;
|
|
|
else
|
|
|
- LOG(L_ERR,"ERROR:modem_process: pipe reading failed: "
|
|
|
- " : %s\n",strerror(errno));
|
|
|
+ LM_ERR("pipe reading failed: %s\n",strerror(errno));
|
|
|
sleep(1);
|
|
|
counter++;
|
|
|
continue;
|
|
@@ -889,7 +882,7 @@ void modem_process(struct modem *mdm)
|
|
|
(*queued_msgs)--;
|
|
|
|
|
|
/* compute and send the sms */
|
|
|
- DBG("DEBUG:modem_process: %s processing sms for net %s:"
|
|
|
+ LM_DBG("%s processing sms for net %s:"
|
|
|
" \n\tTo:[%.*s]\n\tBody=<%d>[%.*s]\n",
|
|
|
mdm->device, net->name,
|
|
|
sms_messg->to.len,sms_messg->to.s,
|
|
@@ -906,20 +899,19 @@ void modem_process(struct modem *mdm)
|
|
|
/* let's see if we have incoming sms */
|
|
|
if ( !cpms_unsuported )
|
|
|
if ((used_mem = check_memory(mdm,USED_MEM))==-1) {
|
|
|
- LOG(L_ERR,"ERROR:modem_process: CPMS command failed!"
|
|
|
- " cannot get used mem -> using 10\n");
|
|
|
+ LM_ERR("CPMS command failed! cannot get used mem -> using 10\n");
|
|
|
used_mem = 10;
|
|
|
}
|
|
|
|
|
|
/* if any, let's get them */
|
|
|
if (used_mem)
|
|
|
- DBG("DEBUG:modem_process: %d new SMS on modem\n",used_mem);
|
|
|
+ LM_DBG("%d new SMS on modem\n",used_mem);
|
|
|
for(i=1,k=1;k<=used_mem && i<=max_mem;i++) {
|
|
|
if (getsms(&sms,mdm,i)!=-1) {
|
|
|
k++;
|
|
|
- DBG("SMS Get from location %d\n",i);
|
|
|
+ LM_DBG("SMS Get from location %d\n",i);
|
|
|
/*for test ;-) -> to be remove*/
|
|
|
- DBG("SMS RECEIVED:\n\rFrom: %s %s\n\r%.*s %.*s"
|
|
|
+ LM_DBG("SMS RECEIVED:\n\rFrom: %s %s\n\r%.*s %.*s"
|
|
|
"\n\r\"%.*s\"\n\r",sms.sender,sms.name,
|
|
|
DATE_LEN,sms.date,TIME_LEN,sms.time,
|
|
|
sms.userdatalength,sms.ascii);
|