}
static void
-inc_address (Addr * addr, guint8 count)
+inc_address (Addr * addr, guint count)
{
gint i;
guint carry;
}
/* tells us the number of addresses between min_addr and max_addr */
-
static guint
diff_address (Addr * max_addr, Addr * min_addr)
{
return result;
}
-
static AddrRange *
split_range (GstRTSPAddressPool * pool, AddrRange * range, guint skip_addr,
guint skip_port, gint n_ports)
ttl);
if (list != NULL) {
AddrRange *range = list->data;
- gint skip_port, skip_addr;
+ guint skip_port, skip_addr;
skip_addr = diff_address (&input_addr, &range->min);
skip_port = port - range->min.port;
+ GST_DEBUG_OBJECT (pool, "diff 0x%08x/%u", skip_addr, skip_port);
+
/* we found a range, remove from the list */
priv->addresses = g_list_delete_link (priv->addresses, list);
/* now split and exit our loop */
fail_unless (!strcmp (addr->address, "192.168.1.1"));
gst_rtsp_address_free (addr);
+ fail_unless (gst_rtsp_address_pool_add_range (pool,
+ GST_RTSP_ADDRESS_POOL_ANY_IPV4, GST_RTSP_ADDRESS_POOL_ANY_IPV4, 5000,
+ 5001, 0));
+ res =
+ gst_rtsp_address_pool_reserve_address (pool, "192.168.0.1", 5000, 1, 0,
+ &addr);
+ fail_unless (res == GST_RTSP_ADDRESS_POOL_ERANGE);
+ res =
+ gst_rtsp_address_pool_reserve_address (pool, "0.0.0.0", 5000, 1, 0,
+ &addr);
+ fail_unless (res == GST_RTSP_ADDRESS_POOL_OK);
+ gst_rtsp_address_free (addr);
+ gst_rtsp_address_pool_clear (pool);
+
+ /* Error case 2. Using ANY as min address makes it possible to allocate the
+ * same address twice */
+ fail_unless (gst_rtsp_address_pool_add_range (pool,
+ GST_RTSP_ADDRESS_POOL_ANY_IPV4, "255.255.255.255", 5000, 5001, 0));
+ res =
+ gst_rtsp_address_pool_reserve_address (pool, "192.168.0.1", 5000, 1, 0,
+ &addr);
+ fail_unless (res == GST_RTSP_ADDRESS_POOL_OK);
+ res =
+ gst_rtsp_address_pool_reserve_address (pool, "192.168.0.1", 5000, 1, 0,
+ &addr2);
+ fail_unless (res == GST_RTSP_ADDRESS_POOL_ERESERVED);
+ gst_rtsp_address_free (addr);
+ gst_rtsp_address_pool_clear (pool);
g_object_unref (pool);
}