- possibility to log call establishment

- eliminated MOREDEBUG conditional
This commit is contained in:
Thomas Ries 2003-12-21 14:36:45 +00:00
parent 9526f46589
commit b910e74318
6 changed files with 74 additions and 61 deletions

View File

@ -135,6 +135,44 @@ int proxy_request (osip_message_t *request) {
}
#endif
/*
* logging of passing calls
*/
if (configuration.log_calls) {
osip_uri_t *cont_url;
cont_url=((osip_contact_t*)(request->contacts->node->element))->url;
/* INVITE */
if(MSG_IS_INVITE(request)) {
if (cont_url) {
INFO("Incomming Call from: %s:%s",
cont_url->username ? cont_url->username:"*NULL*",
cont_url->host ? cont_url->host : "*NULL*");
} else {
INFO("Incomming Call (w/o contact header) from: %s:%s",
request->from->url->username ?
request->from->url->username:"*NULL*",
request->from->url->host ?
request->from->url->host : "*NULL*");
}
/* BYE / CANCEL */
} else if (MSG_IS_BYE(request) || MSG_IS_CANCEL(request)) {
if (cont_url) {
INFO("Ending Call from: %s:%s",
cont_url->username ? cont_url->username:"*NULL*",
cont_url->host ? cont_url->host : "*NULL*");
} else {
INFO("Ending Call (w/o contact header) from: %s:%s",
request->from->url->username ?
request->from->url->username:"*NULL*",
request->from->url->host ?
request->from->url->host : "*NULL*");
}
}
} /* log_calls */
switch (type) {
/*
* from an external host to the internal masqueraded host
@ -162,39 +200,20 @@ int proxy_request (osip_message_t *request) {
/* if this is CANCEL/BYE request, stop RTP proxying */
if (MSG_IS_BYE(request) || MSG_IS_CANCEL(request)) {
#ifdef MOREDEBUG /*&&&&*/
INFO("stopping RTP proxy stream for: %s@%s",
osip_message_get_call_id(request)->number,
osip_message_get_call_id(request)->host);
#endif
/* stop the RTP proxying stream(s) */
rtp_stop_fwd(osip_message_get_call_id(request), incoming);
rtp_stop_fwd(osip_message_get_call_id(request), outgoing);
/* check for incoming request */
} else if (MSG_IS_INVITE(request)) {
osip_uri_t *contact;
/* First, rewrite the body */
sts = proxy_rewrite_invitation_body(request, incoming);
/*
* Note: Incoming request has no need to rewrite Contact
* header as we are not masquerading something there
* Note: Incoming requests have no need to rewrite Contact
* header - as we are not masquerading something there
*/
contact=((osip_contact_t*)(request->contacts->node->element))->url;
if (contact) {
INFO("Incomming Call from: %s:%s",
contact->username ? contact->username:"*NULL*",
contact->host ? contact->host : "*NULL*");
} else {
INFO("Incomming Call (w/o contact header) from: %s:%s",
request->from->url->username ?
request->from->url->username:"*NULL*",
request->from->url->host ?
request->from->url->host : "*NULL*");
}
}
break;
@ -377,7 +396,8 @@ int proxy_response (osip_message_t *response) {
return STS_FAILURE;
}
/* figure out if this is an request coming from the outside
/*
* figure out if this is an request coming from the outside
* world to one of our registered clients
*/
@ -413,6 +433,7 @@ int proxy_response (osip_message_t *response) {
}
}
/*
* ok, we got a response that we are allowed to process.
*/
@ -563,6 +584,7 @@ int proxy_rewrite_invitation_body(osip_message_t *mymsg, rtp_direction dir){
/* 183 Trying *MAY* contain SDP data */
DEBUGC(DBCLASS_PROXY, "rewrite_invitation_body: "
"no body found in message");
return STS_SUCCESS;
} else {
/* INVITE request and 200 response *MUST* contain SDP data */
ERROR("rewrite_invitation_body: no body found in message");

View File

@ -168,6 +168,7 @@ static int parse_config (FILE *configfile) {
{ "outbound_proxy_host", TYP_STRING, &configuration.outbound_proxy_host },
{ "outbound_proxy_port", TYP_INT4, &configuration.outbound_proxy_port },
{ "registration_file", TYP_STRING ,&configuration.registrationfile },
{ "log_calls", TYP_INT4, &configuration.log_calls },
{0, 0, 0}
};

View File

@ -140,18 +140,18 @@ static void *rtpproxy_main(void *arg) {
continue;
}
#ifdef MOREDEBUG /*&&&&*/
if (num_fd<0) {
int i;
WARN("select() returned error [%s]",strerror(errno));
for (i=0;i<RTPPROXY_SIZE;i++) {
DEBUGC(DBCLASS_RTP,"maxfd=%i",master_fd_max);
if (rtp_proxytable[i].sock != 0) {
DEBUGC(DBCLASS_RTP,"[%i] -> socket=%i",i, rtp_proxytable[i].sock);
}
} /* for i */
}
#endif
//#ifdef MOREDEBUG /*&&&&*/
//if (num_fd<0) {
// int i;
// WARN("select() returned error [%s]",strerror(errno));
// for (i=0;i<RTPPROXY_SIZE;i++) {
// DEBUGC(DBCLASS_RTP,"maxfd=%i",master_fd_max);
// if (rtp_proxytable[i].sock != 0) {
// DEBUGC(DBCLASS_RTP,"[%i] -> socket=%i",i, rtp_proxytable[i].sock);
// }
// } /* for i */
//}
//#endif
time(&t);
/*
@ -168,18 +168,16 @@ if (num_fd<0) {
/* read from sock rtp_proxytable[i].sock*/
count=read(rtp_proxytable[i].sock, rtp_buff, RTP_BUFFER_SIZE);
#ifdef MOREDEBUG /*&&&&*/
if (count<0) {WARN("read() returned error [%s]",strerror(errno));}
#endif
if (count<0) {
WARN("read() returned error [%s]",strerror(errno));
}
/* write to dest via socket rtp_inbound*/
/* write to dest via socket rtp__socket */
sts = sipsock_send_udp(&rtp_socket,
rtp_proxytable[i].inbound_client_ipaddr,
rtp_proxytable[i].inbound_client_port,
rtp_buff, count, 0); /* don't dump it */
#ifdef MOREDEBUG /*&&&&*/
if (sts != STS_SUCCESS) {WARN("sipsock_send_udp() returned error");}
#endif
/* update timestamp of last usage */
rtp_proxytable[i].timestamp=t;

View File

@ -187,10 +187,8 @@ int main (int argc, char *argv[])
if (fork()!=0) exit(0);
log_set_tosyslog(1);
INFO("daemonized, pid=%i", getpid());
}
#ifdef MOREDEBUG /*&&&&*/
INFO("daemonizing done (pid=%i)", getpid());
#endif
/* initialize the RTP proxy */
sts=rtpproxy_init();
@ -250,13 +248,6 @@ INFO("daemonizing done (pid=%i)", getpid());
i=sipsock_read(&buff, sizeof(buff)-1, &from);
buff[i]='\0';
#ifdef MOREDEBUG /*&&&&*/
{char tmp[32];
strncpy(tmp, buff, 30);
tmp[30]='\0';
INFO("got packet [%i bytes] from %s [%s]", i,
utils_inet_ntoa(from.sin_addr), tmp);}
#endif
/* evaluate the access lists (IP based filter)*/
access=accesslist_check(from);
if (access == 0) continue; /* there are no resources to free */

View File

@ -152,6 +152,7 @@ struct siproxd_config {
char *outbound_proxy_host;
int outbound_proxy_port;
char *registrationfile;
int log_calls;
};
@ -205,5 +206,3 @@ struct siproxd_config {
Port (!!!) are kept from the SIP address given by the user.
This issue is fixed in linphone-0.9.1pre1
*/
//#define MOREDEBUG

View File

@ -81,9 +81,10 @@ int sipsock_wait(void) {
FD_ZERO(&fdset);
FD_SET (listen_socket, &fdset);
sts=select (listen_socket+1, &fdset, NULL, NULL, &timeout);
#ifdef MOREDEBUG /*&&&&*/
if (sts<0) {WARN("select() returned error [%s]",strerror(errno));}
#endif
if (sts<0) {
WARN("select() returned error [%s]",strerror(errno));
}
return sts;
}
@ -101,9 +102,10 @@ int sipsock_read(void *buf, size_t bufsize, struct sockaddr_in *from) {
fromlen=sizeof(struct sockaddr_in);
count=recvfrom(listen_socket, buf, bufsize, 0,
(struct sockaddr *)from, &fromlen);
#ifdef MOREDEBUG /*&&&&*/
if (count<0) {WARN("recvfrom() returned error [%s]",strerror(errno));}
#endif
if (count<0) {
WARN("recvfrom() returned error [%s]",strerror(errno));
}
DEBUGC(DBCLASS_NET,"received UDP packet from %s, count=%i",
utils_inet_ntoa(from->sin_addr), count);
@ -159,8 +161,8 @@ int sipsock_send_udp(int *sock, struct in_addr addr, int port,
port, strerror(errno));
return STS_FAILURE;
}
DEBUGC(DBCLASS_BABBLE,"sendto() [%s:%i] call failed: %s",
utils_inet_ntoa(addr), port, strerror(errno));
DEBUGC(DBCLASS_BABBLE,"sendto() [%s:%i] call failed: %s",
utils_inet_ntoa(addr), port, strerror(errno));
}
return STS_SUCCESS;