RetroArch/network/netplay/netplay_discovery.h

107 lines
2.8 KiB
C
Raw Normal View History

/* RetroArch - A frontend for libretro.
2017-01-22 13:40:32 +01:00
* Copyright (C) 2016-2017 - Gregor Richards
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __RARCH_NETPLAY_DISCOVERY_H
#define __RARCH_NETPLAY_DISCOVERY_H
#include <net/net_compat.h>
Fix lan rooms Squashed commit of the following: commit 6e1fea3b16bb330ed2862eb00d2e911221c48a34 Author: radius <andres.430@gmail.com> Date: Sat Nov 18 22:16:02 2017 -0500 use the baked in address instead of sockaddr commit 84f2d389fd6352b3037f48c18d133d2f1063d461 Author: radius <andres.430@gmail.com> Date: Sat Nov 18 22:05:57 2017 -0500 send replies commit c6733009cc5a25e58391c5fc693b277ea27404b3 Author: radius <andres.430@gmail.com> Date: Sat Nov 18 21:53:12 2017 -0500 send replies commit a6816c9481f7ea89a3c97597233e54c6354716e7 Author: radius <andres.430@gmail.com> Date: Sat Nov 18 21:46:55 2017 -0500 send replies commit c2453b73ccafbd53192507affbc11d5f279c2e7c Author: radius <andres.430@gmail.com> Date: Sat Nov 18 21:26:34 2017 -0500 look for common interfaces commit fb42e6470242689f5e6160149ef91f0f0abf068d Author: radius <andres.430@gmail.com> Date: Sat Nov 18 20:06:50 2017 -0500 send broadcasts in all interfaces commit b7730596df9775fb815007689e9c7cc06b317b03 Author: radius <andres.430@gmail.com> Date: Sat Nov 18 20:00:17 2017 -0500 send broadcasts in all interfaces commit b620a78052d1b95e81d346f3e5efb233e0547793 Author: radius <andres.430@gmail.com> Date: Sat Nov 18 14:30:31 2017 -0500 add more logging commit c016c7d559cd631172a58f99cd3e1a1365965b8e Author: radius <andres.430@gmail.com> Date: Sat Nov 18 14:12:03 2017 -0500 update log messages commit 0a49ba61f56f2ca483fa76c7a04f0709c68b95ad Author: radius <andres.430@gmail.com> Date: Sat Nov 18 13:50:47 2017 -0500 fix lan room listing for rooms > 1, allow connecting in arbitrary ports
2017-11-18 22:43:47 -05:00
#include <net/net_ifinfo.h>
2017-01-19 08:56:56 -05:00
#include <retro_miscellaneous.h>
#define NETPLAY_HOST_STR_LEN 32
#define NETPLAY_HOST_LONGSTR_LEN 256
enum rarch_netplay_discovery_ctl_state
{
RARCH_NETPLAY_DISCOVERY_CTL_NONE = 0,
RARCH_NETPLAY_DISCOVERY_CTL_LAN_SEND_QUERY,
RARCH_NETPLAY_DISCOVERY_CTL_LAN_GET_RESPONSES,
RARCH_NETPLAY_DISCOVERY_CTL_LAN_CLEAR_RESPONSES
};
2017-01-22 21:19:39 +01:00
struct netplay_host
{
struct sockaddr addr;
socklen_t addrlen;
Fix lan rooms Squashed commit of the following: commit 6e1fea3b16bb330ed2862eb00d2e911221c48a34 Author: radius <andres.430@gmail.com> Date: Sat Nov 18 22:16:02 2017 -0500 use the baked in address instead of sockaddr commit 84f2d389fd6352b3037f48c18d133d2f1063d461 Author: radius <andres.430@gmail.com> Date: Sat Nov 18 22:05:57 2017 -0500 send replies commit c6733009cc5a25e58391c5fc693b277ea27404b3 Author: radius <andres.430@gmail.com> Date: Sat Nov 18 21:53:12 2017 -0500 send replies commit a6816c9481f7ea89a3c97597233e54c6354716e7 Author: radius <andres.430@gmail.com> Date: Sat Nov 18 21:46:55 2017 -0500 send replies commit c2453b73ccafbd53192507affbc11d5f279c2e7c Author: radius <andres.430@gmail.com> Date: Sat Nov 18 21:26:34 2017 -0500 look for common interfaces commit fb42e6470242689f5e6160149ef91f0f0abf068d Author: radius <andres.430@gmail.com> Date: Sat Nov 18 20:06:50 2017 -0500 send broadcasts in all interfaces commit b7730596df9775fb815007689e9c7cc06b317b03 Author: radius <andres.430@gmail.com> Date: Sat Nov 18 20:00:17 2017 -0500 send broadcasts in all interfaces commit b620a78052d1b95e81d346f3e5efb233e0547793 Author: radius <andres.430@gmail.com> Date: Sat Nov 18 14:30:31 2017 -0500 add more logging commit c016c7d559cd631172a58f99cd3e1a1365965b8e Author: radius <andres.430@gmail.com> Date: Sat Nov 18 14:12:03 2017 -0500 update log messages commit 0a49ba61f56f2ca483fa76c7a04f0709c68b95ad Author: radius <andres.430@gmail.com> Date: Sat Nov 18 13:50:47 2017 -0500 fix lan room listing for rooms > 1, allow connecting in arbitrary ports
2017-11-18 22:43:47 -05:00
char address[NETPLAY_HOST_STR_LEN];
2017-01-22 21:19:39 +01:00
char nick[NETPLAY_HOST_STR_LEN];
char frontend[NETPLAY_HOST_STR_LEN];
2017-01-22 21:19:39 +01:00
char core[NETPLAY_HOST_STR_LEN];
char core_version[NETPLAY_HOST_STR_LEN];
char retroarch_version[NETPLAY_HOST_STR_LEN];
char content[NETPLAY_HOST_LONGSTR_LEN];
char subsystem_name[NETPLAY_HOST_LONGSTR_LEN];
int content_crc;
Fix lan rooms Squashed commit of the following: commit 6e1fea3b16bb330ed2862eb00d2e911221c48a34 Author: radius <andres.430@gmail.com> Date: Sat Nov 18 22:16:02 2017 -0500 use the baked in address instead of sockaddr commit 84f2d389fd6352b3037f48c18d133d2f1063d461 Author: radius <andres.430@gmail.com> Date: Sat Nov 18 22:05:57 2017 -0500 send replies commit c6733009cc5a25e58391c5fc693b277ea27404b3 Author: radius <andres.430@gmail.com> Date: Sat Nov 18 21:53:12 2017 -0500 send replies commit a6816c9481f7ea89a3c97597233e54c6354716e7 Author: radius <andres.430@gmail.com> Date: Sat Nov 18 21:46:55 2017 -0500 send replies commit c2453b73ccafbd53192507affbc11d5f279c2e7c Author: radius <andres.430@gmail.com> Date: Sat Nov 18 21:26:34 2017 -0500 look for common interfaces commit fb42e6470242689f5e6160149ef91f0f0abf068d Author: radius <andres.430@gmail.com> Date: Sat Nov 18 20:06:50 2017 -0500 send broadcasts in all interfaces commit b7730596df9775fb815007689e9c7cc06b317b03 Author: radius <andres.430@gmail.com> Date: Sat Nov 18 20:00:17 2017 -0500 send broadcasts in all interfaces commit b620a78052d1b95e81d346f3e5efb233e0547793 Author: radius <andres.430@gmail.com> Date: Sat Nov 18 14:30:31 2017 -0500 add more logging commit c016c7d559cd631172a58f99cd3e1a1365965b8e Author: radius <andres.430@gmail.com> Date: Sat Nov 18 14:12:03 2017 -0500 update log messages commit 0a49ba61f56f2ca483fa76c7a04f0709c68b95ad Author: radius <andres.430@gmail.com> Date: Sat Nov 18 13:50:47 2017 -0500 fix lan room listing for rooms > 1, allow connecting in arbitrary ports
2017-11-18 22:43:47 -05:00
int port;
};
2017-01-22 21:19:39 +01:00
struct netplay_host_list
{
struct netplay_host *hosts;
size_t size;
};
/* Keep these in order, they coincide with a server-side enum and must match. */
enum netplay_host_method
{
NETPLAY_HOST_METHOD_UNKNOWN = 0,
NETPLAY_HOST_METHOD_MANUAL,
NETPLAY_HOST_METHOD_UPNP,
NETPLAY_HOST_METHOD_MITM
};
2017-01-19 08:56:56 -05:00
struct netplay_room
{
int id;
char nickname [2048];
char address [2048];
char mitm_address[2048];
2017-01-19 08:56:56 -05:00
int port;
int mitm_port;
char corename [2048];
char frontend [2048];
char coreversion [2048];
char gamename [2048];
2017-01-19 08:56:56 -05:00
int gamecrc;
int timestamp;
int host_method;
2017-03-04 01:31:24 -05:00
bool has_password;
bool has_spectate_password;
bool lan;
2017-03-04 01:31:24 -05:00
bool fixed;
char retroarch_version [2048];
char subsystem_name [2048];
char country[2048];
2017-03-04 01:31:24 -05:00
struct netplay_room *next;
2017-01-19 08:56:56 -05:00
};
2017-01-22 21:19:39 +01:00
extern struct netplay_room *netplay_room_list;
2017-01-19 08:56:56 -05:00
2017-01-22 21:19:39 +01:00
extern int netplay_room_count;
2017-01-19 08:56:56 -05:00
/** Initialize Netplay discovery */
bool init_netplay_discovery(void);
/** Deinitialize and free Netplay discovery */
void deinit_netplay_discovery(void);
/** Discovery control */
bool netplay_discovery_driver_ctl(enum rarch_netplay_discovery_ctl_state state, void *data);
struct netplay_room* netplay_get_host_room(void);
#endif