- Use same SIP port number for RX & TX (-> support
symmetric SIP signalling)
This commit is contained in:
parent
d0a2ac463a
commit
3c9e22b0cb
@ -1,5 +1,7 @@
|
|||||||
0.5.3
|
0.5.3
|
||||||
=====
|
=====
|
||||||
|
11-Feb-2004: - Use same SIP port number for RX & TX (-> support
|
||||||
|
symmetric SIP signalling)
|
||||||
7-Feb-2004: - Fix for local-UA to local-UA RTP proxying, symmetric
|
7-Feb-2004: - Fix for local-UA to local-UA RTP proxying, symmetric
|
||||||
RTP was not working.
|
RTP was not working.
|
||||||
- logging routines now use a MUTEX to be thread safe.
|
- logging routines now use a MUTEX to be thread safe.
|
||||||
|
|||||||
@ -165,16 +165,22 @@ static void *rtpproxy_main(void *arg) {
|
|||||||
if (count < 0) {
|
if (count < 0) {
|
||||||
/*
|
/*
|
||||||
* It has been seen on linux 2.2.x systems that for some
|
* It has been seen on linux 2.2.x systems that for some
|
||||||
* reason (kernel bug?) inside the RTP relay, select()
|
* reason (ICMP issue? -> below) inside the RTP relay, select()
|
||||||
* claims that a certain file descriptor has data available to
|
* claims that a certain file descriptor has data available to
|
||||||
* read, a subsequent call to read() or recv() the does block!!
|
* read, a subsequent call to read() or recv() then does block!!
|
||||||
* So lets make the FD's we are going to use non-blocking, so
|
* So lets make the FD's we are going to use non-blocking, so
|
||||||
* we will at least survive and not run into a deadlock.
|
* we will at least survive and not run into a deadlock.
|
||||||
*
|
*
|
||||||
* We catch this here with this workaround (pronounce "hack")
|
* We catch this here with this workaround (pronounce "HACK")
|
||||||
* and hope that next time we pass by it will be ok again.
|
* and hope that next time we pass by it will be ok again.
|
||||||
*/
|
*/
|
||||||
if (errno == EAGAIN) {
|
if (errno == EAGAIN) {
|
||||||
|
/*&&&& I may want to remove this WARNing */
|
||||||
|
WARN("read() [fd=%i, %s:%i] would block, but select() "
|
||||||
|
"claimed to be readable!",
|
||||||
|
rtp_proxytable[i].rtp_rx_sock,
|
||||||
|
utils_inet_ntoa(rtp_proxytable[i].local_ipaddr),
|
||||||
|
rtp_proxytable[i].local_port);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,6 +197,7 @@ static void *rtpproxy_main(void *arg) {
|
|||||||
* done above!
|
* done above!
|
||||||
*/
|
*/
|
||||||
if (errno != ECONNREFUSED) {
|
if (errno != ECONNREFUSED) {
|
||||||
|
/* some other error that I probably want to know about */
|
||||||
int j;
|
int j;
|
||||||
WARN("read() [fd=%i, %s:%i] returned error [%i:%s]",
|
WARN("read() [fd=%i, %s:%i] returned error [%i:%s]",
|
||||||
rtp_proxytable[i].rtp_rx_sock,
|
rtp_proxytable[i].rtp_rx_sock,
|
||||||
|
|||||||
@ -201,7 +201,7 @@ int main (int argc, char *argv[])
|
|||||||
parser_init();
|
parser_init();
|
||||||
|
|
||||||
/* listen for incoming messages */
|
/* listen for incoming messages */
|
||||||
sts=sipsock_listen();
|
sts=sipsock_listen(&sip_socket);
|
||||||
if (sts == STS_FAILURE) {
|
if (sts == STS_FAILURE) {
|
||||||
/* failure to allocate SIP socket... */
|
/* failure to allocate SIP socket... */
|
||||||
ERROR("unable to bind to SIP listening socket - aborting");
|
ERROR("unable to bind to SIP listening socket - aborting");
|
||||||
@ -223,7 +223,7 @@ int main (int argc, char *argv[])
|
|||||||
while (!exit_program) {
|
while (!exit_program) {
|
||||||
|
|
||||||
DEBUGC(DBCLASS_BABBLE,"going into sip_wait\n");
|
DEBUGC(DBCLASS_BABBLE,"going into sip_wait\n");
|
||||||
while (sipsock_wait()<=0) {
|
while (sipsock_wait(sip_socket)<=0) {
|
||||||
/* got no input, here by timeout. do aging */
|
/* got no input, here by timeout. do aging */
|
||||||
register_agemap();
|
register_agemap();
|
||||||
|
|
||||||
@ -245,7 +245,7 @@ int main (int argc, char *argv[])
|
|||||||
/* got input, process */
|
/* got input, process */
|
||||||
DEBUGC(DBCLASS_BABBLE,"back from sip_wait");
|
DEBUGC(DBCLASS_BABBLE,"back from sip_wait");
|
||||||
|
|
||||||
i=sipsock_read(&buff, sizeof(buff)-1, &from);
|
i=sipsock_read(sip_socket, &buff, sizeof(buff)-1, &from);
|
||||||
buff[i]='\0';
|
buff[i]='\0';
|
||||||
|
|
||||||
/* evaluate the access lists (IP based filter)*/
|
/* evaluate the access lists (IP based filter)*/
|
||||||
|
|||||||
@ -26,9 +26,10 @@
|
|||||||
/* function returns STS_* status values vvv */
|
/* function returns STS_* status values vvv */
|
||||||
|
|
||||||
/* sock.c */
|
/* sock.c */
|
||||||
int sipsock_listen (void); /*X*/
|
int sipsock_listen (int *sock); /*X*/
|
||||||
int sipsock_wait(void);
|
int sipsock_wait(int sock);
|
||||||
int sipsock_read(void *buf, size_t bufsize, struct sockaddr_in *from);
|
int sipsock_read(int sock, void *buf, size_t bufsize,
|
||||||
|
struct sockaddr_in *from);
|
||||||
int sipsock_send_udp(int *sock, struct in_addr addr, int port, /*X*/
|
int sipsock_send_udp(int *sock, struct in_addr addr, int port, /*X*/
|
||||||
char *buffer, int size, int allowdump);
|
char *buffer, int size, int allowdump);
|
||||||
int sockbind(struct in_addr ipaddr, int localport, int errflg);
|
int sockbind(struct in_addr ipaddr, int localport, int errflg);
|
||||||
|
|||||||
31
src/sock.c
31
src/sock.c
@ -44,8 +44,6 @@ static char const ident[]="$Id: " __FILE__ ": " PACKAGE "-" VERSION "-"\
|
|||||||
/* configuration storage */
|
/* configuration storage */
|
||||||
extern struct siproxd_config configuration;
|
extern struct siproxd_config configuration;
|
||||||
|
|
||||||
static int listen_socket=0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* binds to SIP UDP socket for listening to incoming packets
|
* binds to SIP UDP socket for listening to incoming packets
|
||||||
*
|
*
|
||||||
@ -53,15 +51,17 @@ static int listen_socket=0;
|
|||||||
* STS_SUCCESS on success
|
* STS_SUCCESS on success
|
||||||
* STS_FAILURE on error
|
* STS_FAILURE on error
|
||||||
*/
|
*/
|
||||||
int sipsock_listen (void) {
|
int sipsock_listen (int *sock) {
|
||||||
struct in_addr ipaddr;
|
struct in_addr ipaddr;
|
||||||
|
|
||||||
memset(&ipaddr, 0, sizeof(ipaddr));
|
if (sock == NULL) return STS_FAILURE;
|
||||||
listen_socket=sockbind(ipaddr, configuration.sip_listen_port, 1);
|
|
||||||
if (listen_socket == 0) return STS_FAILURE; /* failure*/
|
|
||||||
|
|
||||||
INFO("listening on port %i", configuration.sip_listen_port);
|
memset(&ipaddr, 0, sizeof(ipaddr));
|
||||||
DEBUGC(DBCLASS_NET,"bound listen socket %i",listen_socket);
|
*sock=sockbind(ipaddr, configuration.sip_listen_port, 1);
|
||||||
|
if (*sock == 0) return STS_FAILURE; /* failure*/
|
||||||
|
|
||||||
|
INFO("bound to port %i", configuration.sip_listen_port);
|
||||||
|
DEBUGC(DBCLASS_NET,"bound socket %i",*sock);
|
||||||
return STS_SUCCESS;
|
return STS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ int sipsock_listen (void) {
|
|||||||
*
|
*
|
||||||
* RETURNS >0 if data received, =0 if nothing received /T/O), -1 on error
|
* RETURNS >0 if data received, =0 if nothing received /T/O), -1 on error
|
||||||
*/
|
*/
|
||||||
int sipsock_wait(void) {
|
int sipsock_wait(int sock) {
|
||||||
int sts;
|
int sts;
|
||||||
fd_set fdset;
|
fd_set fdset;
|
||||||
struct timeval timeout;
|
struct timeval timeout;
|
||||||
@ -80,8 +80,8 @@ int sipsock_wait(void) {
|
|||||||
timeout.tv_usec=0;
|
timeout.tv_usec=0;
|
||||||
|
|
||||||
FD_ZERO(&fdset);
|
FD_ZERO(&fdset);
|
||||||
FD_SET (listen_socket, &fdset);
|
FD_SET (sock, &fdset);
|
||||||
sts=select (listen_socket+1, &fdset, NULL, NULL, &timeout);
|
sts=select (sock+1, &fdset, NULL, NULL, &timeout);
|
||||||
|
|
||||||
/* WARN on failures */
|
/* WARN on failures */
|
||||||
if (sts<0) {
|
if (sts<0) {
|
||||||
@ -104,12 +104,13 @@ int sipsock_wait(void) {
|
|||||||
* RETURNS number of bytes read
|
* RETURNS number of bytes read
|
||||||
* from is modified to return the sockaddr_in of the sender
|
* from is modified to return the sockaddr_in of the sender
|
||||||
*/
|
*/
|
||||||
int sipsock_read(void *buf, size_t bufsize, struct sockaddr_in *from) {
|
int sipsock_read(int sock, void *buf, size_t bufsize,
|
||||||
|
struct sockaddr_in *from) {
|
||||||
int count;
|
int count;
|
||||||
socklen_t fromlen;
|
socklen_t fromlen;
|
||||||
|
|
||||||
fromlen=sizeof(struct sockaddr_in);
|
fromlen=sizeof(struct sockaddr_in);
|
||||||
count=recvfrom(listen_socket, buf, bufsize, 0,
|
count=recvfrom(sock, buf, bufsize, 0,
|
||||||
(struct sockaddr *)from, &fromlen);
|
(struct sockaddr *)from, &fromlen);
|
||||||
|
|
||||||
if (count<0) {
|
if (count<0) {
|
||||||
@ -214,9 +215,9 @@ int sockbind(struct in_addr ipaddr, int localport, int errflg) {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* It has been seen on linux 2.2.x systems that for some
|
* It has been seen on linux 2.2.x systems that for some
|
||||||
* reason (kernel bug?) inside the RTP relay, select()
|
* reason (bug?) inside the RTP relay, select()
|
||||||
* claims that a certain file descriptor has data available to
|
* claims that a certain file descriptor has data available to
|
||||||
* read, a subsequent call to read() or recv() the does block!!
|
* read, a subsequent call to read() or recv() then does block!!
|
||||||
* So lets make the FD's we are going to use non-blocking, so
|
* So lets make the FD's we are going to use non-blocking, so
|
||||||
* we will at least survive and not run into a deadlock.
|
* we will at least survive and not run into a deadlock.
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user