-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
Copy pathCHIPConfig.h
1876 lines (1710 loc) · 61.9 KB
/
CHIPConfig.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
*
* Copyright (c) 2020-2022 Project CHIP Authors
* Copyright (c) 2019 Google LLC.
* Copyright (c) 2013-2018 Nest Labs, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file
* This file defines default compile-time configuration constants
* for CHIP.
*
* Package integrators that wish to override these values should
* either use preprocessor definitions or create a project-
* specific chipProjectConfig.h header and then assert
* HAVE_CHIPPROJECTCONFIG_H via the package configuration tool
* via --with-chip-project-includes=DIR where DIR is the
* directory that contains the header.
*
* NOTE WELL: On some platforms, this header is included by C-language programs.
*
*/
#pragma once
#if CHIP_HAVE_CONFIG_H
#include <core/CHIPBuildConfig.h>
#endif
#include <ble/BleConfig.h>
#include <system/SystemConfig.h>
#include <inet/InetConfig.h>
/*
#if INET_CONFIG_ENABLE_TCP_ENDPOINT && INET_TCP_IDLE_CHECK_INTERVAL <= 0
#error "chip SDK requires INET_TCP_IDLE_CHECK_INTERVAL > 0"
#endif // INET_CONFIG_ENABLE_TCP_ENDPOINT && INET_TCP_IDLE_CHECK_INTERVAL <= 0
*/
/* Include a project-specific configuration file, if defined.
*
* An application or module that incorporates chip can define a project configuration
* file to override standard chip configuration with application-specific values.
* The chipProjectConfig.h file is typically located outside the CHIP source tree,
* alongside the source code for the application.
*/
#ifdef CHIP_PROJECT_CONFIG_INCLUDE
#include CHIP_PROJECT_CONFIG_INCLUDE
#endif
/* Include a platform-specific configuration file, if defined.
*
* A platform configuration file contains overrides to standard chip configuration
* that are specific to the platform or OS on which chip is running. It is typically
* provided as apart of an adaptation layer that adapts CHIP to the target
* environment. This adaptation layer may be included in the CHIP source tree
* itself or implemented externally.
*/
#ifdef CHIP_PLATFORM_CONFIG_INCLUDE
#include CHIP_PLATFORM_CONFIG_INCLUDE
#endif
/**
* @name chip Security Manager Memory Management Configuration
*
* @brief
* The following definitions enable one of three potential chip
* Security Manager memory-management options:
*
* * #CHIP_CONFIG_MEMORY_MGMT_PLATFORM
* * #CHIP_CONFIG_MEMORY_MGMT_SIMPLE
* * #CHIP_CONFIG_MEMORY_MGMT_MALLOC
*
* Note that these options are mutually exclusive and only one
* of these options should be set.
*
* @{
*/
/**
* @def CHIP_CONFIG_MEMORY_MGMT_PLATFORM
*
* @brief
* Enable (1) or disable (0) support for platform-specific
* implementation of Matter memory-management functions.
*
* @note This configuration is mutual exclusive with
* #CHIP_CONFIG_MEMORY_MGMT_MALLOC.
*
*/
#ifndef CHIP_CONFIG_MEMORY_MGMT_PLATFORM
#define CHIP_CONFIG_MEMORY_MGMT_PLATFORM 0
#endif // CHIP_CONFIG_MEMORY_MGMT_PLATFORM
/**
* @def CHIP_CONFIG_MEMORY_MGMT_MALLOC
*
* @brief
* Enable (1) or disable (0) support for a chip-provided
* implementation of Matter memory-management
* functions based on the C Standard Library malloc / free
* functions.
*
* @note This configuration is mutual exclusive with
* #CHIP_CONFIG_MEMORY_MGMT_PLATFORM.
*
*/
#ifndef CHIP_CONFIG_MEMORY_MGMT_MALLOC
#define CHIP_CONFIG_MEMORY_MGMT_MALLOC 1
#endif // CHIP_CONFIG_MEMORY_MGMT_MALLOC
/**
* @}
*/
#if ((CHIP_CONFIG_MEMORY_MGMT_PLATFORM + CHIP_CONFIG_MEMORY_MGMT_MALLOC) != 1)
#error "Please assert exactly one of CHIP_CONFIG_MEMORY_MGMT_PLATFORM or CHIP_CONFIG_MEMORY_MGMT_MALLOC."
#endif // ((CHIP_CONFIG_MEMORY_MGMT_PLATFORM + CHIP_CONFIG_MEMORY_MGMT_MALLOC) != 1)
#if !CHIP_CONFIG_MEMORY_MGMT_MALLOC && CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS
#error "!CHIP_CONFIG_MEMORY_MGMT_MALLOC but getifaddrs() uses malloc()"
#endif
/**
* @def CHIP_CONFIG_MEMORY_DEBUG_CHECKS
*
* @brief
* Enable (1) or disable (0) building with additional code
* for memory-related checks.
*/
#ifndef CHIP_CONFIG_MEMORY_DEBUG_CHECKS
#define CHIP_CONFIG_MEMORY_DEBUG_CHECKS 0
#endif // CHIP_CONFIG_MEMORY_DEBUG_CHECKS
/**
* @def CHIP_CONFIG_MEMORY_DEBUG_DMALLOC
*
* @brief
* Enable (1) or disable (0) malloc memory allocator support
* for dmalloc, an open-source debug malloc library. When enabled,
* additional checks and logging of allocations may be performed,
* with some performance cost.
*
* @note This configuration is most relevant when
* #CHIP_CONFIG_MEMORY_MGMT_MALLOC is set, but may also
* affect other configurations where application or platform
* code uses the malloc() family.
*
*/
#ifndef CHIP_CONFIG_MEMORY_DEBUG_DMALLOC
#define CHIP_CONFIG_MEMORY_DEBUG_DMALLOC 0
#endif // CHIP_CONFIG_MEMORY_DEBUG_DMALLOC
/**
* @def CHIP_CONFIG_GLOBALS_LAZY_INIT
*
* @brief
* Whether to perform chip::Global initialization lazily (1) or eagerly (0).
*
* The default is standard (eager) C++ global initialization behavior.
*/
#ifndef CHIP_CONFIG_GLOBALS_LAZY_INIT
#define CHIP_CONFIG_GLOBALS_LAZY_INIT 0
#endif // CHIP_CONFIG_GLOBALS_LAZY_INIT
/**
* @def CHIP_CONFIG_GLOBALS_NO_DESTRUCT
*
* @brief
* Whether to omit calling destructors for chip::Global objects.
*
* The default is to call destructors.
*/
#ifndef CHIP_CONFIG_GLOBALS_NO_DESTRUCT
#define CHIP_CONFIG_GLOBALS_NO_DESTRUCT 0
#endif // CHIP_CONFIG_GLOBALS_NO_DESTRUCT
/**
* @def CHIP_CONFIG_SHA256_CONTEXT_SIZE
*
* @brief
* Size of the statically allocated context for SHA256 operations in CryptoPAL
*
* The default size is based on the Worst software implementation, OpenSSL. A
* static assert will tell us if we are wrong, since `typedef SHA_LONG unsigned
* int` is default.
* SHA_LONG h[8];
* SHA_LONG Nl, Nh;
* SHA_LONG data[SHA_LBLOCK]; // SHA_LBLOCK is 16 for SHA256
* unsigned int num, md_len;
*
* We also have to account for possibly some custom extensions on some targets,
* especially for mbedTLS, so an extra sizeof(uint64_t) is added to account.
*
*/
#ifndef CHIP_CONFIG_SHA256_CONTEXT_SIZE
#define CHIP_CONFIG_SHA256_CONTEXT_SIZE ((sizeof(unsigned int) * (8 + 2 + 16 + 2)) + sizeof(uint64_t))
#endif // CHIP_CONFIG_SHA256_CONTEXT_SIZE
/**
* @def CHIP_CONFIG_SHA256_CONTEXT_ALIGN
*
* @brief The alignment of SHA256 context buffer.
*/
#ifndef CHIP_CONFIG_SHA256_CONTEXT_ALIGN
#define CHIP_CONFIG_SHA256_CONTEXT_ALIGN size_t
#endif // CHIP_CONFIG_SHA256_CONTEXT_ALIGN
/**
* @def CHIP_CONFIG_HKDF_KEY_HANDLE_CONTEXT_SIZE
*
* @brief
* Size of the statically allocated context for the HKDF key handle in CryptoPAL.
*
* The default size is selected so that the key handle is able to fit 256-bit raw key
* material along with the size information.
*/
#ifndef CHIP_CONFIG_HKDF_KEY_HANDLE_CONTEXT_SIZE
#define CHIP_CONFIG_HKDF_KEY_HANDLE_CONTEXT_SIZE (32 + 1)
#endif // CHIP_CONFIG_HKDF_KEY_HANDLE_CONTEXT_SIZE
/**
* @def CHIP_CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS
*
* @brief
* Maximum number of simultaneously active unsolicited message
* handlers.
*
*/
#ifndef CHIP_CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS
#define CHIP_CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS 8
#endif // CHIP_CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS
/**
* @def CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS
*
* @brief
* Maximum number of simultaneously active exchange contexts.
*
*/
#ifndef CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS
#define CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS 16
#endif // CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS
/**
* @def CHIP_CONFIG_MCSP_RECEIVE_TABLE_SIZE
*
* @brief
* Size of the receive table for message counter synchronization protocol
*
*/
#ifndef CHIP_CONFIG_MCSP_RECEIVE_TABLE_SIZE
#define CHIP_CONFIG_MCSP_RECEIVE_TABLE_SIZE (CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS - 2)
#endif // CHIP_CONFIG_MCSP_RECEIVE_TABLE_SIZE
/**
* @def CHIP_CONFIG_MESSAGE_COUNTER_WINDOW_SIZE
*
* @brief
* Max number of messages behind message window can be accepted.
*
*/
#ifndef CHIP_CONFIG_MESSAGE_COUNTER_WINDOW_SIZE
#define CHIP_CONFIG_MESSAGE_COUNTER_WINDOW_SIZE 32
#endif // CHIP_CONFIG_MESSAGE_COUNTER_WINDOW_SIZE
/**
* @def CHIP_CONFIG_DEFAULT_UDP_MTU_SIZE
*
* @brief
* The default MTU size for an IPv6 datagram carrying UDP. This is useful
* for senders who want to send UDP chip messages that fit within a single
* IPv6 datagram.
*
* 1280 is the guaranteed minimum IPv6 MTU.
*
*/
#ifndef CHIP_CONFIG_DEFAULT_UDP_MTU_SIZE
#define CHIP_CONFIG_DEFAULT_UDP_MTU_SIZE 1280
#endif // CHIP_CONFIG_DEFAULT_UDP_MTU_SIZE
/**
* @def CHIP_PORT
*
* @brief
* chip TCP/UDP port for secured chip traffic.
*
*/
#ifndef CHIP_PORT
#define CHIP_PORT 5540
#endif // CHIP_PORT
/**
* @def CHIP_UDC_PORT
*
* @brief
* chip TCP/UDP port on commissioner for unsecured user-directed-commissioning traffic.
*
*/
#ifndef CHIP_UDC_PORT
#define CHIP_UDC_PORT CHIP_PORT + 10
#endif // CHIP_UDC_PORT
/**
* @def CHIP_UDC_COMMISSIONEE_PORT
*
* @brief
* chip TCP/UDP port on commisionee for unsecured user-directed-commissioning traffic.
*
*/
#ifndef CHIP_UDC_COMMISSIONEE_PORT
#define CHIP_UDC_COMMISSIONEE_PORT CHIP_UDC_PORT + 10
#endif // CHIP_UDC_COMMISSIONEE_PORT
/**
* @def CHIP_CONFIG_SECURITY_TEST_MODE
*
* @brief
* Enable various features that make it easier to debug secure chip communication.
*
* @note
* WARNING: This option makes it possible to circumvent basic chip security functionality,
* including message encryption. Because of this it SHOULD NEVER BE ENABLED IN PRODUCTION BUILDS.
*
* To build with this flag, pass 'treat_warnings_as_errors=false' to gn/ninja.
*/
#ifndef CHIP_CONFIG_SECURITY_TEST_MODE
#define CHIP_CONFIG_SECURITY_TEST_MODE 0
#endif // CHIP_CONFIG_SECURITY_TEST_MODE
/**
* @def CHIP_CONFIG_TEST_SHARED_SECRET_VALUE
*
* @brief
* Shared secret to use for unit tests or when CHIP_CONFIG_SECURITY_TEST_MODE is enabled.
*
* This parameter is 32 bytes to maximize entropy passed to the CryptoContext::InitWithSecret KDF,
* and can be initialized either as a raw string or array of bytes. The default test secret of
* "Test secret for key derivation." results in the following encryption keys:
*
* 5E DE D2 44 E5 53 2B 3C DC 23 40 9D BA D0 52 D2
* A9 E0 11 B1 73 7C 6D 4B 70 E4 C0 A2 FE 66 04 76
*/
#ifndef CHIP_CONFIG_TEST_SHARED_SECRET_VALUE
#define CHIP_CONFIG_TEST_SHARED_SECRET_VALUE "Test secret for key derivation."
#endif // CHIP_CONFIG_TEST_SHARED_SECRET_VALUE
/**
* @def CHIP_CONFIG_TEST_SHARED_SECRET_LENGTH
*
* @brief
* Length of the shared secret to use for unit tests or when CHIP_CONFIG_SECURITY_TEST_MODE is enabled.
*
* Note that the default value of 32 includes the null terminator.
* WARNING: `strlen(CHIP_CONFIG_TEST_SHARED_SECRET_VALUE)` will result in different keys
* than expected and give unexpected results for shared secrets that contain '\x00'.
*/
#ifndef CHIP_CONFIG_TEST_SHARED_SECRET_LENGTH
#define CHIP_CONFIG_TEST_SHARED_SECRET_LENGTH 32
#endif // CHIP_CONFIG_TEST_SHARED_SECRET_LENGTH
/**
* @def CHIP_CONFIG_CERT_MAX_RDN_ATTRIBUTES
*
* @brief
* The maximum number of Relative Distinguished Name (RDN) attributes
* supported by the CHIP Certificate Distinguished Names (DN).
*
*/
#ifndef CHIP_CONFIG_CERT_MAX_RDN_ATTRIBUTES
#define CHIP_CONFIG_CERT_MAX_RDN_ATTRIBUTES 5
#endif // CHIP_CONFIG_CERT_MAX_RDN_ATTRIBUTES
/**
* @def CHIP_ERROR_LOGGING
*
* @brief
* If asserted (1), enable logging of all messages in the
* chip::Logging::LogCategory::kLogCategory_Error category.
*
*/
#ifndef CHIP_ERROR_LOGGING
#define CHIP_ERROR_LOGGING 1
#endif // CHIP_ERROR_LOGGING
/**
* @def CHIP_PROGRESS_LOGGING
*
* @brief
* If asserted (1), enable logging of all messages in the
* chip::Logging::LogCategory::kLogCategory_Progress category.
*
*/
#ifndef CHIP_PROGRESS_LOGGING
#define CHIP_PROGRESS_LOGGING 1
#endif // CHIP_PROGRESS_LOGGING
/**
* @def CHIP_DETAIL_LOGGING
*
* @brief
* If asserted (1), enable logging of all messages in the
* chip::Logging::kLogCategory_Detail category.
*
*/
#ifndef CHIP_DETAIL_LOGGING
#define CHIP_DETAIL_LOGGING 1
#endif // CHIP_DETAIL_LOGGING
/**
* @def CHIP_AUTOMATION_LOGGING
*
* @brief
* If asserted (1), enable logging of all messages in the
* chip::Logging::kLogCategory_Automation category.
*
*/
#ifndef CHIP_AUTOMATION_LOGGING
#define CHIP_AUTOMATION_LOGGING 1
#endif // CHIP_AUTOMATION_LOGGING
/**
* @def CHIP_LOG_FILTERING
*
* @brief
* If asserted (1), enable runtime log level configuration.
*/
#ifndef CHIP_LOG_FILTERING
#define CHIP_LOG_FILTERING 1
#endif
/**
* CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE
*
* The maximum size (in bytes) of a log message
*/
#ifndef CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE
#define CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE 256
#endif
/**
* @def CHIP_CONFIG_ENABLE_CONDITION_LOGGING
*
* @brief
* If asserted (1), enable logging of failed conditions via the
* ChipLogIfFalse() macro.
*/
#ifndef CHIP_CONFIG_ENABLE_CONDITION_LOGGING
#define CHIP_CONFIG_ENABLE_CONDITION_LOGGING 0
#endif // CHIP_CONFIG_ENABLE_CONDITION_LOGGING
/**
* @def CHIP_CONFIG_TEST
*
* @brief
* If asserted (1), enable APIs that help implement
* unit and integration tests.
*
*/
#ifndef CHIP_CONFIG_TEST
#define CHIP_CONFIG_TEST 0
#endif // CHIP_CONFIG_TEST
/**
* @def CHIP_CONFIG_ERROR_SOURCE
*
* If asserted (1), then CHIP_ERROR constants will include the source location of their expansion.
*/
#ifndef CHIP_CONFIG_ERROR_SOURCE
#define CHIP_CONFIG_ERROR_SOURCE 0
#endif // CHIP_CONFIG_ERROR_SOURCE
/**
* @def CHIP_CONFIG_ERROR_SOURCE_NO_ERROR
*
* If asserted (1) along with CHIP_CONFIG_ERROR_SOURCE, then instances of CHIP_NO_ERROR will also include
* the source location of their expansion. Otherwise, CHIP_NO_ERROR is excluded from source tracking.
*/
#ifndef CHIP_CONFIG_ERROR_SOURCE_NO_ERROR
#define CHIP_CONFIG_ERROR_SOURCE_NO_ERROR 1
#endif // CHIP_CONFIG_ERROR_SOURCE
/**
* @def CHIP_CONFIG_ERROR_FORMAT_AS_STRING
*
* If 0, then ChipError::Format() returns an integer (ChipError::StorageType).
* If 1, then ChipError::Format() returns a const char *, from chip::ErrorStr().
* In either case, the macro CHIP_ERROR_FORMAT expands to a suitable printf format.
*/
#ifndef CHIP_CONFIG_ERROR_FORMAT_AS_STRING
#define CHIP_CONFIG_ERROR_FORMAT_AS_STRING 0
#endif // CHIP_CONFIG_ERROR_FORMAT_AS_STRING
/**
* @def CHIP_CONFIG_SHORT_ERROR_STR
*
* @brief
* If asserted (1), produce shorter error strings that only carry a
* minimum of information.
*
*/
#ifndef CHIP_CONFIG_SHORT_ERROR_STR
#define CHIP_CONFIG_SHORT_ERROR_STR 0
#endif // CHIP_CONFIG_SHORT_ERROR_STR
/**
* @def CHIP_CONFIG_ERROR_STR_SIZE
*
* @brief
* This defines the size of the buffer to store a formatted error string.
* If the formatting of an error string exceeds this size it will be truncated.
*
* The default size varies based on the CHIP_CONFIG_SHORT_ERROR_STR option.
*
* When CHIP_CONFIG_SHORT_ERROR_STR is 0, a large default buffer size is used
* to accommodate descriptive text summarizing the cause of the error. E.g.:
*
* "chip Error 4047 (0x00000FCF): Invalid Argument"
*
* When CHIP_CONFIG_SHORT_ERROR_STR is 1, the buffer size is set to accommodate
* a minimal error string consisting of a 10 character subsystem name followed
* by an 8 character error number, plus boilerplate. E.g.:
*
* "Error chip:0x00000FCF"
*
*/
#ifndef CHIP_CONFIG_ERROR_STR_SIZE
#if CHIP_CONFIG_SHORT_ERROR_STR
#define CHIP_CONFIG_ERROR_STR_SIZE (5 + 1 + 10 + 3 + 8 + 1)
#else // CHIP_CONFIG_SHORT_ERROR_STR
#define CHIP_CONFIG_ERROR_STR_SIZE 256
#endif // CHIP_CONFIG_SHORT_ERROR_STR
#endif // CHIP_CONFIG_ERROR_STR_SIZE
/**
* @def CHIP_CONFIG_CUSTOM_ERROR_FORMATTER
*
* @brief
* If asserted (1), suppress definition of the standard error formatting function
* (#FormatError()) allowing an application-specific implementation to be used.
*
*/
#ifndef CHIP_CONFIG_CUSTOM_ERROR_FORMATTER
#define CHIP_CONFIG_CUSTOM_ERROR_FORMATTER 0
#endif // CHIP_CONFIG_CUSTOM_ERROR_FORMATTER
/**
* @def CHIP_CONFIG_SHORT_FORM_ERROR_VALUE_FORMAT
*
* @brief
* The printf-style format string used to format error values.
*
* On some platforms, the structure of error values makes them more convenient to
* read in either hex or decimal format. This option can be used to override
* the default hex format.
*
* Note that this option only affects short-form error strings (i.e. when
* CHIP_CONFIG_SHORT_ERROR_STR == 1). Long form error strings always show both hex
* and decimal values
*/
#ifndef CHIP_CONFIG_SHORT_FORM_ERROR_VALUE_FORMAT
#define CHIP_CONFIG_SHORT_FORM_ERROR_VALUE_FORMAT "0x%08" PRIX32
#endif // CHIP_CONFIG_SHORT_FORM_ERROR_VALUE_FORMAT
/**
* @def CHIP_CONFIG_BLE_PKT_RESERVED_SIZE
*
* @brief
* The number of bytes that chip should reserve at the front of
* every outgoing BLE packet for the sake of the underlying BLE
* stack.
*
*/
#ifndef CHIP_CONFIG_BLE_PKT_RESERVED_SIZE
#define CHIP_CONFIG_BLE_PKT_RESERVED_SIZE 0
#endif // CHIP_CONFIG_BLE_PKT_RESERVED_SIZE
/**
* @def CHIP_CONFIG_IsPlatformErrorNonCritical(CODE)
*
* This macro checks if a platform generated error is critical and
* needs to be reported to the application/caller. The criticality
* of an error (in the context of that platform) is determined by how
* it impacts the logic flow, i.e., whether or not the current flow
* can continue despite the error or it needs to be reported back
* resulting in a potential stoppage.
*
* @note
* This is a default set of platform errors which are configured as
* non-critical from the context of that platform. Any new error that
* the platforms deem as non-critical could be added by overriding
* this default macro definition after careful thought towards its
* implication in the logic flow in that platform.
*
* @param[in] CODE The #CHIP_ERROR being checked for criticality.
*
* @return true if the error is non-critical; false otherwise.
*
*/
#ifndef CHIP_CONFIG_IsPlatformErrorNonCritical
#if CHIP_SYSTEM_CONFIG_USE_LWIP
#define _CHIP_CONFIG_IsPlatformLwIPErrorNonCritical(CODE) \
((CODE) == chip::System::MapErrorLwIP(ERR_RTE) || (CODE) == chip::System::MapErrorLwIP(ERR_MEM))
#else // !CHIP_SYSTEM_CONFIG_USE_LWIP
#define _CHIP_CONFIG_IsPlatformLwIPErrorNonCritical(CODE) 0
#endif // !CHIP_SYSTEM_CONFIG_USE_LWIP
#if CHIP_SYSTEM_CONFIG_USE_SOCKETS || CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK
#define _CHIP_CONFIG_IsPlatformPOSIXErrorNonCritical(CODE) \
((CODE) == CHIP_ERROR_POSIX(EHOSTUNREACH) || (CODE) == CHIP_ERROR_POSIX(ENETUNREACH) || \
(CODE) == CHIP_ERROR_POSIX(EADDRNOTAVAIL) || (CODE) == CHIP_ERROR_POSIX(EPIPE))
#else // !(CHIP_SYSTEM_CONFIG_USE_SOCKETS || CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK)
#define _CHIP_CONFIG_IsPlatformPOSIXErrorNonCritical(CODE) 0
#endif // !(CHIP_SYSTEM_CONFIG_USE_SOCKETS || CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK)
#define CHIP_CONFIG_IsPlatformErrorNonCritical(CODE) \
(_CHIP_CONFIG_IsPlatformPOSIXErrorNonCritical(CODE) || _CHIP_CONFIG_IsPlatformLwIPErrorNonCritical(CODE))
#endif // CHIP_CONFIG_IsPlatformErrorNonCritical
/**
* @def CHIP_CONFIG_PERSISTED_STORAGE_KEY_TYPE
*
* @brief
* The data type used to represent the key of a persistedly-stored
* key/value pair.
*/
#ifndef CHIP_CONFIG_PERSISTED_STORAGE_KEY_TYPE
#define CHIP_CONFIG_PERSISTED_STORAGE_KEY_TYPE const char *
#endif
/**
* @def CHIP_CONFIG_LIFETIIME_PERSISTED_COUNTER_KEY
*
* @brief
* Lifetime Counter Key.
*/
#ifndef CHIP_CONFIG_LIFETIIME_PERSISTED_COUNTER_KEY
#define CHIP_CONFIG_LIFETIIME_PERSISTED_COUNTER_KEY "life-count"
#endif
/**
* @def CHIP_CONFIG_PERSISTED_STORAGE_ENC_MSG_CNTR_ID
*
* @brief
* The group key message counter persisted storage Id.
*
*/
#ifndef CHIP_CONFIG_PERSISTED_STORAGE_ENC_MSG_CNTR_ID
#define CHIP_CONFIG_PERSISTED_STORAGE_ENC_MSG_CNTR_ID "EncMsgCntr"
#endif // CHIP_CONFIG_PERSISTED_STORAGE_ENC_MSG_CNTR_ID
/**
* @def CHIP_CONFIG_PERSISTED_STORAGE_MAX_KEY_LENGTH
*
* @brief The maximum length of the key in a key/value pair
* stored in the platform's persistent storage.
*/
#ifndef CHIP_CONFIG_PERSISTED_STORAGE_MAX_KEY_LENGTH
#define CHIP_CONFIG_PERSISTED_STORAGE_MAX_KEY_LENGTH 16
#endif
/**
* @def CHIP_CONFIG_PERSISTED_COUNTER_DEBUG_LOGGING
*
* @brief Enable debug logging for the PersistedCounter API.
*/
#ifndef CHIP_CONFIG_PERSISTED_COUNTER_DEBUG_LOGGING
#define CHIP_CONFIG_PERSISTED_COUNTER_DEBUG_LOGGING 0
#endif
/**
* @def CHIP_CONFIG_EVENT_LOGGING_VERBOSE_DEBUG_LOGS
*
* @brief Enable verbose debug logging for the EventLogging API.
* This setting is incompatible with platforms that route console
* logs into event logging, as it would result in circular logic.
*/
#ifndef CHIP_CONFIG_EVENT_LOGGING_VERBOSE_DEBUG_LOGS
#define CHIP_CONFIG_EVENT_LOGGING_VERBOSE_DEBUG_LOGS 1
#endif
/**
* @def CHIP_CONFIG_ENABLE_ARG_PARSER
*
* @brief Enable support functions for parsing command-line arguments
*/
#ifndef CHIP_CONFIG_ENABLE_ARG_PARSER
#define CHIP_CONFIG_ENABLE_ARG_PARSER 0
#endif
/**
* @def CHIP_CONFIG_ENABLE_ARG_PARSER_VALIDITY_CHECKS
*
* @brief Enable validity checking of command-line argument definitions.
*
* // TODO: Determine why we wouldn't need this
*/
#ifndef CHIP_CONFIG_ENABLE_ARG_PARSER_VALIDITY_CHECKS
#define CHIP_CONFIG_ENABLE_ARG_PARSER_VALIDITY_CHECKS 1
#endif
/**
* @def CHIP_CONFIG_NON_POSIX_LONG_OPT
*
* @brief Some platforms have a version of getopt_long that behaves differently from the
* POSIX version. Set CHIP_CONFIG_NON_POSIX_LONG_OPT to 1 if the platform's implementation of
* getopt_long differs from POSIX in the following ways (as is the case for ESP32 and OpenIoT):
* (a) Sets optopt to '?' when encountering an unknown short option, instead of setting it
* to the actual value of the character it encountered.
* (b) Treats an unknown long option like a series of short options.
* (c) Does not always permute argv to put the nonoptions at the end.
*/
#ifndef CHIP_CONFIG_NON_POSIX_LONG_OPT
#define CHIP_CONFIG_NON_POSIX_LONG_OPT 0
#endif
/**
* @def CHIP_CONFIG_UNAUTHENTICATED_CONNECTION_POOL_SIZE
*
* @brief Define the size of the pool used for tracking Matter unauthenticated
* message states. The entries in the pool are automatically rotated by LRU. The size
* of the pool limits how many PASE and CASE pairing sessions can be processed
* simultaneously.
*/
#ifndef CHIP_CONFIG_UNAUTHENTICATED_CONNECTION_POOL_SIZE
#define CHIP_CONFIG_UNAUTHENTICATED_CONNECTION_POOL_SIZE 4
#endif // CHIP_CONFIG_UNAUTHENTICATED_CONNECTION_POOL_SIZE
/**
* @def CHIP_CONFIG_SECURE_SESSION_REFCOUNT_LOGGING
*
* @brief This enables logging of changes to the underlying reference count of
* SecureSession objects.
*
*/
#ifndef CHIP_CONFIG_SECURE_SESSION_REFCOUNT_LOGGING
#define CHIP_CONFIG_SECURE_SESSION_REFCOUNT_LOGGING 0
#endif
/**
* @def CHIP_CONFIG_MAX_FABRICS
*
* @brief
* Maximum number of fabrics the device can participate in. Each fabric can
* provision the device with its unique operational credentials and manage
* its own access control lists.
*/
#ifndef CHIP_CONFIG_MAX_FABRICS
#define CHIP_CONFIG_MAX_FABRICS 16
#endif // CHIP_CONFIG_MAX_FABRICS
/**
* @def CHIP_CONFIG_SECURE_SESSION_POOL_SIZE
*
* @brief Defines the size of the pool used for tracking the state of
* secure sessions. This controls the maximum number of concurrent
* established secure sessions across all supported transports.
*
* This is sized by default to cover the sum of the following:
* - At least 3 CASE sessions / fabric (Spec Ref: 4.13.2.8)
* - 1 reserved slot for CASEServer as a responder.
* - 1 reserved slot for PASE.
*
* NOTE: On heap-based platforms, there is no pre-allocation of the pool.
* Due to the use of an LRU-scheme to manage sessions, the actual active
* size of the pool will grow up to the value of this define,
* after which, it will remain at or around this size indefinitely.
*
*/
#ifndef CHIP_CONFIG_SECURE_SESSION_POOL_SIZE
#define CHIP_CONFIG_SECURE_SESSION_POOL_SIZE (CHIP_CONFIG_MAX_FABRICS * 3 + 2)
#endif // CHIP_CONFIG_SECURE_SESSION_POOL_SIZE
/**
* @def CHIP_CONFIG_MAX_GROUP_DATA_PEERS
*
* @brief
* Maximum number of Peer within a fabric that can send group data message to a device.
*
* // TODO: Determine a better value for this
*/
#ifndef CHIP_CONFIG_MAX_GROUP_DATA_PEERS
#define CHIP_CONFIG_MAX_GROUP_DATA_PEERS 15
#endif // CHIP_CONFIG_MAX_GROUP_DATA_PEERS
/**
* @def CHIP_CONFIG_MAX_GROUP_CONTROL_PEERS
*
* @brief
* Maximum number of Peer within a fabric that can send group control message to a device.
*/
#ifndef CHIP_CONFIG_MAX_GROUP_CONTROL_PEERS
#define CHIP_CONFIG_MAX_GROUP_CONTROL_PEERS 2
#endif // CHIP_CONFIG_MAX_GROUP_CONTROL_PEER
/**
* @def CHIP_CONFIG_SLOW_CRYPTO
*
* @brief
* When enabled, CASE and PASE setup will proactively send standalone acknowledgements
* prior to engaging in crypto operations.
*/
#ifndef CHIP_CONFIG_SLOW_CRYPTO
#define CHIP_CONFIG_SLOW_CRYPTO 1
#endif // CHIP_CONFIG_SLOW_CRYPTO
/**
* @def CHIP_NON_PRODUCTION_MARKER
*
* @brief Defines the name of a mark symbol whose presence signals that the chip code
* includes development/testing features that should never be used in production contexts.
*/
#ifndef CHIP_NON_PRODUCTION_MARKER
#if (CHIP_CONFIG_SECURITY_TEST_MODE || CHIP_FUZZING_ENABLED)
#define CHIP_NON_PRODUCTION_MARKER WARNING__DO_NOT_SHIP__CONTAINS_NON_PRODUCTION_CHIP_CODE
#endif
#endif
#ifdef CHIP_NON_PRODUCTION_MARKER
extern const char CHIP_NON_PRODUCTION_MARKER[];
#endif
/**
* @def CHIP_COMMISSIONING_HINT_TABLE
*
* @brief Defines the set of "pairing hint" values that can be set in
* the PH key in commissionable node discovery response.
*/
#ifndef CHIP_COMMISSIONING_HINT_TABLE
#define CHIP_COMMISSIONING_HINT_TABLE
#define CHIP_COMMISSIONING_HINT_INDEX_POWER_CYCLE 0
#define CHIP_COMMISSIONING_HINT_INDEX_MANUFACTURER_URL 1
#define CHIP_COMMISSIONING_HINT_INDEX_SEE_ADMINISTRATOR_UX 2
#define CHIP_COMMISSIONING_HINT_INDEX_SEE_SETTINGS_MENU 3
#define CHIP_COMMISSIONING_HINT_INDEX_CUSTOM_INSTRUCTION 4
#define CHIP_COMMISSIONING_HINT_INDEX_SEE_MANUAL 5
#define CHIP_COMMISSIONING_HINT_INDEX_PRESS_RESET 6
#define CHIP_COMMISSIONING_HINT_INDEX_PRESS_RESET_WITH_POWER 7
#define CHIP_COMMISSIONING_HINT_INDEX_PRESS_RESET_SECONDS 8
#define CHIP_COMMISSIONING_HINT_INDEX_PRESS_RESET_UNTIL_BLINK 9
#define CHIP_COMMISSIONING_HINT_INDEX_PRESS_RESET_SECONDS_WITH_POWER 10
#define CHIP_COMMISSIONING_HINT_INDEX_PRESS_RESET_UNTIL_BLINK_WITH_POWER 11
#endif
/**
* @name Interaction Model object pool configuration.
*
* @brief
* The following definitions sets the maximum number of corresponding interaction model object pool size.
*
* * #CHIP_IM_MAX_NUM_COMMAND_HANDLER
* * #CHIP_IM_MAX_NUM_READS
* * #CHIP_IM_MAX_NUM_SUBSCRIPTIONS
* * #CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS_FOR_SUBSCRIPTIONS
* * #CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS_FOR_READS
* * #CHIP_IM_MAX_REPORTS_IN_FLIGHT
* * #CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS
* * #CHIP_IM_SERVER_MAX_NUM_DIRTY_SET
* * #CHIP_IM_MAX_NUM_WRITE_HANDLER
* * #CHIP_IM_MAX_NUM_WRITE_CLIENT
* * #CHIP_IM_MAX_NUM_TIMED_HANDLER
*
* @{
*/
/**
* @def CHIP_IM_MAX_NUM_COMMAND_HANDLER
*
* @brief Defines the maximum number of CommandHandler, limits the number of active commands transactions on server.
*/
#ifndef CHIP_IM_MAX_NUM_COMMAND_HANDLER
#define CHIP_IM_MAX_NUM_COMMAND_HANDLER 4
#endif
/**
* @def CHIP_IM_MAX_NUM_SUBSCRIPTIONS
*
* @brief Defines the maximum number of ReadHandler for subscriptions, limits the number of active subscription transactions on
* server.
*
* The default value comes from 3sub per fabric * max number of fabrics.
*
*/
#ifndef CHIP_IM_MAX_NUM_SUBSCRIPTIONS
#define CHIP_IM_MAX_NUM_SUBSCRIPTIONS (CHIP_CONFIG_MAX_FABRICS * 3)
#endif
/**
* @def CHIP_IM_MAX_NUM_READS
*
* @brief Defines the maximum number of ReadHandler for read transactions, limits the number of active read transactions on
* server.
*
* The default value is one per fabric * max number of fabrics.
*/
#ifndef CHIP_IM_MAX_NUM_READS
#define CHIP_IM_MAX_NUM_READS (CHIP_CONFIG_MAX_FABRICS)
#endif
/**
* @def CHIP_IM_MAX_REPORTS_IN_FLIGHT
*
* @brief Defines the maximum number of Reports, limits the traffic of read and subscription transactions.
*/
#ifndef CHIP_IM_MAX_REPORTS_IN_FLIGHT
#define CHIP_IM_MAX_REPORTS_IN_FLIGHT 4
#endif
/**
* @def CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS_FOR_SUBSCRIPTIONS
*
* @brief The maximum number of path objects for subscriptions, limits the number of attributes being subscribed at the same time.
*/
#ifndef CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS_FOR_SUBSCRIPTIONS
#define CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS_FOR_SUBSCRIPTIONS (CHIP_IM_MAX_NUM_SUBSCRIPTIONS * 3)
#endif
/**
* @def CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS_FOR_READS
*
* @brief Defines the maximum number of path objects for read requests.
*/
#ifndef CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS_FOR_READS
#define CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS_FOR_READS (CHIP_IM_MAX_NUM_READS * 9)
#endif
/**
* @def CHIP_IM_SERVER_MAX_NUM_DIRTY_SET
*
* @brief Defines the maximum number of dirty set, limits the number of attributes being read or subscribed at the same time.
*/
#ifndef CHIP_IM_SERVER_MAX_NUM_DIRTY_SET
#define CHIP_IM_SERVER_MAX_NUM_DIRTY_SET 8
#endif
/**
* @def CHIP_IM_MAX_NUM_WRITE_HANDLER
*
* @brief Defines the maximum number of WriteHandler, limits the number of active write transactions on server.
*/
#ifndef CHIP_IM_MAX_NUM_WRITE_HANDLER
#define CHIP_IM_MAX_NUM_WRITE_HANDLER 4
#endif
/**
* @def CHIP_IM_MAX_NUM_WRITE_CLIENT
*
* @brief Defines the maximum number of WriteClient, limits the number of active write transactions on client.
*/
#ifndef CHIP_IM_MAX_NUM_WRITE_CLIENT
#define CHIP_IM_MAX_NUM_WRITE_CLIENT 4
#endif
/**
* @def CHIP_IM_MAX_NUM_TIMED_HANDLER
*
* @brief Defines the maximum number of TimedHandler, limits the number of
* active timed interactions waiting for the Invoke or Write.
*/
#ifndef CHIP_IM_MAX_NUM_TIMED_HANDLER
#define CHIP_IM_MAX_NUM_TIMED_HANDLER 8
#endif
/**
* @}
*/
/**
* @def CONFIG_BUILD_FOR_HOST_UNIT_TEST
*
* @brief Defines whether we're currently building for unit testing, which enables a set of features
* that are only utilized in those tests. This flag should not be enabled on devices. If you have a test
* that uses this flag, either appropriately conditionalize the entire test on this flag, or to exclude
* the compliation of that test source file entirely.
*/
#ifndef CONFIG_BUILD_FOR_HOST_UNIT_TEST
#define CONFIG_BUILD_FOR_HOST_UNIT_TEST 0
#endif
/**
* @def CHIP_CONFIG_IM_ENABLE_ENCODING_SENTINEL_ENUM_VALUES
*
* @brief Defines whether encoding the "not a known enum value" enum values is
* allowed. Should only be enabled in certain test applications. This
* flag must not be enabled on actual devices.
*/
#ifndef CHIP_CONFIG_IM_ENABLE_ENCODING_SENTINEL_ENUM_VALUES