[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCHv3 1/4] net-dhcp-leases: Implement the public APIs



On Mon, Sep 16, 2013 at 11:19:13AM +0530, Nehal J Wani wrote:
> +int
> +virNetworkGetDHCPLeasesForMAC(virNetworkPtr network,
> +                              const char *mac,
> +                              virNetworkDHCPLeasesPtr **leases,
> +                              unsigned int flags)
> +{
> +    virConnectPtr conn;
> +    virMacAddr addr;
> +
> +    VIR_DEBUG("network=%p, mac=%s, leases=%p, flags=%x",
> +               network, mac, leases, flags);
> +
> +    virResetLastError();
> +
> +    virCheckNonNullArgGoto(network, error);
> +    virCheckNonNullArgGoto(mac, error);
> +
> +    if (leases)
> +        *leases = NULL;
> +
> +    if (!VIR_IS_CONNECTED_NETWORK(network)) {
> +        virLibNetworkError(VIR_ERR_INVALID_NETWORK, __FUNCTION__);
> +        virDispatchError(NULL);
> +        return -1;
> +    }
> +
> +    /* Validate the MAC address */
> +    if (mac && virMacAddrParse(mac, &addr) < 0) {
> +        virReportInvalidArg(mac,
> +                            _("Given MAC Address doesn't comply "
> +                              "with the standard (IEEE 802) format in %s"),
> +                            __FUNCTION__);

Don't pass __FUNCTION__ in this error message - that is already done automatically

> +        goto error;
> +    }

'mac' should be a mandatory parameter here.

> +
> +    conn = network->conn;
> +
> +    if (conn->networkDriver &&
> +        conn->networkDriver->networkGetDHCPLeasesForMAC) {
> +        int ret;
> +        ret = conn->networkDriver->networkGetDHCPLeasesForMAC(network, mac,
> +                                                              leases, flags);
> +        if (ret < 0)
> +            goto error;
> +        return ret;
> +    }
> +
> +    virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
> +
> +error:
> +    virDispatchError(network->conn);
> +    return -1;
> +}

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]