net: add MAC address string printer
We can use this in virtio-net code as well as new Rocker driver code, so up-level this. Signed-off-by: Scott Feldman <sfeldma@gmail.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-id: 1426306173-24884-2-git-send-email-sfeldma@gmail.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
b951cda21d
commit
890ee6abb3
@ -97,6 +97,7 @@ typedef struct NICState {
|
|||||||
bool peer_deleted;
|
bool peer_deleted;
|
||||||
} NICState;
|
} NICState;
|
||||||
|
|
||||||
|
char *qemu_mac_strdup_printf(const uint8_t *macaddr);
|
||||||
NetClientState *qemu_find_netdev(const char *id);
|
NetClientState *qemu_find_netdev(const char *id);
|
||||||
int qemu_find_net_clients_except(const char *id, NetClientState **ncs,
|
int qemu_find_net_clients_except(const char *id, NetClientState **ncs,
|
||||||
NetClientOptionsKind type, int max);
|
NetClientOptionsKind type, int max);
|
||||||
|
@ -151,6 +151,13 @@ int parse_host_port(struct sockaddr_in *saddr, const char *str)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *qemu_mac_strdup_printf(const uint8_t *macaddr)
|
||||||
|
{
|
||||||
|
return g_strdup_printf("%.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
|
||||||
|
macaddr[0], macaddr[1], macaddr[2],
|
||||||
|
macaddr[3], macaddr[4], macaddr[5]);
|
||||||
|
}
|
||||||
|
|
||||||
void qemu_format_nic_info_str(NetClientState *nc, uint8_t macaddr[6])
|
void qemu_format_nic_info_str(NetClientState *nc, uint8_t macaddr[6])
|
||||||
{
|
{
|
||||||
snprintf(nc->info_str, sizeof(nc->info_str),
|
snprintf(nc->info_str, sizeof(nc->info_str),
|
||||||
|
Loading…
Reference in New Issue
Block a user