mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-04-21 22:46:54 +02:00
add isSocketAddressEmpty
This commit is contained in:
parent
6537ee2fe4
commit
6ea4e1f1f0
2 changed files with 27 additions and 0 deletions
|
@ -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…
Add table
Reference in a new issue