virmacaddr.h 2.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
/*
 * virmacaddr.h: MAC address handling
 *
 * Copyright (C) 2006-2012 Red Hat, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
 *
 * Authors:
 *     Daniel P. Berrange <berrange@redhat.com>
 */

#ifndef __VIR_MACADDR_H__
# define __VIR_MACADDR_H__

# include "internal.h"

# define VIR_MAC_BUFLEN 6
# define VIR_MAC_PREFIX_BUFLEN 3
S
Stefan Berger 已提交
31 32
# define VIR_MAC_STRING_BUFLEN (VIR_MAC_BUFLEN * 3)

33 34 35 36 37 38
typedef struct _virMacAddr virMacAddr;
typedef virMacAddr *virMacAddrPtr;

struct _virMacAddr {
    unsigned char addr[VIR_MAC_BUFLEN];
};
39 40

int virMacAddrCompare(const char *mac1, const char *mac2);
41 42 43 44 45 46 47
int virMacAddrCmp(const virMacAddrPtr mac1, const virMacAddrPtr mac2);
int virMacAddrCmpRaw(const virMacAddrPtr mac1,
                     const unsigned char s[VIR_MAC_BUFLEN]);
void virMacAddrSet(virMacAddrPtr dst, const virMacAddrPtr src);
void virMacAddrSetRaw(virMacAddrPtr dst, const unsigned char s[VIR_MAC_BUFLEN]);
void virMacAddrGetRaw(virMacAddrPtr src, unsigned char dst[VIR_MAC_BUFLEN]);
void virMacAddrFormat(const virMacAddrPtr addr,
48
                      char *str);
49 50
void virMacAddrGenerate(const unsigned char prefix[VIR_MAC_PREFIX_BUFLEN],
                        virMacAddrPtr addr);
51
int virMacAddrParse(const char* str,
52 53 54
                    virMacAddrPtr addr) ATTRIBUTE_RETURN_CHECK;
bool virMacAddrIsUnicast(const virMacAddrPtr addr);
bool virMacAddrIsMulticast(const virMacAddrPtr addr);
55
#endif /* __VIR_MACADDR_H__ */