msg/msg_types: update sockaddr, sockaddr_storage accessors

Return sockaddr_storage by value.  New sockaddr-based accessors.

Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2016-05-06 09:46:06 -04:00
parent ba5b40c0ce
commit 0038d362d3

View File

@ -251,7 +251,21 @@ struct entity_addr_t {
return addr6;
}
bool set_sockaddr(struct sockaddr *sa)
const sockaddr *get_sockaddr() const {
return (const sockaddr *)&addr4;
}
size_t get_sockaddr_len() const {
switch (addr.ss_family) {
case AF_INET:
return sizeof(addr4);
break;
case AF_INET6:
return sizeof(addr6);
break;
}
return sizeof(addr);
}
bool set_sockaddr(const struct sockaddr *sa)
{
switch (sa->sa_family) {
case AF_INET:
@ -266,6 +280,10 @@ struct entity_addr_t {
return true;
}
sockaddr_storage get_sockaddr_storage() const {
return addr;
}
void set_in4_quad(int pos, int val) {
addr4.sin_family = AF_INET;
unsigned char *ipq = (unsigned char*)&addr4.sin_addr.s_addr;