Beispiel #1
0
        // GetCurrentNetworkProfile() -> buffer<nn::nifm::detail::sf::NetworkProfileData, 0x1a, 0x17c>
        public ResultCode GetCurrentNetworkProfile(ServiceCtx context)
        {
            ulong networkProfileDataPosition = context.Request.RecvListBuff[0].Position;

            (IPInterfaceProperties interfaceProperties, UnicastIPAddressInformation unicastAddress) = GetLocalInterface();

            if (interfaceProperties == null || unicastAddress == null)
            {
                return(ResultCode.NoInternetConnection);
            }

            Logger.Info?.Print(LogClass.ServiceNifm, $"Console's local IP is \"{unicastAddress.Address}\".");

            context.Response.PtrBuff[0] = context.Response.PtrBuff[0].WithSize((uint)Unsafe.SizeOf <NetworkProfileData>());

            NetworkProfileData networkProfile = new NetworkProfileData
            {
                Uuid = new UInt128(Guid.NewGuid().ToByteArray())
            };

            networkProfile.IpSettingData.IpAddressSetting = new IpAddressSetting(interfaceProperties, unicastAddress);
            networkProfile.IpSettingData.DnsSetting       = new DnsSetting(interfaceProperties);

            Encoding.ASCII.GetBytes("RyujinxNetwork").CopyTo(networkProfile.Name.ToSpan());

            context.Memory.Write(networkProfileDataPosition, networkProfile);

            return(ResultCode.Success);
        }
        internal static NetworkProfileListResult DeserializeNetworkProfileListResult(JsonElement element)
        {
            Optional <IReadOnlyList <NetworkProfileData> > value = default;
            Optional <string> nextLink = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("value"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <NetworkProfileData> array = new List <NetworkProfileData>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(NetworkProfileData.DeserializeNetworkProfileData(item));
                    }
                    value = array;
                    continue;
                }
                if (property.NameEquals("nextLink"))
                {
                    nextLink = property.Value.GetString();
                    continue;
                }
            }
            return(new NetworkProfileListResult(Optional.ToList(value), nextLink.Value));
        }