Import ArpDxe, Dhcp4Dxe, Ip4Dxe, Mtftp4Dxe, PxeBcDxe and PxeDhcp4Dxe.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3492 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
2401
MdeModulePkg/Universal/Network/PxeBcDxe/Bc.c
Normal file
2401
MdeModulePkg/Universal/Network/PxeBcDxe/Bc.c
Normal file
File diff suppressed because it is too large
Load Diff
564
MdeModulePkg/Universal/Network/PxeBcDxe/Bc.h
Normal file
564
MdeModulePkg/Universal/Network/PxeBcDxe/Bc.h
Normal file
@@ -0,0 +1,564 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2004 - 2007, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
bc.h
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _BC_H
|
||||
#define _BC_H
|
||||
|
||||
#include <PiDxe.h>
|
||||
|
||||
#include <Guid/SmBios.h>
|
||||
#include <Protocol/Bis.h>
|
||||
#include <Protocol/PxeBaseCode.h>
|
||||
#include <Protocol/PxeBaseCodeCallBack.h>
|
||||
#include <Protocol/NetworkInterfaceIdentifier.h>
|
||||
#include <Protocol/SimpleNetwork.h>
|
||||
#include <Protocol/LoadFile.h>
|
||||
#include <Protocol/DevicePath.h>
|
||||
#include <Protocol/Tcp.h>
|
||||
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/UefiDriverEntryPoint.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
|
||||
#define CALLBACK_INTERVAL 100 // ten times a second
|
||||
#define FILTER_BITS (EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP | \
|
||||
EFI_PXE_BASE_CODE_IP_FILTER_BROADCAST | \
|
||||
EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS | \
|
||||
EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS_MULTICAST \
|
||||
)
|
||||
|
||||
#define WAIT_TX_TIMEOUT 1000
|
||||
|
||||
#define SUPPORT_IPV6 0
|
||||
|
||||
#define PXE_BASECODE_DEVICE_SIGNATURE 'pxed'
|
||||
|
||||
//
|
||||
// Determine the classes of IPv4 address
|
||||
//
|
||||
#define IS_CLASSA_IPADDR(x) ((((EFI_IP_ADDRESS*)x)->v4.Addr[0] & 0x80) == 0x00)
|
||||
#define IS_CLASSB_IPADDR(x) ((((EFI_IP_ADDRESS*)x)->v4.Addr[0] & 0xc0) == 0x80)
|
||||
#define IS_CLASSC_IPADDR(x) ((((EFI_IP_ADDRESS*)x)->v4.Addr[0] & 0xe0) == 0xc0)
|
||||
#define IS_INADDR_UNICAST(x) ((IS_CLASSA_IPADDR(x) || IS_CLASSB_IPADDR(x) || IS_CLASSC_IPADDR(x)) && (((EFI_IP_ADDRESS*)x)->Addr[0] != 0) )
|
||||
|
||||
//
|
||||
// Definitions for internet group management protocol version 2 message
|
||||
// structure
|
||||
// Per RFC 2236, November 1997
|
||||
//
|
||||
#pragma pack(1)
|
||||
|
||||
typedef struct {
|
||||
UINT8 Type;
|
||||
UINT8 MaxRespTime; // in tenths of a second
|
||||
UINT16 Checksum; // ones complement of ones complement sum of
|
||||
// 16 bit words of message
|
||||
UINT32 GroupAddress; // for general query, all systems group,
|
||||
// for group specific, the group
|
||||
} IGMPV2_MESSAGE;
|
||||
|
||||
#define IGMP_TYPE_QUERY 0x11
|
||||
#define IGMP_TYPE_REPORT 0x16
|
||||
#define IGMP_TYPE_V1REPORT 0x12
|
||||
#define IGMP_TYPE_LEAVE_GROUP 0x17
|
||||
|
||||
#define IGMP_DEFAULT_MAX_RESPONSE_TIME 10 // 10 second default
|
||||
#pragma pack()
|
||||
|
||||
#define MAX_MCAST_GROUPS 8 // most we allow ourselves to join at once
|
||||
#define MAX_OFFERS 16
|
||||
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
EFI_LOCK Lock;
|
||||
BOOLEAN ShowErrorMessages;
|
||||
EFI_TCP_PROTOCOL Tcp;
|
||||
EFI_PXE_BASE_CODE_PROTOCOL EfiBc;
|
||||
EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *CallbackProtocolPtr;
|
||||
EFI_HANDLE Handle;
|
||||
|
||||
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *NiiPtr;
|
||||
EFI_SIMPLE_NETWORK_PROTOCOL *SimpleNetwork;
|
||||
UINT8 *TransmitBufferPtr;
|
||||
UINT8 *ReceiveBufferPtr;
|
||||
EFI_PXE_BASE_CODE_FUNCTION Function;
|
||||
|
||||
UINTN OldestArpEntry;
|
||||
UINTN MCastGroupCount;
|
||||
EFI_EVENT Igmpv1TimeoutEvent;
|
||||
BOOLEAN UseIgmpv1Reporting;
|
||||
EFI_EVENT IgmpGroupEvent[MAX_MCAST_GROUPS];
|
||||
UINT16 RandomPort;
|
||||
|
||||
#if SUPPORT_IPV6
|
||||
//
|
||||
// TBD
|
||||
//
|
||||
#else
|
||||
UINT32 MCastGroup[MAX_MCAST_GROUPS];
|
||||
#endif
|
||||
|
||||
BOOLEAN GoodStationIp;
|
||||
BOOLEAN DidTransmit;
|
||||
UINTN IpLength;
|
||||
VOID *DhcpPacketBuffer;
|
||||
UINTN FileSize;
|
||||
VOID *BootServerReceiveBuffer;
|
||||
EFI_IP_ADDRESS ServerIp;
|
||||
|
||||
//
|
||||
// work area
|
||||
// for dhcp
|
||||
//
|
||||
VOID *ReceiveBuffers;
|
||||
VOID *TransmitBuffer;
|
||||
UINTN NumOffersReceived;
|
||||
UINT16 TotalSeconds;
|
||||
|
||||
//
|
||||
// arrays for different types of offers
|
||||
//
|
||||
UINT8 ServerCount[4];
|
||||
UINT8 OfferCount[4][MAX_OFFERS];
|
||||
UINT8 GotBootp;
|
||||
UINT8 GotProxy[4];
|
||||
UINT8 BinlProxies[MAX_OFFERS];
|
||||
|
||||
UINT8 *ArpBuffer;
|
||||
UINT8 *TftpAckBuffer;
|
||||
UINT8 *TftpErrorBuffer;
|
||||
IGMPV2_MESSAGE IgmpMessage;
|
||||
BOOLEAN BigBlkNumFlag;
|
||||
UINT8 Timeout;
|
||||
UINT16 RandomSeed;
|
||||
} PXE_BASECODE_DEVICE;
|
||||
|
||||
//
|
||||
// type index
|
||||
//
|
||||
#define DHCP_ONLY_IX 0
|
||||
#define PXE10_IX 1
|
||||
#define WfM11a_IX 2
|
||||
#define BINL_IX 3
|
||||
|
||||
#define PXE_RND_PORT_LOW 2070
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
#define LOADFILE_DEVICE_SIGNATURE 'pxel'
|
||||
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
EFI_LOCK Lock;
|
||||
EFI_LOAD_FILE_PROTOCOL LoadFile;
|
||||
PXE_BASECODE_DEVICE *Private;
|
||||
} LOADFILE_DEVICE;
|
||||
|
||||
#define EFI_BASE_CODE_DEV_FROM_THIS(a) CR (a, PXE_BASECODE_DEVICE, efi_bc, PXE_BASECODE_DEVICE_SIGNATURE);
|
||||
|
||||
#define EFI_BASE_CODE_DEV_FROM_TCP(a) CR (a, PXE_BASECODE_DEVICE, Tcp, PXE_BASECODE_DEVICE_SIGNATURE);
|
||||
|
||||
#define EFI_LOAD_FILE_DEV_FROM_THIS(a) CR (a, LOADFILE_DEVICE, LoadFile, LOADFILE_DEVICE_SIGNATURE)
|
||||
|
||||
EFI_BIS_PROTOCOL *
|
||||
PxebcBisStart (
|
||||
PXE_BASECODE_DEVICE *Private,
|
||||
BIS_APPLICATION_HANDLE *BisAppHandle,
|
||||
EFI_BIS_DATA **BisDataSigInfo
|
||||
)
|
||||
;
|
||||
|
||||
VOID
|
||||
PxebcBisStop (
|
||||
EFI_BIS_PROTOCOL *Bis,
|
||||
BIS_APPLICATION_HANDLE BisAppHandle,
|
||||
EFI_BIS_DATA *BisDataSigInfo
|
||||
)
|
||||
;
|
||||
|
||||
BOOLEAN
|
||||
PxebcBisVerify (
|
||||
PXE_BASECODE_DEVICE *Private,
|
||||
VOID *FileBuffer,
|
||||
UINTN FileBufferLength,
|
||||
VOID *CredentialBuffer,
|
||||
UINTN CredentialBufferLength
|
||||
)
|
||||
;
|
||||
|
||||
BOOLEAN
|
||||
PxebcBisDetect (
|
||||
PXE_BASECODE_DEVICE *Private
|
||||
)
|
||||
;
|
||||
|
||||
//
|
||||
// Global Variables
|
||||
//
|
||||
extern EFI_COMPONENT_NAME_PROTOCOL gPxeBcComponentName;
|
||||
|
||||
//
|
||||
// //////////////////////////////////////////////////////////
|
||||
//
|
||||
// prototypes
|
||||
//
|
||||
|
||||
/**
|
||||
Initialize the base code drivers and install the driver binding
|
||||
|
||||
Standard EFI Image Entry
|
||||
|
||||
@retval EFI_SUCCESS This driver was successfully bound
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
InitializeBCDriver (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
BcStart (
|
||||
IN EFI_PXE_BASE_CODE_PROTOCOL *This,
|
||||
IN BOOLEAN UseIpv6
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
BcStop (
|
||||
IN EFI_PXE_BASE_CODE_PROTOCOL *This
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
BcDhcp (
|
||||
IN EFI_PXE_BASE_CODE_PROTOCOL *This,
|
||||
IN BOOLEAN SortOffers
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
BcDiscover (
|
||||
IN EFI_PXE_BASE_CODE_PROTOCOL * This,
|
||||
IN UINT16 Type,
|
||||
IN UINT16 *Layer,
|
||||
IN BOOLEAN UseBis,
|
||||
IN EFI_PXE_BASE_CODE_DISCOVER_INFO * Info OPTIONAL
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
BcMtftp (
|
||||
IN EFI_PXE_BASE_CODE_PROTOCOL * This,
|
||||
IN EFI_PXE_BASE_CODE_TFTP_OPCODE Operation,
|
||||
IN OUT VOID *BufferPtr,
|
||||
IN BOOLEAN Overwrite,
|
||||
IN OUT UINT64 *BufferSize,
|
||||
IN UINTN *BlockSize OPTIONAL,
|
||||
IN EFI_IP_ADDRESS * ServerIp,
|
||||
IN UINT8 *Filename,
|
||||
IN EFI_PXE_BASE_CODE_MTFTP_INFO * Info OPTIONAL,
|
||||
IN BOOLEAN DontUseBuffer
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
BcUdpWrite (
|
||||
IN EFI_PXE_BASE_CODE_PROTOCOL *This,
|
||||
IN UINT16 OpFlags,
|
||||
IN EFI_IP_ADDRESS *DestIp,
|
||||
IN EFI_PXE_BASE_CODE_UDP_PORT *DestPort,
|
||||
IN EFI_IP_ADDRESS *GatewayIp, OPTIONAL
|
||||
IN EFI_IP_ADDRESS *SrcIp, OPTIONAL
|
||||
IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort, OPTIONAL
|
||||
IN UINTN *HeaderSize, OPTIONAL
|
||||
IN VOID *HeaderPtr, OPTIONAL
|
||||
IN UINTN *BufferSize,
|
||||
IN VOID *BufferPtr
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
BcUdpRead (
|
||||
IN EFI_PXE_BASE_CODE_PROTOCOL *This,
|
||||
IN UINT16 OpFlags,
|
||||
IN OUT EFI_IP_ADDRESS *DestIp, OPTIONAL
|
||||
IN OUT EFI_PXE_BASE_CODE_UDP_PORT *DestPort, OPTIONAL
|
||||
IN OUT EFI_IP_ADDRESS *SrcIp, OPTIONAL
|
||||
IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort, OPTIONAL
|
||||
IN UINTN *HeaderSize, OPTIONAL
|
||||
IN VOID *HeaderPtr, OPTIONAL
|
||||
IN OUT UINTN *BufferSize,
|
||||
IN VOID *BufferPtr
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
BcTcpWrite (
|
||||
IN EFI_PXE_BASE_CODE_PROTOCOL *This,
|
||||
IN UINT16 OpFlags,
|
||||
IN UINT16 *UrgentPointer,
|
||||
IN UINT32 *SequenceNumber,
|
||||
IN UINT32 *AckNumber,
|
||||
IN UINT16 *HlenResCode,
|
||||
IN UINT16 *Window,
|
||||
IN EFI_IP_ADDRESS *DestIp,
|
||||
IN EFI_PXE_BASE_CODE_TCP_PORT *DestPort,
|
||||
IN EFI_IP_ADDRESS *GatewayIp, OPTIONAL
|
||||
IN EFI_IP_ADDRESS *SrcIp, OPTIONAL
|
||||
IN OUT EFI_PXE_BASE_CODE_TCP_PORT *SrcPort, OPTIONAL
|
||||
IN UINTN *HeaderSize, OPTIONAL
|
||||
IN VOID *HeaderPtr, OPTIONAL
|
||||
IN UINTN *BufferSize,
|
||||
IN VOID *BufferPtr
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
BcTcpRead (
|
||||
IN EFI_PXE_BASE_CODE_PROTOCOL *This,
|
||||
IN UINT16 OpFlags,
|
||||
IN OUT EFI_IP_ADDRESS *DestIp, OPTIONAL
|
||||
IN OUT EFI_PXE_BASE_CODE_TCP_PORT *DestPort, OPTIONAL
|
||||
IN OUT EFI_IP_ADDRESS *SrcIp, OPTIONAL
|
||||
IN OUT EFI_PXE_BASE_CODE_TCP_PORT *SrcPort, OPTIONAL
|
||||
IN UINTN *HeaderSize, OPTIONAL
|
||||
IN VOID *HeaderPtr, OPTIONAL
|
||||
IN OUT UINTN *BufferSize,
|
||||
IN VOID *BufferPtr
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
BcArp (
|
||||
IN EFI_PXE_BASE_CODE_PROTOCOL * This,
|
||||
IN EFI_IP_ADDRESS * IpAddr,
|
||||
IN EFI_MAC_ADDRESS * MacAddr OPTIONAL
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
BcIpFilter (
|
||||
IN EFI_PXE_BASE_CODE_PROTOCOL *This,
|
||||
IN EFI_PXE_BASE_CODE_IP_FILTER *NewFilter
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
BcSetParameters (
|
||||
IN EFI_PXE_BASE_CODE_PROTOCOL * This,
|
||||
IN BOOLEAN *NewAutoArp, OPTIONAL
|
||||
IN BOOLEAN *NewSendGUID, OPTIONAL
|
||||
IN UINT8 *NewTTL, OPTIONAL
|
||||
IN UINT8 *NewToS, OPTIONAL
|
||||
IN BOOLEAN *NewMakeCallback OPTIONAL
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
BcSetStationIP (
|
||||
IN EFI_PXE_BASE_CODE_PROTOCOL * This,
|
||||
IN EFI_IP_ADDRESS * NewStationIp, OPTIONAL
|
||||
IN EFI_IP_ADDRESS * NewSubnetMask OPTIONAL
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
BcSetPackets (
|
||||
IN EFI_PXE_BASE_CODE_PROTOCOL * This,
|
||||
BOOLEAN *NewDhcpDiscoverValid, OPTIONAL
|
||||
BOOLEAN *NewDhcpAckReceived, OPTIONAL
|
||||
BOOLEAN *NewProxyOfferReceived, OPTIONAL
|
||||
BOOLEAN *NewPxeDiscoverValid, OPTIONAL
|
||||
BOOLEAN *NewPxeReplyReceived, OPTIONAL
|
||||
BOOLEAN *NewPxeBisReplyReceived, OPTIONAL
|
||||
IN EFI_PXE_BASE_CODE_PACKET * NewDhcpDiscover, OPTIONAL
|
||||
IN EFI_PXE_BASE_CODE_PACKET * NewDhcpAck, OPTIONAL
|
||||
IN EFI_PXE_BASE_CODE_PACKET * NewProxyOffer, OPTIONAL
|
||||
IN EFI_PXE_BASE_CODE_PACKET * NewPxeDiscover, OPTIONAL
|
||||
IN EFI_PXE_BASE_CODE_PACKET * NewPxeReply, OPTIONAL
|
||||
IN EFI_PXE_BASE_CODE_PACKET * NewPxeBisReply OPTIONAL
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
LoadFile (
|
||||
IN EFI_LOAD_FILE_PROTOCOL *This,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
|
||||
IN BOOLEAN BootPolicy,
|
||||
IN OUT UINTN *BufferSize,
|
||||
IN VOID *Buffer
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
PxeBcLibGetSmbiosSystemGuidAndSerialNumber (
|
||||
IN EFI_GUID *SystemGuid,
|
||||
OUT CHAR8 **SystemSerialNumber
|
||||
)
|
||||
;
|
||||
|
||||
#ifdef EFI_SIZE_REDUCTION_APPLIED
|
||||
#define COMPONENT_NAME_CODE(code)
|
||||
#define COMPONENT_NAME NULL
|
||||
#else
|
||||
#define COMPONENT_NAME_CODE(code) code
|
||||
#define COMPONENT_NAME &gPxeBcComponentName
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// Define SMBIOS tables.
|
||||
//
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UINT8 AnchorString[4];
|
||||
UINT8 EntryPointStructureChecksum;
|
||||
UINT8 EntryPointLength;
|
||||
UINT8 MajorVersion;
|
||||
UINT8 MinorVersion;
|
||||
UINT16 MaxStructureSize;
|
||||
UINT8 EntryPointRevision;
|
||||
UINT8 FormattedArea[5];
|
||||
UINT8 IntermediateAnchorString[5];
|
||||
UINT8 IntermediateChecksum;
|
||||
UINT16 TableLength;
|
||||
UINT32 TableAddress;
|
||||
UINT16 NumberOfSmbiosStructures;
|
||||
UINT8 SmbiosBcdRevision;
|
||||
} SMBIOS_STRUCTURE_TABLE;
|
||||
|
||||
//
|
||||
// Please note that SMBIOS structures can be odd byte aligned since the
|
||||
// unformated section of each record is a set of arbitrary size strings.
|
||||
//
|
||||
typedef struct {
|
||||
UINT8 Type;
|
||||
UINT8 Length;
|
||||
UINT8 Handle[2];
|
||||
} SMBIOS_HEADER;
|
||||
|
||||
typedef UINT8 SMBIOS_STRING;
|
||||
|
||||
typedef struct {
|
||||
SMBIOS_HEADER Hdr;
|
||||
SMBIOS_STRING Vendor;
|
||||
SMBIOS_STRING BiosVersion;
|
||||
UINT8 BiosSegment[2];
|
||||
SMBIOS_STRING BiosReleaseDate;
|
||||
UINT8 BiosSize;
|
||||
UINT8 BiosCharacteristics[8];
|
||||
} SMBIOS_TYPE0;
|
||||
|
||||
typedef struct {
|
||||
SMBIOS_HEADER Hdr;
|
||||
SMBIOS_STRING Manufacturer;
|
||||
SMBIOS_STRING ProductName;
|
||||
SMBIOS_STRING Version;
|
||||
SMBIOS_STRING SerialNumber;
|
||||
|
||||
//
|
||||
// always byte copy this data to prevent alignment faults!
|
||||
//
|
||||
EFI_GUID Uuid;
|
||||
|
||||
UINT8 WakeUpType;
|
||||
} SMBIOS_TYPE1;
|
||||
|
||||
typedef struct {
|
||||
SMBIOS_HEADER Hdr;
|
||||
SMBIOS_STRING Manufacturer;
|
||||
SMBIOS_STRING ProductName;
|
||||
SMBIOS_STRING Version;
|
||||
SMBIOS_STRING SerialNumber;
|
||||
} SMBIOS_TYPE2;
|
||||
|
||||
typedef struct {
|
||||
SMBIOS_HEADER Hdr;
|
||||
SMBIOS_STRING Manufacturer;
|
||||
UINT8 Type;
|
||||
SMBIOS_STRING Version;
|
||||
SMBIOS_STRING SerialNumber;
|
||||
SMBIOS_STRING AssetTag;
|
||||
UINT8 BootupState;
|
||||
UINT8 PowerSupplyState;
|
||||
UINT8 ThermalState;
|
||||
UINT8 SecurityStatus;
|
||||
UINT8 OemDefined[4];
|
||||
} SMBIOS_TYPE3;
|
||||
|
||||
typedef struct {
|
||||
SMBIOS_HEADER Hdr;
|
||||
UINT8 Socket;
|
||||
UINT8 ProcessorType;
|
||||
UINT8 ProcessorFamily;
|
||||
SMBIOS_STRING ProcessorManufacture;
|
||||
UINT8 ProcessorId[8];
|
||||
SMBIOS_STRING ProcessorVersion;
|
||||
UINT8 Voltage;
|
||||
UINT8 ExternalClock[2];
|
||||
UINT8 MaxSpeed[2];
|
||||
UINT8 CurrentSpeed[2];
|
||||
UINT8 Status;
|
||||
UINT8 ProcessorUpgrade;
|
||||
UINT8 L1CacheHandle[2];
|
||||
UINT8 L2CacheHandle[2];
|
||||
UINT8 L3CacheHandle[2];
|
||||
} SMBIOS_TYPE4;
|
||||
|
||||
typedef union {
|
||||
SMBIOS_HEADER *Hdr;
|
||||
SMBIOS_TYPE0 *Type0;
|
||||
SMBIOS_TYPE1 *Type1;
|
||||
SMBIOS_TYPE2 *Type2;
|
||||
SMBIOS_TYPE3 *Type3;
|
||||
SMBIOS_TYPE4 *Type4;
|
||||
UINT8 *Raw;
|
||||
} SMBIOS_STRUCTURE_POINTER;
|
||||
#pragma pack()
|
||||
|
||||
#include "ip.h"
|
||||
#include "dhcp.h"
|
||||
#include "tftp.h"
|
||||
|
||||
#endif /* _BC_H */
|
||||
|
||||
/* EOF - bc.h */
|
160
MdeModulePkg/Universal/Network/PxeBcDxe/ComponentName.c
Normal file
160
MdeModulePkg/Universal/Network/PxeBcDxe/ComponentName.c
Normal file
@@ -0,0 +1,160 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2004 - 2007, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
ComponentName.c
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#include "Bc.h"
|
||||
|
||||
//
|
||||
// EFI Component Name Functions
|
||||
//
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PxeBcComponentNameGetDriverName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **DriverName
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PxeBcComponentNameGetControllerName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **ControllerName
|
||||
);
|
||||
|
||||
//
|
||||
// EFI Component Name Protocol
|
||||
//
|
||||
EFI_COMPONENT_NAME_PROTOCOL gPxeBcComponentName = {
|
||||
PxeBcComponentNameGetDriverName,
|
||||
PxeBcComponentNameGetControllerName,
|
||||
"eng"
|
||||
};
|
||||
|
||||
static EFI_UNICODE_STRING_TABLE mPxeBcDriverNameTable[] = {
|
||||
{
|
||||
"eng",
|
||||
L"PXE Base Code Driver"
|
||||
},
|
||||
{
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PxeBcComponentNameGetDriverName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **DriverName
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
Retrieves a Unicode string that is the user readable name of the EFI Driver.
|
||||
|
||||
Arguments:
|
||||
This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
|
||||
Language - A pointer to a three character ISO 639-2 language identifier.
|
||||
This is the language of the driver name that that the caller
|
||||
is requesting, and it must match one of the languages specified
|
||||
in SupportedLanguages. The number of languages supported by a
|
||||
driver is up to the driver writer.
|
||||
DriverName - A pointer to the Unicode string to return. This Unicode string
|
||||
is the name of the driver specified by This in the language
|
||||
specified by Language.
|
||||
|
||||
Returns:
|
||||
EFI_SUCCESS - The Unicode string for the Driver specified by This
|
||||
and the language specified by Language was returned
|
||||
in DriverName.
|
||||
EFI_INVALID_PARAMETER - Language is NULL.
|
||||
EFI_INVALID_PARAMETER - DriverName is NULL.
|
||||
EFI_UNSUPPORTED - The driver specified by This does not support the
|
||||
language specified by Language.
|
||||
|
||||
--*/
|
||||
{
|
||||
return LookupUnicodeString (
|
||||
Language,
|
||||
gPxeBcComponentName.SupportedLanguages,
|
||||
mPxeBcDriverNameTable,
|
||||
DriverName
|
||||
);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PxeBcComponentNameGetControllerName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **ControllerName
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
Retrieves a Unicode string that is the user readable name of the controller
|
||||
that is being managed by an EFI Driver.
|
||||
|
||||
Arguments:
|
||||
This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
|
||||
ControllerHandle - The handle of a controller that the driver specified by
|
||||
This is managing. This handle specifies the controller
|
||||
whose name is to be returned.
|
||||
ChildHandle - The handle of the child controller to retrieve the name
|
||||
of. This is an optional parameter that may be NULL. It
|
||||
will be NULL for device drivers. It will also be NULL
|
||||
for a bus drivers that wish to retrieve the name of the
|
||||
bus controller. It will not be NULL for a bus driver
|
||||
that wishes to retrieve the name of a child controller.
|
||||
Language - A pointer to a three character ISO 639-2 language
|
||||
identifier. This is the language of the controller name
|
||||
that that the caller is requesting, and it must match one
|
||||
of the languages specified in SupportedLanguages. The
|
||||
number of languages supported by a driver is up to the
|
||||
driver writer.
|
||||
ControllerName - A pointer to the Unicode string to return. This Unicode
|
||||
string is the name of the controller specified by
|
||||
ControllerHandle and ChildHandle in the language specified
|
||||
by Language from the point of view of the driver specified
|
||||
by This.
|
||||
|
||||
Returns:
|
||||
EFI_SUCCESS - The Unicode string for the user readable name in the
|
||||
language specified by Language for the driver
|
||||
specified by This was returned in DriverName.
|
||||
EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
|
||||
EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
|
||||
EFI_INVALID_PARAMETER - Language is NULL.
|
||||
EFI_INVALID_PARAMETER - ControllerName is NULL.
|
||||
EFI_UNSUPPORTED - The driver specified by This is not currently managing
|
||||
the controller specified by ControllerHandle and
|
||||
ChildHandle.
|
||||
EFI_UNSUPPORTED - The driver specified by This does not support the
|
||||
language specified by Language.
|
||||
|
||||
--*/
|
||||
{
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
632
MdeModulePkg/Universal/Network/PxeBcDxe/Dhcp.h
Normal file
632
MdeModulePkg/Universal/Network/PxeBcDxe/Dhcp.h
Normal file
@@ -0,0 +1,632 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2004, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _DHCP_H
|
||||
#define _DHCP_H
|
||||
|
||||
//
|
||||
// Definitions for DHCP version 4 UDP packet.
|
||||
// The field names in this structure are defined and described in RFC 2131.
|
||||
//
|
||||
#pragma pack(1)
|
||||
|
||||
typedef struct {
|
||||
UINT8 op;
|
||||
#define BOOTP_REQUEST 1
|
||||
#define BOOTP_REPLY 2
|
||||
|
||||
UINT8 htype;
|
||||
UINT8 hlen;
|
||||
UINT8 hops;
|
||||
UINT32 xid;
|
||||
UINT16 secs;
|
||||
UINT16 flags;
|
||||
#define DHCP_BROADCAST_FLAG 0x8000
|
||||
|
||||
UINT32 ciaddr;
|
||||
UINT32 yiaddr;
|
||||
UINT32 siaddr;
|
||||
UINT32 giaddr;
|
||||
UINT8 chaddr[16];
|
||||
UINT8 sname[64];
|
||||
UINT8 file[128];
|
||||
UINT8 options[312];
|
||||
#define OP_PAD 0
|
||||
#define OP_END 255
|
||||
#define OP_SUBNET_MASK 1
|
||||
#define OP_TIME_OFFSET 2
|
||||
#define OP_ROUTER_LIST 3
|
||||
#define OP_TIME_SERVERS 4
|
||||
#define OP_NAME_SERVERS 5
|
||||
#define OP_DNS_SERVERS 6
|
||||
#define OP_LOG_SERVERS 7
|
||||
#define OP_COOKIE_SERVERS 8
|
||||
#define OP_LPR_SREVERS 9
|
||||
#define OP_IMPRESS_SERVERS 10
|
||||
#define OP_RES_LOC_SERVERS 11
|
||||
#define OP_HOST_NAME 12
|
||||
#define OP_BOOT_FILE_SZ 13
|
||||
#define OP_DUMP_FILE 14
|
||||
#define OP_DOMAIN_NAME 15
|
||||
#define OP_SWAP_SERVER 16
|
||||
#define OP_ROOT_PATH 17
|
||||
#define OP_EXTENSION_PATH 18
|
||||
#define OP_IP_FORWARDING 19
|
||||
#define OP_NON_LOCAL_SRC_RTE 20
|
||||
#define OP_POLICY_FILTER 21
|
||||
#define OP_MAX_DATAGRAM_SZ 22
|
||||
#define OP_DEFAULT_TTL 23
|
||||
#define OP_MTU_AGING_TIMEOUT 24
|
||||
#define OP_MTU_SIZES 25
|
||||
#define OP_MTU_TO_USE 26
|
||||
#define OP_ALL_SUBNETS_LOCAL 27
|
||||
#define OP_BROADCAST_ADD 28
|
||||
#define OP_PERFORM_MASK_DISCOVERY 29
|
||||
#define OP_RESPOND_TO_MASK_REQ 30
|
||||
#define OP_PERFORM_ROUTER_DISCOVERY 31
|
||||
#define OP_ROUTER_SOLICIT_ADDRESS 32
|
||||
#define OP_STATIC_ROUTER_LIST 33
|
||||
#define OP_USE_ARP_TRAILERS 34
|
||||
#define OP_ARP_CACHE_TIMEOUT 35
|
||||
#define OP_ETHERNET_ENCAPSULATION 36
|
||||
#define OP_TCP_DEFAULT_TTL 37
|
||||
#define OP_TCP_KEEP_ALIVE_INT 38
|
||||
#define OP_KEEP_ALIVE_GARBAGE 39
|
||||
#define OP_NIS_DOMAIN_NAME 40
|
||||
#define OP_NIS_SERVERS 41
|
||||
#define OP_NTP_SERVERS 42
|
||||
#define OP_VENDOR_SPECIFIC 43
|
||||
#define VEND_PXE_MTFTP_IP 1
|
||||
#define VEND_PXE_MTFTP_CPORT 2
|
||||
#define VEND_PXE_MTFTP_SPORT 3
|
||||
#define VEND_PXE_MTFTP_TMOUT 4
|
||||
#define VEND_PXE_MTFTP_DELAY 5
|
||||
#define VEND_PXE_DISCOVERY_CONTROL 6
|
||||
#define PXE_DISABLE_BROADCAST_DISCOVERY (1 << 0)
|
||||
#define PXE_DISABLE_MULTICAST_DISCOVERY (1 << 1)
|
||||
#define PXE_ACCEPT_ONLY_PXE_BOOT_SERVERS (1 << 2)
|
||||
#define PXE_DO_NOT_PROMPT (1 << 3)
|
||||
#define VEND_PXE_DISCOVERY_MCAST_ADDR 7
|
||||
#define VEND_PXE_BOOT_SERVERS 8
|
||||
#define VEND_PXE_BOOT_MENU 9
|
||||
#define VEND_PXE_BOOT_PROMPT 10
|
||||
#define VEND_PXE_MCAST_ADDRS_ALLOC 11
|
||||
#define VEND_PXE_CREDENTIAL_TYPES 12
|
||||
#define VEND_PXE_BOOT_ITEM 71
|
||||
#define OP_NBNS_SERVERS 44
|
||||
#define OP_NBDD_SERVERS 45
|
||||
#define OP_NETBIOS_NODE_TYPE 46
|
||||
#define OP_NETBIOS_SCOPE 47
|
||||
#define OP_XWINDOW_SYSTEM_FONT_SERVERS 48
|
||||
#define OP_XWINDOW_SYSTEM_DISPLAY_MANAGERS 49
|
||||
#define OP_DHCP_REQ_IP_ADD 50
|
||||
#define OP_DHCP_LEASE_TIME 51
|
||||
#define OP_DHCP_OPTION_OVERLOAD 52
|
||||
#define OVLD_FILE 1
|
||||
#define OVLD_SRVR_NAME 2
|
||||
#define OP_DHCP_MESSAGE_TYPE 53
|
||||
#define DHCPDISCOVER 1
|
||||
#define DHCPOFFER 2
|
||||
#define DHCPREQUEST 3
|
||||
#define DHCPDECLINE 4
|
||||
#define DHCPACK 5
|
||||
#define DHCPNAK 6
|
||||
#define DHCPRELEASE 7
|
||||
#define DHCPINFORM 8
|
||||
#define OP_DHCP_SERVER_IP 54
|
||||
#define OP_DHCP_PARM_REQ_LIST 55
|
||||
#define OP_DHCP_ERROR_MESSAGE 56
|
||||
#define OP_DHCP_MAX_MESSAGE_SZ 57
|
||||
#define OP_DHCP_RENEWAL_TIME 58
|
||||
#define OP_DHCP_REBINDING_TIME 59
|
||||
#define OP_DHCP_CLASS_IDENTIFIER 60
|
||||
#define OP_DHCP_CLIENT_IDENTIFIER 61
|
||||
#define OP_NISPLUS_DOMAIN_NAME 64
|
||||
#define OP_NISPLUS_SERVERS 65
|
||||
#define OP_DHCP_TFTP_SERVER_NAME 66
|
||||
#define OP_DHCP_BOOTFILE 67
|
||||
#define OP_MOBILE_IP_HOME_AGENTS 68
|
||||
#define OP_SMPT_SERVERS 69
|
||||
#define OP_POP3_SERVERS 70
|
||||
#define OP_NNTP_SERVERS 71
|
||||
#define OP_WWW_SERVERS 72
|
||||
#define OP_FINGER_SERVERS 73
|
||||
#define OP_IRC_SERVERS 74
|
||||
#define OP_STREET_TALK_SERVERS 75
|
||||
#define OP_STREET_TALK_DIR_ASSIST_SERVERS 76
|
||||
#define OP_NDS_SERVERS 85
|
||||
#define OP_NDS_TREE_NAME 86
|
||||
#define OP_NDS_CONTEXT 87
|
||||
#define OP_DHCP_SYSTEM_ARCH 93
|
||||
#define OP_DHCP_NETWORK_ARCH 94
|
||||
#define OP_DHCP_PLATFORM_ID 97
|
||||
} DHCPV4_STRUCT;
|
||||
|
||||
//
|
||||
// DHCPv4 option header
|
||||
//
|
||||
typedef struct {
|
||||
UINT8 OpCode;
|
||||
UINT8 Length;
|
||||
//
|
||||
// followed by Data[]
|
||||
//
|
||||
} DHCPV4_OP_HEADER;
|
||||
|
||||
//
|
||||
// Generic DHCPv4 option (header followed by data)
|
||||
//
|
||||
typedef struct {
|
||||
DHCPV4_OP_HEADER Header;
|
||||
UINT8 Data[1];
|
||||
} DHCPV4_OP_STRUCT;
|
||||
|
||||
//
|
||||
// Maximum DHCP packet size on ethernet
|
||||
//
|
||||
#define MAX_DHCP_MSG_SZ (MAX_ENET_DATA_SIZE - sizeof (IPV4_HEADER) - sizeof (UDPV4_HEADER))
|
||||
|
||||
//
|
||||
// Macros used in pxe_bc_dhcp.c and pxe_loadfile.c
|
||||
//
|
||||
#define DHCPV4_TRANSMIT_BUFFER (*(DHCPV4_STRUCT *) (Private->TransmitBuffer))
|
||||
#define DHCPV4_OPTIONS_BUFFER (*(struct optionsstr *) DHCPV4_TRANSMIT_BUFFER.options)
|
||||
|
||||
#define DHCPV4_ACK_INDEX 0
|
||||
#define PXE_BINL_INDEX 1
|
||||
#define PXE_OFFER_INDEX 1
|
||||
#define PXE_ACK_INDEX 2
|
||||
#define PXE_BIS_INDEX 3
|
||||
|
||||
#define DHCPV4_ACK_BUFFER ((struct DhcpReceiveBufferStruct *) Private->DhcpPacketBuffer)[DHCPV4_ACK_INDEX]
|
||||
#define PXE_BINL_BUFFER ((struct DhcpReceiveBufferStruct *) Private->DhcpPacketBuffer)[PXE_BINL_INDEX]
|
||||
#define PXE_OFFER_BUFFER ((struct DhcpReceiveBufferStruct *) Private->DhcpPacketBuffer)[PXE_OFFER_INDEX]
|
||||
#define PXE_ACK_BUFFER ((struct DhcpReceiveBufferStruct *) Private->DhcpPacketBuffer)[PXE_ACK_INDEX]
|
||||
#define PXE_BIS_BUFFER ((struct DhcpReceiveBufferStruct *) Private->DhcpPacketBuffer)[PXE_BIS_INDEX]
|
||||
|
||||
#define DHCPV4_ACK_PACKET DHCPV4_ACK_BUFFER.u.Dhcpv4
|
||||
#define PXE_BINL_PACKET PXE_BINL_BUFFER.u.Dhcpv4
|
||||
#define PXE_OFFER_PACKET PXE_OFFER_BUFFER.u.Dhcpv4
|
||||
#define PXE_ACK_PACKET PXE_ACK_BUFFER.u.Dhcpv4
|
||||
#define PXE_BIS_PACKET PXE_BIS_BUFFER.u.Dhcpv4
|
||||
|
||||
//
|
||||
// network structure definitions
|
||||
//
|
||||
//
|
||||
// some option definitions
|
||||
//
|
||||
#define DHCPV4_OPTION_LENGTH(type) (sizeof (type) - sizeof (DHCPV4_OP_HEADER))
|
||||
|
||||
typedef struct {
|
||||
DHCPV4_OP_HEADER Header;
|
||||
UINT8 Type;
|
||||
} DHCPV4_OP_MESSAGE_TYPE;
|
||||
|
||||
typedef struct {
|
||||
DHCPV4_OP_HEADER Header;
|
||||
UINT8 Overload;
|
||||
} DHCPV4_OP_OVERLOAD;
|
||||
|
||||
//
|
||||
// boot server list structure
|
||||
// one or more contained in a pxe boot servers structure
|
||||
//
|
||||
typedef struct {
|
||||
UINT8 IpCount;
|
||||
EFI_IPv4_ADDRESS IpList[1]; // IP count of IPs
|
||||
} PXEV4_SERVER_LIST;
|
||||
|
||||
typedef struct {
|
||||
UINT8 IpCount;
|
||||
EFI_IPv6_ADDRESS IpList[1]; // IP count of IPs
|
||||
} PXEV6_SERVER_LIST;
|
||||
|
||||
typedef union {
|
||||
PXEV4_SERVER_LIST Ipv4List;
|
||||
PXEV6_SERVER_LIST Ipv6List;
|
||||
} PXE_SERVER_LISTS;
|
||||
|
||||
typedef struct {
|
||||
UINT16 Type;
|
||||
PXE_SERVER_LISTS u;
|
||||
} PXE_SERVER_LIST;
|
||||
|
||||
//
|
||||
// pxe boot servers structure
|
||||
//
|
||||
typedef struct {
|
||||
DHCPV4_OP_HEADER Header;
|
||||
PXE_SERVER_LIST ServerList[1]; // one or more
|
||||
} PXE_OP_SERVER_LIST;
|
||||
|
||||
//
|
||||
// pxe boot item structure
|
||||
//
|
||||
typedef struct {
|
||||
DHCPV4_OP_HEADER Header;
|
||||
UINT16 Type;
|
||||
UINT16 Layer;
|
||||
} PXE_OP_BOOT_ITEM;
|
||||
|
||||
//
|
||||
// pxe boot menu item structure
|
||||
//
|
||||
typedef struct {
|
||||
UINT16 Type;
|
||||
UINT8 DataLen;
|
||||
UINT8 Data[1];
|
||||
} PXE_BOOT_MENU_ENTRY;
|
||||
|
||||
//
|
||||
// pxe boot menu structure
|
||||
//
|
||||
typedef struct {
|
||||
DHCPV4_OP_HEADER Header;
|
||||
PXE_BOOT_MENU_ENTRY MenuItem[1];
|
||||
} PXE_OP_BOOT_MENU;
|
||||
|
||||
//
|
||||
// pxe boot prompt structure
|
||||
//
|
||||
typedef struct {
|
||||
DHCPV4_OP_HEADER Header;
|
||||
UINT8 Timeout;
|
||||
UINT8 Prompt[1];
|
||||
} PXE_OP_BOOT_PROMPT;
|
||||
|
||||
#define PXE_BOOT_PROMPT_AUTO_SELECT 0
|
||||
#define PXE_BOOT_PROMPT_NO_TIMEOUT 255
|
||||
|
||||
typedef struct {
|
||||
DHCPV4_OP_HEADER Header;
|
||||
UINT8 Class[1];
|
||||
} DHCPV4_OP_CLASS;
|
||||
|
||||
typedef struct {
|
||||
DHCPV4_OP_HEADER Header;
|
||||
UINT8 File[1];
|
||||
} DHCPV4_OP_BOOTFILE;
|
||||
|
||||
typedef struct {
|
||||
DHCPV4_OP_HEADER Header;
|
||||
UINT8 VendorOptions[1];
|
||||
} DHCPV4_OP_VENDOR_OPTIONS;
|
||||
|
||||
typedef struct {
|
||||
DHCPV4_OP_HEADER Header;
|
||||
UINT8 MaxSize[2];
|
||||
} DHCPV4_OP_MAX_MESSAGE_SIZE;
|
||||
|
||||
typedef struct {
|
||||
UINT8 _OP_SUBNET_MASK; /* 1 */
|
||||
UINT8 _OP_TIME_OFFSET; /* 2 */
|
||||
UINT8 _OP_ROUTER_LIST; /* 3 */
|
||||
UINT8 _OP_TIME_SERVERS; /* 4 */
|
||||
UINT8 _OP_NAME_SERVERS; /* 5 */
|
||||
UINT8 _OP_DNS_SERVERS; /* 6 */
|
||||
UINT8 _OP_HOST_NAME; /* 12 */
|
||||
UINT8 _OP_BOOT_FILE_SZ; /* 13 */
|
||||
UINT8 _OP_DOMAIN_NAME; /* 15 */
|
||||
UINT8 _OP_ROOT_PATH; /* 17 */
|
||||
UINT8 _OP_EXTENSION_PATH; /* 18 */
|
||||
UINT8 _OP_MAX_DATAGRAM_SZ; /* 22 */
|
||||
UINT8 _OP_DEFAULT_TTL; /* 23 */
|
||||
UINT8 _OP_BROADCAST_ADD; /* 28 */
|
||||
UINT8 _OP_NIS_DOMAIN_NAME; /* 40 */
|
||||
UINT8 _OP_NIS_SERVERS; /* 41 */
|
||||
UINT8 _OP_NTP_SERVERS; /* 42 */
|
||||
UINT8 _OP_VENDOR_SPECIFIC; /* 43 */
|
||||
UINT8 _OP_DHCP_REQ_IP_ADD; /* 50 */
|
||||
UINT8 _OP_DHCP_LEASE_TIME; /* 51 */
|
||||
UINT8 _OP_DHCP_SERVER_IP; /* 54 */
|
||||
UINT8 _OP_DHCP_RENEWAL_TIME; /* 58 */
|
||||
UINT8 _OP_DHCP_REBINDING_TIME; /* 59 */
|
||||
UINT8 _OP_DHCP_CLASS_IDENTIFIER; /* 60 */
|
||||
UINT8 _OP_DHCP_TFTP_SERVER_NAME; /* 66 */
|
||||
UINT8 _OP_DHCP_BOOTFILE; /* 67 */
|
||||
UINT8 _OP_DHCP_PLATFORM_ID; /* 97 */
|
||||
UINT8 VendorOption128; // vendor option 128
|
||||
UINT8 VendorOption129; // vendor option 129
|
||||
UINT8 VendorOption130; // vendor option 130
|
||||
UINT8 VendorOption131; // vendor option 131
|
||||
UINT8 VendorOption132; // vendor option 132
|
||||
UINT8 VendorOption133; // vendor option 133
|
||||
UINT8 VendorOption134; // vendor option 134
|
||||
UINT8 VendorOption135; // vendor option 135
|
||||
} DHCPV4_REQUESTED_OPTIONS_DATA;
|
||||
|
||||
typedef struct {
|
||||
DHCPV4_OP_HEADER Header;
|
||||
DHCPV4_REQUESTED_OPTIONS_DATA Data;
|
||||
} DHCPV4_OP_REQUESTED_OPTIONS;
|
||||
|
||||
typedef struct opipstr {
|
||||
DHCPV4_OP_HEADER Header;
|
||||
EFI_IPv4_ADDRESS Ip;
|
||||
} DHCPV4_OP_IP_ADDRESS;
|
||||
|
||||
//
|
||||
// ip list structure - e.g. router list
|
||||
//
|
||||
typedef struct {
|
||||
DHCPV4_OP_HEADER Header;
|
||||
EFI_IPv4_ADDRESS IpList[1];
|
||||
} DHCPV4_OP_IP_LIST;
|
||||
|
||||
typedef struct {
|
||||
DHCPV4_OP_HEADER Header;
|
||||
UINT8 Type;
|
||||
UINT8 Guid[sizeof (EFI_GUID)];
|
||||
} DHCPV4_OP_CLIENT_ID;
|
||||
|
||||
//
|
||||
// special options start - someday obsolete ???
|
||||
//
|
||||
#define DHCPV4_OP_PLATFORM_ID DHCPV4_OP_CLIENT_ID
|
||||
|
||||
typedef struct {
|
||||
DHCPV4_OP_HEADER Header;
|
||||
UINT8 Type; // SNP = 2
|
||||
UINT8 MajorVersion;
|
||||
UINT8 MinorVersion;
|
||||
} DHCPV4_OP_NETWORK_INTERFACE;
|
||||
|
||||
#define UNDI_TYPE 1
|
||||
#define SNP_TYPE 2
|
||||
|
||||
typedef struct {
|
||||
DHCPV4_OP_HEADER Header;
|
||||
UINT16 Type;
|
||||
} DHCPV4_OP_ARCHITECTURE_TYPE;
|
||||
//
|
||||
// special options end - someday obsolete ???
|
||||
//
|
||||
typedef struct {
|
||||
UINT8 ClassIdentifier[10]; // PXEClient:
|
||||
UINT8 Lit2[5]; // Arch:
|
||||
UINT8 ArchitectureType[5]; // 00000 - 65536
|
||||
UINT8 Lit3[1]; // :
|
||||
UINT8 InterfaceName[4]; // e.g. UNDI
|
||||
UINT8 Lit4[1]; // :
|
||||
UINT8 UndiMajor[3]; // 000 - 255
|
||||
UINT8 UndiMinor[3]; // 000 - 255
|
||||
} DHCPV4_CLASS_ID_DATA;
|
||||
|
||||
typedef struct {
|
||||
DHCPV4_OP_HEADER Header;
|
||||
DHCPV4_CLASS_ID_DATA Data;
|
||||
} DHCPV4_OP_CLASS_ID;
|
||||
|
||||
typedef struct {
|
||||
DHCPV4_OP_HEADER Header;
|
||||
EFI_IPv4_ADDRESS Ip;
|
||||
} DHCPV4_OP_REQUESTED_IP;
|
||||
|
||||
typedef struct {
|
||||
DHCPV4_OP_HEADER Header;
|
||||
EFI_IPv4_ADDRESS Ip;
|
||||
} DHCPV4_OP_SERVER_IP;
|
||||
|
||||
typedef struct {
|
||||
DHCPV4_OP_HEADER Header;
|
||||
EFI_IPv4_ADDRESS Ip;
|
||||
} DHCPV4_OP_SUBNET_MASK;
|
||||
|
||||
typedef struct { // oppxedisctlstr {
|
||||
DHCPV4_OP_HEADER Header;
|
||||
UINT8 ControlBits;
|
||||
} PXE_OP_DISCOVERY_CONTROL;
|
||||
|
||||
#define DISABLE_BCAST (1 << 0)
|
||||
#define DISABLE_MCAST (1 << 1)
|
||||
#define USE_ACCEPT_LIST (1 << 2)
|
||||
#define USE_BOOTFILE (1 << 3)
|
||||
|
||||
#pragma pack()
|
||||
//
|
||||
// definitions of indices to populate option interest array
|
||||
//
|
||||
#define VEND_PXE_MTFTP_IP_IX 1 // multicast IP address of bootfile for MTFTP listen
|
||||
#define VEND_PXE_MTFTP_CPORT_IX 2 // UDP Port to monitor for MTFTP responses - Intel order
|
||||
#define VEND_PXE_MTFTP_SPORT_IX 3 // Server UDP Port for MTFTP open - Intel order
|
||||
#define VEND_PXE_MTFTP_TMOUT_IX 4 // Listen timeout - secs
|
||||
#define VEND_PXE_MTFTP_DELAY_IX 5 // Transmission timeout - secs
|
||||
#define VEND_PXE_DISCOVERY_CONTROL_IX 6 // bit field
|
||||
#define VEND_PXE_DISCOVERY_MCAST_ADDR_IX 7 // boot server discovery multicast address
|
||||
#define VEND_PXE_BOOT_SERVERS_IX 8 // list of boot servers of form tp(2) cnt(1) ips[cnt]
|
||||
#define VEND_PXE_BOOT_MENU_IX 9
|
||||
#define VEND_PXE_BOOT_PROMPT_IX 10
|
||||
#define VEND_PXE_MCAST_ADDRS_ALLOC_IX 0 // not used by PXE client
|
||||
#define VEND_PXE_CREDENTIAL_TYPES_IX 11
|
||||
#define VEND_13_IX 0 // not used by PXE client
|
||||
#define VEND_14_IX 0 // not used by PXE client
|
||||
#define VEND_15_IX 0 // not used by PXE client
|
||||
#define VEND_16_IX 0 // not used by PXE client
|
||||
#define VEND_17_IX 0 // not used by PXE client
|
||||
#define VEND_18_IX 0 // not used by PXE client
|
||||
#define VEND_19_IX 0 // not used by PXE client
|
||||
#define VEND_20_IX 0 // not used by PXE client
|
||||
#define VEND_21_IX 0 // not used by PXE client
|
||||
#define VEND_22_IX 0 // not used by PXE client
|
||||
#define VEND_23_IX 0 // not used by PXE client
|
||||
#define VEND_24_IX 0 // not used by PXE client
|
||||
#define VEND_25_IX 0 // not used by PXE client
|
||||
#define VEND_26_IX 0 // not used by PXE client
|
||||
#define VEND_27_IX 0 // not used by PXE client
|
||||
#define VEND_28_IX 0 // not used by PXE client
|
||||
#define VEND_29_IX 0 // not used by PXE client
|
||||
#define VEND_30_IX 0 // not used by PXE client
|
||||
#define VEND_31_IX 0 // not used by PXE client
|
||||
#define VEND_32_IX 0 // not used by PXE client
|
||||
#define VEND_33_IX 0 // not used by PXE client
|
||||
#define VEND_34_IX 0 // not used by PXE client
|
||||
#define VEND_35_IX 0 // not used by PXE client
|
||||
#define VEND_36_IX 0 // not used by PXE client
|
||||
#define VEND_37_IX 0 // not used by PXE client
|
||||
#define VEND_38_IX 0 // not used by PXE client
|
||||
#define VEND_39_IX 0 // not used by PXE client
|
||||
#define VEND_40_IX 0 // not used by PXE client
|
||||
#define VEND_41_IX 0 // not used by PXE client
|
||||
#define VEND_42_IX 0 // not used by PXE client
|
||||
#define VEND_43_IX 0 // not used by PXE client
|
||||
#define VEND_44_IX 0 // not used by PXE client
|
||||
#define VEND_45_IX 0 // not used by PXE client
|
||||
#define VEND_46_IX 0 // not used by PXE client
|
||||
#define VEND_47_IX 0 // not used by PXE client
|
||||
#define VEND_48_IX 0 // not used by PXE client
|
||||
#define VEND_49_IX 0 // not used by PXE client
|
||||
#define VEND_50_IX 0 // not used by PXE client
|
||||
#define VEND_51_IX 0 // not used by PXE client
|
||||
#define VEND_52_IX 0 // not used by PXE client
|
||||
#define VEND_53_IX 0 // not used by PXE client
|
||||
#define VEND_54_IX 0 // not used by PXE client
|
||||
#define VEND_55_IX 0 // not used by PXE client
|
||||
#define VEND_56_IX 0 // not used by PXE client
|
||||
#define VEND_57_IX 0 // not used by PXE client
|
||||
#define VEND_58_IX 0 // not used by PXE client
|
||||
#define VEND_59_IX 0 // not used by PXE client
|
||||
#define VEND_60_IX 0 // not used by PXE client
|
||||
#define VEND_61_IX 0 // not used by PXE client
|
||||
#define VEND_62_IX 0 // not used by PXE client
|
||||
#define VEND_63_IX 0 // not used by PXE client
|
||||
#define VEND_64_IX 0 // not used by PXE client
|
||||
#define VEND_65_IX 0 // not used by PXE client
|
||||
#define VEND_66_IX 0 // not used by PXE client
|
||||
#define VEND_67_IX 0 // not used by PXE client
|
||||
#define VEND_68_IX 0 // not used by PXE client
|
||||
#define VEND_69_IX 0 // not used by PXE client
|
||||
#define VEND_70_IX 0 // not used by PXE client
|
||||
#define VEND_PXE_BOOT_ITEM_IX 12
|
||||
|
||||
#define MAX_OUR_PXE_OPT VEND_PXE_BOOT_ITEM // largest PXE option in which we are interested
|
||||
#define MAX_OUR_PXE_IX VEND_PXE_BOOT_ITEM_IX // largest PXE option index
|
||||
//
|
||||
// define various types by options that are sent
|
||||
//
|
||||
#define WfM11a_OPTS ((1<<VEND_PXE_MTFTP_IP_IX) | \
|
||||
(1<<VEND_PXE_MTFTP_CPORT_IX) | \
|
||||
(1<<VEND_PXE_MTFTP_SPORT_IX) | \
|
||||
(1<<VEND_PXE_MTFTP_TMOUT_IX) | \
|
||||
(1<<VEND_PXE_MTFTP_DELAY_IX))
|
||||
|
||||
#define DISCOVER_OPTS ((1<<VEND_PXE_DISCOVERY_CONTROL_IX) | \
|
||||
(1<<VEND_PXE_DISCOVERY_MCAST_ADDR_IX) | \
|
||||
(1<<VEND_PXE_BOOT_SERVERS_IX) | \
|
||||
(1<<VEND_PXE_BOOT_MENU_IX) | \
|
||||
(1<<VEND_PXE_BOOT_PROMPT_IX) | \
|
||||
(1<<VEND_PXE_BOOT_ITEM_IX))
|
||||
|
||||
#define CREDENTIALS_OPT (1 << VEND_PXE_CREDENTIAL_TYPES_IX)
|
||||
|
||||
//
|
||||
// definitions of indices to populate option interest array
|
||||
//
|
||||
#define OP_SUBNET_MASK_IX 1
|
||||
#define OP_TIME_OFFSET_IX 0 // not used by PXE client
|
||||
#define OP_ROUTER_LIST_IX 2
|
||||
#define OP_TIME_SERVERS_IX 0 // not used by PXE client
|
||||
#define OP_NAME_SERVERS_IX 0 // not used by PXE client
|
||||
#define OP_DNS_SERVERS_IX 0 // not used by PXE client
|
||||
#define OP_LOG_SERVERS_IX 0 // not used by PXE client
|
||||
#define OP_COOKIE_SERVERS_IX 0 // not used by PXE client
|
||||
#define OP_LPR_SREVERS_IX 0 // not used by PXE client
|
||||
#define OP_IMPRESS_SERVERS_IX 0 // not used by PXE client
|
||||
#define OP_RES_LOC_SERVERS_IX 0 // not used by PXE client
|
||||
#define OP_HOST_NAME_IX 0 // not used by PXE client
|
||||
#define OP_BOOT_FILE_SZ_IX 9
|
||||
#define OP_DUMP_FILE_IX 0 // not used by PXE client
|
||||
#define OP_DOMAIN_NAME_IX 0 // not used by PXE client
|
||||
#define OP_SWAP_SERVER_IX 0 // not used by PXE client
|
||||
#define OP_ROOT_PATH_IX 0 // not used by PXE client
|
||||
#define OP_EXTENSION_PATH_IX 0 // not used by PXE client
|
||||
#define OP_IP_FORWARDING_IX 0 // not used by PXE client
|
||||
#define OP_NON_LOCAL_SRC_RTE_IX 0 // not used by PXE client
|
||||
#define OP_POLICY_FILTER_IX 0 // not used by PXE client
|
||||
#define OP_MAX_DATAGRAM_SZ_IX 0 // not used by PXE client
|
||||
#define OP_DEFAULT_TTL_IX 0 // not used by PXE client
|
||||
#define OP_MTU_AGING_TIMEOUT_IX 0 // not used by PXE client
|
||||
#define OP_MTU_SIZES_IX 0 // not used by PXE client
|
||||
#define OP_MTU_TO_USE_IX 0 // not used by PXE client
|
||||
#define OP_ALL_SUBNETS_LOCAL_IX 0 // not used by PXE client
|
||||
#define OP_BROADCAST_ADD_IX 0 // not used by PXE client
|
||||
#define OP_PERFORM_MASK_DISCOVERY_IX 0 // not used by PXE client
|
||||
#define OP_RESPOND_TO_MASK_REQ_IX 0 // not used by PXE client
|
||||
#define OP_PERFORM_ROUTER_DISCOVERY_IX 0 // not used by PXE client
|
||||
#define OP_ROUTER_SOLICIT_ADDRESS_IX 0 // not used by PXE client
|
||||
#define OP_STATIC_ROUTER_LIST_IX 0 // not used by PXE client
|
||||
#define OP_USE_ARP_TRAILERS_IX 0 // not used by PXE client
|
||||
#define OP_ARP_CACHE_TIMEOUT_IX 0 // not used by PXE client
|
||||
#define OP_ETHERNET_ENCAPSULATION_IX 0 // not used by PXE client
|
||||
#define OP_TCP_DEFAULT_TTL_IX 0 // not used by PXE client
|
||||
#define OP_TCP_KEEP_ALIVE_INT_IX 0 // not used by PXE client
|
||||
#define OP_KEEP_ALIVE_GARBAGE_IX 0 // not used by PXE client
|
||||
#define OP_NIS_DOMAIN_NAME_IX 0 // not used by PXE client
|
||||
#define OP_NIS_SERVERS_IX 0 // not used by PXE client
|
||||
#define OP_NTP_SERVERS_IX 0 // not used by PXE client
|
||||
#define OP_VENDOR_SPECIFIC_IX 3
|
||||
#define OP_NBNS_SERVERS_IX 0 // not used by PXE client
|
||||
#define OP_NBDD_SERVERS_IX 0 // not used by PXE client
|
||||
#define OP_NETBIOS_NODE_TYPE_IX 0 // not used by PXE client
|
||||
#define OP_NETBIOS_SCOPE_IX 0 // not used by PXE client
|
||||
#define OP_XWINDOW_SYSTEM_FONT_SERVERS_IX 0 // not used by PXE client
|
||||
#define OP_XWINDOW_SYSTEM_DISPLAY_MANAGERS_IX 0 // not used by PXE client
|
||||
// DHCP option indices
|
||||
//
|
||||
#define OP_DHCP_REQ_IP_ADD_IX 0 // not used by PXE client
|
||||
#define OP_DHCP_LEASE_TIME_IX 0 // not used by PXE client
|
||||
#define OP_DHCP_OPTION_OVERLOAD_IX 4
|
||||
#define OP_DHCP_MESSAGE_TYPE_IX 5
|
||||
#define OP_DHCP_SERVER_IP_IX 6
|
||||
#define OP_DHCP_PARM_REQ_LIST_IX 0 // not used by PXE client
|
||||
#define OP_DHCP_ERROR_MESSAGE_IX 0 // not used by PXE client
|
||||
#define OP_DHCP_MAX_MESSAGE_SZ_IX 0 // not used by PXE client
|
||||
#define OP_DHCP_RENEWAL_TIME_IX 0 // not used by PXE client
|
||||
#define OP_DHCP_REBINDING_TIME_IX 0 // not used by PXE client
|
||||
#define OP_DHCP_CLASS_IDENTIFIER_IX 7
|
||||
#define OP_DHCP_CLIENT_IDENTIFIER_IX 0 // not used by PXE client
|
||||
#define OP_RESERVED62_IX 0 // not used by PXE client
|
||||
#define OP_RESERVED63_IX 0 // not used by PXE client
|
||||
#define OP_NISPLUS_DOMAIN_NAME_IX 0 // not used by PXE client
|
||||
#define OP_NISPLUS_SERVERS_IX 0 // not used by PXE client
|
||||
#define OP_DHCP_TFTP_SERVER_NAME_IX 0 // not used by PXE client
|
||||
#define OP_DHCP_BOOTFILE_IX 8
|
||||
|
||||
#define MAX_OUR_OPT OP_DHCP_BOOTFILE // largest option in which we are interested
|
||||
#define MAX_OUR_IX OP_BOOT_FILE_SZ_IX
|
||||
|
||||
typedef struct {
|
||||
DHCPV4_OP_STRUCT *PktOptAdds[MAX_OUR_IX];
|
||||
DHCPV4_OP_STRUCT *PxeOptAdds[MAX_OUR_PXE_IX];
|
||||
UINT8 Status;
|
||||
} OPTION_POINTERS;
|
||||
|
||||
typedef struct DhcpReceiveBufferStruct {
|
||||
union {
|
||||
UINT8 ReceiveBuffer[MAX_DHCP_MSG_SZ];
|
||||
DHCPV4_STRUCT Dhcpv4;
|
||||
} u;
|
||||
|
||||
OPTION_POINTERS OpAdds;
|
||||
} DHCP_RECEIVE_BUFFER;
|
||||
|
||||
#define PXE_TYPE (1 << 0)
|
||||
#define WfM11a_TYPE (1 << 1)
|
||||
#define DISCOVER_TYPE (1 << 2)
|
||||
#define CREDENTIALS_TYPE (1 << 3)
|
||||
#define USE_THREE_BYTE (1 << 4)
|
||||
|
||||
#endif // _DHCP_H
|
||||
|
||||
/* EOF - dhcp.h */
|
46
MdeModulePkg/Universal/Network/PxeBcDxe/Ebc/PxeArch.c
Normal file
46
MdeModulePkg/Universal/Network/PxeBcDxe/Ebc/PxeArch.c
Normal file
@@ -0,0 +1,46 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2007, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
PxeArch.c
|
||||
|
||||
Abstract:
|
||||
Defines PXE Arch type
|
||||
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include "PxeArch.h"
|
||||
|
||||
UINT16 mSysArch = 0;
|
||||
|
||||
UINT16
|
||||
GetSysArch (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
if (mSysArch == 0) {
|
||||
//
|
||||
// This is first call
|
||||
// Assign to invalid value
|
||||
//
|
||||
mSysArch = 0xFFFF;
|
||||
|
||||
//
|
||||
// We do not know what is EBC architecture.
|
||||
// Maybe we can try to locate DebugSupport protocol to get ISA.
|
||||
// TBD now.
|
||||
//
|
||||
}
|
||||
|
||||
return mSysArch;
|
||||
}
|
36
MdeModulePkg/Universal/Network/PxeBcDxe/Ebc/PxeArch.h
Normal file
36
MdeModulePkg/Universal/Network/PxeBcDxe/Ebc/PxeArch.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2007, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
PxeArch.h
|
||||
|
||||
Abstract:
|
||||
Defines PXE Arch type
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _EFI_PXE_ARCH_H_
|
||||
#define _EFI_PXE_ARCH_H_
|
||||
|
||||
//
|
||||
// warning #175: subscript out of range
|
||||
//
|
||||
#pragma warning (disable: 175)
|
||||
|
||||
#define SYS_ARCH GetSysArch()
|
||||
|
||||
UINT16
|
||||
GetSysArch (
|
||||
VOID
|
||||
);
|
||||
|
||||
#endif
|
43
MdeModulePkg/Universal/Network/PxeBcDxe/Hton.h
Normal file
43
MdeModulePkg/Universal/Network/PxeBcDxe/Hton.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2004, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module name:
|
||||
hton.h
|
||||
|
||||
Abstract:
|
||||
Byte swapping macros.
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _HTON_H_
|
||||
#define _HTON_H_
|
||||
|
||||
//
|
||||
// Only Intel order functions are defined at this time.
|
||||
//
|
||||
#define HTONS(v) (UINT16) ((((v) << 8) & 0xff00) + (((v) >> 8) & 0x00ff))
|
||||
|
||||
#define HTONL(v) \
|
||||
(UINT32) ((((v) << 24) & 0xff000000) + (((v) << 8) & 0x00ff0000) + (((v) >> 8) & 0x0000ff00) + (((v) >> 24) & 0x000000ff))
|
||||
|
||||
#define HTONLL(v) swap64 (v)
|
||||
|
||||
#define U8PTR(na) ((UINT8 *) &(na))
|
||||
|
||||
#define NTOHS(ns) ((UINT16) (((*U8PTR (ns)) << 8) +*(U8PTR (ns) + 1)))
|
||||
|
||||
#define NTOHL(ns) \
|
||||
((UINT32) (((*U8PTR (ns)) << 24) + ((*(U8PTR (ns) + 1)) << 16) + ((*(U8PTR (ns) + 2)) << 8) +*(U8PTR (ns) + 3)))
|
||||
|
||||
#endif /* _HTON_H_ */
|
||||
|
||||
/* EOF - hton.h */
|
26
MdeModulePkg/Universal/Network/PxeBcDxe/Ia32/PxeArch.h
Normal file
26
MdeModulePkg/Universal/Network/PxeBcDxe/Ia32/PxeArch.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2006, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
PxeArch.h
|
||||
|
||||
Abstract:
|
||||
Defines PXE Arch type
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _EFI_PXE_ARCH_H_
|
||||
#define _EFI_PXE_ARCH_H_
|
||||
|
||||
#define SYS_ARCH 0x6
|
||||
|
||||
#endif
|
736
MdeModulePkg/Universal/Network/PxeBcDxe/Ip.h
Normal file
736
MdeModulePkg/Universal/Network/PxeBcDxe/Ip.h
Normal file
@@ -0,0 +1,736 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2004 - 2006, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _IP_H_
|
||||
#define _IP_H_
|
||||
|
||||
#include "hton.h"
|
||||
|
||||
//
|
||||
// portability macros
|
||||
//
|
||||
#define UDP_FILTER_MASK (EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_IP | \
|
||||
EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT | \
|
||||
EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_IP | \
|
||||
EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT | \
|
||||
EFI_PXE_BASE_CODE_UDP_OPFLAGS_USE_FILTER \
|
||||
)
|
||||
|
||||
#define PXE_BOOT_LAYER_MASK 0x7FFF
|
||||
#define PXE_BOOT_LAYER_INITIAL 0x0000
|
||||
#define PXE_BOOT_LAYER_CREDENTIAL_FLAG 0x8000
|
||||
#define MAX_BOOT_SERVERS 32
|
||||
|
||||
//
|
||||
// macro to evaluate IP address as TRUE if it is a multicast IP address
|
||||
//
|
||||
#define IS_MULTICAST(ptr) ((*((UINT8 *) ptr) & 0xf0) == 0xe0)
|
||||
|
||||
//
|
||||
// length macros
|
||||
//
|
||||
#define IP_ADDRESS_LENGTH(qp) (((qp)->UsingIpv6) ? sizeof (EFI_IPv6_ADDRESS) : sizeof (EFI_IPv4_ADDRESS))
|
||||
|
||||
#define MAX_FRAME_DATA_SIZE 1488
|
||||
#define ALLOCATE_SIZE(X) (((X) + 7) & 0xfff8)
|
||||
#define MODE_ALLOCATE_SIZE ALLOCATE_SIZE (sizeof (EFI_PXE_BASE_CODE_MODE))
|
||||
#define BUFFER_ALLOCATE_SIZE (8192 + 512)
|
||||
#define ROUTER_ALLOCATE_SIZE ALLOCATE_SIZE ((sizeof (EFI_PXE_BASE_CODE_ROUTE_ENTRY) * PXE_ROUTER_TABLE_SIZE))
|
||||
#define ARP_ALLOCATE_SIZE ALLOCATE_SIZE ((sizeof (EFI_PXE_BASE_CODE_ARP_ENTRY) * PXE_ARP_CACHE_SIZE))
|
||||
#define FILTER_ALLOCATE_SIZE ALLOCATE_SIZE ((sizeof (EFI_IP_ADDRESS) * PXE_IP_FILTER_SIZE))
|
||||
#define PXE_ARP_CACHE_SIZE 8
|
||||
#define PXE_ROUTER_TABLE_SIZE 8
|
||||
#define PXE_IP_FILTER_SIZE 8
|
||||
#define ICMP_ALLOCATE_SIZE ALLOCATE_SIZE (sizeof (EFI_PXE_BASE_CODE_ICMP_ERROR))
|
||||
#define TFTP_ERR_ALLOCATE_SIZE ALLOCATE_SIZE (sizeof (EFI_PXE_BASE_CODE_TFTP_ERROR))
|
||||
|
||||
//
|
||||
// DHCP discover/request packets are sent to this UDP port. ProxyDHCP
|
||||
// servers listen on this port for DHCP discover packets that have a
|
||||
// class identifier (option 60) with 'PXEClient' in the first 9 bytes.
|
||||
// Bootservers also listen on this port for PXE broadcast discover
|
||||
// requests from PXE clients.
|
||||
//
|
||||
#define DHCP_SERVER_PORT 67
|
||||
|
||||
//
|
||||
// When DHCP, proxyDHCP and Bootservers respond to DHCP and PXE broadcast
|
||||
// discover requests by broadcasting the reply packet, the packet is
|
||||
// broadcast to this port.
|
||||
//
|
||||
#define DHCP_CLIENT_PORT 68
|
||||
|
||||
//
|
||||
// TFTP servers listen for TFTP open requests on this port.
|
||||
//
|
||||
#define TFTP_OPEN_PORT 69
|
||||
|
||||
//
|
||||
// proxyDHCP and Bootservers listen on this port for a PXE unicast and/or
|
||||
// multicast discover requests from PXE clients. A PXE discover request
|
||||
// looks like a DHCP discover or DHCP request packet.
|
||||
//
|
||||
#define PXE_DISCOVERY_PORT 4011
|
||||
|
||||
//
|
||||
// This port is used by the PXE client/server protocol tests.
|
||||
//
|
||||
#define PXE_PORT_PXETEST_PORT 0x8080
|
||||
|
||||
//
|
||||
// Definitions for Ethertype protocol numbers and interface types
|
||||
// Per RFC 1700,
|
||||
//
|
||||
#define PXE_PROTOCOL_ETHERNET_IP 0x0800
|
||||
#define PXE_PROTOCOL_ETHERNET_ARP 0x0806
|
||||
#define PXE_PROTOCOL_ETHERNET_RARP 0x8035
|
||||
|
||||
#define PXE_IFTYPE_ETHERNET 0x01
|
||||
#define PXE_IFTYPE_TOKENRING 0x04
|
||||
#define PXE_IFTYPE_FIBRE_CHANNEL 0x12
|
||||
|
||||
//
|
||||
// Definitions for internet protocol version 4 header
|
||||
// Per RFC 791, September 1981.
|
||||
//
|
||||
#define IPVER4 4
|
||||
|
||||
#pragma pack(1) // make network structures packed byte alignment
|
||||
typedef union {
|
||||
UINT8 B[4];
|
||||
UINT32 L;
|
||||
} IPV4_ADDR;
|
||||
|
||||
#define IPV4_HEADER_LENGTH(IpHeaderPtr) (((IpHeaderPtr)->VersionIhl & 0xf) << 2)
|
||||
|
||||
#define SET_IPV4_VER_HDL(IpHeaderPtr, IpHeaderLen) { \
|
||||
(IpHeaderPtr)->VersionIhl = (UINT8) ((IPVER4 << 4) | ((IpHeaderLen) >> 2)); \
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
UINT8 VersionIhl;
|
||||
UINT8 TypeOfService;
|
||||
UINT16 TotalLength;
|
||||
UINT16 Id;
|
||||
UINT16 FragmentFields;
|
||||
UINT8 TimeToLive;
|
||||
UINT8 Protocol;
|
||||
UINT16 HeaderChecksum;
|
||||
IPV4_ADDR SrcAddr;
|
||||
IPV4_ADDR DestAddr;
|
||||
//
|
||||
// options are not implemented
|
||||
//
|
||||
} IPV4_HEADER;
|
||||
|
||||
#define IP_FRAG_RSVD 0x8000 // reserved bit - must be zero
|
||||
#define IP_NO_FRAG 0x4000 // do not fragment bit
|
||||
#define IP_MORE_FRAG 0x2000 // not last fragment
|
||||
#define IP_FRAG_OFF_MSK 0x1fff // fragment offset in 8 byte chunks
|
||||
#define DEFAULT_RFC_TTL 64
|
||||
|
||||
#define PROT_ICMP 1
|
||||
#define PROT_IGMP 2
|
||||
#define PROT_TCP 6
|
||||
#define PROT_UDP 17
|
||||
|
||||
/*
|
||||
* Definitions for internet control message protocol version 4 message
|
||||
* structure. Per RFC 792, September 1981.
|
||||
*/
|
||||
|
||||
//
|
||||
// icmp header for all icmp messages
|
||||
//
|
||||
typedef struct {
|
||||
UINT8 Type; // message type
|
||||
UINT8 Code; // type specific - 0 for types we implement
|
||||
UINT16 Checksum; // ones complement of ones complement sum of 16 bit words of message
|
||||
} ICMPV4_HEADER;
|
||||
|
||||
#define ICMP_DEST_UNREACHABLE 3
|
||||
#define ICMP_SOURCE_QUENCH 4
|
||||
#define ICMP_REDIRECT 5
|
||||
#define ICMP_ECHO 8
|
||||
#define ICMP_ECHO_REPLY 0
|
||||
#define ICMP_ROUTER_ADV 9
|
||||
#define ICMP_ROUTER_SOLICIT 10
|
||||
#define ICMP_TIME_EXCEEDED 11
|
||||
#define ICMP_PARAMETER_PROBLEM 12
|
||||
#define ICMP_TIMESTAMP 13
|
||||
#define ICMP_TIMESTAMP_REPLY 14
|
||||
#define ICMP_INFO_REQ 15
|
||||
#define ICMP_INFO_REQ_REPLY 16
|
||||
#define ICMP_SUBNET_MASK_REQ 17
|
||||
#define ICMP_SUBNET_MASK_REPLY 18
|
||||
//
|
||||
// other ICMP message types ignored in this implementation
|
||||
//
|
||||
// icmp general messages
|
||||
//
|
||||
typedef struct {
|
||||
ICMPV4_HEADER Header;
|
||||
//
|
||||
// generally unused except byte [0] for
|
||||
// parameter problem message
|
||||
//
|
||||
UINT8 GenerallyUnused[4];
|
||||
//
|
||||
// original message ip header of plus 64
|
||||
// bits of data
|
||||
//
|
||||
IPV4_HEADER IpHeader;
|
||||
} ICMPV4_GENERAL_MESSAGE;
|
||||
|
||||
//
|
||||
// icmp req/rply message header
|
||||
//
|
||||
typedef struct {
|
||||
ICMPV4_HEADER Header;
|
||||
UINT16 Id;
|
||||
UINT16 SequenceNumber;
|
||||
} ICMPV4_REQUEST_REPLY_HEADER;
|
||||
|
||||
//
|
||||
// icmp echo message
|
||||
//
|
||||
typedef struct {
|
||||
ICMPV4_REQUEST_REPLY_HEADER Header;
|
||||
UINT8 EchoData[1]; // variable length data to be echoed
|
||||
} ICMPV4_ECHO_MESSAGE;
|
||||
|
||||
//
|
||||
// icmp timestamp message - times are milliseconds since midnight UT -
|
||||
// if non std, set high order bit
|
||||
//
|
||||
typedef struct {
|
||||
ICMPV4_REQUEST_REPLY_HEADER Header;
|
||||
UINT32 OriginalTime; // originating timestamp
|
||||
UINT32 ReceiveTime; // receiving timestamp
|
||||
UINT32 TransmitTime; // transmitting timestamp
|
||||
} ICMPV4_TIMESTAMP_MESSAGE;
|
||||
|
||||
//
|
||||
// icmp info request structure - fill in source and dest net ip address on reply
|
||||
//
|
||||
typedef struct {
|
||||
ICMPV4_REQUEST_REPLY_HEADER Header;
|
||||
} ICMPV4_INFO_MESSAGE;
|
||||
|
||||
//
|
||||
// Definitions for internet control message protocol version 4 message structure
|
||||
// Router discovery
|
||||
// Per RFC 1256, September 1991.
|
||||
//
|
||||
//
|
||||
// icmp router advertisement message
|
||||
//
|
||||
typedef struct {
|
||||
ICMPV4_HEADER Header;
|
||||
UINT8 NumberEntries; // number of address entries
|
||||
UINT8 EntrySize; // number of 32 bit words per address entry
|
||||
UINT16 Lifetime; // seconds to consider info valid
|
||||
UINT32 RouterIp;
|
||||
UINT32 Preferance;
|
||||
} ICMPV4_ROUTER_ADVERTISE_MESSAGE;
|
||||
|
||||
//
|
||||
// icmp router solicitation message
|
||||
//
|
||||
typedef struct {
|
||||
ICMPV4_HEADER Header;
|
||||
UINT32 Reserved;
|
||||
} ICMPV4_ROUTER_SOLICIT_MESSAGE;
|
||||
|
||||
#define MAX_SOLICITATION_DELAY 1 // 1 second
|
||||
#define SOLICITATION_INTERVAL 3 // 3 seconds
|
||||
#define MAX_SOLICITATIONS 3 // 3 transmissions
|
||||
#define V1ROUTER_PRESENT_TIMEOUT 400 // 400 second timeout until v2 reports can be sent
|
||||
#define UNSOLICITED_REPORT_INTERVAL 10 // 10 seconds between unsolicited reports
|
||||
#define BROADCAST_IPv4 0xffffffff
|
||||
|
||||
//
|
||||
// Definitions for address resolution protocol message structure
|
||||
// Per RFC 826, November 1982
|
||||
//
|
||||
typedef struct {
|
||||
UINT16 HwType; // hardware type - e.g. ethernet (1)
|
||||
UINT16 ProtType; // protocol type - for ethernet, 0x800 for IP
|
||||
UINT8 HwAddLen; // byte length of a hardware address (e.g. 6 for ethernet)
|
||||
UINT8 ProtAddLen; // byte length of a protocol address (e.g. 4 for ipv4)
|
||||
UINT16 OpCode;
|
||||
//
|
||||
// source and dest hw and prot addresses follow - see example below
|
||||
//
|
||||
} ARP_HEADER;
|
||||
|
||||
#define ETHERNET_ADD_SPC 1
|
||||
|
||||
#define ETHER_TYPE_IP 0x800
|
||||
|
||||
#define ARP_REQUEST 1
|
||||
#define ARP_REPLY 2
|
||||
|
||||
//
|
||||
// generic ARP packet
|
||||
//
|
||||
typedef struct {
|
||||
ARP_HEADER ArpHeader;
|
||||
EFI_MAC_ADDRESS SrcHardwareAddr;
|
||||
EFI_IP_ADDRESS SrcProtocolAddr;
|
||||
EFI_MAC_ADDRESS DestHardwareAddr;
|
||||
EFI_IP_ADDRESS DestProtocolAddr;
|
||||
} ARP_PACKET;
|
||||
|
||||
#define ENET_HWADDLEN 6
|
||||
#define IPV4_PROTADDLEN 4
|
||||
|
||||
//
|
||||
// Definitions for user datagram protocol version 4 pseudo header & header
|
||||
// Per RFC 768, 28 August 1980
|
||||
//
|
||||
typedef struct {
|
||||
IPV4_ADDR SrcAddr; // source ip address
|
||||
IPV4_ADDR DestAddr; // dest ip address
|
||||
UINT8 Zero; // 0
|
||||
UINT8 Protocol; // protocol
|
||||
UINT16 TotalLength; // UDP length - sizeof udpv4hdr + data length
|
||||
} UDPV4_PSEUDO_HEADER;
|
||||
|
||||
typedef struct {
|
||||
UINT16 SrcPort; // source port identifier
|
||||
UINT16 DestPort; // destination port identifier
|
||||
UINT16 TotalLength; // total length header plus data
|
||||
//
|
||||
// ones complement of ones complement sum of 16 bit
|
||||
// words of pseudo header, UDP header, and data
|
||||
// zero checksum is transmitted as -0 (ones comp)
|
||||
// zero transmitted means checksum not computed
|
||||
// data follows
|
||||
//
|
||||
UINT16 Checksum;
|
||||
} UDPV4_HEADER;
|
||||
|
||||
typedef struct {
|
||||
UDPV4_PSEUDO_HEADER Udpv4PseudoHeader;
|
||||
UDPV4_HEADER Udpv4Header;
|
||||
} UDPV4_HEADERS;
|
||||
|
||||
//
|
||||
// Definitions for transmission control protocol header
|
||||
// Per RFC 793, September, 1981
|
||||
//
|
||||
typedef struct {
|
||||
IPV4_ADDR SrcAddr; // source ip address
|
||||
IPV4_ADDR DestAddr; // dest ip address
|
||||
UINT8 Zero; // 0
|
||||
UINT8 Protocol; // protocol
|
||||
UINT16 TotalLength; // TCP length - TCP header length + data length
|
||||
} TCPV4_PSEUDO_HEADER;
|
||||
|
||||
typedef struct {
|
||||
UINT16 SrcPort; // source port identifier
|
||||
UINT16 DestPort; // destination port identifier
|
||||
UINT32 SeqNumber; // Sequence number
|
||||
UINT32 AckNumber; // Acknowledgement Number
|
||||
//
|
||||
// Nibble of HLEN (length of header in 32-bit multiples)
|
||||
// 6bits of RESERVED
|
||||
// Nibble of Code Bits
|
||||
//
|
||||
UINT16 HlenResCode;
|
||||
UINT16 Window; // Software buffer size (sliding window size) in network-standard byte order
|
||||
//
|
||||
// ones complement of ones complement sum of 16 bit words of
|
||||
// pseudo header, TCP header, and data
|
||||
// zero checksum is transmitted as -0 (ones comp)
|
||||
// zero transmitted means checksum not computed
|
||||
//
|
||||
UINT16 Checksum;
|
||||
UINT16 UrgentPointer; // pointer to urgent data (allows sender to specify urgent data)
|
||||
} TCPV4_HEADER;
|
||||
|
||||
typedef struct {
|
||||
TCPV4_PSEUDO_HEADER Tcpv4PseudoHeader;
|
||||
TCPV4_HEADER Tcpv4Header;
|
||||
} TCPV4_HEADERS;
|
||||
|
||||
typedef struct {
|
||||
UINT8 Kind; // one of the following:
|
||||
UINT8 Length; // total option length including Kind and Lth
|
||||
UINT8 Data[1]; // length = Lth - 2
|
||||
} TCPV4_OPTION;
|
||||
|
||||
#define TCP_OP_END 0 // only used to pad to end of TCP header
|
||||
#define TCP_NOP 1 // optional - may be used to pad between options to get alignment
|
||||
#define TCP_MAX_SEG 2 // maximum receive segment size - only send at initial connection request
|
||||
#define MAX_MEDIA_HDR_SIZE 64
|
||||
#define MIN_ENET_DATA_SIZE 64
|
||||
#define MAX_ENET_DATA_SIZE 1500 // temp def - make a network based var
|
||||
#define MAX_IPV4_PKT_SIZE 65535 // maximum IP packet size
|
||||
#define MAX_IPV4_DATA_SIZE (MAX_IPV4_PKT_SIZE - sizeof (IPV4_HEADER))
|
||||
#define MAX_IPV4_FRAME_DATA_SIZE (MAX_FRAME_DATA_SIZE - sizeof (IPV4_HEADER))
|
||||
#define REAS_IPV4_PKT_SIZE 576 // minimum IP packet size all IP host can handle
|
||||
#define REAS_IPV4_DATA_SIZE (REAS_IPV4_PKT_SIZE - sizeof (IPV4_HEADER))
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
typedef union {
|
||||
UINT8 Data[MAX_ENET_DATA_SIZE];
|
||||
ICMPV4_HEADER IcmpHeader;
|
||||
IGMPV2_MESSAGE IgmpMessage;
|
||||
struct {
|
||||
UDPV4_HEADER UdpHeader;
|
||||
UINT8 Data[1];
|
||||
} Udp;
|
||||
struct {
|
||||
TCPV4_HEADER TcpHeader;
|
||||
UINT8 Data[1];
|
||||
} Tcp;
|
||||
} PROTOCOL_UNION;
|
||||
|
||||
//
|
||||
// out buffer structure
|
||||
//
|
||||
typedef struct {
|
||||
UINT8 MediaHeader[MAX_MEDIA_HDR_SIZE];
|
||||
IPV4_HEADER IpHeader;
|
||||
//
|
||||
// following union placement only valid if no option IP header
|
||||
//
|
||||
PROTOCOL_UNION u;
|
||||
} IPV4_BUFFER;
|
||||
|
||||
typedef struct {
|
||||
IPV4_HEADER IpHeader;
|
||||
//
|
||||
// following union placement only valid if no option IP header
|
||||
//
|
||||
PROTOCOL_UNION u;
|
||||
} IPV4_STRUCT;
|
||||
|
||||
#pragma pack() // reset to default
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// BC IP Filter Routine
|
||||
//
|
||||
EFI_STATUS
|
||||
IpFilter (
|
||||
PXE_BASECODE_DEVICE *Private,
|
||||
IN EFI_PXE_BASE_CODE_IP_FILTER *Filter
|
||||
)
|
||||
;
|
||||
|
||||
//
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Udp Write Routine - called by base code - e.g. TFTP - already locked
|
||||
//
|
||||
EFI_STATUS
|
||||
UdpWrite (
|
||||
IN PXE_BASECODE_DEVICE *Private,
|
||||
IN UINT16 OpFlags,
|
||||
IN EFI_IP_ADDRESS *DestIpPtr,
|
||||
IN EFI_PXE_BASE_CODE_UDP_PORT *DestPortptr,
|
||||
IN EFI_IP_ADDRESS *GatewayIpPtr, OPTIONAL
|
||||
IN EFI_IP_ADDRESS *SrcIpPtr, OPTIONAL
|
||||
IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPortPtr, OPTIONAL
|
||||
IN UINTN *HeaderSizePtr, OPTIONAL
|
||||
IN VOID *HeaderPtr, OPTIONAL
|
||||
IN UINTN *BufferSizePtr,
|
||||
IN VOID *BufferPtr
|
||||
)
|
||||
;
|
||||
|
||||
//
|
||||
// /////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Udp Read Routine - called by base code - e.g. TFTP - already locked
|
||||
//
|
||||
EFI_STATUS
|
||||
UdpRead (
|
||||
IN PXE_BASECODE_DEVICE *Private,
|
||||
IN UINT16 OpFlags,
|
||||
IN OUT EFI_IP_ADDRESS *DestIpPtr, OPTIONAL
|
||||
IN OUT EFI_PXE_BASE_CODE_UDP_PORT *DestPorPtrt, OPTIONAL
|
||||
IN OUT EFI_IP_ADDRESS *SrcIpPtr, OPTIONAL
|
||||
IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPortPtr, OPTIONAL
|
||||
IN UINTN *HeaderSizePtr, OPTIONAL
|
||||
IN VOID *HeaderPtr, OPTIONAL
|
||||
IN OUT UINTN *BufferSizePtr,
|
||||
IN VOID *BufferPtr,
|
||||
IN EFI_EVENT TimeoutEvent
|
||||
)
|
||||
;
|
||||
|
||||
VOID
|
||||
IgmpLeaveGroup (
|
||||
PXE_BASECODE_DEVICE *Private,
|
||||
EFI_IP_ADDRESS *
|
||||
)
|
||||
;
|
||||
|
||||
VOID
|
||||
IgmpJoinGroup (
|
||||
PXE_BASECODE_DEVICE *Private,
|
||||
EFI_IP_ADDRESS *
|
||||
)
|
||||
;
|
||||
|
||||
//
|
||||
// convert number to zero filled ascii value of length lth
|
||||
//
|
||||
VOID
|
||||
CvtNum (
|
||||
UINTN Number,
|
||||
UINT8 *BufferPtr,
|
||||
INTN BufferLen
|
||||
)
|
||||
;
|
||||
|
||||
//
|
||||
// convert number to ascii string at ptr
|
||||
//
|
||||
VOID
|
||||
UtoA10 (
|
||||
UINTN Number,
|
||||
UINT8 *BufferPtr
|
||||
)
|
||||
;
|
||||
|
||||
//
|
||||
// convert ascii numeric string to UINTN
|
||||
//
|
||||
UINTN
|
||||
AtoU (
|
||||
UINT8 *BufferPtr
|
||||
)
|
||||
;
|
||||
|
||||
UINT64
|
||||
AtoU64 (
|
||||
UINT8 *BufferPtr
|
||||
)
|
||||
;
|
||||
|
||||
//
|
||||
// calculate the internet checksum (RFC 1071)
|
||||
// return 16 bit ones complement of ones complement sum of 16 bit words
|
||||
//
|
||||
UINT16
|
||||
IpChecksum (
|
||||
UINT16 *MessagePtr,
|
||||
UINTN ByteLength
|
||||
)
|
||||
;
|
||||
|
||||
//
|
||||
// do checksum on non contiguous header and data
|
||||
//
|
||||
UINT16
|
||||
IpChecksum2 (
|
||||
UINT16 *Header,
|
||||
UINTN HeaderLength,
|
||||
UINT16 *Message,
|
||||
UINTN MessageLength
|
||||
)
|
||||
;
|
||||
|
||||
//
|
||||
// update checksum when only a single word changes
|
||||
//
|
||||
UINT16
|
||||
UpdateChecksum (
|
||||
UINT16 OldChecksum,
|
||||
UINT16 OldWord,
|
||||
UINT16 NewWord
|
||||
)
|
||||
;
|
||||
|
||||
VOID
|
||||
SeedRandom (
|
||||
IN PXE_BASECODE_DEVICE *Private,
|
||||
IN UINT16 InitialSeed
|
||||
)
|
||||
;
|
||||
|
||||
UINT16
|
||||
Random (
|
||||
IN PXE_BASECODE_DEVICE *Private
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SendPacket (
|
||||
PXE_BASECODE_DEVICE *Private,
|
||||
VOID *HeaderPtr,
|
||||
VOID *PacketPtr,
|
||||
INTN PacketLength,
|
||||
VOID *HardwareAddress,
|
||||
UINT16 MediaProtocol,
|
||||
IN EFI_PXE_BASE_CODE_FUNCTION Function
|
||||
)
|
||||
;
|
||||
|
||||
VOID
|
||||
HandleArpReceive (
|
||||
PXE_BASECODE_DEVICE *Private,
|
||||
ARP_PACKET *ArpPacketPtr,
|
||||
VOID *HeaderPtr
|
||||
)
|
||||
;
|
||||
|
||||
VOID
|
||||
HandleIgmp (
|
||||
PXE_BASECODE_DEVICE *Private,
|
||||
IGMPV2_MESSAGE *IgmpMessageptr,
|
||||
UINTN IgmpMessageLen
|
||||
)
|
||||
;
|
||||
|
||||
VOID
|
||||
IgmpCheckTimers (
|
||||
PXE_BASECODE_DEVICE *Private
|
||||
)
|
||||
; // poll when doing a receive
|
||||
// return hw add of IP and TRUE if available, otherwise FALSE
|
||||
//
|
||||
BOOLEAN
|
||||
GetHwAddr (
|
||||
IN PXE_BASECODE_DEVICE *Private,
|
||||
EFI_IP_ADDRESS *ProtocolAddressPtr,
|
||||
EFI_MAC_ADDRESS *HardwareAddressPtr
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
DoArp (
|
||||
IN PXE_BASECODE_DEVICE *Private,
|
||||
IN EFI_IP_ADDRESS *ProtocolAddressPtr,
|
||||
OUT EFI_MAC_ADDRESS *HardwareAddressptr
|
||||
)
|
||||
;
|
||||
|
||||
BOOLEAN
|
||||
OnSameSubnet (
|
||||
UINTN IpAddressLen,
|
||||
EFI_IP_ADDRESS *Ip1,
|
||||
EFI_IP_ADDRESS *Ip2,
|
||||
EFI_IP_ADDRESS *SubnetMask
|
||||
)
|
||||
;
|
||||
|
||||
VOID
|
||||
IpAddRouter (
|
||||
PXE_BASECODE_DEVICE *Private,
|
||||
EFI_IP_ADDRESS *RouterIp
|
||||
)
|
||||
;
|
||||
|
||||
#define Ip4AddRouter(Private, Ipv4Ptr) IpAddRouter (Private, (EFI_IP_ADDRESS *) Ipv4Ptr)
|
||||
|
||||
//
|
||||
// routine to send ipv4 packet
|
||||
// ipv4 + upper protocol header for length TotHdrLth in xmtbuf, ipv4 header length IpHdrLth
|
||||
// routine fills in ipv4hdr Ver_Hdl, TotLth, and Checksum, moves in Data, and gets dest MAC address
|
||||
//
|
||||
EFI_STATUS
|
||||
Ipv4Xmt (
|
||||
PXE_BASECODE_DEVICE *Private,
|
||||
UINT32 GatewayIP,
|
||||
UINTN IpHeaderLen,
|
||||
UINTN TotalHeaderLen,
|
||||
VOID *Data,
|
||||
UINTN DataLen,
|
||||
EFI_PXE_BASE_CODE_FUNCTION Function
|
||||
)
|
||||
;
|
||||
|
||||
//
|
||||
// send ipv4 packet with ipv4 option
|
||||
//
|
||||
EFI_STATUS
|
||||
Ipv4SendWOp (
|
||||
PXE_BASECODE_DEVICE *Private,
|
||||
UINT32 GatewayIP,
|
||||
UINT8 *MessagePtr,
|
||||
UINTN MessageLth,
|
||||
UINT8 Protocol,
|
||||
UINT8 *Option,
|
||||
UINTN OptionLen,
|
||||
UINT32 DestIp,
|
||||
EFI_PXE_BASE_CODE_FUNCTION Function
|
||||
)
|
||||
;
|
||||
|
||||
//
|
||||
// send MsgLth message at MsgPtr - higher level protocol header already in xmtbuf, length HdrSize
|
||||
//
|
||||
EFI_STATUS
|
||||
Ip4Send (
|
||||
IN PXE_BASECODE_DEVICE *Private, // pointer to instance data
|
||||
IN UINTN MayFragment, //
|
||||
IN UINT8 Protocol, // protocol
|
||||
IN UINT32 SrcIp, // Source IP address
|
||||
IN UINT32 DestIp, // Destination IP address
|
||||
IN UINT32 GatewayIp, // used if not NULL and needed
|
||||
IN UINTN HeaderSize, // protocol header byte length
|
||||
IN UINT8 *MsgPtr, // pointer to data
|
||||
IN UINTN MsgLength
|
||||
)
|
||||
; // data byte length
|
||||
// receive up to MsgLth message into MsgPtr for protocol Prot
|
||||
// return message length, src/dest ips if select any, and pointer to protocol header
|
||||
//
|
||||
EFI_STATUS
|
||||
IpReceive (
|
||||
IN PXE_BASECODE_DEVICE *Private, // pointer to instance data
|
||||
UINT16 OpFlags, // Flags to determine if filtering on IP addresses
|
||||
EFI_IP_ADDRESS *SrcIpPtr, // if filtering, O if accept any
|
||||
EFI_IP_ADDRESS *DstIpPtr, // if filtering, O if accept any
|
||||
UINT8 Protocol, // protocol
|
||||
VOID *HeaderPtr, // address of where to put protocol header
|
||||
UINTN HeaderSize, // protocol header byte length
|
||||
UINT8 *MsgPtr, // pointer to data buffer
|
||||
UINTN *MsgLenPtr, // pointer to data buffer length/ O - returned data length
|
||||
IN EFI_EVENT TimeoutEvent
|
||||
)
|
||||
;
|
||||
|
||||
#if 0
|
||||
VOID
|
||||
WaitForTxComplete (
|
||||
IN PXE_BASECODE_DEVICE *Private
|
||||
)
|
||||
;
|
||||
#endif
|
||||
//
|
||||
// routine to cycle waiting for a receive or timeout
|
||||
//
|
||||
EFI_STATUS
|
||||
WaitForReceive (
|
||||
IN PXE_BASECODE_DEVICE *Private,
|
||||
IN EFI_PXE_BASE_CODE_FUNCTION Function,
|
||||
IN EFI_EVENT TimeoutEvent,
|
||||
IN OUT UINTN *HeaderSizePtr,
|
||||
IN OUT UINTN *BufferSizePtr,
|
||||
IN OUT UINT16 *ProtocolPtr
|
||||
)
|
||||
;
|
||||
|
||||
#endif /* _IP_H_ */
|
||||
|
||||
/* EOF - ip.h */
|
26
MdeModulePkg/Universal/Network/PxeBcDxe/Ipf/PxeArch.h
Normal file
26
MdeModulePkg/Universal/Network/PxeBcDxe/Ipf/PxeArch.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2006, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
PxeArch.h
|
||||
|
||||
Abstract:
|
||||
Defines PXE Arch type
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _EFI_PXE_ARCH_H_
|
||||
#define _EFI_PXE_ARCH_H_
|
||||
|
||||
#define SYS_ARCH 0x2
|
||||
|
||||
#endif
|
92
MdeModulePkg/Universal/Network/PxeBcDxe/PxeBcDxe.inf
Normal file
92
MdeModulePkg/Universal/Network/PxeBcDxe/PxeBcDxe.inf
Normal file
@@ -0,0 +1,92 @@
|
||||
#/** @file
|
||||
# Component name for module BC
|
||||
#
|
||||
# Copyright (c) 2007, Intel Corporation
|
||||
#
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are licensed and made available under the terms and conditions of the BSD License
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
#
|
||||
#**/
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = PxeBcDxe
|
||||
FILE_GUID = A3f436EA-A127-4EF8-957C-8048606FF670
|
||||
MODULE_TYPE = DXE_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
EDK_RELEASE_VERSION = 0x00020000
|
||||
EFI_SPECIFICATION_VERSION = 0x00020000
|
||||
|
||||
ENTRY_POINT = InitializeBCDriver
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||
#
|
||||
|
||||
[Sources.common]
|
||||
Pxe_bc_mtftp.c
|
||||
Bc.c
|
||||
Dhcp.h
|
||||
Ip.h
|
||||
Pxe_bc_ip.c
|
||||
Pxe_bc_dhcp.c
|
||||
Pxe_bc_arp.c
|
||||
Hton.h
|
||||
ComponentName.c
|
||||
Bc.h
|
||||
Pxe_loadfile.c
|
||||
Tftp.h
|
||||
Pxe_bc_igmp.c
|
||||
Pxe_bc_udp.c
|
||||
|
||||
[Sources.IA32]
|
||||
Ia32\PxeArch.h
|
||||
|
||||
[Sources.X64]
|
||||
X64\PxeArch.h
|
||||
|
||||
[Sources.IPF]
|
||||
Ipf\PxeArch.h
|
||||
|
||||
[Sources.EBC]
|
||||
Ebc\PxeArch.h
|
||||
Ebc\PxeArch.c
|
||||
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
|
||||
|
||||
[LibraryClasses]
|
||||
UefiLib
|
||||
BaseLib
|
||||
UefiBootServicesTableLib
|
||||
UefiDriverEntryPoint
|
||||
BaseMemoryLib
|
||||
DebugLib
|
||||
|
||||
|
||||
[Guids]
|
||||
gEfiSmbiosTableGuid # ALWAYS_CONSUMED
|
||||
|
||||
|
||||
[Protocols]
|
||||
gEfiBisProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiPxeBaseCodeCallbackProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiPxeBaseCodeProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiLoadFileProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiSimpleNetworkProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiDevicePathProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiNetworkInterfaceIdentifierProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiTcpProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiNetworkInterfaceIdentifierProtocolGuid_31 # PROTOCOL ALWAYS_CONSUMED
|
||||
|
106
MdeModulePkg/Universal/Network/PxeBcDxe/PxeBcDxe.msa
Normal file
106
MdeModulePkg/Universal/Network/PxeBcDxe/PxeBcDxe.msa
Normal file
@@ -0,0 +1,106 @@
|
||||
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<MsaHeader>
|
||||
<ModuleName>BC</ModuleName>
|
||||
<ModuleType>DXE_DRIVER</ModuleType>
|
||||
<GuidValue>A3f436EA-A127-4EF8-957C-8048606FF670</GuidValue>
|
||||
<Version>1.0</Version>
|
||||
<Abstract>Component name for module BC</Abstract>
|
||||
<Description>FIX ME!</Description>
|
||||
<Copyright>Copyright (c) 2007, Intel Corporation. All rights reserved.</Copyright>
|
||||
<License>All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>
|
||||
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
|
||||
</MsaHeader>
|
||||
<ModuleDefinitions>
|
||||
<SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
|
||||
<BinaryModule>false</BinaryModule>
|
||||
<OutputFileBasename>BC</OutputFileBasename>
|
||||
</ModuleDefinitions>
|
||||
<LibraryClassDefinitions>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>DebugLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>BaseMemoryLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>UefiDriverEntryPoint</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>UefiBootServicesTableLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>BaseLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>UefiLib</Keyword>
|
||||
</LibraryClass>
|
||||
</LibraryClassDefinitions>
|
||||
<SourceFiles>
|
||||
<Filename>pxe_bc_udp.c</Filename>
|
||||
<Filename>pxe_bc_igmp.c</Filename>
|
||||
<Filename>tftp.h</Filename>
|
||||
<Filename>pxe_loadfile.c</Filename>
|
||||
<Filename>bc.h</Filename>
|
||||
<Filename>ComponentName.c</Filename>
|
||||
<Filename>BcEntry.c</Filename>
|
||||
<Filename>ipf\PxeArch.h</Filename>
|
||||
<Filename>ebc\PxeArch.h</Filename>
|
||||
<Filename SupArchList="X64">x64\PxeArch.h</Filename>
|
||||
<Filename>pxe_bc_tcp.c</Filename>
|
||||
<Filename>hton.h</Filename>
|
||||
<Filename>pxe_bc_arp.c</Filename>
|
||||
<Filename>pxe_bc_dhcp.c</Filename>
|
||||
<Filename>pxe_bc_ip.c</Filename>
|
||||
<Filename>ip.h</Filename>
|
||||
<Filename>dhcp.h</Filename>
|
||||
<Filename>bc.c</Filename>
|
||||
<Filename>pxe_bc_mtftp.c</Filename>
|
||||
<Filename>ia32\PxeArch.h</Filename>
|
||||
<Filename>ebc\PxeArch.c</Filename>
|
||||
</SourceFiles>
|
||||
<PackageDependencies>
|
||||
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||
<Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
|
||||
</PackageDependencies>
|
||||
<Protocols>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiNetworkInterfaceIdentifierProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiDevicePathProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiSimpleNetworkProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiLoadFileProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiPxeBaseCodeProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiPxeBaseCodeCallbackProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiBisProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
</Protocols>
|
||||
<Guids>
|
||||
<GuidCNames Usage="ALWAYS_CONSUMED">
|
||||
<GuidCName>gEfiSmbiosTableGuid</GuidCName>
|
||||
</GuidCNames>
|
||||
</Guids>
|
||||
<Externs>
|
||||
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
|
||||
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
|
||||
<Extern>
|
||||
<ModuleEntryPoint>InitializeBCDriver</ModuleEntryPoint>
|
||||
</Extern>
|
||||
</Externs>
|
||||
</ModuleSurfaceArea>
|
583
MdeModulePkg/Universal/Network/PxeBcDxe/Pxe_bc_arp.c
Normal file
583
MdeModulePkg/Universal/Network/PxeBcDxe/Pxe_bc_arp.c
Normal file
@@ -0,0 +1,583 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2004, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
pxe_bc_arp.c
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#include "Bc.h"
|
||||
|
||||
//
|
||||
// Definitions for ARP
|
||||
// Per RFC 826
|
||||
//
|
||||
STATIC ARP_HEADER ArpHeader;
|
||||
|
||||
#pragma pack(1)
|
||||
STATIC struct {
|
||||
UINT8 MediaHeader[14];
|
||||
ARP_HEADER ArpHeader;
|
||||
UINT8 ArpData[64];
|
||||
} ArpReplyPacket;
|
||||
#pragma pack()
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
/**
|
||||
|
||||
@return none
|
||||
|
||||
**/
|
||||
VOID
|
||||
InitArpHeader (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
ArpHeader.HwType = HTONS (ETHERNET_ADD_SPC);
|
||||
ArpHeader.ProtType = HTONS (ETHER_TYPE_IP);
|
||||
ArpHeader.HwAddLen = ENET_HWADDLEN;
|
||||
ArpHeader.ProtAddLen = IPV4_PROTADDLEN;
|
||||
ArpHeader.OpCode = HTONS (ARP_REQUEST);
|
||||
|
||||
CopyMem (&ArpReplyPacket.ArpHeader, &ArpHeader, sizeof (ARP_HEADER));
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
/**
|
||||
|
||||
|
||||
**/
|
||||
VOID
|
||||
HandleArpReceive (
|
||||
IN PXE_BASECODE_DEVICE *Private,
|
||||
IN ARP_PACKET *ArpPacketPtr,
|
||||
IN VOID *MediaHeader
|
||||
)
|
||||
{
|
||||
EFI_PXE_BASE_CODE_MODE *PxeBcMode;
|
||||
EFI_SIMPLE_NETWORK_MODE *SnpMode;
|
||||
EFI_MAC_ADDRESS TmpMacAddr;
|
||||
UINTN Index;
|
||||
UINT8 *SrcHwAddr;
|
||||
UINT8 *SrcPrAddr;
|
||||
UINT8 *DstHwAddr;
|
||||
UINT8 *DstPrAddr;
|
||||
UINT8 *TmpPtr;
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
PxeBcMode = Private->EfiBc.Mode;
|
||||
SnpMode = Private->SimpleNetwork->Mode;
|
||||
|
||||
//
|
||||
// For now only ethernet addresses are supported.
|
||||
// This will need to be updated when other media
|
||||
// layers are supported by PxeBc, Snp and UNDI.
|
||||
//
|
||||
if (ArpPacketPtr->ArpHeader.HwType != HTONS (ETHERNET_ADD_SPC)) {
|
||||
return ;
|
||||
}
|
||||
//
|
||||
// For now only IP protocol addresses are supported.
|
||||
// This will need to be updated when other protocol
|
||||
// types are supported by PxeBc, Snp and UNDI.
|
||||
//
|
||||
if (ArpPacketPtr->ArpHeader.ProtType != HTONS (ETHER_TYPE_IP)) {
|
||||
return ;
|
||||
}
|
||||
//
|
||||
// For now only SNP hardware address sizes are supported.
|
||||
//
|
||||
if (ArpPacketPtr->ArpHeader.HwAddLen != SnpMode->HwAddressSize) {
|
||||
return ;
|
||||
}
|
||||
//
|
||||
// For now only PxeBc protocol address sizes are supported.
|
||||
//
|
||||
if (ArpPacketPtr->ArpHeader.ProtAddLen != Private->IpLength) {
|
||||
return ;
|
||||
}
|
||||
//
|
||||
// Ignore out of range opcodes
|
||||
//
|
||||
switch (ArpPacketPtr->ArpHeader.OpCode) {
|
||||
case HTONS (ARP_REPLY):
|
||||
case HTONS (ARP_REQUEST):
|
||||
break;
|
||||
|
||||
default:
|
||||
return ;
|
||||
}
|
||||
//
|
||||
// update entry in our ARP cache if we have it
|
||||
//
|
||||
SrcHwAddr = (UINT8 *) &ArpPacketPtr->SrcHardwareAddr;
|
||||
SrcPrAddr = SrcHwAddr + SnpMode->HwAddressSize;
|
||||
|
||||
for (Index = 0; Index < PxeBcMode->ArpCacheEntries; ++Index) {
|
||||
if (CompareMem (
|
||||
&PxeBcMode->ArpCache[Index].IpAddr,
|
||||
SrcPrAddr,
|
||||
Private->IpLength
|
||||
)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CopyMem (
|
||||
&PxeBcMode->ArpCache[Index].MacAddr,
|
||||
SrcHwAddr,
|
||||
SnpMode->HwAddressSize
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
//
|
||||
// Done if ARP packet was not for us.
|
||||
//
|
||||
DstHwAddr = SrcPrAddr + Private->IpLength;
|
||||
DstPrAddr = DstHwAddr + SnpMode->HwAddressSize;
|
||||
|
||||
if (CompareMem (DstPrAddr, &PxeBcMode->StationIp, Private->IpLength)) {
|
||||
return ;
|
||||
//
|
||||
// not for us
|
||||
//
|
||||
}
|
||||
//
|
||||
// for us - if we did not update entry, add it
|
||||
//
|
||||
if (Index == PxeBcMode->ArpCacheEntries) {
|
||||
//
|
||||
// if we have a full table, get rid of oldest
|
||||
//
|
||||
if (Index == PXE_ARP_CACHE_SIZE) {
|
||||
Index = Private->OldestArpEntry;
|
||||
|
||||
if (++Private->OldestArpEntry == PXE_ARP_CACHE_SIZE) {
|
||||
Private->OldestArpEntry = 0;
|
||||
}
|
||||
} else {
|
||||
++PxeBcMode->ArpCacheEntries;
|
||||
}
|
||||
|
||||
CopyMem (
|
||||
&PxeBcMode->ArpCache[Index].MacAddr,
|
||||
SrcHwAddr,
|
||||
SnpMode->HwAddressSize
|
||||
);
|
||||
|
||||
CopyMem (
|
||||
&PxeBcMode->ArpCache[Index].IpAddr,
|
||||
SrcPrAddr,
|
||||
Private->IpLength
|
||||
);
|
||||
}
|
||||
//
|
||||
// if this is not a request or we don't yet have an IP, finished
|
||||
//
|
||||
if (ArpPacketPtr->ArpHeader.OpCode != HTONS (ARP_REQUEST) || !Private->GoodStationIp) {
|
||||
return ;
|
||||
}
|
||||
//
|
||||
// Assemble ARP reply.
|
||||
//
|
||||
//
|
||||
// Create media header. [ dest mac | src mac | prot ]
|
||||
//
|
||||
CopyMem (
|
||||
&ArpReplyPacket.MediaHeader[0],
|
||||
SrcHwAddr,
|
||||
SnpMode->HwAddressSize
|
||||
);
|
||||
|
||||
CopyMem (
|
||||
&ArpReplyPacket.MediaHeader[SnpMode->HwAddressSize],
|
||||
&SnpMode->CurrentAddress,
|
||||
SnpMode->HwAddressSize
|
||||
);
|
||||
|
||||
CopyMem (
|
||||
&ArpReplyPacket.MediaHeader[2 * SnpMode->HwAddressSize],
|
||||
&((UINT8 *) MediaHeader)[2 * SnpMode->HwAddressSize],
|
||||
sizeof (UINT16)
|
||||
);
|
||||
|
||||
//
|
||||
// ARP reply header is almost filled in,
|
||||
// just insert the correct opcode.
|
||||
//
|
||||
ArpReplyPacket.ArpHeader.OpCode = HTONS (ARP_REPLY);
|
||||
|
||||
//
|
||||
// Now fill in ARP data. [ src mac | src prot | dest mac | dest prot ]
|
||||
//
|
||||
TmpPtr = ArpReplyPacket.ArpData;
|
||||
CopyMem (TmpPtr, &SnpMode->CurrentAddress, SnpMode->HwAddressSize);
|
||||
|
||||
TmpPtr += SnpMode->HwAddressSize;
|
||||
CopyMem (TmpPtr, &PxeBcMode->StationIp, Private->IpLength);
|
||||
|
||||
TmpPtr += Private->IpLength;
|
||||
CopyMem (TmpPtr, SrcHwAddr, SnpMode->HwAddressSize);
|
||||
|
||||
TmpPtr += SnpMode->HwAddressSize;
|
||||
CopyMem (TmpPtr, SrcPrAddr, Private->IpLength);
|
||||
|
||||
//
|
||||
// Now send out the ARP reply.
|
||||
//
|
||||
CopyMem (&TmpMacAddr, SrcHwAddr, sizeof (EFI_MAC_ADDRESS));
|
||||
|
||||
SendPacket (
|
||||
Private,
|
||||
&ArpReplyPacket.MediaHeader,
|
||||
&ArpReplyPacket.ArpHeader,
|
||||
sizeof (ARP_HEADER) + 2 * (Private->IpLength + SnpMode->HwAddressSize),
|
||||
&TmpMacAddr,
|
||||
PXE_PROTOCOL_ETHERNET_ARP,
|
||||
EFI_PXE_BASE_CODE_FUNCTION_ARP
|
||||
);
|
||||
|
||||
//
|
||||
// Give time (100 microseconds) for ARP reply to get onto wire.
|
||||
//
|
||||
gBS->Stall (1000);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
/**
|
||||
|
||||
@return TRUE := If IP address was found and MAC address was stored
|
||||
@return FALSE := If IP address was not found
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
GetHwAddr (
|
||||
IN PXE_BASECODE_DEVICE *Private,
|
||||
IN EFI_IP_ADDRESS *ProtocolAddrPtr,
|
||||
OUT EFI_MAC_ADDRESS *HardwareAddrPtr
|
||||
)
|
||||
{
|
||||
EFI_PXE_BASE_CODE_MODE *PxeBcMode;
|
||||
UINTN HardwareAddrLength;
|
||||
UINTN Index;
|
||||
|
||||
PxeBcMode = Private->EfiBc.Mode;
|
||||
HardwareAddrLength = Private->SimpleNetwork->Mode->HwAddressSize;
|
||||
|
||||
for (Index = 0; Index < PxeBcMode->ArpCacheEntries; ++Index) {
|
||||
if (!CompareMem (
|
||||
ProtocolAddrPtr,
|
||||
&PxeBcMode->ArpCache[Index].IpAddr,
|
||||
Private->IpLength
|
||||
)) {
|
||||
CopyMem (
|
||||
HardwareAddrPtr,
|
||||
&PxeBcMode->ArpCache[Index].MacAddr,
|
||||
HardwareAddrLength
|
||||
);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
/**
|
||||
|
||||
@return EFI_SUCCESS := ARP request sent
|
||||
@return other := ARP request could not be sent
|
||||
|
||||
**/
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
SendRequest (
|
||||
IN PXE_BASECODE_DEVICE *Private,
|
||||
IN EFI_IP_ADDRESS *ProtocolAddrPtr,
|
||||
IN EFI_MAC_ADDRESS *HardwareAddrPtr
|
||||
)
|
||||
{
|
||||
EFI_PXE_BASE_CODE_MODE *PxeBcMode;
|
||||
EFI_SIMPLE_NETWORK_MODE *SnpMode;
|
||||
ARP_PACKET *ArpPacket;
|
||||
EFI_STATUS Status;
|
||||
UINTN HardwareAddrLength;
|
||||
UINT8 *SrcProtocolAddrPtr;
|
||||
UINT8 *DestHardwareAddrptr;
|
||||
UINT8 *DestProtocolAddrPtr;
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
PxeBcMode = Private->EfiBc.Mode;
|
||||
SnpMode = Private->SimpleNetwork->Mode;
|
||||
HardwareAddrLength = SnpMode->HwAddressSize;
|
||||
|
||||
//
|
||||
// Allocate ARP buffer
|
||||
//
|
||||
if (Private->ArpBuffer == NULL) {
|
||||
Status = gBS->AllocatePool (
|
||||
EfiBootServicesData,
|
||||
SnpMode->MediaHeaderSize + sizeof (ARP_PACKET),
|
||||
&Private->ArpBuffer
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
ArpPacket = (VOID *) (Private->ArpBuffer + SnpMode->MediaHeaderSize);
|
||||
|
||||
//
|
||||
// for now, only handle one kind of hw and pr address
|
||||
//
|
||||
ArpPacket->ArpHeader = ArpHeader;
|
||||
ArpPacket->ArpHeader.HwAddLen = (UINT8) HardwareAddrLength;
|
||||
ArpPacket->ArpHeader.ProtAddLen = (UINT8) Private->IpLength;
|
||||
|
||||
//
|
||||
// rest more generic
|
||||
//
|
||||
SrcProtocolAddrPtr = (UINT8 *) (&ArpPacket->SrcHardwareAddr) + HardwareAddrLength;
|
||||
DestHardwareAddrptr = SrcProtocolAddrPtr + Private->IpLength;
|
||||
DestProtocolAddrPtr = DestHardwareAddrptr + HardwareAddrLength;
|
||||
|
||||
CopyMem (DestProtocolAddrPtr, ProtocolAddrPtr, Private->IpLength);
|
||||
CopyMem (DestHardwareAddrptr, HardwareAddrPtr, HardwareAddrLength);
|
||||
CopyMem (SrcProtocolAddrPtr, &PxeBcMode->StationIp, Private->IpLength);
|
||||
CopyMem (
|
||||
&ArpPacket->SrcHardwareAddr,
|
||||
&SnpMode->CurrentAddress,
|
||||
HardwareAddrLength
|
||||
);
|
||||
|
||||
return SendPacket (
|
||||
Private,
|
||||
Private->ArpBuffer,
|
||||
ArpPacket,
|
||||
sizeof (ARP_HEADER) + ((Private->IpLength + HardwareAddrLength) << 1),
|
||||
&SnpMode->BroadcastAddress,
|
||||
PXE_PROTOCOL_ETHERNET_ARP,
|
||||
EFI_PXE_BASE_CODE_FUNCTION_ARP
|
||||
);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
//
|
||||
// check for address - if not there, send ARP request, wait and check again
|
||||
// not how it would be done in a full system
|
||||
//
|
||||
#define ARP_REQUEST_TIMEOUT_MS 500 // try for half a second
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// BC Arp Routine
|
||||
//
|
||||
|
||||
/**
|
||||
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
BcArp (
|
||||
IN EFI_PXE_BASE_CODE_PROTOCOL * This,
|
||||
IN EFI_IP_ADDRESS * ProtocolAddrPtr,
|
||||
OUT EFI_MAC_ADDRESS * HardwareAddrPtr OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_MAC_ADDRESS Mac;
|
||||
EFI_STATUS StatCode;
|
||||
PXE_BASECODE_DEVICE *Private;
|
||||
|
||||
//
|
||||
// Lock the instance data and make sure started
|
||||
//
|
||||
StatCode = EFI_SUCCESS;
|
||||
|
||||
if (This == NULL) {
|
||||
DEBUG ((DEBUG_ERROR, "BC *This pointer == NULL"));
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Private = CR (This, PXE_BASECODE_DEVICE, EfiBc, PXE_BASECODE_DEVICE_SIGNATURE);
|
||||
|
||||
if (Private == NULL) {
|
||||
DEBUG ((DEBUG_ERROR, "PXE_BASECODE_DEVICE poiner == NULL"));
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
EfiAcquireLock (&Private->Lock);
|
||||
|
||||
if (This->Mode == NULL || !This->Mode->Started) {
|
||||
DEBUG ((DEBUG_ERROR, "BC was not started."));
|
||||
EfiReleaseLock (&Private->Lock);
|
||||
return EFI_NOT_STARTED;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "\nBcArp()"));
|
||||
|
||||
//
|
||||
// Issue BC command
|
||||
//
|
||||
if (ProtocolAddrPtr == NULL) {
|
||||
DEBUG (
|
||||
(DEBUG_INFO,
|
||||
"\nBcArp() Exit #1 %Xh (%r)",
|
||||
EFI_INVALID_PARAMETER,
|
||||
EFI_INVALID_PARAMETER)
|
||||
);
|
||||
|
||||
EfiReleaseLock (&Private->Lock);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (HardwareAddrPtr == NULL) {
|
||||
HardwareAddrPtr = &Mac;
|
||||
}
|
||||
|
||||
ZeroMem (HardwareAddrPtr, Private->SimpleNetwork->Mode->HwAddressSize);
|
||||
|
||||
if (GetHwAddr (Private, ProtocolAddrPtr, HardwareAddrPtr)) {
|
||||
DEBUG (
|
||||
(DEBUG_INFO,
|
||||
"\nBcArp() Exit #2 %Xh (%r)",
|
||||
EFI_SUCCESS,
|
||||
EFI_SUCCESS)
|
||||
);
|
||||
|
||||
EfiReleaseLock (&Private->Lock);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
StatCode = DoArp (Private, ProtocolAddrPtr, HardwareAddrPtr);
|
||||
|
||||
DEBUG ((DEBUG_INFO, "\nBcArp() Exit #3 %Xh (%r)", StatCode, StatCode));
|
||||
|
||||
EfiReleaseLock (&Private->Lock);
|
||||
return StatCode;
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
/**
|
||||
|
||||
@return EFI_SUCCESS := MAC address found
|
||||
@return other := MAC address could not be found
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
DoArp (
|
||||
IN PXE_BASECODE_DEVICE *Private,
|
||||
IN EFI_IP_ADDRESS *ProtocolAddrPtr,
|
||||
OUT EFI_MAC_ADDRESS *HardwareAddrPtr
|
||||
)
|
||||
{
|
||||
EFI_STATUS StatCode;
|
||||
EFI_EVENT TimeoutEvent;
|
||||
UINTN HeaderSize;
|
||||
UINTN BufferSize;
|
||||
UINT16 Protocol;
|
||||
|
||||
DEBUG ((DEBUG_INFO, "\nDoArp()"));
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
StatCode = SendRequest (Private, ProtocolAddrPtr, HardwareAddrPtr);
|
||||
|
||||
if (EFI_ERROR (StatCode)) {
|
||||
DEBUG ((DEBUG_INFO, "\nDoArp() Exit #1 %Xh (%r)", StatCode, StatCode));
|
||||
return StatCode;
|
||||
}
|
||||
//
|
||||
//
|
||||
//
|
||||
StatCode = gBS->CreateEvent (
|
||||
EVT_TIMER,
|
||||
TPL_CALLBACK,
|
||||
NULL,
|
||||
NULL,
|
||||
&TimeoutEvent
|
||||
);
|
||||
|
||||
if (EFI_ERROR (StatCode)) {
|
||||
return StatCode;
|
||||
}
|
||||
|
||||
StatCode = gBS->SetTimer (
|
||||
TimeoutEvent,
|
||||
TimerRelative,
|
||||
ARP_REQUEST_TIMEOUT_MS * 10000
|
||||
);
|
||||
|
||||
if (EFI_ERROR (StatCode)) {
|
||||
gBS->CloseEvent (TimeoutEvent);
|
||||
return StatCode;
|
||||
}
|
||||
//
|
||||
//
|
||||
//
|
||||
for (;;) {
|
||||
StatCode = WaitForReceive (
|
||||
Private,
|
||||
EFI_PXE_BASE_CODE_FUNCTION_ARP,
|
||||
TimeoutEvent,
|
||||
&HeaderSize,
|
||||
&BufferSize,
|
||||
&Protocol
|
||||
);
|
||||
|
||||
if (EFI_ERROR (StatCode)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (Protocol != PXE_PROTOCOL_ETHERNET_ARP) {
|
||||
continue;
|
||||
}
|
||||
|
||||
HandleArpReceive (
|
||||
Private,
|
||||
(ARP_PACKET *) (Private->ReceiveBufferPtr + HeaderSize),
|
||||
Private->ReceiveBufferPtr
|
||||
);
|
||||
|
||||
if (GetHwAddr (Private, ProtocolAddrPtr, HardwareAddrPtr)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG (
|
||||
(DEBUG_INFO,
|
||||
"\nDoArp() Exit #2 %Xh, (%r)",
|
||||
StatCode,
|
||||
StatCode)
|
||||
);
|
||||
|
||||
gBS->CloseEvent (TimeoutEvent);
|
||||
|
||||
return StatCode;
|
||||
}
|
||||
|
||||
/* eof - pxe_bc_arp.c */
|
3284
MdeModulePkg/Universal/Network/PxeBcDxe/Pxe_bc_dhcp.c
Normal file
3284
MdeModulePkg/Universal/Network/PxeBcDxe/Pxe_bc_dhcp.c
Normal file
File diff suppressed because it is too large
Load Diff
421
MdeModulePkg/Universal/Network/PxeBcDxe/Pxe_bc_igmp.c
Normal file
421
MdeModulePkg/Universal/Network/PxeBcDxe/Pxe_bc_igmp.c
Normal file
@@ -0,0 +1,421 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2004, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#define RAND_MAX 0x10000
|
||||
|
||||
#include "Bc.h"
|
||||
|
||||
//
|
||||
// Definitions for internet group management protocol version 2 message
|
||||
// structure Per RFC 2236, November 1997
|
||||
//
|
||||
STATIC UINT8 RouterAlertOption[4] = { 0x80 | 20, 4, 0, 0 };
|
||||
STATIC IPV4_ADDR AllRoutersGroup = { { 224, 0, 0, 2 } };
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
STATIC
|
||||
VOID
|
||||
ClearGroupTimer (
|
||||
PXE_BASECODE_DEVICE *Private,
|
||||
UINTN TimerId
|
||||
)
|
||||
{
|
||||
if (Private == NULL) {
|
||||
return ;
|
||||
}
|
||||
|
||||
if (TimerId >= Private->MCastGroupCount) {
|
||||
return ;
|
||||
}
|
||||
|
||||
if (Private->IgmpGroupEvent[TimerId] == NULL) {
|
||||
return ;
|
||||
}
|
||||
|
||||
gBS->CloseEvent (Private->IgmpGroupEvent[TimerId]);
|
||||
Private->IgmpGroupEvent[TimerId] = NULL;
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
/**
|
||||
|
||||
|
||||
**/
|
||||
STATIC
|
||||
VOID
|
||||
SetGroupTimer (
|
||||
PXE_BASECODE_DEVICE *Private,
|
||||
UINTN TimerId,
|
||||
UINTN MaxRespTime
|
||||
)
|
||||
{
|
||||
EFI_STATUS EfiStatus;
|
||||
|
||||
if (Private == NULL) {
|
||||
return ;
|
||||
}
|
||||
|
||||
if (TimerId >= Private->MCastGroupCount) {
|
||||
return ;
|
||||
}
|
||||
|
||||
if (Private->IgmpGroupEvent[TimerId] != NULL) {
|
||||
gBS->CloseEvent (Private->IgmpGroupEvent[TimerId]);
|
||||
}
|
||||
|
||||
EfiStatus = gBS->CreateEvent (
|
||||
EVT_TIMER,
|
||||
TPL_CALLBACK,
|
||||
NULL,
|
||||
NULL,
|
||||
&Private->IgmpGroupEvent[TimerId]
|
||||
);
|
||||
|
||||
if (EFI_ERROR (EfiStatus)) {
|
||||
Private->IgmpGroupEvent[TimerId] = NULL;
|
||||
return ;
|
||||
}
|
||||
|
||||
EfiStatus = gBS->SetTimer (
|
||||
Private->IgmpGroupEvent[TimerId],
|
||||
TimerRelative,
|
||||
MaxRespTime * 1000000 + Random (Private) % RAND_MAX
|
||||
);
|
||||
|
||||
if (EFI_ERROR (EfiStatus)) {
|
||||
gBS->CloseEvent (Private->IgmpGroupEvent[TimerId]);
|
||||
Private->IgmpGroupEvent[TimerId] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
/**
|
||||
|
||||
|
||||
**/
|
||||
STATIC
|
||||
VOID
|
||||
SendIgmpMessage (
|
||||
PXE_BASECODE_DEVICE *Private,
|
||||
UINT8 Type,
|
||||
INTN GroupId
|
||||
)
|
||||
{
|
||||
Private->IgmpMessage.Type = Type;
|
||||
Private->IgmpMessage.MaxRespTime = 0;
|
||||
Private->IgmpMessage.Checksum = 0;
|
||||
Private->IgmpMessage.GroupAddress = Private->MCastGroup[GroupId];
|
||||
Private->IgmpMessage.Checksum = IpChecksum (
|
||||
(UINT16 *) &Private->IgmpMessage,
|
||||
sizeof Private->IgmpMessage
|
||||
);
|
||||
|
||||
Ipv4SendWOp (
|
||||
Private,
|
||||
0,
|
||||
(UINT8 *) &Private->IgmpMessage,
|
||||
sizeof Private->IgmpMessage,
|
||||
PROT_IGMP,
|
||||
RouterAlertOption,
|
||||
sizeof RouterAlertOption,
|
||||
((Type == IGMP_TYPE_LEAVE_GROUP) ? AllRoutersGroup.L : Private->IgmpMessage.GroupAddress),
|
||||
EFI_PXE_BASE_CODE_FUNCTION_IGMP
|
||||
);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
/**
|
||||
|
||||
|
||||
**/
|
||||
STATIC
|
||||
VOID
|
||||
ReportIgmp (
|
||||
PXE_BASECODE_DEVICE *Private,
|
||||
INTN GroupId
|
||||
)
|
||||
{
|
||||
//
|
||||
// if version 1 querier, send v1 report
|
||||
//
|
||||
UINT8 Type;
|
||||
|
||||
if (Private->Igmpv1TimeoutEvent != NULL) {
|
||||
if (!EFI_ERROR (gBS->CheckEvent (Private->Igmpv1TimeoutEvent))) {
|
||||
gBS->CloseEvent (Private->Igmpv1TimeoutEvent);
|
||||
Private->Igmpv1TimeoutEvent = NULL;
|
||||
Private->UseIgmpv1Reporting = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
Type = (UINT8) (Private->UseIgmpv1Reporting ? IGMP_TYPE_V1REPORT : IGMP_TYPE_REPORT);
|
||||
|
||||
SendIgmpMessage (Private, Type, GroupId);
|
||||
ClearGroupTimer (Private, GroupId);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
/**
|
||||
|
||||
|
||||
**/
|
||||
VOID
|
||||
IgmpCheckTimers (
|
||||
PXE_BASECODE_DEVICE *Private
|
||||
)
|
||||
{
|
||||
UINTN GroupId;
|
||||
|
||||
if (Private == NULL) {
|
||||
return ;
|
||||
}
|
||||
|
||||
for (GroupId = 0; GroupId < Private->MCastGroupCount; ++GroupId) {
|
||||
if (Private->IgmpGroupEvent[GroupId] == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (gBS->CheckEvent (Private->IgmpGroupEvent[GroupId]))) {
|
||||
//
|
||||
// send a report
|
||||
//
|
||||
ReportIgmp (Private, GroupId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
/**
|
||||
|
||||
@return 0 := Group not found
|
||||
@return other := Group ID#
|
||||
|
||||
**/
|
||||
STATIC
|
||||
INTN
|
||||
FindMulticastGroup (
|
||||
PXE_BASECODE_DEVICE *Private,
|
||||
UINT32 GroupAddress
|
||||
)
|
||||
{
|
||||
UINTN GroupId;
|
||||
|
||||
for (GroupId = 0; GroupId < Private->MCastGroupCount; ++GroupId) {
|
||||
if (Private->MCastGroup[GroupId] == GroupAddress) {
|
||||
return GroupId + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
/**
|
||||
|
||||
|
||||
**/
|
||||
VOID
|
||||
IgmpJoinGroup (
|
||||
PXE_BASECODE_DEVICE *Private,
|
||||
EFI_IP_ADDRESS *GroupPtr
|
||||
)
|
||||
{
|
||||
UINT32 Grp;
|
||||
|
||||
Grp = *(UINT32 *) GroupPtr;
|
||||
|
||||
//
|
||||
// see if we already have it or if we can't take anymore
|
||||
//
|
||||
if (FindMulticastGroup (Private, Grp) || Private->MCastGroupCount == MAX_MCAST_GROUPS) {
|
||||
return ;
|
||||
}
|
||||
//
|
||||
// add the group
|
||||
//
|
||||
Private->MCastGroup[Private->MCastGroupCount] = Grp;
|
||||
|
||||
ReportIgmp (Private, Private->MCastGroupCount);
|
||||
//
|
||||
// send a report
|
||||
// so it will get sent again per RFC 2236
|
||||
//
|
||||
SetGroupTimer (
|
||||
Private,
|
||||
Private->MCastGroupCount++,
|
||||
UNSOLICITED_REPORT_INTERVAL * 10
|
||||
);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
/**
|
||||
|
||||
|
||||
**/
|
||||
VOID
|
||||
IgmpLeaveGroup (
|
||||
PXE_BASECODE_DEVICE *Private,
|
||||
EFI_IP_ADDRESS *GroupPtr
|
||||
)
|
||||
{
|
||||
UINT32 Grp;
|
||||
UINTN GroupId;
|
||||
|
||||
Grp = *(UINT32 *) GroupPtr;
|
||||
|
||||
//
|
||||
// if not in group, ignore
|
||||
//
|
||||
GroupId = FindMulticastGroup (Private, Grp);
|
||||
|
||||
if (GroupId == 0) {
|
||||
return ;
|
||||
}
|
||||
//
|
||||
// if not v1 querrier, send leave group IGMP message
|
||||
//
|
||||
if (Private->Igmpv1TimeoutEvent != NULL) {
|
||||
if (!EFI_ERROR (gBS->CheckEvent (Private->Igmpv1TimeoutEvent))) {
|
||||
gBS->CloseEvent (Private->Igmpv1TimeoutEvent);
|
||||
Private->Igmpv1TimeoutEvent = NULL;
|
||||
Private->UseIgmpv1Reporting = TRUE;
|
||||
} else {
|
||||
SendIgmpMessage (Private, IGMP_TYPE_LEAVE_GROUP, GroupId - 1);
|
||||
}
|
||||
}
|
||||
|
||||
while (GroupId < Private->MCastGroupCount) {
|
||||
Private->MCastGroup[GroupId - 1] = Private->MCastGroup[GroupId];
|
||||
Private->IgmpGroupEvent[GroupId - 1] = Private->IgmpGroupEvent[GroupId];
|
||||
++GroupId;
|
||||
}
|
||||
|
||||
--Private->MCastGroupCount;
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
/**
|
||||
|
||||
|
||||
**/
|
||||
VOID
|
||||
HandleIgmp (
|
||||
PXE_BASECODE_DEVICE *Private,
|
||||
IGMPV2_MESSAGE *IgmpMessagePtr,
|
||||
UINTN IgmpLength
|
||||
)
|
||||
{
|
||||
EFI_STATUS EfiStatus;
|
||||
UINTN GroupId;
|
||||
INTN MaxRespTime;
|
||||
|
||||
if (Private == NULL) {
|
||||
return ;
|
||||
}
|
||||
|
||||
if (Private->MCastGroupCount == 0) {
|
||||
//
|
||||
// if we don't belong to any multicast groups, ignore
|
||||
//
|
||||
return ;
|
||||
}
|
||||
//
|
||||
// verify checksum
|
||||
//
|
||||
if (IpChecksum ((UINT16 *) IgmpMessagePtr, IgmpLength)) {
|
||||
//
|
||||
// bad checksum - ignore packet
|
||||
//
|
||||
return ;
|
||||
}
|
||||
|
||||
switch (IgmpMessagePtr->Type) {
|
||||
case IGMP_TYPE_QUERY:
|
||||
//
|
||||
// if a version 1 querier, note the fact and set max resp time
|
||||
//
|
||||
MaxRespTime = IgmpMessagePtr->MaxRespTime;
|
||||
|
||||
if (MaxRespTime == 0) {
|
||||
Private->UseIgmpv1Reporting = TRUE;
|
||||
|
||||
if (Private->Igmpv1TimeoutEvent != NULL) {
|
||||
gBS->CloseEvent (Private->Igmpv1TimeoutEvent);
|
||||
}
|
||||
|
||||
EfiStatus = gBS->CreateEvent (
|
||||
EVT_TIMER,
|
||||
TPL_CALLBACK,
|
||||
NULL,
|
||||
NULL,
|
||||
&Private->Igmpv1TimeoutEvent
|
||||
);
|
||||
|
||||
if (EFI_ERROR (EfiStatus)) {
|
||||
Private->Igmpv1TimeoutEvent = NULL;
|
||||
} else {
|
||||
EfiStatus = gBS->SetTimer (
|
||||
Private->Igmpv1TimeoutEvent,
|
||||
TimerRelative,
|
||||
(UINT64) V1ROUTER_PRESENT_TIMEOUT * 10000000
|
||||
);
|
||||
}
|
||||
|
||||
MaxRespTime = IGMP_DEFAULT_MAX_RESPONSE_TIME * 10;
|
||||
}
|
||||
//
|
||||
// if a general query (!GroupAddress), set all our group timers
|
||||
//
|
||||
if (!IgmpMessagePtr->GroupAddress) {
|
||||
for (GroupId = 0; GroupId < Private->MCastGroupCount; ++GroupId) {
|
||||
SetGroupTimer (Private, GroupId, MaxRespTime);
|
||||
}
|
||||
} else {
|
||||
//
|
||||
// specific query - set only specific group
|
||||
//
|
||||
GroupId = FindMulticastGroup (Private, IgmpMessagePtr->GroupAddress);
|
||||
|
||||
if (GroupId != 0) {
|
||||
SetGroupTimer (Private, GroupId - 1, MaxRespTime);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
//
|
||||
// if we have a timer running for this group, clear it
|
||||
//
|
||||
case IGMP_TYPE_V1REPORT:
|
||||
case IGMP_TYPE_REPORT:
|
||||
GroupId = FindMulticastGroup (Private, IgmpMessagePtr->GroupAddress);
|
||||
|
||||
if (GroupId != 0) {
|
||||
ClearGroupTimer (Private, GroupId - 1);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* EOF - pxe_bc_igmp.c */
|
846
MdeModulePkg/Universal/Network/PxeBcDxe/Pxe_bc_ip.c
Normal file
846
MdeModulePkg/Universal/Network/PxeBcDxe/Pxe_bc_ip.c
Normal file
@@ -0,0 +1,846 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2004, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
pxe_bc_ip.c
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#include "Bc.h"
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
/**
|
||||
Check if two IP addresses are on the same subnet.
|
||||
|
||||
@param IpLength Length of IP address in bytes.
|
||||
@param Ip1 IP address to check.
|
||||
@param Ip2 IP address to check.
|
||||
@param SubnetMask Subnet mask to check with.
|
||||
|
||||
@retval TRUE IP addresses are on the same subnet.
|
||||
@retval FALSE IP addresses are on different subnets.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
OnSameSubnet (
|
||||
IN UINTN IpLength,
|
||||
IN EFI_IP_ADDRESS *Ip1,
|
||||
IN EFI_IP_ADDRESS *Ip2,
|
||||
IN EFI_IP_ADDRESS *SubnetMask
|
||||
)
|
||||
{
|
||||
if (IpLength == 0 || Ip1 == NULL || Ip2 == NULL || SubnetMask == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
while (IpLength-- != 0) {
|
||||
if ((Ip1->v6.Addr[IpLength] ^ Ip2->v6.Addr[IpLength]) & SubnetMask->v6.Addr[IpLength]) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
/**
|
||||
Add router to router table.
|
||||
|
||||
@param Private Pointer PxeBc instance data.
|
||||
@param RouterIpPtr Pointer to router IP address.
|
||||
|
||||
@return Nothing
|
||||
|
||||
**/
|
||||
VOID
|
||||
IpAddRouter (
|
||||
IN PXE_BASECODE_DEVICE *Private,
|
||||
IN EFI_IP_ADDRESS *RouterIpPtr
|
||||
)
|
||||
{
|
||||
EFI_PXE_BASE_CODE_MODE *PxeBcMode;
|
||||
UINTN Index;
|
||||
|
||||
if (Private == NULL || RouterIpPtr == NULL) {
|
||||
return ;
|
||||
}
|
||||
|
||||
PxeBcMode = Private->EfiBc.Mode;
|
||||
|
||||
//
|
||||
// if we are filled up or this is not on the same subnet, forget it
|
||||
//
|
||||
if ((PxeBcMode->RouteTableEntries == PXE_ROUTER_TABLE_SIZE) ||
|
||||
!OnSameSubnet(Private->IpLength, &PxeBcMode->StationIp, RouterIpPtr, &PxeBcMode->SubnetMask)) {
|
||||
return ;
|
||||
}
|
||||
//
|
||||
// make sure we don't already have it
|
||||
//
|
||||
for (Index = 0; Index < PxeBcMode->RouteTableEntries; ++Index) {
|
||||
if (!CompareMem (
|
||||
&PxeBcMode->RouteTable[Index].GwAddr,
|
||||
RouterIpPtr,
|
||||
Private->IpLength
|
||||
)) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
//
|
||||
// keep it
|
||||
//
|
||||
ZeroMem (
|
||||
&PxeBcMode->RouteTable[PxeBcMode->RouteTableEntries],
|
||||
sizeof (EFI_PXE_BASE_CODE_ROUTE_ENTRY)
|
||||
);
|
||||
|
||||
CopyMem (
|
||||
&PxeBcMode->RouteTable[PxeBcMode->RouteTableEntries++].GwAddr,
|
||||
RouterIpPtr,
|
||||
Private->IpLength
|
||||
);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
//
|
||||
// return router ip to use for DestIp (0 if none)
|
||||
//
|
||||
STATIC
|
||||
EFI_IP_ADDRESS *
|
||||
GetRouterIp (
|
||||
PXE_BASECODE_DEVICE *Private,
|
||||
EFI_IP_ADDRESS *DestIpPtr
|
||||
)
|
||||
{
|
||||
EFI_PXE_BASE_CODE_MODE *PxeBcMode;
|
||||
UINTN Index;
|
||||
|
||||
if (Private == NULL || DestIpPtr == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PxeBcMode = Private->EfiBc.Mode;
|
||||
|
||||
for (Index = 0; Index < PxeBcMode->RouteTableEntries; ++Index) {
|
||||
if (OnSameSubnet (
|
||||
Private->IpLength,
|
||||
&PxeBcMode->RouteTable[Index].IpAddr,
|
||||
DestIpPtr,
|
||||
&PxeBcMode->RouteTable[Index].SubnetMask
|
||||
)) {
|
||||
return &PxeBcMode->RouteTable[Index].GwAddr;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
//
|
||||
// routine to send ipv4 packet
|
||||
// ipv4 header of length HdrLth in TransmitBufferPtr
|
||||
// routine fills in ipv4hdr Ver_Hdl, TotalLength, and Checksum, moves in Data
|
||||
// and gets dest MAC address
|
||||
//
|
||||
#define IP_TX_BUFFER ((IPV4_BUFFER *) Private->TransmitBufferPtr)
|
||||
#define IP_TX_HEADER IP_TX_BUFFER->IpHeader
|
||||
|
||||
EFI_STATUS
|
||||
Ipv4Xmt (
|
||||
PXE_BASECODE_DEVICE *Private,
|
||||
UINT32 GatewayIp,
|
||||
UINTN IpHeaderLength,
|
||||
UINTN TotalHeaderLength,
|
||||
VOID *Data,
|
||||
UINTN DataLength,
|
||||
EFI_PXE_BASE_CODE_FUNCTION Function
|
||||
)
|
||||
{
|
||||
EFI_MAC_ADDRESS DestMac;
|
||||
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
|
||||
EFI_PXE_BASE_CODE_MODE *PxeBcMode;
|
||||
EFI_STATUS StatCode;
|
||||
UINTN PacketLength;
|
||||
|
||||
Snp = Private->SimpleNetwork;
|
||||
PxeBcMode = Private->EfiBc.Mode;
|
||||
StatCode = EFI_SUCCESS;
|
||||
PacketLength = TotalHeaderLength + DataLength;
|
||||
|
||||
//
|
||||
// get dest MAC address
|
||||
// multicast - convert to hw equiv
|
||||
// unicast on same net, use arp
|
||||
// on different net, arp for router
|
||||
//
|
||||
if (IP_TX_HEADER.DestAddr.L == BROADCAST_IPv4) {
|
||||
CopyMem (&DestMac, &Snp->Mode->BroadcastAddress, sizeof (DestMac));
|
||||
} else if (IS_MULTICAST (&IP_TX_HEADER.DestAddr)) {
|
||||
StatCode = (*Snp->MCastIpToMac) (Snp, PxeBcMode->UsingIpv6, (EFI_IP_ADDRESS *) &IP_TX_HEADER.DestAddr, &DestMac);
|
||||
} else {
|
||||
UINT32 Ip;
|
||||
|
||||
if (OnSameSubnet (
|
||||
Private->IpLength,
|
||||
&PxeBcMode->StationIp,
|
||||
(EFI_IP_ADDRESS *) &IP_TX_HEADER.DestAddr,
|
||||
&PxeBcMode->SubnetMask
|
||||
)) {
|
||||
Ip = IP_TX_HEADER.DestAddr.L;
|
||||
} else if (GatewayIp != 0) {
|
||||
Ip = GatewayIp;
|
||||
} else {
|
||||
EFI_IP_ADDRESS *TmpIp;
|
||||
|
||||
TmpIp = GetRouterIp (Private, (EFI_IP_ADDRESS *) &IP_TX_HEADER.DestAddr);
|
||||
|
||||
if (TmpIp == NULL) {
|
||||
DEBUG (
|
||||
(DEBUG_WARN,
|
||||
"\nIpv4Xmit() Exit #1 %xh (%r)",
|
||||
EFI_NO_RESPONSE,
|
||||
EFI_NO_RESPONSE)
|
||||
);
|
||||
|
||||
return EFI_NO_RESPONSE;
|
||||
//
|
||||
// no router
|
||||
//
|
||||
}
|
||||
|
||||
Ip = TmpIp->Addr[0];
|
||||
}
|
||||
|
||||
if (!GetHwAddr (
|
||||
Private,
|
||||
(EFI_IP_ADDRESS *) &Ip,
|
||||
(EFI_MAC_ADDRESS *) &DestMac
|
||||
)) {
|
||||
if (!PxeBcMode->AutoArp) {
|
||||
DEBUG (
|
||||
(DEBUG_WARN,
|
||||
"\nIpv4Xmit() Exit #2 %xh (%r)",
|
||||
EFI_DEVICE_ERROR,
|
||||
EFI_DEVICE_ERROR)
|
||||
);
|
||||
|
||||
return EFI_DEVICE_ERROR;
|
||||
} else {
|
||||
StatCode = DoArp (
|
||||
Private,
|
||||
(EFI_IP_ADDRESS *) &Ip,
|
||||
(EFI_MAC_ADDRESS *) &DestMac
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (EFI_ERROR (StatCode)) {
|
||||
DEBUG ((DEBUG_WARN, "\nIpv4Xmit() Exit #3 %xh (%r)", StatCode, StatCode));
|
||||
return StatCode;
|
||||
}
|
||||
//
|
||||
// fill in packet info
|
||||
//
|
||||
SET_IPV4_VER_HDL (&IP_TX_HEADER, IpHeaderLength);
|
||||
IP_TX_HEADER.TotalLength = HTONS (PacketLength);
|
||||
IP_TX_HEADER.HeaderChecksum = IpChecksum ((UINT16 *) &IP_TX_HEADER, IpHeaderLength);
|
||||
CopyMem (((UINT8 *) &IP_TX_HEADER) + TotalHeaderLength, Data, DataLength);
|
||||
|
||||
//
|
||||
// send it
|
||||
//
|
||||
return SendPacket (
|
||||
Private,
|
||||
(UINT8 *) &IP_TX_HEADER - Snp->Mode->MediaHeaderSize,
|
||||
&IP_TX_HEADER,
|
||||
PacketLength,
|
||||
&DestMac,
|
||||
PXE_PROTOCOL_ETHERNET_IP,
|
||||
Function
|
||||
);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
//
|
||||
// send ipv4 packet with option
|
||||
//
|
||||
EFI_STATUS
|
||||
Ipv4SendWOp (
|
||||
PXE_BASECODE_DEVICE *Private,
|
||||
UINT32 GatewayIp,
|
||||
UINT8 *Msg,
|
||||
UINTN MessageLength,
|
||||
UINT8 Prot,
|
||||
UINT8 *Option,
|
||||
UINTN OptionLength,
|
||||
UINT32 DestIp,
|
||||
EFI_PXE_BASE_CODE_FUNCTION Function
|
||||
)
|
||||
{
|
||||
EFI_PXE_BASE_CODE_MODE *PxeBcMode;
|
||||
UINTN HdrLth;
|
||||
|
||||
PxeBcMode = Private->EfiBc.Mode;
|
||||
HdrLth = sizeof (IPV4_HEADER) + OptionLength;
|
||||
|
||||
ZeroMem ((VOID *) &IP_TX_HEADER, sizeof (IPV4_HEADER));
|
||||
IP_TX_HEADER.TimeToLive = PxeBcMode->TTL;
|
||||
IP_TX_HEADER.TypeOfService = PxeBcMode->ToS;
|
||||
IP_TX_HEADER.Protocol = Prot;
|
||||
IP_TX_HEADER.SrcAddr.L = *(UINT32 *) &PxeBcMode->StationIp;
|
||||
IP_TX_HEADER.DestAddr.L = DestIp;
|
||||
IP_TX_HEADER.Id = Random (Private);
|
||||
CopyMem (IP_TX_BUFFER->u.Data, Option, OptionLength);
|
||||
return Ipv4Xmt (
|
||||
Private,
|
||||
GatewayIp,
|
||||
HdrLth,
|
||||
HdrLth,
|
||||
Msg,
|
||||
MessageLength,
|
||||
Function
|
||||
);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
//
|
||||
// send MessageLength message at MessagePtr - higher level protocol header already in TransmitBufferPtr, length HdrSize
|
||||
//
|
||||
EFI_STATUS
|
||||
Ip4Send (
|
||||
PXE_BASECODE_DEVICE *Private, // pointer to instance data
|
||||
UINTN MayFrag, //
|
||||
UINT8 Prot, // protocol
|
||||
UINT32 SrcIp, // Source IP address
|
||||
UINT32 DestIp, // Destination IP address
|
||||
UINT32 GatewayIp, // used if not NULL and needed
|
||||
UINTN HdrSize, // protocol header byte length
|
||||
UINT8 *MessagePtr, // pointer to data
|
||||
UINTN MessageLength // data byte length
|
||||
)
|
||||
{
|
||||
EFI_STATUS StatCode;
|
||||
UINTN TotDataLength;
|
||||
|
||||
TotDataLength = HdrSize + MessageLength;
|
||||
|
||||
if (TotDataLength > MAX_IPV4_DATA_SIZE) {
|
||||
DEBUG (
|
||||
(DEBUG_WARN,
|
||||
"\nIp4Send() Exit #1 %xh (%r)",
|
||||
EFI_BAD_BUFFER_SIZE,
|
||||
EFI_BAD_BUFFER_SIZE)
|
||||
);
|
||||
|
||||
return EFI_BAD_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
ZeroMem ((VOID *) &IP_TX_HEADER, sizeof (IPV4_HEADER));
|
||||
IP_TX_HEADER.TimeToLive = DEFAULT_TTL;
|
||||
IP_TX_HEADER.Protocol = Prot;
|
||||
IP_TX_HEADER.SrcAddr.L = SrcIp;
|
||||
IP_TX_HEADER.DestAddr.L = DestIp;
|
||||
IP_TX_HEADER.Id = Random (Private);
|
||||
|
||||
if (!MayFrag) {
|
||||
*(UINT8 *) (&IP_TX_HEADER.FragmentFields) = IP_NO_FRAG >> 8;
|
||||
}
|
||||
//
|
||||
// check for need to fragment
|
||||
//
|
||||
if (TotDataLength > MAX_IPV4_FRAME_DATA_SIZE) {
|
||||
UINTN DataLengthSent;
|
||||
UINT16 FragmentOffset;
|
||||
|
||||
FragmentOffset = IP_MORE_FRAG;
|
||||
//
|
||||
// frag offset field
|
||||
//
|
||||
if (!MayFrag) {
|
||||
DEBUG (
|
||||
(DEBUG_WARN,
|
||||
"\nIp4Send() Exit #2 %xh (%r)",
|
||||
EFI_BAD_BUFFER_SIZE,
|
||||
EFI_BAD_BUFFER_SIZE)
|
||||
);
|
||||
|
||||
return EFI_BAD_BUFFER_SIZE;
|
||||
}
|
||||
//
|
||||
// send out in fragments - first includes upper level header
|
||||
// all are max and include more frag bit except last
|
||||
//
|
||||
* (UINT8 *) (&IP_TX_HEADER.FragmentFields) = IP_MORE_FRAG >> 8;
|
||||
|
||||
#define IPV4_FRAG_SIZE (MAX_IPV4_FRAME_DATA_SIZE & 0xfff8)
|
||||
#define IPV4_FRAG_OFF_INC (IPV4_FRAG_SIZE >> 3)
|
||||
|
||||
DataLengthSent = IPV4_FRAG_SIZE - HdrSize;
|
||||
|
||||
StatCode = Ipv4Xmt (
|
||||
Private,
|
||||
GatewayIp,
|
||||
sizeof (IPV4_HEADER),
|
||||
sizeof (IPV4_HEADER) + HdrSize,
|
||||
MessagePtr,
|
||||
DataLengthSent,
|
||||
Private->Function
|
||||
);
|
||||
|
||||
if (EFI_ERROR (StatCode)) {
|
||||
DEBUG (
|
||||
(DEBUG_WARN,
|
||||
"\nIp4Send() Exit #3 %xh (%r)",
|
||||
StatCode,
|
||||
StatCode)
|
||||
);
|
||||
|
||||
return StatCode;
|
||||
}
|
||||
|
||||
MessagePtr += DataLengthSent;
|
||||
MessageLength -= DataLengthSent;
|
||||
FragmentOffset += IPV4_FRAG_OFF_INC;
|
||||
IP_TX_HEADER.FragmentFields = HTONS (FragmentOffset);
|
||||
|
||||
while (MessageLength > IPV4_FRAG_SIZE) {
|
||||
StatCode = Ipv4Xmt (
|
||||
Private,
|
||||
GatewayIp,
|
||||
sizeof (IPV4_HEADER),
|
||||
sizeof (IPV4_HEADER),
|
||||
MessagePtr,
|
||||
IPV4_FRAG_SIZE,
|
||||
Private->Function
|
||||
);
|
||||
|
||||
if (EFI_ERROR (StatCode)) {
|
||||
DEBUG (
|
||||
(DEBUG_WARN,
|
||||
"\nIp4Send() Exit #3 %xh (%r)",
|
||||
StatCode,
|
||||
StatCode)
|
||||
);
|
||||
|
||||
return StatCode;
|
||||
}
|
||||
|
||||
MessagePtr += IPV4_FRAG_SIZE;
|
||||
MessageLength -= IPV4_FRAG_SIZE;
|
||||
FragmentOffset += IPV4_FRAG_OFF_INC;
|
||||
IP_TX_HEADER.FragmentFields = HTONS (FragmentOffset);
|
||||
}
|
||||
|
||||
* (UINT8 *) (&IP_TX_HEADER.FragmentFields) &= ~(IP_MORE_FRAG >> 8);
|
||||
HdrSize = 0;
|
||||
}
|
||||
//
|
||||
// transmit
|
||||
//
|
||||
return Ipv4Xmt (
|
||||
Private,
|
||||
GatewayIp,
|
||||
sizeof (IPV4_HEADER),
|
||||
sizeof (IPV4_HEADER) + HdrSize,
|
||||
MessagePtr,
|
||||
MessageLength,
|
||||
Private->Function
|
||||
);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
//
|
||||
// return true if dst IP in receive header matched with what's enabled
|
||||
//
|
||||
STATIC
|
||||
BOOLEAN
|
||||
IPgood (
|
||||
PXE_BASECODE_DEVICE *Private,
|
||||
IPV4_HEADER *IpHeader
|
||||
)
|
||||
{
|
||||
EFI_PXE_BASE_CODE_MODE *PxeBcMode;
|
||||
UINTN Index;
|
||||
|
||||
PxeBcMode = Private->EfiBc.Mode;
|
||||
|
||||
if (PxeBcMode->IpFilter.Filters & EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ((PxeBcMode->IpFilter.Filters & EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS_MULTICAST) &&
|
||||
IS_MULTICAST (&IpHeader->DestAddr)
|
||||
) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ((PxeBcMode->IpFilter.Filters & EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP) &&
|
||||
PxeBcMode->StationIp.Addr[0] == IpHeader->DestAddr.L
|
||||
) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ((PxeBcMode->IpFilter.Filters & EFI_PXE_BASE_CODE_IP_FILTER_BROADCAST) && IpHeader->DestAddr.L == BROADCAST_IPv4) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
for (Index = 0; Index < PxeBcMode->IpFilter.IpCnt; ++Index) {
|
||||
if (IpHeader->DestAddr.L == PxeBcMode->IpFilter.IpList[Index].Addr[0]) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
//
|
||||
// receive up to MessageLength message into MessagePtr for protocol Prot
|
||||
// return message length, src/dest ips if select any, and pointer to protocol
|
||||
// header routine will filter based on source and/or dest ip if OpFlags set.
|
||||
//
|
||||
EFI_STATUS
|
||||
IpReceive (
|
||||
PXE_BASECODE_DEVICE *Private,
|
||||
PXE_OPFLAGS OpFlags,
|
||||
EFI_IP_ADDRESS *SrcIpPtr,
|
||||
EFI_IP_ADDRESS *DestIpPtr,
|
||||
UINT8 Prot,
|
||||
VOID *HeaderPtr,
|
||||
UINTN HdrSize,
|
||||
UINT8 *MessagePtr,
|
||||
UINTN *MessageLengthPtr,
|
||||
EFI_EVENT TimeoutEvent
|
||||
)
|
||||
{
|
||||
EFI_PXE_BASE_CODE_MODE *PxeBcMode;
|
||||
EFI_STATUS StatCode;
|
||||
UINTN ByteCount;
|
||||
UINTN FragmentCount;
|
||||
UINTN ExpectedPacketLength;
|
||||
UINTN Id;
|
||||
BOOLEAN GotFirstFragment;
|
||||
BOOLEAN GotLastFragment;
|
||||
|
||||
DEBUG (
|
||||
(DEBUG_NET,
|
||||
"\nIpReceive() Hdr=%Xh HdrSz=%d Data=%Xh DataSz=%d",
|
||||
HeaderPtr,
|
||||
HdrSize,
|
||||
MessagePtr,
|
||||
*MessageLengthPtr)
|
||||
);
|
||||
|
||||
PxeBcMode = Private->EfiBc.Mode;
|
||||
PxeBcMode->IcmpErrorReceived = FALSE;
|
||||
|
||||
ExpectedPacketLength = 0;
|
||||
GotFirstFragment = FALSE;
|
||||
GotLastFragment = FALSE;
|
||||
FragmentCount = 0;
|
||||
ByteCount = 0;
|
||||
Id = 0;
|
||||
|
||||
for (;;) {
|
||||
IPV4_HEADER IpHdr;
|
||||
UINTN FFlds;
|
||||
UINTN TotalLength;
|
||||
UINTN FragmentOffset;
|
||||
UINTN HeaderSize;
|
||||
UINTN BufferSize;
|
||||
UINTN IpHeaderLength;
|
||||
UINTN DataLength;
|
||||
UINT16 Protocol;
|
||||
UINT8 *NextHdrPtr;
|
||||
UINT8 *PacketPtr;
|
||||
|
||||
StatCode = WaitForReceive (
|
||||
Private,
|
||||
Private->Function,
|
||||
TimeoutEvent,
|
||||
&HeaderSize,
|
||||
&BufferSize,
|
||||
&Protocol
|
||||
);
|
||||
|
||||
if (EFI_ERROR (StatCode)) {
|
||||
return StatCode;
|
||||
}
|
||||
|
||||
PacketPtr = Private->ReceiveBufferPtr + HeaderSize;
|
||||
|
||||
if (Protocol == PXE_PROTOCOL_ETHERNET_ARP) {
|
||||
HandleArpReceive (
|
||||
Private,
|
||||
(ARP_PACKET *) PacketPtr,
|
||||
Private->ReceiveBufferPtr
|
||||
);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Protocol != PXE_PROTOCOL_ETHERNET_IP) {
|
||||
continue;
|
||||
}
|
||||
|
||||
#define IpRxHeader ((IPV4_HEADER *) PacketPtr)
|
||||
|
||||
//
|
||||
// filter for version & check sum
|
||||
//
|
||||
IpHeaderLength = IPV4_HEADER_LENGTH (IpRxHeader);
|
||||
|
||||
if ((IpRxHeader->VersionIhl >> 4) != IPVER4) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (IpChecksum ((UINT16 *) IpRxHeader, IpHeaderLength)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CopyMem (&IpHdr, IpRxHeader, sizeof (IpHdr));
|
||||
TotalLength = NTOHS (IpHdr.TotalLength);
|
||||
|
||||
if (IpHdr.Protocol == PROT_TCP) {
|
||||
//
|
||||
// The NextHdrPtr is used to seed the header buffer we are passing back.
|
||||
// That being the case, we want to see everything in pPkt which contains
|
||||
// everything but the ethernet (or whatever) frame. IP + TCP in this case.
|
||||
//
|
||||
DataLength = TotalLength;
|
||||
NextHdrPtr = PacketPtr;
|
||||
} else {
|
||||
DataLength = TotalLength - IpHeaderLength;
|
||||
NextHdrPtr = PacketPtr + IpHeaderLength;
|
||||
}
|
||||
//
|
||||
// If this is an ICMP, it might not be for us.
|
||||
// Double check the state of the IP stack and the
|
||||
// packet fields before assuming it is an ICMP
|
||||
// error. ICMP requests are not supported by the
|
||||
// PxeBc IP stack and should be ignored.
|
||||
//
|
||||
if (IpHdr.Protocol == PROT_ICMP) {
|
||||
ICMPV4_HEADER *Icmpv4;
|
||||
|
||||
Icmpv4 = (ICMPV4_HEADER *) NextHdrPtr;
|
||||
|
||||
//
|
||||
// For now only obvious ICMP error replies will be accepted by
|
||||
// this stack. This still makes us vulnerable to DoS attacks.
|
||||
// But at least we will not be killed by DHCP daemons.
|
||||
//
|
||||
switch (Icmpv4->Type) {
|
||||
case ICMP_REDIRECT:
|
||||
case ICMP_ECHO:
|
||||
case ICMP_ROUTER_ADV:
|
||||
case ICMP_ROUTER_SOLICIT:
|
||||
case ICMP_TIMESTAMP:
|
||||
case ICMP_TIMESTAMP_REPLY:
|
||||
case ICMP_INFO_REQ:
|
||||
case ICMP_INFO_REQ_REPLY:
|
||||
case ICMP_SUBNET_MASK_REQ:
|
||||
case ICMP_SUBNET_MASK_REPLY:
|
||||
default:
|
||||
continue;
|
||||
|
||||
//
|
||||
// %%TBD - This should be implemented.
|
||||
//
|
||||
case ICMP_ECHO_REPLY:
|
||||
continue;
|
||||
|
||||
case ICMP_DEST_UNREACHABLE:
|
||||
case ICMP_TIME_EXCEEDED:
|
||||
case ICMP_PARAMETER_PROBLEM:
|
||||
case ICMP_SOURCE_QUENCH:
|
||||
PxeBcMode->IcmpErrorReceived = TRUE;
|
||||
|
||||
CopyMem (
|
||||
&PxeBcMode->IcmpError,
|
||||
NextHdrPtr,
|
||||
sizeof (EFI_PXE_BASE_CODE_ICMP_ERROR)
|
||||
);
|
||||
|
||||
DEBUG (
|
||||
(DEBUG_NET,
|
||||
"\nIpReceive() Exit #1 %Xh (%r)",
|
||||
EFI_ICMP_ERROR,
|
||||
EFI_ICMP_ERROR)
|
||||
);
|
||||
}
|
||||
|
||||
return EFI_ICMP_ERROR;
|
||||
}
|
||||
|
||||
if (IpHdr.Protocol == PROT_IGMP) {
|
||||
HandleIgmp (Private, (IGMPV2_MESSAGE *) NextHdrPtr, DataLength);
|
||||
|
||||
DEBUG ((DEBUG_NET, "\n IGMP"));
|
||||
continue;
|
||||
}
|
||||
//
|
||||
// check for protocol
|
||||
//
|
||||
if (IpHdr.Protocol != Prot) {
|
||||
continue;
|
||||
}
|
||||
//
|
||||
// do filtering
|
||||
//
|
||||
if (!(OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_IP) && SrcIpPtr && SrcIpPtr->Addr[0] != IpHdr.SrcAddr.L) {
|
||||
DEBUG ((DEBUG_NET, "\n Not expected source IP address."));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_USE_FILTER) {
|
||||
if (!IPgood (Private, &IpHdr)) {
|
||||
continue;
|
||||
}
|
||||
} else if (!(OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_IP)) {
|
||||
if (DestIpPtr == NULL) {
|
||||
if (PxeBcMode->StationIp.Addr[0] != IpHdr.DestAddr.L) {
|
||||
continue;
|
||||
}
|
||||
} else if (DestIpPtr->Addr[0] != IpHdr.DestAddr.L) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
//
|
||||
// get some data we need
|
||||
//
|
||||
FFlds = NTOHS (IpHdr.FragmentFields);
|
||||
FragmentOffset = ((FFlds & IP_FRAG_OFF_MSK) << 3);
|
||||
|
||||
/* Keep count of fragments that belong to this session.
|
||||
* If we get packets with a different IP ID number,
|
||||
* ignore them. Ignored packets should be handled
|
||||
* by the upper level protocol.
|
||||
*/
|
||||
if (FragmentCount == 0) {
|
||||
Id = IpHdr.Id;
|
||||
|
||||
if (DestIpPtr != NULL) {
|
||||
DestIpPtr->Addr[0] = IpHdr.DestAddr.L;
|
||||
}
|
||||
|
||||
if (SrcIpPtr != NULL) {
|
||||
SrcIpPtr->Addr[0] = IpHdr.SrcAddr.L;
|
||||
}
|
||||
} else {
|
||||
if (IpHdr.Id != Id) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
++FragmentCount;
|
||||
|
||||
/* Fragment management.
|
||||
*/
|
||||
if (FragmentOffset == 0) {
|
||||
/* This is the first fragment (may also be the
|
||||
* only fragment).
|
||||
*/
|
||||
GotFirstFragment = TRUE;
|
||||
|
||||
/* If there is a separate protocol header buffer,
|
||||
* copy the header, adjust the data pointer and
|
||||
* the data length.
|
||||
*/
|
||||
if (HdrSize != 0) {
|
||||
CopyMem (HeaderPtr, NextHdrPtr, HdrSize);
|
||||
|
||||
NextHdrPtr += HdrSize;
|
||||
DataLength -= HdrSize;
|
||||
}
|
||||
} else {
|
||||
/* If there is a separate protocol header buffer,
|
||||
* adjust the fragment offset.
|
||||
*/
|
||||
FragmentOffset -= HdrSize;
|
||||
}
|
||||
|
||||
/* See if this is the last fragment.
|
||||
*/
|
||||
if (!(FFlds & IP_MORE_FRAG)) {
|
||||
//
|
||||
// This is the last fragment (may also be the only fragment).
|
||||
//
|
||||
GotLastFragment = TRUE;
|
||||
|
||||
/* Compute the expected length of the assembled
|
||||
* packet. This will be used to decide if we
|
||||
* have gotten all of the fragments.
|
||||
*/
|
||||
ExpectedPacketLength = FragmentOffset + DataLength;
|
||||
}
|
||||
|
||||
DEBUG (
|
||||
(DEBUG_NET,
|
||||
"\n ID = %Xh Off = %d Len = %d",
|
||||
Id,
|
||||
FragmentOffset,
|
||||
DataLength)
|
||||
);
|
||||
|
||||
/* Check for receive buffer overflow.
|
||||
*/
|
||||
if (FragmentOffset + DataLength > *MessageLengthPtr) {
|
||||
/* There is not enough space in the receive
|
||||
* buffer for the fragment.
|
||||
*/
|
||||
DEBUG (
|
||||
(DEBUG_NET,
|
||||
"\nIpReceive() Exit #3 %Xh (%r)",
|
||||
EFI_BUFFER_TOO_SMALL,
|
||||
EFI_BUFFER_TOO_SMALL)
|
||||
);
|
||||
|
||||
return EFI_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
/* Copy data into receive buffer.
|
||||
*/
|
||||
if (DataLength != 0) {
|
||||
DEBUG ((DEBUG_NET, " To = %Xh", MessagePtr + FragmentOffset));
|
||||
|
||||
CopyMem (MessagePtr + FragmentOffset, NextHdrPtr, DataLength);
|
||||
ByteCount += DataLength;
|
||||
}
|
||||
|
||||
/* If we have seen the first and last fragments and
|
||||
* the receive byte count is at least as large as the
|
||||
* expected byte count, return SUCCESS.
|
||||
*
|
||||
* We could be tricked by receiving a fragment twice
|
||||
* but the upper level protocol should figure this
|
||||
* out.
|
||||
*/
|
||||
if (GotFirstFragment && GotLastFragment && ByteCount >= ExpectedPacketLength) {
|
||||
*MessageLengthPtr = ExpectedPacketLength;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* eof - pxe_bc_ip.c */
|
2193
MdeModulePkg/Universal/Network/PxeBcDxe/Pxe_bc_mtftp.c
Normal file
2193
MdeModulePkg/Universal/Network/PxeBcDxe/Pxe_bc_mtftp.c
Normal file
File diff suppressed because it is too large
Load Diff
517
MdeModulePkg/Universal/Network/PxeBcDxe/Pxe_bc_udp.c
Normal file
517
MdeModulePkg/Universal/Network/PxeBcDxe/Pxe_bc_udp.c
Normal file
@@ -0,0 +1,517 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2004 - 2007, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
pxe_bc_udp.c
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#include "Bc.h"
|
||||
|
||||
//
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Udp Write Routine - called by base code - e.g. TFTP - already locked
|
||||
//
|
||||
|
||||
/**
|
||||
|
||||
@return EFI_SUCCESS :=
|
||||
@return EFI_INVALID_PARAMETER :=
|
||||
@return other :=
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
UdpWrite (
|
||||
IN PXE_BASECODE_DEVICE *Private,
|
||||
IN UINT16 OpFlags,
|
||||
IN EFI_IP_ADDRESS *DestIpPtr,
|
||||
IN EFI_PXE_BASE_CODE_UDP_PORT *DestPortPtr,
|
||||
IN EFI_IP_ADDRESS *GatewayIpPtr, OPTIONAL
|
||||
IN EFI_IP_ADDRESS *SrcIpPtr, OPTIONAL
|
||||
IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPortPtr, OPTIONAL
|
||||
IN UINTN *HeaderSizePtr, OPTIONAL
|
||||
IN VOID *HeaderPtr, OPTIONAL
|
||||
IN UINTN *BufferSizeptr,
|
||||
IN VOID *BufferPtr
|
||||
)
|
||||
{
|
||||
UINTN TotalLength;
|
||||
UINTN HeaderSize;
|
||||
EFI_PXE_BASE_CODE_UDP_PORT DefaultSrcPort;
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
HeaderSize = (HeaderSizePtr != NULL) ? *HeaderSizePtr : 0;
|
||||
DefaultSrcPort = 0;
|
||||
|
||||
//
|
||||
// check parameters
|
||||
//
|
||||
if (BufferSizeptr == NULL ||
|
||||
BufferPtr == NULL ||
|
||||
DestIpPtr == NULL ||
|
||||
DestPortPtr == NULL ||
|
||||
(HeaderSizePtr != NULL && *HeaderSizePtr == 0) ||
|
||||
(HeaderSize != 0 && HeaderPtr == NULL) ||
|
||||
(GatewayIpPtr != NULL && !IS_INADDR_UNICAST(GatewayIpPtr)) ||
|
||||
(OpFlags &~(EFI_PXE_BASE_CODE_UDP_OPFLAGS_MAY_FRAGMENT | EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT))
|
||||
) {
|
||||
DEBUG (
|
||||
(DEBUG_WARN,
|
||||
"\nUdpWrite() Exit #1 %xh (%r)",
|
||||
EFI_INVALID_PARAMETER,
|
||||
EFI_INVALID_PARAMETER)
|
||||
);
|
||||
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
TotalLength = *BufferSizeptr + HeaderSize + sizeof (UDPV4_HEADER);
|
||||
|
||||
if (TotalLength > 0x0000ffff) {
|
||||
DEBUG (
|
||||
(DEBUG_WARN,
|
||||
"\nUdpWrite() Exit #2 %xh (%r)",
|
||||
EFI_BAD_BUFFER_SIZE,
|
||||
EFI_BAD_BUFFER_SIZE)
|
||||
);
|
||||
|
||||
return EFI_BAD_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
if (SrcIpPtr == NULL) {
|
||||
SrcIpPtr = &Private->EfiBc.Mode->StationIp;
|
||||
}
|
||||
|
||||
if (SrcPortPtr == NULL) {
|
||||
SrcPortPtr = &DefaultSrcPort;
|
||||
OpFlags |= EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT;
|
||||
}
|
||||
|
||||
if (OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT) {
|
||||
*SrcPortPtr = Private->RandomPort;
|
||||
|
||||
if (++Private->RandomPort == 0) {
|
||||
Private->RandomPort = PXE_RND_PORT_LOW;
|
||||
}
|
||||
}
|
||||
|
||||
#define IpTxBuffer ((IPV4_BUFFER *) Private->TransmitBufferPtr)
|
||||
//
|
||||
// build pseudo header and udp header in transmit buffer
|
||||
//
|
||||
#define Udpv4Base ((UDPV4_HEADERS *) (IpTxBuffer->u.Data - sizeof (UDPV4_PSEUDO_HEADER)))
|
||||
|
||||
Udpv4Base->Udpv4PseudoHeader.SrcAddr.L = SrcIpPtr->Addr[0];
|
||||
Udpv4Base->Udpv4PseudoHeader.DestAddr.L = DestIpPtr->Addr[0];
|
||||
Udpv4Base->Udpv4PseudoHeader.Zero = 0;
|
||||
Udpv4Base->Udpv4PseudoHeader.Protocol = PROT_UDP;
|
||||
Udpv4Base->Udpv4PseudoHeader.TotalLength = HTONS (TotalLength);
|
||||
Udpv4Base->Udpv4Header.SrcPort = HTONS (*SrcPortPtr);
|
||||
Udpv4Base->Udpv4Header.DestPort = HTONS (*DestPortPtr);
|
||||
Udpv4Base->Udpv4Header.TotalLength = Udpv4Base->Udpv4PseudoHeader.TotalLength;
|
||||
Udpv4Base->Udpv4Header.Checksum = 0;
|
||||
|
||||
if (HeaderSize != 0) {
|
||||
CopyMem (IpTxBuffer->u.Udp.Data, HeaderPtr, HeaderSize);
|
||||
}
|
||||
|
||||
HeaderSize += sizeof (UDPV4_HEADER);
|
||||
|
||||
Udpv4Base->Udpv4Header.Checksum = IpChecksum2 (
|
||||
(UINT16 *) Udpv4Base,
|
||||
HeaderSize + sizeof (UDPV4_PSEUDO_HEADER),
|
||||
(UINT16 *) BufferPtr,
|
||||
(UINT16) *BufferSizeptr
|
||||
);
|
||||
|
||||
if (Udpv4Base->Udpv4Header.Checksum == 0) {
|
||||
Udpv4Base->Udpv4Header.Checksum = 0xffff;
|
||||
//
|
||||
// transmit zero checksum as ones complement
|
||||
//
|
||||
}
|
||||
|
||||
return Ip4Send (
|
||||
Private,
|
||||
OpFlags,
|
||||
PROT_UDP,
|
||||
Udpv4Base->Udpv4PseudoHeader.SrcAddr.L,
|
||||
Udpv4Base->Udpv4PseudoHeader.DestAddr.L,
|
||||
(GatewayIpPtr) ? GatewayIpPtr->Addr[0] : 0,
|
||||
HeaderSize,
|
||||
BufferPtr,
|
||||
*BufferSizeptr
|
||||
);
|
||||
}
|
||||
//
|
||||
// //////////////////////////////////////////////////////////
|
||||
//
|
||||
// BC Udp Write Routine
|
||||
//
|
||||
|
||||
/**
|
||||
|
||||
@return EFI_SUCCESS :=
|
||||
@return other :=
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
BcUdpWrite (
|
||||
IN EFI_PXE_BASE_CODE_PROTOCOL *This,
|
||||
IN UINT16 OpFlags,
|
||||
IN EFI_IP_ADDRESS *DestIpPtr,
|
||||
IN EFI_PXE_BASE_CODE_UDP_PORT *DestPortPtr,
|
||||
IN EFI_IP_ADDRESS *GatewayIpPtr, OPTIONAL
|
||||
IN EFI_IP_ADDRESS *SrcIpPtr, OPTIONAL
|
||||
IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPortPtr, OPTIONAL
|
||||
IN UINTN *HeaderSizePtr, OPTIONAL
|
||||
IN VOID *HeaderPtr, OPTIONAL
|
||||
IN UINTN *BufferSizeptr,
|
||||
IN VOID *BufferPtr
|
||||
)
|
||||
{
|
||||
EFI_STATUS StatCode;
|
||||
PXE_BASECODE_DEVICE *Private;
|
||||
|
||||
//
|
||||
// Lock the instance data and make sure started
|
||||
//
|
||||
StatCode = EFI_SUCCESS;
|
||||
|
||||
if (This == NULL) {
|
||||
DEBUG ((DEBUG_ERROR, "BC *This pointer == NULL"));
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Private = CR (This, PXE_BASECODE_DEVICE, EfiBc, PXE_BASECODE_DEVICE_SIGNATURE);
|
||||
|
||||
if (Private == NULL) {
|
||||
DEBUG ((DEBUG_ERROR, "PXE_BASECODE_DEVICE poiner == NULL"));
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
EfiAcquireLock (&Private->Lock);
|
||||
|
||||
if (This->Mode == NULL || !This->Mode->Started) {
|
||||
DEBUG ((DEBUG_ERROR, "BC was not started."));
|
||||
EfiReleaseLock (&Private->Lock);
|
||||
return EFI_NOT_STARTED;
|
||||
}
|
||||
|
||||
Private->Function = EFI_PXE_BASE_CODE_FUNCTION_UDP_WRITE;
|
||||
|
||||
//
|
||||
// Issue BC command
|
||||
//
|
||||
StatCode = UdpWrite (
|
||||
Private,
|
||||
OpFlags,
|
||||
DestIpPtr,
|
||||
DestPortPtr,
|
||||
GatewayIpPtr,
|
||||
SrcIpPtr,
|
||||
SrcPortPtr,
|
||||
HeaderSizePtr,
|
||||
HeaderPtr,
|
||||
BufferSizeptr,
|
||||
BufferPtr
|
||||
);
|
||||
|
||||
//
|
||||
// Unlock the instance data
|
||||
//
|
||||
EfiReleaseLock (&Private->Lock);
|
||||
return StatCode;
|
||||
}
|
||||
//
|
||||
// /////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Udp Read Routine - called by base code - e.g. TFTP - already locked
|
||||
//
|
||||
|
||||
/**
|
||||
|
||||
@return EFI_SUCCESS :=
|
||||
@return EFI_INVALID_PARAMETER :=
|
||||
@return other :=
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
UdpRead (
|
||||
IN PXE_BASECODE_DEVICE *Private,
|
||||
IN UINT16 OpFlags,
|
||||
IN OUT EFI_IP_ADDRESS *DestIpPtr, OPTIONAL
|
||||
IN OUT EFI_PXE_BASE_CODE_UDP_PORT *DestPortPtr, OPTIONAL
|
||||
IN OUT EFI_IP_ADDRESS *SrcIpPtr, OPTIONAL
|
||||
IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPortPtr, OPTIONAL
|
||||
IN UINTN *HeaderSizePtr, OPTIONAL
|
||||
IN VOID *HeaderPtr, OPTIONAL
|
||||
IN OUT UINTN *BufferSizeptr,
|
||||
IN VOID *BufferPtr,
|
||||
EFI_EVENT TimeoutEvent
|
||||
)
|
||||
{
|
||||
EFI_STATUS StatCode;
|
||||
EFI_IP_ADDRESS TmpSrcIp;
|
||||
EFI_IP_ADDRESS TmpDestIp;
|
||||
UINTN BufferSize;
|
||||
UINTN HeaderSize;
|
||||
|
||||
//
|
||||
// combination structure of pseudo header/udp header
|
||||
//
|
||||
#pragma pack (1)
|
||||
struct {
|
||||
UDPV4_PSEUDO_HEADER Udpv4PseudoHeader;
|
||||
UDPV4_HEADER Udpv4Header;
|
||||
UINT8 ProtHdr[64];
|
||||
} Hdrs;
|
||||
#pragma pack ()
|
||||
|
||||
HeaderSize = (HeaderSizePtr != NULL) ? *HeaderSizePtr : 0;
|
||||
//
|
||||
// read [with filtering]
|
||||
// check parameters
|
||||
//
|
||||
if (BufferSizeptr == NULL ||
|
||||
BufferPtr == NULL ||
|
||||
(HeaderSize != 0 && HeaderPtr == NULL) ||
|
||||
(OpFlags &~UDP_FILTER_MASK)
|
||||
//
|
||||
// if filtering on a particular IP/Port, need it
|
||||
//
|
||||
||
|
||||
(!(OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_IP) && SrcIpPtr == NULL) ||
|
||||
(!(OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT) && SrcPortPtr == NULL) ||
|
||||
(!(OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT) && DestPortPtr == NULL)
|
||||
) {
|
||||
DEBUG ((DEBUG_INFO, "\nUdpRead() Exit #1 Invalid Parameter"));
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//
|
||||
// in case we loop
|
||||
//
|
||||
BufferSize = *BufferSizeptr;
|
||||
//
|
||||
// we need source and dest IPs for pseudo header
|
||||
//
|
||||
if (SrcIpPtr == NULL) {
|
||||
SrcIpPtr = &TmpSrcIp;
|
||||
}
|
||||
|
||||
if (DestIpPtr == NULL) {
|
||||
DestIpPtr = &TmpDestIp;
|
||||
TmpDestIp = Private->EfiBc.Mode->StationIp;
|
||||
}
|
||||
|
||||
#if SUPPORT_IPV6
|
||||
if (Private->EfiBc.Mode->UsingIpv6) {
|
||||
//
|
||||
// %%TBD
|
||||
//
|
||||
}
|
||||
#endif
|
||||
|
||||
for (;;) {
|
||||
*BufferSizeptr = BufferSize;
|
||||
|
||||
StatCode = IpReceive (
|
||||
Private,
|
||||
OpFlags,
|
||||
SrcIpPtr,
|
||||
DestIpPtr,
|
||||
PROT_UDP,
|
||||
&Hdrs.Udpv4Header,
|
||||
HeaderSize + sizeof Hdrs.Udpv4Header,
|
||||
BufferPtr,
|
||||
BufferSizeptr,
|
||||
TimeoutEvent
|
||||
);
|
||||
|
||||
if (StatCode == EFI_SUCCESS || StatCode == EFI_BUFFER_TOO_SMALL) {
|
||||
UINT16 SPort;
|
||||
UINT16 DPort;
|
||||
|
||||
SPort = NTOHS (Hdrs.Udpv4Header.SrcPort);
|
||||
DPort = NTOHS (Hdrs.Udpv4Header.DestPort);
|
||||
|
||||
//
|
||||
// do filtering
|
||||
//
|
||||
if (!(OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT) && *SrcPortPtr != SPort) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!(OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT) && *DestPortPtr != DPort) {
|
||||
continue;
|
||||
}
|
||||
//
|
||||
// check checksum
|
||||
//
|
||||
if (StatCode == EFI_SUCCESS && Hdrs.Udpv4Header.Checksum) {
|
||||
Hdrs.Udpv4PseudoHeader.SrcAddr.L = SrcIpPtr->Addr[0];
|
||||
Hdrs.Udpv4PseudoHeader.DestAddr.L = DestIpPtr->Addr[0];
|
||||
Hdrs.Udpv4PseudoHeader.Zero = 0;
|
||||
Hdrs.Udpv4PseudoHeader.Protocol = PROT_UDP;
|
||||
Hdrs.Udpv4PseudoHeader.TotalLength = Hdrs.Udpv4Header.TotalLength;
|
||||
|
||||
if (Hdrs.Udpv4Header.Checksum == 0xffff) {
|
||||
Hdrs.Udpv4Header.Checksum = 0;
|
||||
}
|
||||
|
||||
if (IpChecksum2 (
|
||||
(UINT16 *) &Hdrs.Udpv4PseudoHeader,
|
||||
HeaderSize + sizeof (Hdrs.Udpv4PseudoHeader) + sizeof (Hdrs.Udpv4Header),
|
||||
(UINT16 *) BufferPtr,
|
||||
*BufferSizeptr
|
||||
)) {
|
||||
DEBUG (
|
||||
(DEBUG_INFO,
|
||||
"\nUdpRead() Hdrs.Udpv4PseudoHeader == %Xh",
|
||||
Hdrs.Udpv4PseudoHeader)
|
||||
);
|
||||
DEBUG (
|
||||
(DEBUG_INFO,
|
||||
"\nUdpRead() Header size == %d",
|
||||
HeaderSize + sizeof (Hdrs.Udpv4PseudoHeader))
|
||||
);
|
||||
DEBUG (
|
||||
(DEBUG_INFO,
|
||||
"\nUdpRead() BufferPtr == %Xh",
|
||||
BufferPtr)
|
||||
);
|
||||
DEBUG (
|
||||
(DEBUG_INFO,
|
||||
"\nUdpRead() Buffer size == %d",
|
||||
*BufferSizeptr)
|
||||
);
|
||||
DEBUG ((DEBUG_INFO, "\nUdpRead() Exit #2 Device Error"));
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
}
|
||||
//
|
||||
// all passed
|
||||
//
|
||||
if (SrcPortPtr != NULL) {
|
||||
*SrcPortPtr = SPort;
|
||||
}
|
||||
|
||||
if (DestPortPtr != NULL) {
|
||||
*DestPortPtr = DPort;
|
||||
}
|
||||
|
||||
if (HeaderSize != 0) {
|
||||
CopyMem (HeaderPtr, Hdrs.ProtHdr, HeaderSize);
|
||||
}
|
||||
}
|
||||
|
||||
if ((StatCode != EFI_SUCCESS) && (StatCode != EFI_TIMEOUT)) {
|
||||
DEBUG (
|
||||
(DEBUG_INFO,
|
||||
"\nUdpRead() Exit #3 %Xh %r",
|
||||
StatCode,
|
||||
StatCode)
|
||||
);
|
||||
}
|
||||
|
||||
return StatCode;
|
||||
}
|
||||
}
|
||||
//
|
||||
// //////////////////////////////////////////////////////////
|
||||
//
|
||||
// BC Udp Read Routine
|
||||
//
|
||||
|
||||
/**
|
||||
|
||||
@return EFI_SUCCESS :=
|
||||
@return other :=
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
BcUdpRead (
|
||||
IN EFI_PXE_BASE_CODE_PROTOCOL *This,
|
||||
IN UINT16 OpFlags,
|
||||
IN OUT EFI_IP_ADDRESS *DestIp, OPTIONAL
|
||||
IN OUT EFI_PXE_BASE_CODE_UDP_PORT *DestPort, OPTIONAL
|
||||
IN OUT EFI_IP_ADDRESS *SrcIp, OPTIONAL
|
||||
IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort, OPTIONAL
|
||||
IN UINTN *HeaderSize, OPTIONAL
|
||||
IN VOID *HeaderPtr, OPTIONAL
|
||||
IN OUT UINTN *BufferSize,
|
||||
IN VOID *BufferPtr
|
||||
)
|
||||
{
|
||||
EFI_STATUS StatCode;
|
||||
PXE_BASECODE_DEVICE *Private;
|
||||
|
||||
//
|
||||
// Lock the instance data and make sure started
|
||||
//
|
||||
StatCode = EFI_SUCCESS;
|
||||
|
||||
if (This == NULL) {
|
||||
DEBUG ((DEBUG_ERROR, "BC *This pointer == NULL"));
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Private = CR (This, PXE_BASECODE_DEVICE, EfiBc, PXE_BASECODE_DEVICE_SIGNATURE);
|
||||
|
||||
if (Private == NULL) {
|
||||
DEBUG ((DEBUG_ERROR, "PXE_BASECODE_DEVICE poiner == NULL"));
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
EfiAcquireLock (&Private->Lock);
|
||||
|
||||
if (This->Mode == NULL || !This->Mode->Started) {
|
||||
DEBUG ((DEBUG_ERROR, "BC was not started."));
|
||||
EfiReleaseLock (&Private->Lock);
|
||||
return EFI_NOT_STARTED;
|
||||
}
|
||||
|
||||
Private->Function = EFI_PXE_BASE_CODE_FUNCTION_UDP_READ;
|
||||
|
||||
//
|
||||
// Issue BC command
|
||||
//
|
||||
StatCode = UdpRead (
|
||||
Private,
|
||||
OpFlags,
|
||||
DestIp,
|
||||
DestPort,
|
||||
SrcIp,
|
||||
SrcPort,
|
||||
HeaderSize,
|
||||
HeaderPtr,
|
||||
BufferSize,
|
||||
BufferPtr,
|
||||
0
|
||||
);
|
||||
|
||||
//
|
||||
// Unlock the instance data and return
|
||||
//
|
||||
EfiReleaseLock (&Private->Lock);
|
||||
return StatCode;
|
||||
}
|
||||
|
||||
/* eof - pxe_bc_udp.c */
|
1614
MdeModulePkg/Universal/Network/PxeBcDxe/Pxe_loadfile.c
Normal file
1614
MdeModulePkg/Universal/Network/PxeBcDxe/Pxe_loadfile.c
Normal file
File diff suppressed because it is too large
Load Diff
154
MdeModulePkg/Universal/Network/PxeBcDxe/Tftp.h
Normal file
154
MdeModulePkg/Universal/Network/PxeBcDxe/Tftp.h
Normal file
@@ -0,0 +1,154 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2004, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
tftp.h
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __TFTP_H__
|
||||
#define __TFTP_H__
|
||||
|
||||
//
|
||||
// Definitions for trivial file transfer protocol functionality with IP v4
|
||||
// Per RFC 1350, July 1992 and RFC 2347, 8, and 9, May 1998
|
||||
//
|
||||
#pragma pack(1)
|
||||
//
|
||||
// max and min packet sizes
|
||||
// (all data packets in transmission except last)
|
||||
//
|
||||
#define MAX_TFTP_PKT_SIZE (BUFFER_ALLOCATE_SIZE - 512)
|
||||
#define MIN_TFTP_PKT_SIZE 512
|
||||
|
||||
//
|
||||
// TFTPv4 OpCodes
|
||||
//
|
||||
#define TFTP_RRQ 1 // read request
|
||||
#define TFTP_WRQ 2 // write request
|
||||
#define TFTP_DATA 3 // data
|
||||
#define TFTP_ACK 4 // acknowledgement
|
||||
#define TFTP_ERROR 5 // error packet
|
||||
#define TFTP_OACK 6 // option acknowledge
|
||||
#define TFTP_DIR 7 // read directory request
|
||||
#define TFTP_DATA8 8
|
||||
#define TFTP_ACK8 9
|
||||
|
||||
//
|
||||
// request packet (read or write)
|
||||
// Fields shown (except file name) are not to be referenced directly,
|
||||
// since their placement is variable within a request packet.
|
||||
// All are null terminated case insensitive ascii strings.
|
||||
//
|
||||
struct Tftpv4Req {
|
||||
UINT16 OpCode; // TFTP Op code
|
||||
UINT8 FileName[2]; // file name
|
||||
UINT8 Mode[2]; // "netascii" or "octet"
|
||||
struct { // optionally, one or more option requests
|
||||
UINT8 Option[2]; // option name
|
||||
UINT8 Value[2]; // value requested
|
||||
} OpReq[1];
|
||||
};
|
||||
|
||||
//
|
||||
// modes
|
||||
//
|
||||
#define MODE_ASCII "netascii"
|
||||
#define MODE_BINARY "octet"
|
||||
|
||||
//
|
||||
// option strings
|
||||
//
|
||||
#define OP_BLKSIZE "blksize" // block size option
|
||||
#define OP_TIMEOUT "timeout" // time to wait before retransmitting
|
||||
#define OP_TFRSIZE "tsize" // total transfer size option
|
||||
#define OP_OVERWRITE "overwrite" // overwrite file option
|
||||
#define OP_BIGBLKNUM "bigblk#" // big block number
|
||||
// See RFC 2347, 8, and 9 for more information on TFTP options
|
||||
// option acknowledge packet (optional)
|
||||
// options not acknowledged are rejected
|
||||
//
|
||||
struct Tftpv4Oack {
|
||||
UINT16 OpCode; // TFTP Op code
|
||||
struct { // optionally, one or more option acknowledgements
|
||||
UINT8 Option[2]; // option name (of those requested)
|
||||
UINT8 Value[2]; // value acknowledged
|
||||
} OpAck[1];
|
||||
};
|
||||
|
||||
//
|
||||
// acknowledge packet
|
||||
//
|
||||
struct Tftpv4Ack {
|
||||
UINT16 OpCode; // TFTP Op code
|
||||
UINT16 BlockNum;
|
||||
};
|
||||
|
||||
//
|
||||
// data packet
|
||||
//
|
||||
struct Tftpv4Data {
|
||||
struct Tftpv4Ack Header;
|
||||
UINT8 Data[512];
|
||||
};
|
||||
|
||||
//
|
||||
// big block number ack packet
|
||||
//
|
||||
struct Tftpv4Ack8 {
|
||||
UINT16 OpCode;
|
||||
UINT64 BlockNum;
|
||||
};
|
||||
|
||||
//
|
||||
// big block number data packet
|
||||
//
|
||||
struct Tftpv4Data8 {
|
||||
struct Tftpv4Ack8 Header;
|
||||
UINT8 Data[506];
|
||||
};
|
||||
|
||||
//
|
||||
// error packet
|
||||
//
|
||||
struct Tftpv4Error {
|
||||
UINT16 OpCode; // TFTP Op code
|
||||
UINT16 ErrCode; // error code
|
||||
UINT8 ErrMsg[1]; // error message (nul terminated)
|
||||
};
|
||||
|
||||
#pragma pack()
|
||||
//
|
||||
// error codes
|
||||
//
|
||||
#define TFTP_ERR_UNDEF 0 // Not defined, see error message (if any).
|
||||
#define TFTP_ERR_NOT_FOUND 1 // File not found.
|
||||
#define TFTP_ERR_ACCESS 2 // Access violation.
|
||||
#define TFTP_ERR_FULL 3 // Disk full or allocation exceeded.
|
||||
#define TFTP_ERR_ILLEGAL 4 // Illegal TFTP operation.
|
||||
#define TFTP_ERR_BAD_ID 5 // Unknown transfer ID.
|
||||
#define TFTP_ERR_EXISTS 6 // File already exists.
|
||||
#define TFTP_ERR_NO_USER 7 // No such user.
|
||||
#define TFTP_ERR_OPTION 8 // Option negotiation termination
|
||||
//
|
||||
// some defines
|
||||
//
|
||||
#define REQ_RESP_TIMEOUT 5 // Wait five seconds for request response.
|
||||
#define ACK_TIMEOUT 4 // Wait four seconds for ack response.
|
||||
#define NUM_ACK_RETRIES 3
|
||||
#define NUM_MTFTP_OPEN_RETRIES 3
|
||||
|
||||
#endif /* __TFTP_H__ */
|
||||
|
||||
/* EOF - tftp.h */
|
26
MdeModulePkg/Universal/Network/PxeBcDxe/X64/PxeArch.h
Normal file
26
MdeModulePkg/Universal/Network/PxeBcDxe/X64/PxeArch.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2006, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
PxeArch.h
|
||||
|
||||
Abstract:
|
||||
Defines PXE Arch type
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _EFI_PXE_ARCH_H_
|
||||
#define _EFI_PXE_ARCH_H_
|
||||
|
||||
#define SYS_ARCH 0x7
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user