more_printf("PCI Bus : %02d\n",bus);
more_printf("PCI Slot : %02d\n",slot);
more_printf("PCI Func : %02d\n",func);
- if ((hardware->pxe.pci_device != NULL) && (hardware->pxe.pci_device == pci_device)) {
- more_printf("PXE : Current boot device\n",func);
+
+ if (hardware->is_pxe_valid == true) {
+ more_printf("Mac Address : %s\n",hardware->pxe.mac_addr);
+ if ((hardware->pxe.pci_device != NULL) && (hardware->pxe.pci_device == pci_device))
+ more_printf("PXE : Current boot device\n",func);
}
}
more_printf(" PCI device no: %d \n", p->pci_device_pos);
if (hardware->pci_ids_return_code == -ENOPCIIDS) {
- snprintf(buffer,sizeof(buffer)," PCI ID : %04x:%04x[%04x:%04X] rev(%02x)\n",
+ snprintf(buffer,sizeof(buffer)," PCI ID : %04x:%04x[%04x:%04X] rev(%02x)\n",
p->vendor_id, p->product_id, p->subvendor_id, p->subproduct_id,
p->rev);
- snprintf(buffer,sizeof(buffer)," PCI Bus pos. : %02x:%02x.%02x\n",
+ snprintf(buffer,sizeof(buffer)," PCI Bus pos. : %02x:%02x.%02x\n",
p->pci_bus,p->pci_dev, p->pci_func);
-
- more_printf(buffer);
+ more_printf(buffer);
} else {
- snprintf(buffer,sizeof(buffer)," Manufacturer : %s \n", p->pci_device->dev_info->vendor_name);
- more_printf(buffer);
- snprintf(buffer,sizeof(buffer)," Product : %s \n", p->pci_device->dev_info->product_name);
- more_printf(buffer);
-
+ snprintf(buffer,sizeof(buffer)," Manufacturer : %s \n", p->pci_device->dev_info->vendor_name);
+ more_printf(buffer);
+ snprintf(buffer,sizeof(buffer)," Product : %s \n", p->pci_device->dev_info->product_name);
+ more_printf(buffer);
}
-
+ more_printf( " Addresses : %d.%d.%d.%d @ %s\n",p->ip_addr[0], p->ip_addr[1], p->ip_addr[2], p->ip_addr[3],p->mac_addr);
}
/* Detecting if a DMI table exist
* if yes, let's parse it */
int detect_dmi(struct s_hardware *hardware) {
- if (hardware->dmi_detection == true) return;
+ if (hardware->dmi_detection == true) return -1;
hardware->dmi_detection=true;
if (dmi_iterate(&hardware->dmi) == -ENODMITABLE ) {
hardware->is_dmi_valid=false;
int detect_pxe(struct s_hardware *hardware) {
void *dhcpdata;
+
size_t dhcplen;
const struct syslinux_version *sv;
t_PXENV_UNDI_GET_NIC_TYPE gnt;
// printf("PXE: PXElinux detected\n");
if (!pxe_get_cached_info(PXENV_PACKET_TYPE_DHCP_ACK, &dhcpdata, &dhcplen)) {
+ pxe_bootp_t *dhcp=&hardware->pxe.dhcpdata;
+ memcpy(&hardware->pxe.dhcpdata,dhcpdata,dhcplen);
+ snprintf(hardware->pxe.mac_addr, sizeof(hardware->pxe.mac_addr), "%02x:%02x:%02x:%02x:%02x:%02x",
+ dhcp->CAddr[0],dhcp->CAddr[1],dhcp->CAddr[2],dhcp->CAddr[3],dhcp->CAddr[4],dhcp->CAddr[5]);
+
+ /* Saving Our IP address in a easy format*/
+ hardware->pxe.ip_addr[0]= hardware->pxe.dhcpdata.yip & 0xff;
+ hardware->pxe.ip_addr[1]= hardware->pxe.dhcpdata.yip >>8 & 0xff;
+ hardware->pxe.ip_addr[2]= hardware->pxe.dhcpdata.yip >>16 & 0xff;
+ hardware->pxe.ip_addr[3]= hardware->pxe.dhcpdata.yip >>24 & 0xff;
+
if (!pxe_get_nic_type(&gnt)) {
switch(gnt.NicType) {
case PCI_NIC:
case PnP_NIC:
default: return -1; break;
}
- if (hardware->pci_detection==false) detect_pci(hardware);
+ /* Let's try to find the associated pci device */
+ detect_pci(hardware);
hardware->pxe.pci_device=NULL;
hardware->pxe.pci_device_pos=0;
struct pci_device *pci_device;
(pci_device->product == hardware->pxe.product_id)) {
hardware->pxe.pci_device=pci_device;
hardware->pxe.pci_device_pos=pci_number;
- // printf("PXE: PCI device %d is the current boot device\n", pci_number);
}
}
}
uint8_t sub_class;
uint8_t prog_intf;
uint8_t nictype;
+ char mac_addr[18]; /* The current mac address */
+ uint8_t ip_addr[4];
+
+ pxe_bootp_t dhcpdata; /* The dhcp answer */
+ struct pci_device *pci_device; /* The matching pci device */
+ uint8_t pci_device_pos; /* It position in our pci sorted list*/
- struct pci_device *pci_device;
- uint8_t pci_device_pos;
};
struct s_hardware {