ACK: [PATCH v2] uefi: uefidump: dumping the new definitions for ipv4 ipv6 device path (LP: #1311538)

Alex Hung alex.hung at canonical.com
Mon Apr 28 03:25:05 UTC 2014


On 04/23/2014 06:35 PM, Ivan Hu wrote:
> The definitions, GatewayIPAddress, Subnet Mask have been added to Ipv4 device path
> structure and PrefixLength, GatewayIPAddress have been added to Ipv6 device path
> structure on UEFI spec 2.2. Add to dump these information on uefidump tool.
>
> This patch also fix the woring dumping size for ipv6 device path.
>
> Signed-off-by: Ivan Hu <ivan.hu at canonical.com>
> ---
>   src/lib/include/fwts_uefi.h  |   24 ++++++++++++++++++++++++
>   src/uefi/uefidump/uefidump.c |   42 ++++++++++++++++++++++++++++++++++--------
>   2 files changed, 58 insertions(+), 8 deletions(-)
>
> diff --git a/src/lib/include/fwts_uefi.h b/src/lib/include/fwts_uefi.h
> index ebb5bad..1a15d8e 100644
> --- a/src/lib/include/fwts_uefi.h
> +++ b/src/lib/include/fwts_uefi.h
> @@ -366,6 +366,18 @@ typedef struct {
>
>   typedef struct {
>   	fwts_uefi_dev_path dev_path;
> +  	fwts_uefi_ipv4_addr local_ip_addr;
> +  	fwts_uefi_ipv4_addr remote_ip_addr;
> +  	uint16_t local_port;
> +  	uint16_t remote_port;
> +  	uint16_t protocol;
> +  	uint8_t static_ip_address;
> +  	fwts_uefi_ipv4_addr gateway_ip_addr;
> +  	fwts_uefi_ipv4_addr subnet_mask;
> +} __attribute__((packed)) fwts_uefi_ipv4_dev_path_v2;
> +
> +typedef struct {
> +	fwts_uefi_dev_path dev_path;
>     	fwts_uefi_ipv6_addr local_ip_addr;
>     	fwts_uefi_ipv6_addr remote_ip_addr;
>     	uint16_t local_port;
> @@ -376,6 +388,18 @@ typedef struct {
>
>   typedef struct {
>   	fwts_uefi_dev_path dev_path;
> +  	fwts_uefi_ipv6_addr local_ip_addr;
> +  	fwts_uefi_ipv6_addr remote_ip_addr;
> +  	uint16_t local_port;
> +  	uint16_t remote_port;
> +  	uint16_t protocol;
> +  	uint8_t ip_address_origin;
> +	uint8_t prefix_length;
> +  	fwts_uefi_ipv6_addr gateway_ip_addr;
> +} __attribute__((packed)) fwts_uefi_ipv6_dev_path_v2;
> +
> +typedef struct {
> +	fwts_uefi_dev_path dev_path;
>   	uint32_t resource_flags;
>   	uint8_t port_gid[16];
>   	uint64_t remote_id;
> diff --git a/src/uefi/uefidump/uefidump.c b/src/uefi/uefidump/uefidump.c
> index 50d47e1..d0d7804 100644
> --- a/src/uefi/uefidump/uefidump.c
> +++ b/src/uefi/uefidump/uefidump.c
> @@ -273,28 +273,41 @@ static char *uefidump_build_dev_path(char *path, fwts_uefi_dev_path *dev_path, c
>   			break;
>   		case FWTS_UEFI_IPV4_DEVICE_PATH_SUBTYPE:
>   			if (dev_path_len >= sizeof(fwts_uefi_ipv4_dev_path)) {
> -				fwts_uefi_ipv4_dev_path *i = (fwts_uefi_ipv4_dev_path*)dev_path;
> +				fwts_uefi_ipv4_dev_path *i = (fwts_uefi_ipv4_dev_path *)dev_path;
> +				uint16_t len = i->dev_path.length[0] | (((uint16_t)i->dev_path.length[1]) << 8);
>   				path = uefidump_vprintf(path, "\\IPv4("
>   					"%" PRIu8 ".%" PRIu8 ".%" PRIu8 ".%" PRIu8 ","
>   					"%" PRIu8 ".%" PRIu8 ".%" PRIu8 ".%" PRIu8 ","
> -					"%" PRIu16 ",%" PRIu16 ",%" PRIx16 ",%" PRIx8 ")",
> +					"%" PRIu16 ",%" PRIu16 ",%" PRIx16 ",%" PRIx8 ,
>   					i->local_ip_addr[0], i->local_ip_addr[1],
>   					i->local_ip_addr[2], i->local_ip_addr[3],
>   					i->remote_ip_addr[0], i->remote_ip_addr[1],
>   					i->remote_ip_addr[2], i->remote_ip_addr[3],
>   					i->local_port, i->remote_port,
>   					i->protocol, i->static_ip_address);
> +				if (len >= sizeof(fwts_uefi_ipv4_dev_path_v2) && dev_path_len >= sizeof(fwts_uefi_ipv4_dev_path_v2)) {
> +					fwts_uefi_ipv4_dev_path_v2 *i = (fwts_uefi_ipv4_dev_path_v2 *)dev_path;
> +					path = uefidump_vprintf(path,
> +						",%" PRIu8 ".%" PRIu8 ".%" PRIu8 ".%" PRIu8 ","
> +						"%" PRIu8 ".%" PRIu8 ".%" PRIu8 ".%" PRIu8 ,
> +						i->gateway_ip_addr[0], i->gateway_ip_addr[1],
> +						i->gateway_ip_addr[2], i->gateway_ip_addr[3],
> +						i->subnet_mask[0], i->subnet_mask[1],
> +						i->subnet_mask[2], i->subnet_mask[3]);
> +				}
> +				path = uefidump_vprintf(path, ")");
>   			}
>   			break;
>   		case FWTS_UEFI_IPV6_DEVICE_PATH_SUBTYPE:
>   			if (dev_path_len >= sizeof(fwts_uefi_ipv6_dev_path)) {
> -				fwts_uefi_ipv6_dev_path *i = (fwts_uefi_ipv6_dev_path*)dev_path;
> +				fwts_uefi_ipv6_dev_path *i = (fwts_uefi_ipv6_dev_path *)dev_path;
> +				uint16_t len = i->dev_path.length[0] | (((uint16_t)i->dev_path.length[1]) << 8);
>   				path = uefidump_vprintf(path, "\\IPv6("
> -					"%" PRIx8 ":%" PRIx8 ":%" PRIx8 ":%" PRIx8
> -					":%" PRIx8 ":%" PRIx8 ":%" PRIx8 ":%" PRIx8 ","
> -					"%" PRIx8 ":%" PRIx8 ":%" PRIx8 ":%" PRIx8
> -					":%" PRIx8 ":%" PRIx8 ":%" PRIx8 ":%" PRIx8 ","
> -					"%" PRIu16 ",%" PRIu16 ",%" PRIx16 ",%" PRIx8 ")",
> +					"%" PRIx16 ":%" PRIx16 ":%" PRIx16 ":%" PRIx16
> +					":%" PRIx16 ":%" PRIx16 ":%" PRIx16 ":%" PRIx16 ","
> +					"%" PRIx16 ":%" PRIx16 ":%" PRIx16 ":%" PRIx16
> +					":%" PRIx16 ":%" PRIx16 ":%" PRIx16 ":%" PRIx16 ","
> +					"%" PRIu16 ",%" PRIu16 ",%" PRIx16 ",%" PRIx8,
>   					i->local_ip_addr[0], i->local_ip_addr[1],
>   					i->local_ip_addr[2], i->local_ip_addr[3],
>   					i->local_ip_addr[4], i->local_ip_addr[5],
> @@ -305,6 +318,19 @@ static char *uefidump_build_dev_path(char *path, fwts_uefi_dev_path *dev_path, c
>   					i->remote_ip_addr[6], i->remote_ip_addr[7],
>   					i->local_port, i->remote_port,
>   					i->protocol, i->static_ip_address);
> +				if (len >= sizeof(fwts_uefi_ipv6_dev_path_v2) && dev_path_len >= sizeof(fwts_uefi_ipv6_dev_path_v2)) {
> +					fwts_uefi_ipv6_dev_path_v2 *i = (fwts_uefi_ipv6_dev_path_v2 *)dev_path;
> +					path = uefidump_vprintf(path,
> +					",%" PRIu8 ","
> +					"%" PRIx16 ":%" PRIx16 ":%" PRIx16 ":%" PRIx16
> +					":%" PRIx16 ":%" PRIx16 ":%" PRIx16 ":%" PRIx16,
> +					i->prefix_length,
> +					i->gateway_ip_addr[0], i->gateway_ip_addr[1],
> +					i->gateway_ip_addr[2], i->gateway_ip_addr[3],
> +					i->gateway_ip_addr[4], i->gateway_ip_addr[5],
> +					i->gateway_ip_addr[6], i->gateway_ip_addr[7]);
> +				}
> +				path = uefidump_vprintf(path, ")");
>   			}
>   			break;
>   		case FWTS_UEFI_INFINIBAND_DEVICE_PATH_SUBTYPE:
>


Acked-by: Alex Hung <alex.hung at canonical.com>



More information about the fwts-devel mailing list