Hans-Werner.Jouy at hamburglb.de
2002-Aug-14 09:21 UTC
[syslinux] re: using mac-addr for selecting configfile now working
Hi everybody hacking in the 200-pre4 i found everything i needed, so i gave it a try ... and it works! But dont blame for the code, its just quick and dirty! --- ../syslinux-2.00-pre4/pxelinux.asm Sat Jun 15 07:25:51 2002 +++ ./pxelinux.asm Wed Aug 14 10:05:00 2002 @@ -17,6 +17,11 @@ ; version; incorporated herein by reference. ; ; **************************************************************************** +; modified by Hans-Werner Jouy (hans-werner.jouy at hamburglb.de) to use +; the macaddr aus configfilename, only try full maccaddr, then vendor part +; (first 3 byte), then defaultfilename: dirty hack, USE AT YOUR OWN RISK +; but free or better try to integrate into stable release +; **************************************************************************** %define IS_PXELINUX 1 %include "macros.inc" @@ -692,22 +697,39 @@ mov si,cfgprefix mov cx,cfgprefix_len rep movsb - mov cx,8 - mov eax,[MyIP] + mov cx,6 ; 6 nibbles in vendor part of MAC + mov eax,[MyMAC1] ; 3 bytes vendor part of MAC + xchg ah,al ; Convert to host byte order + ror eax,16 + xchg ah,al +.hexify_loop1: rol eax,4 + push eax + and al,0Fh + cmp al,10 + jae .high1 +.low1: add al,'0' + jmp short .char1 +.high1: add al,'A'-10 +.char1: stosb + pop eax + loop .hexify_loop1 + + mov cx,6 ; 6 nibbles in netcard part of MAC + mov eax,[MyMAC2] ; 3 byte netcard part of MAC xchg ah,al ; Convert to host byte order ror eax,16 xchg ah,al -.hexify_loop: rol eax,4 +.hexify_loop2: rol eax,4 push eax and al,0Fh cmp al,10 - jae .high -.low: add al,'0' - jmp short .char -.high: add al,'A'-10 -.char: stosb + jae .high2 +.low2: add al,'0' + jmp short .char2 +.high2: add al,'A'-10 +.char2: stosb pop eax - loop .hexify_loop + loop .hexify_loop2 ; ; Begin looking for configuration file @@ -730,7 +752,7 @@ .no_option: ; Have to guess config file name - mov cx,9 ; Up to 9 attempts + mov cx,3 ; Up to 3 attempts (complete MAC, vendor part of MAC, default .tryagain: mov byte [di],0 cmp cx,byte 1 @@ -751,6 +773,11 @@ jnz .success .badness: popa + dec di ; truncate configfilename 6 nibbles / 3 byte + dec di + dec di + dec di + dec di dec di loop .tryagain @@ -2071,6 +2098,8 @@ ; information is present: ; ; MyIP - client IP address +; MyMAC1 - client MAC address (vendor part) +; MyMAC2 - client MAC address ; ServerIP - boot server IP address ; Netmask - network mask ; Gateway - default gateway router IP @@ -2082,6 +2111,10 @@ parse_dhcp: mov byte [OverLoad],0 ; Assume no overload + mov eax, [trackbuf+bootp.macaddr] ; get macaddr (vendor part) + mov [MyMAC1], eax + mov eax, [trackbuf+bootp.macaddr+3] ; get macaddr (netcard part) + mov [MyMAC2], eax mov eax, [trackbuf+bootp.yip] and eax, eax jz .noyip @@ -2484,6 +2517,8 @@ ; ; IP information (initialized to "unknown" values) +MyMAC1 dd 0 ; My MAC (vendor part) +MyMAC2 dd 0 ; My MAC (card part) MyIP dd 0 ; My IP address ServerIP dd 0 ; IP address of boot server Netmask dd 0 ; Netmask of this subnet -------------------------------------------------------------------- Hans-Werner Jouy -------------------------------------------------------------------- Hamburgische Landesbank Organisation/Informatik, Handelssysteme/SAP Gerhart-Hauptmann-Platz 50, 20095 Hamburg Im Internet: www.hamburglb.de -------------------------------------------------------------------- Hans-Werner.Jouy at HamburgLB.DE -------------------------------------------------------------------- ______________________________________________________________________ Diese Nachricht kann vertrauliche Informationen enthalten. Sollten Sie nicht der vorgesehene Empf?nger sein, so bitten wir um eine kurze Nachricht. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzul?ssig. Da wir nicht die Echtheit oder Vollst?ndigkeit der in dieser Nachricht enthaltenen Informationen garantieren k?nnen, schlie?en wir die rechtliche Verbindlichkeit der vorstehenden Erkl?rungen und ?u?erungen aus. This message may contain confidential information. If you are not the intended recipient please inform us. Any unauthorised dissemination, distribution or copying hereof is prohibited. As we cannot guarantee the genuineness or completeness of the information contained in this message, the statements set forth above are not legally binding. Hamburgische Landesbank - Girozentrale -