Import socket() implementation from FreeBSD

Add new test syscalls01.
This commit is contained in:
Sebastian Huber
2013-10-10 11:29:33 +02:00
parent 69b29a0c0d
commit caf8eded60
9 changed files with 3452 additions and 38 deletions

View File

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

View File

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