/*
 
  PrivL0UDP.h
 
*/
 
#ifndef PRIVL0UDP_H
#define PRIVL0UDP_H
 
#include <NET\L0UDP.h>
 
/* 
 * universal multiplayer library level 0 header file
 * transport layer: UDP PC-windows 95
 */
 
#if !defined(__L0UDPPCWIN95_TYPES__)
#define __L0UDPPCWIN95_TYPES__
 
#if !defined(ONLY_TYPES)
#define L0UDPPCWIN95_UNDEF
#define ONLY_TYPES
#endif /* !ONLY_TYPES */
 
/*
 * include here any other include files you need
 */
#include <windows.h>
#include <NET\macros.h>
#include "L0GlDef.h"
 
#ifndef _WINSOCKAPI_
#include <winsock.h>
#endif
 
#if defined(L0UDPPCWIN95_UNDEF)
#undef ONLY_TYPES
#undef L0UDPPCWIN95_UNDEF
#endif /* !L0UDPPCWIN95_UNDEF */
 
/* maximum number of channels managed by the layer */
 
#define C_ucL0MaxNumberOfUDPChannels 15
 
 
/* 
 * template name for all structures
 * typedef struct tdstL0PCWin95UDPChannel_
 * {
 * } tdstL0PCWin95UDP;
 */
 
typedef struct tdstL0PCWin95UDPChannel_
{
 tdeNetTransferStatus eChannelStatus;
 
 /* IP address of the destination host */
 struct sockaddr_in stRemoteAddr;
 /* Index in the array of sockets */
 unsigned short uwSocketIndex;
 
 /* ring of messages received but not read yet */
 /* note that for  the broadcast channels,*/
 /* the array doesn't contain pointers to messages,*/
 /*  it holds channel numbers (cast to char *) instead.*/
 /* We rely on the possibility to cast an unsigned int into a tdpPointer */
 /* without loss of precision. */
 /* it would b goof to use a union to solve this problem ... */
 tdstNetDataCell *p_FirstDataCell;
 
 /* can this channel be used to send broadcast messages ? */
 unsigned char ubf1IsBroadcast : 1;
 /* is this slot in use in the protocol's array of channels ? */
 unsigned char ubf1IsSlotInUse : 1;
 /* is this slot ready for reading ? */
 unsigned char ubf1IsReadable : 1;
 
} tdstL0PCWin95UDPChannel;
 
#endif /* !__L0UDPPCWIN95_TYPES__ */
 
#if !defined(ONLY_TYPES)
 
#if !defined(__L0UDPPCWIN95_VARS__)
#define __L0UDPPCWIN95_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 /* !__L0UDPPCWIN95_VARS__ */
 
#if !defined (__L0UDPPCWIN95_PROTOS__)
#define __L0UDPPCWIN95_PROTOS__
 
/*
 * put here the prototypes of the handler functions for the object
 */
tduwNetChannel uwL0PCWin95UDPGetChannel(struct sockaddr_in *);
static tduwNetChannel uwL0PCWin95UDPOpenChannel(struct sockaddr_in *,unsigned short);
static void vL0PCWin95UDPCloseChannel(tduwNetChannel);
NetLib_tdeErrorStatus eL0PCWin95UDPInsertMessage(tduwNetChannel , tdpPointer );
NetLib_tdeErrorStatus eL0PCWin95UDPRemoveMessage(tduwNetChannel , tdpPointer *);
NetLib_tdeErrorStatus eL0PCWin95UDPMessageAvailable(void);
tduwNetChannel uwL0PCWin95UDPGetMessage(void);
tduwNetChannel uwL0PCWin95UDPStartChannelScan(void);
tduwNetChannel uwL0PCWin95UDPNextChannel(tduwNetChannel);
tduwNetChannel uwL0PCWin95UDPStartBroadcastChannelScan(void);
tduwNetChannel uwL0PCWin95UDPNextBroadcastChannel(tduwNetChannel);
NetLib_tdeErrorStatus eL0PCWin95UDPReadData(tduwNetChannel *, tdpPointer *);
NetLib_tdeErrorStatus eL0PCWin95UDPSendData(tduwNetChannel , tdpPointer);
NetLib_tdeErrorStatus eL0PCWin95UDPQueryChannelStatus(tduwNetChannel);
NetLib_tdeErrorStatus eLevel0InitWin95PCUDP(void);
void vL0PCWin95UDPCloseProtocol(void);
 
 
#endif /* !__L0UDPPCWIN95_PROTOS__ */
 
#endif /* !ONLY_TYPES */
 
#endif /* PRIVL0UDP_H */
