Commit 72292bb3 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

- Write COMEDIA MRLs properly (host is the remote rather than the local part)

- Validate and canonicalize source-filter address
parent aba6c4cd
...@@ -894,26 +894,13 @@ static int ParseConnection( vlc_object_t *p_obj, sdp_t *p_sdp ) ...@@ -894,26 +894,13 @@ static int ParseConnection( vlc_object_t *p_obj, sdp_t *p_sdp )
"\0"; "\0";
const char *vlc_proto = NULL; const char *vlc_proto = NULL;
uint8_t flags = 0;
for (const char *proto = proto_match; *proto;) for (const char *proto = proto_match; *proto;)
{ {
if (strcasecmp (proto, sdp_proto)) if (strcasecmp (proto, sdp_proto))
{ {
vlc_proto = proto + strlen (proto) + 1; vlc_proto = proto + strlen (proto) + 1;
flags = vlc_proto[strlen (vlc_proto) + 1];
if (vlc_proto[strlen (vlc_proto) + 1] & 1)
{
/* COMEDIA check */
const char *setup = FindAttribute (p_sdp, 0, "setup");
if (setup == NULL)
setup = "active"; /* default value */
if (strcmp (setup, "actpass") && strcmp (setup, "passive"))
{
msg_Dbg (p_obj, "unsupported COMEDIA mode: %s", setup);
free (sdp_proto);
return VLC_EGENERIC;
}
}
break; break;
} }
proto += strlen (proto) + 1; proto += strlen (proto) + 1;
...@@ -928,24 +915,72 @@ static int ParseConnection( vlc_object_t *p_obj, sdp_t *p_sdp ) ...@@ -928,24 +915,72 @@ static int ParseConnection( vlc_object_t *p_obj, sdp_t *p_sdp )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
/* handle SSM case */ if (flags & 1)
const char *sfilter = FindAttribute (p_sdp, 0, "source-filter"); {
/* Connection-oriented media */
const char *setup = FindAttribute (p_sdp, 0, "setup");
if (setup == NULL)
setup = "active"; /* default value */
if (strcmp (setup, "actpass") && strcmp (setup, "passive"))
{
msg_Dbg (p_obj, "unsupported COMEDIA mode: %s", setup);
return VLC_EGENERIC;
}
if (asprintf (&p_sdp->psz_uri, "%s://%s:%d", vlc_proto,
host, port) == -1)
return VLC_ENOMEM;
}
else
{
/* Non-connected (normally multicast) media */
char psz_source[258] = ""; char psz_source[258] = "";
const char *sfilter = FindAttribute (p_sdp, 0, "source-filter");
if (sfilter != NULL) if (sfilter != NULL)
{ {
char psz_source_ip[256]; char psz_source_ip[256];
unsigned ipv;
if (sscanf (sfilter, " incl IN IP%*c %*s %255s ", psz_source_ip) == 1) if (sscanf (sfilter, " incl IN IP%u %*s %255s ", &ipv,
psz_source_ip) == 2)
{ {
if (strchr (psz_source_ip, ':') != NULL) /* According to RFC4570, FQDNs can be used for source-filters,
sprintf (psz_source, "[%s]", psz_source_ip); * but -seriously- this is impractical */
else switch (ipv)
strcpy (psz_source, psz_source_ip); {
#ifdef AF_INET6
case 6:
{
struct in6_addr addr;
if ((inet_pton (AF_INET6, psz_source_ip, &addr) > 0)
&& (inet_ntop (AF_INET6, &addr, psz_source + 1,
sizeof (psz_source) - 2) != NULL))
{
psz_source[0] = '[';
psz_source[strlen (psz_source)] = ']';
}
break;
}
#endif
case 4:
{
struct in_addr addr;
if ((inet_pton (AF_INET, psz_source_ip, &addr) > 0)
&& (inet_ntop (AF_INET, &addr, psz_source,
sizeof (psz_source)) == NULL))
*psz_source = '\0';
break;
}
}
} }
} }
asprintf( &p_sdp->psz_uri, "%s://%s@%s:%i", vlc_proto, psz_source, if (asprintf (&p_sdp->psz_uri, "%s://%s@%s:%i", vlc_proto, psz_source,
host, port ); host, port) == -1)
return VLC_ENOMEM;
}
return VLC_SUCCESS; return VLC_SUCCESS;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment