本文整理汇总了C++中EFI_SIMPLE_NETWORK::Receive方法的典型用法代码示例。如果您正苦于以下问题:C++ EFI_SIMPLE_NETWORK::Receive方法的具体用法?C++ EFI_SIMPLE_NETWORK::Receive怎么用?C++ EFI_SIMPLE_NETWORK::Receive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EFI_SIMPLE_NETWORK
的用法示例。
在下文中一共展示了EFI_SIMPLE_NETWORK::Receive方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: time
static int
efinet_get(struct iodesc *desc, void *pkt, size_t len, time_t timeout)
{
struct netif *nif = desc->io_netif;
EFI_SIMPLE_NETWORK *net;
EFI_STATUS status;
UINTN bufsz;
time_t t;
char buf[2048];
net = nif->nif_devdata;
t = time(0);
while ((time(0) - t) < timeout) {
bufsz = sizeof(buf);
status = net->Receive(net, 0, &bufsz, buf, 0, 0, 0);
if (status == EFI_SUCCESS) {
/*
* XXX EFI1.1 and the E1000 card trash our
* workspace if we do not do this silly copy.
* Either they are not respecting the len
* value or do not like the alignment.
*/
if (bufsz > len)
bufsz = len;
bcopy(buf, pkt, bufsz);
return (bufsz);
}
if (status != EFI_NOT_READY)
return (0);
}
return (0);
}
示例2: malloc
static ssize_t
efinet_get(struct iodesc *desc, void **pkt, time_t timeout)
{
struct netif *nif = desc->io_netif;
EFI_SIMPLE_NETWORK *net;
EFI_STATUS status;
UINTN bufsz;
time_t t;
char *buf, *ptr;
ssize_t ret = -1;
net = nif->nif_devdata;
if (net == NULL)
return (ret);
bufsz = net->Mode->MaxPacketSize + ETHER_HDR_LEN + ETHER_CRC_LEN;
buf = malloc(bufsz + ETHER_ALIGN);
if (buf == NULL)
return (ret);
ptr = buf + ETHER_ALIGN;
t = getsecs();
while ((getsecs() - t) < timeout) {
status = net->Receive(net, NULL, &bufsz, ptr, NULL, NULL, NULL);
if (status == EFI_SUCCESS) {
*pkt = buf;
ret = (ssize_t)bufsz;
break;
}
if (status != EFI_NOT_READY)
break;
}
if (ret == -1)
free(buf);
return (ret);
}