User APP can use AF_INET6/PF_INET6 directly whether call ff socket or linux API, such as inet_ntoa/inet_aton.

This commit is contained in:
fengbojiang 2020-09-03 01:35:22 +08:00
parent f41205e9f3
commit 8d21adc4b7
3 changed files with 8 additions and 20 deletions

View File

@ -231,20 +231,14 @@ socket(int domain, int type, int protocol)
{
int sock;
if (unlikely(inited == 0)) {
if (AF_INET6 == domain)
domain = AF_INET6_LINUX;
return SYSCALL(socket)(domain, type, protocol);
}
if (unlikely(fstack_territory(domain, type, protocol) == 0)) {
if (AF_INET6 == domain)
domain = AF_INET6_LINUX;
return SYSCALL(socket)(domain, type, protocol);
}
if (unlikely((type & SOCK_FSTACK) == 0)) {
if (AF_INET6 == domain)
domain = AF_INET6_LINUX;
return SYSCALL(socket)(domain, type, protocol);
}

View File

@ -44,17 +44,6 @@ struct linux_sockaddr {
char sa_data[126];
};
/* AF_INET6/PF_INET6 is 10 in linux
* defined 28 for FreeBSD
*/
#ifdef AF_INET6
#undef AF_INET6
#endif
#ifdef PF_INET6
#undef PF_INET6
#endif
#define AF_INET6 28
#define PF_INET6 AF_INET6
#define AF_INET6_LINUX 10
#define PF_INET6_LINUX AF_INET6_LINUX

View File

@ -168,6 +168,11 @@
/* ioctl define end */
/* af define start */
#define LINUX_AF_INET6 10
/* af define end */
extern int sendit(struct thread *td, int s, struct msghdr *mp, int flags);
@ -405,7 +410,7 @@ linux2freebsd_sockaddr(const struct linux_sockaddr *linux,
}
/* #linux and #freebsd may point to the same address */
freebsd->sa_family = linux->sa_family;
freebsd->sa_family = linux->sa_family == LINUX_AF_INET6 ? AF_INET6 : linux->sa_family;
freebsd->sa_len = addrlen;
bcopy(linux->sa_data, freebsd->sa_data, addrlen - sizeof(linux->sa_family));
@ -419,7 +424,7 @@ freebsd2linux_sockaddr(struct linux_sockaddr *linux,
return;
}
linux->sa_family = freebsd->sa_family;
linux->sa_family = freebsd->sa_family == AF_INET6 ? LINUX_AF_INET6 : freebsd->sa_family;
bcopy(freebsd->sa_data, linux->sa_data, freebsd->sa_len - sizeof(linux->sa_family));
}
@ -429,7 +434,7 @@ ff_socket(int domain, int type, int protocol)
{
int rc;
struct socket_args sa;
sa.domain = domain;
sa.domain = domain == LINUX_AF_INET6 ? AF_INET6 : domain;
sa.type = type;
sa.protocol = protocol;
if ((rc = sys_socket(curthread, &sa)))