Commit 76ea08f970e558a99b2c5fd05bc4f4da87dfbc93

Authored by balrog
1 parent ffe8ab83

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
Showing 1 changed file with 26 additions and 11 deletions
... ... @@ -235,7 +235,7 @@ char drives_opt[MAX_DRIVES][1024];
235 235  
236 236 static CPUState *cur_cpu;
237 237 static CPUState *next_cpu;
238   -static int event_pending;
  238 +static int event_pending = 1;
239 239  
240 240 #define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
241 241  
... ... @@ -3453,18 +3453,33 @@ static void hex_dump(FILE *f, const uint8_t *buf, int size)
3453 3453 static int parse_macaddr(uint8_t *macaddr, const char *p)
3454 3454 {
3455 3455 int i;
3456   - for(i = 0; i < 6; i++) {
3457   - macaddr[i] = strtol(p, (char **)&p, 16);
3458   - if (i == 5) {
3459   - if (*p != '\0')
3460   - return -1;
3461   - } else {
3462   - if (*p != ':')
3463   - return -1;
3464   - p++;
  3456 + char *last_char;
  3457 + long int offset;
  3458 +
  3459 + errno = 0;
  3460 + offset = strtol(p, &last_char, 0);
  3461 + if (0 == errno && '\0' == *last_char &&
  3462 + offset >= 0 && offset <= 0xFFFFFF) {
  3463 + macaddr[3] = (offset & 0xFF0000) >> 16;
  3464 + macaddr[4] = (offset & 0xFF00) >> 8;
  3465 + macaddr[5] = offset & 0xFF;
  3466 + return 0;
  3467 + } else {
  3468 + for(i = 0; i < 6; i++) {
  3469 + macaddr[i] = strtol(p, (char **)&p, 16);
  3470 + if (i == 5) {
  3471 + if (*p != '\0')
  3472 + return -1;
  3473 + } else {
  3474 + if (*p != ':' && *p != '-')
  3475 + return -1;
  3476 + p++;
  3477 + }
3465 3478 }
  3479 + return 0;
3466 3480 }
3467   - return 0;
  3481 +
  3482 + return -1;
3468 3483 }
3469 3484  
3470 3485 static int get_str_sep(char *buf, int buf_size, const char **pp, int sep)
... ...