virsocketaddr: Introduce virSocketAddrSetIPv6Addr

This is a missing counterpart for virSocketAddrSetIPv4Addr()
and is going to be needed later in the tests.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Michal Privoznik 2016-03-15 16:35:23 +01:00
parent 4122137871
commit 1ca59d89c6
3 changed files with 17 additions and 0 deletions

View File

@ -2165,6 +2165,7 @@ virSocketAddrParseIPv4;
virSocketAddrParseIPv6; virSocketAddrParseIPv6;
virSocketAddrPrefixToNetmask; virSocketAddrPrefixToNetmask;
virSocketAddrSetIPv4Addr; virSocketAddrSetIPv4Addr;
virSocketAddrSetIPv6Addr;
virSocketAddrSetPort; virSocketAddrSetPort;
# util/virstats.h # util/virstats.h

View File

@ -188,6 +188,21 @@ virSocketAddrSetIPv4Addr(virSocketAddrPtr addr, uint32_t val)
addr->len = sizeof(struct sockaddr_in); addr->len = sizeof(struct sockaddr_in);
} }
/*
* virSocketAddrSetIPv6Addr:
* @addr: the location to store the result
* @val: the 128bit integer in host byte order representing the IPv6 address
*
* Set the IPv6 address given an integer in host order. This function does not
* touch any previously set port.
*/
void virSocketAddrSetIPv6Addr(virSocketAddrPtr addr, uint32_t val[4])
{
addr->data.stor.ss_family = AF_INET6;
memcpy(addr->data.inet6.sin6_addr.s6_addr, val, 4 * sizeof(*val));
addr->len = sizeof(struct sockaddr_in6);
}
/* /*
* virSocketAddrEqual: * virSocketAddrEqual:
* @s1: the location of the one IP address * @s1: the location of the one IP address

View File

@ -85,6 +85,7 @@ int virSocketAddrParseIPv6(virSocketAddrPtr addr,
const char *val); const char *val);
void virSocketAddrSetIPv4Addr(virSocketAddrPtr s, uint32_t addr); void virSocketAddrSetIPv4Addr(virSocketAddrPtr s, uint32_t addr);
void virSocketAddrSetIPv6Addr(virSocketAddrPtr s, uint32_t addr[4]);
char *virSocketAddrFormat(const virSocketAddr *addr); char *virSocketAddrFormat(const virSocketAddr *addr);
char *virSocketAddrFormatFull(const virSocketAddr *addr, char *virSocketAddrFormatFull(const virSocketAddr *addr,