mirror of
https://github.com/ceph/ceph
synced 2025-01-03 09:32:43 +00:00
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:
parent
ba5b40c0ce
commit
0038d362d3
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user