mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-24 21:45:21 +00:00
maint: avoid 'const fooPtr' in several util files
'const fooPtr' is the same as 'foo * const' (the pointer won't change, but it's contents can). But in general, if an interface is trying to be const-correct, it should be using 'const foo *' (the pointer is to data that can't be changed). Fix up offenders in src/util outside of the virnet namespace. Also, make a few virSocketAddr functions const-correct, for easier conversions in future patches. * src/util/virbuffer.h (virBufferError, virBufferUse) (virBufferGetIndent): Use intended type. * src/util/virmacaddr.h (virMacAddrCmp, virMacAddrCmpRaw) (virMacAddrSet, virMcAddrFormat, virMacAddrIsUnicast) (virMacAddrIsMulticast): Likewise. * src/util/virebtables.h (ebtablesAddForwardAllowIn) (ebtablesRemoveForwardAllowIn): Likewise. * src/util/virsocketaddr.h (virSocketAddrSetIPv4Addr): Drop incorrect const. (virMacAddrGetRaw, virSocketAddrFormat, virSocketAddrFormatFull): Make const-correct. (virSocketAddrMask, virSocketAddrMaskByPrefix) (virSocketAddrBroadcast, virSocketAddrBroadcastByPrefix) (virSocketAddrGetNumNetmaskBits, virSocketAddrGetIpPrefix) (virSocketAddrEqual, virSocketAddrIsPrivate) (virSocketAddrIsWildcard): Use intended type. * src/util/virbuffer.c (virBufferError, virBufferUse) (virBufferGetIndent): Fix fallout. * src/util/virmacaddr.c (virMacAddrCmp, virMacAddrCmpRaw) (virMacAddrSet, virMcAddrFormat, virMacAddrIsUnicast) (virMacAddrIsMulticast): Likewise. * src/util/virebtables.c (ebtablesAddForwardAllowIn) (ebtablesRemoveForwardAllowIn): Likewise. * src/util/virsocketaddr.c (virSocketAddrMask, virMacAddrGetRaw) (virSocketAddrMaskByPrefix, virSocketAddrBroadcast) (virSocketAddrBroadcastByPrefix, virSocketAddrGetNumNetmaskBits) (virSocketAddrGetIpPrefix, virSocketAddrEqual) (virSocketAddrIsPrivate, virSocketAddrIsWildcard) (virSocketAddrGetIPv4Addr, virSocketAddrGetIPv6Addr) (virSocketAddrFormat, virSocketAddrFormatFull): Likewise. Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
b43efdaa13
commit
1b0bc4169f
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* virbuffer.c: buffers for libvirt
|
* virbuffer.c: buffers for libvirt
|
||||||
*
|
*
|
||||||
* Copyright (C) 2005-2008, 2010-2012 Red Hat, Inc.
|
* Copyright (C) 2005-2008, 2010-2013 Red Hat, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -95,7 +95,7 @@ virBufferAdjustIndent(virBufferPtr buf, int indent)
|
|||||||
* Return the current auto-indent value, or -1 if there has been an error.
|
* Return the current auto-indent value, or -1 if there has been an error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virBufferGetIndent(const virBufferPtr buf, bool dynamic)
|
virBufferGetIndent(const virBuffer *buf, bool dynamic)
|
||||||
{
|
{
|
||||||
if (!buf || buf->error)
|
if (!buf || buf->error)
|
||||||
return -1;
|
return -1;
|
||||||
@ -255,7 +255,7 @@ void virBufferFreeAndReset(virBufferPtr buf)
|
|||||||
* Return positive errno value or -1 on usage error, 0 if normal
|
* Return positive errno value or -1 on usage error, 0 if normal
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virBufferError(const virBufferPtr buf)
|
virBufferError(const virBuffer *buf)
|
||||||
{
|
{
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
@ -270,7 +270,7 @@ virBufferError(const virBufferPtr buf)
|
|||||||
* Return the string usage in bytes
|
* Return the string usage in bytes
|
||||||
*/
|
*/
|
||||||
unsigned int
|
unsigned int
|
||||||
virBufferUse(const virBufferPtr buf)
|
virBufferUse(const virBuffer *buf)
|
||||||
{
|
{
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* virbuffer.h: buffers for libvirt
|
* virbuffer.h: buffers for libvirt
|
||||||
*
|
*
|
||||||
* Copyright (C) 2005-2008, 2011, 2012 Red Hat, Inc.
|
* Copyright (C) 2005-2008, 2011-2013 Red Hat, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -52,8 +52,8 @@ struct _virBuffer {
|
|||||||
const char *virBufferCurrentContent(virBufferPtr buf);
|
const char *virBufferCurrentContent(virBufferPtr buf);
|
||||||
char *virBufferContentAndReset(virBufferPtr buf);
|
char *virBufferContentAndReset(virBufferPtr buf);
|
||||||
void virBufferFreeAndReset(virBufferPtr buf);
|
void virBufferFreeAndReset(virBufferPtr buf);
|
||||||
int virBufferError(const virBufferPtr buf);
|
int virBufferError(const virBuffer *buf);
|
||||||
unsigned int virBufferUse(const virBufferPtr buf);
|
unsigned int virBufferUse(const virBuffer *buf);
|
||||||
void virBufferAdd(virBufferPtr buf, const char *str, int len);
|
void virBufferAdd(virBufferPtr buf, const char *str, int len);
|
||||||
void virBufferAddChar(virBufferPtr buf, char c);
|
void virBufferAddChar(virBufferPtr buf, char c);
|
||||||
void virBufferAsprintf(virBufferPtr buf, const char *format, ...)
|
void virBufferAsprintf(virBufferPtr buf, const char *format, ...)
|
||||||
@ -75,7 +75,7 @@ void virBufferURIEncodeString(virBufferPtr buf, const char *str);
|
|||||||
virBufferAdd(buf_, "" literal_string_ "", sizeof(literal_string_) - 1)
|
virBufferAdd(buf_, "" literal_string_ "", sizeof(literal_string_) - 1)
|
||||||
|
|
||||||
void virBufferAdjustIndent(virBufferPtr buf, int indent);
|
void virBufferAdjustIndent(virBufferPtr buf, int indent);
|
||||||
int virBufferGetIndent(const virBufferPtr buf, bool dynamic);
|
int virBufferGetIndent(const virBuffer *buf, bool dynamic);
|
||||||
|
|
||||||
void virBufferTrim(virBufferPtr buf, const char *trim, int len);
|
void virBufferTrim(virBufferPtr buf, const char *trim, int len);
|
||||||
|
|
||||||
|
@ -449,7 +449,7 @@ ebtablesForwardAllowIn(ebtablesContext *ctx,
|
|||||||
int
|
int
|
||||||
ebtablesAddForwardAllowIn(ebtablesContext *ctx,
|
ebtablesAddForwardAllowIn(ebtablesContext *ctx,
|
||||||
const char *iface,
|
const char *iface,
|
||||||
const virMacAddrPtr mac)
|
const virMacAddr *mac)
|
||||||
{
|
{
|
||||||
char macaddr[VIR_MAC_STRING_BUFLEN];
|
char macaddr[VIR_MAC_STRING_BUFLEN];
|
||||||
|
|
||||||
@ -472,7 +472,7 @@ ebtablesAddForwardAllowIn(ebtablesContext *ctx,
|
|||||||
int
|
int
|
||||||
ebtablesRemoveForwardAllowIn(ebtablesContext *ctx,
|
ebtablesRemoveForwardAllowIn(ebtablesContext *ctx,
|
||||||
const char *iface,
|
const char *iface,
|
||||||
const virMacAddrPtr mac)
|
const virMacAddr *mac)
|
||||||
{
|
{
|
||||||
char macaddr[VIR_MAC_STRING_BUFLEN];
|
char macaddr[VIR_MAC_STRING_BUFLEN];
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* virebtables.c: Helper APIs for managing ebtables
|
* virebtables.c: Helper APIs for managing ebtables
|
||||||
*
|
*
|
||||||
|
* Copyright (C) 2007-2008, 2013 Red Hat, Inc.
|
||||||
* Copyright (C) 2009 IBM Corp.
|
* Copyright (C) 2009 IBM Corp.
|
||||||
* Copyright (C) 2007, 2008 Red Hat, Inc.
|
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -54,10 +54,10 @@ void ebtablesSaveRules (ebtablesContext *ctx);
|
|||||||
|
|
||||||
int ebtablesAddForwardAllowIn (ebtablesContext *ctx,
|
int ebtablesAddForwardAllowIn (ebtablesContext *ctx,
|
||||||
const char *iface,
|
const char *iface,
|
||||||
const virMacAddrPtr mac);
|
const virMacAddr *mac);
|
||||||
int ebtablesRemoveForwardAllowIn (ebtablesContext *ctx,
|
int ebtablesRemoveForwardAllowIn (ebtablesContext *ctx,
|
||||||
const char *iface,
|
const char *iface,
|
||||||
const virMacAddrPtr mac);
|
const virMacAddr *mac);
|
||||||
|
|
||||||
int ebtablesAddForwardPolicyReject(ebtablesContext *ctx);
|
int ebtablesAddForwardPolicyReject(ebtablesContext *ctx);
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* virmacaddr.c: MAC address handling
|
* virmacaddr.c: MAC address handling
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2012 Red Hat, Inc.
|
* Copyright (C) 2006-2013 Red Hat, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -74,7 +74,7 @@ virMacAddrCompare(const char *p, const char *q)
|
|||||||
* > 0 if mac1 > mac2
|
* > 0 if mac1 > mac2
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virMacAddrCmp(const virMacAddrPtr mac1, const virMacAddrPtr mac2)
|
virMacAddrCmp(const virMacAddr *mac1, const virMacAddr *mac2)
|
||||||
{
|
{
|
||||||
return memcmp(mac1->addr, mac2->addr, VIR_MAC_BUFLEN);
|
return memcmp(mac1->addr, mac2->addr, VIR_MAC_BUFLEN);
|
||||||
}
|
}
|
||||||
@ -89,7 +89,7 @@ virMacAddrCmp(const virMacAddrPtr mac1, const virMacAddrPtr mac2)
|
|||||||
* > 0 if mac1 > mac2
|
* > 0 if mac1 > mac2
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virMacAddrCmpRaw(const virMacAddrPtr mac1,
|
virMacAddrCmpRaw(const virMacAddr *mac1,
|
||||||
const unsigned char mac2[VIR_MAC_BUFLEN])
|
const unsigned char mac2[VIR_MAC_BUFLEN])
|
||||||
{
|
{
|
||||||
return memcmp(mac1->addr, mac2, VIR_MAC_BUFLEN);
|
return memcmp(mac1->addr, mac2, VIR_MAC_BUFLEN);
|
||||||
@ -103,7 +103,7 @@ virMacAddrCmpRaw(const virMacAddrPtr mac1,
|
|||||||
* Copy src to dst
|
* Copy src to dst
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
virMacAddrSet(virMacAddrPtr dst, const virMacAddrPtr src)
|
virMacAddrSet(virMacAddrPtr dst, const virMacAddr *src)
|
||||||
{
|
{
|
||||||
memcpy(dst, src, sizeof(*src));
|
memcpy(dst, src, sizeof(*src));
|
||||||
}
|
}
|
||||||
@ -129,7 +129,7 @@ virMacAddrSetRaw(virMacAddrPtr dst, const unsigned char src[VIR_MAC_BUFLEN])
|
|||||||
* Copies the MAC address into raw memory
|
* Copies the MAC address into raw memory
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
virMacAddrGetRaw(virMacAddrPtr src, unsigned char dst[VIR_MAC_BUFLEN])
|
virMacAddrGetRaw(const virMacAddr *src, unsigned char dst[VIR_MAC_BUFLEN])
|
||||||
{
|
{
|
||||||
memcpy(dst, src->addr, VIR_MAC_BUFLEN);
|
memcpy(dst, src->addr, VIR_MAC_BUFLEN);
|
||||||
}
|
}
|
||||||
@ -187,7 +187,7 @@ virMacAddrParse(const char* str, virMacAddrPtr addr)
|
|||||||
* Returns a pointer to the resulting character string.
|
* Returns a pointer to the resulting character string.
|
||||||
*/
|
*/
|
||||||
const char *
|
const char *
|
||||||
virMacAddrFormat(const virMacAddrPtr addr,
|
virMacAddrFormat(const virMacAddr *addr,
|
||||||
char *str)
|
char *str)
|
||||||
{
|
{
|
||||||
snprintf(str, VIR_MAC_STRING_BUFLEN,
|
snprintf(str, VIR_MAC_STRING_BUFLEN,
|
||||||
@ -211,13 +211,13 @@ void virMacAddrGenerate(const unsigned char prefix[VIR_MAC_PREFIX_BUFLEN],
|
|||||||
|
|
||||||
/* The low order bit of the first byte is the "multicast" bit. */
|
/* The low order bit of the first byte is the "multicast" bit. */
|
||||||
bool
|
bool
|
||||||
virMacAddrIsMulticast(const virMacAddrPtr mac)
|
virMacAddrIsMulticast(const virMacAddr *mac)
|
||||||
{
|
{
|
||||||
return !!(mac->addr[0] & 1);
|
return !!(mac->addr[0] & 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
virMacAddrIsUnicast(const virMacAddrPtr mac)
|
virMacAddrIsUnicast(const virMacAddr *mac)
|
||||||
{
|
{
|
||||||
return !(mac->addr[0] & 1);
|
return !(mac->addr[0] & 1);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* virmacaddr.h: MAC address handling
|
* virmacaddr.h: MAC address handling
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2012 Red Hat, Inc.
|
* Copyright (C) 2006-2013 Red Hat, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -38,20 +38,20 @@ struct _virMacAddr {
|
|||||||
};
|
};
|
||||||
|
|
||||||
int virMacAddrCompare(const char *mac1, const char *mac2);
|
int virMacAddrCompare(const char *mac1, const char *mac2);
|
||||||
int virMacAddrCmp(const virMacAddrPtr mac1, const virMacAddrPtr mac2);
|
int virMacAddrCmp(const virMacAddr *mac1, const virMacAddr *mac2);
|
||||||
int virMacAddrCmpRaw(const virMacAddrPtr mac1,
|
int virMacAddrCmpRaw(const virMacAddr *mac1,
|
||||||
const unsigned char s[VIR_MAC_BUFLEN]);
|
const unsigned char s[VIR_MAC_BUFLEN]);
|
||||||
void virMacAddrSet(virMacAddrPtr dst, const virMacAddrPtr src);
|
void virMacAddrSet(virMacAddrPtr dst, const virMacAddr *src);
|
||||||
void virMacAddrSetRaw(virMacAddrPtr dst, const unsigned char s[VIR_MAC_BUFLEN]);
|
void virMacAddrSetRaw(virMacAddrPtr dst, const unsigned char s[VIR_MAC_BUFLEN]);
|
||||||
void virMacAddrGetRaw(virMacAddrPtr src, unsigned char dst[VIR_MAC_BUFLEN]);
|
void virMacAddrGetRaw(const virMacAddr *src, unsigned char dst[VIR_MAC_BUFLEN]);
|
||||||
const char *virMacAddrFormat(const virMacAddrPtr addr,
|
const char *virMacAddrFormat(const virMacAddr *addr,
|
||||||
char *str);
|
char *str);
|
||||||
void virMacAddrGenerate(const unsigned char prefix[VIR_MAC_PREFIX_BUFLEN],
|
void virMacAddrGenerate(const unsigned char prefix[VIR_MAC_PREFIX_BUFLEN],
|
||||||
virMacAddrPtr addr);
|
virMacAddrPtr addr);
|
||||||
int virMacAddrParse(const char* str,
|
int virMacAddrParse(const char* str,
|
||||||
virMacAddrPtr addr) ATTRIBUTE_RETURN_CHECK;
|
virMacAddrPtr addr) ATTRIBUTE_RETURN_CHECK;
|
||||||
bool virMacAddrIsUnicast(const virMacAddrPtr addr);
|
bool virMacAddrIsUnicast(const virMacAddr *addr);
|
||||||
bool virMacAddrIsMulticast(const virMacAddrPtr addr);
|
bool virMacAddrIsMulticast(const virMacAddr *addr);
|
||||||
bool virMacAddrIsBroadcastRaw(const unsigned char s[VIR_MAC_BUFLEN]);
|
bool virMacAddrIsBroadcastRaw(const unsigned char s[VIR_MAC_BUFLEN]);
|
||||||
|
|
||||||
#endif /* __VIR_MACADDR_H__ */
|
#endif /* __VIR_MACADDR_H__ */
|
||||||
|
@ -40,11 +40,14 @@ typedef virSocketAddrIPv4 *virSocketAddrIPv4Ptr;
|
|||||||
typedef unsigned short virSocketAddrIPv6[8];
|
typedef unsigned short virSocketAddrIPv6[8];
|
||||||
typedef virSocketAddrIPv6 *virSocketAddrIPv6Ptr;
|
typedef virSocketAddrIPv6 *virSocketAddrIPv6Ptr;
|
||||||
|
|
||||||
static int virSocketAddrGetIPv4Addr(virSocketAddrPtr addr, virSocketAddrIPv4Ptr tab) {
|
static int
|
||||||
|
virSocketAddrGetIPv4Addr(const virSocketAddr *addr,
|
||||||
|
virSocketAddrIPv4Ptr tab)
|
||||||
|
{
|
||||||
unsigned long val;
|
unsigned long val;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if ((addr == NULL) || (tab == NULL) || (addr->data.stor.ss_family != AF_INET))
|
if (!addr || !tab || addr->data.stor.ss_family != AF_INET)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
val = ntohl(addr->data.inet4.sin_addr.s_addr);
|
val = ntohl(addr->data.inet4.sin_addr.s_addr);
|
||||||
@ -57,10 +60,12 @@ static int virSocketAddrGetIPv4Addr(virSocketAddrPtr addr, virSocketAddrIPv4Ptr
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int virSocketAddrGetIPv6Addr(virSocketAddrPtr addr, virSocketAddrIPv6Ptr tab) {
|
static int
|
||||||
|
virSocketAddrGetIPv6Addr(const virSocketAddr *addr, virSocketAddrIPv6Ptr tab)
|
||||||
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if ((addr == NULL) || (tab == NULL) || (addr->data.stor.ss_family != AF_INET6))
|
if (!addr || !tab || addr->data.stor.ss_family != AF_INET6)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
@ -188,7 +193,7 @@ virSocketAddrSetIPv4Addr(virSocketAddrPtr addr, uint32_t val)
|
|||||||
* if their IP addresses and ports are equal.
|
* if their IP addresses and ports are equal.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
virSocketAddrEqual(const virSocketAddrPtr s1, const virSocketAddrPtr s2)
|
virSocketAddrEqual(const virSocketAddr *s1, const virSocketAddr *s2)
|
||||||
{
|
{
|
||||||
if (s1->data.stor.ss_family != s2->data.stor.ss_family)
|
if (s1->data.stor.ss_family != s2->data.stor.ss_family)
|
||||||
return false;
|
return false;
|
||||||
@ -221,7 +226,7 @@ virSocketAddrEqual(const virSocketAddrPtr s1, const virSocketAddrPtr s2)
|
|||||||
* See RFC1918, RFC3484, and RFC4193 for details.
|
* See RFC1918, RFC3484, and RFC4193 for details.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
virSocketAddrIsPrivate(const virSocketAddrPtr addr)
|
virSocketAddrIsPrivate(const virSocketAddr *addr)
|
||||||
{
|
{
|
||||||
unsigned long val;
|
unsigned long val;
|
||||||
|
|
||||||
@ -248,7 +253,7 @@ virSocketAddrIsPrivate(const virSocketAddrPtr addr)
|
|||||||
* Check if passed address is a variant of ANYCAST address.
|
* Check if passed address is a variant of ANYCAST address.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
virSocketAddrIsWildcard(const virSocketAddrPtr addr)
|
virSocketAddrIsWildcard(const virSocketAddr *addr)
|
||||||
{
|
{
|
||||||
struct in_addr tmp = { .s_addr = INADDR_ANY };
|
struct in_addr tmp = { .s_addr = INADDR_ANY };
|
||||||
switch (addr->data.stor.ss_family) {
|
switch (addr->data.stor.ss_family) {
|
||||||
@ -270,7 +275,8 @@ virSocketAddrIsWildcard(const virSocketAddrPtr addr)
|
|||||||
* Caller must free the returned string
|
* Caller must free the returned string
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
virSocketAddrFormat(virSocketAddrPtr addr) {
|
virSocketAddrFormat(const virSocketAddr *addr)
|
||||||
|
{
|
||||||
return virSocketAddrFormatFull(addr, false, NULL);
|
return virSocketAddrFormatFull(addr, false, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,7 +292,7 @@ virSocketAddrFormat(virSocketAddrPtr addr) {
|
|||||||
* Caller must free the returned string
|
* Caller must free the returned string
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
virSocketAddrFormatFull(virSocketAddrPtr addr,
|
virSocketAddrFormatFull(const virSocketAddr *addr,
|
||||||
bool withService,
|
bool withService,
|
||||||
const char *separator)
|
const char *separator)
|
||||||
{
|
{
|
||||||
@ -414,8 +420,8 @@ int virSocketAddrIsNetmask(virSocketAddrPtr netmask) {
|
|||||||
* Returns 0 in case of success, or -1 on error.
|
* Returns 0 in case of success, or -1 on error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virSocketAddrMask(const virSocketAddrPtr addr,
|
virSocketAddrMask(const virSocketAddr *addr,
|
||||||
const virSocketAddrPtr netmask,
|
const virSocketAddr *netmask,
|
||||||
virSocketAddrPtr network)
|
virSocketAddrPtr network)
|
||||||
{
|
{
|
||||||
if (addr->data.stor.ss_family != netmask->data.stor.ss_family) {
|
if (addr->data.stor.ss_family != netmask->data.stor.ss_family) {
|
||||||
@ -460,7 +466,7 @@ virSocketAddrMask(const virSocketAddrPtr addr,
|
|||||||
* Returns 0 in case of success, or -1 on error.
|
* Returns 0 in case of success, or -1 on error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virSocketAddrMaskByPrefix(const virSocketAddrPtr addr,
|
virSocketAddrMaskByPrefix(const virSocketAddr *addr,
|
||||||
unsigned int prefix,
|
unsigned int prefix,
|
||||||
virSocketAddrPtr network)
|
virSocketAddrPtr network)
|
||||||
{
|
{
|
||||||
@ -487,8 +493,8 @@ virSocketAddrMaskByPrefix(const virSocketAddrPtr addr,
|
|||||||
* Returns 0 in case of success, or -1 on error.
|
* Returns 0 in case of success, or -1 on error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virSocketAddrBroadcast(const virSocketAddrPtr addr,
|
virSocketAddrBroadcast(const virSocketAddr *addr,
|
||||||
const virSocketAddrPtr netmask,
|
const virSocketAddr *netmask,
|
||||||
virSocketAddrPtr broadcast)
|
virSocketAddrPtr broadcast)
|
||||||
{
|
{
|
||||||
if ((addr->data.stor.ss_family != AF_INET) ||
|
if ((addr->data.stor.ss_family != AF_INET) ||
|
||||||
@ -517,7 +523,7 @@ virSocketAddrBroadcast(const virSocketAddrPtr addr,
|
|||||||
* Returns 0 in case of success, or -1 on error.
|
* Returns 0 in case of success, or -1 on error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virSocketAddrBroadcastByPrefix(const virSocketAddrPtr addr,
|
virSocketAddrBroadcastByPrefix(const virSocketAddr *addr,
|
||||||
unsigned int prefix,
|
unsigned int prefix,
|
||||||
virSocketAddrPtr broadcast)
|
virSocketAddrPtr broadcast)
|
||||||
{
|
{
|
||||||
@ -654,7 +660,7 @@ int virSocketAddrGetRange(virSocketAddrPtr start, virSocketAddrPtr end) {
|
|||||||
* Returns the number of bits in the netmask or -1 if an error occurred
|
* Returns the number of bits in the netmask or -1 if an error occurred
|
||||||
* or the netmask is invalid.
|
* or the netmask is invalid.
|
||||||
*/
|
*/
|
||||||
int virSocketAddrGetNumNetmaskBits(const virSocketAddrPtr netmask)
|
int virSocketAddrGetNumNetmaskBits(const virSocketAddr *netmask)
|
||||||
{
|
{
|
||||||
size_t i, j;
|
size_t i, j;
|
||||||
int c = 0;
|
int c = 0;
|
||||||
@ -801,8 +807,8 @@ error:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
int
|
||||||
virSocketAddrGetIpPrefix(const virSocketAddrPtr address,
|
virSocketAddrGetIpPrefix(const virSocketAddr *address,
|
||||||
const virSocketAddrPtr netmask,
|
const virSocketAddr *netmask,
|
||||||
int prefix)
|
int prefix)
|
||||||
{
|
{
|
||||||
if (prefix > 0) {
|
if (prefix > 0) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2009-2012 Red Hat, Inc.
|
* Copyright (C) 2009-2013 Red Hat, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -80,10 +80,10 @@ int virSocketAddrParseIPv4(virSocketAddrPtr addr,
|
|||||||
int virSocketAddrParseIPv6(virSocketAddrPtr addr,
|
int virSocketAddrParseIPv6(virSocketAddrPtr addr,
|
||||||
const char *val);
|
const char *val);
|
||||||
|
|
||||||
void virSocketAddrSetIPv4Addr(const virSocketAddrPtr s, uint32_t addr);
|
void virSocketAddrSetIPv4Addr(virSocketAddrPtr s, uint32_t addr);
|
||||||
|
|
||||||
char * virSocketAddrFormat(virSocketAddrPtr addr);
|
char *virSocketAddrFormat(const virSocketAddr *addr);
|
||||||
char * virSocketAddrFormatFull(virSocketAddrPtr addr,
|
char *virSocketAddrFormatFull(const virSocketAddr *addr,
|
||||||
bool withService,
|
bool withService,
|
||||||
const char *separator);
|
const char *separator);
|
||||||
|
|
||||||
@ -99,31 +99,31 @@ int virSocketAddrIsNetmask(virSocketAddrPtr netmask);
|
|||||||
int virSocketAddrCheckNetmask(virSocketAddrPtr addr1,
|
int virSocketAddrCheckNetmask(virSocketAddrPtr addr1,
|
||||||
virSocketAddrPtr addr2,
|
virSocketAddrPtr addr2,
|
||||||
virSocketAddrPtr netmask);
|
virSocketAddrPtr netmask);
|
||||||
int virSocketAddrMask(const virSocketAddrPtr addr,
|
int virSocketAddrMask(const virSocketAddr *addr,
|
||||||
const virSocketAddrPtr netmask,
|
const virSocketAddr *netmask,
|
||||||
virSocketAddrPtr network);
|
virSocketAddrPtr network);
|
||||||
int virSocketAddrMaskByPrefix(const virSocketAddrPtr addr,
|
int virSocketAddrMaskByPrefix(const virSocketAddr *addr,
|
||||||
unsigned int prefix,
|
unsigned int prefix,
|
||||||
virSocketAddrPtr network);
|
virSocketAddrPtr network);
|
||||||
int virSocketAddrBroadcast(const virSocketAddrPtr addr,
|
int virSocketAddrBroadcast(const virSocketAddr *addr,
|
||||||
const virSocketAddrPtr netmask,
|
const virSocketAddr *netmask,
|
||||||
virSocketAddrPtr broadcast);
|
virSocketAddrPtr broadcast);
|
||||||
int virSocketAddrBroadcastByPrefix(const virSocketAddrPtr addr,
|
int virSocketAddrBroadcastByPrefix(const virSocketAddr *addr,
|
||||||
unsigned int prefix,
|
unsigned int prefix,
|
||||||
virSocketAddrPtr broadcast);
|
virSocketAddrPtr broadcast);
|
||||||
|
|
||||||
int virSocketAddrGetNumNetmaskBits(const virSocketAddrPtr netmask);
|
int virSocketAddrGetNumNetmaskBits(const virSocketAddr *netmask);
|
||||||
int virSocketAddrPrefixToNetmask(unsigned int prefix,
|
int virSocketAddrPrefixToNetmask(unsigned int prefix,
|
||||||
virSocketAddrPtr netmask,
|
virSocketAddrPtr netmask,
|
||||||
int family);
|
int family);
|
||||||
int virSocketAddrGetIpPrefix(const virSocketAddrPtr address,
|
int virSocketAddrGetIpPrefix(const virSocketAddr *address,
|
||||||
const virSocketAddrPtr netmask,
|
const virSocketAddr *netmask,
|
||||||
int prefix);
|
int prefix);
|
||||||
bool virSocketAddrEqual(const virSocketAddrPtr s1,
|
bool virSocketAddrEqual(const virSocketAddr *s1,
|
||||||
const virSocketAddrPtr s2);
|
const virSocketAddr *s2);
|
||||||
bool virSocketAddrIsPrivate(const virSocketAddrPtr addr);
|
bool virSocketAddrIsPrivate(const virSocketAddr *addr);
|
||||||
|
|
||||||
bool virSocketAddrIsWildcard(const virSocketAddrPtr addr);
|
bool virSocketAddrIsWildcard(const virSocketAddr *addr);
|
||||||
|
|
||||||
bool virSocketAddrIsNumeric(const char *address);
|
bool virSocketAddrIsNumeric(const char *address);
|
||||||
#endif /* __VIR_SOCKETADDR_H__ */
|
#endif /* __VIR_SOCKETADDR_H__ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user