Changeset View
Changeset View
Standalone View
Standalone View
sys/compat/linux/linux.c
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | |||||
#include <sys/signalvar.h> | #include <sys/signalvar.h> | ||||
#include <sys/socket.h> | #include <sys/socket.h> | ||||
#include <sys/socketvar.h> | #include <sys/socketvar.h> | ||||
#include <net/if.h> | #include <net/if.h> | ||||
#include <net/if_var.h> | #include <net/if_var.h> | ||||
#include <net/if_dl.h> | #include <net/if_dl.h> | ||||
#include <net/if_types.h> | #include <net/if_types.h> | ||||
#include <netlink/netlink.h> | |||||
#include <sys/un.h> | #include <sys/un.h> | ||||
#include <netinet/in.h> | #include <netinet/in.h> | ||||
#include <compat/linux/linux.h> | #include <compat/linux/linux.h> | ||||
#include <compat/linux/linux_common.h> | #include <compat/linux/linux_common.h> | ||||
#include <compat/linux/linux_mib.h> | #include <compat/linux/linux_mib.h> | ||||
#include <compat/linux/linux_util.h> | #include <compat/linux/linux_util.h> | ||||
▲ Show 20 Lines • Show All 301 Lines • ▼ Show 20 Lines | linux_to_bsd_domain(int domain) | ||||
case LINUX_AF_INET6: | case LINUX_AF_INET6: | ||||
return (AF_INET6); | return (AF_INET6); | ||||
case LINUX_AF_AX25: | case LINUX_AF_AX25: | ||||
return (AF_CCITT); | return (AF_CCITT); | ||||
case LINUX_AF_IPX: | case LINUX_AF_IPX: | ||||
return (AF_IPX); | return (AF_IPX); | ||||
case LINUX_AF_APPLETALK: | case LINUX_AF_APPLETALK: | ||||
return (AF_APPLETALK); | return (AF_APPLETALK); | ||||
case LINUX_AF_NETLINK: | |||||
return (AF_NETLINK); | |||||
} | } | ||||
return (-1); | return (-1); | ||||
} | } | ||||
int | int | ||||
bsd_to_linux_domain(int domain) | bsd_to_linux_domain(int domain) | ||||
{ | { | ||||
switch (domain) { | switch (domain) { | ||||
case AF_UNSPEC: | case AF_UNSPEC: | ||||
return (LINUX_AF_UNSPEC); | return (LINUX_AF_UNSPEC); | ||||
case AF_LOCAL: | case AF_LOCAL: | ||||
return (LINUX_AF_UNIX); | return (LINUX_AF_UNIX); | ||||
case AF_INET: | case AF_INET: | ||||
return (LINUX_AF_INET); | return (LINUX_AF_INET); | ||||
case AF_INET6: | case AF_INET6: | ||||
return (LINUX_AF_INET6); | return (LINUX_AF_INET6); | ||||
case AF_CCITT: | case AF_CCITT: | ||||
return (LINUX_AF_AX25); | return (LINUX_AF_AX25); | ||||
case AF_IPX: | case AF_IPX: | ||||
return (LINUX_AF_IPX); | return (LINUX_AF_IPX); | ||||
case AF_APPLETALK: | case AF_APPLETALK: | ||||
return (LINUX_AF_APPLETALK); | return (LINUX_AF_APPLETALK); | ||||
case AF_NETLINK: | |||||
return (LINUX_AF_NETLINK); | |||||
} | } | ||||
return (-1); | return (-1); | ||||
} | } | ||||
/* | /* | ||||
* Based on the fact that: | * Based on the fact that: | ||||
* 1. Native and Linux storage of struct sockaddr | * 1. Native and Linux storage of struct sockaddr | ||||
* and struct sockaddr_in6 are equal. | * and struct sockaddr_in6 are equal. | ||||
▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | if (*name == '\0') { | ||||
namelen = strnlen(name + 1, salen - hdrlen - 1) + 1; | namelen = strnlen(name + 1, salen - hdrlen - 1) + 1; | ||||
} else | } else | ||||
namelen = strnlen(name, salen - hdrlen); | namelen = strnlen(name, salen - hdrlen); | ||||
salen = hdrlen + namelen; | salen = hdrlen + namelen; | ||||
if (salen > sizeof(struct sockaddr_un)) { | if (salen > sizeof(struct sockaddr_un)) { | ||||
error = ENAMETOOLONG; | error = ENAMETOOLONG; | ||||
goto out; | goto out; | ||||
} | } | ||||
} | |||||
if (bdom == AF_NETLINK) { | |||||
if (salen < sizeof(struct sockaddr_nl)) { | |||||
error = EINVAL; | |||||
goto out; | |||||
} | |||||
salen = sizeof(struct sockaddr_nl); | |||||
} | } | ||||
sa = (struct sockaddr *)kosa; | sa = (struct sockaddr *)kosa; | ||||
sa->sa_family = bdom; | sa->sa_family = bdom; | ||||
sa->sa_len = salen; | sa->sa_len = salen; | ||||
*sap = sa; | *sap = sa; | ||||
*len = salen; | *len = salen; | ||||
▲ Show 20 Lines • Show All 190 Lines • Show Last 20 Lines |