diff options
Diffstat (limited to 'pfinet.old')
-rw-r--r-- | pfinet.old/iioctlServer.c | 1672 | ||||
-rw-r--r-- | pfinet.old/ioServer.c | 2021 | ||||
-rw-r--r-- | pfinet.old/pfinetServer.c | 189 | ||||
-rw-r--r-- | pfinet.old/socketServer.c | 1533 | ||||
-rw-r--r-- | pfinet.old/startup_notifyServer.c | 129 |
5 files changed, 0 insertions, 5544 deletions
diff --git a/pfinet.old/iioctlServer.c b/pfinet.old/iioctlServer.c deleted file mode 100644 index 1c646f32..00000000 --- a/pfinet.old/iioctlServer.c +++ /dev/null @@ -1,1672 +0,0 @@ -/* Module iioctl */ - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE 1 -#endif - -#define EXPORT_BOOLEAN -#include <mach/boolean.h> -#include <mach/kern_return.h> -#include <mach/message.h> -#include <mach/mig_errors.h> -#include <mach/mig_support.h> - -#ifndef mig_internal -#define mig_internal static -#endif - -#ifndef mig_external -#define mig_external -#endif - -#ifndef TypeCheck -#define TypeCheck 1 -#endif - -#ifndef UseExternRCSId -#define UseExternRCSId 1 -#endif - -#define BAD_TYPECHECK(type, check) ({\ - union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\ - _t.t = *(type); _c.t = *(check); _t.w != _c.w; }) -#define msgh_request_port msgh_local_port -#define MACH_MSGH_BITS_REQUEST(bits) MACH_MSGH_BITS_LOCAL(bits) -#define msgh_reply_port msgh_remote_port -#define MACH_MSGH_BITS_REPLY(bits) MACH_MSGH_BITS_REMOTE(bits) - -#include <mach/std_types.h> -#include <mach/mach_types.h> -#include <device/device_types.h> -#include <device/net_status.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/statfs.h> -#include <sys/resource.h> -#include <sys/utsname.h> -#include <hurd/hurd_types.h> -#include <hurd/ioctl_types.h> - -/* Routine iioctl_siocsifaddr */ -mig_internal void _Xiioctl_siocsifaddr - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t ifnamType; - ifname_t ifnam; - mach_msg_type_t addrType; - sockaddr_t addr; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_iioctl_siocsifaddr - (io_t reqport, ifname_t ifnam, sockaddr_t addr); - - auto const mach_msg_type_t ifnamCheck = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t addrCheck = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - -#if TypeCheck - if ((In0P->Head.msgh_size != 64) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->ifnamType, &ifnamCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->addrType, &addrCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_iioctl_siocsifaddr(In0P->Head.msgh_request_port, In0P->ifnam, In0P->addr); -} - -/* Routine iioctl_siocsifdstaddr */ -mig_internal void _Xiioctl_siocsifdstaddr - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t ifnamType; - ifname_t ifnam; - mach_msg_type_t dstaddrType; - sockaddr_t dstaddr; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_iioctl_siocsifdstaddr - (io_t reqport, ifname_t ifnam, sockaddr_t dstaddr); - - auto const mach_msg_type_t ifnamCheck = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t dstaddrCheck = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - -#if TypeCheck - if ((In0P->Head.msgh_size != 64) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->ifnamType, &ifnamCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->dstaddrType, &dstaddrCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_iioctl_siocsifdstaddr(In0P->Head.msgh_request_port, In0P->ifnam, In0P->dstaddr); -} - -/* Routine iioctl_siocsifflags */ -mig_internal void _Xiioctl_siocsifflags - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t ifnamType; - ifname_t ifnam; - mach_msg_type_t flagsType; - short flags; - char flagsPad[2]; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_iioctl_siocsifflags - (io_t reqport, ifname_t ifnam, short flags); - - auto const mach_msg_type_t ifnamCheck = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t flagsCheck = { - /* msgt_name = */ 1, - /* msgt_size = */ 16, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - -#if TypeCheck - if ((In0P->Head.msgh_size != 52) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->ifnamType, &ifnamCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->flagsType, &flagsCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_iioctl_siocsifflags(In0P->Head.msgh_request_port, In0P->ifnam, In0P->flags); -} - -/* Routine iioctl_siocgifflags */ -mig_internal void _Xiioctl_siocgifflags - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t ifnamType; - ifname_t ifnam; - mach_msg_type_t flagsType; - short flags; - char flagsPad[2]; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t ifnamType; - ifname_t ifnam; - mach_msg_type_t flagsType; - short flags; - char flagsPad[2]; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_iioctl_siocgifflags - (io_t reqport, ifname_t ifnam, short *flags); - - auto const mach_msg_type_t ifnamCheck = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t flagsCheck = { - /* msgt_name = */ 1, - /* msgt_size = */ 16, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t ifnamType = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t flagsType = { - /* msgt_name = */ 1, - /* msgt_size = */ 16, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - -#if TypeCheck - if ((In0P->Head.msgh_size != 52) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->ifnamType, &ifnamCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->flagsType, &flagsCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_iioctl_siocgifflags(In0P->Head.msgh_request_port, In0P->ifnam, &In0P->flags); - if (OutP->RetCode != KERN_SUCCESS) - return; - - OutP->Head.msgh_size = 60; - - OutP->ifnamType = ifnamType; - - { typedef struct { char data[16]; } *sp; * (sp) OutP->ifnam = * (sp) In0P->ifnam; } - - OutP->flagsType = flagsType; - - OutP->flags = In0P->flags; -} - -/* Routine iioctl_siocsifbrdaddr */ -mig_internal void _Xiioctl_siocsifbrdaddr - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t ifnamType; - ifname_t ifnam; - mach_msg_type_t brdaddrType; - sockaddr_t brdaddr; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_iioctl_siocsifbrdaddr - (io_t reqport, ifname_t ifnam, sockaddr_t brdaddr); - - auto const mach_msg_type_t ifnamCheck = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t brdaddrCheck = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - -#if TypeCheck - if ((In0P->Head.msgh_size != 64) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->ifnamType, &ifnamCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->brdaddrType, &brdaddrCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_iioctl_siocsifbrdaddr(In0P->Head.msgh_request_port, In0P->ifnam, In0P->brdaddr); -} - -/* Routine iioctl_siocsifnetmask */ -mig_internal void _Xiioctl_siocsifnetmask - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t ifnamType; - ifname_t ifnam; - mach_msg_type_t netmaskType; - sockaddr_t netmask; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_iioctl_siocsifnetmask - (io_t reqport, ifname_t ifnam, sockaddr_t netmask); - - auto const mach_msg_type_t ifnamCheck = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t netmaskCheck = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - -#if TypeCheck - if ((In0P->Head.msgh_size != 64) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->ifnamType, &ifnamCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->netmaskType, &netmaskCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_iioctl_siocsifnetmask(In0P->Head.msgh_request_port, In0P->ifnam, In0P->netmask); -} - -/* Routine iioctl_siocgifmetric */ -mig_internal void _Xiioctl_siocgifmetric - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t ifnamType; - ifname_t ifnam; - mach_msg_type_t metricType; - int metric; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t ifnamType; - ifname_t ifnam; - mach_msg_type_t metricType; - int metric; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_iioctl_siocgifmetric - (io_t reqport, ifname_t ifnam, int *metric); - - auto const mach_msg_type_t ifnamCheck = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t metricCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t ifnamType = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t metricType = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - -#if TypeCheck - if ((In0P->Head.msgh_size != 52) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->ifnamType, &ifnamCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->metricType, &metricCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_iioctl_siocgifmetric(In0P->Head.msgh_request_port, In0P->ifnam, &In0P->metric); - if (OutP->RetCode != KERN_SUCCESS) - return; - - OutP->Head.msgh_size = 60; - - OutP->ifnamType = ifnamType; - - { typedef struct { char data[16]; } *sp; * (sp) OutP->ifnam = * (sp) In0P->ifnam; } - - OutP->metricType = metricType; - - OutP->metric = In0P->metric; -} - -/* Routine iioctl_siocsifmetric */ -mig_internal void _Xiioctl_siocsifmetric - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t ifnamType; - ifname_t ifnam; - mach_msg_type_t metricType; - int metric; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_iioctl_siocsifmetric - (io_t reqport, ifname_t ifnam, int metric); - - auto const mach_msg_type_t ifnamCheck = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t metricCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - -#if TypeCheck - if ((In0P->Head.msgh_size != 52) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->ifnamType, &ifnamCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->metricType, &metricCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_iioctl_siocsifmetric(In0P->Head.msgh_request_port, In0P->ifnam, In0P->metric); -} - -/* Routine iioctl_siocdifaddr */ -mig_internal void _Xiioctl_siocdifaddr - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t ifnamType; - ifname_t ifnam; - mach_msg_type_t addrType; - sockaddr_t addr; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_iioctl_siocdifaddr - (io_t reqport, ifname_t ifnam, sockaddr_t addr); - - auto const mach_msg_type_t ifnamCheck = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t addrCheck = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - -#if TypeCheck - if ((In0P->Head.msgh_size != 64) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->ifnamType, &ifnamCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->addrType, &addrCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_iioctl_siocdifaddr(In0P->Head.msgh_request_port, In0P->ifnam, In0P->addr); -} - -/* Routine iioctl_siocgifaddr */ -mig_internal void _Xiioctl_siocgifaddr - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t ifnamType; - ifname_t ifnam; - mach_msg_type_t addrType; - sockaddr_t addr; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t ifnamType; - ifname_t ifnam; - mach_msg_type_t addrType; - sockaddr_t addr; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_iioctl_siocgifaddr - (io_t reqport, ifname_t ifnam, sockaddr_t *addr); - - auto const mach_msg_type_t ifnamCheck = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t addrCheck = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t ifnamType = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t addrType = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - -#if TypeCheck - if ((In0P->Head.msgh_size != 64) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->ifnamType, &ifnamCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->addrType, &addrCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_iioctl_siocgifaddr(In0P->Head.msgh_request_port, In0P->ifnam, &In0P->addr); - if (OutP->RetCode != KERN_SUCCESS) - return; - - OutP->Head.msgh_size = 72; - - OutP->ifnamType = ifnamType; - - { typedef struct { char data[16]; } *sp; * (sp) OutP->ifnam = * (sp) In0P->ifnam; } - - OutP->addrType = addrType; - - OutP->addr = In0P->addr; -} - -/* Routine iioctl_siocgifdstaddr */ -mig_internal void _Xiioctl_siocgifdstaddr - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t ifnamType; - ifname_t ifnam; - mach_msg_type_t dstaddrType; - sockaddr_t dstaddr; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t ifnamType; - ifname_t ifnam; - mach_msg_type_t dstaddrType; - sockaddr_t dstaddr; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_iioctl_siocgifdstaddr - (io_t reqport, ifname_t ifnam, sockaddr_t *dstaddr); - - auto const mach_msg_type_t ifnamCheck = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t dstaddrCheck = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t ifnamType = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t dstaddrType = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - -#if TypeCheck - if ((In0P->Head.msgh_size != 64) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->ifnamType, &ifnamCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->dstaddrType, &dstaddrCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_iioctl_siocgifdstaddr(In0P->Head.msgh_request_port, In0P->ifnam, &In0P->dstaddr); - if (OutP->RetCode != KERN_SUCCESS) - return; - - OutP->Head.msgh_size = 72; - - OutP->ifnamType = ifnamType; - - { typedef struct { char data[16]; } *sp; * (sp) OutP->ifnam = * (sp) In0P->ifnam; } - - OutP->dstaddrType = dstaddrType; - - OutP->dstaddr = In0P->dstaddr; -} - -/* Routine iioctl_siocgifbrdaddr */ -mig_internal void _Xiioctl_siocgifbrdaddr - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t ifnamType; - ifname_t ifnam; - mach_msg_type_t brdaddrType; - sockaddr_t brdaddr; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t ifnamType; - ifname_t ifnam; - mach_msg_type_t brdaddrType; - sockaddr_t brdaddr; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_iioctl_siocgifbrdaddr - (io_t reqport, ifname_t ifnam, sockaddr_t *brdaddr); - - auto const mach_msg_type_t ifnamCheck = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t brdaddrCheck = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t ifnamType = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t brdaddrType = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - -#if TypeCheck - if ((In0P->Head.msgh_size != 64) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->ifnamType, &ifnamCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->brdaddrType, &brdaddrCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_iioctl_siocgifbrdaddr(In0P->Head.msgh_request_port, In0P->ifnam, &In0P->brdaddr); - if (OutP->RetCode != KERN_SUCCESS) - return; - - OutP->Head.msgh_size = 72; - - OutP->ifnamType = ifnamType; - - { typedef struct { char data[16]; } *sp; * (sp) OutP->ifnam = * (sp) In0P->ifnam; } - - OutP->brdaddrType = brdaddrType; - - OutP->brdaddr = In0P->brdaddr; -} - -/* Routine iioctl_siocgifnetmask */ -mig_internal void _Xiioctl_siocgifnetmask - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t ifnamType; - ifname_t ifnam; - mach_msg_type_t netmaskType; - sockaddr_t netmask; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t ifnamType; - ifname_t ifnam; - mach_msg_type_t netmaskType; - sockaddr_t netmask; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_iioctl_siocgifnetmask - (io_t reqport, ifname_t ifnam, sockaddr_t *netmask); - - auto const mach_msg_type_t ifnamCheck = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t netmaskCheck = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t ifnamType = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t netmaskType = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - -#if TypeCheck - if ((In0P->Head.msgh_size != 64) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->ifnamType, &ifnamCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->netmaskType, &netmaskCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_iioctl_siocgifnetmask(In0P->Head.msgh_request_port, In0P->ifnam, &In0P->netmask); - if (OutP->RetCode != KERN_SUCCESS) - return; - - OutP->Head.msgh_size = 72; - - OutP->ifnamType = ifnamType; - - { typedef struct { char data[16]; } *sp; * (sp) OutP->ifnam = * (sp) In0P->ifnam; } - - OutP->netmaskType = netmaskType; - - OutP->netmask = In0P->netmask; -} - -/* Routine iioctl_siocgifhwaddr */ -mig_internal void _Xiioctl_siocgifhwaddr - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t ifnamType; - ifname_t ifnam; - mach_msg_type_t netmaskType; - sockaddr_t netmask; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t ifnamType; - ifname_t ifnam; - mach_msg_type_t netmaskType; - sockaddr_t netmask; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_iioctl_siocgifhwaddr - (io_t reqport, ifname_t ifnam, sockaddr_t *netmask); - - auto const mach_msg_type_t ifnamCheck = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t netmaskCheck = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t ifnamType = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t netmaskType = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - -#if TypeCheck - if ((In0P->Head.msgh_size != 64) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->ifnamType, &ifnamCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->netmaskType, &netmaskCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_iioctl_siocgifhwaddr(In0P->Head.msgh_request_port, In0P->ifnam, &In0P->netmask); - if (OutP->RetCode != KERN_SUCCESS) - return; - - OutP->Head.msgh_size = 72; - - OutP->ifnamType = ifnamType; - - { typedef struct { char data[16]; } *sp; * (sp) OutP->ifnam = * (sp) In0P->ifnam; } - - OutP->netmaskType = netmaskType; - - OutP->netmask = In0P->netmask; -} - -/* Routine iioctl_siocgifmtu */ -mig_internal void _Xiioctl_siocgifmtu - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t ifnamType; - ifname_t ifnam; - mach_msg_type_t mtuType; - int mtu; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t ifnamType; - ifname_t ifnam; - mach_msg_type_t mtuType; - int mtu; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_iioctl_siocgifmtu - (io_t reqport, ifname_t ifnam, int *mtu); - - auto const mach_msg_type_t ifnamCheck = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t mtuCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t ifnamType = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t mtuType = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - -#if TypeCheck - if ((In0P->Head.msgh_size != 52) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->ifnamType, &ifnamCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->mtuType, &mtuCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_iioctl_siocgifmtu(In0P->Head.msgh_request_port, In0P->ifnam, &In0P->mtu); - if (OutP->RetCode != KERN_SUCCESS) - return; - - OutP->Head.msgh_size = 60; - - OutP->ifnamType = ifnamType; - - { typedef struct { char data[16]; } *sp; * (sp) OutP->ifnam = * (sp) In0P->ifnam; } - - OutP->mtuType = mtuType; - - OutP->mtu = In0P->mtu; -} - -/* Routine iioctl_siocsifmtu */ -mig_internal void _Xiioctl_siocsifmtu - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t ifnamType; - ifname_t ifnam; - mach_msg_type_t mtuType; - int mtu; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_iioctl_siocsifmtu - (io_t reqport, ifname_t ifnam, int mtu); - - auto const mach_msg_type_t ifnamCheck = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t mtuCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - -#if TypeCheck - if ((In0P->Head.msgh_size != 52) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->ifnamType, &ifnamCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->mtuType, &mtuCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_iioctl_siocsifmtu(In0P->Head.msgh_request_port, In0P->ifnam, In0P->mtu); -} - -/* Routine iioctl_siocgifindex */ -mig_internal void _Xiioctl_siocgifindex - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t ifnamType; - ifname_t ifnam; - mach_msg_type_t indexType; - int index; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t ifnamType; - ifname_t ifnam; - mach_msg_type_t indexType; - int index; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_iioctl_siocgifindex - (io_t reqport, ifname_t ifnam, int *index); - - auto const mach_msg_type_t ifnamCheck = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t indexCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t ifnamType = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t indexType = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - -#if TypeCheck - if ((In0P->Head.msgh_size != 52) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->ifnamType, &ifnamCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->indexType, &indexCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_iioctl_siocgifindex(In0P->Head.msgh_request_port, In0P->ifnam, &In0P->index); - if (OutP->RetCode != KERN_SUCCESS) - return; - - OutP->Head.msgh_size = 60; - - OutP->ifnamType = ifnamType; - - { typedef struct { char data[16]; } *sp; * (sp) OutP->ifnam = * (sp) In0P->ifnam; } - - OutP->indexType = indexType; - - OutP->index = In0P->index; -} - -/* Routine iioctl_siocgifname */ -mig_internal void _Xiioctl_siocgifname - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t ifnamType; - ifname_t ifnam; - mach_msg_type_t indexType; - int index; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t ifnamType; - ifname_t ifnam; - mach_msg_type_t indexType; - int index; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_iioctl_siocgifname - (io_t reqport, ifname_t ifnam, int *index); - - auto const mach_msg_type_t ifnamCheck = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t indexCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t ifnamType = { - /* msgt_name = */ 8, - /* msgt_size = */ 8, - /* msgt_number = */ 16, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t indexType = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - -#if TypeCheck - if ((In0P->Head.msgh_size != 52) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->ifnamType, &ifnamCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->indexType, &indexCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_iioctl_siocgifname(In0P->Head.msgh_request_port, In0P->ifnam, &In0P->index); - if (OutP->RetCode != KERN_SUCCESS) - return; - - OutP->Head.msgh_size = 60; - - OutP->ifnamType = ifnamType; - - { typedef struct { char data[16]; } *sp; * (sp) OutP->ifnam = * (sp) In0P->ifnam; } - - OutP->indexType = indexType; - - OutP->index = In0P->index; -} - -static mig_routine_t iioctl_server_routines[] = { - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - _Xiioctl_siocsifaddr, - 0, - _Xiioctl_siocsifdstaddr, - 0, - _Xiioctl_siocsifflags, - _Xiioctl_siocgifflags, - 0, - _Xiioctl_siocsifbrdaddr, - 0, - 0, - _Xiioctl_siocsifnetmask, - _Xiioctl_siocgifmetric, - _Xiioctl_siocsifmetric, - _Xiioctl_siocdifaddr, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - _Xiioctl_siocgifaddr, - _Xiioctl_siocgifdstaddr, - _Xiioctl_siocgifbrdaddr, - 0, - _Xiioctl_siocgifnetmask, - 0, - _Xiioctl_siocgifhwaddr, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - _Xiioctl_siocgifmtu, - _Xiioctl_siocsifmtu, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - _Xiioctl_siocgifindex, - _Xiioctl_siocgifname, -}; - -mig_external boolean_t iioctl_server - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - register mach_msg_header_t *InP = InHeadP; - register mig_reply_header_t *OutP = (mig_reply_header_t *) OutHeadP; - - auto const mach_msg_type_t RetCodeType = { - /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - register mig_routine_t routine; - - OutP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InP->msgh_bits), 0); - OutP->Head.msgh_size = sizeof *OutP; - OutP->Head.msgh_remote_port = InP->msgh_reply_port; - OutP->Head.msgh_local_port = MACH_PORT_NULL; - OutP->Head.msgh_seqno = 0; - OutP->Head.msgh_id = InP->msgh_id + 100; - - OutP->RetCodeType = RetCodeType; - - if ((InP->msgh_id > 112091) || (InP->msgh_id < 112000) || - ((routine = iioctl_server_routines[InP->msgh_id - 112000]) == 0)) { - OutP->RetCode = MIG_BAD_ID; - return FALSE; - } - (*routine) (InP, &OutP->Head); - return TRUE; -} - -mig_external mig_routine_t iioctl_server_routine - (const mach_msg_header_t *InHeadP) -{ - register int msgh_id; - - msgh_id = InHeadP->msgh_id - 112000; - - if ((msgh_id > 91) || (msgh_id < 0)) - return 0; - - return iioctl_server_routines[msgh_id]; -} - diff --git a/pfinet.old/ioServer.c b/pfinet.old/ioServer.c deleted file mode 100644 index 979ce37d..00000000 --- a/pfinet.old/ioServer.c +++ /dev/null @@ -1,2021 +0,0 @@ -/* Module io */ - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE 1 -#endif - -#define EXPORT_BOOLEAN -#include <mach/boolean.h> -#include <mach/kern_return.h> -#include <mach/message.h> -#include <mach/mig_errors.h> -#include <mach/mig_support.h> - -#ifndef mig_internal -#define mig_internal static -#endif - -#ifndef mig_external -#define mig_external -#endif - -#ifndef TypeCheck -#define TypeCheck 1 -#endif - -#ifndef UseExternRCSId -#define UseExternRCSId 1 -#endif - -#define BAD_TYPECHECK(type, check) ({\ - union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\ - _t.t = *(type); _c.t = *(check); _t.w != _c.w; }) -#define msgh_request_port msgh_local_port -#define MACH_MSGH_BITS_REQUEST(bits) MACH_MSGH_BITS_LOCAL(bits) -#define msgh_reply_port msgh_remote_port -#define MACH_MSGH_BITS_REPLY(bits) MACH_MSGH_BITS_REMOTE(bits) - -#include <mach/std_types.h> -#include <mach/mach_types.h> -#include <device/device_types.h> -#include <device/net_status.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/statfs.h> -#include <sys/resource.h> -#include <sys/utsname.h> -#include <hurd/hurd_types.h> -#include "pfinet.h" - -/* Routine io_write */ -mig_internal void _Xio_write - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_long_t dataType; - char data[2048]; - mach_msg_type_t offsetType; - loff_t offset; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t amountType; - vm_size_t amount; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Request *In1P; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_io_write - (sock_user_t io_object, data_t data, mach_msg_type_number_t dataCnt, loff_t offset, vm_size_t *amount); - -#if TypeCheck - boolean_t msgh_simple; -#endif /* TypeCheck */ - - unsigned int msgh_size; - unsigned int msgh_size_delta; - - auto const mach_msg_type_t offsetCheck = { - /* msgt_name = */ 11, - /* msgt_size = */ 64, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t amountType = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t io_object; - -#if TypeCheck - msgh_size = In0P->Head.msgh_size; - msgh_simple = !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); - if ((msgh_size < 48)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if ((In0P->dataType.msgtl_header.msgt_longform != TRUE) || - (In0P->dataType.msgtl_name != 8) || - (In0P->dataType.msgtl_size != 8)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - msgh_size_delta = (In0P->dataType.msgtl_header.msgt_inline) ? (In0P->dataType.msgtl_number + 3) & ~3 : sizeof(char *); -#if TypeCheck - if (msgh_size != 48 + msgh_size_delta) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - In1P = (Request *) ((char *) In0P + msgh_size_delta - 2048); - -#if TypeCheck - if (BAD_TYPECHECK(&In1P->offsetType, &offsetCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - io_object = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_io_write(io_object, (In0P->dataType.msgtl_header.msgt_inline) ? In0P->data : *((char **)In0P->data), In0P->dataType.msgtl_number, In1P->offset, &OutP->amount); - if (OutP->RetCode == KERN_SUCCESS) - if (!In0P->dataType.msgtl_header.msgt_inline) - __mig_deallocate(* (vm_offset_t *) In0P->data, In0P->dataType.msgtl_number); - end_using_socket_port(io_object); - if (OutP->RetCode != KERN_SUCCESS) - return; - - OutP->Head.msgh_size = 40; - - OutP->amountType = amountType; -} - -/* Routine io_read */ -mig_internal void _Xio_read - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t offsetType; - loff_t offset; - mach_msg_type_t amountType; - vm_size_t amount; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_long_t dataType; - char data[2048]; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_io_read - (sock_user_t io_object, data_t *data, mach_msg_type_number_t *dataCnt, loff_t offset, vm_size_t amount); - - boolean_t msgh_simple; - auto const mach_msg_type_t offsetCheck = { - /* msgt_name = */ 11, - /* msgt_size = */ 64, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t amountCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_long_t dataType = { - { - /* msgt_name = */ 0, - /* msgt_size = */ 0, - /* msgt_number = */ 0, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ TRUE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }, - /* msgtl_name = */ 8, - /* msgtl_size = */ 8, - /* msgtl_number = */ 2048, - }; - - sock_user_t io_object; - mach_msg_type_number_t dataCnt; - - char *dataP; - -#if TypeCheck - if ((In0P->Head.msgh_size != 44) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->offsetType, &offsetCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->amountType, &amountCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - io_object = begin_using_socket_port(In0P->Head.msgh_request_port); - - dataP = OutP->data; - dataCnt = 2048; - - OutP->RetCode = S_io_read(io_object, &dataP, &dataCnt, In0P->offset, In0P->amount); - end_using_socket_port(io_object); - if (OutP->RetCode != KERN_SUCCESS) - return; - - msgh_simple = TRUE; - - OutP->dataType = dataType; - if (dataP != OutP->data) { - OutP->dataType.msgtl_header.msgt_inline = FALSE; - OutP->dataType.msgtl_header.msgt_deallocate = TRUE; - *((char **)OutP->data) = dataP; - msgh_simple = FALSE; - } - - OutP->dataType.msgtl_number = dataCnt; - OutP->Head.msgh_size = 44 + ((OutP->dataType.msgtl_header.msgt_inline) ? (dataCnt + 3) & ~3 : sizeof(char *)); - - if (!msgh_simple) - OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; -} - -/* Routine io_seek */ -mig_internal void _Xio_seek - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t offsetType; - loff_t offset; - mach_msg_type_t whenceType; - int whence; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t newpType; - loff_t newp; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_io_seek - (sock_user_t io_object, loff_t offset, int whence, loff_t *newp); - - auto const mach_msg_type_t offsetCheck = { - /* msgt_name = */ 11, - /* msgt_size = */ 64, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t whenceCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t newpType = { - /* msgt_name = */ 11, - /* msgt_size = */ 64, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t io_object; - -#if TypeCheck - if ((In0P->Head.msgh_size != 44) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->offsetType, &offsetCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->whenceType, &whenceCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - io_object = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_io_seek(io_object, In0P->offset, In0P->whence, &OutP->newp); - end_using_socket_port(io_object); - if (OutP->RetCode != KERN_SUCCESS) - return; - - OutP->Head.msgh_size = 44; - - OutP->newpType = newpType; -} - -/* Routine io_readable */ -mig_internal void _Xio_readable - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t amountType; - vm_size_t amount; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_io_readable - (sock_user_t io_object, vm_size_t *amount); - - auto const mach_msg_type_t amountType = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t io_object; - -#if TypeCheck - if ((In0P->Head.msgh_size != 24) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - io_object = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_io_readable(io_object, &OutP->amount); - end_using_socket_port(io_object); - if (OutP->RetCode != KERN_SUCCESS) - return; - - OutP->Head.msgh_size = 40; - - OutP->amountType = amountType; -} - -/* Routine io_set_all_openmodes */ -mig_internal void _Xio_set_all_openmodes - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t newbitsType; - int newbits; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_io_set_all_openmodes - (sock_user_t io_object, int newbits); - - auto const mach_msg_type_t newbitsCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t io_object; - -#if TypeCheck - if ((In0P->Head.msgh_size != 32) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->newbitsType, &newbitsCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - io_object = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_io_set_all_openmodes(io_object, In0P->newbits); - end_using_socket_port(io_object); -} - -/* Routine io_get_openmodes */ -mig_internal void _Xio_get_openmodes - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t bitsType; - int bits; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_io_get_openmodes - (sock_user_t io_object, int *bits); - - auto const mach_msg_type_t bitsType = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t io_object; - -#if TypeCheck - if ((In0P->Head.msgh_size != 24) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - io_object = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_io_get_openmodes(io_object, &OutP->bits); - end_using_socket_port(io_object); - if (OutP->RetCode != KERN_SUCCESS) - return; - - OutP->Head.msgh_size = 40; - - OutP->bitsType = bitsType; -} - -/* Routine io_set_some_openmodes */ -mig_internal void _Xio_set_some_openmodes - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t bits_to_setType; - int bits_to_set; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_io_set_some_openmodes - (sock_user_t io_object, int bits_to_set); - - auto const mach_msg_type_t bits_to_setCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t io_object; - -#if TypeCheck - if ((In0P->Head.msgh_size != 32) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->bits_to_setType, &bits_to_setCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - io_object = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_io_set_some_openmodes(io_object, In0P->bits_to_set); - end_using_socket_port(io_object); -} - -/* Routine io_clear_some_openmodes */ -mig_internal void _Xio_clear_some_openmodes - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t bits_to_clearType; - int bits_to_clear; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_io_clear_some_openmodes - (sock_user_t io_object, int bits_to_clear); - - auto const mach_msg_type_t bits_to_clearCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t io_object; - -#if TypeCheck - if ((In0P->Head.msgh_size != 32) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->bits_to_clearType, &bits_to_clearCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - io_object = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_io_clear_some_openmodes(io_object, In0P->bits_to_clear); - end_using_socket_port(io_object); -} - -/* Routine io_async */ -mig_internal void _Xio_async - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t notify_portType; - mach_port_t notify_port; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t async_id_portType; - mach_port_t async_id_port; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_io_async - (sock_user_t io_object, mach_port_t notify_port, mach_port_t *async_id_port, mach_msg_type_name_t *async_id_portPoly); - - boolean_t msgh_simple; - auto const mach_msg_type_t notify_portCheck = { - /* msgt_name = */ 17, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t async_id_portType = { - /* msgt_name = */ -1, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t io_object; - mach_msg_type_name_t async_id_portPoly; - -#if TypeCheck - if ((In0P->Head.msgh_size != 32) || - !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->notify_portType, ¬ify_portCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - io_object = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_io_async(io_object, In0P->notify_port, &OutP->async_id_port, &async_id_portPoly); - end_using_socket_port(io_object); - if (OutP->RetCode != KERN_SUCCESS) - return; - - msgh_simple = TRUE; - OutP->Head.msgh_size = 40; - - OutP->async_id_portType = async_id_portType; - - if (MACH_MSG_TYPE_PORT_ANY(async_id_portPoly)) - msgh_simple = FALSE; - - OutP->async_id_portType.msgt_name = async_id_portPoly; - - if (!msgh_simple) - OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; -} - -/* Routine io_mod_owner */ -mig_internal void _Xio_mod_owner - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t ownerType; - pid_t owner; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_io_mod_owner - (sock_user_t io_object, pid_t owner); - - auto const mach_msg_type_t ownerCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t io_object; - -#if TypeCheck - if ((In0P->Head.msgh_size != 32) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->ownerType, &ownerCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - io_object = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_io_mod_owner(io_object, In0P->owner); - end_using_socket_port(io_object); -} - -/* Routine io_get_owner */ -mig_internal void _Xio_get_owner - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t ownerType; - pid_t owner; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_io_get_owner - (sock_user_t io_object, pid_t *owner); - - auto const mach_msg_type_t ownerType = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t io_object; - -#if TypeCheck - if ((In0P->Head.msgh_size != 24) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - io_object = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_io_get_owner(io_object, &OutP->owner); - end_using_socket_port(io_object); - if (OutP->RetCode != KERN_SUCCESS) - return; - - OutP->Head.msgh_size = 40; - - OutP->ownerType = ownerType; -} - -/* Routine io_get_icky_async_id */ -mig_internal void _Xio_get_icky_async_id - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t icky_async_id_portType; - mach_port_t icky_async_id_port; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_io_get_icky_async_id - (sock_user_t io_object, mach_port_t *icky_async_id_port, mach_msg_type_name_t *icky_async_id_portPoly); - - boolean_t msgh_simple; - auto const mach_msg_type_t icky_async_id_portType = { - /* msgt_name = */ -1, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t io_object; - mach_msg_type_name_t icky_async_id_portPoly; - -#if TypeCheck - if ((In0P->Head.msgh_size != 24) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - io_object = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_io_get_icky_async_id(io_object, &OutP->icky_async_id_port, &icky_async_id_portPoly); - end_using_socket_port(io_object); - if (OutP->RetCode != KERN_SUCCESS) - return; - - msgh_simple = TRUE; - OutP->Head.msgh_size = 40; - - OutP->icky_async_id_portType = icky_async_id_portType; - - if (MACH_MSG_TYPE_PORT_ANY(icky_async_id_portPoly)) - msgh_simple = FALSE; - - OutP->icky_async_id_portType.msgt_name = icky_async_id_portPoly; - - if (!msgh_simple) - OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; -} - -/* Routine io_select */ -mig_internal void _Xio_select - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t select_typeType; - int select_type; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t select_typeType; - int select_type; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_io_select - (sock_user_t io_object, mach_port_t reply, mach_msg_type_name_t replyPoly, int *select_type); - - auto const mach_msg_type_t select_typeCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t select_typeType = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t io_object; - -#if TypeCheck - if ((In0P->Head.msgh_size != 32) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->select_typeType, &select_typeCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - io_object = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_io_select(io_object, In0P->Head.msgh_reply_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits), &In0P->select_type); - end_using_socket_port(io_object); - if (OutP->RetCode != KERN_SUCCESS) - return; - - OutP->Head.msgh_size = 40; - - OutP->select_typeType = select_typeType; - - OutP->select_type = In0P->select_type; -} - -/* Routine io_stat */ -mig_internal void _Xio_stat - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t stat_infoType; - io_statbuf_t stat_info; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_io_stat - (sock_user_t stat_object, io_statbuf_t *stat_info); - - auto const mach_msg_type_t stat_infoType = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 32, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t stat_object; - -#if TypeCheck - if ((In0P->Head.msgh_size != 24) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - stat_object = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_io_stat(stat_object, &OutP->stat_info); - end_using_socket_port(stat_object); - if (OutP->RetCode != KERN_SUCCESS) - return; - - OutP->Head.msgh_size = 164; - - OutP->stat_infoType = stat_infoType; -} - -/* SimpleRoutine io_reauthenticate */ -mig_internal void _Xio_reauthenticate - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t rendezvous2Type; - mach_port_t rendezvous2; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_io_reauthenticate - (sock_user_t auth_object, mach_port_t rendezvous2); - - auto const mach_msg_type_t rendezvous2Check = { - /* msgt_name = */ 17, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t auth_object; - -#if TypeCheck - if ((In0P->Head.msgh_size != 32) || - !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->rendezvous2Type, &rendezvous2Check)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - auth_object = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_io_reauthenticate(auth_object, In0P->rendezvous2); - end_using_socket_port(auth_object); -} - -/* Routine io_restrict_auth */ -mig_internal void _Xio_restrict_auth - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_long_t uidsType; - uid_t uids[512]; - mach_msg_type_long_t gidsType; - uid_t gids[512]; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t new_objectType; - mach_port_t new_object; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Request *In1P; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_io_restrict_auth - (sock_user_t io_object, mach_port_t *new_object, mach_msg_type_name_t *new_objectPoly, idarray_t uids, mach_msg_type_number_t uidsCnt, idarray_t gids, mach_msg_type_number_t gidsCnt); - - boolean_t msgh_simple; - unsigned int msgh_size; - unsigned int msgh_size_delta; - - auto const mach_msg_type_t new_objectType = { - /* msgt_name = */ -1, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t io_object; - mach_msg_type_name_t new_objectPoly; - -#if TypeCheck - msgh_size = In0P->Head.msgh_size; - msgh_simple = !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); - if ((msgh_size < 48)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if ((In0P->uidsType.msgtl_header.msgt_longform != TRUE) || - (In0P->uidsType.msgtl_name != 2) || - (In0P->uidsType.msgtl_size != 32)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - msgh_size_delta = (In0P->uidsType.msgtl_header.msgt_inline) ? 4 * In0P->uidsType.msgtl_number : sizeof(uid_t *); -#if TypeCheck - if (msgh_size < 48 + msgh_size_delta) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } - msgh_size -= msgh_size_delta; -#endif /* TypeCheck */ - - In1P = (Request *) ((char *) In0P + msgh_size_delta - 2048); - -#if TypeCheck - if ((In1P->gidsType.msgtl_header.msgt_longform != TRUE) || - (In1P->gidsType.msgtl_name != 2) || - (In1P->gidsType.msgtl_size != 32)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (msgh_size != 48 + ((In1P->gidsType.msgtl_header.msgt_inline) ? 4 * In1P->gidsType.msgtl_number : sizeof(uid_t *))) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - io_object = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_io_restrict_auth(io_object, &OutP->new_object, &new_objectPoly, (In0P->uidsType.msgtl_header.msgt_inline) ? In0P->uids : *((uid_t **)In0P->uids), In0P->uidsType.msgtl_number, (In1P->gidsType.msgtl_header.msgt_inline) ? In1P->gids : *((uid_t **)In1P->gids), In1P->gidsType.msgtl_number); - if (OutP->RetCode == KERN_SUCCESS) - if (!In1P->gidsType.msgtl_header.msgt_inline) - __mig_deallocate(* (vm_offset_t *) In1P->gids, 4 * In1P->gidsType.msgtl_number); - if (OutP->RetCode == KERN_SUCCESS) - if (!In0P->uidsType.msgtl_header.msgt_inline) - __mig_deallocate(* (vm_offset_t *) In0P->uids, 4 * In0P->uidsType.msgtl_number); - end_using_socket_port(io_object); - if (OutP->RetCode != KERN_SUCCESS) - return; - - msgh_simple = TRUE; - OutP->Head.msgh_size = 40; - - OutP->new_objectType = new_objectType; - - if (MACH_MSG_TYPE_PORT_ANY(new_objectPoly)) - msgh_simple = FALSE; - - OutP->new_objectType.msgt_name = new_objectPoly; - - if (!msgh_simple) - OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; -} - -/* Routine io_duplicate */ -mig_internal void _Xio_duplicate - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t newportType; - mach_port_t newport; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_io_duplicate - (sock_user_t io_object, mach_port_t *newport, mach_msg_type_name_t *newportPoly); - - boolean_t msgh_simple; - auto const mach_msg_type_t newportType = { - /* msgt_name = */ -1, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t io_object; - mach_msg_type_name_t newportPoly; - -#if TypeCheck - if ((In0P->Head.msgh_size != 24) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - io_object = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_io_duplicate(io_object, &OutP->newport, &newportPoly); - end_using_socket_port(io_object); - if (OutP->RetCode != KERN_SUCCESS) - return; - - msgh_simple = TRUE; - OutP->Head.msgh_size = 40; - - OutP->newportType = newportType; - - if (MACH_MSG_TYPE_PORT_ANY(newportPoly)) - msgh_simple = FALSE; - - OutP->newportType.msgt_name = newportPoly; - - if (!msgh_simple) - OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; -} - -/* Routine io_server_version */ -mig_internal void _Xio_server_version - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t server_nameType; - string_t server_name; - mach_msg_type_t server_major_versionType; - int server_major_version; - mach_msg_type_t server_minor_versionType; - int server_minor_version; - mach_msg_type_t server_edit_levelType; - int server_edit_level; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_io_server_version - (sock_user_t vers_object, string_t server_name, int *server_major_version, int *server_minor_version, int *server_edit_level); - - auto const mach_msg_type_t server_nameType = { - /* msgt_name = */ MACH_MSG_TYPE_STRING_C, - /* msgt_size = */ 8, - /* msgt_number = */ 1024, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t server_major_versionType = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t server_minor_versionType = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t server_edit_levelType = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t vers_object; - -#if TypeCheck - if ((In0P->Head.msgh_size != 24) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - vers_object = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_io_server_version(vers_object, OutP->server_name, &OutP->server_major_version, &OutP->server_minor_version, &OutP->server_edit_level); - end_using_socket_port(vers_object); - if (OutP->RetCode != KERN_SUCCESS) - return; - - OutP->Head.msgh_size = 1084; - - OutP->server_nameType = server_nameType; - - OutP->server_major_versionType = server_major_versionType; - - OutP->server_minor_versionType = server_minor_versionType; - - OutP->server_edit_levelType = server_edit_levelType; -} - -/* Routine io_map */ -mig_internal void _Xio_map - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t memobjrdType; - mach_port_t memobjrd; - mach_msg_type_t memobjwtType; - mach_port_t memobjwt; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_io_map - (sock_user_t io_object, mach_port_t *memobjrd, mach_msg_type_name_t *memobjrdPoly, mach_port_t *memobjwt, mach_msg_type_name_t *memobjwtPoly); - - boolean_t msgh_simple; - auto const mach_msg_type_t memobjrdType = { - /* msgt_name = */ -1, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t memobjwtType = { - /* msgt_name = */ -1, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t io_object; - mach_msg_type_name_t memobjrdPoly; - mach_msg_type_name_t memobjwtPoly; - -#if TypeCheck - if ((In0P->Head.msgh_size != 24) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - io_object = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_io_map(io_object, &OutP->memobjrd, &memobjrdPoly, &OutP->memobjwt, &memobjwtPoly); - end_using_socket_port(io_object); - if (OutP->RetCode != KERN_SUCCESS) - return; - - msgh_simple = TRUE; - OutP->Head.msgh_size = 48; - - OutP->memobjrdType = memobjrdType; - - if (MACH_MSG_TYPE_PORT_ANY(memobjrdPoly)) - msgh_simple = FALSE; - - OutP->memobjrdType.msgt_name = memobjrdPoly; - - OutP->memobjwtType = memobjwtType; - - if (MACH_MSG_TYPE_PORT_ANY(memobjwtPoly)) - msgh_simple = FALSE; - - OutP->memobjwtType.msgt_name = memobjwtPoly; - - if (!msgh_simple) - OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; -} - -/* Routine io_map_cntl */ -mig_internal void _Xio_map_cntl - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t memobjType; - mach_port_t memobj; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_io_map_cntl - (sock_user_t io_object, mach_port_t *memobj, mach_msg_type_name_t *memobjPoly); - - boolean_t msgh_simple; - auto const mach_msg_type_t memobjType = { - /* msgt_name = */ -1, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t io_object; - mach_msg_type_name_t memobjPoly; - -#if TypeCheck - if ((In0P->Head.msgh_size != 24) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - io_object = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_io_map_cntl(io_object, &OutP->memobj, &memobjPoly); - end_using_socket_port(io_object); - if (OutP->RetCode != KERN_SUCCESS) - return; - - msgh_simple = TRUE; - OutP->Head.msgh_size = 40; - - OutP->memobjType = memobjType; - - if (MACH_MSG_TYPE_PORT_ANY(memobjPoly)) - msgh_simple = FALSE; - - OutP->memobjType.msgt_name = memobjPoly; - - if (!msgh_simple) - OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; -} - -/* Routine io_get_conch */ -mig_internal void _Xio_get_conch - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_io_get_conch - (sock_user_t io_object); - - sock_user_t io_object; - -#if TypeCheck - if ((In0P->Head.msgh_size != 24) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - io_object = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_io_get_conch(io_object); - end_using_socket_port(io_object); -} - -/* Routine io_release_conch */ -mig_internal void _Xio_release_conch - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_io_release_conch - (sock_user_t io_object); - - sock_user_t io_object; - -#if TypeCheck - if ((In0P->Head.msgh_size != 24) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - io_object = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_io_release_conch(io_object); - end_using_socket_port(io_object); -} - -/* Routine io_eofnotify */ -mig_internal void _Xio_eofnotify - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_io_eofnotify - (sock_user_t io_object); - - sock_user_t io_object; - -#if TypeCheck - if ((In0P->Head.msgh_size != 24) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - io_object = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_io_eofnotify(io_object); - end_using_socket_port(io_object); -} - -/* Routine io_prenotify */ -mig_internal void _Xio_prenotify - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t write_startType; - vm_offset_t write_start; - mach_msg_type_t write_endType; - vm_offset_t write_end; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_io_prenotify - (sock_user_t io_object, vm_offset_t write_start, vm_offset_t write_end); - - auto const mach_msg_type_t write_startCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t write_endCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t io_object; - -#if TypeCheck - if ((In0P->Head.msgh_size != 40) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->write_startType, &write_startCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->write_endType, &write_endCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - io_object = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_io_prenotify(io_object, In0P->write_start, In0P->write_end); - end_using_socket_port(io_object); -} - -/* Routine io_postnotify */ -mig_internal void _Xio_postnotify - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t write_startType; - vm_offset_t write_start; - mach_msg_type_t write_endType; - vm_offset_t write_end; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_io_postnotify - (sock_user_t io_object, vm_offset_t write_start, vm_offset_t write_end); - - auto const mach_msg_type_t write_startCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t write_endCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t io_object; - -#if TypeCheck - if ((In0P->Head.msgh_size != 40) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->write_startType, &write_startCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->write_endType, &write_endCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - io_object = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_io_postnotify(io_object, In0P->write_start, In0P->write_end); - end_using_socket_port(io_object); -} - -/* Routine io_readnotify */ -mig_internal void _Xio_readnotify - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_io_readnotify - (sock_user_t io_object); - - sock_user_t io_object; - -#if TypeCheck - if ((In0P->Head.msgh_size != 24) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - io_object = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_io_readnotify(io_object); - end_using_socket_port(io_object); -} - -/* Routine io_readsleep */ -mig_internal void _Xio_readsleep - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_io_readsleep - (sock_user_t io_object); - - sock_user_t io_object; - -#if TypeCheck - if ((In0P->Head.msgh_size != 24) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - io_object = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_io_readsleep(io_object); - end_using_socket_port(io_object); -} - -/* Routine io_sigio */ -mig_internal void _Xio_sigio - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_io_sigio - (sock_user_t io_object); - - sock_user_t io_object; - -#if TypeCheck - if ((In0P->Head.msgh_size != 24) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - io_object = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_io_sigio(io_object); - end_using_socket_port(io_object); -} - -/* Routine io_pathconf */ -mig_internal void _Xio_pathconf - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t nameType; - int name; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t valueType; - int value; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_io_pathconf - (sock_user_t io_object, int name, int *value); - - auto const mach_msg_type_t nameCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t valueType = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t io_object; - -#if TypeCheck - if ((In0P->Head.msgh_size != 32) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - io_object = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_io_pathconf(io_object, In0P->name, &OutP->value); - end_using_socket_port(io_object); - if (OutP->RetCode != KERN_SUCCESS) - return; - - OutP->Head.msgh_size = 40; - - OutP->valueType = valueType; -} - -/* Routine io_identity */ -mig_internal void _Xio_identity - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t idportType; - mach_port_t idport; - mach_msg_type_t fsidportType; - mach_port_t fsidport; - mach_msg_type_t filenoType; - ino64_t fileno; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_io_identity - (sock_user_t io_object, mach_port_t *idport, mach_msg_type_name_t *idportPoly, mach_port_t *fsidport, mach_msg_type_name_t *fsidportPoly, ino64_t *fileno); - - boolean_t msgh_simple; - auto const mach_msg_type_t idportType = { - /* msgt_name = */ -1, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t fsidportType = { - /* msgt_name = */ -1, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t filenoType = { - /* msgt_name = */ 11, - /* msgt_size = */ 64, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t io_object; - mach_msg_type_name_t idportPoly; - mach_msg_type_name_t fsidportPoly; - -#if TypeCheck - if ((In0P->Head.msgh_size != 24) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - io_object = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_io_identity(io_object, &OutP->idport, &idportPoly, &OutP->fsidport, &fsidportPoly, &OutP->fileno); - end_using_socket_port(io_object); - if (OutP->RetCode != KERN_SUCCESS) - return; - - msgh_simple = TRUE; - OutP->Head.msgh_size = 60; - - OutP->idportType = idportType; - - if (MACH_MSG_TYPE_PORT_ANY(idportPoly)) - msgh_simple = FALSE; - - OutP->idportType.msgt_name = idportPoly; - - OutP->fsidportType = fsidportType; - - if (MACH_MSG_TYPE_PORT_ANY(fsidportPoly)) - msgh_simple = FALSE; - - OutP->fsidportType.msgt_name = fsidportPoly; - - OutP->filenoType = filenoType; - - if (!msgh_simple) - OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; -} - -/* Routine io_revoke */ -mig_internal void _Xio_revoke - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_io_revoke - (sock_user_t io_object); - - sock_user_t io_object; - -#if TypeCheck - if ((In0P->Head.msgh_size != 24) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - io_object = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_io_revoke(io_object); - end_using_socket_port(io_object); -} - -static mig_routine_t io_server_routines[] = { - _Xio_write, - _Xio_read, - _Xio_seek, - _Xio_readable, - _Xio_set_all_openmodes, - _Xio_get_openmodes, - _Xio_set_some_openmodes, - _Xio_clear_some_openmodes, - _Xio_async, - _Xio_mod_owner, - _Xio_get_owner, - _Xio_get_icky_async_id, - _Xio_select, - _Xio_stat, - _Xio_reauthenticate, - _Xio_restrict_auth, - _Xio_duplicate, - _Xio_server_version, - _Xio_map, - _Xio_map_cntl, - _Xio_get_conch, - _Xio_release_conch, - _Xio_eofnotify, - _Xio_prenotify, - _Xio_postnotify, - _Xio_readnotify, - _Xio_readsleep, - _Xio_sigio, - _Xio_pathconf, - _Xio_identity, - _Xio_revoke, -}; - -mig_external boolean_t io_server - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - register mach_msg_header_t *InP = InHeadP; - register mig_reply_header_t *OutP = (mig_reply_header_t *) OutHeadP; - - auto const mach_msg_type_t RetCodeType = { - /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - register mig_routine_t routine; - - OutP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InP->msgh_bits), 0); - OutP->Head.msgh_size = sizeof *OutP; - OutP->Head.msgh_remote_port = InP->msgh_reply_port; - OutP->Head.msgh_local_port = MACH_PORT_NULL; - OutP->Head.msgh_seqno = 0; - OutP->Head.msgh_id = InP->msgh_id + 100; - - OutP->RetCodeType = RetCodeType; - - if ((InP->msgh_id > 21030) || (InP->msgh_id < 21000) || - ((routine = io_server_routines[InP->msgh_id - 21000]) == 0)) { - OutP->RetCode = MIG_BAD_ID; - return FALSE; - } - (*routine) (InP, &OutP->Head); - return TRUE; -} - -mig_external mig_routine_t io_server_routine - (const mach_msg_header_t *InHeadP) -{ - register int msgh_id; - - msgh_id = InHeadP->msgh_id - 21000; - - if ((msgh_id > 30) || (msgh_id < 0)) - return 0; - - return io_server_routines[msgh_id]; -} - diff --git a/pfinet.old/pfinetServer.c b/pfinet.old/pfinetServer.c deleted file mode 100644 index 14408d21..00000000 --- a/pfinet.old/pfinetServer.c +++ /dev/null @@ -1,189 +0,0 @@ -/* Module pfinet */ - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE 1 -#endif - -#define EXPORT_BOOLEAN -#include <mach/boolean.h> -#include <mach/kern_return.h> -#include <mach/message.h> -#include <mach/mig_errors.h> -#include <mach/mig_support.h> - -#ifndef mig_internal -#define mig_internal static -#endif - -#ifndef mig_external -#define mig_external -#endif - -#ifndef TypeCheck -#define TypeCheck 1 -#endif - -#ifndef UseExternRCSId -#define UseExternRCSId 1 -#endif - -#define BAD_TYPECHECK(type, check) ({\ - union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\ - _t.t = *(type); _c.t = *(check); _t.w != _c.w; }) -#define msgh_request_port msgh_local_port -#define MACH_MSGH_BITS_REQUEST(bits) MACH_MSGH_BITS_LOCAL(bits) -#define msgh_reply_port msgh_remote_port -#define MACH_MSGH_BITS_REPLY(bits) MACH_MSGH_BITS_REMOTE(bits) - -#include <mach/std_types.h> -#include <mach/mach_types.h> -#include <device/device_types.h> -#include <device/net_status.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/statfs.h> -#include <sys/resource.h> -#include <sys/utsname.h> -#include <hurd/hurd_types.h> - -/* Routine pfinet_siocgifconf */ -mig_internal void _Xpfinet_siocgifconf - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t amountType; - vm_size_t amount; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_long_t bufType; - char buf[2048]; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_pfinet_siocgifconf - (io_t port, vm_size_t amount, data_t *buf, mach_msg_type_number_t *bufCnt); - - boolean_t msgh_simple; - auto const mach_msg_type_t amountCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_long_t bufType = { - { - /* msgt_name = */ 0, - /* msgt_size = */ 0, - /* msgt_number = */ 0, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ TRUE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }, - /* msgtl_name = */ 8, - /* msgtl_size = */ 8, - /* msgtl_number = */ 2048, - }; - - mach_msg_type_number_t bufCnt; - - char *bufP; - -#if TypeCheck - if ((In0P->Head.msgh_size != 32) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->amountType, &amountCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - bufP = OutP->buf; - bufCnt = 2048; - - OutP->RetCode = S_pfinet_siocgifconf(In0P->Head.msgh_request_port, In0P->amount, &bufP, &bufCnt); - if (OutP->RetCode != KERN_SUCCESS) - return; - - msgh_simple = TRUE; - - OutP->bufType = bufType; - if (bufP != OutP->buf) { - OutP->bufType.msgtl_header.msgt_inline = FALSE; - OutP->bufType.msgtl_header.msgt_deallocate = TRUE; - *((char **)OutP->buf) = bufP; - msgh_simple = FALSE; - } - - OutP->bufType.msgtl_number = bufCnt; - OutP->Head.msgh_size = 44 + ((OutP->bufType.msgtl_header.msgt_inline) ? (bufCnt + 3) & ~3 : sizeof(char *)); - - if (!msgh_simple) - OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; -} - -static mig_routine_t pfinet_server_routines[] = { - _Xpfinet_siocgifconf, -}; - -mig_external boolean_t pfinet_server - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - register mach_msg_header_t *InP = InHeadP; - register mig_reply_header_t *OutP = (mig_reply_header_t *) OutHeadP; - - auto const mach_msg_type_t RetCodeType = { - /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - register mig_routine_t routine; - - OutP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InP->msgh_bits), 0); - OutP->Head.msgh_size = sizeof *OutP; - OutP->Head.msgh_remote_port = InP->msgh_reply_port; - OutP->Head.msgh_local_port = MACH_PORT_NULL; - OutP->Head.msgh_seqno = 0; - OutP->Head.msgh_id = InP->msgh_id + 100; - - OutP->RetCodeType = RetCodeType; - - if ((InP->msgh_id > 37000) || (InP->msgh_id < 37000) || - ((routine = pfinet_server_routines[InP->msgh_id - 37000]) == 0)) { - OutP->RetCode = MIG_BAD_ID; - return FALSE; - } - (*routine) (InP, &OutP->Head); - return TRUE; -} - -mig_external mig_routine_t pfinet_server_routine - (const mach_msg_header_t *InHeadP) -{ - register int msgh_id; - - msgh_id = InHeadP->msgh_id - 37000; - - if ((msgh_id > 0) || (msgh_id < 0)) - return 0; - - return pfinet_server_routines[msgh_id]; -} - diff --git a/pfinet.old/socketServer.c b/pfinet.old/socketServer.c deleted file mode 100644 index baacef9d..00000000 --- a/pfinet.old/socketServer.c +++ /dev/null @@ -1,1533 +0,0 @@ -/* Module socket */ - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE 1 -#endif - -#define EXPORT_BOOLEAN -#include <mach/boolean.h> -#include <mach/kern_return.h> -#include <mach/message.h> -#include <mach/mig_errors.h> -#include <mach/mig_support.h> - -#ifndef mig_internal -#define mig_internal static -#endif - -#ifndef mig_external -#define mig_external -#endif - -#ifndef TypeCheck -#define TypeCheck 1 -#endif - -#ifndef UseExternRCSId -#define UseExternRCSId 1 -#endif - -#define BAD_TYPECHECK(type, check) ({\ - union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\ - _t.t = *(type); _c.t = *(check); _t.w != _c.w; }) -#define msgh_request_port msgh_local_port -#define MACH_MSGH_BITS_REQUEST(bits) MACH_MSGH_BITS_LOCAL(bits) -#define msgh_reply_port msgh_remote_port -#define MACH_MSGH_BITS_REPLY(bits) MACH_MSGH_BITS_REMOTE(bits) - -#include <mach/std_types.h> -#include <mach/mach_types.h> -#include <device/device_types.h> -#include <device/net_status.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/statfs.h> -#include <sys/resource.h> -#include <sys/utsname.h> -#include <hurd/hurd_types.h> -#include "pfinet.h" - -/* Routine socket_create */ -mig_internal void _Xsocket_create - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t sock_typeType; - int sock_type; - mach_msg_type_t protocolType; - int protocol; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t sockType; - mach_port_t sock; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_socket_create - (trivfs_protid_t server, int sock_type, int protocol, mach_port_t *sock, mach_msg_type_name_t *sockPoly); - - boolean_t msgh_simple; - auto const mach_msg_type_t sock_typeCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t protocolCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t sockType = { - /* msgt_name = */ -1, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - trivfs_protid_t server; - mach_msg_type_name_t sockPoly; - -#if TypeCheck - if ((In0P->Head.msgh_size != 40) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->sock_typeType, &sock_typeCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->protocolType, &protocolCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - server = trivfs_begin_using_protid(In0P->Head.msgh_request_port); - - OutP->RetCode = S_socket_create(server, In0P->sock_type, In0P->protocol, &OutP->sock, &sockPoly); - trivfs_end_using_protid(server); - if (OutP->RetCode != KERN_SUCCESS) - return; - - msgh_simple = TRUE; - OutP->Head.msgh_size = 40; - - OutP->sockType = sockType; - - if (MACH_MSG_TYPE_PORT_ANY(sockPoly)) - msgh_simple = FALSE; - - OutP->sockType.msgt_name = sockPoly; - - if (!msgh_simple) - OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; -} - -/* Routine socket_listen */ -mig_internal void _Xsocket_listen - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t queue_limitType; - int queue_limit; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_socket_listen - (sock_user_t sock, int queue_limit); - - auto const mach_msg_type_t queue_limitCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t sock; - -#if TypeCheck - if ((In0P->Head.msgh_size != 32) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->queue_limitType, &queue_limitCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - sock = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_socket_listen(sock, In0P->queue_limit); - end_using_socket_port(sock); -} - -/* Routine socket_accept */ -mig_internal void _Xsocket_accept - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t conn_sockType; - mach_port_t conn_sock; - mach_msg_type_t peer_addrType; - mach_port_t peer_addr; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_socket_accept - (sock_user_t sock, mach_port_t *conn_sock, mach_msg_type_name_t *conn_sockPoly, mach_port_t *peer_addr, mach_msg_type_name_t *peer_addrPoly); - - boolean_t msgh_simple; - auto const mach_msg_type_t conn_sockType = { - /* msgt_name = */ -1, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t peer_addrType = { - /* msgt_name = */ -1, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t sock; - mach_msg_type_name_t conn_sockPoly; - mach_msg_type_name_t peer_addrPoly; - -#if TypeCheck - if ((In0P->Head.msgh_size != 24) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - sock = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_socket_accept(sock, &OutP->conn_sock, &conn_sockPoly, &OutP->peer_addr, &peer_addrPoly); - end_using_socket_port(sock); - if (OutP->RetCode != KERN_SUCCESS) - return; - - msgh_simple = TRUE; - OutP->Head.msgh_size = 48; - - OutP->conn_sockType = conn_sockType; - - if (MACH_MSG_TYPE_PORT_ANY(conn_sockPoly)) - msgh_simple = FALSE; - - OutP->conn_sockType.msgt_name = conn_sockPoly; - - OutP->peer_addrType = peer_addrType; - - if (MACH_MSG_TYPE_PORT_ANY(peer_addrPoly)) - msgh_simple = FALSE; - - OutP->peer_addrType.msgt_name = peer_addrPoly; - - if (!msgh_simple) - OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; -} - -/* Routine socket_connect */ -mig_internal void _Xsocket_connect - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t addrType; - addr_port_t addr; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_socket_connect - (sock_user_t sock, sock_addr_t addr); - - auto const mach_msg_type_t addrCheck = { - /* msgt_name = */ 17, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t sock; - sock_addr_t addr; - -#if TypeCheck - if ((In0P->Head.msgh_size != 32) || - !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->addrType, &addrCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - sock = begin_using_socket_port(In0P->Head.msgh_request_port); - - addr = begin_using_sockaddr_port(In0P->addr); - - OutP->RetCode = S_socket_connect(sock, addr); - end_using_sockaddr_port(addr); - end_using_socket_port(sock); -} - -/* Routine socket_bind */ -mig_internal void _Xsocket_bind - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t addrType; - addr_port_t addr; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_socket_bind - (sock_user_t sock, sock_addr_t addr); - - auto const mach_msg_type_t addrCheck = { - /* msgt_name = */ 17, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t sock; - sock_addr_t addr; - -#if TypeCheck - if ((In0P->Head.msgh_size != 32) || - !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->addrType, &addrCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - sock = begin_using_socket_port(In0P->Head.msgh_request_port); - - addr = begin_using_sockaddr_port(In0P->addr); - - OutP->RetCode = S_socket_bind(sock, addr); - end_using_sockaddr_port(addr); - end_using_socket_port(sock); -} - -/* Routine socket_name */ -mig_internal void _Xsocket_name - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t addrType; - mach_port_t addr; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_socket_name - (sock_user_t sock, mach_port_t *addr, mach_msg_type_name_t *addrPoly); - - boolean_t msgh_simple; - auto const mach_msg_type_t addrType = { - /* msgt_name = */ -1, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t sock; - mach_msg_type_name_t addrPoly; - -#if TypeCheck - if ((In0P->Head.msgh_size != 24) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - sock = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_socket_name(sock, &OutP->addr, &addrPoly); - end_using_socket_port(sock); - if (OutP->RetCode != KERN_SUCCESS) - return; - - msgh_simple = TRUE; - OutP->Head.msgh_size = 40; - - OutP->addrType = addrType; - - if (MACH_MSG_TYPE_PORT_ANY(addrPoly)) - msgh_simple = FALSE; - - OutP->addrType.msgt_name = addrPoly; - - if (!msgh_simple) - OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; -} - -/* Routine socket_peername */ -mig_internal void _Xsocket_peername - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t addrType; - mach_port_t addr; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_socket_peername - (sock_user_t sock, mach_port_t *addr, mach_msg_type_name_t *addrPoly); - - boolean_t msgh_simple; - auto const mach_msg_type_t addrType = { - /* msgt_name = */ -1, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t sock; - mach_msg_type_name_t addrPoly; - -#if TypeCheck - if ((In0P->Head.msgh_size != 24) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - sock = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_socket_peername(sock, &OutP->addr, &addrPoly); - end_using_socket_port(sock); - if (OutP->RetCode != KERN_SUCCESS) - return; - - msgh_simple = TRUE; - OutP->Head.msgh_size = 40; - - OutP->addrType = addrType; - - if (MACH_MSG_TYPE_PORT_ANY(addrPoly)) - msgh_simple = FALSE; - - OutP->addrType.msgt_name = addrPoly; - - if (!msgh_simple) - OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; -} - -/* Routine socket_connect2 */ -mig_internal void _Xsocket_connect2 - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t sock2Type; - socket_t sock2; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_socket_connect2 - (sock_user_t sock1, sock_user_t sock2); - - auto const mach_msg_type_t sock2Check = { - /* msgt_name = */ 17, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t sock1; - sock_user_t sock2; - -#if TypeCheck - if ((In0P->Head.msgh_size != 32) || - !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->sock2Type, &sock2Check)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - sock1 = begin_using_socket_port(In0P->Head.msgh_request_port); - - sock2 = begin_using_socket_port(In0P->sock2); - - OutP->RetCode = S_socket_connect2(sock1, sock2); - end_using_socket_port(sock2); - end_using_socket_port(sock1); -} - -/* Routine socket_create_address */ -mig_internal void _Xsocket_create_address - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t sockaddr_typeType; - int sockaddr_type; - mach_msg_type_long_t sockaddrType; - char sockaddr[2048]; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t addrType; - mach_port_t addr; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_socket_create_address - (mach_port_t server, int sockaddr_type, data_t sockaddr, mach_msg_type_number_t sockaddrCnt, mach_port_t *addr, mach_msg_type_name_t *addrPoly); - - boolean_t msgh_simple; - unsigned int msgh_size; - - auto const mach_msg_type_t sockaddr_typeCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t addrType = { - /* msgt_name = */ -1, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - mach_msg_type_name_t addrPoly; - -#if TypeCheck - msgh_size = In0P->Head.msgh_size; - msgh_simple = !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); - if ((msgh_size < 44)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->sockaddr_typeType, &sockaddr_typeCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if ((In0P->sockaddrType.msgtl_header.msgt_longform != TRUE) || - (In0P->sockaddrType.msgtl_name != 8) || - (In0P->sockaddrType.msgtl_size != 8)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (msgh_size != 44 + ((In0P->sockaddrType.msgtl_header.msgt_inline) ? (In0P->sockaddrType.msgtl_number + 3) & ~3 : sizeof(char *))) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_socket_create_address(In0P->Head.msgh_request_port, In0P->sockaddr_type, (In0P->sockaddrType.msgtl_header.msgt_inline) ? In0P->sockaddr : *((char **)In0P->sockaddr), In0P->sockaddrType.msgtl_number, &OutP->addr, &addrPoly); - if (OutP->RetCode == KERN_SUCCESS) - if (!In0P->sockaddrType.msgtl_header.msgt_inline) - __mig_deallocate(* (vm_offset_t *) In0P->sockaddr, In0P->sockaddrType.msgtl_number); - if (OutP->RetCode != KERN_SUCCESS) - return; - - msgh_simple = TRUE; - OutP->Head.msgh_size = 40; - - OutP->addrType = addrType; - - if (MACH_MSG_TYPE_PORT_ANY(addrPoly)) - msgh_simple = FALSE; - - OutP->addrType.msgt_name = addrPoly; - - if (!msgh_simple) - OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; -} - -/* Routine socket_fabricate_address */ -mig_internal void _Xsocket_fabricate_address - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t sockaddr_typeType; - int sockaddr_type; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t addrType; - mach_port_t addr; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_socket_fabricate_address - (mach_port_t server, int sockaddr_type, mach_port_t *addr, mach_msg_type_name_t *addrPoly); - - boolean_t msgh_simple; - auto const mach_msg_type_t sockaddr_typeCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t addrType = { - /* msgt_name = */ -1, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - mach_msg_type_name_t addrPoly; - -#if TypeCheck - if ((In0P->Head.msgh_size != 32) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->sockaddr_typeType, &sockaddr_typeCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_socket_fabricate_address(In0P->Head.msgh_request_port, In0P->sockaddr_type, &OutP->addr, &addrPoly); - if (OutP->RetCode != KERN_SUCCESS) - return; - - msgh_simple = TRUE; - OutP->Head.msgh_size = 40; - - OutP->addrType = addrType; - - if (MACH_MSG_TYPE_PORT_ANY(addrPoly)) - msgh_simple = FALSE; - - OutP->addrType.msgt_name = addrPoly; - - if (!msgh_simple) - OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; -} - -/* Routine socket_whatis_address */ -mig_internal void _Xsocket_whatis_address - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t sockaddr_typeType; - int sockaddr_type; - mach_msg_type_long_t sockaddrType; - char sockaddr[2048]; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_socket_whatis_address - (sock_addr_t addr, int *sockaddr_type, data_t *sockaddr, mach_msg_type_number_t *sockaddrCnt); - - boolean_t msgh_simple; - auto const mach_msg_type_t sockaddr_typeType = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_long_t sockaddrType = { - { - /* msgt_name = */ 0, - /* msgt_size = */ 0, - /* msgt_number = */ 0, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ TRUE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }, - /* msgtl_name = */ 8, - /* msgtl_size = */ 8, - /* msgtl_number = */ 2048, - }; - - sock_addr_t addr; - mach_msg_type_number_t sockaddrCnt; - - char *sockaddrP; - -#if TypeCheck - if ((In0P->Head.msgh_size != 24) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - addr = begin_using_sockaddr_port(In0P->Head.msgh_request_port); - - sockaddrP = OutP->sockaddr; - sockaddrCnt = 2048; - - OutP->RetCode = S_socket_whatis_address(addr, &OutP->sockaddr_type, &sockaddrP, &sockaddrCnt); - end_using_sockaddr_port(addr); - if (OutP->RetCode != KERN_SUCCESS) - return; - - msgh_simple = TRUE; - - OutP->sockaddr_typeType = sockaddr_typeType; - - OutP->sockaddrType = sockaddrType; - if (sockaddrP != OutP->sockaddr) { - OutP->sockaddrType.msgtl_header.msgt_inline = FALSE; - OutP->sockaddrType.msgtl_header.msgt_deallocate = TRUE; - *((char **)OutP->sockaddr) = sockaddrP; - msgh_simple = FALSE; - } - - OutP->sockaddrType.msgtl_number = sockaddrCnt; - OutP->Head.msgh_size = 52 + ((OutP->sockaddrType.msgtl_header.msgt_inline) ? (sockaddrCnt + 3) & ~3 : sizeof(char *)); - - if (!msgh_simple) - OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; -} - -/* Routine socket_shutdown */ -mig_internal void _Xsocket_shutdown - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t directionType; - int direction; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_socket_shutdown - (sock_user_t sock, int direction); - - auto const mach_msg_type_t directionCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t sock; - -#if TypeCheck - if ((In0P->Head.msgh_size != 32) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->directionType, &directionCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - sock = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_socket_shutdown(sock, In0P->direction); - end_using_socket_port(sock); -} - -/* Routine socket_getopt */ -mig_internal void _Xsocket_getopt - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t levelType; - int level; - mach_msg_type_t optionType; - int option; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_long_t optvalType; - char optval[2048]; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_socket_getopt - (sock_user_t sock, int level, int option, data_t *optval, mach_msg_type_number_t *optvalCnt); - - boolean_t msgh_simple; - auto const mach_msg_type_t levelCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t optionCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_long_t optvalType = { - { - /* msgt_name = */ 0, - /* msgt_size = */ 0, - /* msgt_number = */ 0, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ TRUE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }, - /* msgtl_name = */ 8, - /* msgtl_size = */ 8, - /* msgtl_number = */ 2048, - }; - - sock_user_t sock; - mach_msg_type_number_t optvalCnt; - - char *optvalP; - -#if TypeCheck - if ((In0P->Head.msgh_size != 40) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->levelType, &levelCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->optionType, &optionCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - sock = begin_using_socket_port(In0P->Head.msgh_request_port); - - optvalP = OutP->optval; - optvalCnt = 2048; - - OutP->RetCode = S_socket_getopt(sock, In0P->level, In0P->option, &optvalP, &optvalCnt); - end_using_socket_port(sock); - if (OutP->RetCode != KERN_SUCCESS) - return; - - msgh_simple = TRUE; - - OutP->optvalType = optvalType; - if (optvalP != OutP->optval) { - OutP->optvalType.msgtl_header.msgt_inline = FALSE; - OutP->optvalType.msgtl_header.msgt_deallocate = TRUE; - *((char **)OutP->optval) = optvalP; - msgh_simple = FALSE; - } - - OutP->optvalType.msgtl_number = optvalCnt; - OutP->Head.msgh_size = 44 + ((OutP->optvalType.msgtl_header.msgt_inline) ? (optvalCnt + 3) & ~3 : sizeof(char *)); - - if (!msgh_simple) - OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; -} - -/* Routine socket_setopt */ -mig_internal void _Xsocket_setopt - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t levelType; - int level; - mach_msg_type_t optionType; - int option; - mach_msg_type_long_t optvalType; - char optval[2048]; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_socket_setopt - (sock_user_t sock, int level, int option, data_t optval, mach_msg_type_number_t optvalCnt); - -#if TypeCheck - boolean_t msgh_simple; -#endif /* TypeCheck */ - - unsigned int msgh_size; - - auto const mach_msg_type_t levelCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t optionCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t sock; - -#if TypeCheck - msgh_size = In0P->Head.msgh_size; - msgh_simple = !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); - if ((msgh_size < 52)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->levelType, &levelCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->optionType, &optionCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if ((In0P->optvalType.msgtl_header.msgt_longform != TRUE) || - (In0P->optvalType.msgtl_name != 8) || - (In0P->optvalType.msgtl_size != 8)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (msgh_size != 52 + ((In0P->optvalType.msgtl_header.msgt_inline) ? (In0P->optvalType.msgtl_number + 3) & ~3 : sizeof(char *))) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - sock = begin_using_socket_port(In0P->Head.msgh_request_port); - - OutP->RetCode = S_socket_setopt(sock, In0P->level, In0P->option, (In0P->optvalType.msgtl_header.msgt_inline) ? In0P->optval : *((char **)In0P->optval), In0P->optvalType.msgtl_number); - if (OutP->RetCode == KERN_SUCCESS) - if (!In0P->optvalType.msgtl_header.msgt_inline) - __mig_deallocate(* (vm_offset_t *) In0P->optval, In0P->optvalType.msgtl_number); - end_using_socket_port(sock); -} - -/* Routine socket_send */ -mig_internal void _Xsocket_send - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t addrType; - addr_port_t addr; - mach_msg_type_t flagsType; - int flags; - mach_msg_type_long_t dataType; - char data[2048]; - mach_msg_type_long_t portsType; - mach_port_t ports[512]; - mach_msg_type_long_t controlType; - char control[2048]; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t amountType; - vm_size_t amount; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Request *In1P; - register Request *In2P; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_socket_send - (sock_user_t sock, sock_addr_t addr, int flags, data_t data, mach_msg_type_number_t dataCnt, portarray_t ports, mach_msg_type_number_t portsCnt, data_t control, mach_msg_type_number_t controlCnt, vm_size_t *amount); - - unsigned int msgh_size; - unsigned int msgh_size_delta; - - auto const mach_msg_type_t addrCheck = { - /* msgt_name = */ 17, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t flagsCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t amountType = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t sock; - sock_addr_t addr; - -#if TypeCheck - msgh_size = In0P->Head.msgh_size; - if ((msgh_size < 76) || - !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->addrType, &addrCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->flagsType, &flagsCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if ((In0P->dataType.msgtl_header.msgt_longform != TRUE) || - (In0P->dataType.msgtl_name != 8) || - (In0P->dataType.msgtl_size != 8)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - msgh_size_delta = (In0P->dataType.msgtl_header.msgt_inline) ? (In0P->dataType.msgtl_number + 3) & ~3 : sizeof(char *); -#if TypeCheck - if (msgh_size < 76 + msgh_size_delta) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } - msgh_size -= msgh_size_delta; -#endif /* TypeCheck */ - - In1P = (Request *) ((char *) In0P + msgh_size_delta - 2048); - -#if TypeCheck - if ((In1P->portsType.msgtl_header.msgt_longform != TRUE) || - (In1P->portsType.msgtl_name != 17) || - (In1P->portsType.msgtl_size != 32)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - msgh_size_delta = (In1P->portsType.msgtl_header.msgt_inline) ? 4 * In1P->portsType.msgtl_number : sizeof(mach_port_t *); -#if TypeCheck - if (msgh_size < 76 + msgh_size_delta) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } - msgh_size -= msgh_size_delta; -#endif /* TypeCheck */ - - In2P = (Request *) ((char *) In1P + msgh_size_delta - 2048); - -#if TypeCheck - if ((In2P->controlType.msgtl_header.msgt_longform != TRUE) || - (In2P->controlType.msgtl_name != 8) || - (In2P->controlType.msgtl_size != 8)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (msgh_size != 76 + ((In2P->controlType.msgtl_header.msgt_inline) ? (In2P->controlType.msgtl_number + 3) & ~3 : sizeof(char *))) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - sock = begin_using_socket_port(In0P->Head.msgh_request_port); - - addr = begin_using_sockaddr_port(In0P->addr); - - OutP->RetCode = S_socket_send(sock, addr, In0P->flags, (In0P->dataType.msgtl_header.msgt_inline) ? In0P->data : *((char **)In0P->data), In0P->dataType.msgtl_number, (In1P->portsType.msgtl_header.msgt_inline) ? In1P->ports : *((mach_port_t **)In1P->ports), In1P->portsType.msgtl_number, (In2P->controlType.msgtl_header.msgt_inline) ? In2P->control : *((char **)In2P->control), In2P->controlType.msgtl_number, &OutP->amount); - if (OutP->RetCode == KERN_SUCCESS) - if (!In2P->controlType.msgtl_header.msgt_inline) - __mig_deallocate(* (vm_offset_t *) In2P->control, In2P->controlType.msgtl_number); - if (OutP->RetCode == KERN_SUCCESS) - if (!In1P->portsType.msgtl_header.msgt_inline) - __mig_deallocate(* (vm_offset_t *) In1P->ports, 4 * In1P->portsType.msgtl_number); - if (OutP->RetCode == KERN_SUCCESS) - if (!In0P->dataType.msgtl_header.msgt_inline) - __mig_deallocate(* (vm_offset_t *) In0P->data, In0P->dataType.msgtl_number); - end_using_sockaddr_port(addr); - end_using_socket_port(sock); - if (OutP->RetCode != KERN_SUCCESS) - return; - - OutP->Head.msgh_size = 40; - - OutP->amountType = amountType; -} - -/* Routine socket_recv */ -mig_internal void _Xsocket_recv - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t flagsType; - int flags; - mach_msg_type_t amountType; - vm_size_t amount; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t addrType; - mach_port_t addr; - mach_msg_type_long_t dataType; - char data[2048]; - mach_msg_type_long_t portsType; - mach_port_t ports[512]; - mach_msg_type_long_t controlType; - char control[2048]; - mach_msg_type_t outflagsType; - int outflags; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_socket_recv - (sock_user_t sock, mach_port_t *addr, mach_msg_type_name_t *addrPoly, int flags, data_t *data, mach_msg_type_number_t *dataCnt, portarray_t *ports, mach_msg_type_name_t *portsPoly, mach_msg_type_number_t *portsCnt, data_t *control, mach_msg_type_number_t *controlCnt, int *outflags, vm_size_t amount); - - boolean_t msgh_simple; - unsigned int msgh_size; - unsigned int msgh_size_delta; - - auto const mach_msg_type_t flagsCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t amountCheck = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_t addrType = { - /* msgt_name = */ -1, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - auto const mach_msg_type_long_t dataType = { - { - /* msgt_name = */ 0, - /* msgt_size = */ 0, - /* msgt_number = */ 0, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ TRUE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }, - /* msgtl_name = */ 8, - /* msgtl_size = */ 8, - /* msgtl_number = */ 2048, - }; - - auto const mach_msg_type_long_t portsType = { - { - /* msgt_name = */ 0, - /* msgt_size = */ 0, - /* msgt_number = */ 0, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ TRUE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }, - /* msgtl_name = */ -1, - /* msgtl_size = */ 32, - /* msgtl_number = */ 512, - }; - - auto const mach_msg_type_long_t controlType = { - { - /* msgt_name = */ 0, - /* msgt_size = */ 0, - /* msgt_number = */ 0, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ TRUE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }, - /* msgtl_name = */ 8, - /* msgtl_size = */ 8, - /* msgtl_number = */ 2048, - }; - - auto const mach_msg_type_t outflagsType = { - /* msgt_name = */ 2, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - sock_user_t sock; - mach_msg_type_name_t addrPoly; - mach_msg_type_number_t dataCnt; - mach_port_t ports[512]; - mach_msg_type_name_t portsPoly; - mach_msg_type_number_t portsCnt; - char control[2048]; - mach_msg_type_number_t controlCnt; - int outflags; - - char *dataP; - mach_port_t *portsP; - char *controlP; - -#if TypeCheck - if ((In0P->Head.msgh_size != 40) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->flagsType, &flagsCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - -#if TypeCheck - if (BAD_TYPECHECK(&In0P->amountType, &amountCheck)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - sock = begin_using_socket_port(In0P->Head.msgh_request_port); - - dataP = OutP->data; - dataCnt = 2048; - - portsP = ports; - portsCnt = 512; - - controlP = control; - controlCnt = 2048; - - OutP->RetCode = S_socket_recv(sock, &OutP->addr, &addrPoly, In0P->flags, &dataP, &dataCnt, &portsP, &portsPoly, &portsCnt, &controlP, &controlCnt, &outflags, In0P->amount); - end_using_socket_port(sock); - if (OutP->RetCode != KERN_SUCCESS) - return; - - msgh_simple = TRUE; - - OutP->addrType = addrType; - - if (MACH_MSG_TYPE_PORT_ANY(addrPoly)) - msgh_simple = FALSE; - - OutP->addrType.msgt_name = addrPoly; - - OutP->dataType = dataType; - if (dataP != OutP->data) { - OutP->dataType.msgtl_header.msgt_inline = FALSE; - OutP->dataType.msgtl_header.msgt_deallocate = TRUE; - *((char **)OutP->data) = dataP; - msgh_simple = FALSE; - } - - OutP->dataType.msgtl_number = dataCnt; - msgh_size_delta = (OutP->dataType.msgtl_header.msgt_inline) ? (dataCnt + 3) & ~3 : sizeof(char *); - msgh_size = 84 + msgh_size_delta; - OutP = (Reply *) ((char *) OutP + msgh_size_delta - 2048); - - OutP->portsType = portsType; - - if (portsP != ports) { - OutP->portsType.msgtl_header.msgt_inline = FALSE; - OutP->portsType.msgtl_header.msgt_deallocate = TRUE; - *((mach_port_t **)OutP->ports) = portsP; - msgh_simple = FALSE; - } - else { - memcpy(OutP->ports, ports, 4 * portsCnt); - } - - if (MACH_MSG_TYPE_PORT_ANY(portsPoly)) - msgh_simple = FALSE; - - OutP->portsType.msgtl_name = portsPoly; - - OutP->portsType.msgtl_number = portsCnt; - msgh_size_delta = (OutP->portsType.msgtl_header.msgt_inline) ? 4 * portsCnt : sizeof(mach_port_t *); - msgh_size += msgh_size_delta; - OutP = (Reply *) ((char *) OutP + msgh_size_delta - 2048); - - OutP->controlType = controlType; - - if (controlP != control) { - OutP->controlType.msgtl_header.msgt_inline = FALSE; - OutP->controlType.msgtl_header.msgt_deallocate = TRUE; - *((char **)OutP->control) = controlP; - msgh_simple = FALSE; - } - else { - memcpy(OutP->control, control, controlCnt); - } - - OutP->controlType.msgtl_number = controlCnt; - msgh_size_delta = (OutP->controlType.msgtl_header.msgt_inline) ? (controlCnt + 3) & ~3 : sizeof(char *); - msgh_size += msgh_size_delta; - OutP = (Reply *) ((char *) OutP + msgh_size_delta - 2048); - - OutP->outflagsType = outflagsType; - - OutP->outflags = outflags; - - OutP = (Reply *) OutHeadP; - if (!msgh_simple) - OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX; - OutP->Head.msgh_size = msgh_size; -} - -static mig_routine_t socket_server_routines[] = { - _Xsocket_create, - _Xsocket_listen, - _Xsocket_accept, - _Xsocket_connect, - _Xsocket_bind, - _Xsocket_name, - _Xsocket_peername, - _Xsocket_connect2, - _Xsocket_create_address, - _Xsocket_fabricate_address, - _Xsocket_whatis_address, - _Xsocket_shutdown, - _Xsocket_getopt, - _Xsocket_setopt, - _Xsocket_send, - _Xsocket_recv, -}; - -mig_external boolean_t socket_server - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - register mach_msg_header_t *InP = InHeadP; - register mig_reply_header_t *OutP = (mig_reply_header_t *) OutHeadP; - - auto const mach_msg_type_t RetCodeType = { - /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - register mig_routine_t routine; - - OutP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InP->msgh_bits), 0); - OutP->Head.msgh_size = sizeof *OutP; - OutP->Head.msgh_remote_port = InP->msgh_reply_port; - OutP->Head.msgh_local_port = MACH_PORT_NULL; - OutP->Head.msgh_seqno = 0; - OutP->Head.msgh_id = InP->msgh_id + 100; - - OutP->RetCodeType = RetCodeType; - - if ((InP->msgh_id > 26015) || (InP->msgh_id < 26000) || - ((routine = socket_server_routines[InP->msgh_id - 26000]) == 0)) { - OutP->RetCode = MIG_BAD_ID; - return FALSE; - } - (*routine) (InP, &OutP->Head); - return TRUE; -} - -mig_external mig_routine_t socket_server_routine - (const mach_msg_header_t *InHeadP) -{ - register int msgh_id; - - msgh_id = InHeadP->msgh_id - 26000; - - if ((msgh_id > 15) || (msgh_id < 0)) - return 0; - - return socket_server_routines[msgh_id]; -} - diff --git a/pfinet.old/startup_notifyServer.c b/pfinet.old/startup_notifyServer.c deleted file mode 100644 index 45710e4e..00000000 --- a/pfinet.old/startup_notifyServer.c +++ /dev/null @@ -1,129 +0,0 @@ -/* Module startup_notify */ - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE 1 -#endif - -#define EXPORT_BOOLEAN -#include <mach/boolean.h> -#include <mach/kern_return.h> -#include <mach/message.h> -#include <mach/mig_errors.h> -#include <mach/mig_support.h> - -#ifndef mig_internal -#define mig_internal static -#endif - -#ifndef mig_external -#define mig_external -#endif - -#ifndef TypeCheck -#define TypeCheck 1 -#endif - -#ifndef UseExternRCSId -#define UseExternRCSId 1 -#endif - -#define BAD_TYPECHECK(type, check) ({\ - union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\ - _t.t = *(type); _c.t = *(check); _t.w != _c.w; }) -#define msgh_request_port msgh_local_port -#define MACH_MSGH_BITS_REQUEST(bits) MACH_MSGH_BITS_LOCAL(bits) -#define msgh_reply_port msgh_remote_port -#define MACH_MSGH_BITS_REPLY(bits) MACH_MSGH_BITS_REMOTE(bits) - -#include <mach/std_types.h> -#include <mach/mach_types.h> -#include <device/device_types.h> -#include <device/net_status.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/statfs.h> -#include <sys/resource.h> -#include <sys/utsname.h> -#include <hurd/hurd_types.h> - -/* Routine startup_dosync */ -mig_internal void _Xstartup_dosync - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - typedef struct { - mach_msg_header_t Head; - } Request; - - typedef struct { - mach_msg_header_t Head; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - } Reply; - - register Request *In0P = (Request *) InHeadP; - register Reply *OutP = (Reply *) OutHeadP; - mig_external kern_return_t S_startup_dosync - (mach_port_t notify_port); - -#if TypeCheck - if ((In0P->Head.msgh_size != 24) || - (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } -#endif /* TypeCheck */ - - OutP->RetCode = S_startup_dosync(In0P->Head.msgh_request_port); -} - -static mig_routine_t startup_notify_server_routines[] = { - _Xstartup_dosync, -}; - -mig_external boolean_t startup_notify_server - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - register mach_msg_header_t *InP = InHeadP; - register mig_reply_header_t *OutP = (mig_reply_header_t *) OutHeadP; - - auto const mach_msg_type_t RetCodeType = { - /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, - /* msgt_size = */ 32, - /* msgt_number = */ 1, - /* msgt_inline = */ TRUE, - /* msgt_longform = */ FALSE, - /* msgt_deallocate = */ FALSE, - /* msgt_unused = */ 0 - }; - - register mig_routine_t routine; - - OutP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InP->msgh_bits), 0); - OutP->Head.msgh_size = sizeof *OutP; - OutP->Head.msgh_remote_port = InP->msgh_reply_port; - OutP->Head.msgh_local_port = MACH_PORT_NULL; - OutP->Head.msgh_seqno = 0; - OutP->Head.msgh_id = InP->msgh_id + 100; - - OutP->RetCodeType = RetCodeType; - - if ((InP->msgh_id > 29500) || (InP->msgh_id < 29500) || - ((routine = startup_notify_server_routines[InP->msgh_id - 29500]) == 0)) { - OutP->RetCode = MIG_BAD_ID; - return FALSE; - } - (*routine) (InP, &OutP->Head); - return TRUE; -} - -mig_external mig_routine_t startup_notify_server_routine - (const mach_msg_header_t *InHeadP) -{ - register int msgh_id; - - msgh_id = InHeadP->msgh_id - 29500; - - if ((msgh_id > 0) || (msgh_id < 0)) - return 0; - - return startup_notify_server_routines[msgh_id]; -} - |