1 /*
2  *  Copyright (c) 2017, 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 "openthread-core-config.h"
30 
31 #include "fuzzer_platform.h"
32 
33 #include <string.h>
34 
35 #include <openthread/platform/alarm-micro.h>
36 #include <openthread/platform/alarm-milli.h>
37 #include <openthread/platform/diag.h>
38 #include <openthread/platform/dnssd.h>
39 #include <openthread/platform/entropy.h>
40 #include <openthread/platform/logging.h>
41 #include <openthread/platform/mdns_socket.h>
42 #include <openthread/platform/misc.h>
43 #include <openthread/platform/multipan.h>
44 #include <openthread/platform/radio.h>
45 #include <openthread/platform/settings.h>
46 
47 #include "mac/mac_frame.hpp"
48 
49 using namespace ot;
50 
51 typedef struct AlarmState
52 {
53     uint32_t fire;
54     bool     isRunning;
55 } AlarmState;
56 
57 enum
58 {
59     IEEE802154_ACK_LENGTH = 5,
60 
61     IEEE802154_FRAME_TYPE_ACK = 2 << 0,
62 };
63 
64 static uint32_t     sAlarmNow;
65 static AlarmState   sAlarmMilli;
66 static AlarmState   sAlarmMicro;
67 static uint32_t     sRandomState = 1;
68 static uint8_t      sRadioTransmitPsdu[OT_RADIO_FRAME_MAX_SIZE];
69 static otRadioFrame sRadioTransmitFrame;
70 static uint8_t      sRadioAckPsdu[OT_RADIO_FRAME_MAX_SIZE];
71 static otRadioFrame sRadioAckFrame;
72 static bool         sResetWasRequested = false;
73 static otRadioState sRadioState        = OT_RADIO_STATE_DISABLED;
74 
otMacFrameIsAckRequested(const otRadioFrame * aFrame)75 bool otMacFrameIsAckRequested(const otRadioFrame *aFrame)
76 {
77     return static_cast<const Mac::Frame *>(aFrame)->GetAckRequest();
78 }
79 
otMacFrameGetSequence(const otRadioFrame * aFrame,uint8_t * aSequence)80 otError otMacFrameGetSequence(const otRadioFrame *aFrame, uint8_t *aSequence)
81 {
82     otError error;
83 
84     if (static_cast<const Mac::Frame *>(aFrame)->IsSequencePresent())
85     {
86         *aSequence = static_cast<const Mac::Frame *>(aFrame)->GetSequence();
87         error      = kErrorNone;
88     }
89     else
90     {
91         error = kErrorParse;
92     }
93 
94     return error;
95 }
96 
FuzzerPlatformInit(void)97 void FuzzerPlatformInit(void)
98 {
99     sRandomState = 1;
100     sAlarmNow    = 0;
101     memset(&sAlarmMilli, 0, sizeof(sAlarmMilli));
102     memset(&sAlarmMicro, 0, sizeof(sAlarmMicro));
103 
104     sRadioTransmitFrame.mPsdu = sRadioTransmitPsdu;
105     sRadioAckFrame.mPsdu      = sRadioAckPsdu;
106 }
107 
FuzzerPlatformProcess(otInstance * aInstance)108 void FuzzerPlatformProcess(otInstance *aInstance)
109 {
110     if (sRadioState == OT_RADIO_STATE_TRANSMIT)
111     {
112         sRadioState = OT_RADIO_STATE_RECEIVE;
113 
114         if (otMacFrameIsAckRequested(&sRadioTransmitFrame))
115         {
116             otError error;
117 
118             sRadioAckFrame.mLength  = IEEE802154_ACK_LENGTH;
119             sRadioAckFrame.mPsdu[0] = IEEE802154_FRAME_TYPE_ACK;
120             sRadioAckFrame.mPsdu[1] = 0;
121             error                   = otMacFrameGetSequence(&sRadioTransmitFrame, &sRadioAckFrame.mPsdu[2]);
122             OT_ASSERT(error == OT_ERROR_NONE);
123             sRadioAckFrame.mChannel = sRadioTransmitFrame.mChannel;
124 
125             otPlatRadioTxDone(aInstance, &sRadioTransmitFrame, &sRadioAckFrame, OT_ERROR_NONE);
126         }
127         else
128         {
129             otPlatRadioTxDone(aInstance, &sRadioTransmitFrame, nullptr, OT_ERROR_NONE);
130         }
131     }
132 
133     if (sAlarmMilli.isRunning || sAlarmMicro.isRunning)
134     {
135         uint32_t fire = UINT32_MAX;
136 
137         if (sAlarmMilli.isRunning && fire > sAlarmMilli.fire)
138         {
139             fire = sAlarmMilli.fire;
140         }
141 
142         if (sAlarmMicro.isRunning && fire > sAlarmMicro.fire)
143         {
144             fire = sAlarmMicro.fire;
145         }
146 
147         sAlarmNow = fire;
148 
149         if (sAlarmMilli.isRunning && sAlarmNow >= sAlarmMilli.fire)
150         {
151             sAlarmMilli.isRunning = false;
152             otPlatAlarmMilliFired(aInstance);
153         }
154 
155 #if OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE
156         if (sAlarmMicro.isRunning && sAlarmNow >= sAlarmMicro.fire)
157         {
158             sAlarmMicro.isRunning = false;
159             otPlatAlarmMicroFired(aInstance);
160         }
161 #endif
162     }
163 }
164 
FuzzerPlatformResetWasRequested(void)165 bool FuzzerPlatformResetWasRequested(void) { return sResetWasRequested; }
166 
167 extern "C" {
168 
otPlatAlarmMilliGetNow(void)169 uint32_t otPlatAlarmMilliGetNow(void) { return sAlarmNow / 1000; }
170 
otPlatAlarmMilliStartAt(otInstance * aInstance,uint32_t aT0,uint32_t aDt)171 void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
172 {
173     OT_UNUSED_VARIABLE(aInstance);
174 
175     sAlarmMilli.fire      = (aT0 + aDt) * 1000;
176     sAlarmMilli.isRunning = true;
177 }
178 
otPlatAlarmMilliStop(otInstance * aInstance)179 void otPlatAlarmMilliStop(otInstance *aInstance)
180 {
181     OT_UNUSED_VARIABLE(aInstance);
182 
183     sAlarmMilli.isRunning = false;
184 }
185 
otPlatAlarmMicroGetNow(void)186 uint32_t otPlatAlarmMicroGetNow(void) { return sAlarmNow; }
187 
otPlatAlarmMicroStartAt(otInstance * aInstance,uint32_t aT0,uint32_t aDt)188 void otPlatAlarmMicroStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
189 {
190     OT_UNUSED_VARIABLE(aInstance);
191 
192     sAlarmMicro.fire      = aT0 + aDt;
193     sAlarmMicro.isRunning = true;
194 }
195 
otPlatAlarmMicroStop(otInstance * aInstance)196 void otPlatAlarmMicroStop(otInstance *aInstance)
197 {
198     OT_UNUSED_VARIABLE(aInstance);
199 
200     sAlarmMicro.isRunning = false;
201 }
202 
otDiagIsEnabled(otInstance * aInstance)203 bool otDiagIsEnabled(otInstance *aInstance)
204 {
205     OT_UNUSED_VARIABLE(aInstance);
206 
207     return false;
208 }
209 
otDiagProcessCmd(otInstance * aInstance,uint8_t aArgsLength,char * aArgs[],char * aOutput,size_t aOutputMaxLen)210 otError otDiagProcessCmd(otInstance *aInstance, uint8_t aArgsLength, char *aArgs[], char *aOutput, size_t aOutputMaxLen)
211 {
212     OT_UNUSED_VARIABLE(aInstance);
213     OT_UNUSED_VARIABLE(aArgsLength);
214     OT_UNUSED_VARIABLE(aArgs);
215     OT_UNUSED_VARIABLE(aOutput);
216     OT_UNUSED_VARIABLE(aOutputMaxLen);
217 
218     return OT_ERROR_NOT_IMPLEMENTED;
219 }
220 
otDiagProcessCmdLine(otInstance * aInstance,const char * aString,char * aOutput,size_t aOutputMaxLen)221 otError otDiagProcessCmdLine(otInstance *aInstance, const char *aString, char *aOutput, size_t aOutputMaxLen)
222 {
223     OT_UNUSED_VARIABLE(aInstance);
224     OT_UNUSED_VARIABLE(aString);
225     OT_UNUSED_VARIABLE(aOutput);
226     OT_UNUSED_VARIABLE(aOutputMaxLen);
227 
228     return OT_ERROR_NOT_IMPLEMENTED;
229 }
230 
otPlatReset(otInstance * aInstance)231 void otPlatReset(otInstance *aInstance)
232 {
233     OT_UNUSED_VARIABLE(aInstance);
234 
235     sResetWasRequested = true;
236 }
237 
otPlatGetResetReason(otInstance * aInstance)238 otPlatResetReason otPlatGetResetReason(otInstance *aInstance)
239 {
240     OT_UNUSED_VARIABLE(aInstance);
241     return OT_PLAT_RESET_REASON_POWER_ON;
242 }
243 
otPlatLog(otLogLevel aLogLevel,otLogRegion aLogRegion,const char * aFormat,...)244 OT_TOOL_WEAK void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
245 {
246     OT_UNUSED_VARIABLE(aLogLevel);
247     OT_UNUSED_VARIABLE(aLogRegion);
248     OT_UNUSED_VARIABLE(aFormat);
249 }
250 
otPlatWakeHost(void)251 void otPlatWakeHost(void) {}
252 
otPlatMultipanGetActiveInstance(otInstance **)253 otError otPlatMultipanGetActiveInstance(otInstance **) { return OT_ERROR_NOT_IMPLEMENTED; }
254 
otPlatMultipanSetActiveInstance(otInstance *,bool)255 otError otPlatMultipanSetActiveInstance(otInstance *, bool) { return OT_ERROR_NOT_IMPLEMENTED; }
256 
otPlatRadioGetIeeeEui64(otInstance * aInstance,uint8_t * aIeeeEui64)257 void otPlatRadioGetIeeeEui64(otInstance *aInstance, uint8_t *aIeeeEui64)
258 {
259     OT_UNUSED_VARIABLE(aInstance);
260     OT_UNUSED_VARIABLE(aIeeeEui64);
261 }
262 
otPlatRadioSetPanId(otInstance * aInstance,uint16_t aPanId)263 void otPlatRadioSetPanId(otInstance *aInstance, uint16_t aPanId)
264 {
265     OT_UNUSED_VARIABLE(aInstance);
266     OT_UNUSED_VARIABLE(aPanId);
267 }
268 
otPlatRadioSetExtendedAddress(otInstance * aInstance,const otExtAddress * aExtAddr)269 void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aExtAddr)
270 {
271     OT_UNUSED_VARIABLE(aInstance);
272     OT_UNUSED_VARIABLE(aExtAddr);
273 }
274 
otPlatRadioSetShortAddress(otInstance * aInstance,uint16_t aShortAddress)275 void otPlatRadioSetShortAddress(otInstance *aInstance, uint16_t aShortAddress)
276 {
277     OT_UNUSED_VARIABLE(aInstance);
278     OT_UNUSED_VARIABLE(aShortAddress);
279 }
280 
otPlatRadioSetPromiscuous(otInstance * aInstance,bool aEnabled)281 void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnabled)
282 {
283     OT_UNUSED_VARIABLE(aInstance);
284     OT_UNUSED_VARIABLE(aEnabled);
285 }
286 
otPlatRadioSetRxOnWhenIdle(otInstance * aInstance,bool aEnabled)287 void otPlatRadioSetRxOnWhenIdle(otInstance *aInstance, bool aEnabled)
288 {
289     OT_UNUSED_VARIABLE(aInstance);
290     OT_UNUSED_VARIABLE(aEnabled);
291 }
292 
otPlatRadioIsEnabled(otInstance * aInstance)293 bool otPlatRadioIsEnabled(otInstance *aInstance)
294 {
295     OT_UNUSED_VARIABLE(aInstance);
296     return true;
297 }
298 
otPlatRadioEnable(otInstance * aInstance)299 otError otPlatRadioEnable(otInstance *aInstance)
300 {
301     OT_UNUSED_VARIABLE(aInstance);
302 
303     sRadioState = OT_RADIO_STATE_SLEEP;
304 
305     return OT_ERROR_NONE;
306 }
307 
otPlatRadioDisable(otInstance * aInstance)308 otError otPlatRadioDisable(otInstance *aInstance)
309 {
310     OT_UNUSED_VARIABLE(aInstance);
311 
312     sRadioState = OT_RADIO_STATE_DISABLED;
313 
314     return OT_ERROR_NONE;
315 }
316 
otPlatRadioSleep(otInstance * aInstance)317 otError otPlatRadioSleep(otInstance *aInstance)
318 {
319     OT_UNUSED_VARIABLE(aInstance);
320 
321     sRadioState = OT_RADIO_STATE_SLEEP;
322 
323     return OT_ERROR_NONE;
324 }
325 
otPlatRadioReceive(otInstance * aInstance,uint8_t aChannel)326 otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel)
327 {
328     OT_UNUSED_VARIABLE(aInstance);
329     OT_UNUSED_VARIABLE(aChannel);
330 
331     sRadioState = OT_RADIO_STATE_RECEIVE;
332 
333     return OT_ERROR_NONE;
334 }
335 
otPlatRadioTransmit(otInstance * aInstance,otRadioFrame * aFrame)336 otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
337 {
338     sRadioState = OT_RADIO_STATE_TRANSMIT;
339 
340     otPlatRadioTxStarted(aInstance, aFrame);
341 
342     return OT_ERROR_NONE;
343 }
344 
otPlatRadioGetTransmitPower(otInstance * aInstance,int8_t * aPower)345 otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower)
346 {
347     OT_UNUSED_VARIABLE(aInstance);
348     OT_UNUSED_VARIABLE(aPower);
349     return OT_ERROR_NONE;
350 }
351 
otPlatRadioGetTransmitBuffer(otInstance * aInstance)352 otRadioFrame *otPlatRadioGetTransmitBuffer(otInstance *aInstance)
353 {
354     OT_UNUSED_VARIABLE(aInstance);
355     return &sRadioTransmitFrame;
356 }
357 
otPlatRadioGetRssi(otInstance * aInstance)358 int8_t otPlatRadioGetRssi(otInstance *aInstance)
359 {
360     OT_UNUSED_VARIABLE(aInstance);
361     return 0;
362 }
363 
otPlatRadioGetCaps(otInstance * aInstance)364 otRadioCaps otPlatRadioGetCaps(otInstance *aInstance)
365 {
366     OT_UNUSED_VARIABLE(aInstance);
367     return OT_RADIO_CAPS_NONE;
368 }
369 
otPlatRadioGetPromiscuous(otInstance * aInstance)370 bool otPlatRadioGetPromiscuous(otInstance *aInstance)
371 {
372     OT_UNUSED_VARIABLE(aInstance);
373     return false;
374 }
375 
otPlatRadioEnableSrcMatch(otInstance * aInstance,bool aEnable)376 void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable)
377 {
378     OT_UNUSED_VARIABLE(aInstance);
379     OT_UNUSED_VARIABLE(aEnable);
380 }
381 
otPlatRadioAddSrcMatchShortEntry(otInstance * aInstance,uint16_t aShortAddress)382 otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, uint16_t aShortAddress)
383 {
384     OT_UNUSED_VARIABLE(aInstance);
385     OT_UNUSED_VARIABLE(aShortAddress);
386     return OT_ERROR_NONE;
387 }
388 
otPlatRadioAddSrcMatchExtEntry(otInstance * aInstance,const otExtAddress * aExtAddress)389 otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress)
390 {
391     OT_UNUSED_VARIABLE(aInstance);
392     OT_UNUSED_VARIABLE(aExtAddress);
393     return OT_ERROR_NONE;
394 }
395 
otPlatRadioClearSrcMatchShortEntry(otInstance * aInstance,uint16_t aShortAddress)396 otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, uint16_t aShortAddress)
397 {
398     OT_UNUSED_VARIABLE(aInstance);
399     OT_UNUSED_VARIABLE(aShortAddress);
400     return OT_ERROR_NONE;
401 }
402 
otPlatRadioClearSrcMatchExtEntry(otInstance * aInstance,const otExtAddress * aExtAddress)403 otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress)
404 {
405     OT_UNUSED_VARIABLE(aInstance);
406     OT_UNUSED_VARIABLE(aExtAddress);
407     return OT_ERROR_NONE;
408 }
409 
otPlatRadioClearSrcMatchShortEntries(otInstance * aInstance)410 void otPlatRadioClearSrcMatchShortEntries(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); }
411 
otPlatRadioClearSrcMatchExtEntries(otInstance * aInstance)412 void otPlatRadioClearSrcMatchExtEntries(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); }
413 
otPlatRadioEnergyScan(otInstance * aInstance,uint8_t aScanChannel,uint16_t aScanDuration)414 otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint16_t aScanDuration)
415 {
416     OT_UNUSED_VARIABLE(aInstance);
417     OT_UNUSED_VARIABLE(aScanChannel);
418     OT_UNUSED_VARIABLE(aScanDuration);
419     return OT_ERROR_NOT_IMPLEMENTED;
420 }
421 
otPlatRadioSetTransmitPower(otInstance * aInstance,int8_t aPower)422 otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower)
423 {
424     OT_UNUSED_VARIABLE(aInstance);
425     OT_UNUSED_VARIABLE(aPower);
426     return OT_ERROR_NOT_IMPLEMENTED;
427 }
428 
otPlatRadioGetCcaEnergyDetectThreshold(otInstance * aInstance,int8_t * aThreshold)429 otError otPlatRadioGetCcaEnergyDetectThreshold(otInstance *aInstance, int8_t *aThreshold)
430 {
431     OT_UNUSED_VARIABLE(aInstance);
432     OT_UNUSED_VARIABLE(aThreshold);
433     return OT_ERROR_NOT_IMPLEMENTED;
434 }
435 
otPlatRadioSetCcaEnergyDetectThreshold(otInstance * aInstance,int8_t aThreshold)436 otError otPlatRadioSetCcaEnergyDetectThreshold(otInstance *aInstance, int8_t aThreshold)
437 {
438     OT_UNUSED_VARIABLE(aInstance);
439     OT_UNUSED_VARIABLE(aThreshold);
440     return OT_ERROR_NOT_IMPLEMENTED;
441 }
442 
otPlatRadioGetReceiveSensitivity(otInstance * aInstance)443 int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance)
444 {
445     OT_UNUSED_VARIABLE(aInstance);
446     return 0;
447 }
448 
otPlatEntropyGet(uint8_t * aOutput,uint16_t aOutputLength)449 otError otPlatEntropyGet(uint8_t *aOutput, uint16_t aOutputLength)
450 {
451     for (uint16_t length = 0; length < aOutputLength; length++)
452     {
453         aOutput[length] = (uint8_t)rand();
454     }
455 
456     return OT_ERROR_NONE;
457 }
458 
otPlatSettingsInit(otInstance * aInstance,const uint16_t * aSensitiveKeys,uint16_t aSensitiveKeysLength)459 void otPlatSettingsInit(otInstance *aInstance, const uint16_t *aSensitiveKeys, uint16_t aSensitiveKeysLength)
460 {
461     OT_UNUSED_VARIABLE(aInstance);
462     OT_UNUSED_VARIABLE(aSensitiveKeys);
463     OT_UNUSED_VARIABLE(aSensitiveKeysLength);
464 }
465 
otPlatSettingsDeinit(otInstance * aInstance)466 void otPlatSettingsDeinit(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); }
467 
otPlatSettingsGet(otInstance * aInstance,uint16_t aKey,int aIndex,uint8_t * aValue,uint16_t * aValueLength)468 otError otPlatSettingsGet(otInstance *aInstance, uint16_t aKey, int aIndex, uint8_t *aValue, uint16_t *aValueLength)
469 {
470     OT_UNUSED_VARIABLE(aInstance);
471     OT_UNUSED_VARIABLE(aKey);
472     OT_UNUSED_VARIABLE(aIndex);
473     OT_UNUSED_VARIABLE(aValue);
474     OT_UNUSED_VARIABLE(aValueLength);
475     return OT_ERROR_NOT_FOUND;
476 }
477 
otPlatSettingsSet(otInstance * aInstance,uint16_t aKey,const uint8_t * aValue,uint16_t aValueLength)478 otError otPlatSettingsSet(otInstance *aInstance, uint16_t aKey, const uint8_t *aValue, uint16_t aValueLength)
479 {
480     OT_UNUSED_VARIABLE(aInstance);
481     OT_UNUSED_VARIABLE(aKey);
482     OT_UNUSED_VARIABLE(aValue);
483     OT_UNUSED_VARIABLE(aValueLength);
484     return OT_ERROR_NONE;
485 }
486 
otPlatSettingsAdd(otInstance * aInstance,uint16_t aKey,const uint8_t * aValue,uint16_t aValueLength)487 otError otPlatSettingsAdd(otInstance *aInstance, uint16_t aKey, const uint8_t *aValue, uint16_t aValueLength)
488 {
489     OT_UNUSED_VARIABLE(aInstance);
490     OT_UNUSED_VARIABLE(aKey);
491     OT_UNUSED_VARIABLE(aValue);
492     OT_UNUSED_VARIABLE(aValueLength);
493     return OT_ERROR_NONE;
494 }
495 
otPlatSettingsDelete(otInstance * aInstance,uint16_t aKey,int aIndex)496 otError otPlatSettingsDelete(otInstance *aInstance, uint16_t aKey, int aIndex)
497 {
498     OT_UNUSED_VARIABLE(aInstance);
499     OT_UNUSED_VARIABLE(aKey);
500     OT_UNUSED_VARIABLE(aIndex);
501     return OT_ERROR_NONE;
502 }
503 
otPlatSettingsWipe(otInstance * aInstance)504 void otPlatSettingsWipe(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); }
505 
otPlatDiagSetOutputCallback(otInstance * aInstance,otPlatDiagOutputCallback aCallback,void * aContext)506 void otPlatDiagSetOutputCallback(otInstance *aInstance, otPlatDiagOutputCallback aCallback, void *aContext)
507 {
508     OT_UNUSED_VARIABLE(aInstance);
509     OT_UNUSED_VARIABLE(aCallback);
510     OT_UNUSED_VARIABLE(aContext);
511 }
512 
otPlatDiagProcess(otInstance * aInstance,uint8_t aArgsLength,char * aArgs[])513 otError otPlatDiagProcess(otInstance *aInstance, uint8_t aArgsLength, char *aArgs[])
514 {
515     OT_UNUSED_VARIABLE(aInstance);
516     OT_UNUSED_VARIABLE(aArgsLength);
517     OT_UNUSED_VARIABLE(aArgs);
518 
519     return OT_ERROR_INVALID_COMMAND;
520 }
521 
otPlatDiagModeSet(bool aMode)522 void otPlatDiagModeSet(bool aMode) { OT_UNUSED_VARIABLE(aMode); }
523 
otPlatDiagModeGet(void)524 bool otPlatDiagModeGet(void) { return false; }
525 
otPlatDiagChannelSet(uint8_t aChannel)526 void otPlatDiagChannelSet(uint8_t aChannel) { OT_UNUSED_VARIABLE(aChannel); }
527 
otPlatDiagTxPowerSet(int8_t aTxPower)528 void otPlatDiagTxPowerSet(int8_t aTxPower) { OT_UNUSED_VARIABLE(aTxPower); }
529 
otPlatDiagRadioReceived(otInstance * aInstance,otRadioFrame * aFrame,otError aError)530 void otPlatDiagRadioReceived(otInstance *aInstance, otRadioFrame *aFrame, otError aError)
531 {
532     OT_UNUSED_VARIABLE(aInstance);
533     OT_UNUSED_VARIABLE(aFrame);
534     OT_UNUSED_VARIABLE(aError);
535 }
536 
otPlatDiagAlarmCallback(otInstance * aInstance)537 void otPlatDiagAlarmCallback(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); }
538 
otPlatDnssdGetState(otInstance * aInstance)539 otPlatDnssdState otPlatDnssdGetState(otInstance *aInstance)
540 {
541     OT_UNUSED_VARIABLE(aInstance);
542 
543     return OT_PLAT_DNSSD_STOPPED;
544 }
545 
otPlatDnssdRegisterService(otInstance * aInstance,const otPlatDnssdService * aService,otPlatDnssdRequestId aRequestId,otPlatDnssdRegisterCallback aCallback)546 void otPlatDnssdRegisterService(otInstance                 *aInstance,
547                                 const otPlatDnssdService   *aService,
548                                 otPlatDnssdRequestId        aRequestId,
549                                 otPlatDnssdRegisterCallback aCallback)
550 {
551     OT_UNUSED_VARIABLE(aInstance);
552     OT_UNUSED_VARIABLE(aService);
553     OT_UNUSED_VARIABLE(aRequestId);
554     OT_UNUSED_VARIABLE(aCallback);
555 }
556 
otPlatDnssdUnregisterService(otInstance * aInstance,const otPlatDnssdService * aService,otPlatDnssdRequestId aRequestId,otPlatDnssdRegisterCallback aCallback)557 void otPlatDnssdUnregisterService(otInstance                 *aInstance,
558                                   const otPlatDnssdService   *aService,
559                                   otPlatDnssdRequestId        aRequestId,
560                                   otPlatDnssdRegisterCallback aCallback)
561 {
562     OT_UNUSED_VARIABLE(aInstance);
563     OT_UNUSED_VARIABLE(aService);
564     OT_UNUSED_VARIABLE(aRequestId);
565     OT_UNUSED_VARIABLE(aCallback);
566 }
567 
otPlatDnssdRegisterHost(otInstance * aInstance,const otPlatDnssdHost * aHost,otPlatDnssdRequestId aRequestId,otPlatDnssdRegisterCallback aCallback)568 void otPlatDnssdRegisterHost(otInstance                 *aInstance,
569                              const otPlatDnssdHost      *aHost,
570                              otPlatDnssdRequestId        aRequestId,
571                              otPlatDnssdRegisterCallback aCallback)
572 {
573     OT_UNUSED_VARIABLE(aInstance);
574     OT_UNUSED_VARIABLE(aHost);
575     OT_UNUSED_VARIABLE(aRequestId);
576     OT_UNUSED_VARIABLE(aCallback);
577 }
578 
otPlatDnssdUnregisterHost(otInstance * aInstance,const otPlatDnssdHost * aHost,otPlatDnssdRequestId aRequestId,otPlatDnssdRegisterCallback aCallback)579 void otPlatDnssdUnregisterHost(otInstance                 *aInstance,
580                                const otPlatDnssdHost      *aHost,
581                                otPlatDnssdRequestId        aRequestId,
582                                otPlatDnssdRegisterCallback aCallback)
583 {
584     OT_UNUSED_VARIABLE(aInstance);
585     OT_UNUSED_VARIABLE(aHost);
586     OT_UNUSED_VARIABLE(aRequestId);
587     OT_UNUSED_VARIABLE(aCallback);
588 }
589 
otPlatDnssdRegisterKey(otInstance * aInstance,const otPlatDnssdKey * aKey,otPlatDnssdRequestId aRequestId,otPlatDnssdRegisterCallback aCallback)590 void otPlatDnssdRegisterKey(otInstance                 *aInstance,
591                             const otPlatDnssdKey       *aKey,
592                             otPlatDnssdRequestId        aRequestId,
593                             otPlatDnssdRegisterCallback aCallback)
594 {
595     OT_UNUSED_VARIABLE(aInstance);
596     OT_UNUSED_VARIABLE(aKey);
597     OT_UNUSED_VARIABLE(aRequestId);
598     OT_UNUSED_VARIABLE(aCallback);
599 }
600 
otPlatDnssdUnregisterKey(otInstance * aInstance,const otPlatDnssdKey * aKey,otPlatDnssdRequestId aRequestId,otPlatDnssdRegisterCallback aCallback)601 void otPlatDnssdUnregisterKey(otInstance                 *aInstance,
602                               const otPlatDnssdKey       *aKey,
603                               otPlatDnssdRequestId        aRequestId,
604                               otPlatDnssdRegisterCallback aCallback)
605 {
606     OT_UNUSED_VARIABLE(aInstance);
607     OT_UNUSED_VARIABLE(aKey);
608     OT_UNUSED_VARIABLE(aRequestId);
609     OT_UNUSED_VARIABLE(aCallback);
610 }
611 
otPlatMdnsSetListeningEnabled(otInstance * aInstance,bool aEnable,uint32_t aInfraIfIndex)612 otError otPlatMdnsSetListeningEnabled(otInstance *aInstance, bool aEnable, uint32_t aInfraIfIndex)
613 {
614     OT_UNUSED_VARIABLE(aInstance);
615     OT_UNUSED_VARIABLE(aEnable);
616     OT_UNUSED_VARIABLE(aInfraIfIndex);
617 
618     return OT_ERROR_NOT_IMPLEMENTED;
619 }
620 
otPlatMdnsSendMulticast(otInstance * aInstance,otMessage * aMessage,uint32_t aInfraIfIndex)621 void otPlatMdnsSendMulticast(otInstance *aInstance, otMessage *aMessage, uint32_t aInfraIfIndex)
622 {
623     OT_UNUSED_VARIABLE(aInstance);
624     OT_UNUSED_VARIABLE(aMessage);
625     OT_UNUSED_VARIABLE(aInfraIfIndex);
626 }
627 
otPlatMdnsSendUnicast(otInstance * aInstance,otMessage * aMessage,const otPlatMdnsAddressInfo * aAddress)628 void otPlatMdnsSendUnicast(otInstance *aInstance, otMessage *aMessage, const otPlatMdnsAddressInfo *aAddress)
629 {
630     OT_UNUSED_VARIABLE(aInstance);
631     OT_UNUSED_VARIABLE(aMessage);
632     OT_UNUSED_VARIABLE(aAddress);
633 }
634 
otPlatInfraIfHasAddress(uint32_t aInfraIfIndex,const otIp6Address * aAddress)635 bool otPlatInfraIfHasAddress(uint32_t aInfraIfIndex, const otIp6Address *aAddress)
636 {
637     OT_UNUSED_VARIABLE(aInfraIfIndex);
638     OT_UNUSED_VARIABLE(aAddress);
639 
640     return false;
641 }
642 
otPlatInfraIfSendIcmp6Nd(uint32_t aInfraIfIndex,const otIp6Address * aDestAddress,const uint8_t * aBuffer,uint16_t aBufferLength)643 otError otPlatInfraIfSendIcmp6Nd(uint32_t            aInfraIfIndex,
644                                  const otIp6Address *aDestAddress,
645                                  const uint8_t      *aBuffer,
646                                  uint16_t            aBufferLength)
647 {
648     OT_UNUSED_VARIABLE(aInfraIfIndex);
649     OT_UNUSED_VARIABLE(aDestAddress);
650     OT_UNUSED_VARIABLE(aBuffer);
651     OT_UNUSED_VARIABLE(aBufferLength);
652 
653     return OT_ERROR_FAILED;
654 }
655 
otPlatInfraIfDiscoverNat64Prefix(uint32_t aInfraIfIndex)656 otError otPlatInfraIfDiscoverNat64Prefix(uint32_t aInfraIfIndex)
657 {
658     OT_UNUSED_VARIABLE(aInfraIfIndex);
659 
660     return OT_ERROR_FAILED;
661 }
662 
663 } // extern "C"
664