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:
		
							parent
							
								
									ffe8ab83da
								
							
						
					
					
						commit
						76ea08f970
					
				
							
								
								
									
										19
									
								
								vl.c
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								vl.c
									
									
									
									
									
								
							@ -235,7 +235,7 @@ char drives_opt[MAX_DRIVES][1024];
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static CPUState *cur_cpu;
 | 
					static CPUState *cur_cpu;
 | 
				
			||||||
static CPUState *next_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)
 | 
					#define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -3453,18 +3453,33 @@ static void hex_dump(FILE *f, const uint8_t *buf, int size)
 | 
				
			|||||||
static int parse_macaddr(uint8_t *macaddr, const char *p)
 | 
					static int parse_macaddr(uint8_t *macaddr, const char *p)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int i;
 | 
					    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++) {
 | 
					        for(i = 0; i < 6; i++) {
 | 
				
			||||||
            macaddr[i] = strtol(p, (char **)&p, 16);
 | 
					            macaddr[i] = strtol(p, (char **)&p, 16);
 | 
				
			||||||
            if (i == 5) {
 | 
					            if (i == 5) {
 | 
				
			||||||
                if (*p != '\0')
 | 
					                if (*p != '\0')
 | 
				
			||||||
                    return -1;
 | 
					                    return -1;
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
            if (*p != ':')
 | 
					                if (*p != ':' && *p != '-')
 | 
				
			||||||
                    return -1;
 | 
					                    return -1;
 | 
				
			||||||
                p++;
 | 
					                p++;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return 0;    
 | 
					        return 0;    
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return -1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int get_str_sep(char *buf, int buf_size, const char **pp, int sep)
 | 
					static int get_str_sep(char *buf, int buf_size, const char **pp, int sep)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user