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:
lpleahy
2012-02-09 19:16:44 +00:00
parent 5709e4e290
commit 3bdf9aae5f
19 changed files with 6551 additions and 25 deletions

View File

@@ -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

View File

@@ -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 */

View File

@@ -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 *);

237
StdLib/Include/nsswitch.h Normal file
View File

@@ -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 */

View File

@@ -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_ */