[polypaudio-commits] r569 - in /trunk/src: modules/module-protocol-stub.c polypcore/socket-server.c polypcore/socket-server.h
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Wed Feb 22 12:44:38 PST 2006
Author: lennart
Date: Wed Feb 22 21:44:37 2006
New Revision: 569
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=569&root=polypaudio&view=rev
Log:
add listen= parameter to tcp protocol modules
Modified:
trunk/src/modules/module-protocol-stub.c
trunk/src/polypcore/socket-server.c
trunk/src/polypcore/socket-server.h
Modified: trunk/src/modules/module-protocol-stub.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/modules/module-protocol-stub.c?rev=569&root=polypaudio&r1=568&r2=569&view=diff
==============================================================================
--- trunk/src/modules/module-protocol-stub.c (original)
+++ trunk/src/modules/module-protocol-stub.c Wed Feb 22 21:44:37 2006
@@ -52,7 +52,7 @@
#ifdef USE_TCP_SOCKETS
#define SOCKET_DESCRIPTION "(TCP sockets)"
-#define SOCKET_USAGE "port=<TCP port number> loopback=<listen on loopback device only?>"
+#define SOCKET_USAGE "port=<TCP port number> loopback=<listen on loopback device only?> listen=<address to listen on>"
#else
#define SOCKET_DESCRIPTION "(UNIX sockets)"
#define SOCKET_USAGE "socket=<path to UNIX socket>"
@@ -146,6 +146,7 @@
#if defined(USE_TCP_SOCKETS)
"port",
"loopback",
+ "listen",
#else
"socket",
#endif
@@ -157,6 +158,7 @@
#if defined(USE_TCP_SOCKETS)
int loopback = 1;
uint32_t port = IPV4_PORT;
+ const char *listen_on;
if (pa_modargs_get_value_boolean(ma, "loopback", &loopback) < 0) {
pa_log(__FILE__": loopback= expects a boolean argument.\n");
@@ -168,8 +170,12 @@
return NULL;
}
-
- if (loopback) {
+ listen_on = pa_modargs_get_value(ma, "listen", NULL);
+
+ if (listen_on) {
+ if (!(s = pa_socket_server_new_ip_string(c->mainloop, listen_on, port, TCPWRAP_SERVICE)))
+ return NULL;
+ } else if (loopback) {
if (!(s = pa_socket_server_new_ip_loopback(c->mainloop, port, TCPWRAP_SERVICE)))
return NULL;
} else {
Modified: trunk/src/polypcore/socket-server.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polypcore/socket-server.c?rev=569&root=polypaudio&r1=568&r2=569&view=diff
==============================================================================
--- trunk/src/polypcore/socket-server.c (original)
+++ trunk/src/polypcore/socket-server.c Wed Feb 22 21:44:37 2006
@@ -334,6 +334,24 @@
return s;
}
+pa_socket_server* pa_socket_server_new_ip_string(pa_mainloop_api *m, const char *name, uint16_t port, const char *tcpwrap_service) {
+ uint8_t ipv6[16];
+ uint32_t ipv4;
+
+ assert(m);
+ assert(name);
+ assert(port > 0);
+
+ if (inet_pton(AF_INET6, name, ipv6) > 0)
+ return pa_socket_server_new_ipv6(m, ipv6, port, tcpwrap_service);
+
+ if (inet_pton(AF_INET, name, &ipv4) > 0)
+ return pa_socket_server_new_ipv4(m, ntohl(ipv4), port, tcpwrap_service);
+
+ pa_log_warn(__FILE__": failed to parse '%s'.\n", name);
+
+ return NULL;
+}
static void socket_server_free(pa_socket_server*s) {
assert(s);
Modified: trunk/src/polypcore/socket-server.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polypcore/socket-server.h?rev=569&root=polypaudio&r1=568&r2=569&view=diff
==============================================================================
--- trunk/src/polypcore/socket-server.h (original)
+++ trunk/src/polypcore/socket-server.h Wed Feb 22 21:44:37 2006
@@ -36,6 +36,7 @@
pa_socket_server* pa_socket_server_new_ipv6(pa_mainloop_api *m, const uint8_t address[16], uint16_t port, const char *tcpwrap_service);
pa_socket_server* pa_socket_server_new_ip_loopback(pa_mainloop_api *m, uint16_t port, const char *tcpwrap_service);
pa_socket_server* pa_socket_server_new_ip_any(pa_mainloop_api *m, uint16_t port, const char *tcpwrap_service);
+pa_socket_server* pa_socket_server_new_ip_string(pa_mainloop_api *m, const char *name, uint16_t port, const char *tcpwrap_service);
void pa_socket_server_unref(pa_socket_server*s);
pa_socket_server* pa_socket_server_ref(pa_socket_server *s);
More information about the pulseaudio-commits
mailing list