/*
 
PrivNetDef.h : private types declaration
 
 
*/
 
#ifndef PRIVNETDEF_H
#define PRIVNETDEF_H
 
#include <NET\NetDef.h>
 
M_BeginDeclareEnumerate(tdeNetMessageType)
 E_Net_mt_InvalidMessage,/*0*/
 E_Net_mt_EngineMessage,
 E_Net_mt_FirstSysMessage,
 E_Net_mt_SysRequestActiveSessions,
 E_Net_mt_SysUnknownSender,
 E_Net_mt_SysUnknownRecipient,/*5*/
 E_Net_mt_SysFullBuffer,
 E_Net_mt_SysRequestActiveSessionsReply,
 E_Net_mt_SysConnectRequest,
 E_Net_mt_SysConnectCancel,
 E_Net_mt_SysConnectAcknowledgement,/*10*/
 E_Net_mt_SysConnectListened,
 E_Net_mt_SysConnectAgreement,
 E_Net_mt_SysConnectDeny,
 E_Net_mt_SysWaitFollow,
 E_Net_mt_SysWaitBusy,/*15*/
 E_Net_mt_SysDisconnection,
 E_Net_mt_SysPlayerDescriptorChanged,
 E_Net_mt_SysSessionDescriptorChanged,
 E_Net_mt_SysTimeDeltaRequest,
 E_Net_mt_SysTimeDeltaReply, /*20*/
 E_Net_mt_SysDisconnectRemotePlayer,
 
 E_Net_mt_Unused1,
 E_Net_mt_Unused2,
 E_Net_mt_Unused3,
 
 E_Net_mt_ReadReceipt,/*25*/
 E_Net_mt_MaxNbrOfPlayers,
 E_Net_mt_TCPAddress,
 E_Net_mt_TCPIsMe,
 E_Net_mt_TCPSupRoute,
 E_Net_mt_SysSynchro, /*30*/
 E_Net_mt_LastSysMsg /*31*/
M_EndDeclareEnumerate(tdeNetMessageType, unsigned char)
 
M_BeginDeclareEnumerate(tdeNetProtocol)
 E_Net_pr_Windows95SerialProtocol,
 E_Net_pr_Windows95ModemProtocol,
 E_Net_pr_Windows95UDPProtocol,
 E_Net_pr_Windows95IPXProtocol,
 E_Net_pr_Windows95TCPProtocol,
 E_Net_pr_Windows95SharedMemProtocol,
 E_Net_pr_Windows95TENProtocol,
 E_Net_pr_Windows95GSUBIProtocol,
 E_Net_pr_Windows95DPlayProtocol,
 E_Net_pr_NumberOfProtocols,
 E_Net_pr_InvalidProtocol = 0xff,
M_EndDeclareEnumerate(tdeNetProtocol, unsigned char)
 
 
 
/* transport channel identification */
typedef unsigned short tduwNetChannel;
 
#pragma pack(push)
#pragma pack(1)
 
#if defined(_MSC_VER)
  #pragma warning(disable : 4214)
#endif
 
/*
 * this is a message header structure. once it is received, we know the
 * number of subsequent bytes in the body. these will be stored just after
 * the header. Hence there is no need
 */
typedef struct tdstNetMessage_
{
  unsigned long ulReserved; /* Lowword contains the msg number - high word contains checksum*/
  unsigned short uwMessageSizeInBytes;
  NetLib_tduxSessionId uxSessionId;
  NetLib_tduxPlayerId uxSenderId;
  NetLib_tduxPlayerId uxRecipientId;
  NetLib_uxReadReceiptId m_uxReadReceiptId;
  unsigned short uxPriority:4;
  unsigned short uxReplaceType:4;
  unsigned short uxReplace:1;
  unsigned short eMessageType:5;
  unsigned short uxHeadBigEndian:1;
  unsigned short uxBodyBigEndian:1;
} tdstNetMessage;
 
#pragma pack(pop)
 
typedef struct tdstNetDataCell_
{
 struct tdstNetDataCell_ *p_stNextDataCell;
 tdpPointer pData;
} tdstNetDataCell;
 
typedef struct tdstNetIOSystemCell_
{
 tdstNetMessage *p_stMessage;
 tdeNetProtocol eProtocol;
 tduwNetChannel uwChannel;
} tdstNetIOSystemCell;
 
typedef struct tdstAddPlayerL1Desc_
{
 tdeNetProtocol m_eProtocol;
 void *m_vL0Param;
} tdstAddPlayerL1Desc;
 
#undef EXTERN
#undef extern
#if !defined(GLOBALS)
#define EXTERN extern
#else /* !GLOBALS */
#define EXTERN
#endif /* !GLOBALS */
 
 
#if !defined (__NETDEF_PROTOS__)
#define __NETDEF_PROTOS__
 
 
/* Pointer to a memcpy function :*/
EXTERN td_pfn_vNetMemcpy g_pfn_vNetMemcpy;
 
 
/*
 * put here the prototypes of the handler functions for the object
 */
#ifdef NETLIB_TRACEALL
 #define M_vTraceEnter(p_stLogFile,szFunctionName) \
  if(p_stLogFile) \
  { \
   fprintf(p_stLogFile,"In %s \n\t",szFunctionName);\
   fflush(p_stLogFile);\
  }
 
 #define M_vTraceExit(p_stLogFile,szFunctionName)  \
  if(p_stLogFile) \
  {\
   fprintf(p_stLogFile,"Out %s \n",szFunctionName);\
   fflush(p_stLogFile);\
  }
#endif
 
#define M_uwProcessCheckSum(p_stMsg)\
 (uwNetProcessCheckSumHeader(p_stMsg))
 
#define M_uwProcessCheckSumBody(p_stMsg) \
 (uwNetProcessCheckSumBody(p_stMsg))
 
#define M_uwCheckSumSlot(p_stMsg) \
((unsigned short)(p_stMsg->ulReserved))
#define M_uwCheckSumBodySlot(p_stMsg) \
 ((unsigned short)((p_stMsg->ulReserved)>>16))
 
#define M_uwNbrMsgSlot(p_stMsg) \
 (p_stMsg->uwMessageNumber)
 
#define M_ulMakeReserved(CheckSumHeader,CheckSumBody) \
 ( \
 (unsigned long) \
  ( \
   ((unsigned short)(CheckSumHeader)) | \
   ((unsigned long)((unsigned short)(CheckSumBody))) << 16 \
  ) \
 )
 
unsigned short uwNetProcessCheckSumHeader(tdstNetMessage*);
unsigned short uwNetProcessCheckSumBody(tdstNetMessage *);
 
#endif /* !__NETDEF_PROTOS__ */
 
#endif /* PRIVNETDEF_H */
