wtay gst-plugins-base: gst-plugins-base/ gst-plugins-base/gst-libs/gst/netbuffer/
[email protected] Thu, 18 Dec 2008 04:37:47 -0800 (PST)
| Newsgroups | gmane.comp.video.gstreamer.cvs |
|---|---|
| Message-ID | <[email protected]> |
CVS Root: /cvs/gstreamer
Module: gst-plugins-base
Changes by: wtay
Date: Thu Dec 18 2008 12:37:47 UTC
Log message:
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.
Modified files:
. : ChangeLog
gst-libs/gst/netbuffer: gstnetbuffer.c gstnetbuffer.h
Links:
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/ChangeLog.diff?r1=1.4257&r2=1.4258
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/gst-libs/gst/netbuffer/gstnetbuffer.c.diff?r1=1.7&r2=1.8
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/gst-libs/gst/netbuffer/gstnetbuffer.h.diff?r1=1.5&r2=1.6
====Begin Diffs====
Index: ChangeLog
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-base/ChangeLog,v
retrieving revision 1.4257
retrieving revision 1.4258
diff -u -d -r1.4257 -r1.4258
--- ChangeLog 17 Dec 2008 08:51:33 -0000 1.4257
+++ ChangeLog 18 Dec 2008 12:37:31 -0000 1.4258
@@ -1,3 +1,20 @@
+2008-12-18 Wim Taymans <[email protected]>
+
+ 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 <[email protected]>
* gst/adder/Makefile.am:
Index: gstnetbuffer.c
RCS file: /cvs/gstreamer/gst-plugins-base/gst-libs/gst/netbuffer/gstnetbuffer.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- gstnetbuffer.c 7 Mar 2008 18:17:44 -0000 1.7
+++ gstnetbuffer.c 18 Dec 2008 12:37:33 -0000 1.8
@@ -190,7 +190,8 @@
* @address: a location to store the address.
* @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.
*/
@@ -200,7 +201,7 @@
{
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;
if (address)
@@ -219,19 +220,30 @@
* Get the IPv6 address stored in @naddr into @address.
+ * If @naddr is of type GST_NET_TYPE_IP4, the transitional IP6 address is
+ * returned.
+ *
gboolean
gst_netaddress_get_ip6_address (GstNetAddress * naddr, guint8 address[16],
guint16 * port)
+ static guint8 ip4_transition[16] =
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF };
if (naddr->type == GST_NET_TYPE_UNKNOWN)
- if (address)
- memcpy (address, naddr->address.ip6, 16);
+ if (address) {
+ 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)
*port = naddr->port;
@@ -239,6 +251,83 @@
}
/**
+ * 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;
+ ret = 16;
+ memcpy (address, (guint8 *) & (naddr->address.ip4), 4);
+ ret = 4;
+ if (port)
+ *port = naddr->port;
+ return ret;
+}
+/**
+ * gst_netaddress_set_address_bytes:
+ * Set just the address bytes stored in @naddr into @address.
+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);
+ naddr->port = port;
+ return len;
* gst_netaddress_equal:
* @naddr1: The first #GstNetAddress
* @naddr2: The second #GstNetAddress
Index: gstnetbuffer.h
RCS file: /cvs/gstreamer/gst-plugins-base/gst-libs/gst/netbuffer/gstnetbuffer.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- gstnetbuffer.h 7 Mar 2008 18:17:44 -0000 1.5
+++ gstnetbuffer.h 18 Dec 2008 12:37:33 -0000 1.6
@@ -93,20 +93,23 @@
};
/* 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 */
-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_ip4_address (GstNetAddress *naddr, guint32 address, 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);
-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);
+GstNetType gst_netaddress_get_net_type (GstNetAddress *naddr);
+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);
+gint gst_netaddress_get_address_bytes (GstNetAddress *naddr, guint8 address[16], guint16 *port);
-gboolean gst_netaddress_equal (const GstNetAddress *naddr1,
- const GstNetAddress *naddr2);
+gboolean gst_netaddress_equal (const GstNetAddress *naddr1,
+ const GstNetAddress *naddr2);
G_END_DECLS
------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you. Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/