/*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
sa_family_t getFamily() const {
DCHECK(external_ || AF_UNIX != storage_.addr.family());
- return external_ ? AF_UNIX : storage_.addr.family();
+ return external_ ? sa_family_t(AF_UNIX) : storage_.addr.family();
}
bool empty() const {
*/
void getAddressStr(char* buf, size_t buflen) const;
+ /**
+ * Return true if it is a valid IPv4 or IPv6 address.
+ */
+ bool isFamilyInet() const;
+
/**
* For v4 & v6 addresses, return the fully qualified address string
*/
static constexpr uint64_t kMagic = 0x1234faceb00c;
socklen_t pathLength() const {
- return len - offsetof(struct sockaddr_un, sun_path);
+ return socklen_t(len - offsetof(struct sockaddr_un, sun_path));
}
void init() {
addr = new sockaddr_un;
magic = kMagic;
len = other.len;
- memcpy(addr, other.addr, len);
+ memcpy(addr, other.addr, size_t(len));
// Fill the rest with 0s, just for safety
memset(reinterpret_cast<char*>(addr) + len, 0,
sizeof(struct sockaddr_un) - len);
void copy(const ExternalUnixAddr &other) {
CHECK(magic == kMagic);
len = other.len;
- memcpy(addr, other.addr, len);
+ memcpy(addr, other.addr, size_t(len));
}
void free() {
CHECK(magic == kMagic);