private static void GenerateDescriptionFunc(XmlWriter writer, GenerationPosition pos, EndpointConfiguration config, CultureInfo culture)
 {
     if (pos == GenerationPosition.AfterDeviceList)
     {
         writer.WriteElementString("dlna", "X_DLNADOC", "urn:schemas-dlna-org:device-1-0", "DMS-1.50");
     }
 }
Exemple #2
0
    protected void InitializeDiscoveryEndpoints()
    {
      IDictionary<IPAddress, EndpointConfiguration> oldEndpoints = new Dictionary<IPAddress, EndpointConfiguration>();
      foreach (EndpointConfiguration config in _serverData.UPnPEndPoints)
        oldEndpoints.Add(config.EndPointIPAddress, config);
      IList<IPAddress> addresses = NetworkHelper.OrderAddressesByScope(NetworkHelper.GetUPnPEnabledIPAddresses(UPnPConfiguration.IP_ADDRESS_BINDINGS));

      // Add new endpoints
      foreach (IPAddress address in addresses)
      {
        if (oldEndpoints.ContainsKey(address))
          continue;
        AddressFamily family = address.AddressFamily;
        if (family == AddressFamily.InterNetwork && !UPnPConfiguration.USE_IPV4)
          continue;
        if (family == AddressFamily.InterNetworkV6 && !UPnPConfiguration.USE_IPV6)
          continue;

        UPnPConfiguration.LOGGER.Debug("UPnPServer: Initializing IP endpoint '{0}'", NetworkHelper.IPAddrToString(address));
        EndpointConfiguration config = new EndpointConfiguration
          {
            EndPointIPAddress = address,
            DescriptionPathBase = DEFAULT_DESCRIPTION_URL_PREFIX,
            ControlPathBase = DEFAULT_CONTROL_URL_PREFIX,
            EventSubPathBase = DEFAULT_EVENT_SUB_URL_PREFIX,
            HTTPServerPort = family == AddressFamily.InterNetwork ? _serverData.HTTP_PORTv4 : _serverData.HTTP_PORTv6
          };
        GenerateObjectURLs(config);
        config.ConfigId = GenerateConfigId(config);
        _serverData.UPnPEndPoints.Add(config);
        _serverData.SSDPController.StartSSDPEndpoint(config);
        _serverData.GENAController.InitializeGENAEndpoint(config);
      }
      // Remove obsolete endpoints
      foreach (EndpointConfiguration config in new List<EndpointConfiguration>(_serverData.UPnPEndPoints))
        if (!addresses.Contains(config.EndPointIPAddress))
        {
          UPnPConfiguration.LOGGER.Debug("UPnPServer: Removing obsolete IP endpoint IP '{0}'", NetworkHelper.IPAddrToString(config.EndPointIPAddress));
          _serverData.GENAController.CloseGENAEndpoint(config);
          _serverData.SSDPController.CloseSSDPEndpoint(config, false);
          _serverData.UPnPEndPoints.Remove(config);
        }
    }
Exemple #3
0
 protected Int32 GenerateConfigId(EndpointConfiguration config)
 {
   Int64 result = config.RootDeviceDescriptionPathsToRootDevices.Values.Select(
       rootDevice => rootDevice.BuildRootDeviceDescription(
           _serverData, config, CultureInfo.InvariantCulture)).Aggregate<string, long>(
               0, (current, description) => current + HashGenerator.CalculateHash(0, description));
   result = config.SCPDPathsToServices.Values.Select(service => service.BuildSCPDDocument(
       config, _serverData)).Aggregate(result, (current, description) => current + HashGenerator.CalculateHash(0, description));
   result += HashGenerator.CalculateHash(0, NetworkHelper.IPAddrToString(config.EndPointIPAddress));
   result += config.HTTPServerPort;
   result += HashGenerator.CalculateHash(0, config.ControlPathBase + config.DescriptionPathBase + config.EventSubPathBase);
   return (int)result;
 }
Exemple #4
0
 protected void GenerateObjectURLs(EndpointConfiguration config)
 {
   DeviceTreeURLGenerator.GenerateObjectURLs(this, config);
 }
Exemple #5
0
 public CallContext(IHttpRequest request, IHttpClientContext httpContext, EndpointConfiguration endpoint)
 {
   _request = request;
   _httpContext = httpContext;
   _endpoint = endpoint;
 }