cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync/* $Id$ */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync/** @file
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * TestExecServ - Basic Remote Execution Service, Internal Header.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync/*
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * Copyright (C) 2010-2014 Oracle Corporation
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync *
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * available from http://www.virtualbox.org. This file is free software;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * you can redistribute it and/or modify it under the terms of the GNU
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * General Public License (GPL) as published by the Free Software
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync *
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * The contents of this file may alternatively be used under the terms
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * of the Common Development and Distribution License Version 1.0
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * VirtualBox OSE distribution, in which case the provisions of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * CDDL are applicable instead of those of the GPL.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync *
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * You may elect to license modified versions of this file under the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * terms and conditions of either the GPL or the CDDL or both.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync#ifndef ___TestExecServiceInternal_h___
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync#define ___TestExecServiceInternal_h___
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync#include <iprt/getopt.h>
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync#include <iprt/stream.h>
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncRT_C_DECLS_BEGIN
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync/**
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * Packet header.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsynctypedef struct TXSPKTHDR
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync{
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /** The unpadded packet length. This include this header. */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync uint32_t cb;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /** The CRC-32 for the packet starting from the opcode field. 0 if the packet
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * hasn't been CRCed. */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync uint32_t uCrc32;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /** Packet opcode, an unterminated ASCII string. */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync uint8_t achOpcode[8];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync} TXSPKTHDR;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncAssertCompileSize(TXSPKTHDR, 16);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync/** Pointer to a packet header. */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsynctypedef TXSPKTHDR *PTXSPKTHDR;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync/** Pointer to a packet header. */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsynctypedef TXSPKTHDR const *PCTXSPKTHDR;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync/** Pointer to a packet header pointer. */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsynctypedef PTXSPKTHDR *PPTXSPKTHDR;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync/** Packet alignment. */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync#define TXSPKT_ALIGNMENT 16
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync/** Max packet size. */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync#define TXSPKT_MAX_SIZE _256K
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync/**
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * Transport layer descriptor.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsynctypedef struct TXSTRANSPORT
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync{
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /** The name. */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync char szName[16];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /** The description. */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync const char *pszDesc;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /** Pointer to an array of options. */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync PCRTGETOPTDEF paOpts;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /** The number of options in the array. */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync size_t cOpts;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /**
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * Print the usage information for this transport layer.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync *
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * @param pThis Pointer to the transport layer descriptor.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * @param pStream The stream to print the usage info to.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync *
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * @remarks This is only required if TXSTRANSPORT::cOpts is greater than 0.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync DECLR3CALLBACKMEMBER(void, pfnUsage,(PRTSTREAM pStream));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /**
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * Handle an option.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync *
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * When encountering an options that is not part of the base options, we'll call
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * this method for each transport layer until one handles it.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync *
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * @retval VINF_SUCCESS if handled.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * @retval VERR_TRY_AGAIN if not handled.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * @retval VERR_INVALID_PARAMETER if we should exit with a non-zero status.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync *
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * @param pThis Pointer to the transport layer descriptor.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * @param ch The short option value.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * @param pVal Pointer to the value union.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync *
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * @remarks This is only required if TXSTRANSPORT::cOpts is greater than 0.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync DECLR3CALLBACKMEMBER(int, pfnOption,(int ch, PCRTGETOPTUNION pVal));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /**
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * Initializes the transport layer.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync *
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * @returns IPRT status code. On errors, the transport layer shall call
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * RTMsgError to display the error details to the user.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync DECLR3CALLBACKMEMBER(int, pfnInit,(void));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /**
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * Terminate the transport layer, closing and freeing resources.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync *
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * On errors, the transport layer shall call RTMsgError to display the error
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * details to the user.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync DECLR3CALLBACKMEMBER(void, pfnTerm,(void));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /**
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * Polls for incoming packets.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync *
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * @returns true if there are pending packets, false if there isn't.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync DECLR3CALLBACKMEMBER(bool, pfnPollIn,(void));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /**
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * Adds any pollable handles to the poll set.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync *
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * This is optional and layers that doesn't have anything that can be polled
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * shall set this method pointer to NULL to indicate that pfnPollIn must be used
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * instead.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync *
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * @returns IPRT status code.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * @param hPollSet The poll set to add them to.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * @param idStart The handle ID to start at.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync DECLR3CALLBACKMEMBER(int, pfnPollSetAdd,(RTPOLLSET hPollSet, uint32_t idStart));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /**
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * Receives an incoming packet.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync *
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * This will block until the data becomes available or we're interrupted by a
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * signal or something.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync *
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * @returns IPRT status code. On error conditions other than VERR_INTERRUPTED,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * the current operation will be aborted when applicable. When
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * interrupted, the transport layer will store the data until the next
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * receive call.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync *
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * @param ppPktHdr Where to return the pointer to the packet we've
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * read. This is allocated from the heap using
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * RTMemAlloc (w/ TXSPKT_ALIGNMENT) and must be
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * free by calling RTMemFree.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync DECLR3CALLBACKMEMBER(int, pfnRecvPkt,(PPTXSPKTHDR ppPktHdr));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /**
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * Sends an outgoing packet.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync *
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * This will block until the data has been written.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync *
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * @returns IPRT status code.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * @retval VERR_INTERRUPTED if interrupted before anything was sent.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync *
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * @param pPktHdr The packet to send. The size is given by
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * aligning the size in the header by
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * TXSPKT_ALIGNMENT.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync DECLR3CALLBACKMEMBER(int, pfnSendPkt,(PCTXSPKTHDR pPktHdr));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /**
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * Sends a babble packet and disconnects the client (if applicable).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync *
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * @param pPktHdr The packet to send. The size is given by
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * aligning the size in the header by
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * TXSPKT_ALIGNMENT.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * @param cMsSendTimeout The send timeout measured in milliseconds.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync DECLR3CALLBACKMEMBER(void, pfnBabble,(PCTXSPKTHDR pPktHdr, RTMSINTERVAL cMsSendTimeout));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /**
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * Notification about a client HOWDY.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync DECLR3CALLBACKMEMBER(void, pfnNotifyHowdy,(void));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /**
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * Notification about a client BYE.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync *
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * For connection oriented transport layers, it would be good to disconnect the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * client at this point.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync DECLR3CALLBACKMEMBER(void, pfnNotifyBye,(void));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /**
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * Notification about a REBOOT or SHUTDOWN.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync *
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * For connection oriented transport layers, stop listening for and
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * accepting at this point.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync DECLR3CALLBACKMEMBER(void, pfnNotifyReboot,(void));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /** Non-zero end marker. */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync uint32_t u32EndMarker;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync} TXSTRANSPORT;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync/** Pointer to a const transport layer descriptor. */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsynctypedef const struct TXSTRANSPORT *PCTXSTRANSPORT;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncextern TXSTRANSPORT const g_TcpTransport;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncextern TXSTRANSPORT const g_SerialTransport;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncextern TXSTRANSPORT const g_FileSysTransport;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncextern TXSTRANSPORT const g_GuestPropTransport;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncextern TXSTRANSPORT const g_TestDevTransport;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncRT_C_DECLS_END
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync#endif
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync