- 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
|
||||
=====
|
||||
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
|
||||
RTP was not working.
|
||||
- logging routines now use a MUTEX to be thread safe.
|
||||
|
||||
@ -165,16 +165,22 @@ static void *rtpproxy_main(void *arg) {
|
||||
if (count < 0) {
|
||||
/*
|
||||
* 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
|
||||
* 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
|
||||
* 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.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
@ -191,6 +197,7 @@ static void *rtpproxy_main(void *arg) {
|
||||
* done above!
|
||||
*/
|
||||
if (errno != ECONNREFUSED) {
|
||||
/* some other error that I probably want to know about */
|
||||
int j;
|
||||
WARN("read() [fd=%i, %s:%i] returned error [%i:%s]",
|
||||
rtp_proxytable[i].rtp_rx_sock,
|
||||
|
||||
@ -201,7 +201,7 @@ int main (int argc, char *argv[])
|
||||
parser_init();
|
||||
|
||||
/* listen for incoming messages */
|
||||
sts=sipsock_listen();
|
||||
sts=sipsock_listen(&sip_socket);
|
||||
if (sts == STS_FAILURE) {
|
||||
/* failure to allocate SIP socket... */
|
||||
ERROR("unable to bind to SIP listening socket - aborting");
|
||||
@ -223,7 +223,7 @@ int main (int argc, char *argv[])
|
||||
while (!exit_program) {
|
||||
|
||||
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 */
|
||||
register_agemap();
|
||||
|
||||
@ -245,7 +245,7 @@ int main (int argc, char *argv[])
|
||||
/* got input, process */
|
||||
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';
|
||||
|
||||
/* evaluate the access lists (IP based filter)*/
|
||||
|
||||
@ -26,9 +26,10 @@
|
||||
/* function returns STS_* status values vvv */
|
||||
|
||||
/* sock.c */
|
||||
int sipsock_listen (void); /*X*/
|
||||
int sipsock_wait(void);
|
||||
int sipsock_read(void *buf, size_t bufsize, struct sockaddr_in *from);
|
||||
int sipsock_listen (int *sock); /*X*/
|
||||
int sipsock_wait(int sock);
|
||||
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*/
|
||||
char *buffer, int size, int allowdump);
|
||||
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 */
|
||||
extern struct siproxd_config configuration;
|
||||
|
||||
static int listen_socket=0;
|
||||
|
||||
/*
|
||||
* binds to SIP UDP socket for listening to incoming packets
|
||||
*
|
||||
@ -53,15 +51,17 @@ static int listen_socket=0;
|
||||
* STS_SUCCESS on success
|
||||
* STS_FAILURE on error
|
||||
*/
|
||||
int sipsock_listen (void) {
|
||||
int sipsock_listen (int *sock) {
|
||||
struct in_addr ipaddr;
|
||||
|
||||
memset(&ipaddr, 0, sizeof(ipaddr));
|
||||
listen_socket=sockbind(ipaddr, configuration.sip_listen_port, 1);
|
||||
if (listen_socket == 0) return STS_FAILURE; /* failure*/
|
||||
if (sock == NULL) return STS_FAILURE;
|
||||
|
||||
INFO("listening on port %i", configuration.sip_listen_port);
|
||||
DEBUGC(DBCLASS_NET,"bound listen socket %i",listen_socket);
|
||||
memset(&ipaddr, 0, sizeof(ipaddr));
|
||||
*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;
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ int sipsock_listen (void) {
|
||||
*
|
||||
* 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;
|
||||
fd_set fdset;
|
||||
struct timeval timeout;
|
||||
@ -80,8 +80,8 @@ int sipsock_wait(void) {
|
||||
timeout.tv_usec=0;
|
||||
|
||||
FD_ZERO(&fdset);
|
||||
FD_SET (listen_socket, &fdset);
|
||||
sts=select (listen_socket+1, &fdset, NULL, NULL, &timeout);
|
||||
FD_SET (sock, &fdset);
|
||||
sts=select (sock+1, &fdset, NULL, NULL, &timeout);
|
||||
|
||||
/* WARN on failures */
|
||||
if (sts<0) {
|
||||
@ -104,12 +104,13 @@ int sipsock_wait(void) {
|
||||
* RETURNS number of bytes read
|
||||
* 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;
|
||||
socklen_t fromlen;
|
||||
|
||||
fromlen=sizeof(struct sockaddr_in);
|
||||
count=recvfrom(listen_socket, buf, bufsize, 0,
|
||||
count=recvfrom(sock, buf, bufsize, 0,
|
||||
(struct sockaddr *)from, &fromlen);
|
||||
|
||||
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
|
||||
* 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
|
||||
* 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
|
||||
* we will at least survive and not run into a deadlock.
|
||||
*
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user