]> icculus.org git repositories - btb/d2x.git/blob - include/ipx_drv.h
fix formatting
[btb/d2x.git] / include / ipx_drv.h
1 /* 
2  * IPX driver interface
3  *
4  * parts from:
5  * ipx.h header file for IPX for the DOS emulator
6  *              Tim Bird, tbird@novell.com
7  */
8 #ifndef _IPX_DRV_H
9 #define _IPX_DRV_H
10 #define IPX_MANUAL_ADDRESS
11
12 #include "pstypes.h"
13
14 #if defined(__WINDOWS__) || defined(__MINGW32__)
15 #include <winsock.h>
16 #else
17 #include <netinet/in.h> /* for htons & co. */
18 #endif
19
20 #define MAX_PACKET_DATA         1500
21
22 #ifdef _MSC_VER
23 #pragma pack (push, 1)
24 #endif
25
26 typedef struct IPXAddressStruct {
27   ubyte Network[4] __pack__;
28   ubyte Node[6] __pack__;
29   ubyte Socket[2] __pack__;
30 } IPXAddress_t;
31
32 typedef struct IPXPacketStructure {
33   ushort Checksum __pack__;
34   ushort Length __pack__;
35   ubyte TransportControl __pack__;
36   ubyte PacketType __pack__;
37   IPXAddress_t Destination __pack__;
38   IPXAddress_t Source __pack__;
39 } IPXPacket_t;
40
41 #ifdef _MSC_VER
42 #pragma pack (pop)
43 #endif
44
45 typedef struct ipx_socket_struct {
46   ushort socket;
47   int fd;
48 } ipx_socket_t;
49
50 struct ipx_recv_data {
51         /* all network order */
52         ubyte src_network[4];
53         ubyte src_node[6];
54         ushort src_socket;
55         ushort dst_socket;
56         int pkt_type;
57 };
58
59 struct ipx_driver {
60 //      int (*GetMyAddress)(void);
61         int (*OpenSocket)(int port);
62         void (*CloseSocket)(void);
63         int (*SendPacket)(IPXPacket_t *IPXHeader,
64          ubyte *data, int dataLen);
65         int (*ReceivePacket)(char *buffer, int bufsize, 
66          struct ipx_recv_data *rec);
67         int (*PacketReady)(void);
68         int (*CheckReadyToJoin)(unsigned char *server, unsigned char *node);
69         int usepacketnum;//we can save 4 bytes
70         void (*GetLocalTarget) ( ubyte * server, ubyte * node, ubyte * local_target );
71         int (*GetPacketData) ( ubyte * data );
72         void (*SendPacketData) ( ubyte * data, int datasize, ubyte *network, ubyte *address, ubyte *immediate_address );
73 };
74
75 int ipx_general_PacketReady(int fd);
76
77 extern unsigned char ipx_MyAddress[10];
78
79 extern ubyte broadcast_addr[];
80 extern ubyte null_addr[];
81 extern u_int32_t ipx_network;
82
83 struct ipx_driver * arch_ipx_set_driver(char *arg);
84
85 #ifdef SUPPORTS_NET_IP
86 extern struct ipx_driver ipx_ip;
87 #endif
88
89 #endif /* _IPX_DRV_H */