Use bind() from FreeBSD

This commit is contained in:
Sebastian Huber
2013-10-11 16:44:48 +02:00
parent 6ffb9b9e27
commit 468b08e553
5 changed files with 109 additions and 75 deletions

View File

@@ -271,6 +271,12 @@ socket(int domain, int type, int protocol)
/* ARGSUSED */
int
bind(td, uap)
#else /* __rtems__ */
static int kern_bind(struct thread *, int, struct sockaddr *);
static int
rtems_bsd_bind(td, uap)
#endif /* __rtems__ */
struct thread *td;
struct bind_args /* {
int s;
@@ -288,6 +294,27 @@ bind(td, uap)
free(sa, M_SONAME);
return (error);
}
#ifdef __rtems__
int
bind(int socket, const struct sockaddr *address, socklen_t address_len)
{
struct thread *td = rtems_bsd_get_curthread_or_null();
struct bind_args ua = {
.s = socket,
.name = (caddr_t) address,
.namelen = address_len
};
int error;
if (td != NULL) {
error = rtems_bsd_bind(td, &ua);
} else {
error = ENOMEM;
}
return rtems_bsd_error_to_status_and_errno(error);
}
#endif /* __rtems__ */
int
kern_bind(td, fd, sa)
@@ -317,6 +344,7 @@ kern_bind(td, fd, sa)
return (error);
}
#ifndef __rtems__
/* ARGSUSED */
int
listen(td, uap)
@@ -1763,6 +1791,7 @@ sockargs(mp, buf, buflen, type)
}
return (error);
}
#endif /* __rtems__ */
int
getsockaddr(namp, uaddr, len)
@@ -1792,6 +1821,7 @@ getsockaddr(namp, uaddr, len)
return (error);
}
#ifndef __rtems__
#include <sys/condvar.h>
struct sendfile_sync {

View File

@@ -366,11 +366,17 @@ struct getpriority_args {
char which_l_[PADL_(int)]; int which; char which_r_[PADR_(int)];
char who_l_[PADL_(int)]; int who; char who_r_[PADR_(int)];
};
#endif /* __rtems__ */
struct bind_args {
char s_l_[PADL_(int)]; int s; char s_r_[PADR_(int)];
char name_l_[PADL_(caddr_t)]; caddr_t name; char name_r_[PADR_(caddr_t)];
#ifndef __rtems__
char namelen_l_[PADL_(int)]; int namelen; char namelen_r_[PADR_(int)];
#else /* __rtems__ */
char namelen_l_[PADL_(__socklen_t)]; __socklen_t namelen; char namelen_r_[PADR_(__socklen_t)];
#endif /* __rtems__ */
};
#ifndef __rtems__
struct setsockopt_args {
char s_l_[PADL_(int)]; int s; char s_r_[PADR_(int)];
char level_l_[PADL_(int)]; int level; char level_r_[PADR_(int)];