*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
{
char *psz_address;
char psz_machine[NI_MAXNUMERICHOST];
- int i_port;
int i_rfd; /* Read socket */
int i_wfd; /* Write socket */
if ((ipv4 & 0xfffc0000) == 0xefc00000)
ipv4 = 0xefc3ffff;
else
+ if ((ipv4 & 0xff000000) == 0xef000000)
+ ipv4 = 0;
+ else
/* other addresses => 224.2.127.254 */
ipv4 = 0xe0027ffe;
+ if( ipv4 == 0 )
+ {
+ msg_Err( p_sap, "Out-of-scope multicast address "
+ "not supported by SAP: %s", p_session->psz_uri );
+ vlc_mutex_unlock( &p_sap->object_lock );
+ vlc_freeaddrinfo( res );
+ return VLC_EGENERIC;
+ }
+
((struct sockaddr_in *)&addr)->sin_addr.s_addr = htonl( ipv4 );
break;
}
return VLC_ENOMEM;
}
p_address->psz_address = strdup( psz_addr );
- p_address->i_port = 9875;
- p_address->i_wfd = net_OpenUDP( p_sap, "", 0, psz_addr,
- p_address->i_port );
+ p_address->i_wfd = net_ConnectUDP( p_sap, psz_addr, SAP_PORT, 255 );
if( p_address->i_wfd != -1 )
{
char *ptr;
if( p_sap->b_control == VLC_TRUE )
{
- p_address->i_rfd = net_OpenUDP( p_sap, psz_addr,
- p_address->i_port, "", 0 );
+ p_address->i_rfd = net_OpenUDP( p_sap, psz_addr, SAP_PORT, "", 0 );
if( p_address->i_rfd != -1 )
net_StopSend( p_address->i_rfd );
p_address->i_buff = 0;
psz_head + 4 );
}
else
-#else
+#endif
{
inet_pton( AF_INET, /* can't fail */
p_sap_session->p_address->psz_machine,
psz_head + 4 );
}
-#endif
memcpy( psz_head + (b_ipv6 ? 20 : 8), "application/sdp", 15 );
i_ret = net_Write( p_sap, p_session->p_address->i_wfd, NULL,
p_session->psz_data,
p_session->i_length );
- if( i_ret != p_session->i_length )
+ if( i_ret != (int)p_session->i_length )
{
msg_Warn( p_sap, "SAP send failed on address %s (%i %i)",
p_session->p_address->psz_address,
"%s%s%s",
i_sdp_id, i_sdp_version,
ipv, p_addr->psz_machine,
- psz_name, ipv, psz_uri, p_session->i_ttl,
+ psz_name, ipv, psz_uri,
+ /* FIXME: 1 is IPv4 default TTL, not that of IPv6 */
+ p_session->i_ttl ?: (config_GetInt( p_sap, "ttl" ) ?: 1),
p_session->i_port,
p_session->b_rtp ? "RTP/AVP" : "udp",
p_session->i_payload,
psz_group ? "a=x-plgroup:" : "",
psz_group ? psz_group : "", psz_group ? "\r\n" : "" ) == -1 )
return NULL;
-
+
msg_Dbg( p_sap, "Generated SDP (%i bytes):\n%s", strlen(psz_sdp),
psz_sdp );
return psz_sdp;
}
#ifdef EXTRA_DEBUG
msg_Dbg( p_sap,"%s:%i : Rate=%i, Interval = %i s",
- p_address->psz_address,p_address->i_port,
- i_rate,
- p_address->i_interval );
+ p_address->psz_address,SAP_PORT, i_rate, p_address->i_interval );
#endif
p_address->b_ready = VLC_TRUE;