Implement Bluetooth, Btm, Hid and Nsd services and calls. (#761)
- Implement `btdrv` service (IBluetoothDriver).
Implement call `InitializeBluetoothLe` for initialize events of `bt` service according to RE.
- Implement `bt` service (IBluetoothUser).
Implement call `RegisterBleEvent` according to RE.
- Add a placeholder for the `btm` service (close #750).
- Implement `btm:u` service (IBtmUser) (close #751).
Implement call `GetCore` according to RE (close #752).
- Implement `IBtmUserCore` and calls `AcquireBleScanEvent`, `AcquireBleConnectionEvent`, `AcquireBleServiceDiscoveryEvent` and `AcquireBleMtuConfigEvent` according to RE.
- Implement `SetPalmaBoostMode` in `IHidServer` according to RE.
- Add stub for `SetIsPalmaAllConnectable` in `IHidServer` because we will not support Palma devices soon.
- Implement `nsd:a` and `nsd:u` service (IManager) (close #755).
Implement call `ResolveEx` according to RE (close #756).
Implement calls `GetSettingName`, `GetEnvironmentIdentifier`, `GetDeviceId`, `DeleteSettings`, `Resolve`, `ReadSaveDataFromFsForTest`, `WriteSaveDataToFsForTest` and `DeleteSaveDataOfFsForTest` according to RE.
2019-09-06 16:58:50 +02:00
|
|
|
|
using System.Text;
|
|
|
|
|
|
2019-09-19 02:45:11 +02:00
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd.Manager
|
Implement Bluetooth, Btm, Hid and Nsd services and calls. (#761)
- Implement `btdrv` service (IBluetoothDriver).
Implement call `InitializeBluetoothLe` for initialize events of `bt` service according to RE.
- Implement `bt` service (IBluetoothUser).
Implement call `RegisterBleEvent` according to RE.
- Add a placeholder for the `btm` service (close #750).
- Implement `btm:u` service (IBtmUser) (close #751).
Implement call `GetCore` according to RE (close #752).
- Implement `IBtmUserCore` and calls `AcquireBleScanEvent`, `AcquireBleConnectionEvent`, `AcquireBleServiceDiscoveryEvent` and `AcquireBleMtuConfigEvent` according to RE.
- Implement `SetPalmaBoostMode` in `IHidServer` according to RE.
- Add stub for `SetIsPalmaAllConnectable` in `IHidServer` because we will not support Palma devices soon.
- Implement `nsd:a` and `nsd:u` service (IManager) (close #755).
Implement call `ResolveEx` according to RE (close #756).
Implement calls `GetSettingName`, `GetEnvironmentIdentifier`, `GetDeviceId`, `DeleteSettings`, `Resolve`, `ReadSaveDataFromFsForTest`, `WriteSaveDataToFsForTest` and `DeleteSaveDataOfFsForTest` according to RE.
2019-09-06 16:58:50 +02:00
|
|
|
|
{
|
|
|
|
|
class FqdnResolver
|
|
|
|
|
{
|
|
|
|
|
private const string _dummyAddress = "unknown.dummy.nintendo.net";
|
|
|
|
|
|
|
|
|
|
private NsdSettings _nsdSettings;
|
|
|
|
|
|
|
|
|
|
public FqdnResolver(NsdSettings nsdSettings)
|
|
|
|
|
{
|
|
|
|
|
_nsdSettings = nsdSettings;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-05 23:16:51 +02:00
|
|
|
|
public ResultCode GetEnvironmentIdentifier(out string identifier)
|
Implement Bluetooth, Btm, Hid and Nsd services and calls. (#761)
- Implement `btdrv` service (IBluetoothDriver).
Implement call `InitializeBluetoothLe` for initialize events of `bt` service according to RE.
- Implement `bt` service (IBluetoothUser).
Implement call `RegisterBleEvent` according to RE.
- Add a placeholder for the `btm` service (close #750).
- Implement `btm:u` service (IBtmUser) (close #751).
Implement call `GetCore` according to RE (close #752).
- Implement `IBtmUserCore` and calls `AcquireBleScanEvent`, `AcquireBleConnectionEvent`, `AcquireBleServiceDiscoveryEvent` and `AcquireBleMtuConfigEvent` according to RE.
- Implement `SetPalmaBoostMode` in `IHidServer` according to RE.
- Add stub for `SetIsPalmaAllConnectable` in `IHidServer` because we will not support Palma devices soon.
- Implement `nsd:a` and `nsd:u` service (IManager) (close #755).
Implement call `ResolveEx` according to RE (close #756).
Implement calls `GetSettingName`, `GetEnvironmentIdentifier`, `GetDeviceId`, `DeleteSettings`, `Resolve`, `ReadSaveDataFromFsForTest`, `WriteSaveDataToFsForTest` and `DeleteSaveDataOfFsForTest` according to RE.
2019-09-06 16:58:50 +02:00
|
|
|
|
{
|
|
|
|
|
if (_nsdSettings.TestMode)
|
|
|
|
|
{
|
2021-05-05 23:16:51 +02:00
|
|
|
|
identifier = "err";
|
Implement Bluetooth, Btm, Hid and Nsd services and calls. (#761)
- Implement `btdrv` service (IBluetoothDriver).
Implement call `InitializeBluetoothLe` for initialize events of `bt` service according to RE.
- Implement `bt` service (IBluetoothUser).
Implement call `RegisterBleEvent` according to RE.
- Add a placeholder for the `btm` service (close #750).
- Implement `btm:u` service (IBtmUser) (close #751).
Implement call `GetCore` according to RE (close #752).
- Implement `IBtmUserCore` and calls `AcquireBleScanEvent`, `AcquireBleConnectionEvent`, `AcquireBleServiceDiscoveryEvent` and `AcquireBleMtuConfigEvent` according to RE.
- Implement `SetPalmaBoostMode` in `IHidServer` according to RE.
- Add stub for `SetIsPalmaAllConnectable` in `IHidServer` because we will not support Palma devices soon.
- Implement `nsd:a` and `nsd:u` service (IManager) (close #755).
Implement call `ResolveEx` according to RE (close #756).
Implement calls `GetSettingName`, `GetEnvironmentIdentifier`, `GetDeviceId`, `DeleteSettings`, `Resolve`, `ReadSaveDataFromFsForTest`, `WriteSaveDataToFsForTest` and `DeleteSaveDataOfFsForTest` according to RE.
2019-09-06 16:58:50 +02:00
|
|
|
|
|
2021-05-05 23:16:51 +02:00
|
|
|
|
return ResultCode.InvalidSettingsValue;
|
Implement Bluetooth, Btm, Hid and Nsd services and calls. (#761)
- Implement `btdrv` service (IBluetoothDriver).
Implement call `InitializeBluetoothLe` for initialize events of `bt` service according to RE.
- Implement `bt` service (IBluetoothUser).
Implement call `RegisterBleEvent` according to RE.
- Add a placeholder for the `btm` service (close #750).
- Implement `btm:u` service (IBtmUser) (close #751).
Implement call `GetCore` according to RE (close #752).
- Implement `IBtmUserCore` and calls `AcquireBleScanEvent`, `AcquireBleConnectionEvent`, `AcquireBleServiceDiscoveryEvent` and `AcquireBleMtuConfigEvent` according to RE.
- Implement `SetPalmaBoostMode` in `IHidServer` according to RE.
- Add stub for `SetIsPalmaAllConnectable` in `IHidServer` because we will not support Palma devices soon.
- Implement `nsd:a` and `nsd:u` service (IManager) (close #755).
Implement call `ResolveEx` according to RE (close #756).
Implement calls `GetSettingName`, `GetEnvironmentIdentifier`, `GetDeviceId`, `DeleteSettings`, `Resolve`, `ReadSaveDataFromFsForTest`, `WriteSaveDataToFsForTest` and `DeleteSaveDataOfFsForTest` according to RE.
2019-09-06 16:58:50 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
identifier = _nsdSettings.Environment;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ResultCode Resolve(ServiceCtx context, string address, out string resolvedAddress)
|
|
|
|
|
{
|
2021-05-05 23:16:51 +02:00
|
|
|
|
if (address == "api.sect.srv.nintendo.net" ||
|
|
|
|
|
address == "ctest.cdn.nintendo.net" ||
|
|
|
|
|
address == "ctest.cdn.n.nintendoswitch.cn" ||
|
|
|
|
|
address == "unknown.dummy.nintendo.net")
|
|
|
|
|
{
|
|
|
|
|
resolvedAddress = address;
|
|
|
|
|
}
|
|
|
|
|
else
|
Implement Bluetooth, Btm, Hid and Nsd services and calls. (#761)
- Implement `btdrv` service (IBluetoothDriver).
Implement call `InitializeBluetoothLe` for initialize events of `bt` service according to RE.
- Implement `bt` service (IBluetoothUser).
Implement call `RegisterBleEvent` according to RE.
- Add a placeholder for the `btm` service (close #750).
- Implement `btm:u` service (IBtmUser) (close #751).
Implement call `GetCore` according to RE (close #752).
- Implement `IBtmUserCore` and calls `AcquireBleScanEvent`, `AcquireBleConnectionEvent`, `AcquireBleServiceDiscoveryEvent` and `AcquireBleMtuConfigEvent` according to RE.
- Implement `SetPalmaBoostMode` in `IHidServer` according to RE.
- Add stub for `SetIsPalmaAllConnectable` in `IHidServer` because we will not support Palma devices soon.
- Implement `nsd:a` and `nsd:u` service (IManager) (close #755).
Implement call `ResolveEx` according to RE (close #756).
Implement calls `GetSettingName`, `GetEnvironmentIdentifier`, `GetDeviceId`, `DeleteSettings`, `Resolve`, `ReadSaveDataFromFsForTest`, `WriteSaveDataToFsForTest` and `DeleteSaveDataOfFsForTest` according to RE.
2019-09-06 16:58:50 +02:00
|
|
|
|
{
|
|
|
|
|
// TODO: Load Environment from the savedata.
|
|
|
|
|
address = address.Replace("%", _nsdSettings.Environment);
|
|
|
|
|
|
|
|
|
|
resolvedAddress = "";
|
|
|
|
|
|
|
|
|
|
if (_nsdSettings == null)
|
|
|
|
|
{
|
|
|
|
|
return ResultCode.SettingsNotInitialized;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!_nsdSettings.Initialized)
|
|
|
|
|
{
|
|
|
|
|
return ResultCode.SettingsNotLoaded;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-13 03:04:18 +02:00
|
|
|
|
resolvedAddress = address switch
|
Implement Bluetooth, Btm, Hid and Nsd services and calls. (#761)
- Implement `btdrv` service (IBluetoothDriver).
Implement call `InitializeBluetoothLe` for initialize events of `bt` service according to RE.
- Implement `bt` service (IBluetoothUser).
Implement call `RegisterBleEvent` according to RE.
- Add a placeholder for the `btm` service (close #750).
- Implement `btm:u` service (IBtmUser) (close #751).
Implement call `GetCore` according to RE (close #752).
- Implement `IBtmUserCore` and calls `AcquireBleScanEvent`, `AcquireBleConnectionEvent`, `AcquireBleServiceDiscoveryEvent` and `AcquireBleMtuConfigEvent` according to RE.
- Implement `SetPalmaBoostMode` in `IHidServer` according to RE.
- Add stub for `SetIsPalmaAllConnectable` in `IHidServer` because we will not support Palma devices soon.
- Implement `nsd:a` and `nsd:u` service (IManager) (close #755).
Implement call `ResolveEx` according to RE (close #756).
Implement calls `GetSettingName`, `GetEnvironmentIdentifier`, `GetDeviceId`, `DeleteSettings`, `Resolve`, `ReadSaveDataFromFsForTest`, `WriteSaveDataToFsForTest` and `DeleteSaveDataOfFsForTest` according to RE.
2019-09-06 16:58:50 +02:00
|
|
|
|
{
|
2021-04-13 03:04:18 +02:00
|
|
|
|
"e97b8a9d672e4ce4845ec6947cd66ef6-sb-api.accounts.nintendo.com" => "e97b8a9d672e4ce4845ec6947cd66ef6-sb.baas.nintendo.com", // dp1 environment
|
|
|
|
|
"api.accounts.nintendo.com" => "e0d67c509fb203858ebcb2fe3f88c2aa.baas.nintendo.com", // dp1 environment
|
|
|
|
|
"e97b8a9d672e4ce4845ec6947cd66ef6-sb.accounts.nintendo.com" => "e97b8a9d672e4ce4845ec6947cd66ef6-sb.baas.nintendo.com", // lp1 environment
|
|
|
|
|
"accounts.nintendo.com" => "e0d67c509fb203858ebcb2fe3f88c2aa.baas.nintendo.com", // lp1 environment
|
Implement Bluetooth, Btm, Hid and Nsd services and calls. (#761)
- Implement `btdrv` service (IBluetoothDriver).
Implement call `InitializeBluetoothLe` for initialize events of `bt` service according to RE.
- Implement `bt` service (IBluetoothUser).
Implement call `RegisterBleEvent` according to RE.
- Add a placeholder for the `btm` service (close #750).
- Implement `btm:u` service (IBtmUser) (close #751).
Implement call `GetCore` according to RE (close #752).
- Implement `IBtmUserCore` and calls `AcquireBleScanEvent`, `AcquireBleConnectionEvent`, `AcquireBleServiceDiscoveryEvent` and `AcquireBleMtuConfigEvent` according to RE.
- Implement `SetPalmaBoostMode` in `IHidServer` according to RE.
- Add stub for `SetIsPalmaAllConnectable` in `IHidServer` because we will not support Palma devices soon.
- Implement `nsd:a` and `nsd:u` service (IManager) (close #755).
Implement call `ResolveEx` according to RE (close #756).
Implement calls `GetSettingName`, `GetEnvironmentIdentifier`, `GetDeviceId`, `DeleteSettings`, `Resolve`, `ReadSaveDataFromFsForTest`, `WriteSaveDataToFsForTest` and `DeleteSaveDataOfFsForTest` according to RE.
2019-09-06 16:58:50 +02:00
|
|
|
|
/*
|
2021-04-13 03:04:18 +02:00
|
|
|
|
// TODO: Determine fields of the struct.
|
|
|
|
|
this + 0xEB8 => this + 0xEB8 + 0x300
|
|
|
|
|
this + 0x2BE8 => this + 0x2BE8 + 0x300
|
Implement Bluetooth, Btm, Hid and Nsd services and calls. (#761)
- Implement `btdrv` service (IBluetoothDriver).
Implement call `InitializeBluetoothLe` for initialize events of `bt` service according to RE.
- Implement `bt` service (IBluetoothUser).
Implement call `RegisterBleEvent` according to RE.
- Add a placeholder for the `btm` service (close #750).
- Implement `btm:u` service (IBtmUser) (close #751).
Implement call `GetCore` according to RE (close #752).
- Implement `IBtmUserCore` and calls `AcquireBleScanEvent`, `AcquireBleConnectionEvent`, `AcquireBleServiceDiscoveryEvent` and `AcquireBleMtuConfigEvent` according to RE.
- Implement `SetPalmaBoostMode` in `IHidServer` according to RE.
- Add stub for `SetIsPalmaAllConnectable` in `IHidServer` because we will not support Palma devices soon.
- Implement `nsd:a` and `nsd:u` service (IManager) (close #755).
Implement call `ResolveEx` according to RE (close #756).
Implement calls `GetSettingName`, `GetEnvironmentIdentifier`, `GetDeviceId`, `DeleteSettings`, `Resolve`, `ReadSaveDataFromFsForTest`, `WriteSaveDataToFsForTest` and `DeleteSaveDataOfFsForTest` according to RE.
2019-09-06 16:58:50 +02:00
|
|
|
|
*/
|
2021-04-13 03:04:18 +02:00
|
|
|
|
_ => address,
|
|
|
|
|
};
|
Implement Bluetooth, Btm, Hid and Nsd services and calls. (#761)
- Implement `btdrv` service (IBluetoothDriver).
Implement call `InitializeBluetoothLe` for initialize events of `bt` service according to RE.
- Implement `bt` service (IBluetoothUser).
Implement call `RegisterBleEvent` according to RE.
- Add a placeholder for the `btm` service (close #750).
- Implement `btm:u` service (IBtmUser) (close #751).
Implement call `GetCore` according to RE (close #752).
- Implement `IBtmUserCore` and calls `AcquireBleScanEvent`, `AcquireBleConnectionEvent`, `AcquireBleServiceDiscoveryEvent` and `AcquireBleMtuConfigEvent` according to RE.
- Implement `SetPalmaBoostMode` in `IHidServer` according to RE.
- Add stub for `SetIsPalmaAllConnectable` in `IHidServer` because we will not support Palma devices soon.
- Implement `nsd:a` and `nsd:u` service (IManager) (close #755).
Implement call `ResolveEx` according to RE (close #756).
Implement calls `GetSettingName`, `GetEnvironmentIdentifier`, `GetDeviceId`, `DeleteSettings`, `Resolve`, `ReadSaveDataFromFsForTest`, `WriteSaveDataToFsForTest` and `DeleteSaveDataOfFsForTest` according to RE.
2019-09-06 16:58:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ResultCode ResolveEx(ServiceCtx context, out ResultCode resultCode, out string resolvedAddress)
|
|
|
|
|
{
|
2021-04-24 12:16:01 +02:00
|
|
|
|
ulong inputPosition = context.Request.SendBuff[0].Position;
|
|
|
|
|
ulong inputSize = context.Request.SendBuff[0].Size;
|
Implement Bluetooth, Btm, Hid and Nsd services and calls. (#761)
- Implement `btdrv` service (IBluetoothDriver).
Implement call `InitializeBluetoothLe` for initialize events of `bt` service according to RE.
- Implement `bt` service (IBluetoothUser).
Implement call `RegisterBleEvent` according to RE.
- Add a placeholder for the `btm` service (close #750).
- Implement `btm:u` service (IBtmUser) (close #751).
Implement call `GetCore` according to RE (close #752).
- Implement `IBtmUserCore` and calls `AcquireBleScanEvent`, `AcquireBleConnectionEvent`, `AcquireBleServiceDiscoveryEvent` and `AcquireBleMtuConfigEvent` according to RE.
- Implement `SetPalmaBoostMode` in `IHidServer` according to RE.
- Add stub for `SetIsPalmaAllConnectable` in `IHidServer` because we will not support Palma devices soon.
- Implement `nsd:a` and `nsd:u` service (IManager) (close #755).
Implement call `ResolveEx` according to RE (close #756).
Implement calls `GetSettingName`, `GetEnvironmentIdentifier`, `GetDeviceId`, `DeleteSettings`, `Resolve`, `ReadSaveDataFromFsForTest`, `WriteSaveDataToFsForTest` and `DeleteSaveDataOfFsForTest` according to RE.
2019-09-06 16:58:50 +02:00
|
|
|
|
|
2020-05-04 00:54:50 +02:00
|
|
|
|
byte[] addressBuffer = new byte[inputSize];
|
|
|
|
|
|
2021-04-24 12:16:01 +02:00
|
|
|
|
context.Memory.Read(inputPosition, addressBuffer);
|
2020-05-04 00:54:50 +02:00
|
|
|
|
|
2021-04-14 14:47:19 +02:00
|
|
|
|
string address = Encoding.UTF8.GetString(addressBuffer).TrimEnd('\0');
|
Implement Bluetooth, Btm, Hid and Nsd services and calls. (#761)
- Implement `btdrv` service (IBluetoothDriver).
Implement call `InitializeBluetoothLe` for initialize events of `bt` service according to RE.
- Implement `bt` service (IBluetoothUser).
Implement call `RegisterBleEvent` according to RE.
- Add a placeholder for the `btm` service (close #750).
- Implement `btm:u` service (IBtmUser) (close #751).
Implement call `GetCore` according to RE (close #752).
- Implement `IBtmUserCore` and calls `AcquireBleScanEvent`, `AcquireBleConnectionEvent`, `AcquireBleServiceDiscoveryEvent` and `AcquireBleMtuConfigEvent` according to RE.
- Implement `SetPalmaBoostMode` in `IHidServer` according to RE.
- Add stub for `SetIsPalmaAllConnectable` in `IHidServer` because we will not support Palma devices soon.
- Implement `nsd:a` and `nsd:u` service (IManager) (close #755).
Implement call `ResolveEx` according to RE (close #756).
Implement calls `GetSettingName`, `GetEnvironmentIdentifier`, `GetDeviceId`, `DeleteSettings`, `Resolve`, `ReadSaveDataFromFsForTest`, `WriteSaveDataToFsForTest` and `DeleteSaveDataOfFsForTest` according to RE.
2019-09-06 16:58:50 +02:00
|
|
|
|
|
|
|
|
|
resultCode = Resolve(context, address, out resolvedAddress);
|
|
|
|
|
|
|
|
|
|
if (resultCode != ResultCode.Success)
|
|
|
|
|
{
|
|
|
|
|
resolvedAddress = _dummyAddress;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_nsdSettings.TestMode)
|
|
|
|
|
{
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return resultCode;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|