1 /* 2 * sdl_network.h - Definitions for SDL implementation of networking 3 4 Copyright (C) 1991-2001 and beyond by Bungie Studios, Inc. 5 and the "Aleph One" developers. 6 7 This program is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation; either version 3 of the License, or 10 (at your option) any later version. 11 12 This program is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 This license is contained in the file "COPYING", 18 which is included with this source code; it is available online at 19 http://www.gnu.org/licenses/gpl.html 20 21 * Definitions for SDL implementation of networking 22 * 23 * (believed to be) Created by Christian Bauer 24 * 25 * Sept-Nov 2001 (Woody Zenfell): split some defs out of here to network_lookup_sdl.h 26 */ 27 28 #ifndef __SDL__NETWORK_H 29 #define __SDL__NETWORK_H 30 31 #include <SDL_net.h> 32 #include <string> 33 34 #include "cseries.h" 35 36 #include "network.h" 37 38 39 /* missing from AppleTalk.h */ 40 // ZZZ: note that this determines only the amount of storage allocated for packets, not 41 // the size of actual packets sent. I believe UDP on Ethernet should be able to carry 42 // around 1.5K per packet, not sure of the exact figure off the top of my head though. 43 // Note that the SDL network microphone code is the one sending "big" packets these days. 44 #define ddpMaxData 1500 45 46 typedef char NetEntityName[32]; 47 typedef IPaddress NetAddrBlock; 48 49 /* ---------- DDPFrame and PacketBuffer (DDP) */ 50 51 struct DDPFrame 52 { 53 uint16 data_size; 54 byte data[ddpMaxData]; 55 UDPsocket socket; 56 }; 57 typedef struct DDPFrame DDPFrame, *DDPFramePtr; 58 59 struct DDPPacketBuffer 60 { 61 byte protocolType; 62 NetAddrBlock sourceAddress; 63 64 uint16 datagramSize; 65 byte datagramData[ddpMaxData]; 66 }; 67 typedef struct DDPPacketBuffer DDPPacketBuffer, *DDPPacketBufferPtr; 68 69 /* ---------- ConnectionEnd (ADSP) */ 70 71 struct ConnectionEnd 72 { 73 TCPsocket socket; 74 TCPsocket server_socket; 75 SDLNet_SocketSet server_socket_set; 76 }; 77 typedef struct ConnectionEnd ConnectionEnd, *ConnectionEndPtr; 78 79 /* ---------- types */ 80 81 typedef NetEntityName *NetEntityNamePtr; 82 83 typedef void (*lookupUpdateProcPtr)(short message, short index); 84 typedef bool (*lookupFilterProcPtr)(NetEntityName *entity, NetAddrBlock *address); 85 typedef void (*PacketHandlerProcPtr)(DDPPacketBufferPtr packet); 86 87 /* ---------- prototypes/NETWORK.C */ 88 89 short NetState(void); 90 std::string NetSessionIdentifier(void); 91 92 void NetSetServerIdentifier(short identifier); 93 94 /* for giving to NetLookupOpen() as a filter procedure */ 95 bool NetEntityNotInGame(NetEntityName *entity, NetAddrBlock *address); 96 97 /* ---------- prototypes/NETWORK_NAMES.C */ 98 99 // ZZZ: moved to network_lookup_sdl.h to localize changes. 100 101 /* ---------- prototypes/NETWORK_LOOKUP.C */ 102 103 // ZZZ: moved to network_lookup_sdl.h to localize changes. 104 105 /* ---------- prototypes/NETWORK_DDP.C */ 106 107 OSErr NetDDPOpen(void); 108 OSErr NetDDPClose(void); 109 110 // ZZZ: this is a bit confusing; in the original AppleTalk DDP code, the socket routines 111 // took and returned a socket number, which is a bit like the file descriptor one gets for 112 // a UNIX socket. Now with NETWORK_IP, that portion of the API is used to pass an IP port number. 113 // (The argument to NetDDPCloseSocket() is now ignored, then; we only currently support one open UDP socket.) 114 // NETWORK_IP: *ioPortNumber is in network byte order ("big-endian") 115 OSErr NetDDPOpenSocket(short *ioPortNumber, PacketHandlerProcPtr packetHandler); 116 OSErr NetDDPCloseSocket(short ignored); 117 118 DDPFramePtr NetDDPNewFrame(void); 119 void NetDDPDisposeFrame(DDPFramePtr frame); 120 121 OSErr NetDDPSendFrame(DDPFramePtr frame, NetAddrBlock *address, short protocolType, short socket); 122 123 /* ---------- prototypes/NETWORK_ADSP.C */ 124 125 // jkvw: removed - we use TCPMess now 126 127 #endif 128