mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-10-15 03:17:56 +08:00
Import socket() implementation from FreeBSD
Add new test syscalls01.
This commit is contained in:
@@ -46,6 +46,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
@@ -54,6 +55,8 @@ int pselect(int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict,
|
||||
|
||||
int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
|
||||
|
||||
int socket(int, int, int);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _RTEMS_BSD_MACHINE_RTEMS_BSD_SYSCALL_API_H_ */
|
||||
|
@@ -192,44 +192,6 @@ getsockaddr(namp, uaddr, len)
|
||||
* BSD-style entry points *
|
||||
*********************************************************************
|
||||
*/
|
||||
int
|
||||
socket (int domain, int type, int protocol)
|
||||
{
|
||||
struct thread *td;
|
||||
struct socket *so;
|
||||
int fd, error;
|
||||
|
||||
td = curthread;
|
||||
if (!td) {
|
||||
printf("Current thread NULL\n");
|
||||
exit(0);
|
||||
}
|
||||
#ifdef MAC
|
||||
error = mac_socket_check_create(td->td_ucred, domain, type, protocol);
|
||||
if (error == 0 )
|
||||
{
|
||||
#endif
|
||||
/* An extra reference on `fp' has been held for us by falloc(). */
|
||||
error = socreate(domain, &so, type, protocol, td->td_ucred, td);
|
||||
if (error == 0) {
|
||||
fd = rtems_bsdnet_makeFdForSocket (so);
|
||||
if (fd < 0)
|
||||
{
|
||||
soclose (so);
|
||||
error = EBADF;
|
||||
}
|
||||
}
|
||||
#ifdef MAC
|
||||
}
|
||||
#endif
|
||||
if( error == 0 )
|
||||
{
|
||||
return fd;
|
||||
}
|
||||
errno = error;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
kern_bind(td, fd, sa)
|
||||
struct thread *td;
|
||||
|
Reference in New Issue
Block a user