rubidium@5720: /* $Id$ */ rubidium@5720: rubidium@5720: #ifndef NETWORK_CORE_UDP_H rubidium@5720: #define NETWORK_CORE_UDP_H rubidium@5720: rubidium@5720: #ifdef ENABLE_NETWORK rubidium@5720: rubidium@5720: /** rubidium@5720: * @file udp.h Basic functions to receive and send UDP packets. rubidium@5720: */ rubidium@5720: rubidium@5720: ///** Sending/receiving of UDP packets **//// rubidium@5720: rubidium@5720: void NetworkSendUDP_Packet(SOCKET udp, Packet *p, struct sockaddr_in *recv); rubidium@5720: bool NetworkUDPListen(SOCKET *udp, uint32 host, uint16 port, bool broadcast); rubidium@5720: void NetworkUDPReceive(SOCKET udp); rubidium@5720: rubidium@5720: /** rubidium@5720: * Function that is called for every received UDP packet. rubidium@5720: * @param packet the received packet rubidium@5720: * @param client_addr the address of the sender of the packet rubidium@5720: */ rubidium@5720: void NetworkHandleUDPPacket(Packet *p, struct sockaddr_in *client_addr); rubidium@5720: rubidium@5720: rubidium@5720: ///** Sending/receiving of (large) chuncks of UDP packets **//// rubidium@5720: rubidium@5720: rubidium@5720: /** Enum with all types of UDP packets. The order MUST not be changed **/ rubidium@5720: enum { rubidium@5720: PACKET_UDP_CLIENT_FIND_SERVER, ///< Queries a game server for game information rubidium@5720: PACKET_UDP_SERVER_RESPONSE, ///< Reply of the game server with game information rubidium@5720: PACKET_UDP_CLIENT_DETAIL_INFO, ///< Queries a game server about details of the game, such as companies rubidium@5720: PACKET_UDP_SERVER_DETAIL_INFO, ///< Reply of the game server about details of the game, such as companies rubidium@5720: PACKET_UDP_SERVER_REGISTER, ///< Packet to register itself to the master server rubidium@5720: PACKET_UDP_MASTER_ACK_REGISTER, ///< Packet indicating registration has succedeed rubidium@5720: PACKET_UDP_CLIENT_GET_LIST, ///< Request for serverlist from master server rubidium@5720: PACKET_UDP_MASTER_RESPONSE_LIST, ///< Response from master server with server ip's + port's rubidium@5720: PACKET_UDP_SERVER_UNREGISTER, ///< Request to be removed from the server-list rubidium@5720: PACKET_UDP_CLIENT_GET_NEWGRFS, ///< Requests the name for a list of GRFs (GRF_ID and MD5) rubidium@5720: PACKET_UDP_SERVER_NEWGRFS, ///< Sends the list of NewGRF's requested. rubidium@5720: PACKET_UDP_END ///< Must ALWAYS be on the end of this list!! (period) rubidium@5720: }; rubidium@5720: rubidium@5720: void NetworkSend_GRFIdentifier(Packet *p, const GRFConfig *c); rubidium@5720: void NetworkSend_NetworkGameInfo(Packet *p, const NetworkGameInfo *info); rubidium@5720: rubidium@5720: void NetworkRecv_GRFIdentifier(NetworkClientState *cs, Packet *p, GRFConfig *c); rubidium@5720: void NetworkRecv_NetworkGameInfo(NetworkClientState *cs, Packet *p, NetworkGameInfo *info); rubidium@5720: rubidium@5720: /** rubidium@5720: * Function that is called for every GRFConfig that is read when receiving rubidium@5720: * a NetworkGameInfo. Only grfid and md5sum are set, the rest is zero. This rubidium@5720: * function must set all appropriate fields. This GRF is later appended to rubidium@5720: * the grfconfig list of the NetworkGameInfo. rubidium@5720: * @param config the GRF to handle rubidium@5720: */ rubidium@5720: void HandleIncomingNetworkGameInfoGRFConfig(GRFConfig *config); rubidium@5720: rubidium@5720: #endif /* ENABLE_NETWORK */ rubidium@5720: rubidium@5720: #endif /* NETWORK_CORE_UDP_H */