diff options
author | H. Peter Anvin <hpa@zytor.com> | 2012-05-27 12:57:21 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2012-05-27 12:57:21 -0700 |
commit | a35dce33744f649fdbc0af0da664554cccaa8248 (patch) | |
tree | f0a31d843379e324ad7d28b438cf0db927a7116f | |
parent | 0fa998ef1c083bfbd1ec6d57a2cacc7c46b1e63f (diff) | |
parent | 3857e1487f656fafb0aad778d38fc2beb3676435 (diff) | |
download | syslinux-a35dce33744f649fdbc0af0da664554cccaa8248.tar.gz |
Merge remote-tracking branch 'hdt/master'syslinux-4.06-pre4
-rw-r--r-- | com32/gpllib/disk/labels.c | 179 | ||||
-rw-r--r-- | com32/hdt/Makefile | 2 | ||||
-rw-r--r-- | com32/hdt/floppy/hdt.cfg | 9 | ||||
-rw-r--r-- | com32/hdt/hdt-cli-acpi.c | 2 | ||||
-rw-r--r-- | com32/hdt/hdt-cli-disk.c | 3 | ||||
-rw-r--r-- | com32/hdt/hdt-cli-dmi.c | 15 | ||||
-rw-r--r-- | com32/hdt/hdt-cli-hdt.c | 87 | ||||
-rw-r--r-- | com32/hdt/hdt-cli-memory.c | 5 | ||||
-rw-r--r-- | com32/hdt/hdt-cli-pci.c | 3 | ||||
-rw-r--r-- | com32/hdt/hdt-cli-vesa.c | 5 | ||||
-rw-r--r-- | com32/hdt/hdt-cli.c | 47 | ||||
-rw-r--r-- | com32/hdt/hdt-cli.h | 2 | ||||
-rw-r--r-- | com32/hdt/hdt.h | 2 | ||||
-rw-r--r-- | com32/lua/src/Makefile | 1 | ||||
-rw-r--r-- | com32/lua/src/dhcp.c | 358 | ||||
-rw-r--r-- | com32/lua/src/dhcp.h | 49 | ||||
-rw-r--r-- | com32/lua/src/linit.c | 1 | ||||
-rw-r--r-- | com32/lua/src/lualib.h | 3 | ||||
-rw-r--r-- | com32/modules/ifcpu.c | 25 |
19 files changed, 707 insertions, 91 deletions
diff --git a/com32/gpllib/disk/labels.c b/com32/gpllib/disk/labels.c index ad3d33b3..f27ff655 100644 --- a/com32/gpllib/disk/labels.c +++ b/com32/gpllib/disk/labels.c @@ -36,29 +36,29 @@ void get_label(int label, char **buffer_label) strlcpy(buffer, "DOS 3.31+ 16-bit FAT (over 32M)", buffer_size); break; case 0x07: - strlcpy(buffer, "OS/2 IFS (e.g., HPFS)", buffer_size); - break; + strlcpy(buffer, "NTFS/exFAT/HPFS", buffer_size); //case 0x07: strlcpy(buffer, "Advanced Unix", buffer_size); break; //case 0x07: strlcpy(buffer, "Windows NT NTFS", buffer_size); break; //case 0x07: strlcpy(buffer, "QNX2.x (pre-1988)", buffer_size); break; - case 0x08: - strlcpy(buffer, "OS/2 (v1.0-1.3 only)", buffer_size); break; + case 0x08: + strlcpy(buffer, "AIX", buffer_size); //case 0x08: strlcpy(buffer, "AIX boot partition", buffer_size); break; //case 0x08: strlcpy(buffer, "SplitDrive", buffer_size); break; //case 0x08: strlcpy(buffer, "DELL partition spanning multiple drives", buffer_size); break; //case 0x08: strlcpy(buffer, "Commodore DOS", buffer_size); break; //case 0x08: strlcpy(buffer, "QNX 1.x and 2.x ("qny")", buffer_size); break; - case 0x09: - strlcpy(buffer, "AIX data partition", buffer_size); break; + case 0x09: + strlcpy(buffer, "AIX bootable partition", buffer_size); //case 0x09: strlcpy(buffer, "Coherent filesystem", buffer_size); break; //case 0x09: strlcpy(buffer, "QNX 1.x and 2.x ("qnz")", buffer_size); break; + break; case 0x0a: strlcpy(buffer, "OS/2 Boot Manager", buffer_size); - break; //case 0x0a: strlcpy(buffer, "Coherent swap partition", buffer_size); break; //case 0x0a: strlcpy(buffer, "OPUS", buffer_size); break; + break; case 0x0b: strlcpy(buffer, "WIN95 OSR2 32-bit FAT", buffer_size); break; @@ -72,13 +72,13 @@ void get_label(int label, char **buffer_label) strlcpy(buffer, "WIN95: Extended partition, LBA-mapped", buffer_size); break; case 0x10: - strlcpy(buffer, "OPUS (?)", buffer_size); + strlcpy(buffer, "OPUS", buffer_size); break; case 0x11: strlcpy(buffer, "Hidden DOS 12-bit FAT", buffer_size); break; case 0x12: - strlcpy(buffer, "Compaq config partition", buffer_size); + strlcpy(buffer, "Compaq diagnostic partition", buffer_size); break; case 0x14: strlcpy(buffer, "Hidden DOS 16-bit FAT <32M", buffer_size); @@ -87,7 +87,7 @@ void get_label(int label, char **buffer_label) strlcpy(buffer, "Hidden DOS 16-bit FAT >=32M", buffer_size); break; case 0x17: - strlcpy(buffer, "Hidden IFS (e.g., HPFS)", buffer_size); + strlcpy(buffer, "Hidden HPFS/exFAT/NTFS", buffer_size); break; case 0x18: strlcpy(buffer, "AST SmartSleep Partition", buffer_size); @@ -111,8 +111,8 @@ void get_label(int label, char **buffer_label) break; case 0x21: strlcpy(buffer, "Reserved", buffer_size); - break; //case 0x21: strlcpy(buffer, "Unused", buffer_size); break; + break; case 0x22: strlcpy(buffer, "Unused", buffer_size); break; @@ -125,6 +125,18 @@ void get_label(int label, char **buffer_label) case 0x26: strlcpy(buffer, "Reserved", buffer_size); break; + case 0x27: + strlcpy(buffer, "PQService (Acer laptop hidden rescue partition)", buffer_size); + //Windows RE hidden partition + //MirOS BSD partition + //RouterBOOT kernel partition + break; + case 0x2a: + strlcpy(buffer, "AtheOS File System (AFS)", buffer_size); + break; + case 0x2b: + strlcpy(buffer, "SyllableSecure (SylStor)", buffer_size); + break; case 0x31: strlcpy(buffer, "Reserved", buffer_size); break; @@ -148,8 +160,8 @@ void get_label(int label, char **buffer_label) break; case 0x39: strlcpy(buffer, "Plan 9 partition", buffer_size); - break; //case 0x39: strlcpy(buffer, "THEOS ver 4 spanned partition", buffer_size); break; + break; case 0x3a: strlcpy(buffer, "THEOS ver 4 4gb partition", buffer_size); break; @@ -166,15 +178,15 @@ void get_label(int label, char **buffer_label) strlcpy(buffer, "Venix 80286", buffer_size); break; case 0x41: - strlcpy(buffer, "Linux/MINIX (sharing disk with DRDOS)", buffer_size); - break; + strlcpy(buffer, "PPC PReP Boot", buffer_size); break; //case 0x41: strlcpy(buffer, "Personal RISC Boot", buffer_size); break; - //case 0x41: strlcpy(buffer, "PPC PReP (Power PC Reference Platform) Boot", buffer_size); break; - case 0x42: - strlcpy(buffer, "Linux swap (sharing disk with DRDOS)", buffer_size); + // strlcpy(buffer, "Linux/MINIX (sharing disk with DRDOS)", buffer_size); break; - //case 0x42: strlcpy(buffer, "SFS (Secure Filesystem)", buffer_size); break; + case 0x42: + strlcpy(buffer, "SFS (Secure Filesystem)", buffer_size); break; + // strlcpy(buffer, "Linux swap (sharing disk with DRDOS)", buffer_size); //case 0x42: strlcpy(buffer, "Windows 2000 marker", buffer_size); break; + break; case 0x43: strlcpy(buffer, "Linux native (sharing disk with DRDOS)", buffer_size); break; @@ -183,9 +195,9 @@ void get_label(int label, char **buffer_label) break; case 0x45: strlcpy(buffer, "Boot-US boot manager", buffer_size); - break; //case 0x45: strlcpy(buffer, "Priam", buffer_size); break; //case 0x45: strlcpy(buffer, "EUMEL/Elan", buffer_size); break; + break; case 0x46: strlcpy(buffer, "EUMEL/Elan", buffer_size); break; @@ -197,8 +209,8 @@ void get_label(int label, char **buffer_label) break; case 0x4a: strlcpy(buffer, "AdaOS Aquila (Default)", buffer_size); - break; //case 0x4a: strlcpy(buffer, "ALFS/THIN lightweight filesystem for DOS", buffer_size); break; + break; case 0x4c: strlcpy(buffer, "Oberon partition", buffer_size); break; @@ -210,22 +222,22 @@ void get_label(int label, char **buffer_label) break; case 0x4f: strlcpy(buffer, "QNX4.x 3rd part", buffer_size); - break; //case 0x4f: strlcpy(buffer, "Oberon partition", buffer_size); break; + break; case 0x50: strlcpy(buffer, "OnTrack Disk Manager (older versions) RO", buffer_size); - break; //case 0x50: strlcpy(buffer, "Lynx RTOS", buffer_size); break; //case 0x50: strlcpy(buffer, "Native Oberon (alt)", buffer_size); break; + break; case 0x51: strlcpy(buffer, "OnTrack Disk Manager RW (DM6 Aux1)", buffer_size); - break; //case 0x51: strlcpy(buffer, "Novell", buffer_size); break; + break; case 0x52: strlcpy(buffer, "CP/M", buffer_size); - break; //case 0x52: strlcpy(buffer, "Microport SysV/AT", buffer_size); break; + break; case 0x53: strlcpy(buffer, "Disk Manager 6.0 Aux3", buffer_size); break; @@ -237,12 +249,12 @@ void get_label(int label, char **buffer_label) break; case 0x56: strlcpy(buffer, "Golden Bow VFeature Partitioned Volume.", buffer_size); - break; //case 0x56: strlcpy(buffer, "DM converted to EZ-BIOS", buffer_size); break; + break; case 0x57: strlcpy(buffer, "DrivePro", buffer_size); - break; //case 0x57: strlcpy(buffer, "VNDI Partition", buffer_size); break; + break; case 0x5c: strlcpy(buffer, "Priam EDisk", buffer_size); break; @@ -255,9 +267,9 @@ void get_label(int label, char **buffer_label) buffer_size); break; case 0x64: - strlcpy(buffer, "PC-ARMOUR protected partition", buffer_size); + strlcpy(buffer, "Novell Netware 286, 2.xx", buffer_size); break; + //strlcpy(buffer, "PC-ARMOUR protected partition", buffer_size); break; - //case 0x64: strlcpy(buffer, "Novell Netware 286, 2.xx", buffer_size); break; case 0x65: strlcpy(buffer, "Novell Netware 386, 3.xx or 4.xx", buffer_size); break; @@ -280,13 +292,15 @@ void get_label(int label, char **buffer_label) case 0x71: strlcpy(buffer, "Reserved", buffer_size); break; + case 0x72: + strlcpy(buffer, "V7/x86", buffer_size); + break; case 0x73: strlcpy(buffer, "Reserved", buffer_size); break; case 0x74: - strlcpy(buffer, "Reserved", buffer_size); - break; - //case 0x74: strlcpy(buffer, "Scramdisk partition", buffer_size); break; + //strlcpy(buffer, "Reserved", buffer_size); + strlcpy(buffer, "Scramdisk partition", buffer_size); break; case 0x75: strlcpy(buffer, "IBM PC/IX", buffer_size); break; @@ -301,37 +315,40 @@ void get_label(int label, char **buffer_label) strlcpy(buffer, "XOSL FS", buffer_size); break; case 0x7E: - strlcpy(buffer, " ", buffer_size); + strlcpy(buffer, "Unused", buffer_size); break; case 0x80: strlcpy(buffer, "MINIX until 1.4a", buffer_size); break; case 0x81: strlcpy(buffer, "MINIX since 1.4b, early Linux", buffer_size); - break; //case 0x81: strlcpy(buffer, "Mitac disk manager", buffer_size); break; - //case 0x82: strlcpy(buffer, "Prime", buffer_size); break; - //case 0x82: strlcpy(buffer, "Solaris x86", buffer_size); break; + break; case 0x82: strlcpy(buffer, "Linux swap", buffer_size); + //case 0x82: strlcpy(buffer, "Prime", buffer_size); break; + //case 0x82: strlcpy(buffer, "Solaris x86", buffer_size); break; break; case 0x83: strlcpy(buffer, "Linux native (usually ext2fs)", buffer_size); break; case 0x84: strlcpy(buffer, "OS/2 hidden C: drive", buffer_size); - break; //case 0x84: strlcpy(buffer, "Hibernation partition", buffer_size); break; + break; case 0x85: strlcpy(buffer, "Linux extended partition", buffer_size); break; - //case 0x86: strlcpy(buffer, "Old Linux RAID partition superblock", buffer_size); break; case 0x86: strlcpy(buffer, "NTFS volume set", buffer_size); + //case 0x86: strlcpy(buffer, "Old Linux RAID partition superblock", buffer_size); break; break; case 0x87: strlcpy(buffer, "NTFS volume set", buffer_size); break; + case 0x88: + strlcpy(buffer, "Linux Plaintext", buffer_size); + break; case 0x8a: strlcpy(buffer, "Linux Kernel Partition (used by AiR-BOOT)", buffer_size); @@ -349,7 +366,7 @@ void get_label(int label, char **buffer_label) buffer_size); break; case 0x8e: - strlcpy(buffer, "Linux Logical Volume Manager partition", buffer_size); + strlcpy(buffer, "Linux LVM partition", buffer_size); break; case 0x90: strlcpy(buffer, "Free FDISK hidden Primary DOS FAT16 partitition", @@ -365,14 +382,17 @@ void get_label(int label, char **buffer_label) break; case 0x93: strlcpy(buffer, "Hidden Linux native partition", buffer_size); - break; //case 0x93: strlcpy(buffer, "Amoeba", buffer_size); break; + break; case 0x94: strlcpy(buffer, "Amoeba bad block table", buffer_size); break; case 0x95: strlcpy(buffer, "MIT EXOPC native partitions", buffer_size); break; + case 0x96: + strlcpy(buffer, "CHRP ISO-9660 filesystem", buffer_size); + break; case 0x97: strlcpy(buffer, "Free FDISK hidden Primary DOS FAT32 partitition", buffer_size); @@ -392,6 +412,9 @@ void get_label(int label, char **buffer_label) strlcpy(buffer, "Free FDISK hidden DOS extended partitition (LBA)", buffer_size); break; + case 0x9e: + strlcpy(buffer, "ForthOS partition", buffer_size); + break; case 0x9f: strlcpy(buffer, "BSD/OS", buffer_size); break; @@ -400,13 +423,13 @@ void get_label(int label, char **buffer_label) break; case 0xa1: strlcpy(buffer, "Laptop hibernation partition", buffer_size); - break; //case 0xa1: strlcpy(buffer, "HP Volume Expansion (SpeedStor variant)", buffer_size); break; + break; case 0xa3: - strlcpy(buffer, "Reserved", buffer_size); + strlcpy(buffer, "HP Volume Expansion (SpeedStor variant)", buffer_size); break; case 0xa4: - strlcpy(buffer, "Reserved", buffer_size); + strlcpy(buffer, "HP Volume Expansion (SpeedStor variant)", buffer_size); break; case 0xa5: strlcpy(buffer, "BSD/386, 386BSD, NetBSD, FreeBSD", buffer_size); @@ -415,7 +438,7 @@ void get_label(int label, char **buffer_label) strlcpy(buffer, "OpenBSD", buffer_size); break; case 0xa7: - strlcpy(buffer, "NEXTSTEP", buffer_size); + strlcpy(buffer, "NeXTSTEP", buffer_size); break; case 0xa8: strlcpy(buffer, "Mac OS-X", buffer_size); @@ -429,8 +452,8 @@ void get_label(int label, char **buffer_label) break; case 0xab: strlcpy(buffer, "Mac OS-X Boot partition", buffer_size); - break; //case 0xab: strlcpy(buffer, "GO! partition", buffer_size); break; + break; case 0xae: strlcpy(buffer, "ShagOS filesystem", buffer_size); break; @@ -441,16 +464,19 @@ void get_label(int label, char **buffer_label) strlcpy(buffer, "BootStar Dummy", buffer_size); break; case 0xb1: - strlcpy(buffer, "Reserved", buffer_size); + strlcpy(buffer, "HP Volume Expansion (SpeedStor variant)", buffer_size); + break; + case 0xb2: + strlcpy(buffer, "QNX Neutrino Power-Safe filesystem", buffer_size); break; case 0xb3: - strlcpy(buffer, "Reserved", buffer_size); + strlcpy(buffer, "HP Volume Expansion (SpeedStor variant)", buffer_size); break; case 0xb4: - strlcpy(buffer, "Reserved", buffer_size); + strlcpy(buffer, "HP Volume Expansion (SpeedStor variant)", buffer_size); break; case 0xb6: - strlcpy(buffer, "Reserved", buffer_size); + strlcpy(buffer, "HP Volume Expansion (SpeedStor variant)", buffer_size); break; case 0xb7: strlcpy(buffer, "BSDI BSD/386 filesystem", buffer_size); @@ -461,21 +487,27 @@ void get_label(int label, char **buffer_label) case 0xbb: strlcpy(buffer, "Boot Wizard hidden", buffer_size); break; + case 0xbc: + strlcpy(buffer, "Acronis backup partition", buffer_size); + break; case 0xbe: strlcpy(buffer, "Solaris 8 boot partition", buffer_size); break; + case 0xbf: + strlcpy(buffer, "Solaris partition", buffer_size); + break; case 0xc0: strlcpy(buffer, "CTOS", buffer_size); - break; //case 0xc0: strlcpy(buffer, "REAL/32 secure small partition", buffer_size); break; //case 0xc0: strlcpy(buffer, "NTFT Partition", buffer_size); break; + break; case 0xc1: strlcpy(buffer, "DRDOS/secured (FAT-12)", buffer_size); break; case 0xc2: - strlcpy(buffer, "Reserved for DR-DOS 7+", buffer_size); + strlcpy(buffer, "Hidden Linux", buffer_size); break; + //strlcpy(buffer, "Reserved for DR-DOS 7+", buffer_size); break; - //case 0xc2: strlcpy(buffer, "Hidden Linux", buffer_size); break; case 0xc3: strlcpy(buffer, "Hidden Linux swap", buffer_size); break; @@ -487,21 +519,21 @@ void get_label(int label, char **buffer_label) break; case 0xc6: strlcpy(buffer, "DRDOS/secured (FAT-16, >= 32M)", buffer_size); - break; //case 0xc6: strlcpy(buffer, "Windows NT corrupted FAT16 volume/stripe set", buffer_size); break; + break; case 0xc7: strlcpy(buffer, "Windows NT corrupted NTFS volume/stripe set", buffer_size); - break; //case 0xc7: strlcpy(buffer, "Syrinx boot", buffer_size); break; + break; case 0xc8: - strlcpy(buffer, "(See also ID c2.)", buffer_size); + strlcpy(buffer, "Reserved for DR-DOS 8.0+", buffer_size); break; case 0xc9: - strlcpy(buffer, "(See also ID c2.)", buffer_size); + strlcpy(buffer, "Reserved for DR-DOS 8.0+", buffer_size); break; case 0xca: - strlcpy(buffer, "(See also ID c2.)", buffer_size); + strlcpy(buffer, "Reserved for DR-DOS 8.0+", buffer_size); break; case 0xcb: strlcpy(buffer, "reserved for DRDOS/secured (FAT32)", buffer_size); @@ -515,6 +547,9 @@ void get_label(int label, char **buffer_label) case 0xce: strlcpy(buffer, "reserved for DRDOS/secured (FAT16, LBA)", buffer_size); break; + case 0xcf: + strlcpy(buffer, "DR-DOS 7.04+ secured EXT DOS (LBA)", buffer_size); + break; case 0xd0: strlcpy(buffer, "REAL/32 secure big partition", buffer_size); break; @@ -541,9 +576,9 @@ void get_label(int label, char **buffer_label) strlcpy(buffer, "Digital Research CP/M, Concurrent CP/M, Concurrent DOS", buffer_size); - break; //case 0xdb: strlcpy(buffer, "CTOS (Convergent Technologies OS -Unisys)", buffer_size); break; //case 0xdb: strlcpy(buffer, "KDG Telemetry SCPU boot", buffer_size); break; + break; case 0xdd: strlcpy(buffer, "Hidden CTOS Memdump?", buffer_size); break; @@ -575,24 +610,30 @@ void get_label(int label, char **buffer_label) strlcpy(buffer, "Tandy DOS with logical sectored FAT (According to Powerquest.)", buffer_size); - break; //case 0xe5: strlcpy(buffer, "Reserved", buffer_size); break; + break; case 0xe6: - strlcpy(buffer, "Reserved", buffer_size); + strlcpy(buffer, "Storage Dimensions SpeedStor", buffer_size); + break; + case 0xe8: + strlcpy(buffer, "LUKS", buffer_size); break; case 0xeb: - strlcpy(buffer, "BFS (aka BeFS)", buffer_size); + strlcpy(buffer, "BeOS", buffer_size); + break; + case 0xec: + strlcpy(buffer, "SkyOS SkyFS", buffer_size); break; case 0xed: strlcpy(buffer, "Reserved for Matthias Paul's Sprytix", buffer_size); break; case 0xee: strlcpy(buffer, - "Indication that this legacy MBR is followed by an EFI header", + "GPT", buffer_size); break; case 0xef: - strlcpy(buffer, "Partition that contains an EFI file system", + strlcpy(buffer, "EFI file system", buffer_size); break; case 0xf0: @@ -613,8 +654,8 @@ void get_label(int label, char **buffer_label) break; case 0xf4: strlcpy(buffer, "SpeedStor large partition", buffer_size); - break; //case 0xf4: strlcpy(buffer, "Prologue single-volume partition", buffer_size); break; + break; case 0xf5: strlcpy(buffer, "Prologue multi-volume partition", buffer_size); break; @@ -623,6 +664,12 @@ void get_label(int label, char **buffer_label) "Reserved (Powerquest writes: Storage Dimensions SpeedStor. )", buffer_size); break; + case 0xf7: + strlcpy(buffer, "DDRdrive Solid State File System", buffer_size); + break; + case 0xf9: + strlcpy(buffer, "pCache", buffer_size); + break; case 0xfa: strlcpy(buffer, "Bochs", buffer_size); break; @@ -638,12 +685,12 @@ void get_label(int label, char **buffer_label) buffer_size); break; case 0xfe: - strlcpy(buffer, "SpeedStor > 1024 cyl.", buffer_size); - break; - //case 0xfe: strlcpy(buffer, "LANstep", buffer_size); break; + strlcpy(buffer, "LANstep", buffer_size); break; + //strlcpy(buffer, "SpeedStor > 1024 cyl.", buffer_size); //case 0xfe: strlcpy(buffer, "IBM PS/2 IML (Initial Microcode Load) partition, located at the end of the disk.", buffer_size); break; //case 0xfe: strlcpy(buffer, "Windows NT Disk Administrator hidden partition", buffer_size); break; //case 0xfe: strlcpy(buffer, "Linux Logical Volume Manager partition (old)", buffer_size); break; + break; case 0xff: strlcpy(buffer, "Xenix Bad Block Table ", buffer_size); break; diff --git a/com32/hdt/Makefile b/com32/hdt/Makefile index 17fa1ab6..ea9ddfeb 100644 --- a/com32/hdt/Makefile +++ b/com32/hdt/Makefile @@ -45,7 +45,7 @@ FLOPPY_DIR ?= floppy PCI_IDS_FILE ?= $(PWD)/$(FLOPPY_DIR)/pci.ids GZ_PCI_IDS_FILE ?= $(PCI_IDS_FILE).gz MENU_COM32 ?= $(com32)/menu/menu.c32 -CHAIN_COM32 ?= $(com32)/modules/chain.c32 +CHAIN_COM32 ?= $(com32)/chain/chain.c32 ART_DIR ?= art/ QEMU ?= qemu-kvm diff --git a/com32/hdt/floppy/hdt.cfg b/com32/hdt/floppy/hdt.cfg index c876d239..e5f3b0a0 100644 --- a/com32/hdt/floppy/hdt.cfg +++ b/com32/hdt/floppy/hdt.cfg @@ -86,6 +86,15 @@ ENDTEXT COM32 hdt.c32 APPEND modules_pcimap=modules.pcimap modules_alias=modules.alias pciids=pci.ids quiet vesa nomenu auto='dump' +LABEL postexec +MENU LABEL Dump memory info, sleep 5 and start memtest entry +TEXT HELP + Starts HDT using the Command Line Interface (CLI), show an item, say a message reboot and start memtest + VESA mode is enabled +ENDTEXT +COM32 hdt.c32 +APPEND modules_pcimap=modules.pcimap modules_alias=modules.alias pciids=pci.ids quiet vesa nomenu auto='show memory;say `########`;say `Starting memtest in 5 sec`%5;exit' postexec='memtest' + MENU SEPARATOR LABEL memtest diff --git a/com32/hdt/hdt-cli-acpi.c b/com32/hdt/hdt-cli-acpi.c index a978bb36..55b0c3c7 100644 --- a/com32/hdt/hdt-cli-acpi.c +++ b/com32/hdt/hdt-cli-acpi.c @@ -267,10 +267,12 @@ struct cli_callback_descr list_acpi_show_modules[] = { { .name = "apic", .exec = show_acpi_apic, + .nomodule = false, }, { .name = NULL, .exec = NULL, + .nomodule = false, }, }; diff --git a/com32/hdt/hdt-cli-disk.c b/com32/hdt/hdt-cli-disk.c index 24fce676..10c95d7d 100644 --- a/com32/hdt/hdt-cli-disk.c +++ b/com32/hdt/hdt-cli-disk.c @@ -225,14 +225,17 @@ struct cli_callback_descr list_disk_show_modules[] = { { .name = "disks", .exec = main_show_disks, + .nomodule = false, }, { .name = "disk", .exec = main_show_disk, + .nomodule = false, }, { .name = NULL, .exec = NULL, + .nomodule = false, }, }; diff --git a/com32/hdt/hdt-cli-dmi.c b/com32/hdt/hdt-cli-dmi.c index 45cbb240..02bea0f7 100644 --- a/com32/hdt/hdt-cli-dmi.c +++ b/com32/hdt/hdt-cli-dmi.c @@ -617,62 +617,77 @@ struct cli_callback_descr list_dmi_show_modules[] = { { .name = CLI_DMI_BASE_BOARD, .exec = show_dmi_base_board, + .nomodule = false, }, { .name = CLI_DMI_BIOS, .exec = show_dmi_bios, + .nomodule = false, }, { .name = CLI_DMI_BATTERY, .exec = show_dmi_battery, + .nomodule = false, }, { .name = CLI_DMI_CHASSIS, .exec = show_dmi_chassis, + .nomodule = false, }, { .name = CLI_DMI_MEMORY, .exec = show_dmi_memory_modules, + .nomodule = false, }, { .name = CLI_DMI_MEMORY_BANK, .exec = show_dmi_memory_bank, + .nomodule = false, }, { .name = "module", .exec = show_dmi_memory_module, + .nomodule = false, }, { .name = CLI_DMI_PROCESSOR, .exec = show_dmi_cpu, + .nomodule = false, }, { .name = CLI_DMI_SYSTEM, .exec = show_dmi_system, + .nomodule = false, }, { .name = CLI_DMI_OEM, .exec = show_dmi_oem_strings, + .nomodule = false, }, { .name = CLI_DMI_SECURITY, .exec = show_dmi_hardware_security, + .nomodule = false, }, { .name = CLI_DMI_IPMI, .exec = show_dmi_ipmi, + .nomodule = false, }, { .name = CLI_DMI_CACHE, .exec = show_dmi_cache, + .nomodule = false, }, { .name = CLI_DMI_LIST, .exec = show_dmi_modules, + .nomodule = false, }, { .name = NULL, .exec = NULL, + .nomodule = false, }, }; diff --git a/com32/hdt/hdt-cli-hdt.c b/com32/hdt/hdt-cli-hdt.c index e9752612..f7f7e949 100644 --- a/com32/hdt/hdt-cli-hdt.c +++ b/com32/hdt/hdt-cli-hdt.c @@ -259,101 +259,184 @@ static void do_dump(int argc __unused, char **argv __unused, dump(hardware); } +/** + * do_say - say message to user + **/ +static void do_say(int argc , char **argv , + struct s_hardware *hardware) +{ + (void) hardware; + if (argc == 0) return; + + char text_to_say[255]={0}; + int arg=0; + int sleep_time=0; +#if DEBUG + for (int i=0; i<argc;i++) dprintf("SAY: arg[%d]={%s}\n",i,argv[i]); +#endif + char *argument = strchr(argv[arg],'`'); + if ( argument != NULL) { + argument++; + strcat(text_to_say, argument); + + while ((strchr(argument, '`') == NULL) && (arg+1<argc)) { + arg++; + argument = (char *)argv[arg]; + strcat(text_to_say, " "); + strcat(text_to_say, argument); + } + + /* Removing last ` if any */ + char *last_quote = strrchr(text_to_say,'`'); + if ( last_quote != NULL ) { + *last_quote='\0'; + dprintf("SAY CMD = [%s]\n",text_to_say); + } + + /* The % char can be in the same argument, let's consider it again */ + arg--; + + /* Searching for a % argument to determine the time to show the message */ + char *time_to_display = NULL; + /* Search for a requested time to display */ + while ( ((time_to_display=strchr(argument, '%')) == NULL) && (arg+1<argc)) { + arg++; + argument = (char *)argv[arg]; + } + + if (time_to_display != NULL) { + sleep_time=atoi(time_to_display+1); + dprintf("SAY CMD :Time to display = %d\n",sleep_time); + } + + printf("%s\n",text_to_say); + sleep(sleep_time); + } +} + /* Default hdt mode */ struct cli_callback_descr list_hdt_default_modules[] = { { .name = CLI_CLEAR, .exec = cli_clear_screen, + .nomodule = false, }, { .name = CLI_EXIT, .exec = do_exit, + .nomodule = false, }, { .name = CLI_HELP, .exec = show_cli_help, + .nomodule = false, }, { .name = CLI_MENU, .exec = goto_menu, + .nomodule = false, }, { .name = CLI_REBOOT, .exec = do_reboot, + .nomodule = false, }, { .name = CLI_HISTORY, .exec = print_history, + .nomodule = false, }, { .name = CLI_DUMP, .exec = do_dump, + .nomodule = false, + }, + { + .name = CLI_SAY, + .exec = do_say, + .nomodule = true, }, { .name = NULL, - .exec = NULL}, + .exec = NULL, + .nomodule = false}, }; struct cli_callback_descr list_hdt_show_modules[] = { { .name = CLI_SUMMARY, .exec = main_show_summary, + .nomodule = false, }, { .name = CLI_PCI, .exec = main_show_pci, + .nomodule = false, }, { .name = CLI_DMI, .exec = main_show_dmi, + .nomodule = false, }, { .name = CLI_CPU, .exec = main_show_cpu, + .nomodule = false, }, { .name = CLI_DISK, .exec = disks_summary, + .nomodule = false, }, { .name = CLI_PXE, .exec = main_show_pxe, + .nomodule = false, }, { .name = CLI_SYSLINUX, .exec = main_show_syslinux, + .nomodule = false, }, { .name = CLI_KERNEL, .exec = main_show_kernel, + .nomodule = false, }, { .name = CLI_VESA, .exec = main_show_vesa, + .nomodule = false, }, { .name = CLI_HDT, .exec = main_show_hdt, + .nomodule = false, }, { .name = CLI_VPD, .exec = main_show_vpd, + .nomodule = false, }, { .name = CLI_MEMORY, .exec = show_dmi_memory_modules, + .nomodule = false, }, { .name = CLI_ACPI, .exec = main_show_acpi, + .nomodule = false, }, { .name = "modes", .exec = main_show_modes, + .nomodule = false, }, { .name = NULL, .exec = NULL, + .nomodule = false, }, }; @@ -361,10 +444,12 @@ struct cli_callback_descr list_hdt_set_modules[] = { { .name = CLI_MODE, .exec = cli_set_mode, + .nomodule = false, }, { .name = NULL, .exec = NULL, + .nomodule = false, }, }; diff --git a/com32/hdt/hdt-cli-memory.c b/com32/hdt/hdt-cli-memory.c index 51d087e8..c05b7cd6 100644 --- a/com32/hdt/hdt-cli-memory.c +++ b/com32/hdt/hdt-cli-memory.c @@ -101,22 +101,27 @@ struct cli_callback_descr list_memory_show_modules[] = { { .name = "e820", .exec = show_memory_e820, + .nomodule=false, }, { .name = "e801", .exec = show_memory_e801, + .nomodule=false, }, { .name = "88", .exec = show_memory_88, + .nomodule=false, }, { .name = CLI_DMI_MEMORY_BANK, .exec = show_dmi_memory_bank, + .nomodule=false, }, { .name = NULL, .exec = NULL, + .nomodule=false, }, }; diff --git a/com32/hdt/hdt-cli-pci.c b/com32/hdt/hdt-cli-pci.c index 07c079d5..75fc0011 100644 --- a/com32/hdt/hdt-cli-pci.c +++ b/com32/hdt/hdt-cli-pci.c @@ -266,14 +266,17 @@ struct cli_callback_descr list_pci_show_modules[] = { { .name = CLI_IRQ, .exec = show_pci_irq, + .nomodule=false, }, { .name = CLI_PCI_DEVICE, .exec = show_pci_device, + .nomodule=false, }, { .name = NULL, .exec = NULL, + .nomodule=false, }, }; diff --git a/com32/hdt/hdt-cli-vesa.c b/com32/hdt/hdt-cli-vesa.c index 702f8bd6..ca44987a 100644 --- a/com32/hdt/hdt-cli-vesa.c +++ b/com32/hdt/hdt-cli-vesa.c @@ -98,10 +98,12 @@ struct cli_callback_descr list_vesa_show_modules[] = { { .name = CLI_MODES, .exec = show_vesa_modes, + .nomodule=false, }, { .name = NULL, .exec = NULL, + .nomodule=false, }, }; @@ -109,15 +111,18 @@ struct cli_callback_descr list_vesa_commands[] = { { .name = CLI_ENABLE, .exec = enable_vesa, + .nomodule=false, }, { .name = CLI_DISABLE, .exec = disable_vesa, + .nomodule=false, }, { .name = NULL, .exec = NULL, + .nomodule=false, }, }; diff --git a/com32/hdt/hdt-cli.c b/com32/hdt/hdt-cli.c index 330f93c4..11984e5a 100644 --- a/com32/hdt/hdt-cli.c +++ b/com32/hdt/hdt-cli.c @@ -365,14 +365,14 @@ static void parse_command_line(char *line, char **command, char **module, *command = malloc((token_len + 1) * sizeof(char)); strlcpy(*command, pch, token_len); (*command)[token_len] = '\0'; - dprintf("CLI DEBUG: command = %s\n", *command); + dprintf("CLI DEBUG parse: command = %s\n", *command); args_pos += args_len; } else if (token_found == 1) { /* Module */ *module = malloc((token_len + 1) * sizeof(char)); strlcpy(*module, pch, token_len); (*module)[token_len] = '\0'; - dprintf("CLI DEBUG: module = %s\n", *module); + dprintf("CLI DEBUG parse: module = %s\n", *module); args_pos += args_len; } else (*argc)++; @@ -380,7 +380,7 @@ static void parse_command_line(char *line, char **command, char **module, token_found++; pch = pch_next; } - dprintf("CLI DEBUG: argc = %d\n", *argc); + dprintf("CLI DEBUG parse: argc = %d\n", *argc); /* Skip arguments handling if none is supplied */ if (!*argc) @@ -390,9 +390,9 @@ static void parse_command_line(char *line, char **command, char **module, *argv = malloc(*argc * sizeof(char *)); pch = strtok(line + args_pos, CLI_SPACE); while (pch != NULL) { - dprintf("CLI DEBUG: argv[%d] = %s\n", argc_iter, pch); - argv[argc_iter] = malloc(sizeof(pch) * sizeof(char)); - strlcpy(argv[argc_iter], pch, sizeof(pch)); + dprintf("CLI DEBUG parse: argv[%d] = %s\n", argc_iter, pch); + argv[argc_iter] = malloc(strlen(pch) * sizeof(char)); + strlcpy(argv[argc_iter], pch, strlen(pch)); argc_iter++; pch = strtok(NULL, CLI_SPACE); /* @@ -585,6 +585,7 @@ static void autocomplete(char *line) parse_command_line(line, &command, &module, &argc, argv); + dprintf("CLI DEBUG autocomplete: before checking args\n"); /* If the user specified arguments, there is nothing we can complete */ if (argc != 0) goto out; @@ -625,22 +626,43 @@ static void exec_command(char *line, struct s_hardware *hardware) /* This will allocate memory for command and module */ parse_command_line(line, &command, &module, &argc, argv); + dprintf("CLI DEBUG exec: Checking for aliases\n"); /* * Expand shortcuts, if needed * This will allocate memory for argc/argv */ expand_aliases(line, &command, &module, &argc, argv); + + find_cli_callback_descr(command, current_mode->default_modules, + ¤t_module); - if (module == NULL) { - dprintf("CLI DEBUG: single command detected\n"); + if ((module == NULL) || (current_module->nomodule == true)) { + dprintf("CLI DEBUG exec : single command detected\n"); /* * A single word was specified: look at the list of default * commands in the current mode to see if there is a match. * If not, it may be a generic function (exit, help, ...). These * are stored in the list of default commands of the hdt mode. */ - find_cli_callback_descr(command, current_mode->default_modules, - ¤t_module); + + /* First of all it the command doesn't need module, let's rework the arguments */ + if ((current_module->nomodule == true) && ( module != NULL)) { + dprintf("CLI_DEBUG exec: Reworking arguments with argc=%d\n",argc); + char **new_argv=NULL; + new_argv=malloc((argc + 2)*sizeof(char)); + for (int argc_iter=0; argc_iter<argc; argc_iter++) { + dprintf("CLI_DEBUG exec rework : copy %d to %d (%s)\n",argc_iter,argc_iter+1,argv[argc_iter]); + new_argv[argc_iter+1] = malloc(strlen(argv[argc_iter])); + strlcpy(new_argv[argc_iter+1], argv[argc_iter], strlen(argv[argc_iter])); + free(argv[argc_iter]); + } + new_argv[0] = malloc(strlen(module)*sizeof(char)); + strlcpy(new_argv[0], module, strlen(module)); + argc++; + free(argv); + argv=new_argv; + } + if (current_module != NULL) current_module->exec(argc, argv, hardware); else if (!strncmp(command, CLI_SHOW, sizeof(CLI_SHOW) - 1) && @@ -673,7 +695,7 @@ static void exec_command(char *line, struct s_hardware *hardware) * hdt> set mode dmi */ if (!strncmp(command, CLI_SHOW, sizeof(CLI_SHOW) - 1)) { - dprintf("CLI DEBUG: %s command detected\n", CLI_SHOW); + dprintf("CLI DEBUG exec: %s command detected\n", CLI_SHOW); /* Look first for a 'show' callback in the current mode */ find_cli_callback_descr(module, current_mode->show_modules, ¤t_module); @@ -681,6 +703,7 @@ static void exec_command(char *line, struct s_hardware *hardware) if (current_module != NULL) current_module->exec(argc, argv, hardware); else { + dprintf("CLI DEBUG exec: Looking for callback\n"); /* Look now for a 'show' callback in the hdt mode */ find_cli_callback_descr(module, hdt_mode.show_modules, ¤t_module); @@ -691,7 +714,7 @@ static void exec_command(char *line, struct s_hardware *hardware) printf("unknown module: '%s'\n", module); } } else if (!strncmp(command, CLI_SET, sizeof(CLI_SET) - 1)) { - dprintf("CLI DEBUG: %s command detected\n", CLI_SET); + dprintf("CLI DEBUG exec : %s command detected\n", CLI_SET); /* Look now for a 'set' callback in the hdt mode */ find_cli_callback_descr(module, current_mode->set_modules, ¤t_module); diff --git a/com32/hdt/hdt-cli.h b/com32/hdt/hdt-cli.h index 68b33158..30fe5187 100644 --- a/com32/hdt/hdt-cli.h +++ b/com32/hdt/hdt-cli.h @@ -66,6 +66,7 @@ #define CLI_ENABLE "enable" #define CLI_DISABLE "disable" #define CLI_DUMP "dump" +#define CLI_SAY "say" typedef enum { INVALID_MODE, @@ -120,6 +121,7 @@ struct cli_module_descr { struct cli_callback_descr { const char *name; void (*exec) (int argc, char **argv, struct s_hardware * hardware); + bool nomodule; }; /* Manage aliases */ diff --git a/com32/hdt/hdt.h b/com32/hdt/hdt.h index 9b9e8a10..041d726d 100644 --- a/com32/hdt/hdt.h +++ b/com32/hdt/hdt.h @@ -33,7 +33,7 @@ #define AUTHOR "Erwan Velu" #define CORE_DEVELOPER "Pierre-Alexandre Meyer" #define CONTACT "hdt@zytor.com" -#define VERSION "0.5.2-pre1" +#define VERSION "0.5.2-pre2" #define CODENAME "Manon" #define NB_CONTRIBUTORS 3 #define CONTRIBUTORS {"Sebastien Gonzalve (Patches)", "Gert Hulselmans (Tests)", "Alexander Andino (Design)"} diff --git a/com32/lua/src/Makefile b/com32/lua/src/Makefile index 14b0e33d..f03f7a7f 100644 --- a/com32/lua/src/Makefile +++ b/com32/lua/src/Makefile @@ -44,6 +44,7 @@ LIBLUA_OBJS += dmi.o LIBLUA_OBJS += cpu.o LIBLUA_OBJS += pci.o LIBLUA_OBJS += vesa.o +LIBLUA_OBJS += dhcp.o CFLAGS += -DLUA_ANSI diff --git a/com32/lua/src/dhcp.c b/com32/lua/src/dhcp.c new file mode 100644 index 00000000..af948131 --- /dev/null +++ b/com32/lua/src/dhcp.c @@ -0,0 +1,358 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 2007 H. Peter Anvin - All Rights Reserved + * Copyright 2011 Timothy J Gleason <timmgleason_at_gmail.com> - All Rights Reserved + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall + * be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * ----------------------------------------------------------------------- */ + +/* + * dhcp.c + * + * Adds DHCPINFO functionality to the lua.c32 binary + * + * gettable() returns a table of the BOOTP message fields returned by + * the DHCP server for use in a Lua pxeboot script + * See http://tools.ietf.org/html/rfc1542 + * + * lua key value RFC key + * ----------------------------------------------------------------------- + * opcode op message opcode + * hardware.type htype Hardware address type + * hardware.length hlen Hardware address length + * hops hops Used by relay agents + * transaction.id xid transaction id + * elapsed.seconds secs Secs elapsed since client boot + * flags flags DHCP Flags field + * client.ip.addr ciaddr client IP addr + * your.ip.addr yiaddr 'Your' IP addr. (from server) + * server.ip.addr siaddr Boot server IP addr + * gateway.ip.addr giaddr Relay agent IP addr + * client.mac chaddr Client hardware addr + * server.hostname sname Optl. boot server hostname + * boot.file file boot file name (ascii path) + * magic.cookie cookie Magic cookie + * + * getoptions() returns a table of the DHCP Options field of the BOOTP + * message returned by the DHCP server for use in a Lua pxeboot script. + * Many of the options are reurned formatted in as strings in a standard, + * recognizable format, such as IP addresses. + * + * 1, 2, and 4 byte numerical options are returned as integers. + * + * Other Options with non-standard formats are returned as strings of the + * raw binary number that was returned by the DHCP server and must be decoded + * in a Lua script + * + * The Options table returns the Option code as the key except where there + * are multiple values returned. In those cases, an extra key increment number + * is added to allow individual access to each Option value. + * + * lua key value value Name + * ----------------------------------------------------------------------- + * 1 Subnet Mask + * 6.1 DNS Server [element 1] + * 6.2 DNS Server [element 2] + * 6.3 DNS Server [element 3] + * 209 PXE Configuration File + * 21.1 Policy Filter [element 1] + * 21.2 Policy Filter [element 2] + * + * Options that can have a list of values, but contain only one (like Option 6) + * will not return with .sub key values. + * + * Usage: + t = dhcp.gettable() + + for k,v in pairs(t) do + print(k.." : "..v) + end + */ + +#include <stdio.h> +#include "dhcp.h" +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" +#include <syslinux/pxe.h> + +#define STR_BUF_SIZE 129 /* Sized to accomdate File field in BOOTP message */ + +void +ip_address_list(lua_State *L, uint8_t* value, uint8_t len, uint8_t option ) +{ + static char op_name[64]; + static char op_value[255]; + int loop; + + loop = len/4; + + if ( loop == 1) { + sprintf(op_name, "%u", option); + lua_pushstring(L, op_name); + sprintf(op_value, "%u.%u.%u.%u", value[0], value[1], value[2], value[3]); + lua_pushstring(L, op_value); + lua_settable(L,-3); + } else { + for (int done = 0; done < loop; done++){ + sprintf(op_name, "%u.%d", option, done+1); + lua_pushstring(L, op_name); + sprintf(op_value, "%u.%u.%u.%u", value[0+(done*4)], value[1+(done*4)], value[2+(done*4)], value[3+(done*4)]); + lua_pushstring(L, op_value); + lua_settable(L,-3); + } + } + +} + +static int dhcp_getoptions(lua_State *L) +{ + void* dhcpdata = 0; + dhcp_t* dhcp = 0; + size_t dhcplen = 0; + + /* Append the DHCP info */ + if (pxe_get_cached_info(PXENV_PACKET_TYPE_DHCP_ACK, + &dhcpdata, &dhcplen)) + { + return 0; + } + + dhcp = (dhcp_t*)dhcpdata; + + lua_newtable(L); + + int done = 0; + uint8_t* ptr = (uint8_t*)&dhcp->options; + uint8_t len; + uint8_t option; + uint8_t* value; + static char op_name[64]; + + do { + option = *ptr++; + len = *ptr++; + value = ptr; + ptr += len; + switch (option) { +// IP Address formatted lists, including singles + case 1: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 16: + case 21: /* Policy Filters - address/mask */ + case 28: + case 32: + case 33: /* Static routes - destination/router */ + case 41: + case 42: + case 44: + case 45: + case 47: + case 48: + case 49: + case 50: + case 51: + case 54: + case 65: + case 68: + case 69: + case 70: + case 71: + case 72: + case 73: + case 74: + case 75: + case 76: + ip_address_list(L, value, len, option); + break; +// 4byte options - numerical + case 2: + case 24: + case 35: + case 38: + case 58: + case 59: + case 211: + sprintf(op_name, "%u", option); + lua_pushstring(L, op_name); + lua_pushinteger(L, ntohl(*(long*)value)); + lua_settable(L,-3); + break; +// 2byte options -numerical + case 13: + case 22: + case 26: + case 57: + sprintf(op_name, "%u", option); + lua_pushstring(L, op_name); + lua_pushinteger(L, ntohs(*(short*)value)); + lua_settable(L,-3); + break; +// 1byte options - numerical + case 19: + case 20: + case 23: + case 27: + case 29: + case 30: + case 31: + case 34: + case 36: + case 37: + case 39: + case 46: + case 52: + case 53: + sprintf(op_name, "%u", option); + lua_pushstring(L, op_name); + lua_pushinteger(L, *value); + lua_settable(L,-3); + break; + case 255: + done = 1; + break; + default: + sprintf(op_name, "%u", option); + lua_pushstring(L, op_name); + lua_pushlstring(L, (const char*)value, len); + lua_settable(L,-3); + break; + } + + } while (!done); + + return 1; +} + +static int dhcp_gettable(lua_State *L) +{ + void* dhcpdata = 0; + dhcp_t* dhcp = 0; + size_t dhcplen = 0; + static char dhcp_arg[STR_BUF_SIZE]; + + /* Append the DHCP info */ + if (pxe_get_cached_info(PXENV_PACKET_TYPE_DHCP_ACK, + &dhcpdata, &dhcplen)) + { + return 0; + } + + dhcp = (dhcp_t*)dhcpdata; + + + lua_newtable(L); + + lua_pushstring(L, "opcode"); + lua_pushinteger(L, dhcp->op); + lua_settable(L,-3); + + lua_pushstring(L, "hardware.type"); + lua_pushinteger(L, dhcp->htype); + lua_settable(L,-3); + + lua_pushstring(L, "hardware.length"); + lua_pushinteger(L, dhcp->hlen); + lua_settable(L,-3); + + lua_pushstring(L, "hops"); + lua_pushinteger(L, dhcp->hops); + lua_settable(L,-3); + + lua_pushstring(L, "transaction.id"); + lua_pushinteger(L, ntohl(dhcp->xid)); + lua_settable(L,-3); + + lua_pushstring(L, "elapsed.seconds"); + lua_pushinteger(L, ntohs(dhcp->secs)); + lua_settable(L,-3); + + lua_pushstring(L, "flags"); + lua_pushinteger(L, ntohs(dhcp->flags)); + lua_settable(L,-3); + + sprintf(dhcp_arg, "%u.%u.%u.%u", dhcp->ciaddr[0], dhcp->ciaddr[1], dhcp->ciaddr[2], dhcp->ciaddr[3]); + lua_pushstring(L, "client.ip.addr"); + lua_pushstring(L, dhcp_arg); + lua_settable(L,-3); + + sprintf(dhcp_arg, "%u.%u.%u.%u", dhcp->yiaddr[0], dhcp->yiaddr[1], dhcp->yiaddr[2], dhcp->yiaddr[3]); + lua_pushstring(L, "your.ip.addr"); + lua_pushstring(L, dhcp_arg); + lua_settable(L,-3); + + sprintf(dhcp_arg, "%u.%u.%u.%u", dhcp->siaddr[0], dhcp->siaddr[1], dhcp->siaddr[2], dhcp->siaddr[3]); + lua_pushstring(L, "server.ip.addr"); + lua_pushstring(L, dhcp_arg); + lua_settable(L,-3); + + sprintf(dhcp_arg, "%u.%u.%u.%u", dhcp->giaddr[0], dhcp->giaddr[1], dhcp->giaddr[2], dhcp->giaddr[3]); + lua_pushstring(L, "gateway.ip.addr"); + lua_pushstring(L, dhcp_arg); + lua_settable(L,-3); + + sprintf(dhcp_arg, "%02X:%02X:%02X:%02X:%02X:%02X", + dhcp->chaddr[0], dhcp->chaddr[1], dhcp->chaddr[2], + dhcp->chaddr[3], dhcp->chaddr[4], dhcp->chaddr[5]); + lua_pushstring(L, "client.mac"); + lua_pushstring(L, dhcp_arg); + lua_settable(L,-3); + + snprintf(dhcp_arg, STR_BUF_SIZE, "%s", dhcp->sname); + dhcp_arg[STR_BUF_SIZE-1] = 0; /* Guarantee for lua_pushstring that dhcp_arg is 0 terminated /*/ + lua_pushstring(L, "server.hostname"); + lua_pushstring(L, dhcp_arg); + lua_settable(L,-3); + + snprintf(dhcp_arg, STR_BUF_SIZE, "%s", dhcp->file); + dhcp_arg[STR_BUF_SIZE-1] = 0; /* Guarantee for lua_pushstring that dhcp_arg is 0 terminated /*/ + lua_pushstring(L, "boot.file"); + lua_pushstring(L, dhcp_arg); + lua_settable(L,-3); + + sprintf(dhcp_arg, "%u.%u.%u.%u", dhcp->cookie[0], dhcp->cookie[1], dhcp->cookie[2], dhcp->cookie[3]); + lua_pushstring(L, "magic.cookie"); + lua_pushstring(L, dhcp_arg); + lua_settable(L,-3); + + return 1; +} + +static const luaL_reg dhcplib[] = { + {"gettable", dhcp_gettable}, + {"getoptions", dhcp_getoptions}, + {NULL, NULL} +}; + +LUALIB_API int luaopen_dhcp (lua_State *L) { + luaL_openlib(L, LUA_DHCPLIBNAME, dhcplib, 0); + return 1; +} diff --git a/com32/lua/src/dhcp.h b/com32/lua/src/dhcp.h new file mode 100644 index 00000000..a398cfc1 --- /dev/null +++ b/com32/lua/src/dhcp.h @@ -0,0 +1,49 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 2007 H. Peter Anvin - All Rights Reserved + * Copyright 2011 Timothy J Gleason <timmgleason_at_gmail.com> - All Rights Reserved + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall + * be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * ----------------------------------------------------------------------- */ + +#include <stdint.h> + +typedef struct dhcp { + uint8_t op; /* message opcode */ + uint8_t htype; /* Hardware address type */ + uint8_t hlen; /* Hardware address length */ + uint8_t hops; /* Used by relay agents */ + uint32_t xid; /* transaction id */ + uint16_t secs; /* Secs elapsed since client boot */ + uint16_t flags; /* DHCP Flags field */ + uint8_t ciaddr[4]; /* client IP addr */ + uint8_t yiaddr[4]; /* 'Your' IP addr. (from server) */ + uint8_t siaddr[4]; /* Boot server IP addr */ + uint8_t giaddr[4]; /* Relay agent IP addr */ + uint8_t chaddr[16]; /* Client hardware addr */ + uint8_t sname[64]; /* Optl. boot server hostname */ + uint8_t file[128]; /* boot file name (ascii path) */ + uint8_t cookie[4]; /* Magic cookie */ + uint8_t options[1020]; /* Options */ +} dhcp_t; + diff --git a/com32/lua/src/linit.c b/com32/lua/src/linit.c index 6c7f63e4..6e978736 100644 --- a/com32/lua/src/linit.c +++ b/com32/lua/src/linit.c @@ -33,6 +33,7 @@ static const luaL_Reg lualibs[] = { {LUA_PCILIBNAME, luaopen_pci}, {LUA_SYSLINUXLIBNAME, luaopen_syslinux}, {LUA_VESALIBNAME, luaopen_vesa}, + {LUA_DHCPLIBNAME, luaopen_dhcp}, #endif {NULL, NULL} }; diff --git a/com32/lua/src/lualib.h b/com32/lua/src/lualib.h index 0ae6ba75..40d1bf29 100644 --- a/com32/lua/src/lualib.h +++ b/com32/lua/src/lualib.h @@ -54,6 +54,9 @@ LUALIB_API int (luaopen_vesa) (lua_State *L); #define LUA_CPULIBNAME "cpu" LUALIB_API int (luaopen_cpu) (lua_State *L); + +#define LUA_DHCPLIBNAME "dhcp" +LUALIB_API int (luaopen_dhcp) (lua_State *L); #endif /* open all previous libraries */ diff --git a/com32/modules/ifcpu.c b/com32/modules/ifcpu.c index a28acc4e..0aa63327 100644 --- a/com32/modules/ifcpu.c +++ b/com32/modules/ifcpu.c @@ -49,11 +49,12 @@ static void usage(void) " dry-run : just do the detection, don't boot \n" "\n" "cpu_features could be:\n" - " 64 : Processor is x86_64 compatible (lm cpu flag)\n" - " hvm : Processor features hardware virtualization (hvm or svm cpu flag)\n" - " multicore : Processor must be multi-core \n" - " smp : System must be multi-processor \n" - " pae : Processor features Physical Address Extension (PAE)\n" + " 64 : Processor is x86_64 compatible (lm cpu flag)\n" + " hvm : Processor features hardware virtualization (hvm or svm cpu flag)\n" + " multicore : Processor must be multi-core \n" + " smp : System must be multi-processor \n" + " pae : Processor features Physical Address Extension (PAE)\n" + " hypervisor : Processor is running under an hypervisor\n" "\n" "if you want to match many cpu features, just separate them with a single space.\n"); } @@ -114,30 +115,34 @@ int main(int argc, char *argv[]) args[n++] = &argv[i + 1]; } else if (!strcmp(argv[i], "64")) { if (debug) - printf(" 64bit : %s on this system\n", + printf(" 64bit : %s on this system\n", show_bool(cpu.flags.lm)); hardware_matches = cpu.flags.lm && hardware_matches; } else if (!strcmp(argv[i], "pae")) { if (debug) - printf(" pae : %s on this system\n", + printf(" pae : %s on this system\n", show_bool(cpu.flags.pae)); hardware_matches = cpu.flags.pae && hardware_matches; } else if (!strcmp(argv[i], "hvm")) { if (debug) - printf(" hvm : %s on this system\n", + printf(" hvm : %s on this system\n", show_bool((cpu.flags.vmx || cpu.flags.svm))); hardware_matches = (cpu.flags.vmx || cpu.flags.svm) && hardware_matches; } else if (!strcmp(argv[i], "multicore")) { if (debug) - printf(" multicore : %d cores on this system\n", cpu.num_cores); + printf(" multicore : %d cores on this system\n", cpu.num_cores); if (cpu.num_cores > 1) multicore = true; hardware_matches = multicore && hardware_matches; } else if (!strcmp(argv[i], "smp")) { if (debug) - printf(" smp : %s on this system\n", show_bool(cpu.flags.smp)); + printf(" smp : %s on this system\n", show_bool(cpu.flags.smp)); hardware_matches = cpu.flags.smp && hardware_matches; + } else if (!strcmp(argv[i], "hypervisor")) { + if (debug) + printf(" hypervisor : %s on this system\n", show_bool(cpu.flags.hypervisor)); + hardware_matches = cpu.flags.hypervisor && hardware_matches; } else if (!strcmp(argv[i], "dry-run")) { dryrun = true; } else if (!strcmp(argv[i], "debug")) { |