1 /* RetroArch - A frontend for libretro. 2 * Copyright (C) 2016-2017 - Gregor Richards 3 * 4 * RetroArch is free software: you can redistribute it and/or modify it under the terms 5 * of the GNU General Public License as published by the Free Software Found- 6 * ation, either version 3 of the License, or (at your option) any later version. 7 * 8 * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 9 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 10 * PURPOSE. See the GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License along with RetroArch. 13 * If not, see <http://www.gnu.org/licenses/>. 14 */ 15 16 #ifndef __RARCH_NETPLAY_DISCOVERY_H 17 #define __RARCH_NETPLAY_DISCOVERY_H 18 19 #include <net/net_compat.h> 20 #include <net/net_ifinfo.h> 21 #include <retro_miscellaneous.h> 22 23 #define NETPLAY_HOST_STR_LEN 32 24 #define NETPLAY_HOST_LONGSTR_LEN 256 25 26 enum rarch_netplay_discovery_ctl_state 27 { 28 RARCH_NETPLAY_DISCOVERY_CTL_NONE = 0, 29 RARCH_NETPLAY_DISCOVERY_CTL_LAN_SEND_QUERY, 30 RARCH_NETPLAY_DISCOVERY_CTL_LAN_GET_RESPONSES, 31 RARCH_NETPLAY_DISCOVERY_CTL_LAN_CLEAR_RESPONSES 32 }; 33 34 struct netplay_host 35 { 36 struct sockaddr addr; 37 socklen_t addrlen; 38 int content_crc; 39 int port; 40 char address[NETPLAY_HOST_STR_LEN]; 41 char nick[NETPLAY_HOST_STR_LEN]; 42 char frontend[NETPLAY_HOST_STR_LEN]; 43 char core[NETPLAY_HOST_STR_LEN]; 44 char core_version[NETPLAY_HOST_STR_LEN]; 45 char retroarch_version[NETPLAY_HOST_STR_LEN]; 46 char content[NETPLAY_HOST_LONGSTR_LEN]; 47 char subsystem_name[NETPLAY_HOST_LONGSTR_LEN]; 48 }; 49 50 struct netplay_host_list 51 { 52 struct netplay_host *hosts; 53 size_t size; 54 }; 55 56 /* Keep these in order, they coincide with a server-side enum and must match. */ 57 enum netplay_host_method 58 { 59 NETPLAY_HOST_METHOD_UNKNOWN = 0, 60 NETPLAY_HOST_METHOD_MANUAL, 61 NETPLAY_HOST_METHOD_UPNP, 62 NETPLAY_HOST_METHOD_MITM 63 }; 64 65 struct netplay_room 66 { 67 struct netplay_room *next; 68 int id; 69 int port; 70 int mitm_port; 71 int gamecrc; 72 int timestamp; 73 int host_method; 74 char country [3]; 75 char retroarch_version [33]; 76 char nickname [33]; 77 char subsystem_name [256]; 78 char corename [256]; 79 char frontend [256]; 80 char coreversion [256]; 81 char gamename [256]; 82 char address [256]; 83 char mitm_address [256]; 84 bool has_password; 85 bool has_spectate_password; 86 bool lan; 87 bool fixed; 88 }; 89 90 extern struct netplay_room *netplay_room_list; 91 92 extern int netplay_room_count; 93 94 /** Initialize Netplay discovery */ 95 bool init_netplay_discovery(void); 96 97 /** Deinitialize and free Netplay discovery */ 98 void deinit_netplay_discovery(void); 99 100 /** Discovery control */ 101 bool netplay_discovery_driver_ctl(enum rarch_netplay_discovery_ctl_state state, void *data); 102 103 struct netplay_room* netplay_get_host_room(void); 104 105 #endif 106