Support alternative formats for MAC addresses, by Balazs Attila-Mihaly.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3817 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
balrog 2007-12-16 11:48:54 +00:00
parent ffe8ab83da
commit 76ea08f970

19
vl.c
View File

@ -235,7 +235,7 @@ char drives_opt[MAX_DRIVES][1024];
static CPUState *cur_cpu;
static CPUState *next_cpu;
static int event_pending;
static int event_pending = 1;
#define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
@ -3453,13 +3453,25 @@ static void hex_dump(FILE *f, const uint8_t *buf, int size)
static int parse_macaddr(uint8_t *macaddr, const char *p)
{
int i;
char *last_char;
long int offset;
errno = 0;
offset = strtol(p, &last_char, 0);
if (0 == errno && '\0' == *last_char &&
offset >= 0 && offset <= 0xFFFFFF) {
macaddr[3] = (offset & 0xFF0000) >> 16;
macaddr[4] = (offset & 0xFF00) >> 8;
macaddr[5] = offset & 0xFF;
return 0;
} else {
for(i = 0; i < 6; i++) {
macaddr[i] = strtol(p, (char **)&p, 16);
if (i == 5) {
if (*p != '\0')
return -1;
} else {
if (*p != ':')
if (*p != ':' && *p != '-')
return -1;
p++;
}
@ -3467,6 +3479,9 @@ static int parse_macaddr(uint8_t *macaddr, const char *p)
return 0;
}
return -1;
}
static int get_str_sep(char *buf, int buf_size, const char **pp, int sep)
{
const char *p, *p1;