/*
 
 
NetL1Pri.h : level 1 declarations
 
 
*/
 
#if !defined(__L1STRDEF_TYPES__)
#define __L1STRDEF_TYPES__
 
#if !defined(ONLY_TYPES)
#define L1STRDEF_UNDEF
#define ONLY_TYPES
#endif /* !ONLY_TYPES */
 
/*
 * include here any other include files you need
 */
#include <NET\macros.h>
#include "PrivNetDef.h"
#include "L0GlDef.h"
 
#if defined(L1STRDEF_UNDEF)
#undef ONLY_TYPES
#undef L1STRDEF_UNDEF
#endif /* !L1STRDEF_UNDEF */
 
#define C_DefaultNumberOfQueueableMessage 16
 
/*
 * there is one such structure per player in the game. it holds
 * all incoming and outgoing messages for this player.
 */
typedef struct tdstRouteCell_
{
  NetLib_tduxPlayerId ulPlayerId;
  tdeNetProtocol eProtocol;
  tduwNetChannel uwChannel;
}tdstRouteCell;
 
/*
 * centralize the information about the session
 */
typedef struct tdstSessionCell_
{
  struct tdstSessionCell_ *p_stNextSessionCell;
  NetLib_tduxSessionId ulSessionId;
  unsigned short uwNumberOfPlayers;
  unsigned short uwMaxNumberOfPlayers;
  tdstRouteCell *d_stRouteCell;
}tdstSessionCell;
 
typedef struct tdstNetBroadCastList_
{
  NetLib_tduxPlayerId m_ulPlayerId;
  tduwNetChannel m_uwChannel;
  tdeNetProtocol m_eProtocol;
}tdstNetBroadCastList;
 
#endif /* !__L1STRDEF_TYPES__ */
 
#if !defined(ONLY_TYPES)
 
#if !defined(__L1STRDEF_VARS__)
#define __L1STRDEF_VARS__
 
#undef EXTERN
#undef extern
#if !defined(GLOBALS)
#define EXTERN extern
#else /* !GLOBALS */
#define EXTERN
#endif /* !GLOBALS */
 
/*
 * variables of the above types are here. declarations with initialization
 * are of the form:
 *
 * <type> <variable name>
 * #if defined(GLOBALS)
 * = <initial values>
 * #endif
 * ;
 */
#endif /* !__L1STRDEF_VARS__ */
 
#if !defined (__L1STRDEF_PROTOS__)
#define __L1STRDEF_PROTOS__
 
/*
MACROS-FUNCTIONS :
*/
#define M_vResetpstMessageFIFO(p_stMessageFIFO) \
if (p_stMessageFIFO) \
{\
 (p_stMessageFIFO)->eSendStatus = E_ts_Invalid; \
}
 
/*
 Prototypes :
 */
NetLib_tdeErrorStatus eNetCheckMessageBody(tdstNetMessage *);
unsigned short uwNetProcessCheckSumBody(tdstNetMessage *);
NetLib_tdeErrorStatus eLevel1AddNewSession(tdstNetMessage *pstMes,tdeNetProtocol eProt,tduwNetChannel uwChannel);
NetLib_tdeErrorStatus eLevel1AddNewPlayer(NetLib_tduxPlayerId,tdstAddPlayerL1Desc *);
NetLib_tdeErrorStatus eLevel1BackfireSysMessage(tdeNetMessageType ,tdeNetProtocol,tduwNetChannel ,tdstNetMessage *);
NetLib_tdeErrorStatus eLevel1BuildRouteInfo(tdstNetMessage *pstMes,tdeNetProtocol eProt,tduwNetChannel uwChannel);
NetLib_tdeErrorStatus eLevel1BuildRouteInfoOfSessionPlayer(tdstNetMessage *pstMes,tdeNetProtocol eProt,tduwNetChannel uwChannel);
NetLib_tdeErrorStatus eLevel1DisconnectRemotePlayer(NetLib_tduxPlayerId );
NetLib_tdeErrorStatus eLevel1FillNewRouteCell(tdstRouteCell*,NetLib_tduxPlayerId,tdeNetProtocol,tduwNetChannel);
NetLib_tdeErrorStatus eLevel1GetSysMsg(tdstNetMessage**,tdeNetProtocol *,tduwNetChannel *);
NetLib_tdeErrorStatus eLevel1GlobalSetup(NetLib_tduwMode Mode,short BroadcastIpx);
NetLib_tdeErrorStatus eLevel1HandleSysMsgConnectRequest(tdstNetMessage *pstMes,tdeNetProtocol eProt,tduwNetChannel uwChannel);
NetLib_tdeErrorStatus eLevel1HandleSysMsgFullBuffer(tdstNetMessage *pstMes,tdeNetProtocol eProt,tduwNetChannel uwChannel);
NetLib_tdeErrorStatus eLevel1HandleSysMsgUnknownRecipient(tdstNetMessage*);
NetLib_tdeErrorStatus eLevel1HandleSysMsgUnknownSender(tdstNetMessage*);
NetLib_tdeErrorStatus eLevel1IsSendingListEmpty(NetLib_tduxPlayerId);
NetLib_tdeErrorStatus eLevel1IsSendingListOk(NetLib_tduxPlayerId);
NetLib_tdeErrorStatus eLevel1ReadMessage(NetLib_tduxPlayerId,tdstNetMessage**,unsigned char);
NetLib_tdeErrorStatus eLevel1RouteSysMsg(tdstNetMessage *pstMes,tdeNetProtocol eProt,tduwNetChannel uwChannel);
NetLib_tdeErrorStatus eLevel1GoesToIP(NetLib_tduxPlayerId);
NetLib_tdeErrorStatus eLevel1SendMessage(tdstNetMessage *pstMes,tdeNetProtocol eProt,tduwNetChannel uwChannel);
NetLib_tdeErrorStatus eLevel1SendSessionRequestMsg(NetLib_tduxDescriptionLength uxMaxPlayerInfo);
NetLib_tdeErrorStatus eLevel1SetMaxNumberOfRemotePlayers(unsigned short);
NetLib_tdeErrorStatus eLevel1StripSessionList(NetLib_tduxSessionId );
NetLib_tdeErrorStatus eLevel1UpdateRouteInfo(tdstNetMessage *pstMes,tdeNetProtocol eProt,tduwNetChannel uwChannel);
 
NetLib_tdeErrorStatus eLevel1NetSetMaxNbrOfMsgPerList(unsigned short);
 
tdstNetProtocolInterface *p_stLevel1GetInterfaceOfProtocol(tdeNetProtocol );
 
short wLevel1IndexInRouteTable(NetLib_tduxPlayerId);
 
unsigned char ucLevel1GetReemissionMode(void);
 
unsigned short uwLevel1GetMaxNumberOfRemotePlayers(void);
unsigned short uwLevel1GetNumberOfRemotePlayers(void);
 
NetLib_tdeErrorStatus eLevel1HandleIncomingSysMsg(tdstNetMessage*,tdeNetProtocol,tduwNetChannel);
NetLib_tdeErrorStatus eLevel1HandleIncomingEngineMsg(tdstNetMessage*,tdeNetProtocol,tduwNetChannel);
 
void vLevel1CloseLibrary(void);
void vLevel1DestroySessionCellList(void);
int _NET_CALLING_CONV_ iLevel1NetEngine(void);
void vLevel1NetCloseChannel(tdeNetProtocol,tduwNetChannel,NetLib_tduxPlayerId);
void vLevel1OutgoingNetEngine(void);
void vLevel1SetPlayerId(NetLib_tduxPlayerId );
void vLevel1SetReemissionMode(unsigned char);
void vLevel1SetSessionId(NetLib_tduxPlayerId);
 
void vLevel1AddBroadcastPath(NetLib_tduxPlayerId SourcePlayer,NetLib_tduxPlayerId DestPlayer);
int vLevel1ExistBroadcastPath(NetLib_tduxPlayerId SourcePlayer,NetLib_tduxPlayerId DestPlayer);
void vLevel1SupBroadcastDest(NetLib_tduxPlayerId DestPlayer);
void vLevel1SupBroadcastPath(NetLib_tduxPlayerId SourcePlayer,NetLib_tduxPlayerId DestPlayer);
void vLevel1SupBroadcastSource(NetLib_tduxPlayerId SourcePlayer);
void vLevel1SetBroadcastState(short BroadcastIpx);
void eLevel1UpdateRouteOfPlayer(tdstNetMessage *pstMes,tdeNetProtocol eProt,tduwNetChannel uwChannel);
 
NetLib_tdeErrorStatus eNetLevel1EraseAllMessages
(
 NetLib_tduxPlayerId,
 unsigned char,
 NetLib_tdeErrorStatus (_NET_CALLING_CONV_*)(tdstNetMessage*,void*),
 void *
);
 
#endif /* !__L1STRDEF_PROTOS__ */
 
#endif /* !ONLY_TYPES */
 
