mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-01-18 18:56:24 +00:00
add isSocketAddressEmpty
This commit is contained in:
parent
809022b273
commit
40d5f9b5d2
@ -531,3 +531,28 @@ jbyteArray newByteArray(JNIEnv *env, size_t count) {
|
||||
|
||||
return byteArrayObj;
|
||||
}
|
||||
|
||||
bool isSocketAddressEmpty(const sockaddr_storage addr) {
|
||||
|
||||
//
|
||||
// was:
|
||||
// struct sockaddr_storage nullAddress = {0};
|
||||
//
|
||||
// but was getting this warning:
|
||||
// warning: suggest braces around initialization of subobject
|
||||
//
|
||||
// when building ZeroTierOne
|
||||
//
|
||||
sockaddr_storage emptyAddress; //NOLINT
|
||||
|
||||
//
|
||||
// It is possible to assume knowledge about internals of sockaddr_storage and construct
|
||||
// correct 0-initializer, but it is simpler to just treat sockaddr_storage as opaque and
|
||||
// use memset here to fill with 0
|
||||
//
|
||||
// This is also done in InetAddress.hpp for InetAddress
|
||||
//
|
||||
memset(&emptyAddress, 0, sizeof(sockaddr_storage));
|
||||
|
||||
return (memcmp(&addr, &emptyAddress, sizeof(sockaddr_storage)) == 0); //NOLINT
|
||||
}
|
||||
|
@ -160,4 +160,6 @@ jbyteArray newByteArray(JNIEnv *env, const unsigned char *bytes, size_t count);
|
||||
|
||||
jbyteArray newByteArray(JNIEnv *env, size_t count);
|
||||
|
||||
bool isSocketAddressEmpty(const sockaddr_storage addr);
|
||||
|
||||
#endif // ZT_jniutils_h_
|
||||
|
Loading…
Reference in New Issue
Block a user