summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorGravatar FearlessTobi2022-07-30 05:58:23 +0200
committerGravatar FearlessTobi2022-08-15 20:25:42 +0200
commitf80c7c4cd5c090b9a31f89a0eb3d86cbe928c50b (patch)
treead359908ba2d3cd003082b39cc7217b61e5b18f6 /src/common
parentweb_service: Correct jwt issuer string (diff)
downloadyuzu-f80c7c4cd5c090b9a31f89a0eb3d86cbe928c50b.tar.gz
yuzu-f80c7c4cd5c090b9a31f89a0eb3d86cbe928c50b.tar.xz
yuzu-f80c7c4cd5c090b9a31f89a0eb3d86cbe928c50b.zip
core, network: Add ability to proxy socket packets
Diffstat (limited to 'src/common')
-rw-r--r--src/common/CMakeLists.txt1
-rw-r--r--src/common/announce_multiplayer_room.h10
-rw-r--r--src/common/socket_types.h52
3 files changed, 56 insertions, 7 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index a6dc31b53..635fb85c8 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -124,6 +124,7 @@ add_library(common STATIC
124 settings.h 124 settings.h
125 settings_input.cpp 125 settings_input.cpp
126 settings_input.h 126 settings_input.h
127 socket_types.h
127 spin_lock.cpp 128 spin_lock.cpp
128 spin_lock.h 129 spin_lock.h
129 stream.cpp 130 stream.cpp
diff --git a/src/common/announce_multiplayer_room.h b/src/common/announce_multiplayer_room.h
index 0ad9da2be..cb004e0eb 100644
--- a/src/common/announce_multiplayer_room.h
+++ b/src/common/announce_multiplayer_room.h
@@ -8,12 +8,11 @@
8#include <string> 8#include <string>
9#include <vector> 9#include <vector>
10#include "common/common_types.h" 10#include "common/common_types.h"
11#include "common/socket_types.h"
11#include "web_service/web_result.h" 12#include "web_service/web_result.h"
12 13
13namespace AnnounceMultiplayerRoom { 14namespace AnnounceMultiplayerRoom {
14 15
15using MacAddress = std::array<u8, 6>;
16
17struct GameInfo { 16struct GameInfo {
18 std::string name{""}; 17 std::string name{""};
19 u64 id{0}; 18 u64 id{0};
@@ -24,7 +23,7 @@ struct Member {
24 std::string nickname; 23 std::string nickname;
25 std::string display_name; 24 std::string display_name;
26 std::string avatar_url; 25 std::string avatar_url;
27 MacAddress mac_address; 26 Network::IPv4Address fake_ip;
28 GameInfo game; 27 GameInfo game;
29}; 28};
30 29
@@ -75,10 +74,7 @@ public:
75 const bool has_password, const GameInfo& preferred_game) = 0; 74 const bool has_password, const GameInfo& preferred_game) = 0;
76 /** 75 /**
77 * Adds a player information to the data that gets announced 76 * Adds a player information to the data that gets announced
78 * @param nickname The nickname of the player 77 * @param member The player to add
79 * @param mac_address The MAC Address of the player
80 * @param game_id The title id of the game the player plays
81 * @param game_name The name of the game the player plays
82 */ 78 */
83 virtual void AddPlayer(const Member& member) = 0; 79 virtual void AddPlayer(const Member& member) = 0;
84 80
diff --git a/src/common/socket_types.h b/src/common/socket_types.h
new file mode 100644
index 000000000..5bb309a44
--- /dev/null
+++ b/src/common/socket_types.h
@@ -0,0 +1,52 @@
1// Copyright 2022 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include "common/common_types.h"
8
9namespace Network {
10
11/// Address families
12enum class Domain : u8 {
13 INET, ///< Address family for IPv4
14};
15
16/// Socket types
17enum class Type {
18 STREAM,
19 DGRAM,
20 RAW,
21 SEQPACKET,
22};
23
24/// Protocol values for sockets
25enum class Protocol : u8 {
26 ICMP,
27 TCP,
28 UDP,
29};
30
31/// Shutdown mode
32enum class ShutdownHow {
33 RD,
34 WR,
35 RDWR,
36};
37
38/// Array of IPv4 address
39using IPv4Address = std::array<u8, 4>;
40
41/// Cross-platform sockaddr structure
42struct SockAddrIn {
43 Domain family;
44 IPv4Address ip;
45 u16 portno;
46};
47
48constexpr u32 FLAG_MSG_PEEK = 0x2;
49constexpr u32 FLAG_MSG_DONTWAIT = 0x80;
50constexpr u32 FLAG_O_NONBLOCK = 0x800;
51
52} // namespace Network