提交 1ca59d89 编写于 作者: M Michal Privoznik

virsocketaddr: Introduce virSocketAddrSetIPv6Addr

This is a missing counterpart for virSocketAddrSetIPv4Addr()
and is going to be needed later in the tests.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
上级 41221378
...@@ -2165,6 +2165,7 @@ virSocketAddrParseIPv4; ...@@ -2165,6 +2165,7 @@ virSocketAddrParseIPv4;
virSocketAddrParseIPv6; virSocketAddrParseIPv6;
virSocketAddrPrefixToNetmask; virSocketAddrPrefixToNetmask;
virSocketAddrSetIPv4Addr; virSocketAddrSetIPv4Addr;
virSocketAddrSetIPv6Addr;
virSocketAddrSetPort; virSocketAddrSetPort;
# util/virstats.h # util/virstats.h
......
...@@ -188,6 +188,21 @@ virSocketAddrSetIPv4Addr(virSocketAddrPtr addr, uint32_t val) ...@@ -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
......
...@@ -85,6 +85,7 @@ int virSocketAddrParseIPv6(virSocketAddrPtr addr, ...@@ -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,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册