//
// @APPLE_LICENSE_HEADER_START@
//
// Copyright (c) 2005, 2006 Apple Computer, Inc.  All Rights Reserved.
//
// This file contains Original Code and/or Modifications of Original Code
// as defined in and that are subject to the Apple Public Source License
// Version 2.0 (the 'License'). You may not use this file except in
// compliance with the License. Please obtain a copy of the License at
// http://www.opensource.apple.com/apsl/ and read it before using this
// file.
//
// The Original Code and all software distributed under the License are
// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
// Please see the License for the specific language governing rights and
// limitations under the License.
//
// @APPLE_LICENSE_HEADER_END@

// $Id: darwin_userclient.h,v 1.3 2006/01/15 21:19:30 msmith Exp $

#ifndef __DARWINUSERCLIENT_H__
#define __DARWINUSERCLIENT_H__

// XXX trim these includes
#include <iostream>
#include <pthread.h>
#include <sys/signal.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <fcntl.h>          /* File control definitions */
#include <errno.h>          /* Error number definitions */
#include <unistd.h>         /* fork() */
#include <netinet/in.h>
#include <netdb.h>
#include <stdarg.h>
#include <sys/ioctl.h>
#include <unistd.h>

#include "commdef.h"
#include "interface.h"

#include <IOKit/IOKitLib.h>

class DarwinUserClientInterface : public ArcInterface
{
public:
	DarwinUserClientInterface();
	~DarwinUserClientInterface();

	bool init(const int nPort);
	int  send(sIF_CMD_BLOCK *ifData);
	int  recv(sIF_CMD_BLOCK *ifData);    
	int  syncSend(sIF_CMD_BLOCK *ifData);    
	void requirelock();
	void releaselock();
	bool ClearReadBuffer();
	bool ClearWriteBuffer();
	bool ClearReadWriteBuffer();
	int  getMTU();
	void *getDeviceHandle();

private:
	io_connect_t    connectionPort;
	bool            controllerIsOpen;
	pthread_mutex_t mtx;
};

#endif // __DARWINUSERCLIENT_H__
