From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1UYrK2-00084H-W1 for mharc-grub-devel@gnu.org; Sun, 05 May 2013 01:17:19 -0400 Received: from eggs.gnu.org ([208.118.235.92]:44359) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UYrK0-00081k-Lj for grub-devel@gnu.org; Sun, 05 May 2013 01:17:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UYrJy-0002ZZ-Rm for grub-devel@gnu.org; Sun, 05 May 2013 01:17:16 -0400 Received: from mail-la0-x22b.google.com ([2a00:1450:4010:c03::22b]:61346) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UYrJy-0002ZH-Fh for grub-devel@gnu.org; Sun, 05 May 2013 01:17:14 -0400 Received: by mail-la0-f43.google.com with SMTP id ea20so2521591lab.30 for ; Sat, 04 May 2013 22:17:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:date:from:to:subject:message-id:in-reply-to:references :x-mailer:mime-version:content-type; bh=0EKXMX5chMY8K4dM5EhqkatrnVSxd0zVFmZsJeGGvAc=; b=qeCWWOZjXIpkW9KSAkU/+brPfpZg+r2+HZm0U4KGsYPCA217dLInD1gNCmX+9a9nTH cG2r0nEuYWkrbIgSWoc/7P6MNUAWUfPgAdK+YTxe/JAayTT/kNDQqUR7QvV/8halCVjc ZZgfyqzhk1F8QaUxjq0MsifsWnAozNUMbjnli0mAwS64CeSOPTpH4zVtwQFz+9eeOZLy mEwzWodc1qc3Ekzfv2nicoxQgC0zJV1r7bcop6XpU6CIyErv4m/p4N5X25UXJrMESgps pYf8MCxVNFK3VyshO7+DYFKQ/t8yh897glmtbsvwdnwMl+uP6ENpnSRAyCCBCm2JVx2f pMJQ== X-Received: by 10.112.155.67 with SMTP id vu3mr6118274lbb.109.1367731033311; Sat, 04 May 2013 22:17:13 -0700 (PDT) Received: from opensuse.site ([94.29.72.160]) by mx.google.com with ESMTPSA id t17sm6504967lbd.11.2013.05.04.22.17.12 for (version=SSLv3 cipher=RC4-SHA bits=128/128); Sat, 04 May 2013 22:17:12 -0700 (PDT) Date: Sun, 5 May 2013 09:17:08 +0400 From: Andrey Borzenkov To: grub-devel@gnu.org Subject: Re: Obtaining the MAC address of the boot NIC for a PXE boot Message-ID: <20130505091708.13b0a8c8@opensuse.site> In-Reply-To: <51857B76.6080001@gmail.com> References: <1367240132.58582.YahooMailNeo@web120204.mail.ne1.yahoo.com> <20130501185934.3f2b9c28@opensuse.site> <518578B3.5040003@gmail.com> <51857B76.6080001@gmail.com> X-Mailer: Claws Mail 3.9.0 (GTK+ 2.24.14; x86_64-suse-linux-gnu) Mime-Version: 1.0 Content-Type: multipart/signed; micalg=PGP-SHA1; boundary="Sig_/+o0cJu7eWKpmnSI2IEF_jTO"; protocol="application/pgp-signature" X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::22b X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 May 2013 05:17:17 -0000 --Sig_/+o0cJu7eWKpmnSI2IEF_jTO Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable =D0=92 Sat, 04 May 2013 23:19:50 +0200 Vladimir '=CF=86-coder/phcoder' Serbinenko =D0=BF=D0=B8= =D1=88=D0=B5=D1=82: > Patch for net_default_*. Please test. >=20 > =3D=3D=3D modified file 'grub-core/net/bootp.c' > --- grub-core/net/bootp.c 2013-01-20 13:24:47 +0000 > +++ grub-core/net/bootp.c 2013-05-04 21:16:02 +0000 > @@ -211,6 +211,9 @@ > grub_print_error (); > } > =20 > + if (is_def) > + grub_env_set ("net_default_interface", name); > + > if (device && !*device && bp->server_ip) > { > *device =3D grub_xasprintf ("tftp,%d.%d.%d.%d", >=20 > =3D=3D=3D modified file 'grub-core/net/net.c' > --- grub-core/net/net.c 2013-01-21 01:33:46 +0000 > +++ grub-core/net/net.c 2013-05-04 21:13:29 +0000 > @@ -1,6 +1,6 @@ > /* > * GRUB -- GRand Unified Bootloader > - * Copyright (C) 2010,2011 Free Software Foundation, Inc. > + * Copyright (C) 2010,2011,2012,2013 Free Software Foundation, Inc. > * > * GRUB is free software: you can redistribute it and/or modify > * it under the terms of the GNU General Public License as published by > @@ -813,6 +813,65 @@ > return grub_net_default_server ? : ""; > } > =20 > +static const char * > +defip_get_env (struct grub_env_var *var __attribute__ ((unused)), > + const char *val) > +{ > + const char *intf =3D grub_env_get ("net_default_interface"); > + const char *ret =3D NULL; > + if (intf) > + { > + char *buf =3D grub_xasprintf ("net_%s_ip", intf); > + ret =3D grub_env_get (buf); This will crash if grub_xasprintf fails. > + grub_free (buf); > + } > + return ret; > +} > + > +static char * > +defip_set_env (struct grub_env_var *var __attribute__ ((unused)), > + const char *val) > +{ > + const char *intf =3D grub_env_get ("net_default_interface"); > + if (intf) > + { > + char *buf =3D grub_xasprintf ("net_%s_ip", intf); > + grub_env_set (buf, val); > + grub_free (buf); > + } > + return NULL; > +} > + > + > +static const char * > +defmac_get_env (struct grub_env_var *var __attribute__ ((unused)), > + const char *val) > +{ > + const char *intf =3D grub_env_get ("net_default_interface"); > + const char *ret =3D NULL; > + if (intf) > + { > + char *buf =3D grub_xasprintf ("net_%s_mac", intf); > + ret =3D grub_env_get (buf); > + grub_free (buf); > + } > + return ret; > +} > + > +static char * > +defmac_set_env (struct grub_env_var *var __attribute__ ((unused)), > + const char *val) > +{ > + const char *intf =3D grub_env_get ("net_default_interface"); > + if (intf) > + { > + char *buf =3D grub_xasprintf ("net_%s_mac", intf); > + grub_env_set (buf, val); > + grub_free (buf); > + } > + return NULL; > +} > + > =20 > static void > grub_net_network_level_interface_register (struct grub_net_network_level= _interface *inter) > @@ -1560,6 +1619,10 @@ > defserver_set_env); > grub_register_variable_hook ("pxe_default_server", defserver_get_env, > defserver_set_env); > + grub_register_variable_hook ("net_default_ip", defip_get_env, > + defip_set_env); > + grub_register_variable_hook ("net_default_mac", defmac_get_env, > + defmac_set_env); > =20 > cmd_addaddr =3D grub_register_command ("net_add_addr", grub_cmd_addadd= r, > /* TRANSLATORS: HWADDRESS stands for >=20 >=20 --Sig_/+o0cJu7eWKpmnSI2IEF_jTO Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (GNU/Linux) iEYEARECAAYFAlGF61cACgkQR6LMutpd94wWhwCglHP3Enk2zvDFgiGhnVpo57xA /scAmQEtTCg+Nr/HqOys0CoRt88Aab0P =DSFQ -----END PGP SIGNATURE----- --Sig_/+o0cJu7eWKpmnSI2IEF_jTO--