ps2sdk  1.1
A collection of Open Source libraries used for developing applications on Sony's PlayStation 2® (PS2).
ps2ips.h File Reference
#include <tcpip.h>
#include <sys/time.h>
+ Include dependency graph for ps2ips.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int ps2ip_init (void)
 
void ps2ip_deinit (void)
 
int accept (int s, struct sockaddr *addr, int *addrlen)
 
int bind (int s, struct sockaddr *name, int namelen)
 
int disconnect (int s)
 
int connect (int s, struct sockaddr *name, int namelen)
 
int listen (int s, int backlog)
 
int recv (int s, void *mem, int len, unsigned int flags)
 
int recvfrom (int s, void *mem, int len, unsigned int flags, struct sockaddr *from, int *fromlen)
 
int send (int s, void *dataptr, int size, unsigned int flags)
 
int sendto (int s, void *dataptr, int size, unsigned int flags, struct sockaddr *to, int tolen)
 
int socket (int domain, int type, int protocol)
 
int ps2ip_setconfig (t_ip_info *ip_info)
 
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)
 
struct hostentgethostbyname (const char *name)
 
void dns_setserver (u8 numdns, ip_addr_t *dnsserver)
 
const ip_addr_tdns_getserver (u8 numdns)
 

Detailed Description

PS2IP library.

Definition in file ps2ips.h.

Function Documentation

◆ accept()

int accept ( int  s,
struct sockaddr addr,
int *  addrlen 
)

Definition at line 95 of file ps2ipc.c.

96 {
97  int result;
98  cmd_pkt *pkt = &_rpc_buffer.cmd_pkt;
99 
100  if(!_init_check) return -1;
101 
103 
104  pkt->socket = s;
105 
106  if (SifCallRpc(&_ps2ip, PS2IPS_ID_ACCEPT, 0, (void*)pkt, sizeof(s32), (void*)pkt, sizeof(cmd_pkt), NULL, NULL) < 0)
107  {
109  return -1;
110  }
111 
112  if(addr != NULL)
113  {
114  if(pkt->len < *addrlen) *addrlen = pkt->len;
115  memcpy((void *)addr, (void *)&pkt->sockaddr, *addrlen);
116  }
117 
118  result = pkt->socket;
119 
121 
122  return result;
123 }
s32 SignalSema(s32 sema_id)
s32 WaitSema(s32 sema_id)
@ PS2IPS_ID_ACCEPT
Definition: ps2ip_rpc.h:17
static struct @46 _rpc_buffer
static SifRpcClientData_t _ps2ip
Definition: ps2ipc.c:26
static int _init_check
Definition: ps2ipc.c:24
static int lock_sema
Definition: ps2ipc.c:25
s32 s
Definition: ps2ipc.c:30
s32 result
Definition: ps2ipc.c:29
int SifCallRpc(SifRpcClientData_t *client, int rpc_number, int mode, void *send, int ssize, void *receive, int rsize, SifRpcEndFunc_t end_function, void *end_param)
s32 socket
Definition: ps2ip_rpc.h:89
#define NULL
Definition: tamtypes.h:91
signed int s32
Definition: tamtypes.h:58

References _init_check, _ps2ip, _rpc_buffer, cmd_pkt::len, lock_sema, NULL, PS2IPS_ID_ACCEPT, result, s, SifCallRpc(), SignalSema(), cmd_pkt::sockaddr, cmd_pkt::socket, and WaitSema().

◆ bind()

int bind ( int  s,
struct sockaddr name,
int  namelen 
)

Definition at line 125 of file ps2ipc.c.

126 {
127  cmd_pkt *pkt = &_rpc_buffer.cmd_pkt;
128  int result;
129 
130  if(!_init_check) return -1;
131 
133 
134  pkt->socket = s;
135  pkt->len = namelen;
136  memcpy((void *)&pkt->sockaddr, (void *)name, sizeof(struct sockaddr));
137 
138  if (SifCallRpc(&_ps2ip, PS2IPS_ID_BIND, 0, (void*)pkt, sizeof(cmd_pkt), (void*)&_rpc_buffer.result, sizeof(s32), NULL, NULL) < 0)
139  {
141  return -1;
142  }
143 
144  result = _rpc_buffer.result;
145 
147 
148  return result;
149 }
@ PS2IPS_ID_BIND
Definition: ps2ip_rpc.h:18
struct sockaddr sockaddr
Definition: ps2ip_rpc.h:90
s32 len
Definition: ps2ip_rpc.h:91

References _init_check, _ps2ip, _rpc_buffer, cmd_pkt::len, lock_sema, NULL, PS2IPS_ID_BIND, result, s, SifCallRpc(), SignalSema(), cmd_pkt::sockaddr, cmd_pkt::socket, and WaitSema().

◆ connect()

int connect ( int  s,
struct sockaddr name,
int  namelen 
)

Definition at line 174 of file ps2ipc.c.

175 {
176  int result;
177  cmd_pkt *pkt = &_rpc_buffer.cmd_pkt;
178 
179  if(!_init_check) return -1;
180 
182 
183  pkt->socket = s;
184  pkt->len = namelen;
185  memcpy((void *)&pkt->sockaddr, (void *)name, sizeof(struct sockaddr));
186 
187  if (SifCallRpc(&_ps2ip, PS2IPS_ID_CONNECT, 0, (void*)pkt, sizeof(cmd_pkt), (void*)&_rpc_buffer.result, sizeof(s32), NULL, NULL) < 0)
188  {
190  return -1;
191  }
192 
193  result = _rpc_buffer.result;
194 
196 
197  return result;
198 }
@ PS2IPS_ID_CONNECT
Definition: ps2ip_rpc.h:20

References _init_check, _ps2ip, _rpc_buffer, cmd_pkt::len, lock_sema, NULL, PS2IPS_ID_CONNECT, result, s, SifCallRpc(), SignalSema(), cmd_pkt::sockaddr, cmd_pkt::socket, and WaitSema().

◆ disconnect()

int disconnect ( int  s)

Definition at line 151 of file ps2ipc.c.

152 {
153  int result;
154 
155  if(!_init_check) return -1;
156 
158 
159  _rpc_buffer.s = s;
160 
161  if (SifCallRpc(&_ps2ip, PS2IPS_ID_DISCONNECT, 0, (void*)&_rpc_buffer.s, sizeof(s32), (void*)&_rpc_buffer.result, sizeof(s32), NULL, NULL) < 0)
162  {
164  return -1;
165  }
166 
167  result = _rpc_buffer.result;
168 
170 
171  return result;
172 }
@ PS2IPS_ID_DISCONNECT
Definition: ps2ip_rpc.h:19

References _init_check, _ps2ip, _rpc_buffer, lock_sema, NULL, PS2IPS_ID_DISCONNECT, result, s, SifCallRpc(), SignalSema(), and WaitSema().

Referenced by serverThread().

◆ dns_getserver()

const ip_addr_t* dns_getserver ( u8  numdns)

◆ dns_setserver()

void dns_setserver ( u8  numdns,
ip_addr_t dnsserver 
)

Referenced by ethApplyIPConfig(), and main().

◆ gethostbyname()

struct hostent* gethostbyname ( const char *  name)

◆ getpeername()

int getpeername ( int  s,
struct sockaddr name,
int *  namelen 
)

Definition at line 583 of file ps2ipc.c.

584 {
585  int result;
586  cmd_pkt *pkt = &_rpc_buffer.cmd_pkt;
587 
588  if(!_init_check) return -1;
589 
591 
592  pkt->socket = s;
593 
594  if (SifCallRpc(&_ps2ip, PS2IPS_ID_GETPEERNAME, 0, (void*)pkt, sizeof(pkt->socket), (void*)pkt, sizeof(cmd_pkt), NULL, NULL) < 0)
595  {
597  return -1;
598  }
599 
600  if(pkt->len < *namelen) *namelen = pkt->len;
601  memcpy((void *)name, (void *)&pkt->sockaddr, *namelen);
602 
603  result = pkt->socket;
604 
606 
607  return result;
608 }
@ PS2IPS_ID_GETPEERNAME
Definition: ps2ip_rpc.h:32

References _init_check, _ps2ip, _rpc_buffer, cmd_pkt::len, lock_sema, NULL, PS2IPS_ID_GETPEERNAME, result, s, SifCallRpc(), SignalSema(), cmd_pkt::sockaddr, cmd_pkt::socket, and WaitSema().

◆ getsockname()

int getsockname ( int  s,
struct sockaddr name,
int *  namelen 
)

Definition at line 556 of file ps2ipc.c.

557 {
558  int result;
559  cmd_pkt *pkt = &_rpc_buffer.cmd_pkt;
560 
561  if(!_init_check) return -1;
562 
564 
565  pkt->socket = s;
566 
567  if (SifCallRpc(&_ps2ip, PS2IPS_ID_GETSOCKNAME, 0, (void*)pkt, sizeof(pkt->socket), (void*)pkt, sizeof(cmd_pkt), NULL, NULL) < 0)
568  {
570  return -1;
571  }
572 
573  if(pkt->len < *namelen) *namelen = pkt->len;
574  memcpy((void *)name, (void *)&pkt->sockaddr, *namelen);
575 
576  result = pkt->socket;
577 
579 
580  return result;
581 }
@ PS2IPS_ID_GETSOCKNAME
Definition: ps2ip_rpc.h:31

References _init_check, _ps2ip, _rpc_buffer, cmd_pkt::len, lock_sema, NULL, PS2IPS_ID_GETSOCKNAME, result, s, SifCallRpc(), SignalSema(), cmd_pkt::sockaddr, cmd_pkt::socket, and WaitSema().

◆ getsockopt()

int getsockopt ( int  s,
int  level,
int  optname,
void *  optval,
socklen_t optlen 
)

Definition at line 610 of file ps2ipc.c.

611 {
612  getsockopt_pkt *pkt = &_rpc_buffer.getsockopt_pkt;
613  getsockopt_res_pkt *res_pkt = &_rpc_buffer.getsockopt_res_pkt;
614  int result;
615 
616  if(!_init_check) return -1;
617 
619 
620  pkt->s = s;
621  pkt->level = level;
622  pkt->optname = optname;
623 
624  if (SifCallRpc(&_ps2ip, PS2IPS_ID_GETSOCKOPT, 0, (void*)pkt, sizeof(getsockopt_pkt), (void*)res_pkt, sizeof(getsockopt_res_pkt), NULL, NULL) < 0)
625  {
627  return -1;
628  }
629 
630  if(res_pkt->optlen < *optlen) *optlen = res_pkt->optlen;
631  memcpy((void*)optval, res_pkt->buffer, *optlen);
632 
633  result = res_pkt->result;
634 
636 
637  return result;
638 }
@ PS2IPS_ID_GETSOCKOPT
Definition: ps2ip_rpc.h:33

References _init_check, _ps2ip, _rpc_buffer, getsockopt_res_pkt::buffer, getsockopt_pkt::level, lock_sema, NULL, getsockopt_res_pkt::optlen, getsockopt_pkt::optname, PS2IPS_ID_GETSOCKOPT, getsockopt_res_pkt::result, result, getsockopt_pkt::s, s, SifCallRpc(), SignalSema(), and WaitSema().

◆ ioctlsocket()

int ioctlsocket ( int  s,
long  cmd,
void *  argp 
)

Definition at line 525 of file ps2ipc.c.

526 {
527  int result;
528  ioctl_pkt *pkt = &_rpc_buffer.ioctl_pkt;
529 
530  if(!_init_check) return -1;
531 
533 
534  pkt->s = s;
535  pkt->cmd = (s32)cmd;
536  pkt->argp = argp;
537  if( argp )
538  pkt->value = *(s32*)argp;
539 
540  if (SifCallRpc(&_ps2ip, PS2IPS_ID_IOCTL, 0, (void*)pkt, sizeof(ioctl_pkt), (void*)pkt, sizeof(ioctl_pkt), NULL, NULL) < 0)
541  {
543  return -1;
544  }
545 
546  if( argp )
547  *(s32*)argp = pkt->value;
548 
549  result = pkt->result;
550 
552 
553  return result;
554 }
@ PS2IPS_ID_IOCTL
Definition: ps2ip_rpc.h:30
ioctl_pkt ioctl_pkt
Definition: ps2ipc.c:40
void * argp
Definition: ps2ip_rpc.h:145
s32 result
Definition: ps2ip_rpc.h:142
u32 value
Definition: ps2ip_rpc.h:146

References _init_check, _ps2ip, _rpc_buffer, ioctl_pkt::argp, ioctl_pkt::cmd, ioctl_pkt, lock_sema, NULL, PS2IPS_ID_IOCTL, ioctl_pkt::result, result, ioctl_pkt::s, s, SifCallRpc(), SignalSema(), ioctl_pkt::value, and WaitSema().

◆ listen()

int listen ( int  s,
int  backlog 
)

Definition at line 200 of file ps2ipc.c.

201 {
202  int result;
203  listen_pkt *pkt = &_rpc_buffer.listen_pkt;
204 
205  if(!_init_check) return -1;
206 
208 
209  pkt->s = s;
210  pkt->backlog = backlog;
211 
212  if (SifCallRpc(&_ps2ip, PS2IPS_ID_LISTEN, 0, (void*)pkt, sizeof(listen_pkt), (void*)&_rpc_buffer.result, sizeof(s32), NULL, NULL) < 0)
213  {
215  return -1;
216  }
217 
218  result = _rpc_buffer.result;
219 
221 
222  return result;
223 }
@ PS2IPS_ID_LISTEN
Definition: ps2ip_rpc.h:21
s32 backlog
Definition: ps2ip_rpc.h:101

References _init_check, _ps2ip, _rpc_buffer, listen_pkt::backlog, lock_sema, NULL, PS2IPS_ID_LISTEN, result, listen_pkt::s, s, SifCallRpc(), SignalSema(), and WaitSema().

◆ ps2ip_deinit()

void ps2ip_deinit ( void  )

Definition at line 86 of file ps2ipc.c.

87 {
88  if (lock_sema >= 0)
90  lock_sema = -1;
91 
92  _init_check = 0;
93 }
s32 DeleteSema(s32 sema_id)

References _init_check, DeleteSema(), and lock_sema.

◆ ps2ip_getconfig()

int ps2ip_getconfig ( char *  netif_name,
t_ip_info ip_info 
)

Definition at line 41 of file ps2ip.c.

42 {
43  NetIF* pNetIF=netif_find(pszName);
44 
45  if (pNetIF==NULL)
46  {
47  //Net interface not found.
48  memset(pInfo,0,sizeof(*pInfo));
49  return 0;
50  }
51  strcpy(pInfo->netif_name,pszName);
52  pInfo->ipaddr.s_addr=pNetIF->ip_addr.addr;
53  pInfo->netmask.s_addr=pNetIF->netmask.addr;
54  pInfo->gw.s_addr=pNetIF->gw.addr;
55 
56  memcpy(pInfo->hw_addr,pNetIF->hwaddr,sizeof(pInfo->hw_addr));
57 
58 #if LWIP_DHCP
59  struct dhcp *dhcp = netif_dhcp_data(pNetIF);
60 
61  if ((dhcp != NULL) && (dhcp->state != DHCP_STATE_OFF))
62  {
63  pInfo->dhcp_enabled=1;
64  pInfo->dhcp_status=dhcp->state;
65  }
66  else
67  {
68  pInfo->dhcp_enabled=0;
69  pInfo->dhcp_status=DHCP_STATE_OFF;
70  }
71 
72 #else
73  pInfo->dhcp_enabled=0;
74 #endif
75 
76  return 1;
77 }
struct netif * netif_find(const char *name)
#define netif_dhcp_data(netif)
@ DHCP_STATE_OFF
Definition: tcpip.h:1260

References _init_check, _ps2ip, _rpc_buffer, ip_info, lock_sema, netif_name, NULL, PS2IPS_ID_GETCONFIG, SifCallRpc(), SignalSema(), and WaitSema().

Referenced by ethApplyIPConfig(), ethGetDHCPStatus(), and ethPrintIPConfig().

◆ ps2ip_init()

int ps2ip_init ( void  )

Definition at line 60 of file ps2ipc.c.

61 {
62  ee_sema_t sema;
63 
64  while(1)
65  {
66  if(SifBindRpc(&_ps2ip, PS2IP_IRX, 0) < 0)
67  return -1;
68 
69  if(_ps2ip.server != NULL)
70  break;
71 
72  nopdelay();
73  }
74 
75  sema.init_count = 1;
76  sema.max_count = 1;
77  sema.option = (u32)"ps2ipc";
78  sema.attr = 0;
79  lock_sema = CreateSema(&sema);
80 
81  _init_check = 1;
82 
83  return 0;
84 }
s32 CreateSema(ee_sema_t *sema)
static void nopdelay(void)
Definition: kernel.h:141
#define PS2IP_IRX
Definition: ps2ip_rpc.h:14
int SifBindRpc(SifRpcClientData_t *client, int rpc_number, int mode)
struct t_SifRpcServerData * server
Definition: sifrpc.h:142
int init_count
Definition: kernel.h:218
int max_count
Definition: kernel.h:217
u32 option
Definition: kernel.h:221
u32 attr
Definition: kernel.h:220
unsigned int u32
Definition: tamtypes.h:30

References _init_check, _ps2ip, ee_sema_t::attr, CreateSema(), ee_sema_t::init_count, lock_sema, ee_sema_t::max_count, nopdelay(), NULL, ee_sema_t::option, PS2IP_IRX, SifRpcClientData_t::server, and SifBindRpc().

Referenced by main().

◆ ps2ip_setconfig()

int ps2ip_setconfig ( t_ip_info ip_info)

Definition at line 426 of file ps2ipc.c.

427 {
428  int result;
429 
430  if(!_init_check) return -1;
431 
433 
434  // return config
435  memcpy(&_rpc_buffer.ip_info, ip_info, sizeof(t_ip_info));
436 
437  if (SifCallRpc(&_ps2ip, PS2IPS_ID_SETCONFIG, 0, (void*)&_rpc_buffer.ip_info, sizeof(t_ip_info), (void*)&_rpc_buffer.result, sizeof(s32), NULL, NULL) < 0)
438  {
440  return -1;
441  }
442 
443  result = _rpc_buffer.result;
444 
446 
447  return result;
448 }
@ PS2IPS_ID_SETCONFIG
Definition: ps2ip_rpc.h:27
t_ip_info ip_info
Definition: ps2ipc.c:37

References _init_check, _ps2ip, _rpc_buffer, ip_info, lock_sema, NULL, PS2IPS_ID_SETCONFIG, result, SifCallRpc(), SignalSema(), and WaitSema().

◆ recv()

int recv ( int  s,
void *  mem,
int  len,
unsigned int  flags 
)

Definition at line 240 of file ps2ipc.c.

241 {
242  int result;
243  s_recv_pkt *send_pkt = &_rpc_buffer.s_recv_pkt;
244  r_recv_pkt *recv_pkt = &_rpc_buffer.r_recv_pkt;
245 
246  if(!_init_check) return -1;
247 
249 
250  send_pkt->socket = s;
251  send_pkt->length = len;
252  send_pkt->flags = flags;
253  send_pkt->ee_addr = mem;
254  send_pkt->intr_data = _intr_data;
255 
256  if( !IS_UNCACHED_SEG(mem))
257  SifWriteBackDCache(mem, len);
258 
259  if (SifCallRpc(&_ps2ip, PS2IPS_ID_RECV, 0, (void*)send_pkt, sizeof(s_recv_pkt),
260  (void*)recv_pkt, sizeof(r_recv_pkt), recv_intr, _intr_data) < 0)
261  {
263  return -1;
264  }
265 
266  result = recv_pkt->ret;
267 
269 
270  return result;
271 }
#define IS_UNCACHED_SEG(x)
Definition: kernel.h:38
@ PS2IPS_ID_RECV
Definition: ps2ip_rpc.h:22
static void recv_intr(void *data_raw)
Definition: ps2ipc.c:225
static int _intr_data[32]
Definition: ps2ipc.c:52
void SifWriteBackDCache(void *ptr, int size)
void * ee_addr
Definition: ps2ip_rpc.h:68
s32 socket
Definition: ps2ip_rpc.h:65
s32 flags
Definition: ps2ip_rpc.h:67
s32 length
Definition: ps2ip_rpc.h:66

References _init_check, _intr_data, _ps2ip, _rpc_buffer, send_pkt::ee_addr, send_pkt::flags, IS_UNCACHED_SEG, send_pkt::length, lock_sema, PS2IPS_ID_RECV, recv_intr(), result, r_recv_pkt::ret, s, SifCallRpc(), SifWriteBackDCache(), SignalSema(), send_pkt::socket, and WaitSema().

◆ recvfrom()

int recvfrom ( int  s,
void *  mem,
int  len,
unsigned int  flags,
struct sockaddr from,
int *  fromlen 
)

Definition at line 273 of file ps2ipc.c.

275 {
276  int result;
277  s_recv_pkt *send_pkt = &_rpc_buffer.s_recv_pkt;
278  r_recv_pkt *recv_pkt = &_rpc_buffer.r_recv_pkt;
279 
280  if(!_init_check) return -1;
281 
283 
284  send_pkt->socket = s;
285  send_pkt->length = len;
286  send_pkt->flags = flags;
287  send_pkt->ee_addr = mem;
288  send_pkt->intr_data = _intr_data;
289 
290  if( !IS_UNCACHED_SEG(mem))
291  SifWriteBackDCache(mem, len);
292 
293  if (SifCallRpc(&_ps2ip, PS2IPS_ID_RECVFROM, 0, (void*)send_pkt, sizeof(s_recv_pkt),
294  (void*)recv_pkt, sizeof(r_recv_pkt), recv_intr, _intr_data) < 0)
295  {
297  return -1;
298  }
299 
300  memcpy((void *)from, (void *)&recv_pkt->sockaddr, sizeof(struct sockaddr));
301  *fromlen = sizeof(struct sockaddr);
302 
303  result = recv_pkt->ret;
304 
306 
307  return result;
308 }
@ PS2IPS_ID_RECVFROM
Definition: ps2ip_rpc.h:23

References _init_check, _intr_data, _ps2ip, _rpc_buffer, send_pkt::ee_addr, send_pkt::flags, IS_UNCACHED_SEG, send_pkt::length, lock_sema, PS2IPS_ID_RECVFROM, recv_intr(), result, r_recv_pkt::ret, s, SifCallRpc(), SifWriteBackDCache(), SignalSema(), r_recv_pkt::sockaddr, send_pkt::socket, and WaitSema().

◆ select()

int select ( int  maxfdp1,
struct fd_set readset,
struct fd_set writeset,
struct fd_set exceptset,
struct timeval *  timeout 
)

Definition at line 474 of file ps2ipc.c.

475 {
476  int result;
477  select_pkt *pkt = &_rpc_buffer.select_pkt;
478 
479  if(!_init_check) return -1;
480 
482 
483  pkt->maxfdp1 = maxfdp1;
484  pkt->readset_p = readset;
485  pkt->writeset_p = writeset;
486  pkt->exceptset_p = exceptset;
487  pkt->timeout_p = timeout;
488  if( timeout )
489  pkt->timeout = *timeout;
490 
491  if( readset )
492  pkt->readset = *readset;
493 
494  if( writeset )
495  pkt->writeset = *writeset;
496 
497  if( exceptset )
498  pkt->exceptset = *exceptset;
499 
500  if (SifCallRpc(&_ps2ip, PS2IPS_ID_SELECT, 0, (void*)pkt, sizeof(select_pkt), (void*)pkt, sizeof(select_pkt), NULL, NULL) < 0)
501  {
503  return -1;
504  }
505 
506  if( timeout )
507  *timeout = pkt->timeout;
508 
509  if( readset )
510  *readset = pkt->readset;
511 
512  if( writeset )
513  *writeset = pkt->writeset;
514 
515  if( exceptset )
516  *exceptset = pkt->exceptset;
517 
518  result = pkt->result;
519 
521 
522  return result;
523 }
@ PS2IPS_ID_SELECT
Definition: ps2ip_rpc.h:29
struct fd_set * readset_p
Definition: ps2ip_rpc.h:131
struct fd_set exceptset
Definition: ps2ip_rpc.h:136
struct timeval * timeout_p
Definition: ps2ip_rpc.h:129
struct fd_set * writeset_p
Definition: ps2ip_rpc.h:132
struct timeval timeout
Definition: ps2ip_rpc.h:130
struct fd_set readset
Definition: ps2ip_rpc.h:134
struct fd_set writeset
Definition: ps2ip_rpc.h:135
s32 maxfdp1
Definition: ps2ip_rpc.h:126
struct fd_set * exceptset_p
Definition: ps2ip_rpc.h:133

References _init_check, _ps2ip, _rpc_buffer, select_pkt::exceptset, select_pkt::exceptset_p, lock_sema, select_pkt::maxfdp1, NULL, PS2IPS_ID_SELECT, select_pkt::readset, select_pkt::readset_p, select_pkt::result, result, SifCallRpc(), SignalSema(), select_pkt::timeout, select_pkt::timeout_p, WaitSema(), select_pkt::writeset, and select_pkt::writeset_p.

◆ send()

int send ( int  s,
void *  dataptr,
int  size,
unsigned int  flags 
)

Definition at line 310 of file ps2ipc.c.

311 {
312  int result;
313  send_pkt *pkt = &_rpc_buffer.send_pkt;
314  int miss;
315 
317 
318  pkt->socket = s;
319  pkt->length = size;
320  pkt->flags = flags;
321  pkt->ee_addr = dataptr;
322 
323  if((u32)dataptr & 0x3f)
324  {
325  miss = 64 - ((u32)dataptr & 0x3f);
326  if(miss > size) miss = size;
327 
328  } else {
329 
330  miss = 0;
331  }
332 
333  pkt->malign = miss;
334 
335  if( !IS_UNCACHED_SEG(dataptr))
336  SifWriteBackDCache(dataptr, size);
337 
338  memcpy((void *)pkt->malign_buff, UNCACHED_SEG(dataptr), miss);
339 
340  if (SifCallRpc(&_ps2ip, PS2IPS_ID_SEND, 0, (void*)pkt, sizeof(send_pkt),
341  (void*)&_rpc_buffer.result, sizeof(s32), NULL, NULL) < 0)
342  {
344  return -1;
345  }
346 
347  result = _rpc_buffer.result;
348 
350 
351  return result;
352 }
#define UNCACHED_SEG(x)
Definition: kernel.h:35
@ PS2IPS_ID_SEND
Definition: ps2ip_rpc.h:24
s32 malign
Definition: ps2ip_rpc.h:70
u8 malign_buff[64]
Definition: ps2ip_rpc.h:72

References _ps2ip, _rpc_buffer, send_pkt::ee_addr, send_pkt::flags, IS_UNCACHED_SEG, send_pkt::length, lock_sema, send_pkt::malign, send_pkt::malign_buff, NULL, PS2IPS_ID_SEND, result, s, SifCallRpc(), SifWriteBackDCache(), SignalSema(), send_pkt::socket, UNCACHED_SEG, and WaitSema().

◆ sendto()

int sendto ( int  s,
void *  dataptr,
int  size,
unsigned int  flags,
struct sockaddr to,
int  tolen 
)

Definition at line 354 of file ps2ipc.c.

356 {
357  int result;
358  send_pkt *pkt = &_rpc_buffer.send_pkt;
359  int miss;
360 
362 
363  pkt->socket = s;
364  pkt->length = size;
365  pkt->flags = flags;
366  pkt->ee_addr = dataptr;
367  memcpy((void *)&pkt->sockaddr, (void *)to, sizeof(struct sockaddr));
368 
369  if((u32)dataptr & 0x3f)
370  {
371  miss = 64 - ((u32)dataptr & 0x3f);
372  if(miss > size) miss = size;
373 
374  } else {
375 
376  miss = 0;
377  }
378 
379  pkt->malign = miss;
380 
381  if( !IS_UNCACHED_SEG(dataptr))
382  SifWriteBackDCache(dataptr, size);
383 
384  memcpy((void *)pkt->malign_buff, UNCACHED_SEG(dataptr), miss);
385 
386  if (SifCallRpc(&_ps2ip, PS2IPS_ID_SENDTO, 0, (void*)pkt, sizeof(send_pkt),
387  (void*)&_rpc_buffer.result, sizeof(s32), NULL, NULL) < 0)
388  {
390  return -1;
391  }
392 
393  result = _rpc_buffer.result;
394 
396 
397  return result;
398 }
@ PS2IPS_ID_SENDTO
Definition: ps2ip_rpc.h:25
struct sockaddr sockaddr
Definition: ps2ip_rpc.h:69

References _ps2ip, _rpc_buffer, send_pkt::ee_addr, send_pkt::flags, IS_UNCACHED_SEG, send_pkt::length, lock_sema, send_pkt::malign, send_pkt::malign_buff, NULL, PS2IPS_ID_SENDTO, result, s, SifCallRpc(), SifWriteBackDCache(), SignalSema(), send_pkt::sockaddr, send_pkt::socket, UNCACHED_SEG, and WaitSema().

◆ setsockopt()

int setsockopt ( int  s,
int  level,
int  optname,
const void *  optval,
socklen_t  optlen 
)

Definition at line 640 of file ps2ipc.c.

641 {
642  setsockopt_pkt *pkt = &_rpc_buffer.setsockopt_pkt;
643  int result;
644 
645  if(!_init_check) return -1;
646 
648 
649  pkt->s = s;
650  pkt->s = level;
651  pkt->optname = optname;
652  pkt->optlen = optlen;
653 
654  memcpy(pkt->buffer, optval, optlen);
655 
656  if (SifCallRpc(&_ps2ip, PS2IPS_ID_SETSOCKOPT, 0, (void*)pkt, sizeof(setsockopt_pkt), (void*)&_rpc_buffer.result, sizeof(s32), NULL, NULL) < 0)
657  {
659  return -1;
660  }
661 
662  result = _rpc_buffer.result;
663 
665 
666  return result;
667 }
@ PS2IPS_ID_SETSOCKOPT
Definition: ps2ip_rpc.h:34
u8 buffer[128]
Definition: ps2ip_rpc.h:121

References _init_check, _ps2ip, _rpc_buffer, setsockopt_pkt::buffer, lock_sema, NULL, setsockopt_pkt::optlen, setsockopt_pkt::optname, PS2IPS_ID_SETSOCKOPT, result, setsockopt_pkt::s, s, SifCallRpc(), SignalSema(), and WaitSema().

◆ socket()

int socket ( int  domain,
int  type,
int  protocol 
)

Definition at line 400 of file ps2ipc.c.

401 {
402  int result;
403  socket_pkt *pkt = &_rpc_buffer.socket_pkt;
404 
405  if(!_init_check) return -1;
406 
408 
409  pkt->domain = domain;
410  pkt->type = type;
411  pkt->protocol = protocol;
412 
413  if (SifCallRpc(&_ps2ip, PS2IPS_ID_SOCKET, 0, (void*)pkt, sizeof(socket_pkt), (void*)&_rpc_buffer.result, sizeof(s32), NULL, NULL) < 0)
414  {
416  return -1;
417  }
418 
419  result = _rpc_buffer.result;
420 
422 
423  return result;
424 }
@ PS2IPS_ID_SOCKET
Definition: ps2ip_rpc.h:26
s32 domain
Definition: ps2ip_rpc.h:50
s32 type
Definition: ps2ip_rpc.h:51
s32 protocol
Definition: ps2ip_rpc.h:52

References _init_check, _ps2ip, _rpc_buffer, socket_pkt::domain, lock_sema, NULL, socket_pkt::protocol, PS2IPS_ID_SOCKET, result, SifCallRpc(), SignalSema(), socket_pkt::type, and WaitSema().