From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1UZeka-0007hh-U0 for mharc-grub-devel@gnu.org; Tue, 07 May 2013 06:04:00 -0400 Received: from eggs.gnu.org ([208.118.235.92]:36944) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UZekW-0007h6-UX for grub-devel@gnu.org; Tue, 07 May 2013 06:03:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UZekV-0001jc-CS for grub-devel@gnu.org; Tue, 07 May 2013 06:03:56 -0400 Received: from mail-ee0-f43.google.com ([74.125.83.43]:52303) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UZekV-0001jW-3C for grub-devel@gnu.org; Tue, 07 May 2013 06:03:55 -0400 Received: by mail-ee0-f43.google.com with SMTP id b15so196729eek.30 for ; Tue, 07 May 2013 03:03:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:x-enigmail-version:content-type; bh=r2R1NuJwGbXLE2sdsXOausLczh291rHhNQ/NHiPI6/M=; b=kVPK/M9Sx1mVhb/x65QgsLKxc8TB8cKaGRdLnLISb7Gf7MEQt0i489oG7DkzTAK3Ah rDUG5FzaLyMgjdyOEKW/d8fsEO5ocUhsSCcwkOL6UMGlKOye/rRinTYRPk3FoKS8ceiN p4fvxEinDzBnKmP3ymZoY2pzScoVT/g7oXXaRuKx3Bky6bKhDUefngltb4/T+ViGaUNb /jRCqbbYHoRBijMbXkqheu1/NmF4OnjISUivAxqnK/4KS1uXB14aaoO86Gzmn8kKPawa yWK+5EAIgALvAedx5nFUPDRELHGZmyZW0NDRyopJ5yTMcuIzMUmLjXLOwzcwMh5bhRNn Tizg== X-Received: by 10.14.194.70 with SMTP id l46mr3739403een.28.1367921034328; Tue, 07 May 2013 03:03:54 -0700 (PDT) Received: from debian.x201.phnet (245-188.1-85.cust.bluewin.ch. [85.1.188.245]) by mx.google.com with ESMTPSA id bj12sm38275480eeb.8.2013.05.07.03.03.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 07 May 2013 03:03:53 -0700 (PDT) Message-ID: <5188D187.3040302@gmail.com> Date: Tue, 07 May 2013 12:03:51 +0200 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130116 Icedove/10.0.12 MIME-Version: 1.0 To: grub-devel@gnu.org Subject: Re: Obtaining the MAC address of the boot NIC for a PXE boot References: <1367240132.58582.YahooMailNeo@web120204.mail.ne1.yahoo.com> <20130501185934.3f2b9c28@opensuse.site> <518578B3.5040003@gmail.com> <51857B76.6080001@gmail.com> <20130505091708.13b0a8c8@opensuse.site> In-Reply-To: <20130505091708.13b0a8c8@opensuse.site> X-Enigmail-Version: 1.4.1 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="------------enigB9DF679B01091E2FD13651DE" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 74.125.83.43 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: Tue, 07 May 2013 10:03:58 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigB9DF679B01091E2FD13651DE Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 05.05.2013 07:17, Andrey Borzenkov wrote: > =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: >=20 >> Patch for net_default_*. Please test. >> >> =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", >> >> =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); >=20 > This will crash if grub_xasprintf fails. >=20 Right, thanks. This patch was actually meant to just show the principle. Fixed this and another problem with it, tested and now comitting. >> + 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_le= vel_interface *inter) >> @@ -1560,6 +1619,10 @@ >> defserver_set_env); >> grub_register_variable_hook ("pxe_default_server", defserver_get_en= v, >> 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_add= addr, >> /* TRANSLATORS: HWADDRESS stands for >> >> >=20 >=20 >=20 > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel --------------enigB9DF679B01091E2FD13651DE Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iF4EAREKAAYFAlGI0YcACgkQNak7dOguQgl/LwD/d6IovuAqPdDBXumgQPx2k+0w 26ajhXYtxkyHlX921j8A/1R5o3kOlsYgGCBtzOlQHZgXKxc7/T9xO8Ot3QLAZctq =0kMv -----END PGP SIGNATURE----- --------------enigB9DF679B01091E2FD13651DE--