Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1iLRZU-0006HE-UO for mharc-grub-devel@gnu.org; Fri, 18 Oct 2019 08:41:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42733) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLRZR-0006H6-Up for grub-devel@gnu.org; Fri, 18 Oct 2019 08:41:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iLRZP-00069t-Hx for grub-devel@gnu.org; Fri, 18 Oct 2019 08:41:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48132) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iLRZN-00068o-Fv for grub-devel@gnu.org; Fri, 18 Oct 2019 08:41:26 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 268B87BDAE for ; Fri, 18 Oct 2019 12:41:23 +0000 (UTC) Received: by mail-wm1-f70.google.com with SMTP id p6so2310577wmc.3 for ; Fri, 18 Oct 2019 05:41:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7tBzDcwliSt7BL+7wGIS8nmIYi9nBetRmViTElav1Ms=; b=YVgwJ2HTEKDjX6WSYhzovwlevSuupfqhYEv4u6/kb9dwuVmBFAALz4AGBq5SWutAgR iXY37femiStBBO9osAC3NRL9VhDSuAsBSKxseQSbebD6yQyoty/4B46CbNgpduIYU0Wb eoISByTTaq2Fc/F8d+nDJo9BVT5aolQJxuFODh+T5wzUm85Iugo7OkuAXHf1ackOHjCU uhlBFxFgSsvQYsuRL/pu6jNXONMgkuvtORRn4PcFzJiqNogGCB7qiVWNZHlLiNJAIwWo XmOo/JCkNhP/APyCBWOB5eMHOUlVZpG5yv9qRXcDi36kNID6tnrugwaT6LjDa/KPQZ7I Jd6A== X-Gm-Message-State: APjAAAUrVCJBSYCuW60rD1Nbk65GrSt5E3DW/t+DZO8HF9xz4jxvQr/E eWBJH4FwoVn38k4vrSTavD5DxNW92sCRJfNPpiqbl/vVXZgiFiTaIyn8+0Z62rWgsG7zdmOEt6i IwpBr96hh0JY= X-Received: by 2002:a05:6000:128c:: with SMTP id f12mr1999492wrx.279.1571402481145; Fri, 18 Oct 2019 05:41:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqxllNpOlWXffGqEBs2mjdET6D9cb6eq73W/tuVwUe6y3+CpKcaHkN8eSACV4FJdpHZUoZbzSQ== X-Received: by 2002:a05:6000:128c:: with SMTP id f12mr1999465wrx.279.1571402480636; Fri, 18 Oct 2019 05:41:20 -0700 (PDT) Received: from minerva.redhat.com ([90.168.169.92]) by smtp.gmail.com with ESMTPSA id a192sm5741393wma.1.2019.10.18.05.41.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2019 05:41:20 -0700 (PDT) From: Javier Martinez Canillas To: grub-devel@gnu.org Cc: Peter Jones , Javier Martinez Canillas Subject: [PATCH 2/2] efinet and bootp: add support for dhcpv6 Date: Fri, 18 Oct 2019 14:41:16 +0200 Message-Id: <20191018124116.15283-2-javierm@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191018124116.15283-1-javierm@redhat.com> References: <20191018124116.15283-1-javierm@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Oct 2019 12:41:32 -0000 From: Peter Jones Signed-off-by: Peter Jones Signed-off-by: Javier Martinez Canillas --- grub-core/net/bootp.c | 174 +++++++++++++++++++++++++++++ grub-core/net/drivers/efi/efinet.c | 54 +++++++-- grub-core/net/net.c | 72 ++++++++++++ grub-core/net/tftp.c | 4 + include/grub/efi/api.h | 129 ++++++++++++++++++++- include/grub/net.h | 60 ++++++++++ 6 files changed, 479 insertions(+), 14 deletions(-) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c index 04cfbb04504..d4f13ab1a43 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -23,6 +23,7 @@ #include #include #include +#include #include =20 struct grub_dhcp_discover_options @@ -866,6 +867,179 @@ grub_cmd_bootp (struct grub_command *cmd __attribut= e__ ((unused)), =20 static grub_command_t cmd_getdhcp, cmd_bootp, cmd_dhcp; =20 +struct grub_net_network_level_interface * +grub_net_configure_by_dhcpv6_ack (const char *name, + struct grub_net_card *card, + grub_net_interface_flags_t flags + __attribute__((__unused__)), + const grub_net_link_level_address_t *hwaddr, + const struct grub_net_dhcpv6_packet *packet, + int is_def, char **device, char **path) +{ + struct grub_net_network_level_interface *inter =3D NULL; + struct grub_net_network_level_address addr; + int mask =3D -1; + + if (!device || !path) + return NULL; + + *device =3D 0; + *path =3D 0; + + grub_dprintf ("net", "mac address is %02x:%02x:%02x:%02x:%02x:%02x\n", + hwaddr->mac[0], hwaddr->mac[1], hwaddr->mac[2], + hwaddr->mac[3], hwaddr->mac[4], hwaddr->mac[5]); + + if (is_def) + grub_net_default_server =3D 0; + + if (is_def && !grub_net_default_server && packet) + { + const grub_uint8_t *options =3D packet->dhcp_options; + unsigned int option_max =3D 1024 - OFFSET_OF (dhcp_options, packet= ); + unsigned int i; + + for (i =3D 0; i < option_max - sizeof (grub_net_dhcpv6_option_t); = ) + { + grub_uint16_t num, len; + grub_net_dhcpv6_option_t *opt =3D + (grub_net_dhcpv6_option_t *)(options + i); + + num =3D grub_be_to_cpu16(opt->option_num); + len =3D grub_be_to_cpu16(opt->option_len); + + grub_dprintf ("net", "got dhcpv6 option %d len %d\n", num, len); + + if (len =3D=3D 0) + break; + + if (len + i > 1024) + break; + + if (num =3D=3D GRUB_NET_DHCP6_BOOTFILE_URL) + { + char *scheme, *userinfo, *host, *file; + char *tmp; + int hostlen; + int port; + int rc =3D extract_url_info ((const char *)opt->option_data, + (grub_size_t)len, + &scheme, &userinfo, &host, &port, + &file); + if (rc < 0) + continue; + + /* right now this only handles tftp. */ + if (grub_strcmp("tftp", scheme)) + { + grub_free (scheme); + grub_free (userinfo); + grub_free (host); + grub_free (file); + continue; + } + grub_free (userinfo); + + hostlen =3D grub_strlen (host); + if (hostlen > 2 && host[0] =3D=3D '[' && host[hostlen-1] =3D=3D '= ]') + { + tmp =3D host+1; + host[hostlen-1] =3D '\0'; + } + else + tmp =3D host; + + *device =3D grub_xasprintf ("%s,%s", scheme, tmp); + grub_free (scheme); + grub_free (host); + + if (file && *file) + { + tmp =3D grub_strrchr (file, '/'); + if (tmp) + *(tmp+1) =3D '\0'; + else + file[0] =3D '\0'; + } + else if (!file) + file =3D grub_strdup (""); + + if (file[0] =3D=3D '/') + { + *path =3D grub_strdup (file+1); + grub_free (file); + } + else + *path =3D file; + } + else if (num =3D=3D GRUB_NET_DHCP6_IA_NA) + { + const grub_net_dhcpv6_option_t *ia_na_opt; + const grub_net_dhcpv6_opt_ia_na_t *ia_na =3D + (const grub_net_dhcpv6_opt_ia_na_t *)opt; + unsigned int left =3D len - OFFSET_OF (options, ia_na); + unsigned int j; + + if ((grub_uint8_t *)ia_na + left > + (grub_uint8_t *)options + option_max) + left -=3D ((grub_uint8_t *)ia_na + left) + - ((grub_uint8_t *)options + option_max); + + if (len < OFFSET_OF (option_data, opt) + + sizeof (grub_net_dhcpv6_option_t)) + { + grub_dprintf ("net", + "found dhcpv6 ia_na option with no address\n"); + continue; + } + + for (j =3D 0; left > sizeof (grub_net_dhcpv6_option_t); ) + { + ia_na_opt =3D (const grub_net_dhcpv6_option_t *) + (ia_na->options + j); + grub_uint16_t ia_na_opt_num, ia_na_opt_len; + + ia_na_opt_num =3D grub_be_to_cpu16 (ia_na_opt->option_num); + ia_na_opt_len =3D grub_be_to_cpu16 (ia_na_opt->option_len); + if (ia_na_opt_len =3D=3D 0) + break; + if (j + ia_na_opt_len > left) + break; + if (ia_na_opt_num =3D=3D GRUB_NET_DHCP6_IA_ADDRESS) + { + const grub_net_dhcpv6_opt_ia_address_t *ia_addr; + + ia_addr =3D (const grub_net_dhcpv6_opt_ia_address_t *) + ia_na_opt; + addr.type =3D GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6; + grub_memcpy(addr.ipv6, ia_addr->ipv6_address, + sizeof (ia_addr->ipv6_address)); + inter =3D grub_net_add_addr (name, card, &addr, hwaddr, 0); + } + + j +=3D ia_na_opt_len; + left -=3D ia_na_opt_len; + } + } + + i +=3D len + 4; + } + + grub_print_error (); + } + + if (is_def) + { + grub_env_set ("net_default_interface", name); + grub_env_export ("net_default_interface"); + } + + if (inter) + grub_net_add_ipv6_local (inter, mask); + return inter; +} + + void grub_bootp_init (void) { diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/e= fi/efinet.c index 5388f952ba9..a57189e8bb3 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c @@ -18,11 +18,15 @@ =20 #include #include +#include #include +#include #include #include #include #include +#include +#include =20 GRUB_MOD_LICENSE ("GPLv3+"); =20 @@ -329,7 +333,7 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char= **device, char **path) { struct grub_net_card *card; - grub_efi_device_path_t *dp; + grub_efi_device_path_t *dp, *ldp =3D NULL; =20 dp =3D grub_efi_get_device_path (hnd); if (! dp) @@ -340,14 +344,19 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, ch= ar **device, grub_efi_device_path_t *cdp; struct grub_efi_pxe *pxe; struct grub_efi_pxe_mode *pxe_mode; + if (card->driver !=3D &efidriver) continue; + cdp =3D grub_efi_get_device_path (card->efi_handle); if (! cdp) continue; + + ldp =3D grub_efi_find_last_device_path (dp); + if (grub_efi_compare_device_paths (dp, cdp) !=3D 0) { - grub_efi_device_path_t *ldp, *dup_dp, *dup_ldp; + grub_efi_device_path_t *dup_dp, *dup_ldp; int match; =20 /* EDK2 UEFI PXE driver creates pseudo devices with type IPv4/IPv6 @@ -356,7 +365,6 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char= **device, devices. We skip them when enumerating cards, so here we need to find matching MAC device. */ - ldp =3D grub_efi_find_last_device_path (dp); if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) !=3D GRUB_EFI_MESSAGING_DEVICE_PATH= _TYPE || (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) !=3D GRUB_EFI_IPV4_DEVICE_PA= TH_SUBTYPE && GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) !=3D GRUB_EFI_IPV6_DEVICE_PATH_S= UBTYPE)) @@ -373,16 +381,46 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, ch= ar **device, if (!match) continue; } + pxe =3D grub_efi_open_protocol (hnd, &pxe_io_guid, GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); if (! pxe) continue; + pxe_mode =3D pxe->mode; - grub_net_configure_by_dhcp_ack (card->name, card, 0, - (struct grub_net_bootp_packet *) - &pxe_mode->dhcp_ack, - sizeof (pxe_mode->dhcp_ack), - 1, device, path); + if (pxe_mode->using_ipv6) + { + grub_net_link_level_address_t hwaddr; + struct grub_net_network_level_interface *intf; + + grub_dprintf ("efinet", "using ipv6 and dhcpv6\n"); + grub_dprintf ("efinet", "dhcp_ack_received: %s%s\n", + pxe_mode->dhcp_ack_received ? "yes" : "no", + pxe_mode->dhcp_ack_received ? "" : " cannot continue"); + if (!pxe_mode->dhcp_ack_received) + continue; + + hwaddr.type =3D GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; + grub_memcpy (hwaddr.mac, + card->efi_net->mode->current_address, + sizeof (hwaddr.mac)); + + intf =3D grub_net_configure_by_dhcpv6_ack (card->name, card, 0, &hwaddr= , + (const struct grub_net_dhcpv6_packet *)&pxe_mode->dhcp_ack.dhcpv6= , + 1, device, path); + if (intf && device && path) + grub_dprintf ("efinet", "device: `%s' path: `%s'\n", *device, *path); + } + else + { + grub_dprintf ("efinet", "using ipv4 and dhcp\n"); + grub_net_configure_by_dhcp_ack (card->name, card, 0, + (struct grub_net_bootp_packet *) + &pxe_mode->dhcp_ack, + sizeof (pxe_mode->dhcp_ack), + 1, device, path); + grub_dprintf ("efinet", "device: `%s' path: `%s'\n", *device, *path); + } return; } } diff --git a/grub-core/net/net.c b/grub-core/net/net.c index d5d726a315e..160777066c1 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -955,6 +955,78 @@ grub_net_network_level_interface_register (struct gr= ub_net_network_level_interfa grub_net_network_level_interfaces =3D inter; } =20 +int +grub_ipv6_get_masksize (grub_uint16_t be_mask[8]) +{ + grub_uint8_t *mask; + grub_uint16_t mask16[8]; + int x, y; + int ret =3D 128; + + grub_memcpy (mask16, be_mask, sizeof (mask16)); + for (x =3D 0; x < 8; x++) + mask16[x] =3D grub_be_to_cpu16 (mask16[x]); + + mask =3D (grub_uint8_t *)mask16; + + for (x =3D 15; x >=3D 0; x--) + { + grub_uint8_t octet =3D mask[x]; + if (!octet) + { + ret -=3D 8; + continue; + } + for (y =3D 0; y < 8; y++) + { + if (octet & (1 << y)) + break; + else + ret--; + } + break; + } + + return ret; +} + +grub_err_t +grub_net_add_ipv6_local (struct grub_net_network_level_interface *inter, + int mask) +{ + struct grub_net_route *route; + + if (inter->address.type !=3D GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6) + return 0; + + if (mask =3D=3D -1) + mask =3D grub_ipv6_get_masksize ((grub_uint16_t *)inter->address.i= pv6); + + if (mask =3D=3D -1) + return 0; + + route =3D grub_zalloc (sizeof (*route)); + if (!route) + return grub_errno; + + route->name =3D grub_xasprintf ("%s:local", inter->name); + if (!route->name) + { + grub_free (route); + return grub_errno; + } + + route->target.type =3D GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6; + grub_memcpy (route->target.ipv6.base, inter->address.ipv6, + sizeof (inter->address.ipv6)); + route->target.ipv6.masksize =3D mask; + route->is_gateway =3D 0; + route->interface =3D inter; + + grub_net_route_register (route); + + return 0; +} =20 grub_err_t grub_net_add_ipv4_local (struct grub_net_network_level_interface *inter, diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c index 7d90bf66e76..1157524fc50 100644 --- a/grub-core/net/tftp.c +++ b/grub-core/net/tftp.c @@ -379,19 +379,23 @@ tftp_open (struct grub_file *file, const char *file= name) return grub_errno; } =20 + grub_dprintf("tftp", "resolving address for %s\n", file->device->net->= server); err =3D grub_net_resolve_address (file->device->net->server, &addr); if (err) { + grub_dprintf("tftp", "Address resolution failed: %d\n", err); destroy_pq (data); grub_free (data); return err; } =20 + grub_dprintf("tftp", "opening connection\n"); data->sock =3D grub_net_udp_open (addr, TFTP_SERVER_PORT, tftp_receive, file); if (!data->sock) { + grub_dprintf("tftp", "connection failed\n"); destroy_pq (data); grub_free (data); return grub_errno; diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h index 57607438435..17e48d5ae19 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h @@ -577,10 +577,16 @@ typedef void *grub_efi_handle_t; typedef void *grub_efi_event_t; typedef grub_efi_uint64_t grub_efi_lba_t; typedef grub_efi_uintn_t grub_efi_tpl_t; -typedef grub_uint8_t grub_efi_mac_address_t[32]; -typedef grub_uint8_t grub_efi_ipv4_address_t[4]; -typedef grub_uint16_t grub_efi_ipv6_address_t[8]; -typedef grub_uint8_t grub_efi_ip_address_t[8] __attribute__ ((aligned(4)= )); +typedef grub_efi_uint8_t grub_efi_mac_address_t[32]; +typedef grub_efi_uint8_t grub_efi_ipv4_address_t[4]; +typedef grub_efi_uint8_t grub_efi_ipv6_address_t[16]; +typedef union +{ + grub_efi_uint32_t addr[4]; + grub_efi_ipv4_address_t v4; + grub_efi_ipv6_address_t v6; +} grub_efi_ip_address_t __attribute__ ((aligned(4))); + typedef grub_efi_uint64_t grub_efi_physical_address_t; typedef grub_efi_uint64_t grub_efi_virtual_address_t; =20 @@ -1455,16 +1461,127 @@ struct grub_efi_simple_text_output_interface }; typedef struct grub_efi_simple_text_output_interface grub_efi_simple_tex= t_output_interface_t; =20 -typedef grub_uint8_t grub_efi_pxe_packet_t[1472]; +typedef struct grub_efi_pxe_dhcpv4_packet +{ + grub_efi_uint8_t bootp_opcode; + grub_efi_uint8_t bootp_hwtype; + grub_efi_uint8_t bootp_hwaddr_len; + grub_efi_uint8_t bootp_gate_hops; + grub_efi_uint32_t bootp_ident; + grub_efi_uint16_t bootp_seconds; + grub_efi_uint16_t bootp_flags; + grub_efi_uint8_t bootp_ci_addr[4]; + grub_efi_uint8_t bootp_yi_addr[4]; + grub_efi_uint8_t bootp_si_addr[4]; + grub_efi_uint8_t bootp_gi_addr[4]; + grub_efi_uint8_t bootp_hw_addr[16]; + grub_efi_uint8_t bootp_srv_name[64]; + grub_efi_uint8_t bootp_boot_file[128]; + grub_efi_uint32_t dhcp_magik; + grub_efi_uint8_t dhcp_options[56]; +} grub_efi_pxe_dhcpv4_packet_t; + +struct grub_efi_pxe_dhcpv6_packet +{ + grub_efi_uint32_t message_type:8; + grub_efi_uint32_t transaction_id:24; + grub_efi_uint8_t dhcp_options[1024]; +} GRUB_PACKED; +typedef struct grub_efi_pxe_dhcpv6_packet grub_efi_pxe_dhcpv6_packet_t; + +typedef union +{ + grub_efi_uint8_t raw[1472]; + grub_efi_pxe_dhcpv4_packet_t dhcpv4; + grub_efi_pxe_dhcpv6_packet_t dhcpv6; +} grub_efi_pxe_packet_t; + +#define GRUB_EFI_PXE_MAX_IPCNT 8 +#define GRUB_EFI_PXE_MAX_ARP_ENTRIES 8 +#define GRUB_EFI_PXE_MAX_ROUTE_ENTRIES 8 + +typedef struct grub_efi_pxe_ip_filter +{ + grub_efi_uint8_t filters; + grub_efi_uint8_t ip_count; + grub_efi_uint8_t reserved; + grub_efi_ip_address_t ip_list[GRUB_EFI_PXE_MAX_IPCNT]; +} grub_efi_pxe_ip_filter_t; + +typedef struct grub_efi_pxe_arp_entry +{ + grub_efi_ip_address_t ip_addr; + grub_efi_mac_address_t mac_addr; +} grub_efi_pxe_arp_entry_t; + +typedef struct grub_efi_pxe_route_entry +{ + grub_efi_ip_address_t ip_addr; + grub_efi_ip_address_t subnet_mask; + grub_efi_ip_address_t gateway_addr; +} grub_efi_pxe_route_entry_t; + +typedef struct grub_efi_pxe_icmp_error +{ + grub_efi_uint8_t type; + grub_efi_uint8_t code; + grub_efi_uint16_t checksum; + union + { + grub_efi_uint32_t reserved; + grub_efi_uint32_t mtu; + grub_efi_uint32_t pointer; + struct + { + grub_efi_uint16_t identifier; + grub_efi_uint16_t sequence; + } echo; + } u; + grub_efi_uint8_t data[494]; +} grub_efi_pxe_icmp_error_t; + +typedef struct grub_efi_pxe_tftp_error +{ + grub_efi_uint8_t error_code; + grub_efi_char8_t error_string[127]; +} grub_efi_pxe_tftp_error_t; =20 typedef struct grub_efi_pxe_mode { - grub_uint8_t unused[52]; + grub_efi_boolean_t started; + grub_efi_boolean_t ipv6_available; + grub_efi_boolean_t ipv6_supported; + grub_efi_boolean_t using_ipv6; + grub_efi_boolean_t bis_supported; + grub_efi_boolean_t bis_detected; + grub_efi_boolean_t auto_arp; + grub_efi_boolean_t send_guid; + grub_efi_boolean_t dhcp_discover_valid; + grub_efi_boolean_t dhcp_ack_received; + grub_efi_boolean_t proxy_offer_received; + grub_efi_boolean_t pxe_discover_valid; + grub_efi_boolean_t pxe_reply_received; + grub_efi_boolean_t pxe_bis_reply_received; + grub_efi_boolean_t icmp_error_received; + grub_efi_boolean_t tftp_error_received; + grub_efi_boolean_t make_callbacks; + grub_efi_uint8_t ttl; + grub_efi_uint8_t tos; + grub_efi_ip_address_t station_ip; + grub_efi_ip_address_t subnet_mask; grub_efi_pxe_packet_t dhcp_discover; grub_efi_pxe_packet_t dhcp_ack; grub_efi_pxe_packet_t proxy_offer; grub_efi_pxe_packet_t pxe_discover; grub_efi_pxe_packet_t pxe_reply; + grub_efi_pxe_packet_t pxe_bis_reply; + grub_efi_pxe_ip_filter_t ip_filter; + grub_efi_uint32_t arp_cache_entries; + grub_efi_pxe_arp_entry_t arp_cache[GRUB_EFI_PXE_MAX_ARP_ENTRIES]; + grub_efi_uint32_t route_table_entries; + grub_efi_pxe_route_entry_t route_table[GRUB_EFI_PXE_MAX_ROUTE_ENTRIES]= ; + grub_efi_pxe_icmp_error_t icmp_error; + grub_efi_pxe_tftp_error_t tftp_error; } grub_efi_pxe_mode_t; =20 typedef struct grub_efi_pxe diff --git a/include/grub/net.h b/include/grub/net.h index 4a9069a1474..da52bf06edf 100644 --- a/include/grub/net.h +++ b/include/grub/net.h @@ -447,6 +447,51 @@ struct grub_net_bootp_packet grub_uint8_t vendor[0]; } GRUB_PACKED; =20 +enum + { + GRUB_NET_DHCP6_IA_NA =3D 3, + GRUB_NET_DHCP6_IA_ADDRESS =3D 5, + GRUB_NET_DHCP6_BOOTFILE_URL =3D 59, + }; + +struct grub_net_dhcpv6_option +{ + grub_uint16_t option_num; + grub_uint16_t option_len; + grub_uint8_t option_data[]; +} GRUB_PACKED; +typedef struct grub_net_dhcpv6_option grub_net_dhcpv6_option_t; + +struct grub_net_dhcpv6_opt_ia_na +{ + grub_uint16_t option_num; + grub_uint16_t option_len; + grub_uint32_t iaid; + grub_uint32_t t1; + grub_uint32_t t2; + grub_uint8_t options[]; +} GRUB_PACKED; +typedef struct grub_net_dhcpv6_opt_ia_na grub_net_dhcpv6_opt_ia_na_t; + +struct grub_net_dhcpv6_opt_ia_address +{ + grub_uint16_t option_num; + grub_uint16_t option_len; + grub_uint64_t ipv6_address[2]; + grub_uint32_t preferred_lifetime; + grub_uint32_t valid_lifetime; + grub_uint8_t options[]; +} GRUB_PACKED; +typedef struct grub_net_dhcpv6_opt_ia_address grub_net_dhcpv6_opt_ia_add= ress_t; + +struct grub_net_dhcpv6_packet +{ + grub_uint32_t message_type:8; + grub_uint32_t transaction_id:24; + grub_uint8_t dhcp_options[1024]; +} GRUB_PACKED; +typedef struct grub_net_dhcpv6_packet grub_net_dhcpv6_packet_t; + #define GRUB_NET_BOOTP_RFC1048_MAGIC_0 0x63 #define GRUB_NET_BOOTP_RFC1048_MAGIC_1 0x82 #define GRUB_NET_BOOTP_RFC1048_MAGIC_2 0x53 @@ -480,6 +525,21 @@ grub_net_configure_by_dhcp_ack (const char *name, grub_size_t size, int is_def, char **device, char **path); =20 +struct grub_net_network_level_interface * +grub_net_configure_by_dhcpv6_ack (const char *name, + struct grub_net_card *card, + grub_net_interface_flags_t flags, + const grub_net_link_level_address_t *hwaddr, + const struct grub_net_dhcpv6_packet *packet, + int is_def, char **device, char **path); + +int +grub_ipv6_get_masksize(grub_uint16_t *mask); + +grub_err_t +grub_net_add_ipv6_local (struct grub_net_network_level_interface *inf, + int mask); + grub_err_t grub_net_add_ipv4_local (struct grub_net_network_level_interface *inf, int mask); --=20 2.21.0