I am wondering if the tcpip-additions from ntba2 can be committed to svn. Basically they don't change any existing functionality, but only add 6 functions which are needed to compile myPS2.
I don't see any reason why they can't be commited since they don't change anything which might break existing applications, but having them in svn would make my life way easier since I wouldn't need to patch the sdk each time a new revision comes out. Below are the diff -ru changes.
Code: Select all
--- ps2sdk/common/include/tcpip.h 2007-01-18 02:58:32.000000000 +0100
+++ ps2sdksrc/common/include/tcpip.h 2007-01-18 02:56:41.000000000 +0100
@@ -361,4 +361,21 @@
u8 hw_addr[8];
} t_ip_info;
+#ifndef FAR
+#define FAR
+#endif
+struct hostent {
+ char FAR * h_name; /* official name of host */
+ char FAR * FAR * h_aliases; /* alias list */
+ short h_addrtype; /* host address type */
+ short h_length; /* length of address */
+ char FAR * FAR * h_addr_list; /* list of addresses */
+#define h_addr h_addr_list[0] /* address, for backward compat */
+};
+
+#if !defined(INADDR_NONE)
+#define INADDR_NONE ((u32) 0xffffffff) /* 255.255.255.255 */
+#endif
+
#endif
+
--- ps2sdk/ee/rpc/tcpip/include/ps2ip.h 2007-01-18 02:58:33.000000000 +0100
+++ ps2sdksrc/ee/rpc/tcpip/include/ps2ip.h 2007-01-18 02:55:54.000000000 +0100
@@ -34,6 +34,12 @@
int ps2ip_getconfig(char *netif_name, t_ip_info *ip_info);
int select(int maxfdp1, struct fd_set *readset, struct fd_set *writeset, struct fd_set *exceptset, struct timeval *timeout);
int ioctlsocket(int s, long cmd, void *argp);
+int getsockname(int s, struct sockaddr* name, int* namelen);
+int getpeername(int s, struct sockaddr *name, int *namelen);
+int getsockopt(int s, int level, int optname, void* optval, socklen_t* optlen);
+int setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen);
+int gethostbyname(char *name, struct in_addr *ip);
+int ps2ip_dnslookup(char *name, struct in_addr *ip);
#ifdef __cplusplus
}
--- ps2sdk/ee/rpc/tcpip/src/ps2ipc.c 2007-01-18 02:58:33.000000000 +0100
+++ ps2sdksrc/ee/rpc/tcpip/src/ps2ipc.c 2007-01-18 02:55:29.000000000 +0100
@@ -35,6 +35,11 @@
#define ID_GETCONFIG 13
#define ID_SELECT 14
#define ID_IOCTL 15
+#define ID_GETSOCKNAME 16
+#define ID_GETPEERNAME 17
+#define ID_GETSOCKOPT 18
+#define ID_SETSOCKOPT 19
+#define ID_GETHOSTBYNAME 20
static int _init_check = 0;
static SifRpcClientData_t _ps2ip;
@@ -422,3 +427,85 @@
return _rpc_buffer[0];
}
+
+int getsockname(int s, struct sockaddr *name, int *namelen)
+{
+ cmd_pkt *pkt = (cmd_pkt *)_rpc_buffer;
+
+ if(!_init_check) return -1;
+
+ pkt->socket = s;
+
+ SifCallRpc(&_ps2ip, ID_GETSOCKNAME, 0, (void*)_rpc_buffer, 4, (void*)_rpc_buffer, sizeof(cmd_pkt), 0, 0);
+
+ if(pkt->len < *namelen) *namelen = pkt->len;
+ memcpy((void *)name, (void *)&pkt->sockaddr, *namelen);
+
+ return pkt->socket;
+}
+
+int getpeername(int s, struct sockaddr *name, int *namelen)
+{
+ cmd_pkt *pkt = (cmd_pkt *)_rpc_buffer;
+
+ if(!_init_check) return -1;
+
+ pkt->socket = s;
+
+ SifCallRpc(&_ps2ip, ID_GETPEERNAME, 0, (void*)_rpc_buffer, 4, (void*)_rpc_buffer, sizeof(cmd_pkt), 0, 0);
+
+ if(pkt->len < *namelen) *namelen = pkt->len;
+ memcpy((void *)name, (void *)&pkt->sockaddr, *namelen);
+
+ return pkt->socket;
+}
+
+// return buffer:
+// Offset 0 = getsockopt return value
+// 0ffset 1 = optlen
+// Offset 2 = optval (max 128 bytes)
+int getsockopt(int s, int level, int optname, void* optval, socklen_t* optlen)
+{
+ ((int*)_rpc_buffer)[0] = s;
+ ((int*)_rpc_buffer)[1] = level;
+ ((int*)_rpc_buffer)[2] = optname;
+
+ SifCallRpc(&_ps2ip, ID_GETSOCKOPT, 0, (void*)_rpc_buffer, 12, (void*)_rpc_buffer, 136, 0, 0);
+
+ if(_rpc_buffer[1] < *optlen) *optlen = _rpc_buffer[1];
+ memcpy((void*)optval, &_rpc_buffer[2], *optlen);
+
+ return _rpc_buffer[0];
+}
+
+int setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen)
+{
+ ((int*)_rpc_buffer)[0] = s;
+ ((int*)_rpc_buffer)[1] = level;
+ ((int*)_rpc_buffer)[2] = optname;
+ ((int*)_rpc_buffer)[3] = optlen;
+
+ memcpy(&_rpc_buffer[4], optval, optlen);
+
+ SifCallRpc(&_ps2ip, ID_SETSOCKOPT, 0, (void*)_rpc_buffer, 16 + optlen, (void*)_rpc_buffer, 4, 0, 0);
+
+ return _rpc_buffer[0];
+}
+
+int gethostbyname(char *name, struct in_addr *ip)
+{
+ int ret;
+
+ memcpy(_rpc_buffer, name, 256);
+ SifCallRpc(&_ps2ip, ID_GETHOSTBYNAME, 0, (void*)_rpc_buffer, 256, (void*)_rpc_buffer, 4 + sizeof(struct in_addr), 0, 0);
+
+ ret = _rpc_buffer[0];
+ memcpy(ip, &_rpc_buffer[1], sizeof(struct in_addr));
+
+ return ret;
+}
+
+int ps2ip_dnslookup(char *name, struct in_addr *ip)
+{
+ return gethostbyname(name, ip);
+}
--- ps2sdk/iop/tcpip/tcpip/include/ps2ip.h 2007-01-18 02:57:58.000000000 +0100
+++ ps2sdksrc/iop/tcpip/tcpip/include/ps2ip.h 2007-01-18 02:43:49.000000000 +0100
@@ -144,3 +144,8 @@
#define I_ps2ip_input DECLARE_IMPORT(22, ps2ip_input)
#endif /* IOP_PS2IP_H */
+// ntba2
+#define getsockname lwip_getsockname
+#define getpeername lwip_getpeername
+#define getsockopt lwip_getsockopt
+#define setsockopt lwip_setsockopt
\ No newline at end of file
--- ps2sdk/iop/tcpip/tcpips/src/imports.lst 2007-01-18 02:57:58.000000000 +0100
+++ ps2sdksrc/iop/tcpip/tcpips/src/imports.lst 2007-01-18 02:45:19.000000000 +0100
@@ -41,6 +41,10 @@
I_lwip_bind
I_lwip_close
I_lwip_connect
+I_lwip_getpeername
+I_lwip_getsockname
+I_lwip_getsockopt
+I_lwip_setsockopt
I_lwip_listen
I_lwip_recv
I_lwip_recvfrom
@@ -52,3 +56,7 @@
I_ps2ip_getconfig
I_ps2ip_setconfig
ps2ip_IMPORTS_end
+
+dns_IMPORTS_start
+I_gethostbyname
+dns_IMPORTS_end
\ No newline at end of file
--- ps2sdk/iop/tcpip/tcpips/src/irx_imports.h 2007-01-18 02:57:58.000000000 +0100
+++ ps2sdksrc/iop/tcpip/tcpips/src/irx_imports.h 2007-01-18 02:46:17.000000000 +0100
@@ -17,6 +17,7 @@
#include "irx.h"
/* Please keep these in alphabetical order! */
+#include "../../dns/include/dns.h"
#include "intrman.h"
#include "ps2ip.h"
#include "sifcmd.h"
--- ps2sdk/iop/tcpip/tcpips/src/ps2ips.c 2007-01-18 02:57:58.000000000 +0100
+++ ps2sdksrc/iop/tcpip/tcpips/src/ps2ips.c 2007-01-18 02:51:47.000000000 +0100
@@ -31,6 +31,8 @@
#include <intrman.h>
#include <ps2ip.h>
+#include "../../dns/include/dns.h"
+
#define PS2IP_IRX 0xB0125F2
#define ID_ACCEPT 1
@@ -47,6 +49,11 @@
#define ID_GETCONFIG 13
#define ID_SELECT 14
#define ID_IOCTL 15
+#define ID_GETSOCKNAME 16
+#define ID_GETPEERNAME 17
+#define ID_GETSOCKOPT 18
+#define ID_SETSOCKOPT 19
+#define ID_GETHOSTBYNAME 20
#define BUFF_SIZE (1024)
@@ -743,7 +750,87 @@
ret = ioctlsocket( s, cmd, argp );
ptr[0] = ret;
}
-
+void do_getsockname( void *rpcBuffer, int size )
+{
+ int *ptr = rpcBuffer;
+ cmd_pkt *pkt = (cmd_pkt *)ptr;
+ struct sockaddr addr;
+ int addrlen, ret;
+
+ ret = getsockname(pkt->socket, &addr, &addrlen);
+
+ pkt->socket = ret;
+ memcpy(&pkt->sockaddr, &addr, sizeof(struct sockaddr));
+ pkt->len = sizeof(struct sockaddr);
+}
+
+void do_getpeername( void *rpcBuffer, int size )
+{
+ int *ptr = rpcBuffer;
+ cmd_pkt *pkt = (cmd_pkt *)ptr;
+ struct sockaddr addr;
+ int addrlen, ret;
+
+ ret = getpeername(pkt->socket, &addr, &addrlen);
+
+ pkt->socket = ret;
+ memcpy(&pkt->sockaddr, &addr, sizeof(struct sockaddr));
+ pkt->len = sizeof(struct sockaddr);
+}
+
+void do_getsockopt( void *rpcBuffer, int size )
+{
+ int *ptr = rpcBuffer, ret;
+ int s;
+ int level;
+ int optname;
+ unsigned char optval[128];
+ int optlen;
+
+ s = ((int*)_rpc_buffer)[0];
+ level = ((int*)_rpc_buffer)[1];
+ optname = ((int*)_rpc_buffer)[2];
+ optlen = sizeof(optval);
+
+ ret = getsockopt(s, level, optname, optval, &optlen);
+
+ ptr[0] = ret; // 4
+ ptr[1] = optlen; // 4
+ memcpy( &ptr[2], optval, 128 ); // 128
+
+ // 136 bytes returned
+}
+
+void do_setsockopt( void *rpcBuffer, int size )
+{
+ int *ptr = rpcBuffer, ret;
+ int s;
+ int level;
+ int optname;
+ int optlen;
+ unsigned char optval[128];
+
+ s = ((int*)_rpc_buffer)[0];
+ level = ((int*)_rpc_buffer)[1];
+ optname = ((int*)_rpc_buffer)[2];
+ optlen = ((int*)_rpc_buffer)[3];
+ memcpy(optval, &_rpc_buffer[4], optlen);
+
+ ret = setsockopt(s, level, optname, optval, optlen);
+ ptr[0] = ret;
+}
+
+void do_gethostbyname( void *rpcBuffer, int size )
+{
+ int *ptr = rpcBuffer, ret;
+ struct in_addr addr;
+
+ ret = gethostbyname((char*)_rpc_buffer, &addr);
+
+ ptr[0] = ret;
+ memcpy(&ptr[1], &addr, sizeof(struct in_addr));
+}
+
void * rpcHandlerFunction(unsigned int command, void * rpcBuffer, int size)
{
@@ -791,6 +878,21 @@
case ID_IOCTL:
do_ioctlsocket(rpcBuffer, size);
break;
+ case ID_GETSOCKNAME:
+ do_getsockname(rpcBuffer, size);
+ break;
+ case ID_GETPEERNAME:
+ do_getpeername(rpcBuffer, size);
+ break;
+ case ID_GETSOCKOPT:
+ do_getsockopt(rpcBuffer, size);
+ break;
+ case ID_SETSOCKOPT:
+ do_setsockopt(rpcBuffer, size);
+ break;
+ case ID_GETHOSTBYNAME:
+ do_gethostbyname(rpcBuffer, size);
+ break;
default:
printf("PS2IPS: Unknown Function called!\n");
@@ -850,3 +952,4 @@
return 0;
}
+