summaryrefslogtreecommitdiff
path: root/pfinet.old/pfinetServer.c
diff options
context:
space:
mode:
Diffstat (limited to 'pfinet.old/pfinetServer.c')
-rw-r--r--pfinet.old/pfinetServer.c189
1 files changed, 0 insertions, 189 deletions
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];
-}
-