]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Add scope_id to information used to bind an outgoing IPv6 port. Makes it work with...
authorMike Brady <mikebrady@eircom.net>
Fri, 13 May 2016 16:32:13 +0000 (16:32 +0000)
committerMike Brady <mikebrady@eircom.net>
Fri, 13 May 2016 16:32:13 +0000 (16:32 +0000)
rtp.c

diff --git a/rtp.c b/rtp.c
index 811b4e6b03f6cd3240334945584218ecc1084eb4..0f8dae931e1cad51d322f9d0f300130bdb33d21b 100644 (file)
--- a/rtp.c
+++ b/rtp.c
@@ -60,6 +60,7 @@ static int running = 0;
 
 static char client_ip_string[INET6_ADDRSTRLEN]; // the ip string pointing to the client
 static char self_ip_string[INET6_ADDRSTRLEN]; // the ip string being used by this program -- it could be one of many, so we need to know it
+static uint32_t self_scope_id; // if it's an ipv6 connection, this will be its scope
 static short connection_ip_family;                  // AF_INET / AF_INET6
 static uint32_t client_active_remote;           // used when you want to control the client...
 
@@ -544,7 +545,7 @@ void *rtp_timing_receiver(void *arg) {
   return NULL;
 }
 
-static int bind_port(int ip_family,const char *self_ip_address, int *sock) { 
+static int bind_port(int ip_family,const char *self_ip_address,uint32_t scope_id,int *sock) { 
   // look for a port in the range, if any was specified.
   int desired_port = config.udp_port_base;
   int ret;
@@ -568,6 +569,7 @@ static int bind_port(int ip_family,const char *self_ip_address, int *sock) {
       sa6->sin6_family = AF_INET6;
       sa6->sin6_port = ntohs(desired_port);
       inet_pton(AF_INET6,self_ip_address,&(sa6->sin6_addr));
+      sa6->sin6_scope_id=scope_id;
       ret = bind(local_socket,(struct sockaddr*)sa6, sizeof(struct sockaddr_in6));
     }
 #endif   
@@ -630,6 +632,7 @@ void rtp_setup(SOCKADDR *local, SOCKADDR *remote, int cport, int tport, uint32_t
     sa6 = (struct sockaddr_in6 *)local;
     self_addr = &(sa6->sin6_addr);
     self_port = ntohs(sa6->sin6_port);
+    self_scope_id = sa6->sin6_scope_id;
   }
 #endif
   if (connection_ip_family == AF_INET) {
@@ -689,9 +692,9 @@ void rtp_setup(SOCKADDR *local, SOCKADDR *remote, int cport, int tport, uint32_t
   // now, we open three sockets -- one for the audio stream, one for the timing and one for the
   // control
 
-  *lsport = bind_port(connection_ip_family,self_ip_string,&audio_socket);
-  *lcport = bind_port(connection_ip_family,self_ip_string,&control_socket);
-  *ltport = bind_port(connection_ip_family,self_ip_string,&timing_socket);
+  *lsport = bind_port(connection_ip_family,self_ip_string,self_scope_id,&audio_socket);
+  *lcport = bind_port(connection_ip_family,self_ip_string,self_scope_id,&control_socket);
+  *ltport = bind_port(connection_ip_family,self_ip_string,self_scope_id,&timing_socket);
 
   debug(2, "listening for audio, control and timing on ports %d, %d, %d.", *lsport, *lcport,
         *ltport);