Skip to content

Commit

Permalink
Initializing 'sin_len' fields in inet addresses for Apple and BSD. Fi…
Browse files Browse the repository at this point in the history
…xes unit tests on Mac.
  • Loading branch information
fpagliughi committed Jan 18, 2023
1 parent f1ffec4 commit 55df05e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/inet6_address.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ void inet6_address::create(const in6_addr& addr, in_port_t port)
addr_.sin6_flowinfo = 0;
addr_.sin6_addr = addr;
addr_.sin6_port = htons(port);
#if defined(__APPLE__) || defined(BSD)
addr_.sin6_len = (uint8_t) SZ;
#endif

}

// --------------------------------------------------------------------------
Expand All @@ -100,6 +104,9 @@ void inet6_address::create(const string& saddr, in_port_t port)
addr_.sin6_flowinfo = 0;
addr_.sin6_addr = resolve_name(saddr.c_str());
addr_.sin6_port = htons(port);
#if defined(__APPLE__) || defined(BSD)
addr_.sin6_len = (uint8_t) SZ;
#endif
}

// --------------------------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions src/inet_address.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ void inet_address::create(uint32_t addr, in_port_t port)
addr_.sin_family = AF_INET;
addr_.sin_addr.s_addr = htonl(addr);
addr_.sin_port = htons(port);
#if defined(__APPLE__) || defined(BSD)
addr_.sin_len = (uint8_t) SZ;
#endif
}

// --------------------------------------------------------------------------
Expand All @@ -97,6 +100,9 @@ void inet_address::create(const std::string& saddr, in_port_t port)
addr_.sin_family = AF_INET;
addr_.sin_addr.s_addr = resolve_name(saddr.c_str());
addr_.sin_port = htons(port);
#if defined(__APPLE__) || defined(BSD)
addr_.sin_len = (uint8_t) SZ;
#endif
}

// --------------------------------------------------------------------------
Expand Down

0 comments on commit 55df05e

Please sign in to comment.