-
Notifications
You must be signed in to change notification settings - Fork 2.3k
sceNetInet socket remap #19827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sceNetInet socket remap #19827
Changes from 1 commit
303a03c
08f2bee
0f2bd65
8505e24
fcb3d63
c33ea84
3dc2a10
2c3f7f6
5026e92
155a9f9
a1744a6
b97b0e4
c9c5944
698b73d
728268b
77fcb18
f84ec05
cddd3d4
440fa80
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,22 +13,32 @@ enum class SocketState { | |
struct InetSocket { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should store non-blocking state here too, and probably some other value that can be set using PS: Sockets are in blocking mode by default after creation, thus the default value should be nonblocking = false. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, since we have stored the socket protocol here, we can replace these code at sceNetInet.cpp by forwarding only TCP or UDP instead of forwarding both protocol: // Enable Port-forwarding
// TODO: Check the socket type/protocol for SOCK_STREAM/SOCK_DGRAM or IPPROTO_TCP/IPPROTO_UDP instead of forwarding both protocol
// InetSocket* sock = pspSockets.Get<InetSocket>(socket, error);
// UPnP_Add((sock->type == SOCK_STREAM)? IP_PROTOCOL_TCP: IP_PROTOCOL_UDP, port, port);
unsigned short port = ntohs(saddr.in.sin_port);
UPnP_Add(IP_PROTOCOL_UDP, port, port);
UPnP_Add(IP_PROTOCOL_TCP, port, port); I opened both TCP and UDP because i use the native socket directly and there is noway to retrieve the socket protocol (at least the easy way as i remembered). Edit: oops, you already did this >.< |
||
SOCKET sock; // native socket | ||
SocketState state; | ||
// NOTE: These are the PSP types for now | ||
// NOTE: These are the PSP types. Can be converted to the host types if needed. | ||
int domain; | ||
int type; | ||
int protocol; | ||
// These are the host types for convenience. | ||
int hostDomain; | ||
int hostType; | ||
int hostProtocol; | ||
}; | ||
|
||
#define MIN_VALID_INET_SOCKET 61 | ||
#define VALID_INET_SOCKET_COUNT 256 | ||
class SocketManager { | ||
public: | ||
enum { | ||
VALID_INET_SOCKET_COUNT = 256, | ||
MIN_VALID_INET_SOCKET = 61, | ||
}; | ||
|
||
extern InetSocket g_inetSockets[VALID_INET_SOCKET_COUNT]; | ||
InetSocket *AllocSocket(int *index); | ||
bool GetInetSocket(int sock, InetSocket **inetSocket); | ||
SOCKET GetHostSocketFromInetSocket(int sock); | ||
void CloseAll(); | ||
|
||
int AllocInetSocket(); | ||
bool GetInetSocket(int sock, InetSocket **inetSocket); | ||
SOCKET GetHostSocketFromInetSocket(int sock); | ||
void CloseAllSockets(); | ||
// For debugger | ||
const InetSocket *Sockets() { | ||
return inetSockets_; | ||
} | ||
|
||
private: | ||
// We use this array from MIN_VALID_INET_SOCKET and forward. It's probably not a good idea to return 0 as a socket. | ||
InetSocket inetSockets_[VALID_INET_SOCKET_COUNT]; | ||
}; | ||
|
||
extern SocketManager g_socketManager; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we returned -1 in the case of failure to create a socket? just like a posix
socket
syscall:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The caller is responsible for the actual syscall return value. But yeah this will be made clearer in an upcoming commit.
(either way, haven't hit this yet)