mirror of https://github.com/acidanthera/audk.git
Merged socket development branch:
* Fixed bug report (Duane Voth: Python sockets test application not working) by starting the receive operations when a connection is established! * Increased performance by extending the idle loop into the network stack with the Poll call. * Added support for TCPv6 (SOCK_STREAM) and UDPv6 (SOCK_DGRAM). * Added support for getaddrinfo and getnameinfo calls. * Moved application PCD values into AppPkg Signed-off-by: lpleahy git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13002 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
5709e4e290
commit
3bdf9aae5f
|
@ -31,12 +31,14 @@
|
|||
bind.c
|
||||
close.c
|
||||
connect.c
|
||||
getaddrinfo.c
|
||||
gethostbydns.c
|
||||
gethostbyht.c
|
||||
gethostbynis.c
|
||||
gethostname.c
|
||||
gethostnamadr.c
|
||||
gethostbynis.c
|
||||
getnameinfo.c
|
||||
getnetbydns.c
|
||||
getnetbynis.c
|
||||
getnetbyht.c
|
||||
|
@ -51,16 +53,9 @@
|
|||
getsockname.c
|
||||
getsockopt.c
|
||||
herror.c
|
||||
# inet_addr.c
|
||||
# inet_lnaof.c
|
||||
# inet_makeaddr.c
|
||||
inet_net_ntop.c
|
||||
inet_net_pton.c
|
||||
inet_neta.c
|
||||
# inet_netof.c
|
||||
# inet_network.c
|
||||
# inet_ntoa.c
|
||||
# inet_ntop.c
|
||||
inet_pton.c
|
||||
listen.c
|
||||
map_v4v6.c
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,567 @@
|
|||
/* $NetBSD: getnameinfo.c,v 1.45 2006/10/15 16:14:46 christos Exp $ */
|
||||
/* $KAME: getnameinfo.c,v 1.45 2000/09/25 22:43:56 itojun Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000 Ben Harris.
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the project nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Issues to be discussed:
|
||||
* - Thread safe-ness must be checked
|
||||
* - RFC2553 says that we should raise error on short buffer. X/Open says
|
||||
* we need to truncate the result. We obey RFC2553 (and X/Open should be
|
||||
* modified). ipngwg rough consensus seems to follow RFC2553.
|
||||
* - What is "local" in NI_FQDN?
|
||||
* - NI_NAMEREQD and NI_NUMERICHOST conflict with each other.
|
||||
* - (KAME extension) always attach textual scopeid (fe80::1%lo0), if
|
||||
* sin6_scope_id is filled - standardization status?
|
||||
* XXX breaks backward compat for code that expects no scopeid.
|
||||
* beware on merge.
|
||||
*/
|
||||
|
||||
#define INET6 1
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: getnameinfo.c,v 1.45 2006/10/15 16:14:46 christos Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
//#include <net/if_ieee1394.h>
|
||||
//#include <net/if_types.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
#include <netdb.h>
|
||||
#include <resolv.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <net/servent.h>
|
||||
|
||||
#define CLLADDR(x) ( LLADDR(x) )
|
||||
#define endservent_r(svd) endservent()
|
||||
#define getservbyport_r(Port,pProto,pSv,pSvd) getservbyport(Port,pProto)
|
||||
|
||||
#ifdef __weak_alias
|
||||
__weak_alias(getnameinfo,_getnameinfo)
|
||||
#endif
|
||||
|
||||
static
|
||||
int
|
||||
hexname(
|
||||
const u_int8_t * cp,
|
||||
size_t len,
|
||||
char * host,
|
||||
socklen_t hostlen
|
||||
);
|
||||
|
||||
static const struct afd {
|
||||
int a_af;
|
||||
socklen_t a_addrlen;
|
||||
socklen_t a_socklen;
|
||||
int a_off;
|
||||
} afdl [] = {
|
||||
#ifdef INET6
|
||||
{PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6),
|
||||
offsetof(struct sockaddr_in6, sin6_addr)},
|
||||
#endif
|
||||
{PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in),
|
||||
offsetof(struct sockaddr_in, sin_addr)},
|
||||
{0, 0, 0, 0},
|
||||
};
|
||||
|
||||
struct sockinet {
|
||||
u_char si_len;
|
||||
u_char si_family;
|
||||
u_short si_port;
|
||||
};
|
||||
|
||||
static int getnameinfo_inet __P((const struct sockaddr *, socklen_t, char *,
|
||||
socklen_t, char *, socklen_t, int));
|
||||
#ifdef INET6
|
||||
static int ip6_parsenumeric __P((const struct sockaddr *, const char *, char *,
|
||||
socklen_t, int));
|
||||
static int ip6_sa2str __P((const struct sockaddr_in6 *, char *, size_t,
|
||||
int));
|
||||
#endif
|
||||
static int getnameinfo_link __P((const struct sockaddr *, socklen_t, char *,
|
||||
socklen_t, char *, socklen_t, int));
|
||||
static int hexname __P((const u_int8_t *, size_t, char *, socklen_t));
|
||||
|
||||
/*
|
||||
* Top-level getnameinfo() code. Look at the address family, and pick an
|
||||
* appropriate function to call.
|
||||
*/
|
||||
int
|
||||
getnameinfo(
|
||||
const struct sockaddr * sa,
|
||||
socklen_t salen,
|
||||
char * host,
|
||||
socklen_t hostlen,
|
||||
char * serv,
|
||||
socklen_t servlen,
|
||||
int flags
|
||||
)
|
||||
{
|
||||
|
||||
switch (sa->sa_family) {
|
||||
case AF_INET:
|
||||
case AF_INET6:
|
||||
return getnameinfo_inet(sa, salen, host, hostlen,
|
||||
serv, servlen, flags);
|
||||
case AF_LINK:
|
||||
return getnameinfo_link(sa, salen, host, hostlen,
|
||||
serv, servlen, flags);
|
||||
default:
|
||||
return EAI_FAMILY;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* getnameinfo_inet():
|
||||
* Format an IPv4 or IPv6 sockaddr into a printable string.
|
||||
*/
|
||||
static
|
||||
int
|
||||
getnameinfo_inet(
|
||||
const struct sockaddr * sa,
|
||||
socklen_t salen,
|
||||
char * host,
|
||||
socklen_t hostlen,
|
||||
char * serv,
|
||||
socklen_t servlen,
|
||||
int flags
|
||||
)
|
||||
{
|
||||
const struct afd *afd;
|
||||
struct servent *sp;
|
||||
struct hostent *hp;
|
||||
u_short port;
|
||||
int family, i;
|
||||
const char *addr;
|
||||
u_int32_t v4a;
|
||||
char numserv[512];
|
||||
char numaddr[512];
|
||||
|
||||
/* sa is checked below */
|
||||
/* host may be NULL */
|
||||
/* serv may be NULL */
|
||||
|
||||
if (sa == NULL)
|
||||
return EAI_FAIL;
|
||||
|
||||
#ifdef BSD4_4
|
||||
if (sa->sa_len != salen)
|
||||
return EAI_FAIL;
|
||||
#endif
|
||||
|
||||
family = sa->sa_family;
|
||||
for (i = 0; afdl[i].a_af; i++)
|
||||
if (afdl[i].a_af == family) {
|
||||
afd = &afdl[i];
|
||||
goto found;
|
||||
}
|
||||
return EAI_FAMILY;
|
||||
|
||||
found:
|
||||
if (salen != afd->a_socklen)
|
||||
return EAI_FAIL;
|
||||
|
||||
/* network byte order */
|
||||
port = ((const struct sockinet *)(const void *)sa)->si_port;
|
||||
addr = (const char *)(const void *)sa + afd->a_off;
|
||||
|
||||
if (serv == NULL || servlen == 0) {
|
||||
/*
|
||||
* do nothing in this case.
|
||||
* in case you are wondering if "&&" is more correct than
|
||||
* "||" here: rfc2553bis-03 says that serv == NULL OR
|
||||
* servlen == 0 means that the caller does not want the result.
|
||||
*/
|
||||
} else {
|
||||
if (flags & NI_NUMERICSERV)
|
||||
sp = NULL;
|
||||
else {
|
||||
struct servent_data svd;
|
||||
// struct servent sv;
|
||||
|
||||
(void)memset(&svd, 0, sizeof(svd));
|
||||
sp = getservbyport_r(port,
|
||||
(flags & NI_DGRAM) ? "udp" : "tcp", &sv, &svd);
|
||||
endservent_r(&svd);
|
||||
}
|
||||
if (sp) {
|
||||
if (strlen(sp->s_name) + 1 > servlen)
|
||||
return EAI_MEMORY;
|
||||
strlcpy(serv, sp->s_name, servlen);
|
||||
} else {
|
||||
snprintf(numserv, sizeof(numserv), "%u", ntohs(port));
|
||||
if (strlen(numserv) + 1 > servlen)
|
||||
return EAI_MEMORY;
|
||||
strlcpy(serv, numserv, servlen);
|
||||
}
|
||||
}
|
||||
|
||||
switch (sa->sa_family) {
|
||||
case AF_INET:
|
||||
v4a = (u_int32_t)
|
||||
ntohl(((const struct sockaddr_in *)
|
||||
(const void *)sa)->sin_addr.s_addr);
|
||||
if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
|
||||
flags |= NI_NUMERICHOST;
|
||||
v4a >>= IN_CLASSA_NSHIFT;
|
||||
if (v4a == 0)
|
||||
flags |= NI_NUMERICHOST;
|
||||
break;
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
{
|
||||
const struct sockaddr_in6 *sin6;
|
||||
sin6 = (const struct sockaddr_in6 *)(const void *)sa;
|
||||
switch (sin6->sin6_addr.s6_addr[0]) {
|
||||
case 0x00:
|
||||
if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr))
|
||||
;
|
||||
else if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr))
|
||||
;
|
||||
else
|
||||
flags |= NI_NUMERICHOST;
|
||||
break;
|
||||
default:
|
||||
if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
|
||||
flags |= NI_NUMERICHOST;
|
||||
}
|
||||
else if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
|
||||
flags |= NI_NUMERICHOST;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
if (host == NULL || hostlen == 0) {
|
||||
/*
|
||||
* do nothing in this case.
|
||||
* in case you are wondering if "&&" is more correct than
|
||||
* "||" here: rfc2553bis-03 says that host == NULL or
|
||||
* hostlen == 0 means that the caller does not want the result.
|
||||
*/
|
||||
} else if (flags & NI_NUMERICHOST) {
|
||||
size_t numaddrlen;
|
||||
|
||||
/* NUMERICHOST and NAMEREQD conflicts with each other */
|
||||
if (flags & NI_NAMEREQD)
|
||||
return EAI_NONAME;
|
||||
|
||||
switch(afd->a_af) {
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
{
|
||||
int error;
|
||||
|
||||
if ((error = ip6_parsenumeric(sa, addr, host,
|
||||
hostlen, flags)) != 0)
|
||||
return(error);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr))
|
||||
== NULL)
|
||||
return EAI_SYSTEM;
|
||||
numaddrlen = strlen(numaddr);
|
||||
if (numaddrlen + 1 > hostlen) /* don't forget terminator */
|
||||
return EAI_MEMORY;
|
||||
strlcpy(host, numaddr, hostlen);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af);
|
||||
|
||||
if (hp) {
|
||||
#if 0
|
||||
/*
|
||||
* commented out, since "for local host" is not
|
||||
* implemented here - see RFC2553 p30
|
||||
*/
|
||||
if (flags & NI_NOFQDN) {
|
||||
char *p;
|
||||
p = strchr(hp->h_name, '.');
|
||||
if (p)
|
||||
*p = '\0';
|
||||
}
|
||||
#endif
|
||||
if (strlen(hp->h_name) + 1 > hostlen) {
|
||||
return EAI_MEMORY;
|
||||
}
|
||||
strlcpy(host, hp->h_name, hostlen);
|
||||
} else {
|
||||
if (flags & NI_NAMEREQD)
|
||||
return EAI_NONAME;
|
||||
switch(afd->a_af) {
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
{
|
||||
int error;
|
||||
|
||||
if ((error = ip6_parsenumeric(sa, addr, host,
|
||||
hostlen,
|
||||
flags)) != 0)
|
||||
return(error);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
if (inet_ntop(afd->a_af, addr, host,
|
||||
hostlen) == NULL)
|
||||
return EAI_SYSTEM;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
#ifdef INET6
|
||||
static int
|
||||
ip6_parsenumeric(
|
||||
const struct sockaddr *sa,
|
||||
const char *addr,
|
||||
char *host,
|
||||
socklen_t hostlen,
|
||||
int flags
|
||||
)
|
||||
{
|
||||
size_t numaddrlen;
|
||||
char numaddr[512];
|
||||
|
||||
_DIAGASSERT(sa != NULL);
|
||||
_DIAGASSERT(addr != NULL);
|
||||
_DIAGASSERT(host != NULL);
|
||||
|
||||
if (inet_ntop(AF_INET6, addr, numaddr, sizeof(numaddr)) == NULL)
|
||||
return EAI_SYSTEM;
|
||||
|
||||
numaddrlen = strlen(numaddr);
|
||||
if (numaddrlen + 1 > hostlen) /* don't forget terminator */
|
||||
return EAI_OVERFLOW;
|
||||
strlcpy(host, numaddr, hostlen);
|
||||
|
||||
if (((const struct sockaddr_in6 *)(const void *)sa)->sin6_scope_id) {
|
||||
char zonebuf[MAXHOSTNAMELEN];
|
||||
int zonelen;
|
||||
|
||||
zonelen = ip6_sa2str(
|
||||
(const struct sockaddr_in6 *)(const void *)sa,
|
||||
zonebuf, sizeof(zonebuf), flags);
|
||||
if (zonelen < 0)
|
||||
return EAI_OVERFLOW;
|
||||
if ((size_t) zonelen + 1 + numaddrlen + 1 > hostlen)
|
||||
return EAI_OVERFLOW;
|
||||
/* construct <numeric-addr><delim><zoneid> */
|
||||
memcpy(host + numaddrlen + 1, zonebuf,
|
||||
(size_t)zonelen);
|
||||
host[numaddrlen] = SCOPE_DELIMITER;
|
||||
host[numaddrlen + 1 + zonelen] = '\0';
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
ip6_sa2str(
|
||||
const struct sockaddr_in6 *sa6,
|
||||
char *buf,
|
||||
size_t bufsiz,
|
||||
int flags
|
||||
)
|
||||
{
|
||||
unsigned int ifindex;
|
||||
const struct in6_addr *a6;
|
||||
int n;
|
||||
|
||||
_DIAGASSERT(sa6 != NULL);
|
||||
_DIAGASSERT(buf != NULL);
|
||||
|
||||
ifindex = (unsigned int)sa6->sin6_scope_id;
|
||||
a6 = &sa6->sin6_addr;
|
||||
|
||||
#ifdef NI_NUMERICSCOPE
|
||||
if ((flags & NI_NUMERICSCOPE) != 0) {
|
||||
n = snprintf(buf, bufsiz, "%u", sa6->sin6_scope_id);
|
||||
if ((n < 0) || ((size_t)n >= bufsiz))
|
||||
return -1;
|
||||
else
|
||||
return n;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/* if_indextoname() does not take buffer size. not a good api... */
|
||||
if ((IN6_IS_ADDR_LINKLOCAL(a6) || IN6_IS_ADDR_MC_LINKLOCAL(a6)) &&
|
||||
bufsiz >= IF_NAMESIZE) {
|
||||
char *p = if_indextoname(ifindex, buf);
|
||||
if (p) {
|
||||
return(strlen(p));
|
||||
}
|
||||
}
|
||||
#endif // 0
|
||||
|
||||
/* last resort */
|
||||
n = snprintf(buf, bufsiz, "%u", sa6->sin6_scope_id);
|
||||
if (n < 0 || (size_t) n >= bufsiz)
|
||||
return -1;
|
||||
else
|
||||
return n;
|
||||
}
|
||||
#endif /* INET6 */
|
||||
|
||||
|
||||
/*
|
||||
* getnameinfo_link():
|
||||
* Format a link-layer address into a printable format, paying attention to
|
||||
* the interface type.
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
static
|
||||
int
|
||||
getnameinfo_link (
|
||||
const struct sockaddr * sa,
|
||||
socklen_t salen,
|
||||
char * host,
|
||||
socklen_t hostlen,
|
||||
char * serv,
|
||||
socklen_t servlen,
|
||||
int flags
|
||||
)
|
||||
{
|
||||
const struct sockaddr_dl *sdl =
|
||||
(const struct sockaddr_dl *)(const void *)sa;
|
||||
// const struct ieee1394_hwaddr *iha;
|
||||
int n;
|
||||
|
||||
if (serv != NULL && servlen > 0)
|
||||
*serv = '\0';
|
||||
|
||||
if (sdl->sdl_nlen == 0 && sdl->sdl_alen == 0 && sdl->sdl_slen == 0) {
|
||||
n = snprintf(host, hostlen, "link#%u", sdl->sdl_index);
|
||||
if (n < 0 || (socklen_t) n > hostlen) {
|
||||
*host = '\0';
|
||||
return EAI_MEMORY;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
switch (sdl->sdl_type) {
|
||||
#ifdef IFT_ECONET
|
||||
case IFT_ECONET:
|
||||
if (sdl->sdl_alen < 2)
|
||||
return EAI_FAMILY;
|
||||
if (CLLADDR(sdl)[1] == 0)
|
||||
n = snprintf(host, hostlen, "%u", CLLADDR(sdl)[0]);
|
||||
else
|
||||
n = snprintf(host, hostlen, "%u.%u",
|
||||
CLLADDR(sdl)[1], CLLADDR(sdl)[0]);
|
||||
if (n < 0 || (socklen_t) n >= hostlen) {
|
||||
*host = '\0';
|
||||
return EAI_MEMORY;
|
||||
} else
|
||||
return 0;
|
||||
#endif
|
||||
case IFT_IEEE1394:
|
||||
if (sdl->sdl_alen < sizeof(iha->iha_uid))
|
||||
return EAI_FAMILY;
|
||||
iha =
|
||||
(const struct ieee1394_hwaddr *)(const void *)CLLADDR(sdl);
|
||||
return hexname(iha->iha_uid, sizeof(iha->iha_uid),
|
||||
host, hostlen);
|
||||
/*
|
||||
* The following have zero-length addresses.
|
||||
* IFT_ATM (net/if_atmsubr.c)
|
||||
* IFT_FAITH (net/if_faith.c)
|
||||
* IFT_GIF (net/if_gif.c)
|
||||
* IFT_LOOP (net/if_loop.c)
|
||||
* IFT_PPP (net/if_ppp.c, net/if_spppsubr.c)
|
||||
* IFT_SLIP (net/if_sl.c, net/if_strip.c)
|
||||
* IFT_STF (net/if_stf.c)
|
||||
* IFT_L2VLAN (net/if_vlan.c)
|
||||
* IFT_PROPVIRTUAL (net/if_bridge.h>
|
||||
*/
|
||||
/*
|
||||
* The following use IPv4 addresses as link-layer addresses:
|
||||
* IFT_OTHER (net/if_gre.c)
|
||||
*/
|
||||
case IFT_ARCNET: /* default below is believed correct for all these. */
|
||||
case IFT_ETHER:
|
||||
case IFT_FDDI:
|
||||
case IFT_HIPPI:
|
||||
case IFT_ISO88025:
|
||||
default:
|
||||
#endif // 0
|
||||
return hexname((const u_int8_t *)CLLADDR(sdl),
|
||||
(size_t)sdl->sdl_alen, host, hostlen);
|
||||
// }
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
hexname(
|
||||
const u_int8_t * cp,
|
||||
size_t len,
|
||||
char * host,
|
||||
socklen_t hostlen
|
||||
)
|
||||
{
|
||||
int n;
|
||||
size_t i;
|
||||
char *outp = host;
|
||||
|
||||
*outp = '\0';
|
||||
for (i = 0; i < len; i++) {
|
||||
n = snprintf(outp, hostlen, "%s%02x",
|
||||
i ? ":" : "", cp[i]);
|
||||
if (n < 0 || (socklen_t) n >= hostlen) {
|
||||
*host = '\0';
|
||||
return EAI_MEMORY;
|
||||
}
|
||||
outp += n;
|
||||
hostlen -= n;
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -34,7 +34,9 @@
|
|||
Service.c
|
||||
Socket.c
|
||||
Tcp4.c
|
||||
Tcp6.c
|
||||
Udp4.c
|
||||
Udp6.c
|
||||
UseEfiSocketLib.c
|
||||
|
||||
[Packages]
|
||||
|
@ -52,9 +54,15 @@
|
|||
[Protocols]
|
||||
gEfiIp4ProtocolGuid
|
||||
gEfiIp4ServiceBindingProtocolGuid
|
||||
gEfiIp6ProtocolGuid
|
||||
gEfiIp6ServiceBindingProtocolGuid
|
||||
gEfiTcp4ProtocolGuid
|
||||
gEfiTcp4ServiceBindingProtocolGuid
|
||||
gEfiTcp6ProtocolGuid
|
||||
gEfiTcp6ServiceBindingProtocolGuid
|
||||
gEfiUdp4ProtocolGuid
|
||||
gEfiUdp4ServiceBindingProtocolGuid
|
||||
gEfiUdp6ProtocolGuid
|
||||
gEfiUdp6ServiceBindingProtocolGuid
|
||||
gEfiSocketProtocolGuid
|
||||
gEfiSocketServiceBindingProtocolGuid
|
||||
|
|
|
@ -383,6 +383,7 @@ EslIp4PortAllocate (
|
|||
//
|
||||
pPort->pfnConfigure = (PFN_NET_CONFIGURE)pPort->pProtocol.IPv4->Configure;
|
||||
pPort->pfnRxCancel = (PFN_NET_IO_START)pPort->pProtocol.IPv4->Cancel;
|
||||
pPort->pfnRxPoll = (PFN_NET_POLL)pPort->pProtocol.IPv4->Poll;
|
||||
pPort->pfnRxStart = (PFN_NET_IO_START)pPort->pProtocol.IPv4->Receive;
|
||||
pPort->pfnTxStart = (PFN_NET_IO_START)pPort->pProtocol.IPv4->Transmit;
|
||||
|
||||
|
|
|
@ -481,6 +481,14 @@ CONST ESL_SOCKET_BINDING cEslSocketBinding[] = {
|
|||
4, // RX buffers
|
||||
4, // TX buffers
|
||||
4 }, // TX Oob buffers
|
||||
{ L"Tcp6",
|
||||
&gEfiTcp6ServiceBindingProtocolGuid,
|
||||
&gEfiTcp6ProtocolGuid,
|
||||
&mEslTcp6ServiceGuid,
|
||||
OFFSET_OF ( ESL_LAYER, pTcp6List ),
|
||||
4, // RX buffers
|
||||
4, // TX buffers
|
||||
4 }, // TX Oob buffers
|
||||
{ L"Udp4",
|
||||
&gEfiUdp4ServiceBindingProtocolGuid,
|
||||
&gEfiUdp4ProtocolGuid,
|
||||
|
@ -488,6 +496,14 @@ CONST ESL_SOCKET_BINDING cEslSocketBinding[] = {
|
|||
OFFSET_OF ( ESL_LAYER, pUdp4List ),
|
||||
4, // RX buffers
|
||||
4, // TX buffers
|
||||
0 }, // TX Oob buffers
|
||||
{ L"Udp6",
|
||||
&gEfiUdp6ServiceBindingProtocolGuid,
|
||||
&gEfiUdp6ProtocolGuid,
|
||||
&mEslUdp6ServiceGuid,
|
||||
OFFSET_OF ( ESL_LAYER, pUdp6List ),
|
||||
4, // RX buffers
|
||||
4, // TX buffers
|
||||
0 } // TX Oob buffers
|
||||
};
|
||||
|
||||
|
@ -516,11 +532,11 @@ CONST int cEslAfInetApiSize = DIM ( cEslAfInetApi );
|
|||
**/
|
||||
CONST ESL_PROTOCOL_API * cEslAfInet6Api[] = {
|
||||
NULL, // 0
|
||||
NULL, // SOCK_STREAM
|
||||
NULL, // SOCK_DGRAM
|
||||
&cEslTcp6Api, // SOCK_STREAM
|
||||
&cEslUdp6Api, // SOCK_DGRAM
|
||||
NULL, // SOCK_RAW
|
||||
NULL, // SOCK_RDM
|
||||
NULL // SOCK_SEQPACKET
|
||||
&cEslTcp6Api // SOCK_SEQPACKET
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -603,6 +619,7 @@ EslSocket (
|
|||
// Validate the domain value
|
||||
//
|
||||
if (( AF_INET != domain )
|
||||
&& ( AF_INET6 != domain )
|
||||
&& ( AF_LOCAL != domain )) {
|
||||
DEBUG (( DEBUG_ERROR | DEBUG_SOCKET,
|
||||
"ERROR - Invalid domain value\r\n" ));
|
||||
|
@ -1789,6 +1806,11 @@ EslSocketConnect (
|
|||
if ( EFI_NOT_READY != Status ) {
|
||||
if ( !EFI_ERROR ( Status )) {
|
||||
pSocket->State = SOCKET_STATE_CONNECTED;
|
||||
|
||||
//
|
||||
// Start the receive operations
|
||||
//
|
||||
EslSocketRxStart ( pSocket->pPortList );
|
||||
}
|
||||
else {
|
||||
pSocket->State = SOCKET_STATE_BOUND;
|
||||
|
@ -1980,7 +2002,8 @@ EslSocketGetLocalAddress (
|
|||
//
|
||||
// Verify the socket state
|
||||
//
|
||||
if ( SOCKET_STATE_CONNECTED == pSocket->State ) {
|
||||
if (( SOCKET_STATE_CONNECTED == pSocket->State )
|
||||
|| ( SOCKET_STATE_LISTENING == pSocket->State )) {
|
||||
//
|
||||
// Verify the API
|
||||
//
|
||||
|
@ -3096,7 +3119,7 @@ EslSocketPacketAllocate (
|
|||
LengthInBytes,
|
||||
(VOID **)&pPacket );
|
||||
if ( !EFI_ERROR ( Status )) {
|
||||
DEBUG (( DebugFlags | DEBUG_POOL | DEBUG_INIT,
|
||||
DEBUG (( DebugFlags | DEBUG_POOL,
|
||||
"0x%08x: Allocate pPacket, %d bytes\r\n",
|
||||
pPacket,
|
||||
LengthInBytes ));
|
||||
|
@ -3210,6 +3233,7 @@ EslSocketPoll (
|
|||
short DetectedEvents;
|
||||
ESL_SOCKET * pSocket;
|
||||
EFI_STATUS Status;
|
||||
EFI_TPL TplPrevious;
|
||||
short ValidEvents;
|
||||
|
||||
DEBUG (( DEBUG_POLL, "Entering SocketPoll\r\n" ));
|
||||
|
@ -3247,6 +3271,22 @@ EslSocketPoll (
|
|||
Events & ( ~ValidEvents )));
|
||||
}
|
||||
else {
|
||||
//
|
||||
// Synchronize with the socket layer
|
||||
//
|
||||
RAISE_TPL ( TplPrevious, TPL_SOCKETS );
|
||||
|
||||
//
|
||||
// Increase the network performance by extending the
|
||||
// polling (idle) loop down into the LAN driver
|
||||
//
|
||||
EslSocketRxPoll ( pSocket );
|
||||
|
||||
//
|
||||
// Release the socket layer synchronization
|
||||
//
|
||||
RESTORE_TPL ( TplPrevious );
|
||||
|
||||
//
|
||||
// Check for pending connections
|
||||
//
|
||||
|
@ -4366,6 +4406,11 @@ EslSocketReceive (
|
|||
// Verify that the socket is connected
|
||||
//
|
||||
if ( SOCKET_STATE_CONNECTED == pSocket->State ) {
|
||||
//
|
||||
// Poll the network to increase performance
|
||||
//
|
||||
EslSocketRxPoll ( pSocket );
|
||||
|
||||
//
|
||||
// Locate the port
|
||||
//
|
||||
|
@ -4847,6 +4892,49 @@ EslSocketRxComplete (
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
Poll a socket for pending receive activity.
|
||||
|
||||
This routine is called at elivated TPL and extends the idle
|
||||
loop which polls a socket down into the LAN driver layer to
|
||||
determine if there is any receive activity.
|
||||
|
||||
The ::EslSocketPoll, ::EslSocketReceive and ::EslSocketTransmit
|
||||
routines call this routine when there is nothing to do.
|
||||
|
||||
@param [in] pSocket Address of an ::EFI_SOCKET structure.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EslSocketRxPoll (
|
||||
IN ESL_SOCKET * pSocket
|
||||
)
|
||||
{
|
||||
ESL_PORT * pPort;
|
||||
|
||||
DEBUG (( DEBUG_POLL, "Entering EslSocketRxPoll\r\n" ));
|
||||
|
||||
//
|
||||
// Increase the network performance by extending the
|
||||
// polling (idle) loop down into the LAN driver
|
||||
//
|
||||
pPort = pSocket->pPortList;
|
||||
while ( NULL != pPort ) {
|
||||
//
|
||||
// Poll the LAN adapter
|
||||
//
|
||||
pPort->pfnRxPoll ( pPort->pProtocol.v );
|
||||
|
||||
//
|
||||
// Locate the next LAN adapter
|
||||
//
|
||||
pPort = pPort->pLinkSocket;
|
||||
}
|
||||
|
||||
DEBUG (( DEBUG_POLL, "Exiting EslSocketRxPoll\r\n" ));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Start a receive operation
|
||||
|
||||
|
@ -5291,6 +5379,11 @@ EslSocketTransmit (
|
|||
//
|
||||
RAISE_TPL ( TplPrevious, TPL_SOCKETS );
|
||||
|
||||
//
|
||||
// Poll the network to increase performance
|
||||
//
|
||||
EslSocketRxPoll ( pSocket );
|
||||
|
||||
//
|
||||
// Attempt to buffer the packet for transmission
|
||||
//
|
||||
|
|
|
@ -137,6 +137,26 @@ typedef struct
|
|||
} ESL_TCP4_TX_DATA;
|
||||
|
||||
|
||||
/**
|
||||
Receive context for SOCK_STREAM and SOCK_SEQPACKET sockets using TCPv6.
|
||||
**/
|
||||
typedef struct
|
||||
{
|
||||
EFI_TCP6_RECEIVE_DATA RxData; ///< Receive operation description
|
||||
UINT8 Buffer[ RX_PACKET_DATA ]; ///< Data buffer
|
||||
} ESL_TCP6_RX_DATA;
|
||||
|
||||
|
||||
/**
|
||||
Transmit context for SOCK_STREAM and SOCK_SEQPACKET sockets using TCPv6.
|
||||
**/
|
||||
typedef struct
|
||||
{
|
||||
EFI_TCP6_TRANSMIT_DATA TxData; ///< Transmit operation description
|
||||
UINT8 Buffer[ 1 ]; ///< Data buffer
|
||||
} ESL_TCP6_TX_DATA;
|
||||
|
||||
|
||||
/**
|
||||
Receive context for SOCK_DGRAM sockets using UDPv4.
|
||||
**/
|
||||
|
@ -159,6 +179,28 @@ typedef struct
|
|||
} ESL_UDP4_TX_DATA;
|
||||
|
||||
|
||||
/**
|
||||
Receive context for SOCK_DGRAM sockets using UDPv6.
|
||||
**/
|
||||
typedef struct
|
||||
{
|
||||
EFI_UDP6_SESSION_DATA Session; ///< Remote network address
|
||||
EFI_UDP6_RECEIVE_DATA * pRxData; ///< Receive operation description
|
||||
} ESL_UDP6_RX_DATA;
|
||||
|
||||
|
||||
/**
|
||||
Transmit context for SOCK_DGRAM sockets using UDPv6.
|
||||
**/
|
||||
typedef struct
|
||||
{
|
||||
EFI_UDP6_SESSION_DATA Session; ///< Remote network address
|
||||
EFI_UDP6_TRANSMIT_DATA TxData; ///< Transmit operation description
|
||||
UINTN RetransmitCount; ///< Retransmit to handle ARP negotiation
|
||||
UINT8 Buffer[ 1 ]; ///< Data buffer
|
||||
} ESL_UDP6_TX_DATA;
|
||||
|
||||
|
||||
/**
|
||||
Network specific context for transmit and receive packets.
|
||||
**/
|
||||
|
@ -172,8 +214,12 @@ typedef struct _ESL_PACKET {
|
|||
ESL_IP4_TX_DATA Ip4Tx; ///< Transmit operation description
|
||||
ESL_TCP4_RX_DATA Tcp4Rx; ///< Receive operation description
|
||||
ESL_TCP4_TX_DATA Tcp4Tx; ///< Transmit operation description
|
||||
ESL_TCP6_RX_DATA Tcp6Rx; ///< Receive operation description
|
||||
ESL_TCP6_TX_DATA Tcp6Tx; ///< Transmit operation description
|
||||
ESL_UDP4_RX_DATA Udp4Rx; ///< Receive operation description
|
||||
ESL_UDP4_TX_DATA Udp4Tx; ///< Transmit operation description
|
||||
ESL_UDP6_RX_DATA Udp6Rx; ///< Receive operation description
|
||||
ESL_UDP6_TX_DATA Udp6Tx; ///< Transmit operation description
|
||||
} Op; ///< Network specific context
|
||||
} GCC_ESL_PACKET;
|
||||
|
||||
|
@ -217,8 +263,12 @@ typedef struct _ESL_IO_MGMT {
|
|||
EFI_IP4_COMPLETION_TOKEN Ip4Tx; ///< IP4 transmit token
|
||||
EFI_TCP4_IO_TOKEN Tcp4Rx; ///< TCP4 receive token
|
||||
EFI_TCP4_IO_TOKEN Tcp4Tx; ///< TCP4 transmit token
|
||||
EFI_TCP6_IO_TOKEN Tcp6Rx; ///< TCP6 receive token
|
||||
EFI_TCP6_IO_TOKEN Tcp6Tx; ///< TCP6 transmit token
|
||||
EFI_UDP4_COMPLETION_TOKEN Udp4Rx; ///< UDP4 receive token
|
||||
EFI_UDP4_COMPLETION_TOKEN Udp4Tx; ///< UDP4 transmit token
|
||||
EFI_UDP6_COMPLETION_TOKEN Udp6Rx; ///< UDP6 receive token
|
||||
EFI_UDP6_COMPLETION_TOKEN Udp6Tx; ///< UDP6 transmit token
|
||||
} Token; ///< Completion token for the network operation
|
||||
} GCC_IO_MGMT;
|
||||
|
||||
|
@ -256,6 +306,26 @@ typedef struct {
|
|||
EFI_TCP4_CLOSE_TOKEN CloseToken; ///< Close control
|
||||
} ESL_TCP4_CONTEXT;
|
||||
|
||||
/**
|
||||
TCP6 context structure
|
||||
|
||||
The driver uses this structure to manage the TCP6 connections.
|
||||
**/
|
||||
typedef struct {
|
||||
//
|
||||
// TCP6 context
|
||||
//
|
||||
EFI_TCP6_CONFIG_DATA ConfigData; ///< TCP6 configuration data
|
||||
EFI_TCP6_OPTION Option; ///< TCP6 port options
|
||||
|
||||
//
|
||||
// Tokens
|
||||
//
|
||||
EFI_TCP6_LISTEN_TOKEN ListenToken; ///< Listen control
|
||||
EFI_TCP6_CONNECTION_TOKEN ConnectToken; ///< Connection control
|
||||
EFI_TCP6_CLOSE_TOKEN CloseToken; ///< Close control
|
||||
} ESL_TCP6_CONTEXT;
|
||||
|
||||
/**
|
||||
UDP4 context structure
|
||||
|
||||
|
@ -268,6 +338,18 @@ typedef struct {
|
|||
EFI_UDP4_CONFIG_DATA ConfigData; ///< UDP4 configuration data
|
||||
} ESL_UDP4_CONTEXT;
|
||||
|
||||
/**
|
||||
UDP6 context structure
|
||||
|
||||
The driver uses this structure to manage the UDP6 connections.
|
||||
**/
|
||||
typedef struct {
|
||||
//
|
||||
// UDP6 context
|
||||
//
|
||||
EFI_UDP6_CONFIG_DATA ConfigData; ///< UDP6 configuration data
|
||||
} ESL_UDP6_CONTEXT;
|
||||
|
||||
|
||||
/**
|
||||
Configure the network layer.
|
||||
|
@ -301,6 +383,21 @@ EFI_STATUS
|
|||
IN VOID * pToken
|
||||
);
|
||||
|
||||
/**
|
||||
Poll the LAN adapter for receive packets.
|
||||
|
||||
@param [in] pProtocol Protocol structure address
|
||||
@param [in] pToken Completion token address
|
||||
|
||||
@return Returns EFI_SUCCESS if the operation is successfully
|
||||
started.
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(* PFN_NET_POLL) (
|
||||
IN VOID * pProtocol
|
||||
);
|
||||
|
||||
/**
|
||||
Port control structure
|
||||
|
||||
|
@ -353,6 +450,7 @@ typedef struct _ESL_PORT {
|
|||
// Receive data management
|
||||
//
|
||||
PFN_NET_IO_START pfnRxCancel; ///< Cancel a receive on the network
|
||||
PFN_NET_POLL pfnRxPoll; ///< Poll the LAN adapter for receive packets
|
||||
PFN_NET_IO_START pfnRxStart; ///< Start a receive on the network
|
||||
ESL_IO_MGMT * pRxActive; ///< Active receive operation queue
|
||||
ESL_IO_MGMT * pRxFree; ///< Free structure queue
|
||||
|
@ -364,12 +462,16 @@ typedef struct _ESL_PORT {
|
|||
VOID * v; ///< VOID pointer
|
||||
EFI_IP4_PROTOCOL * IPv4; ///< IP4 protocol pointer
|
||||
EFI_TCP4_PROTOCOL * TCPv4; ///< TCP4 protocol pointer
|
||||
EFI_TCP6_PROTOCOL * TCPv6; ///< TCP6 protocol pointer
|
||||
EFI_UDP4_PROTOCOL * UDPv4; ///< UDP4 protocol pointer
|
||||
EFI_UDP6_PROTOCOL * UDPv6; ///< UDP6 protocol pointer
|
||||
} pProtocol; ///< Protocol structure address
|
||||
union {
|
||||
ESL_IP4_CONTEXT Ip4; ///< IPv4 management data
|
||||
ESL_TCP4_CONTEXT Tcp4; ///< TCPv4 management data
|
||||
ESL_TCP6_CONTEXT Tcp6; ///< TCPv6 management data
|
||||
ESL_UDP4_CONTEXT Udp4; ///< UDPv4 management data
|
||||
ESL_UDP6_CONTEXT Udp6; ///< UDPv6 management data
|
||||
} Context; ///< Network specific context
|
||||
}GCC_ESL_PORT;
|
||||
|
||||
|
@ -975,7 +1077,9 @@ typedef struct {
|
|||
//
|
||||
ESL_SERVICE * pIp4List; ///< List of Ip4 services
|
||||
ESL_SERVICE * pTcp4List; ///< List of Tcp4 services
|
||||
ESL_SERVICE * pTcp6List; ///< List of Tcp6 services
|
||||
ESL_SERVICE * pUdp4List; ///< List of Udp4 services
|
||||
ESL_SERVICE * pUdp6List; ///< List of Udp6 services
|
||||
|
||||
//
|
||||
// Socket management
|
||||
|
@ -992,8 +1096,11 @@ typedef struct {
|
|||
extern ESL_LAYER mEslLayer;
|
||||
|
||||
extern CONST ESL_PROTOCOL_API cEslIp4Api;
|
||||
extern CONST ESL_PROTOCOL_API cEslIp6Api;
|
||||
extern CONST ESL_PROTOCOL_API cEslTcp4Api;
|
||||
extern CONST ESL_PROTOCOL_API cEslTcp6Api;
|
||||
extern CONST ESL_PROTOCOL_API cEslUdp4Api;
|
||||
extern CONST ESL_PROTOCOL_API cEslUdp6Api;
|
||||
|
||||
extern CONST EFI_SERVICE_BINDING_PROTOCOL mEfiServiceBinding;
|
||||
|
||||
|
@ -1423,6 +1530,24 @@ EslSocketRxComplete (
|
|||
IN BOOLEAN bUrgent
|
||||
);
|
||||
|
||||
/**
|
||||
Poll a socket for pending receive activity.
|
||||
|
||||
This routine is called at elivated TPL and extends the idle
|
||||
loop which polls a socket down into the LAN driver layer to
|
||||
determine if there is any receive activity.
|
||||
|
||||
The ::EslSocketPoll, ::EslSocketReceive and ::EslSocketTransmit
|
||||
routines call this routine when there is nothing to do.
|
||||
|
||||
@param [in] pSocket Address of an ::EFI_SOCKET structure.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EslSocketRxPoll (
|
||||
IN ESL_SOCKET * pSocket
|
||||
);
|
||||
|
||||
/**
|
||||
Start a receive operation
|
||||
|
||||
|
|
|
@ -1307,6 +1307,7 @@ EslTcp4PortAllocate (
|
|||
// pPort->pfnRxCancel = NULL; since the UEFI implementation returns EFI_UNSUPPORTED
|
||||
//
|
||||
pPort->pfnConfigure = (PFN_NET_CONFIGURE)pPort->pProtocol.TCPv4->Configure;
|
||||
pPort->pfnRxPoll = (PFN_NET_POLL)pPort->pProtocol.TCPv4->Poll;
|
||||
pPort->pfnRxStart = (PFN_NET_IO_START)pPort->pProtocol.TCPv4->Receive;
|
||||
pPort->pfnTxStart = (PFN_NET_IO_START)pPort->pProtocol.TCPv4->Transmit;
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -253,6 +253,7 @@ EslUdp4PortAllocate (
|
|||
//
|
||||
pPort->pfnConfigure = (PFN_NET_CONFIGURE)pPort->pProtocol.UDPv4->Configure;
|
||||
pPort->pfnRxCancel = (PFN_NET_IO_START)pPort->pProtocol.UDPv4->Cancel;
|
||||
pPort->pfnRxPoll = (PFN_NET_POLL)pPort->pProtocol.UDPv4->Poll;
|
||||
pPort->pfnRxStart = (PFN_NET_IO_START)pPort->pProtocol.UDPv4->Receive;
|
||||
pPort->pfnTxStart = (PFN_NET_IO_START)pPort->pProtocol.UDPv4->Transmit;
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -28,6 +28,14 @@ CONST EFI_GUID mEslIp4ServiceGuid = {
|
|||
};
|
||||
|
||||
|
||||
/**
|
||||
Tag GUID - IPv6 in use by an application using EfiSocketLib
|
||||
**/
|
||||
CONST EFI_GUID mEslIp6ServiceGuid = {
|
||||
0xc51b2761, 0xc476, 0x45fe, { 0xbe, 0x61, 0xba, 0x4b, 0xcc, 0x32, 0xf2, 0x34 }
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Tag GUID - TCPv4 in use by an application using EfiSocketLib
|
||||
**/
|
||||
|
@ -36,6 +44,14 @@ CONST EFI_GUID mEslTcp4ServiceGuid = {
|
|||
};
|
||||
|
||||
|
||||
/**
|
||||
Tag GUID - TCPv6 in use by an application using EfiSocketLib
|
||||
**/
|
||||
CONST EFI_GUID mEslTcp6ServiceGuid = {
|
||||
0x279858a4, 0x4e9e, 0x4e53, { 0x93, 0x22, 0xf2, 0x54, 0xe0, 0x7e, 0xef, 0xd4 }
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Tag GUID - UDPv4 in use by an application using EfiSocketLib
|
||||
**/
|
||||
|
@ -44,6 +60,14 @@ CONST EFI_GUID mEslUdp4ServiceGuid = {
|
|||
};
|
||||
|
||||
|
||||
/**
|
||||
Tag GUID - UDPv6 in use by an application using EfiSocketLib
|
||||
**/
|
||||
CONST EFI_GUID mEslUdp6ServiceGuid = {
|
||||
0xaa4af677, 0x6efe, 0x477c, { 0x96, 0x68, 0xe8, 0x13, 0x9d, 0x2, 0xfd, 0x9b }
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Connect to the EFI socket library
|
||||
|
||||
|
@ -252,10 +276,8 @@ EslServiceNetworkDisconnect (
|
|||
NULL,
|
||||
&HandleCount,
|
||||
&pHandles );
|
||||
if ( EFI_ERROR ( Status )) {
|
||||
break;
|
||||
}
|
||||
if ( NULL != pHandles ) {
|
||||
if (( !EFI_ERROR ( Status ))
|
||||
&& ( NULL != pHandles )) {
|
||||
//
|
||||
// Attempt to disconnect from this network adapter
|
||||
//
|
||||
|
@ -277,6 +299,7 @@ EslServiceNetworkDisconnect (
|
|||
// Set the next network protocol
|
||||
//
|
||||
pSocketBinding += 1;
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -26,7 +26,9 @@
|
|||
#include <Protocol/EfiSocket.h>
|
||||
#include <Protocol/ServiceBinding.h>
|
||||
#include <Protocol/Tcp4.h>
|
||||
#include <Protocol/Tcp6.h>
|
||||
#include <Protocol/Udp4.h>
|
||||
#include <Protocol/Udp6.h>
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
|
@ -154,8 +156,11 @@ typedef struct {
|
|||
//------------------------------------------------------------------------------
|
||||
|
||||
extern CONST EFI_GUID mEslIp4ServiceGuid; ///< Tag GUID for the IPv4 layer
|
||||
extern CONST EFI_GUID mEslIp6ServiceGuid; ///< Tag GUID for the IPv6 layer
|
||||
extern CONST EFI_GUID mEslTcp4ServiceGuid; ///< Tag GUID for the TCPv4 layer
|
||||
extern CONST EFI_GUID mEslTcp6ServiceGuid; ///< Tag GUID for the TCPv6 layer
|
||||
extern CONST EFI_GUID mEslUdp4ServiceGuid; ///< Tag GUID for the UDPv4 layer
|
||||
extern CONST EFI_GUID mEslUdp6ServiceGuid; ///< Tag GUID for the UDPv6 layer
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Data
|
||||
|
|
|
@ -77,8 +77,8 @@ struct sockaddr_dl {
|
|||
#include <sys/EfiCdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
void link_addr __P((const char *, struct sockaddr_dl *));
|
||||
char *link_ntoa __P((const struct sockaddr_dl *));
|
||||
void link_addr (const char *, struct sockaddr_dl *);
|
||||
char *link_ntoa (const struct sockaddr_dl *);
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !KERNEL */
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
/* $NetBSD: servent.h,v 1.3 2008/04/28 20:23:00 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
struct servent_data {
|
||||
void *db;
|
||||
struct servent serv;
|
||||
char **aliases;
|
||||
size_t maxaliases;
|
||||
int flags;
|
||||
#define _SV_STAYOPEN 1
|
||||
#define _SV_DB 2
|
||||
#define _SV_FIRST 4
|
||||
char *line;
|
||||
void *dummy;
|
||||
};
|
||||
|
||||
#if 0
|
||||
struct servent *getservent_r(struct servent *, struct servent_data *);
|
||||
struct servent *getservbyname_r(const char *, const char *,
|
||||
struct servent *, struct servent_data *);
|
||||
struct servent *getservbyport_r(int, const char *,
|
||||
struct servent *, struct servent_data *);
|
||||
void setservent_r(int, struct servent_data *);
|
||||
void endservent_r(struct servent_data *);
|
||||
#endif // 0
|
||||
|
||||
int _servent_open(struct servent_data *);
|
||||
void _servent_close(struct servent_data *);
|
||||
int _servent_getline(struct servent_data *);
|
||||
struct servent *_servent_parseline(struct servent_data *, struct servent *);
|
|
@ -0,0 +1,237 @@
|
|||
/* $NetBSD: nsswitch.h,v 1.20 2008/04/28 20:22:54 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997, 1998, 1999, 2004 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Luke Mewburn.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _NSSWITCH_H
|
||||
#define _NSSWITCH_H 1
|
||||
|
||||
/*
|
||||
* Don't use va_list in prototypes. va_list is typedef'd in two places
|
||||
* (<machine/varargs.h> and <machine/stdarg.h>), so if we include one of
|
||||
* them here we may collide with the utility's includes. It's unreasonable
|
||||
* for utilities to have to include one of them to include nsswitch.h, so
|
||||
* we get _BSD_VA_LIST_ from <machine/ansi.h> and use it.
|
||||
*/
|
||||
#include <machine/ansi.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define NSS_MODULE_INTERFACE_VERSION 0
|
||||
|
||||
#ifndef _PATH_NS_CONF
|
||||
#define _PATH_NS_CONF "/etc/nsswitch.conf"
|
||||
#endif
|
||||
|
||||
#define NS_CONTINUE 0
|
||||
#define NS_RETURN 1
|
||||
|
||||
/*
|
||||
* Layout of:
|
||||
* uint32_t ns_src.flags
|
||||
*/
|
||||
/* nsswitch.conf status codes and nsdispatch(3) return values */
|
||||
#define NS_SUCCESS (1<<0) /* entry was found */
|
||||
#define NS_UNAVAIL (1<<1) /* source not responding, or corrupt */
|
||||
#define NS_NOTFOUND (1<<2) /* source responded 'no such entry' */
|
||||
#define NS_TRYAGAIN (1<<3) /* source busy, may respond to retrys */
|
||||
#define NS_STATUSMASK 0x000000ff /* bitmask to get the status flags */
|
||||
|
||||
/* internal nsdispatch(3) flags; not settable in nsswitch.conf(5) */
|
||||
#define NS_FORCEALL (1<<8) /* force all methods to be invoked; */
|
||||
|
||||
/*
|
||||
* Currently implemented sources.
|
||||
*/
|
||||
#define NSSRC_FILES "files" /* local files */
|
||||
#define NSSRC_DNS "dns" /* DNS; IN for hosts, HS for others */
|
||||
#define NSSRC_NIS "nis" /* YP/NIS */
|
||||
#define NSSRC_COMPAT "compat" /* passwd,group in YP compat mode */
|
||||
|
||||
/*
|
||||
* Currently implemented databases.
|
||||
*/
|
||||
#define NSDB_HOSTS "hosts"
|
||||
#define NSDB_GROUP "group"
|
||||
#define NSDB_GROUP_COMPAT "group_compat"
|
||||
#define NSDB_NETGROUP "netgroup"
|
||||
#define NSDB_NETWORKS "networks"
|
||||
#define NSDB_PASSWD "passwd"
|
||||
#define NSDB_PASSWD_COMPAT "passwd_compat"
|
||||
#define NSDB_SHELLS "shells"
|
||||
|
||||
/*
|
||||
* Suggested databases to implement.
|
||||
*/
|
||||
#define NSDB_ALIASES "aliases"
|
||||
#define NSDB_AUTH "auth"
|
||||
#define NSDB_AUTOMOUNT "automount"
|
||||
#define NSDB_BOOTPARAMS "bootparams"
|
||||
#define NSDB_ETHERS "ethers"
|
||||
#define NSDB_EXPORTS "exports"
|
||||
#define NSDB_NETMASKS "netmasks"
|
||||
#define NSDB_PHONES "phones"
|
||||
#define NSDB_PRINTCAP "printcap"
|
||||
#define NSDB_PROTOCOLS "protocols"
|
||||
#define NSDB_REMOTE "remote"
|
||||
#define NSDB_RPC "rpc"
|
||||
#define NSDB_SENDMAILVARS "sendmailvars"
|
||||
#define NSDB_SERVICES "services"
|
||||
#define NSDB_TERMCAP "termcap"
|
||||
#define NSDB_TTYS "ttys"
|
||||
|
||||
/*
|
||||
* ns_dtab `callback' function signature.
|
||||
*/
|
||||
typedef int (*nss_method)(void *, void *, _BSD_VA_LIST_);
|
||||
|
||||
/*
|
||||
* ns_dtab - `nsswitch dispatch table'
|
||||
* Contains an entry for each source and the appropriate function to call.
|
||||
*/
|
||||
typedef struct {
|
||||
const char *src;
|
||||
nss_method callback;
|
||||
void *cb_data;
|
||||
} ns_dtab;
|
||||
|
||||
/*
|
||||
* Macros to help build an ns_dtab[]
|
||||
*/
|
||||
#define NS_FILES_CB(F,C) { NSSRC_FILES, F, __UNCONST(C) },
|
||||
#define NS_COMPAT_CB(F,C) { NSSRC_COMPAT, F, __UNCONST(C) },
|
||||
|
||||
#ifdef HESIOD
|
||||
# define NS_DNS_CB(F,C) { NSSRC_DNS, F, __UNCONST(C) },
|
||||
#else
|
||||
# define NS_DNS_CB(F,C)
|
||||
#endif
|
||||
|
||||
#ifdef YP
|
||||
# define NS_NIS_CB(F,C) { NSSRC_NIS, F, __UNCONST(C) },
|
||||
#else
|
||||
# define NS_NIS_CB(F,C)
|
||||
#endif
|
||||
#define NS_NULL_CB { NULL, NULL, NULL },
|
||||
|
||||
/*
|
||||
* ns_src - `nsswitch source'
|
||||
* Used by the nsparser routines to store a mapping between a source
|
||||
* and its dispatch control flags for a given database.
|
||||
*/
|
||||
typedef struct {
|
||||
const char *name;
|
||||
uint32_t flags;
|
||||
} ns_src;
|
||||
|
||||
|
||||
/*
|
||||
* Default sourcelists (if nsswitch.conf is missing, corrupt,
|
||||
* or the requested database doesn't have an entry)
|
||||
*/
|
||||
extern const ns_src __nsdefaultsrc[];
|
||||
extern const ns_src __nsdefaultcompat[];
|
||||
extern const ns_src __nsdefaultcompat_forceall[];
|
||||
extern const ns_src __nsdefaultfiles[];
|
||||
extern const ns_src __nsdefaultfiles_forceall[];
|
||||
extern const ns_src __nsdefaultnis[];
|
||||
extern const ns_src __nsdefaultnis_forceall[];
|
||||
|
||||
|
||||
/*
|
||||
* ns_mtab - `nsswitch method table'
|
||||
* An nsswitch module provides a mapping from (database name, method name)
|
||||
* tuples to the nss_method and associated callback data. Effectively,
|
||||
* ns_dtab, but used for dynamically loaded modules.
|
||||
*/
|
||||
typedef struct {
|
||||
const char *database;
|
||||
const char *name;
|
||||
nss_method method;
|
||||
void *mdata;
|
||||
} ns_mtab;
|
||||
|
||||
/*
|
||||
* nss_module_register_fn - module registration function
|
||||
* called at module load
|
||||
* nss_module_unregister_fn - module un-registration function
|
||||
* called at module unload
|
||||
*/
|
||||
typedef void (*nss_module_unregister_fn)(ns_mtab *, u_int);
|
||||
typedef ns_mtab *(*nss_module_register_fn)(const char *, u_int *,
|
||||
nss_module_unregister_fn *);
|
||||
|
||||
#ifdef _NS_PRIVATE
|
||||
|
||||
/*
|
||||
* Private data structures for back-end nsswitch implementation.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ns_dbt - `nsswitch database thang'
|
||||
* For each database in /etc/nsswitch.conf there is a ns_dbt, with its
|
||||
* name and a list of ns_src's containing the source information.
|
||||
*/
|
||||
typedef struct {
|
||||
const char *name; /* name of database */
|
||||
ns_src *srclist; /* list of sources */
|
||||
u_int srclistsize; /* size of srclist */
|
||||
} ns_dbt;
|
||||
|
||||
/*
|
||||
* ns_mod - `nsswitch module'
|
||||
*/
|
||||
typedef struct {
|
||||
const char *name; /* module name */
|
||||
void *handle; /* handle from dlopen() */
|
||||
ns_mtab *mtab; /* method table */
|
||||
u_int mtabsize; /* size of mtab */
|
||||
/* called to unload module */
|
||||
nss_module_unregister_fn unregister;
|
||||
} ns_mod;
|
||||
|
||||
#endif /* _NS_PRIVATE */
|
||||
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
int nsdispatch(void *, const ns_dtab [], const char *,
|
||||
const char *, const ns_src [], ...);
|
||||
|
||||
#ifdef _NS_PRIVATE
|
||||
int _nsdbtaddsrc(ns_dbt *, const ns_src *);
|
||||
void _nsdbtdump(const ns_dbt *);
|
||||
int _nsdbtput(const ns_dbt *);
|
||||
void _nsyyerror(const char *);
|
||||
int _nsyylex(void);
|
||||
#endif /* _NS_PRIVATE */
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_NSSWITCH_H */
|
|
@ -112,6 +112,8 @@ struct __res_state {
|
|||
char pad[72]; /* on an i386 this means 512b total */
|
||||
};
|
||||
|
||||
typedef struct __res_state *res_state;
|
||||
|
||||
/*
|
||||
* Resolver options (keep these in synch with res_debug.c, please)
|
||||
*/
|
||||
|
@ -201,6 +203,7 @@ extern const struct res_sym __p_type_syms[];
|
|||
#define hostalias __hostalias
|
||||
#define putlong __putlong
|
||||
#define putshort __putshort
|
||||
uint16_t _getshort(const u_char *);
|
||||
#define p_class __p_class
|
||||
#define p_time __p_time
|
||||
#define p_type __p_type
|
||||
|
@ -288,6 +291,7 @@ int res_mkupdate __P((ns_updrec *, u_char *, int));
|
|||
ns_updrec * res_mkupdrec __P((int, const char *, u_int, u_int, u_long));
|
||||
void res_freeupdrec __P((ns_updrec *));
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_RESOLV_H_ */
|
||||
|
|
|
@ -29,11 +29,27 @@ CONST EFI_GUID mEslIp4ServiceGuid = {
|
|||
};
|
||||
|
||||
|
||||
/**
|
||||
Tag GUID - IPv6 in use by SocketDxe
|
||||
**/
|
||||
CONST EFI_GUID mEslIp6ServiceGuid = {
|
||||
0x2fc3b2d3, 0x6eba, 0x42b0, { 0xa4, 0xa7, 0x14, 0xc7, 0xa8, 0x4b, 0x5d, 0x22 }
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Tag GUID - TCPv4 in use by SocketDxe
|
||||
**/
|
||||
CONST EFI_GUID mEslTcp4ServiceGuid = {
|
||||
0x4dcaab0a, 0x1990, 0x4352, { 0x8d, 0x2f, 0x2d, 0x8f, 0x13, 0x55, 0x98, 0xa5 }
|
||||
0x4dcaab0a, 0x1990, 0x4352, { 0x8d, 0x2f, 0x2d, 0x8f, 0x13, 0x55, 0x98, 0xa5 }
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Tag GUID - TCPv6 in use by SocketDxe
|
||||
**/
|
||||
CONST EFI_GUID mEslTcp6ServiceGuid = {
|
||||
0xdd455a69, 0xec75, 0x456c, { 0x84, 0xd2, 0x95, 0xca, 0xe7, 0xd3, 0xc6, 0xd3 }
|
||||
};
|
||||
|
||||
|
||||
|
@ -41,7 +57,15 @@ CONST EFI_GUID mEslTcp4ServiceGuid = {
|
|||
Tag GUID - UDPv4 in use by SocketDxe
|
||||
**/
|
||||
CONST EFI_GUID mEslUdp4ServiceGuid = {
|
||||
0x43a110ce, 0x9ccd, 0x402b, { 0x8c, 0x29, 0x4a, 0x6d, 0x8a, 0xf7, 0x79, 0x90 }
|
||||
0x43a110ce, 0x9ccd, 0x402b, { 0x8c, 0x29, 0x4a, 0x6d, 0x8a, 0xf7, 0x79, 0x90 }
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Tag GUID - UDPv6 in use by SocketDxe
|
||||
**/
|
||||
CONST EFI_GUID mEslUdp6ServiceGuid = {
|
||||
0x32ff59cd, 0xc33, 0x48d0, { 0xa2, 0x44, 0x4b, 0xb8, 0x11, 0x33, 0x64, 0x3 }
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -40,11 +40,6 @@
|
|||
gStdLibTokenSpaceGuid = { 0x447559f0, 0xd02e, 0x4cf1, { 0x99, 0xbc, 0xca, 0x11, 0x65, 0x40, 0x54, 0xc2 }}
|
||||
|
||||
|
||||
[PcdsFixedAtBuild]
|
||||
gStdLibTokenSpaceGuid.DataSource_Port|1234|UINT16|0
|
||||
gStdLibTokenSpaceGuid.WebServer_HttpPort|80|UINT16|1
|
||||
|
||||
|
||||
[Protocols]
|
||||
gEfiSocketProtocolGuid = { 0x58e6ed63, 0x1694, 0x440b, { 0x93, 0x88, 0xe9, 0x8f, 0xed, 0x6b, 0x65, 0xaf } }
|
||||
gEfiSocketServiceBindingProtocolGuid = { 0x8aaedb2a, 0xa6bb, 0x47c6, { 0x94, 0xce, 0x1b, 0x80, 0x96, 0x42, 0x3f, 0x2a } }
|
||||
|
|
Loading…
Reference in New Issue