Index: plugin/udp/udp.c =================================================================== RCS file: /cvsroot/partysip/partysip/plugin/udp/udp.c,v retrieving revision 1.21 diff -u -3 -r1.21 udp.c --- plugin/udp/udp.c 10 Sep 2002 14:38:25 -0000 1.21 +++ plugin/udp/udp.c 11 Sep 2002 06:25:47 -0000 @@ -80,9 +80,20 @@ (struct sockaddr *) &raddr, sizeof (raddr)); if (i < 0) { +#ifdef WIN32 OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_WARNING, NULL, + (__FILE__, __LINE__, OSIP_ERROR, NULL, "udp plugin: cannot bind on port %i!\n", ctx->in_port)); +#else + /* XXX use some configure magic to detect if we have the right strerror_r() + * function (the one that returns int, not char *) and then use strerror_r() + * instead. + */ + OSIP_TRACE (osip_trace + (__FILE__, __LINE__, OSIP_ERROR, NULL, + "udp plugin: cannot bind on port %i (%s)!\n", + ctx->in_port, strerror (errno))); +#endif ctx->out_port++; } } @@ -97,9 +108,20 @@ if (ppl_socket_bind (ctx->in_socket, (struct sockaddr *) &raddr, sizeof (raddr)) < 0) { +#ifdef WIN32 OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, - "udp plugin: cannot bind failed on port %i!\n", ctx->in_port)); + "udp plugin: cannot bind on port %i!\n", ctx->in_port)); +#else + /* XXX use some configure magic to detect if we have the right strerror_r() + * function (the one that returns int, not char *) and then use strerror_r() + * instead. + */ + OSIP_TRACE (osip_trace + (__FILE__, __LINE__, OSIP_ERROR, NULL, + "udp plugin: cannot bind on port %i (%s)!\n", ctx->in_port, + strerror (errno))); +#endif goto lci_error4; } @@ -132,13 +154,13 @@ } } #endif - /* we'll see later if we need this option.. - if (0==setsockopt(ctx->in_socket, - SOL_SOCKET , SO_REUSEADDR, (void*)&option, sizeof(option))) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_WARNING,NULL,"upd plugin; UDP listener SO_REUSE_ADDR failed %i!\n", ctx->in_port)); - } - */ + if (0 == setsockopt (ctx->in_socket, SOL_SOCKET, SO_REUSEADDR, NULL, NULL)) + { + OSIP_TRACE (osip_trace + (__FILE__, __LINE__, OSIP_WARNING, NULL, + "upd plugin; UDP listener SO_REUSE_ADDR failed %i!\n", + ctx->in_port)); + } return 0; lci_error5: @@ -369,22 +391,34 @@ if (0 > sendto (sock, (const void *) buf, strlen (buf), 0, (struct sockaddr *) &addr, sizeof (addr))) { + sfree (buf); #ifdef WIN32 - if (WSAECONNREFUSED == WSAGetLastError ()) + i = WSAGetLastError (); + if (WSAECONNREFUSED == i) #else - if (ECONNREFUSED == errno) + i = errno; + if (ECONNREFUSED == i) #endif { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "SIP_ECONNREFUSED - No remote server.\n")); - sfree (buf); return 1; /* I prefer to answer 1 by now.. we'll see later what's better */ } +#ifdef WIN32 + OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, + "SIP_NETWORK_ERROR - Network error %i sending message to %s on port %i.\n", + i, host, port)); +#else + /* XXX use some configure magic to detect if we have the right strerror_r() + * function (the one that returns int, not char *) and then use strerror_r() + * instead. + */ OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, - "SIP_NETWORK_ERROR - Network error.\n")); + "SIP_NETWORK_ERROR - Network error %i (%s) sending message to %s on port %i.\n", + i, strerror (i), host, port)); +#endif /* SIP_NETWORK_ERROR; */ - sfree (buf); return -1; }