1 /*
2 * Copyright (c) 2024, The OpenThread Authors.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * 3. Neither the name of the copyright holder nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #include "fake_platform.hpp"
30
31 #include <assert.h>
32 #include <stdint.h>
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <string.h>
36 #include <sys/time.h>
37
38 #include <openthread/error.h>
39 #include <openthread/instance.h>
40 #include <openthread/tasklet.h>
41 #include <openthread/tcat.h>
42 #include <openthread/platform/ble.h>
43 #include <openthread/platform/diag.h>
44 #include <openthread/platform/dso_transport.h>
45 #include <openthread/platform/entropy.h>
46 #include <openthread/platform/logging.h>
47 #include <openthread/platform/misc.h>
48 #include <openthread/platform/toolchain.h>
49 #include <openthread/platform/trel.h>
50 #include <openthread/platform/udp.h>
51
52 using namespace ot;
53
54 namespace ot {
55
56 FakePlatform *FakePlatform::sPlatform = nullptr;
57
FakePlatform()58 FakePlatform::FakePlatform()
59 {
60 assert(sPlatform == nullptr);
61 sPlatform = this;
62
63 mTransmitFrame.mPsdu = mTransmitBuffer;
64
65 #if OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE
66 #if OPENTHREAD_CONFIG_MULTIPLE_STATIC_INSTANCE_ENABLE
67 mInstance = otInstanceInitMultiple(0);
68 #else
69 {
70 size_t instanceBufferLength = 0;
71 void *instanceBuffer = nullptr;
72
73 otInstanceInit(nullptr, &instanceBufferLength);
74
75 instanceBuffer = malloc(instanceBufferLength);
76 assert(instanceBuffer != nullptr);
77 memset(instanceBuffer, 0, instanceBufferLength);
78
79 mInstance = otInstanceInit(instanceBuffer, &instanceBufferLength);
80 }
81 #endif
82 #else
83 mInstance = otInstanceInitSingle();
84 #endif
85 }
86
~FakePlatform()87 FakePlatform::~FakePlatform()
88 {
89 otInstanceFinalize(mInstance);
90 sPlatform = nullptr;
91 }
92
93 #if OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE
StartMicroAlarm(uint32_t aT0,uint32_t aDt)94 void FakePlatform::StartMicroAlarm(uint32_t aT0, uint32_t aDt)
95 {
96 uint64_t start = mNow;
97 uint32_t now = mNow;
98
99 if (static_cast<int32_t>(aT0 - now) > 0 || static_cast<int32_t>(aT0 - now) + static_cast<int64_t>(aDt) > 0)
100 {
101 start += static_cast<uint64_t>(aDt) + static_cast<int32_t>(aT0 - now);
102 }
103
104 mMicroAlarmStart = start;
105 }
106
StopMicroAlarm()107 void FakePlatform::StopMicroAlarm() { mMicroAlarmStart = kAlarmStop; }
108 #endif
109
StartMilliAlarm(uint32_t aT0,uint32_t aDt)110 void FakePlatform::StartMilliAlarm(uint32_t aT0, uint32_t aDt)
111 {
112 uint64_t start = mNow - (mNow % OT_US_PER_MS);
113 uint32_t now = (mNow / OT_US_PER_MS);
114
115 if (static_cast<int32_t>(aT0 - now) > 0 || static_cast<int32_t>(aT0 - now) + static_cast<int64_t>(aDt) > 0)
116 {
117 start += (static_cast<uint64_t>(aDt) + static_cast<int32_t>(aT0 - now)) * OT_US_PER_MS;
118 }
119
120 mMilliAlarmStart = start;
121 }
122
StopMilliAlarm()123 void FakePlatform::StopMilliAlarm() { mMilliAlarmStart = kAlarmStop; }
124
HandleSchedule()125 template <> void FakePlatform::HandleSchedule<&FakePlatform::mReceiveAtStart>() { mChannel = mReceiveAtChannel; }
126
HandleSchedule()127 template <> void FakePlatform::HandleSchedule<&FakePlatform::mReceiveAtEnd>() { mChannel = 0; }
128
ProcessSchedules(uint64_t & aTimeout)129 void FakePlatform::ProcessSchedules(uint64_t &aTimeout)
130 {
131 uint64_t guard = mNow + aTimeout;
132
133 uint64_t *alarm = &guard;
134 #if OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE
135 if (mMicroAlarmStart < *alarm)
136 {
137 alarm = &mMicroAlarmStart;
138 }
139 #endif
140 if (mMilliAlarmStart < *alarm)
141 {
142 alarm = &mMilliAlarmStart;
143 }
144 if (mReceiveAtStart < *alarm)
145 {
146 alarm = &mReceiveAtStart;
147 }
148 else if (mReceiveAtEnd < *alarm)
149 {
150 alarm = &mReceiveAtEnd;
151 }
152
153 if (mNow < *alarm)
154 {
155 aTimeout -= *alarm - mNow;
156 mNow = *alarm;
157 }
158 *alarm = kAlarmStop;
159
160 if (alarm == &guard)
161 {
162 // nonthing scheduled within this period.
163 }
164 else if (alarm == &mReceiveAtEnd)
165 {
166 FakePlatform::HandleSchedule<&FakePlatform::mReceiveAtEnd>();
167 }
168 else if (alarm == &mReceiveAtStart)
169 {
170 FakePlatform::HandleSchedule<&FakePlatform::mReceiveAtStart>();
171 }
172 else if (alarm == &mMilliAlarmStart)
173 {
174 FakePlatform::HandleSchedule<&FakePlatform::mMilliAlarmStart>();
175 }
176 #if OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE
177 else if (alarm == &mMicroAlarmStart)
178 {
179 FakePlatform::HandleSchedule<&FakePlatform::mMicroAlarmStart>();
180 }
181 #endif
182 }
183
Run(uint64_t aTimeoutInUs)184 uint64_t FakePlatform::Run(uint64_t aTimeoutInUs)
185 {
186 if (otTaskletsArePending(mInstance))
187 {
188 otTaskletsProcess(mInstance);
189 }
190 else
191 {
192 ProcessSchedules(aTimeoutInUs);
193 }
194
195 return aTimeoutInUs;
196 }
197
GoInUs(uint64_t aTimeoutInUs)198 void FakePlatform::GoInUs(uint64_t aTimeoutInUs)
199 {
200 while ((aTimeoutInUs = Run(aTimeoutInUs)) > 0)
201 {
202 // nothing
203 }
204 }
205
Transmit(otRadioFrame * aFrame)206 otError FakePlatform::Transmit(otRadioFrame *aFrame)
207 {
208 otPlatRadioTxStarted(mInstance, aFrame);
209 return OT_ERROR_NONE;
210 }
211
SettingsGet(uint16_t aKey,uint16_t aIndex,uint8_t * aValue,uint16_t * aValueLength) const212 otError FakePlatform::SettingsGet(uint16_t aKey, uint16_t aIndex, uint8_t *aValue, uint16_t *aValueLength) const
213 {
214 auto setting = mSettings.find(aKey);
215
216 if (setting == mSettings.end())
217 {
218 return OT_ERROR_NOT_FOUND;
219 }
220
221 if (aIndex > setting->second.size())
222 {
223 return OT_ERROR_NOT_FOUND;
224 }
225
226 if (aValueLength == nullptr)
227 {
228 return OT_ERROR_NONE;
229 }
230
231 const auto &data = setting->second[aIndex];
232
233 if (aValue == nullptr)
234 {
235 *aValueLength = data.size();
236 return OT_ERROR_NONE;
237 }
238
239 if (*aValueLength >= data.size())
240 {
241 *aValueLength = data.size();
242 }
243
244 memcpy(aValue, &data[0], *aValueLength);
245
246 return OT_ERROR_NONE;
247 }
248
SettingsSet(uint16_t aKey,const uint8_t * aValue,uint16_t aValueLength)249 otError FakePlatform::SettingsSet(uint16_t aKey, const uint8_t *aValue, uint16_t aValueLength)
250 {
251 auto setting = std::vector<uint8_t>(aValue, aValue + aValueLength);
252
253 mSettings[aKey].clear();
254 mSettings[aKey].push_back(setting);
255
256 return OT_ERROR_NONE;
257 }
258
SettingsAdd(uint16_t aKey,const uint8_t * aValue,uint16_t aValueLength)259 otError FakePlatform::SettingsAdd(uint16_t aKey, const uint8_t *aValue, uint16_t aValueLength)
260 {
261 auto setting = std::vector<uint8_t>(aValue, aValue + aValueLength);
262
263 mSettings[aKey].push_back(setting);
264
265 return OT_ERROR_NONE;
266 }
267
SettingsDelete(uint16_t aKey,int aIndex)268 otError FakePlatform::SettingsDelete(uint16_t aKey, int aIndex)
269 {
270 auto setting = mSettings.find(aKey);
271 if (setting == mSettings.end())
272 {
273 return OT_ERROR_NOT_FOUND;
274 }
275
276 if (static_cast<std::size_t>(aIndex) >= setting->second.size())
277 {
278 return OT_ERROR_NOT_FOUND;
279 }
280 setting->second.erase(setting->second.begin() + aIndex);
281 return OT_ERROR_NONE;
282 }
283
SettingsWipe()284 void FakePlatform::SettingsWipe() { mSettings.clear(); }
285
FlashInit()286 void FakePlatform::FlashInit() { memset(mFlash, 0xff, sizeof(mFlash)); }
FlashErase(uint8_t aSwapIndex)287 void FakePlatform::FlashErase(uint8_t aSwapIndex)
288 {
289 uint32_t address;
290
291 assert(aSwapIndex < kFlashSwapNum);
292
293 address = aSwapIndex ? kFlashSwapSize : 0;
294
295 memset(mFlash + address, 0xff, kFlashSwapSize);
296 }
297
FlashRead(uint8_t aSwapIndex,uint32_t aOffset,void * aData,uint32_t aSize) const298 void FakePlatform::FlashRead(uint8_t aSwapIndex, uint32_t aOffset, void *aData, uint32_t aSize) const
299 {
300 uint32_t address;
301
302 assert(aSwapIndex < kFlashSwapNum);
303 assert(aSize <= kFlashSwapSize);
304 assert(aOffset <= (kFlashSwapSize - aSize));
305
306 address = aSwapIndex ? kFlashSwapSize : 0;
307
308 memcpy(aData, mFlash + address + aOffset, aSize);
309 }
310
FlashWrite(uint8_t aSwapIndex,uint32_t aOffset,const void * aData,uint32_t aSize)311 void FakePlatform::FlashWrite(uint8_t aSwapIndex, uint32_t aOffset, const void *aData, uint32_t aSize)
312 {
313 uint32_t address;
314
315 assert(aSwapIndex < kFlashSwapNum);
316 assert(aSize <= kFlashSwapSize);
317 assert(aOffset <= (kFlashSwapSize - aSize));
318
319 address = aSwapIndex ? kFlashSwapSize : 0;
320
321 for (uint32_t index = 0; index < aSize; index++)
322 {
323 mFlash[address + aOffset + index] &= static_cast<const uint8_t *>(aData)[index];
324 }
325 }
326
327 } // namespace ot
328
329 extern "C" {
330
otTaskletsSignalPending(otInstance *)331 void otTaskletsSignalPending(otInstance *) {}
332
otPlatAlarmMilliStop(otInstance *)333 void otPlatAlarmMilliStop(otInstance *) { FakePlatform::CurrentPlatform().StopMilliAlarm(); }
334
otPlatAlarmMilliStartAt(otInstance *,uint32_t aT0,uint32_t aDt)335 void otPlatAlarmMilliStartAt(otInstance *, uint32_t aT0, uint32_t aDt)
336 {
337 FakePlatform::CurrentPlatform().StartMilliAlarm(aT0, aDt);
338 }
339
otPlatAlarmMilliGetNow(void)340 uint32_t otPlatAlarmMilliGetNow(void) { return FakePlatform::CurrentPlatform().GetNow() / OT_US_PER_MS; }
341
342 #if OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE
otPlatAlarmMicroStop(otInstance *)343 void otPlatAlarmMicroStop(otInstance *) { FakePlatform::CurrentPlatform().StopMicroAlarm(); }
otPlatAlarmMicroStartAt(otInstance *,uint32_t aT0,uint32_t aDt)344 void otPlatAlarmMicroStartAt(otInstance *, uint32_t aT0, uint32_t aDt)
345 {
346 FakePlatform::CurrentPlatform().StartMicroAlarm(aT0, aDt);
347 }
348 #endif
349
otPlatTimeGet(void)350 uint64_t otPlatTimeGet(void) { return FakePlatform::CurrentPlatform().GetNow(); }
otPlatTimeGetXtalAccuracy(void)351 uint16_t otPlatTimeGetXtalAccuracy(void) { return 0; }
352
otPlatAlarmMicroGetNow(void)353 uint32_t otPlatAlarmMicroGetNow(void) { return otPlatTimeGet(); }
354
otPlatRadioGetIeeeEui64(otInstance *,uint8_t * aIeeeEui64)355 void otPlatRadioGetIeeeEui64(otInstance *, uint8_t *aIeeeEui64)
356 {
357 uint64_t eui64 = FakePlatform::CurrentPlatform().GetEui64();
358 memcpy(aIeeeEui64, &eui64, sizeof(eui64));
359 }
360
otPlatRadioSetPanId(otInstance *,uint16_t)361 void otPlatRadioSetPanId(otInstance *, uint16_t) {}
362
otPlatRadioSetExtendedAddress(otInstance *,const otExtAddress *)363 void otPlatRadioSetExtendedAddress(otInstance *, const otExtAddress *) {}
364
otPlatRadioSetShortAddress(otInstance *,uint16_t)365 void otPlatRadioSetShortAddress(otInstance *, uint16_t) {}
366
otPlatRadioSetPromiscuous(otInstance *,bool)367 void otPlatRadioSetPromiscuous(otInstance *, bool) {}
368
otPlatRadioSetRxOnWhenIdle(otInstance *,bool)369 void otPlatRadioSetRxOnWhenIdle(otInstance *, bool) {}
370
otPlatRadioIsEnabled(otInstance *)371 bool otPlatRadioIsEnabled(otInstance *) { return true; }
372
otPlatRadioEnable(otInstance *)373 otError otPlatRadioEnable(otInstance *) { return OT_ERROR_NONE; }
374
otPlatRadioDisable(otInstance *)375 otError otPlatRadioDisable(otInstance *) { return OT_ERROR_NONE; }
376
otPlatRadioSleep(otInstance *)377 otError otPlatRadioSleep(otInstance *) { return OT_ERROR_NONE; }
378
otPlatRadioReceive(otInstance *,uint8_t aChannel)379 otError otPlatRadioReceive(otInstance *, uint8_t aChannel) { return FakePlatform::CurrentPlatform().Receive(aChannel); }
380
otPlatRadioReceiveAt(otInstance *,uint8_t aChannel,uint32_t aStart,uint32_t aDuration)381 otError otPlatRadioReceiveAt(otInstance *, uint8_t aChannel, uint32_t aStart, uint32_t aDuration)
382 {
383 return FakePlatform::CurrentPlatform().ReceiveAt(aChannel, aStart, aDuration);
384 }
385
otPlatRadioTransmit(otInstance *,otRadioFrame * aFrame)386 otError otPlatRadioTransmit(otInstance *, otRadioFrame *aFrame)
387 {
388 return FakePlatform::CurrentPlatform().Transmit(aFrame);
389 }
390
otPlatRadioGetTransmitBuffer(otInstance *)391 otRadioFrame *otPlatRadioGetTransmitBuffer(otInstance *) { return FakePlatform::CurrentPlatform().GetTransmitBuffer(); }
392
otPlatRadioGetRssi(otInstance *)393 int8_t otPlatRadioGetRssi(otInstance *) { return 0; }
394
otPlatRadioGetCaps(otInstance *)395 otRadioCaps otPlatRadioGetCaps(otInstance *) { return OT_RADIO_CAPS_NONE; }
396
otPlatRadioGetPromiscuous(otInstance *)397 bool otPlatRadioGetPromiscuous(otInstance *) { return false; }
398
otPlatRadioEnableSrcMatch(otInstance *,bool)399 void otPlatRadioEnableSrcMatch(otInstance *, bool) {}
400
otPlatRadioAddSrcMatchShortEntry(otInstance *,uint16_t)401 otError otPlatRadioAddSrcMatchShortEntry(otInstance *, uint16_t) { return OT_ERROR_NONE; }
402
otPlatRadioAddSrcMatchExtEntry(otInstance *,const otExtAddress *)403 otError otPlatRadioAddSrcMatchExtEntry(otInstance *, const otExtAddress *) { return OT_ERROR_NONE; }
404
otPlatRadioClearSrcMatchShortEntry(otInstance *,uint16_t)405 otError otPlatRadioClearSrcMatchShortEntry(otInstance *, uint16_t) { return OT_ERROR_NONE; }
406
otPlatRadioClearSrcMatchExtEntry(otInstance *,const otExtAddress *)407 otError otPlatRadioClearSrcMatchExtEntry(otInstance *, const otExtAddress *) { return OT_ERROR_NONE; }
408
otPlatRadioClearSrcMatchShortEntries(otInstance *)409 void otPlatRadioClearSrcMatchShortEntries(otInstance *) {}
410
otPlatRadioClearSrcMatchExtEntries(otInstance *)411 void otPlatRadioClearSrcMatchExtEntries(otInstance *) {}
412
otPlatRadioEnergyScan(otInstance *,uint8_t,uint16_t)413 otError otPlatRadioEnergyScan(otInstance *, uint8_t, uint16_t) { return OT_ERROR_NOT_IMPLEMENTED; }
414
otPlatRadioSetTransmitPower(otInstance *,int8_t)415 otError otPlatRadioSetTransmitPower(otInstance *, int8_t) { return OT_ERROR_NOT_IMPLEMENTED; }
416
otPlatRadioGetReceiveSensitivity(otInstance *)417 int8_t otPlatRadioGetReceiveSensitivity(otInstance *) { return -100; }
418
otPlatRadioSetCcaEnergyDetectThreshold(otInstance *,int8_t)419 otError otPlatRadioSetCcaEnergyDetectThreshold(otInstance *, int8_t) { return OT_ERROR_NONE; }
420
otPlatRadioGetCcaEnergyDetectThreshold(otInstance *,int8_t *)421 otError otPlatRadioGetCcaEnergyDetectThreshold(otInstance *, int8_t *) { return OT_ERROR_NONE; }
422
otPlatRadioGetCoexMetrics(otInstance *,otRadioCoexMetrics *)423 otError otPlatRadioGetCoexMetrics(otInstance *, otRadioCoexMetrics *) { return OT_ERROR_NONE; }
424
otPlatRadioGetTransmitPower(otInstance *,int8_t *)425 otError otPlatRadioGetTransmitPower(otInstance *, int8_t *) { return OT_ERROR_NONE; }
426
otPlatRadioIsCoexEnabled(otInstance *)427 bool otPlatRadioIsCoexEnabled(otInstance *) { return true; }
428
otPlatRadioSetCoexEnabled(otInstance *,bool)429 otError otPlatRadioSetCoexEnabled(otInstance *, bool) { return OT_ERROR_NOT_IMPLEMENTED; }
430
otPlatRadioConfigureEnhAckProbing(otInstance *,otLinkMetrics,otShortAddress,const otExtAddress *)431 otError otPlatRadioConfigureEnhAckProbing(otInstance *, otLinkMetrics, otShortAddress, const otExtAddress *)
432 {
433 return OT_ERROR_NOT_IMPLEMENTED;
434 }
435
436 // Add WEAK here because in some unit test there is an implementation for `otPlatRadioSetChannelTargetPower`
otPlatRadioSetChannelTargetPower(otInstance *,uint8_t,int16_t)437 OT_TOOL_WEAK otError otPlatRadioSetChannelTargetPower(otInstance *, uint8_t, int16_t) { return OT_ERROR_NONE; }
438
otPlatReset(otInstance *)439 void otPlatReset(otInstance *) {}
440
otPlatGetResetReason(otInstance *)441 otPlatResetReason otPlatGetResetReason(otInstance *) { return OT_PLAT_RESET_REASON_POWER_ON; }
442
otPlatWakeHost(void)443 void otPlatWakeHost(void) {}
444
otPlatEntropyGet(uint8_t * aOutput,uint16_t aOutputLength)445 otError otPlatEntropyGet(uint8_t *aOutput, uint16_t aOutputLength)
446 {
447 otError error = OT_ERROR_NONE;
448
449 assert(aOutput != nullptr);
450
451 for (uint16_t length = 0; length < aOutputLength; length++)
452 {
453 aOutput[length] = static_cast<uint8_t>(rand());
454 }
455
456 return error;
457 }
458
otPlatDiagSetOutputCallback(otInstance *,otPlatDiagOutputCallback,void *)459 void otPlatDiagSetOutputCallback(otInstance *, otPlatDiagOutputCallback, void *) {}
460
otPlatDiagModeSet(bool)461 void otPlatDiagModeSet(bool) {}
462
otPlatDiagModeGet()463 bool otPlatDiagModeGet() { return false; }
464
otPlatDiagChannelSet(uint8_t)465 void otPlatDiagChannelSet(uint8_t) {}
466
otPlatDiagTxPowerSet(int8_t)467 void otPlatDiagTxPowerSet(int8_t) {}
468
otPlatDiagRadioReceived(otInstance *,otRadioFrame *,otError)469 void otPlatDiagRadioReceived(otInstance *, otRadioFrame *, otError) {}
470
otPlatDiagAlarmCallback(otInstance *)471 void otPlatDiagAlarmCallback(otInstance *) {}
472
otPlatLog(otLogLevel,otLogRegion,const char *,...)473 OT_TOOL_WEAK void otPlatLog(otLogLevel, otLogRegion, const char *, ...) {}
474
otPlatCAlloc(size_t aNum,size_t aSize)475 void *otPlatCAlloc(size_t aNum, size_t aSize) { return calloc(aNum, aSize); }
476
otPlatFree(void * aPtr)477 void otPlatFree(void *aPtr) { free(aPtr); }
478
otPlatInfraIfHasAddress(uint32_t,const otIp6Address *)479 bool otPlatInfraIfHasAddress(uint32_t, const otIp6Address *) { return false; }
480
otPlatInfraIfSendIcmp6Nd(uint32_t,const otIp6Address *,const uint8_t *,uint16_t)481 otError otPlatInfraIfSendIcmp6Nd(uint32_t, const otIp6Address *, const uint8_t *, uint16_t) { return OT_ERROR_FAILED; }
482
otPlatInfraIfDiscoverNat64Prefix(uint32_t)483 otError otPlatInfraIfDiscoverNat64Prefix(uint32_t) { return OT_ERROR_FAILED; }
484
otPlatDsoEnableListening(otInstance *,bool)485 void otPlatDsoEnableListening(otInstance *, bool) {}
486
otPlatDsoConnect(otPlatDsoConnection *,const otSockAddr *)487 void otPlatDsoConnect(otPlatDsoConnection *, const otSockAddr *) {}
488
otPlatDsoSend(otPlatDsoConnection *,otMessage *)489 void otPlatDsoSend(otPlatDsoConnection *, otMessage *) {}
490
otPlatDsoDisconnect(otPlatDsoConnection *,otPlatDsoDisconnectMode)491 void otPlatDsoDisconnect(otPlatDsoConnection *, otPlatDsoDisconnectMode) {}
492
otPlatBleEnable(otInstance *)493 otError otPlatBleEnable(otInstance *) { return OT_ERROR_NONE; }
494
otPlatBleDisable(otInstance *)495 otError otPlatBleDisable(otInstance *) { return OT_ERROR_NONE; }
496
otPlatBleGetAdvertisementBuffer(otInstance *,uint8_t **)497 otError otPlatBleGetAdvertisementBuffer(otInstance *, uint8_t **) { return OT_ERROR_NO_BUFS; }
498
otPlatBleGapAdvStart(otInstance *,uint16_t)499 otError otPlatBleGapAdvStart(otInstance *, uint16_t) { return OT_ERROR_NONE; }
500
otPlatBleGapAdvStop(otInstance *)501 otError otPlatBleGapAdvStop(otInstance *) { return OT_ERROR_NONE; }
502
otPlatBleGapDisconnect(otInstance *)503 otError otPlatBleGapDisconnect(otInstance *) { return OT_ERROR_NONE; }
504
otPlatBleGattMtuGet(otInstance *,uint16_t *)505 otError otPlatBleGattMtuGet(otInstance *, uint16_t *) { return OT_ERROR_NONE; }
506
otPlatBleGattServerIndicate(otInstance *,uint16_t,const otBleRadioPacket *)507 otError otPlatBleGattServerIndicate(otInstance *, uint16_t, const otBleRadioPacket *) { return OT_ERROR_NONE; }
508
otPlatBleGetLinkCapabilities(otInstance *,otBleLinkCapabilities *)509 void otPlatBleGetLinkCapabilities(otInstance *, otBleLinkCapabilities *) {}
510
otPlatBleSupportsMultiRadio(otInstance *)511 bool otPlatBleSupportsMultiRadio(otInstance *) { return false; }
512
otPlatBleGapAdvSetData(otInstance *,uint8_t *,uint16_t)513 otError otPlatBleGapAdvSetData(otInstance *, uint8_t *, uint16_t) { return OT_ERROR_NONE; }
514
otPlatSettingsInit(otInstance *,const uint16_t *,uint16_t)515 void otPlatSettingsInit(otInstance *, const uint16_t *, uint16_t) {}
516
otPlatSettingsDeinit(otInstance *)517 void otPlatSettingsDeinit(otInstance *) {}
518
otPlatSettingsGet(otInstance *,uint16_t aKey,int aIndex,uint8_t * aValue,uint16_t * aValueLength)519 otError otPlatSettingsGet(otInstance *, uint16_t aKey, int aIndex, uint8_t *aValue, uint16_t *aValueLength)
520 {
521 return FakePlatform::CurrentPlatform().SettingsGet(aKey, aIndex, aValue, aValueLength);
522 }
523
otPlatSettingsSet(otInstance *,uint16_t aKey,const uint8_t * aValue,uint16_t aValueLength)524 otError otPlatSettingsSet(otInstance *, uint16_t aKey, const uint8_t *aValue, uint16_t aValueLength)
525 {
526 return FakePlatform::CurrentPlatform().SettingsSet(aKey, aValue, aValueLength);
527 }
528
otPlatSettingsAdd(otInstance *,uint16_t aKey,const uint8_t * aValue,uint16_t aValueLength)529 otError otPlatSettingsAdd(otInstance *, uint16_t aKey, const uint8_t *aValue, uint16_t aValueLength)
530 {
531 return FakePlatform::CurrentPlatform().SettingsAdd(aKey, aValue, aValueLength);
532 }
533
otPlatSettingsDelete(otInstance *,uint16_t aKey,int aIndex)534 otError otPlatSettingsDelete(otInstance *, uint16_t aKey, int aIndex)
535 {
536 return FakePlatform::CurrentPlatform().SettingsDelete(aKey, aIndex);
537 }
538
otPlatSettingsWipe(otInstance *)539 void otPlatSettingsWipe(otInstance *) { FakePlatform::CurrentPlatform().SettingsWipe(); }
540
otPlatFlashInit(otInstance *)541 void otPlatFlashInit(otInstance *) { return FakePlatform::CurrentPlatform().FlashInit(); }
542
otPlatFlashGetSwapSize(otInstance *)543 uint32_t otPlatFlashGetSwapSize(otInstance *) { return FakePlatform::CurrentPlatform().FlashGetSwapSize(); }
544
otPlatFlashErase(otInstance *,uint8_t aSwapIndex)545 void otPlatFlashErase(otInstance *, uint8_t aSwapIndex) { FakePlatform::CurrentPlatform().FlashErase(aSwapIndex); }
546
otPlatFlashRead(otInstance *,uint8_t aSwapIndex,uint32_t aOffset,void * aData,uint32_t aSize)547 void otPlatFlashRead(otInstance *, uint8_t aSwapIndex, uint32_t aOffset, void *aData, uint32_t aSize)
548 {
549 FakePlatform::CurrentPlatform().FlashRead(aSwapIndex, aOffset, aData, aSize);
550 }
551
otPlatFlashWrite(otInstance *,uint8_t aSwapIndex,uint32_t aOffset,const void * aData,uint32_t aSize)552 void otPlatFlashWrite(otInstance *, uint8_t aSwapIndex, uint32_t aOffset, const void *aData, uint32_t aSize)
553 {
554 FakePlatform::CurrentPlatform().FlashWrite(aSwapIndex, aOffset, aData, aSize);
555 }
556
otPlatTrelEnable(otInstance *,uint16_t *)557 void otPlatTrelEnable(otInstance *, uint16_t *) {}
otPlatTrelDisable(otInstance *)558 void otPlatTrelDisable(otInstance *) {}
otPlatTrelNotifyPeerSocketAddressDifference(otInstance *,const otSockAddr *,const otSockAddr *)559 void otPlatTrelNotifyPeerSocketAddressDifference(otInstance *, const otSockAddr *, const otSockAddr *) {}
otPlatTrelRegisterService(otInstance *,uint16_t,const uint8_t *,uint8_t)560 void otPlatTrelRegisterService(otInstance *, uint16_t, const uint8_t *, uint8_t) {}
otPlatTrelSend(otInstance *,const uint8_t *,uint16_t,const otSockAddr *)561 void otPlatTrelSend(otInstance *, const uint8_t *, uint16_t, const otSockAddr *) {}
otPlatTrelGetCounters(otInstance *)562 const otPlatTrelCounters *otPlatTrelGetCounters(otInstance *) { return nullptr; }
otPlatTrelResetCounters(otInstance *)563 void otPlatTrelResetCounters(otInstance *) {}
564
otPlatUdpSocket(otUdpSocket *)565 otError otPlatUdpSocket(otUdpSocket *) { return OT_ERROR_NOT_IMPLEMENTED; }
otPlatUdpClose(otUdpSocket *)566 otError otPlatUdpClose(otUdpSocket *) { return OT_ERROR_NOT_IMPLEMENTED; }
otPlatUdpBind(otUdpSocket *)567 otError otPlatUdpBind(otUdpSocket *) { return OT_ERROR_NOT_IMPLEMENTED; }
otPlatUdpBindToNetif(otUdpSocket *,otNetifIdentifier)568 otError otPlatUdpBindToNetif(otUdpSocket *, otNetifIdentifier) { return OT_ERROR_NOT_IMPLEMENTED; }
otPlatUdpConnect(otUdpSocket *)569 otError otPlatUdpConnect(otUdpSocket *) { return OT_ERROR_NOT_IMPLEMENTED; }
otPlatUdpSend(otUdpSocket *,otMessage *,const otMessageInfo *)570 otError otPlatUdpSend(otUdpSocket *, otMessage *, const otMessageInfo *) { return OT_ERROR_NOT_IMPLEMENTED; }
otPlatUdpJoinMulticastGroup(otUdpSocket *,otNetifIdentifier,const otIp6Address *)571 otError otPlatUdpJoinMulticastGroup(otUdpSocket *, otNetifIdentifier, const otIp6Address *)
572 {
573 return OT_ERROR_NOT_IMPLEMENTED;
574 }
otPlatUdpLeaveMulticastGroup(otUdpSocket *,otNetifIdentifier,const otIp6Address *)575 otError otPlatUdpLeaveMulticastGroup(otUdpSocket *, otNetifIdentifier, const otIp6Address *)
576 {
577 return OT_ERROR_NOT_IMPLEMENTED;
578 }
otPlatAssertFail(const char *,int)579 void otPlatAssertFail(const char *, int) {}
580 } // extern "C"
581