IPDriver(const System::Net::IPEndpoint& ep) { FromHexString("452566E212031284966AB354F7F6CA04",(unsigned char*)id.value,2*16); sock = System::Net::CreateUDPSocket(ep); //Put a sock in itself. System::Net::IPEndpoint bound; sock->GetLocalEndpoint(bound); for(size_t i = 0;i<3;i++) { if(routerip) { gupnp_simple_igd_add_port(gateway.igdContext,"UDP",0,routerip,bound.port,60,"GlobalGrid rules!"); printf("GlobalGrid protocol registered on physical router\n"); break; } sleep(1); } }
static void run_gupnp_simple_igd_test (GMainContext *mainctx, GUPnPSimpleIgd *igd, guint requested_port) { GUPnPContext *context; GUPnPRootDevice *dev; GUPnPDeviceInfo *subdev1; GUPnPDeviceInfo *subdev2; const gchar *xml_path = "."; if (mainctx) g_main_context_push_thread_default (mainctx); context = gupnp_context_new (NULL, NULL, 0, NULL); g_assert (context); if (g_getenv ("XML_PATH")) xml_path = g_getenv ("XML_PATH"); gupnp_context_host_path (context, xml_path, ""); /* gupnp_context_host_path (context, "InternetGatewayDevice.xml", "/InternetGatewayDevice.xml"); gupnp_context_host_path (context, "WANIPConnection.xml", "/WANIPConnection.xml"); gupnp_context_host_path (context, "WANPPPConnection.xml", "/WANPPPConnection.xml"); */ dev = gupnp_root_device_new (context, "InternetGatewayDevice.xml", xml_path); g_assert (dev); subdev1 = gupnp_device_info_get_device (GUPNP_DEVICE_INFO (dev), "urn:schemas-upnp-org:device:WANDevice:1"); g_assert (subdev1); subdev2 = gupnp_device_info_get_device (subdev1, "urn:schemas-upnp-org:device:WANConnectionDevice:1"); g_assert (subdev2); g_object_unref (subdev1); ipservice = gupnp_device_info_get_service (subdev2, "urn:schemas-upnp-org:service:WANIPConnection:1"); g_assert (ipservice); pppservice = gupnp_device_info_get_service (subdev2, "urn:schemas-upnp-org:service:WANPPPConnection:1"); g_assert (pppservice); g_object_unref (subdev2); g_signal_connect (ipservice, "action-invoked::GetExternalIPAddress", G_CALLBACK (get_external_ip_address_cb), GINT_TO_POINTER (CONNECTION_IP)); g_signal_connect (ipservice, "action-invoked::AddPortMapping", G_CALLBACK (add_port_mapping_cb), GUINT_TO_POINTER (requested_port));; g_signal_connect (ipservice, "action-invoked::DeletePortMapping", G_CALLBACK (delete_port_mapping_cb), GUINT_TO_POINTER (requested_port)); g_signal_connect (pppservice, "action-invoked::GetExternalIPAddress", G_CALLBACK (get_external_ip_address_cb), GINT_TO_POINTER (CONNECTION_PPP)); g_signal_connect (pppservice, "action-invoked::AddPortMapping", G_CALLBACK (add_port_mapping_cb), GUINT_TO_POINTER (requested_port)); g_signal_connect (pppservice, "action-invoked::DeletePortMapping", G_CALLBACK (delete_port_mapping_cb), GUINT_TO_POINTER (requested_port)); gupnp_root_device_set_available (dev, TRUE); g_signal_connect (igd, "mapped-external-port", G_CALLBACK (mapped_external_port_cb), GUINT_TO_POINTER (requested_port)); g_signal_connect (igd, "error-mapping-port", G_CALLBACK (error_mapping_port_cb), NULL); gupnp_simple_igd_add_port (igd, "UDP", requested_port, "192.168.4.22", INTERNAL_PORT, 10, "GUPnP Simple IGD test"); loop = g_main_loop_new (mainctx, FALSE); g_main_loop_run (loop); g_main_loop_unref (loop); gupnp_root_device_set_available (dev, FALSE); g_object_unref (dev); if (mainctx) g_main_context_pop_thread_default (mainctx); g_object_unref (context); }
gboolean fs_rawudp_component_gather_local_candidates (FsRawUdpComponent *self, GError **error) { if (self->priv->gathered) { g_set_error (error, FS_ERROR, FS_ERROR_INVALID_ARGUMENTS, "Call gather local candidates twice on the same component"); return FALSE; } if (!self->priv->udpport) { g_set_error (error, FS_ERROR, FS_ERROR_INVALID_ARGUMENTS, "You can not call gather_local_candidate() after the stream has" " been stopped"); return FALSE; } #ifdef HAVE_GUPNP if (self->priv->upnp_igd && (self->priv->upnp_mapping || self->priv->upnp_discovery)) { guint port; GList *ips; port = fs_rawudp_transmitter_udpport_get_port (self->priv->udpport); ips = nice_interfaces_get_local_ips (FALSE); ips = filter_ips (ips, TRUE, FALSE); if (ips) { gchar *ip = g_list_first (ips)->data; GMainContext *ctx; if (self->priv->upnp_discovery) { FS_RAWUDP_COMPONENT_LOCK (self); self->priv->upnp_signal_id = g_signal_connect (self->priv->upnp_igd, "mapped-external-port", G_CALLBACK (_upnp_mapped_external_port), self); FS_RAWUDP_COMPONENT_UNLOCK (self); } GST_DEBUG ("Doing UPnP Discovery for local ip:%s port:%u", ip, port); gupnp_simple_igd_add_port (GUPNP_SIMPLE_IGD (self->priv->upnp_igd), "UDP", port, ip, port, self->priv->upnp_mapping_timeout, "Farstream Raw UDP transmitter " PACKAGE_VERSION); if (self->priv->upnp_discovery) { FS_RAWUDP_COMPONENT_LOCK (self); self->priv->upnp_discovery_timeout_src = g_timeout_source_new_seconds ( self->priv->upnp_discovery_timeout); g_source_set_callback (self->priv->upnp_discovery_timeout_src, _upnp_discovery_timeout, self, NULL); g_object_get (self->priv->upnp_igd, "main-context", &ctx, NULL); g_source_attach (self->priv->upnp_discovery_timeout_src, ctx); FS_RAWUDP_COMPONENT_UNLOCK (self); } } else { FS_RAWUDP_COMPONENT_LOCK (self); fs_rawudp_component_stop_upnp_discovery_locked (self); FS_RAWUDP_COMPONENT_UNLOCK (self); } /* free list of ips */ g_list_foreach (ips, (GFunc) g_free, NULL); g_list_free (ips); } #endif if (self->priv->stun_ip) return fs_rawudp_component_start_stun (self, error); #ifdef HAVE_GUPNP else if (!self->priv->upnp_signal_id) return fs_rawudp_component_emit_local_candidates (self, error); else return TRUE; #else else return fs_rawudp_component_emit_local_candidates (self, error);