I'm trying to get ARP table with ArpDxe driver in UEFI application. Here is my code:
EFI_ARP_PROTOCOL* Arp;
EFI_STATUS Status;
UINT32 Count;
UINT32 Length;
EFI_ARP_FIND_DATA* Entries;
Status = gBS->LocateProtocol (
&gEfiArpProtocolGuid,
NULL,
(VOID**)&Arp
);
if (Status == EFI_SUCCESS) {
Status = Arp->Find(Arp, true, NULL, &Length, &Count, &Entries, false);
if (Status == EFI_SUCCESS) {
//......
}
}
The problem is, the ARP find function always returns EFI_NOT_FOUND. I try to ping a valid IP before running my application, try to call ARP request function before calling find function, and even try to call ARP add function to add a dummy data, but none of them causing something can be found. Can someone points me out what am I doing wrong?
Like most of the network protocols, ARP uses the service binding protocol to create new instances.
You have to:
Locate the service binding protocol
EFI_HANDLE ChildHandle = NULL;
EFI_SERVICE_BINDING_PROTOCOL* ArpSb;
gBS->LocateProtocol(&gEfiArpServiceBindingProtocolGuid,NULL,(VOID**)&ArpSb)
Create a new ARP instance
ArpSb->CreateChild(ArpSb, &ChildHandle)
Handle the EFI_ARP_PROTOCOL
gBS->HandleProtocol(ChildHandle, &gEfiArpProtocolGuid, (VOID**)&Arp)
Configure the new instances
Arp->Configure(Arp,...)
Destroy the instance when you are done
ArpSb->DestroyChild(ArpSb, ChildHandle)
When you search for the proctocol directly (without creating a new instance) you get an instance that belongs to some driver or app with unknown configuration.