/*
 *  NavigatorNetwork.h
 *  TI Connect X CommMgr
 *
 *  Created by Stephen L. Reid on Thu Oct 24 2002.
 *  Copyright (c) 2002 Texas Instruments Incorporated. All rights reserved.
 *
 */


#ifndef __NAVIGATORCONTEXT__
#define __NAVIGATORCONTEXT__

#include <CoreFoundation/CoreFoundation.h>
#include <CoreServices/CoreServices.h>
#include <Carbon/Carbon.h>
#include <IOKit/IOKitLib.h>
#include <IOKit/IOMessage.h>
#include <IOKit/IOCFPlugIn.h>
#include <IOKit/usb/IOUSBLib.h>

#include <SystemConfiguration/SystemConfiguration.h>

typedef struct __NavigatorContext* NavigatorContextRef;
typedef void (*MyTI_AsyncCallBack)( void *inPB, IOReturn inErr, void *arg0 );

#if __LP64__
void BlockMoveData( void *s, void *d, long len );
void BlockZero( void *d, long len );
#endif

// NavigatorNetwork context accessor functions
void 	NavigatorNetworkSetRefcon( NavigatorContextRef context, void *refcon );
void * 	NavigatorNetworkGetRefcon( NavigatorContextRef context );
void 	NavigatorNetworkRemoveReadStreamFromSpecifiedRunLoop( NavigatorContextRef context, CFRunLoopRef runLoop );
void 	NavigatorNetworkRemoveWriteStreamFromSpecifiedRunLoop( NavigatorContextRef context, CFRunLoopRef runLoop );
void 	NavigatorNetworkAddReadStreamToSpecifiedRunLoop( NavigatorContextRef context, CFRunLoopRef runLoop );
void 	NavigatorNetworkAddWriteStreamToSpecifiedRunLoop( NavigatorContextRef context, CFRunLoopRef runLoop );
void 	NavigatorNetworkRunLoopAddTimer( NavigatorContextRef context, CFRunLoopRef runLoop );
void 	NavigatorNetworkRunLoopRemoveTimer( NavigatorContextRef context, CFRunLoopRef runLoop );
void 	NavigatorNetworkAddNotificationCallback( NavigatorContextRef context, MyTI_AsyncCallBack inCallback );

CFStringRef	NavigatorNetworkCreateDeviceName( NavigatorContextRef context );

NavigatorContextRef NavigatorContextCreate( CFAllocatorRef alloc, CFSocketNativeHandle nativeSocket, CFDataRef address );

NavigatorContextRef NavigatorContextRetain(	NavigatorContextRef context );
NavigatorContextRef NavigatorContextRelease(	NavigatorContextRef context );

Boolean NavigatorContextOpen( NavigatorContextRef context, MyTI_AsyncCallBack initialCallback );

void NavigatorContextClose( NavigatorContextRef context );

IOReturn WriteNavigatorStreamAsyncTO( NavigatorContextRef 	context,
                                      UInt8			*theBuffer,
                                      UInt32			sendActualCount,
                                      UInt32			sendDataTimeout,
                                      UInt32			sendTransactionTimeout,
                                      MyTI_AsyncCallBack	sendCallBack,
                                      void			*refcon );
                                      
IOReturn ReadNavigatorStreamAsyncTO(  NavigatorContextRef 	context,
                                      UInt8			*theBuffer,
                                      UInt32			receiveRequestCount,
                                      UInt32			receiveDataTimeout,
                                      UInt32			receiveTransactionTimeout,
                                      MyTI_AsyncCallBack	receiveCallBack,
                                      void			*refcon );
                                      
IOReturn AbortNavigatorStreamAsyncTO( NavigatorContextRef 	context,
                                      void			*refcon );

Boolean NavigatorNetworkCheckStaleAndRelease( NavigatorContextRef context, CFDataRef address );


#endif	/* __NAVIGATORCONTEXT__ */