mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	module-rtp: handle ipv6 sap.ip
Make a socket of the same address family as the address we're going to bind it to. When the source.ip is not specified, use the default in the same address family as the sap.ip. Probe the interface for addresses of the same family as the sap.ip. Makes pactl load-module module-rtp-recv sap_address=:: work. See #3851
This commit is contained in:
		
							parent
							
								
									f5c85478a7
								
							
						
					
					
						commit
						346264f7a4
					
				
					 1 changed files with 7 additions and 5 deletions
				
			
		| 
						 | 
					@ -143,6 +143,7 @@ PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME);
 | 
				
			||||||
#define DEFAULT_SAP_PORT	9875
 | 
					#define DEFAULT_SAP_PORT	9875
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define DEFAULT_SOURCE_IP	"0.0.0.0"
 | 
					#define DEFAULT_SOURCE_IP	"0.0.0.0"
 | 
				
			||||||
 | 
					#define DEFAULT_SOURCE_IP6	"::"
 | 
				
			||||||
#define DEFAULT_TTL		1
 | 
					#define DEFAULT_TTL		1
 | 
				
			||||||
#define DEFAULT_LOOP		false
 | 
					#define DEFAULT_LOOP		false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -367,7 +368,7 @@ static int make_send_socket(
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int af, fd, val, res;
 | 
						int af, fd, val, res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	af = sa->ss_family;
 | 
						af = src->ss_family;
 | 
				
			||||||
	if ((fd = socket(af, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0)) < 0) {
 | 
						if ((fd = socket(af, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0)) < 0) {
 | 
				
			||||||
		pw_log_error("socket failed: %m");
 | 
							pw_log_error("socket failed: %m");
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
| 
						 | 
					@ -1484,13 +1485,12 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
 | 
				
			||||||
			"sap.cleanup.sec", DEFAULT_CLEANUP_SEC);
 | 
								"sap.cleanup.sec", DEFAULT_CLEANUP_SEC);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((str = pw_properties_get(props, "source.ip")) == NULL) {
 | 
						if ((str = pw_properties_get(props, "source.ip")) == NULL) {
 | 
				
			||||||
		str = DEFAULT_SOURCE_IP;
 | 
					 | 
				
			||||||
		if (impl->ifname) {
 | 
							if (impl->ifname) {
 | 
				
			||||||
			int fd = socket(AF_INET, SOCK_DGRAM, 0);
 | 
								int fd = socket(impl->sap_addr.ss_family, SOCK_DGRAM, 0);
 | 
				
			||||||
			if (fd >= 0) {
 | 
								if (fd >= 0) {
 | 
				
			||||||
				struct ifreq req;
 | 
									struct ifreq req;
 | 
				
			||||||
				spa_zero(req);
 | 
									spa_zero(req);
 | 
				
			||||||
				req.ifr_addr.sa_family = AF_INET;
 | 
									req.ifr_addr.sa_family = impl->sap_addr.ss_family;
 | 
				
			||||||
				snprintf(req.ifr_name, sizeof(req.ifr_name), "%s", impl->ifname);
 | 
									snprintf(req.ifr_name, sizeof(req.ifr_name), "%s", impl->ifname);
 | 
				
			||||||
				res = ioctl(fd, SIOCGIFADDR, &req);
 | 
									res = ioctl(fd, SIOCGIFADDR, &req);
 | 
				
			||||||
				if (res < 0)
 | 
									if (res < 0)
 | 
				
			||||||
| 
						 | 
					@ -1500,13 +1500,15 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
 | 
				
			||||||
						addr, sizeof(addr));
 | 
											addr, sizeof(addr));
 | 
				
			||||||
				if (str == NULL) {
 | 
									if (str == NULL) {
 | 
				
			||||||
					pw_log_warn("can't parse interface ip: %m");
 | 
										pw_log_warn("can't parse interface ip: %m");
 | 
				
			||||||
					str = DEFAULT_SOURCE_IP;
 | 
					 | 
				
			||||||
				} else {
 | 
									} else {
 | 
				
			||||||
					pw_log_info("interface %s IP: %s", impl->ifname, str);
 | 
										pw_log_info("interface %s IP: %s", impl->ifname, str);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				close(fd);
 | 
									close(fd);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							if (str == NULL)
 | 
				
			||||||
 | 
								str = impl->sap_addr.ss_family == AF_INET ?
 | 
				
			||||||
 | 
									DEFAULT_SOURCE_IP : DEFAULT_SOURCE_IP6;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if ((res = parse_address(str, 0, &impl->src_addr, &impl->src_len)) < 0) {
 | 
						if ((res = parse_address(str, 0, &impl->src_addr, &impl->src_len)) < 0) {
 | 
				
			||||||
		pw_log_error("invalid source.ip %s: %s", str, spa_strerror(res));
 | 
							pw_log_error("invalid source.ip %s: %s", str, spa_strerror(res));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue