blob: c47816e922b06bbc921c61bfb3c1d60104f6b22c [file] [log] [blame]
/*
*
* Copyright (c) 2018 Nest Labs, Inc.
* All rights reserved.
*
* 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
* General utility functions available on all platforms.
*/
/**
* WEAVE_PII and WEAVE_PII_FMT
*
* Used to mark information that could be used to identify a specific user or device. This info will
* only be logged when PII logging is enabled, otherwise the string will be redacted.
*
* The _FMT variant additionally formats the PII by the given printf format string.
*/
#if WEAVE_DEVICE_CONFIG_LOG_PII
#define WEAVE_PII(pii) pii
#define WEAVE_PII_FMT(fmt, pii) ::nl::Weave::DeviceLayer::FormatString(fmt, pii).data()
#else
#define WEAVE_PII(pii) "[PII Redacted]"
#define WEAVE_PII_FMT(fmt, pii) "[PII Redacted]"
#endif
namespace nl {
namespace Weave {
namespace DeviceLayer {
extern WEAVE_ERROR ParseCompilerDateStr(const char * dateStr, uint16_t & year, uint8_t & month, uint8_t & dayOfMonth);
extern WEAVE_ERROR Parse24HourTimeStr(const char * timeStr, uint8_t & hour, uint8_t & minute, uint8_t & second);
extern const char * CharacterizeIPv6Address(const ::nl::Inet::IPAddress & ipAddr);
extern const char * CharacterizeIPv6Prefix(const Inet::IPPrefix & inPrefix);
extern void RegisterDeviceLayerErrorFormatter(void);
extern bool FormatDeviceLayerError(char * buf, uint16_t bufSize, int32_t err);
extern std::string FormatString(const char* fmt, ...);
} // namespace DeviceLayer
} // namespace Weave
} // namespace nl