/**
* virNetworkGetDHCPLeases:
* @network: pointer to network object
* @macaddr: MAC Address of an interface
* @leases: pointer to an array of structs which will hold the leases
* @nleases: number of leases in output
* @flags: extra flags, not used yet, so callers should always pass 0
*
* The API returns the leases of all interfaces by default, and if
* @macaddr is specified,.only the lease of the interface which
* matches the @macaddr is returned.
*
* Returns number of leases on success, -1 otherwise
*/
int virNetworkGetDHCPLeases(virNetworkPtr network,
const char *macaddr,
virNetworkDHCPLeasesPtr *leases,
int *nleases,
unsigned int flags);
Structs to be used:
struct _virNetworkDHCPLeases {
long long expirytime;
char *macaddr;
char *ipaddr;
char *hostname;
char *clientid;
};
/*In src/remote/remote_protocol.x*/
struct remote_network_dhcp_leases {
hyper expirytime;
remote_nonnull_string macaddr;
remote_nonnull_string ipaddr;
remote_nonnull_string hostname;
remote_nonnull_string clientid;
};
struct remote_network_get_dhcp_leases_args {
remote_nonnull_network net;
remote_string macaddr;
unsigned int flags;
};
struct remote_network_get_dhcp_leases_ret {
remote_network_dhcp_leases leases<>;
};
The following two blocks are required more than one, so should
we be introducing helper functions for them?
if ((VIR_STRDUP((*leases)[0].macaddr, leaseparams[1]) < 0) ||
(VIR_STRDUP((*leases)[0].ipaddr, leaseparams[2]) < 0) ||
(VIR_STRDUP((*leases)[0].hostname, leaseparams[3]) < 0) ||
(VIR_STRDUP((*leases)[0].clientid, leaseparams[4]) < 0))
goto cleanup;
for (i = 0; i < nleases; i++) {
VIR_FREE(leases[i].macaddr);
VIR_FREE(leases[i].ipaddr);
VIR_FREE(leases[i].hostname);
VIR_FREE(leases[i].clientid);
}
--
Nehal J. Wani
UG3, BTech CS+MS(CL)
IIIT-Hyderabad
http://commandlinewani.blogspot.com