From c4a05ef079c5557baf6a3eb1f0da903f27befd02 Mon Sep 17 00:00:00 2001 From: Marcus Overhagen Date: Tue, 26 Dec 2006 19:17:28 +0000 Subject: [PATCH] Determine client IP address and make it known to the ethernet interface. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19634 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/boot/platform/pxe_ia32/network.cpp | 22 ++++++++++++++++++- src/system/boot/platform/pxe_ia32/pxe_undi.h | 14 ++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/system/boot/platform/pxe_ia32/network.cpp b/src/system/boot/platform/pxe_ia32/network.cpp index 1e5b74332c..94add45880 100644 --- a/src/system/boot/platform/pxe_ia32/network.cpp +++ b/src/system/boot/platform/pxe_ia32/network.cpp @@ -100,12 +100,32 @@ status_t UNDI::Init() { TRACE("UNDI::Init\n"); - + + PXENV_GET_CACHED_INFO cached_info; PXENV_UNDI_GET_INFORMATION get_info; PXENV_UNDI_GET_STATE get_state; PXENV_UNDI_OPEN undi_open; uint16 res; + cached_info.PacketType = PXENV_PACKET_TYPE_CACHED_REPLY; + cached_info.BufferSize = 0; + cached_info.BufferLimit = 0; + cached_info.Buffer.seg = 0; + cached_info.Buffer.ofs = 0; + res = call_pxe_bios(fPxeData, GET_CACHED_INFO, &cached_info); + if (res != 0 || get_state.Status != 0) { + TRACE("PXENV_GET_CACHED_INFO failed, res %x, status %x\n", res, undi_open.Status); + panic("Can't determine our IP address\n"); + } + + char *buf = (char *)(cached_info.Buffer.seg * 16 + cached_info.Buffer.ofs); + ip_addr_t ipClient = ntohl(*(ip_addr_t *)(buf + 16)); + ip_addr_t ipServer = ntohl(*(ip_addr_t *)(buf + 20)); + + TRACE("client-ip: %08x, server-ip: %08x\n", (int)ipClient, (int)ipServer); + + SetIPAddress(ipClient); + undi_open.OpenFlag = 0; undi_open.PktFilter = FLTR_DIRECTED | FLTR_BRDCST | FLTR_PRMSCS; undi_open.R_Mcast_Buf.MCastAddrCount = 0; diff --git a/src/system/boot/platform/pxe_ia32/pxe_undi.h b/src/system/boot/platform/pxe_ia32/pxe_undi.h index 8fe50311c8..92136865e2 100644 --- a/src/system/boot/platform/pxe_ia32/pxe_undi.h +++ b/src/system/boot/platform/pxe_ia32/pxe_undi.h @@ -14,6 +14,8 @@ extern "C" uint16 call_pxe_bios(void *pxe, uint16 opcode, void *param); #define UNDI_ISR 0x0014 #define UNDI_GET_STATE 0x0015 +#define GET_CACHED_INFO 0x0071 + #define SEG(ptr) ((uint16)(((uint32)(ptr)) >> 4)) #define OFS(ptr) (((uint16)(ptr)) & 15) @@ -60,6 +62,18 @@ struct PXE_STRUCT SEGDESC BC_CodeWrite; }; +struct PXENV_GET_CACHED_INFO +{ + uint16 Status; + uint16 PacketType; + #define PXENV_PACKET_TYPE_DHCP_DISCOVER 1 + #define PXENV_PACKET_TYPE_DHCP_ACK 2 + #define PXENV_PACKET_TYPE_CACHED_REPLY 3 + uint16 BufferSize; + SEGOFF16 Buffer; + uint16 BufferLimit; +}; + struct PXENV_UNDI_MCAST_ADDRESS { #define MAXNUM_MCADDR 8