mirror of https://github.com/F-Stack/f-stack.git
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:
parent
1b5649a396
commit
3a84cd1fec
|
@ -231,20 +231,14 @@ socket(int domain, int type, int protocol)
|
||||||
{
|
{
|
||||||
int sock;
|
int sock;
|
||||||
if (unlikely(inited == 0)) {
|
if (unlikely(inited == 0)) {
|
||||||
if (AF_INET6 == domain)
|
|
||||||
domain = AF_INET6_LINUX;
|
|
||||||
return SYSCALL(socket)(domain, type, protocol);
|
return SYSCALL(socket)(domain, type, protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unlikely(fstack_territory(domain, type, protocol) == 0)) {
|
if (unlikely(fstack_territory(domain, type, protocol) == 0)) {
|
||||||
if (AF_INET6 == domain)
|
|
||||||
domain = AF_INET6_LINUX;
|
|
||||||
return SYSCALL(socket)(domain, type, protocol);
|
return SYSCALL(socket)(domain, type, protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unlikely((type & SOCK_FSTACK) == 0)) {
|
if (unlikely((type & SOCK_FSTACK) == 0)) {
|
||||||
if (AF_INET6 == domain)
|
|
||||||
domain = AF_INET6_LINUX;
|
|
||||||
return SYSCALL(socket)(domain, type, protocol);
|
return SYSCALL(socket)(domain, type, protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
11
lib/ff_api.h
11
lib/ff_api.h
|
@ -44,17 +44,6 @@ struct linux_sockaddr {
|
||||||
char sa_data[126];
|
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 AF_INET6_LINUX 10
|
||||||
#define PF_INET6_LINUX AF_INET6_LINUX
|
#define PF_INET6_LINUX AF_INET6_LINUX
|
||||||
|
|
||||||
|
|
|
@ -168,6 +168,11 @@
|
||||||
|
|
||||||
/* ioctl define end */
|
/* 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);
|
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 */
|
/* #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;
|
freebsd->sa_len = addrlen;
|
||||||
|
|
||||||
bcopy(linux->sa_data, freebsd->sa_data, addrlen - sizeof(linux->sa_family));
|
bcopy(linux->sa_data, freebsd->sa_data, addrlen - sizeof(linux->sa_family));
|
||||||
|
@ -419,7 +424,7 @@ freebsd2linux_sockaddr(struct linux_sockaddr *linux,
|
||||||
return;
|
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));
|
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;
|
int rc;
|
||||||
struct socket_args sa;
|
struct socket_args sa;
|
||||||
sa.domain = domain;
|
sa.domain = domain == LINUX_AF_INET6 ? AF_INET6 : domain;
|
||||||
sa.type = type;
|
sa.type = type;
|
||||||
sa.protocol = protocol;
|
sa.protocol = protocol;
|
||||||
if ((rc = sys_socket(curthread, &sa)))
|
if ((rc = sys_socket(curthread, &sa)))
|
||||||
|
|
Loading…
Reference in New Issue