mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-20 23:36:38 +00:00
gst-libs/gst/netbuffer/gstnetbuffer.*: Make gst_netaddress_get_ip4_address fail for v6 addresses.
Original commit message from CVS: Patch by: Andrew Feren <acferen at yahoo dot com> * gst-libs/gst/netbuffer/gstnetbuffer.c: (gst_netaddress_get_ip4_address), (gst_netaddress_get_ip6_address), (gst_netaddress_get_address_bytes), (gst_netaddress_set_address_bytes): * gst-libs/gst/netbuffer/gstnetbuffer.h: Make gst_netaddress_get_ip4_address fail for v6 addresses. Make gst_netaddress_get_ip6_address either fail or return the v4 address as a transitional v6 address. Add two convenience functions: API: gst_netaddress_get_address_bytes() API: gst_netaddress_set_address_bytes() Fixes #564896.
This commit is contained in:
parent
8567ee2149
commit
a628077e96
3 changed files with 122 additions and 13 deletions
17
ChangeLog
17
ChangeLog
|
@ -1,3 +1,20 @@
|
||||||
|
2008-12-18 Wim Taymans <wim.taymans@collabora.co.uk>
|
||||||
|
|
||||||
|
Patch by: Andrew Feren <acferen at yahoo dot com>
|
||||||
|
|
||||||
|
* gst-libs/gst/netbuffer/gstnetbuffer.c:
|
||||||
|
(gst_netaddress_get_ip4_address), (gst_netaddress_get_ip6_address),
|
||||||
|
(gst_netaddress_get_address_bytes),
|
||||||
|
(gst_netaddress_set_address_bytes):
|
||||||
|
* gst-libs/gst/netbuffer/gstnetbuffer.h:
|
||||||
|
Make gst_netaddress_get_ip4_address fail for v6 addresses.
|
||||||
|
Make gst_netaddress_get_ip6_address either fail or return the v4
|
||||||
|
address as a transitional v6 address.
|
||||||
|
Add two convenience functions:
|
||||||
|
API: gst_netaddress_get_address_bytes()
|
||||||
|
API: gst_netaddress_set_address_bytes()
|
||||||
|
Fixes #564896.
|
||||||
|
|
||||||
2008-12-17 Stefan Kost <ensonic@users.sf.net>
|
2008-12-17 Stefan Kost <ensonic@users.sf.net>
|
||||||
|
|
||||||
* gst/adder/Makefile.am:
|
* gst/adder/Makefile.am:
|
||||||
|
|
|
@ -190,7 +190,8 @@ gst_netaddress_get_net_type (GstNetAddress * naddr)
|
||||||
* @address: a location to store the address.
|
* @address: a location to store the address.
|
||||||
* @port: a location to store the port.
|
* @port: a location to store the port.
|
||||||
*
|
*
|
||||||
* Get the IPv4 address stored in @naddr into @address.
|
* Get the IPv4 address stored in @naddr into @address. This function requires
|
||||||
|
* that the address type of @naddr is of type #GST_NET_TYPE_IP4.
|
||||||
*
|
*
|
||||||
* Returns: TRUE if the address could be retrieved.
|
* Returns: TRUE if the address could be retrieved.
|
||||||
*/
|
*/
|
||||||
|
@ -200,7 +201,7 @@ gst_netaddress_get_ip4_address (GstNetAddress * naddr, guint32 * address,
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (naddr != NULL, FALSE);
|
g_return_val_if_fail (naddr != NULL, FALSE);
|
||||||
|
|
||||||
if (naddr->type == GST_NET_TYPE_UNKNOWN)
|
if (naddr->type == GST_NET_TYPE_UNKNOWN || naddr->type == GST_NET_TYPE_IP6)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (address)
|
if (address)
|
||||||
|
@ -219,25 +220,113 @@ gst_netaddress_get_ip4_address (GstNetAddress * naddr, guint32 * address,
|
||||||
*
|
*
|
||||||
* Get the IPv6 address stored in @naddr into @address.
|
* Get the IPv6 address stored in @naddr into @address.
|
||||||
*
|
*
|
||||||
|
* If @naddr is of type GST_NET_TYPE_IP4, the transitional IP6 address is
|
||||||
|
* returned.
|
||||||
|
*
|
||||||
* Returns: TRUE if the address could be retrieved.
|
* Returns: TRUE if the address could be retrieved.
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gst_netaddress_get_ip6_address (GstNetAddress * naddr, guint8 address[16],
|
gst_netaddress_get_ip6_address (GstNetAddress * naddr, guint8 address[16],
|
||||||
guint16 * port)
|
guint16 * port)
|
||||||
{
|
{
|
||||||
|
static guint8 ip4_transition[16] =
|
||||||
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF };
|
||||||
g_return_val_if_fail (naddr != NULL, FALSE);
|
g_return_val_if_fail (naddr != NULL, FALSE);
|
||||||
|
|
||||||
if (naddr->type == GST_NET_TYPE_UNKNOWN)
|
if (naddr->type == GST_NET_TYPE_UNKNOWN)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (address)
|
if (address) {
|
||||||
memcpy (address, naddr->address.ip6, 16);
|
if (naddr->type == GST_NET_TYPE_IP6) {
|
||||||
|
memcpy (address, naddr->address.ip6, 16);
|
||||||
|
} else { /* naddr->type == GST_NET_TYPE_IP4 */
|
||||||
|
memcpy (address, ip4_transition, 12);
|
||||||
|
memcpy (address + 12, (guint8 *) & (naddr->address.ip4), 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (port)
|
if (port)
|
||||||
*port = naddr->port;
|
*port = naddr->port;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_netaddress_get_address_bytes:
|
||||||
|
* @naddr: a network address
|
||||||
|
* @address: a location to store the result.
|
||||||
|
* @port: a location to store the port.
|
||||||
|
*
|
||||||
|
* Get just the address bytes stored in @naddr into @address.
|
||||||
|
*
|
||||||
|
* Returns: number of bytes actually copied
|
||||||
|
*
|
||||||
|
* Since: 0.10.22
|
||||||
|
*/
|
||||||
|
gint
|
||||||
|
gst_netaddress_get_address_bytes (GstNetAddress * naddr, guint8 address[16],
|
||||||
|
guint16 * port)
|
||||||
|
{
|
||||||
|
gint ret = 0;
|
||||||
|
|
||||||
|
g_return_val_if_fail (naddr != NULL, FALSE);
|
||||||
|
|
||||||
|
if (naddr->type == GST_NET_TYPE_UNKNOWN)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (address) {
|
||||||
|
if (naddr->type == GST_NET_TYPE_IP6) {
|
||||||
|
memcpy (address, naddr->address.ip6, 16);
|
||||||
|
ret = 16;
|
||||||
|
} else { /* naddr->type == GST_NET_TYPE_IP4 */
|
||||||
|
memcpy (address, (guint8 *) & (naddr->address.ip4), 4);
|
||||||
|
ret = 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (port)
|
||||||
|
*port = naddr->port;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_netaddress_set_address_bytes:
|
||||||
|
* @naddr: a network address
|
||||||
|
* @address: a location to store the result.
|
||||||
|
* @port: a location to store the port.
|
||||||
|
*
|
||||||
|
* Set just the address bytes stored in @naddr into @address.
|
||||||
|
*
|
||||||
|
* Returns: number of bytes actually copied
|
||||||
|
*
|
||||||
|
* Since: 0.10.22
|
||||||
|
*/
|
||||||
|
gint
|
||||||
|
gst_netaddress_set_address_bytes (GstNetAddress * naddr, GstNetType type,
|
||||||
|
guint8 address[16], guint16 port)
|
||||||
|
{
|
||||||
|
gint len = 0;
|
||||||
|
|
||||||
|
g_return_val_if_fail (naddr != NULL, 0);
|
||||||
|
|
||||||
|
naddr->type = type;
|
||||||
|
switch (naddr->type) {
|
||||||
|
case GST_NET_TYPE_UNKNOWN:
|
||||||
|
case GST_NET_TYPE_IP6:
|
||||||
|
len = 16;
|
||||||
|
memcpy (naddr->address.ip6, address, 16);
|
||||||
|
break;
|
||||||
|
case GST_NET_TYPE_IP4:
|
||||||
|
len = 4;
|
||||||
|
memcpy ((guint8 *) & (naddr->address.ip4), address, 4);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (port)
|
||||||
|
naddr->port = port;
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_netaddress_equal:
|
* gst_netaddress_equal:
|
||||||
* @naddr1: The first #GstNetAddress
|
* @naddr1: The first #GstNetAddress
|
||||||
|
|
|
@ -93,20 +93,23 @@ struct _GstNetBufferClass {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* creating buffers */
|
/* creating buffers */
|
||||||
GType gst_netbuffer_get_type (void);
|
GType gst_netbuffer_get_type (void);
|
||||||
|
|
||||||
GstNetBuffer* gst_netbuffer_new (void);
|
GstNetBuffer* gst_netbuffer_new (void);
|
||||||
|
|
||||||
/* address operations */
|
/* address operations */
|
||||||
void gst_netaddress_set_ip4_address (GstNetAddress *naddr, guint32 address, guint16 port);
|
void gst_netaddress_set_ip4_address (GstNetAddress *naddr, guint32 address, guint16 port);
|
||||||
void gst_netaddress_set_ip6_address (GstNetAddress *naddr, guint8 address[16], guint16 port);
|
void gst_netaddress_set_ip6_address (GstNetAddress *naddr, guint8 address[16], guint16 port);
|
||||||
|
gint gst_netaddress_set_address_bytes (GstNetAddress *naddr, GstNetType type,
|
||||||
|
guint8 address[16], guint16 port);
|
||||||
|
|
||||||
GstNetType gst_netaddress_get_net_type (GstNetAddress *naddr);
|
GstNetType gst_netaddress_get_net_type (GstNetAddress *naddr);
|
||||||
gboolean gst_netaddress_get_ip4_address (GstNetAddress *naddr, guint32 *address, guint16 *port);
|
gboolean gst_netaddress_get_ip4_address (GstNetAddress *naddr, guint32 *address, guint16 *port);
|
||||||
gboolean gst_netaddress_get_ip6_address (GstNetAddress *naddr, guint8 address[16], guint16 *port);
|
gboolean gst_netaddress_get_ip6_address (GstNetAddress *naddr, guint8 address[16], guint16 *port);
|
||||||
|
gint gst_netaddress_get_address_bytes (GstNetAddress *naddr, guint8 address[16], guint16 *port);
|
||||||
|
|
||||||
gboolean gst_netaddress_equal (const GstNetAddress *naddr1,
|
gboolean gst_netaddress_equal (const GstNetAddress *naddr1,
|
||||||
const GstNetAddress *naddr2);
|
const GstNetAddress *naddr2);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue