|  | @@ -32,6 +32,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
 | 
		
	
		
			
			| 32 | 32 |  #include <ipxe/dhcp.h>
 | 
		
	
		
			
			| 33 | 33 |  #include <ipxe/uuid.h>
 | 
		
	
		
			
			| 34 | 34 |  #include <ipxe/uri.h>
 | 
		
	
		
			
			|  | 35 | +#include <ipxe/base16.h>
 | 
		
	
		
			
			| 35 | 36 |  #include <ipxe/init.h>
 | 
		
	
		
			
			| 36 | 37 |  #include <ipxe/settings.h>
 | 
		
	
		
			
			| 37 | 38 |  
 | 
		
	
	
		
			
			|  | @@ -1685,37 +1686,6 @@ struct setting_type setting_type_uint32 __setting_type = {
 | 
		
	
		
			
			| 1685 | 1686 |  	.format = format_uint_setting,
 | 
		
	
		
			
			| 1686 | 1687 |  };
 | 
		
	
		
			
			| 1687 | 1688 |  
 | 
		
	
		
			
			| 1688 |  | -/**
 | 
		
	
		
			
			| 1689 |  | - * Parse hex string setting value
 | 
		
	
		
			
			| 1690 |  | - *
 | 
		
	
		
			
			| 1691 |  | - * @v value		Formatted setting value
 | 
		
	
		
			
			| 1692 |  | - * @v buf		Buffer to contain raw value
 | 
		
	
		
			
			| 1693 |  | - * @v len		Length of buffer
 | 
		
	
		
			
			| 1694 |  | - * @ret len		Length of raw value, or negative error
 | 
		
	
		
			
			| 1695 |  | - */
 | 
		
	
		
			
			| 1696 |  | -static int parse_hex_setting ( const char *value, void *buf, size_t len ) {
 | 
		
	
		
			
			| 1697 |  | -	char *ptr = ( char * ) value;
 | 
		
	
		
			
			| 1698 |  | -	uint8_t *bytes = buf;
 | 
		
	
		
			
			| 1699 |  | -	unsigned int count = 0;
 | 
		
	
		
			
			| 1700 |  | -	uint8_t byte;
 | 
		
	
		
			
			| 1701 |  | -
 | 
		
	
		
			
			| 1702 |  | -	while ( 1 ) {
 | 
		
	
		
			
			| 1703 |  | -		byte = strtoul ( ptr, &ptr, 16 );
 | 
		
	
		
			
			| 1704 |  | -		if ( count++ < len )
 | 
		
	
		
			
			| 1705 |  | -			*bytes++ = byte;
 | 
		
	
		
			
			| 1706 |  | -		switch ( *ptr ) {
 | 
		
	
		
			
			| 1707 |  | -		case '\0' :
 | 
		
	
		
			
			| 1708 |  | -			return count;
 | 
		
	
		
			
			| 1709 |  | -		case ':' :
 | 
		
	
		
			
			| 1710 |  | -		case '-' :
 | 
		
	
		
			
			| 1711 |  | -			ptr++;
 | 
		
	
		
			
			| 1712 |  | -			break;
 | 
		
	
		
			
			| 1713 |  | -		default :
 | 
		
	
		
			
			| 1714 |  | -			return -EINVAL;
 | 
		
	
		
			
			| 1715 |  | -		}
 | 
		
	
		
			
			| 1716 |  | -	}
 | 
		
	
		
			
			| 1717 |  | -}
 | 
		
	
		
			
			| 1718 |  | -
 | 
		
	
		
			
			| 1719 | 1689 |  /**
 | 
		
	
		
			
			| 1720 | 1690 |   * Format hex string setting value
 | 
		
	
		
			
			| 1721 | 1691 |   *
 | 
		
	
	
		
			
			|  | @@ -1742,6 +1712,19 @@ static int format_hex_setting ( const void *raw, size_t raw_len, char *buf,
 | 
		
	
		
			
			| 1742 | 1712 |  	return used;
 | 
		
	
		
			
			| 1743 | 1713 |  }
 | 
		
	
		
			
			| 1744 | 1714 |  
 | 
		
	
		
			
			|  | 1715 | +/**
 | 
		
	
		
			
			|  | 1716 | + * Parse hex string setting value (using colon delimiter)
 | 
		
	
		
			
			|  | 1717 | + *
 | 
		
	
		
			
			|  | 1718 | + * @v value		Formatted setting value
 | 
		
	
		
			
			|  | 1719 | + * @v buf		Buffer to contain raw value
 | 
		
	
		
			
			|  | 1720 | + * @v len		Length of buffer
 | 
		
	
		
			
			|  | 1721 | + * @v size		Integer size, in bytes
 | 
		
	
		
			
			|  | 1722 | + * @ret len		Length of raw value, or negative error
 | 
		
	
		
			
			|  | 1723 | + */
 | 
		
	
		
			
			|  | 1724 | +static int parse_hex_setting ( const char *value, void *buf, size_t len ) {
 | 
		
	
		
			
			|  | 1725 | +	return hex_decode ( value, ':', buf, len );
 | 
		
	
		
			
			|  | 1726 | +}
 | 
		
	
		
			
			|  | 1727 | +
 | 
		
	
		
			
			| 1745 | 1728 |  /**
 | 
		
	
		
			
			| 1746 | 1729 |   * Format hex string setting value (using colon delimiter)
 | 
		
	
		
			
			| 1747 | 1730 |   *
 | 
		
	
	
		
			
			|  | @@ -1756,6 +1739,20 @@ static int format_hex_colon_setting ( const void *raw, size_t raw_len,
 | 
		
	
		
			
			| 1756 | 1739 |  	return format_hex_setting ( raw, raw_len, buf, len, ":" );
 | 
		
	
		
			
			| 1757 | 1740 |  }
 | 
		
	
		
			
			| 1758 | 1741 |  
 | 
		
	
		
			
			|  | 1742 | +/**
 | 
		
	
		
			
			|  | 1743 | + * Parse hex string setting value (using hyphen delimiter)
 | 
		
	
		
			
			|  | 1744 | + *
 | 
		
	
		
			
			|  | 1745 | + * @v value		Formatted setting value
 | 
		
	
		
			
			|  | 1746 | + * @v buf		Buffer to contain raw value
 | 
		
	
		
			
			|  | 1747 | + * @v len		Length of buffer
 | 
		
	
		
			
			|  | 1748 | + * @v size		Integer size, in bytes
 | 
		
	
		
			
			|  | 1749 | + * @ret len		Length of raw value, or negative error
 | 
		
	
		
			
			|  | 1750 | + */
 | 
		
	
		
			
			|  | 1751 | +static int parse_hex_hyphen_setting ( const char *value, void *buf,
 | 
		
	
		
			
			|  | 1752 | +				      size_t len ) {
 | 
		
	
		
			
			|  | 1753 | +	return hex_decode ( value, '-', buf, len );
 | 
		
	
		
			
			|  | 1754 | +}
 | 
		
	
		
			
			|  | 1755 | +
 | 
		
	
		
			
			| 1759 | 1756 |  /**
 | 
		
	
		
			
			| 1760 | 1757 |   * Format hex string setting value (using hyphen delimiter)
 | 
		
	
		
			
			| 1761 | 1758 |   *
 | 
		
	
	
		
			
			|  | @@ -1780,7 +1777,7 @@ struct setting_type setting_type_hex __setting_type = {
 | 
		
	
		
			
			| 1780 | 1777 |  /** A hex-string setting (hyphen-delimited) */
 | 
		
	
		
			
			| 1781 | 1778 |  struct setting_type setting_type_hexhyp __setting_type = {
 | 
		
	
		
			
			| 1782 | 1779 |  	.name = "hexhyp",
 | 
		
	
		
			
			| 1783 |  | -	.parse = parse_hex_setting,
 | 
		
	
		
			
			|  | 1780 | +	.parse = parse_hex_hyphen_setting,
 | 
		
	
		
			
			| 1784 | 1781 |  	.format = format_hex_hyphen_setting,
 | 
		
	
		
			
			| 1785 | 1782 |  };
 | 
		
	
		
			
			| 1786 | 1783 |  
 |