From ba282932a94c3bdb1b254ff5a87dcc8cb21b8e52 Mon Sep 17 00:00:00 2001 From: kangping Date: Mon, 30 Mar 2020 09:36:15 +0800 Subject: [PATCH] make pretty --- src/app/border_agent.cpp | 42 +++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/src/app/border_agent.cpp b/src/app/border_agent.cpp index 0c5f41a55..ac66d00a1 100644 --- a/src/app/border_agent.cpp +++ b/src/app/border_agent.cpp @@ -60,9 +60,9 @@ static int HandleRecord(const struct sockaddr *from, Error DiscoverBorderAgent(BorderAgentHandler aBorderAgentHandler, size_t aTimeout) { - static constexpr size_t kDefaultBufferSize = 1024 * 16; - static constexpr mdns_record_type_t kMdnsQueryType = MDNS_RECORDTYPE_PTR; - static const char * kServiceName = "_meshcop._udp.local"; + static constexpr size_t kDefaultBufferSize = 1024 * 16; + static constexpr mdns_record_type_t kMdnsQueryType = MDNS_RECORDTYPE_PTR; + static const char * kServiceName = "_meshcop._udp.local"; Error error = Error::kNone; uint8_t buf[kDefaultBufferSize]; @@ -116,15 +116,15 @@ static inline std::string ToString(const mdns_string_t &aString) * */ static int HandleRecord(const struct sockaddr *from, - mdns_entry_type_t entry, - uint16_t type, - uint16_t rclass, - uint32_t ttl, - const void * data, - size_t size, - size_t offset, - size_t length, - void * border_agent) + mdns_entry_type_t entry, + uint16_t type, + uint16_t rclass, + uint32_t ttl, + const void * data, + size_t size, + size_t offset, + size_t length, + void * border_agent) { Error error = Error::kNone; struct sockaddr_storage fromAddrStorage; @@ -133,16 +133,15 @@ static int HandleRecord(const struct sockaddr *from, std::string entryType; char nameBuffer[256]; - BorderAgentOrErrorMsg &borderAgentOrErrorMsg = *reinterpret_cast(border_agent); - BorderAgent &borderAgent = borderAgentOrErrorMsg.mBorderAgent; - std::string &errorMsg = borderAgentOrErrorMsg.mErrorMsg; + BorderAgentOrErrorMsg &borderAgentOrErrorMsg = *reinterpret_cast(border_agent); + BorderAgent & borderAgent = borderAgentOrErrorMsg.mBorderAgent; + std::string & errorMsg = borderAgentOrErrorMsg.mErrorMsg; (void)rclass; (void)ttl; *reinterpret_cast(&fromAddrStorage) = *from; - if (fromAddr.Set(fromAddrStorage) != Error::kNone || - fromAddr.ToString(fromAddrStr) != Error::kNone) + if (fromAddr.Set(fromAddrStorage) != Error::kNone || fromAddr.ToString(fromAddrStr) != Error::kNone) { ExitNow(errorMsg = "invalid source address of mDNS response"); } @@ -171,8 +170,7 @@ static int HandleRecord(const struct sockaddr *from, mdns_record_parse_a(data, size, offset, length, &addr); *reinterpret_cast(&addrStorage) = addr; - if (fromAddr.Set(addrStorage) != Error::kNone || - fromAddr.ToString(addrStr) != Error::kNone) + if (fromAddr.Set(addrStorage) != Error::kNone || fromAddr.ToString(addrStr) != Error::kNone) { ExitNow(errorMsg = "invalid IPv4 address in A record"); } @@ -193,8 +191,7 @@ static int HandleRecord(const struct sockaddr *from, mdns_record_parse_aaaa(data, size, offset, length, &addr); *reinterpret_cast(&addrStorage) = addr; - if (fromAddr.Set(addrStorage) != Error::kNone || - fromAddr.ToString(addrStr) != Error::kNone) + if (fromAddr.Set(addrStorage) != Error::kNone || fromAddr.ToString(addrStr) != Error::kNone) { ExitNow(errorMsg = "invalid IPv6 address in AAAA record"); } @@ -207,7 +204,8 @@ static int HandleRecord(const struct sockaddr *from, mdns_record_txt_t txtBuffer[128]; size_t parsed; - parsed = mdns_record_parse_txt(data, size, offset, length, txtBuffer, sizeof(txtBuffer) / sizeof(mdns_record_txt_t)); + parsed = + mdns_record_parse_txt(data, size, offset, length, txtBuffer, sizeof(txtBuffer) / sizeof(mdns_record_txt_t)); for (size_t i = 0; i < parsed; ++i) {