RetroArch
Classes | Macros | Typedefs | Functions | Variables
network.c File Reference
#include <time.h>
#include <errno.h>
#include <unistd.h>
#include <ogcsys.h>
#include <lwp.h>
#include <video.h>
#include <message.h>
#include <mutex.h>
#include <cond.h>
#include <semaphore.h>
#include <processor.h>
#include <lwp_threads.h>
#include <lwp_watchdog.h>
#include <lwip/debug.h>
#include <lwip/opt.h>
#include <lwip/mem.h>
#include <lwip/memp.h>
#include <lwip/sys.h>
#include <lwip/stats.h>
#include <lwip/ip.h>
#include <lwip/raw.h>
#include <lwip/udp.h>
#include <lwip/tcp.h>
#include <lwip/dhcp.h>
#include <lwip/api.h>
#include <lwip/api_msg.h>
#include <lwip/tcpip.h>
#include <netif/etharp.h>
#include <netif/loopif.h>
#include <netif/gcif/gcif.h>
#include <sys/iosupport.h>
#include "network.h"
Include dependency graph for network.c:

Classes

struct  netsocket
 
struct  netselect_cb
 

Macros

#define ARP_TIMER_ID   0x00070041
 
#define TCP_TIMER_ID   0x00070042
 
#define DHCPCOARSE_TIMER_ID   0x00070043
 
#define DHCPFINE_TIMER_ID   0x00070044
 
#define STACKSIZE   32768
 
#define MQBOX_SIZE   256
 
#define NUM_SOCKETS   MEMP_NUM_NETCONN
 

Typedefs

typedef void(* apimsg_decode) (struct apimsg_msg *)
 

Functions

static struct netbufnetbuf_new ()
 
static void netbuf_delete (struct netbuf *)
 
static void netbuf_copypartial (struct netbuf *, void *, u32, u32)
 
static void netbuf_ref (struct netbuf *, const void *, u32)
 
static struct netconnnetconn_new_with_callback (enum netconn_type, void(*)(struct netconn *, enum netconn_evt, u32))
 
static struct netconnnetconn_new_with_proto_and_callback (enum netconn_type, u16, void(*)(struct netconn *, enum netconn_evt, u32))
 
static err_t netconn_delete (struct netconn *)
 
static struct netconnnetconn_accept (struct netconn *)
 
static err_t netconn_peer (struct netconn *, struct ip_addr *, u16 *)
 
static err_t netconn_bind (struct netconn *, struct ip_addr *, u16)
 
static err_t netconn_listen (struct netconn *)
 
static struct netbufnetconn_recv (struct netconn *)
 
static err_t netconn_send (struct netconn *, struct netbuf *)
 
static err_t netconn_write (struct netconn *, const void *, u32, u8)
 
static err_t netconn_connect (struct netconn *, struct ip_addr *, u16)
 
static err_t netconn_disconnect (struct netconn *)
 
static void do_newconn (struct apimsg_msg *)
 
static void do_delconn (struct apimsg_msg *)
 
static void do_bind (struct apimsg_msg *)
 
static void do_listen (struct apimsg_msg *)
 
static void do_connect (struct apimsg_msg *)
 
static void do_disconnect (struct apimsg_msg *)
 
static void do_accept (struct apimsg_msg *)
 
static void do_send (struct apimsg_msg *)
 
static void do_recv (struct apimsg_msg *)
 
static void do_write (struct apimsg_msg *)
 
static void do_close (struct apimsg_msg *)
 
static void apimsg_post (struct api_msg *)
 
static err_t net_input (struct pbuf *, struct netif *)
 
static void net_apimsg (struct api_msg *)
 
static err_t net_callback (void(*)(void *), void *)
 
static voidnet_thread (void *)
 
static void tmr_callback (void *arg)
 
static void __dhcpcoarse_timer (void *arg)
 
static void __dhcpfine_timer (void *arg)
 
static void __tcp_timer (void *arg)
 
static void __arp_timer (void *arg)
 
void tcp_timer_needed (void)
 
static __inline__ u16 netbuf_len (struct netbuf *buf)
 
static __inline__ struct ip_addrnetbuf_fromaddr (struct netbuf *buf)
 
static __inline__ u16 netbuf_fromport (struct netbuf *buf)
 
static enum netconn_type netconn_type (struct netconn *conn)
 
static u8_t recv_raw (void *arg, struct raw_pcb *pcb, struct pbuf *p, struct ip_addr *addr)
 
static void recv_udp (void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16 port)
 
static err_t recv_tcp (void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
 
static void err_tcp (void *arg, err_t err)
 
static err_t poll_tcp (void *arg, struct tcp_pcb *pcb)
 
static err_t sent_tcp (void *arg, struct tcp_pcb *pcb, u16 len)
 
static void setuptcp (struct netconn *conn)
 
static err_t accept_func (void *arg, struct tcp_pcb *newpcb, err_t err)
 
static err_t do_connected (void *arg, struct tcp_pcb *pcb, err_t err)
 
static void apimsg_input (struct api_msg *msg)
 
static s32 alloc_socket (struct netconn *conn)
 
static struct netsocketget_socket (s32 s)
 
static void evt_callback (struct netconn *conn, enum netconn_evt evt, u32 len)
 
s32 if_configex (struct in_addr *local_ip, struct in_addr *netmask, struct in_addr *gateway, bool use_dhcp, int max_retries)
 
s32 if_config (char *local_ip, char *netmask, char *gateway, bool use_dhcp, int max_retries)
 
s32 net_init ()
 
s32 net_shutdown (s32 s, u32 how)
 
s32 net_fcntl (s32 s, u32 cmd, u32 flags)
 
s32 net_socket (u32 domain, u32 type, u32 protocol)
 
s32 net_accept (s32 s, struct sockaddr *addr, socklen_t *addrlen)
 
s32 net_bind (s32 s, struct sockaddr *name, socklen_t namelen)
 
s32 net_listen (s32 s, u32 backlog)
 
s32 net_recvfrom (s32 s, void *mem, s32 len, u32 flags, struct sockaddr *from, socklen_t *fromlen)
 
s32 net_read (s32 s, void *mem, s32 len)
 
s32 net_recv (s32 s, void *mem, s32 len, u32 flags)
 
s32 net_sendto (s32 s, const void *data, s32 len, u32 flags, struct sockaddr *to, socklen_t tolen)
 
s32 net_send (s32 s, const void *data, s32 len, u32 flags)
 
s32 net_write (s32 s, const void *data, s32 size)
 
s32 net_connect (s32 s, struct sockaddr *name, socklen_t namelen)
 
s32 net_close (s32 s)
 
static s32 net_selscan (s32 maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset)
 
s32 net_select (s32 maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, struct timeval *timeout)
 
s32 net_setsockopt (s32 s, u32 level, u32 optname, const void *optval, socklen_t optlen)
 
s32 net_ioctl (s32 s, u32 cmd, void *argp)
 

Variables

static u32 g_netinitiated = 0
 
static u32 tcpiplayer_inited = 0
 
static u64 net_tcp_ticks = 0
 
static u64 net_dhcpcoarse_ticks = 0
 
static u64 net_dhcpfine_ticks = 0
 
static u64 net_arp_ticks = 0
 
static wd_cntrl arp_time_cntrl
 
static wd_cntrl tcp_timer_cntrl
 
static wd_cntrl dhcp_coarsetimer_cntrl
 
static wd_cntrl dhcp_finetimer_cntrl
 
static struct netif g_hNetIF
 
static struct netif g_hLoopIF
 
static struct netsocket sockets [NUM_SOCKETS]
 
static struct netselect_cbselectcb_list = NULL
 
static sys_sem netsocket_sem
 
static sys_sem sockselect_sem
 
static sys_mbox netthread_mbox
 
static sys_thread hnet_thread
 
static u8 netthread_stack [STACKSIZE]
 
static u32 tcp_timer_active = 0
 
static apimsg_decode decode [APIMSG_MAX]
 
const devoptab_t dotab_stdnet
 

Macro Definition Documentation

◆ ARP_TIMER_ID

#define ARP_TIMER_ID   0x00070041

◆ DHCPCOARSE_TIMER_ID

#define DHCPCOARSE_TIMER_ID   0x00070043

◆ DHCPFINE_TIMER_ID

#define DHCPFINE_TIMER_ID   0x00070044

◆ MQBOX_SIZE

#define MQBOX_SIZE   256

◆ NUM_SOCKETS

#define NUM_SOCKETS   MEMP_NUM_NETCONN

◆ STACKSIZE

#define STACKSIZE   32768

◆ TCP_TIMER_ID

#define TCP_TIMER_ID   0x00070042

Typedef Documentation

◆ apimsg_decode

typedef void(* apimsg_decode) (struct apimsg_msg *)

Function Documentation

◆ __arp_timer()

static void __arp_timer ( void arg)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __dhcpcoarse_timer()

static void __dhcpcoarse_timer ( void arg)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __dhcpfine_timer()

static void __dhcpfine_timer ( void arg)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __tcp_timer()

static void __tcp_timer ( void arg)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ accept_func()

static err_t accept_func ( void arg,
struct tcp_pcb newpcb,
err_t  err 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ alloc_socket()

static s32 alloc_socket ( struct netconn conn)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ apimsg_input()

static void apimsg_input ( struct api_msg msg)
static
Here is the caller graph for this function:

◆ apimsg_post()

static void apimsg_post ( struct api_msg msg)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_accept()

static void do_accept ( struct apimsg_msg msg)
static

◆ do_bind()

static void do_bind ( struct apimsg_msg msg)
static
Here is the call graph for this function:

◆ do_close()

static void do_close ( struct apimsg_msg msg)
static
Here is the call graph for this function:

◆ do_connect()

static void do_connect ( struct apimsg_msg msg)
static
Here is the call graph for this function:

◆ do_connected()

static err_t do_connected ( void arg,
struct tcp_pcb pcb,
err_t  err 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_delconn()

static void do_delconn ( struct apimsg_msg msg)
static
Here is the call graph for this function:

◆ do_disconnect()

static void do_disconnect ( struct apimsg_msg msg)
static
Here is the call graph for this function:

◆ do_listen()

static void do_listen ( struct apimsg_msg msg)
static
Here is the call graph for this function:

◆ do_newconn()

static void do_newconn ( struct apimsg_msg msg)
static
Here is the call graph for this function:

◆ do_recv()

static void do_recv ( struct apimsg_msg msg)
static
Here is the call graph for this function:

◆ do_send()

static void do_send ( struct apimsg_msg msg)
static
Here is the call graph for this function:

◆ do_write()

static void do_write ( struct apimsg_msg msg)
static
Here is the call graph for this function:

◆ err_tcp()

static void err_tcp ( void arg,
err_t  err 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ evt_callback()

static void evt_callback ( struct netconn conn,
enum netconn_evt  evt,
u32  len 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_socket()

static struct netsocket* get_socket ( s32  s)
static
Here is the caller graph for this function:

◆ if_config()

s32 if_config ( char *  local_ip,
char *  netmask,
char *  gateway,
bool  use_dhcp,
int  max_retries 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ if_configex()

s32 if_configex ( struct in_addr local_ip,
struct in_addr netmask,
struct in_addr gateway,
bool  use_dhcp,
int  max_retries 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ net_accept()

s32 net_accept ( s32  s,
struct sockaddr addr,
socklen_t addrlen 
)
Here is the call graph for this function:

◆ net_apimsg()

static void net_apimsg ( struct api_msg apimsg)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ net_bind()

s32 net_bind ( s32  s,
struct sockaddr name,
socklen_t  namelen 
)
Here is the call graph for this function:

◆ net_callback()

static err_t net_callback ( void(*)(void *)  f,
void ctx 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ net_close()

s32 net_close ( s32  s)
Here is the call graph for this function:

◆ net_connect()

s32 net_connect ( s32  s,
struct sockaddr name,
socklen_t  namelen 
)
Here is the call graph for this function:

◆ net_fcntl()

s32 net_fcntl ( s32  s,
u32  cmd,
u32  flags 
)

◆ net_init()

s32 net_init ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ net_input()

static err_t net_input ( struct pbuf p,
struct netif inp 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ net_ioctl()

s32 net_ioctl ( s32  s,
u32  cmd,
void argp 
)
Here is the call graph for this function:

◆ net_listen()

s32 net_listen ( s32  s,
u32  backlog 
)
Here is the call graph for this function:

◆ net_read()

s32 net_read ( s32  s,
void mem,
s32  len 
)
Here is the call graph for this function:

◆ net_recv()

s32 net_recv ( s32  s,
void mem,
s32  len,
u32  flags 
)
Here is the call graph for this function:

◆ net_recvfrom()

s32 net_recvfrom ( s32  s,
void mem,
s32  len,
u32  flags,
struct sockaddr from,
socklen_t fromlen 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ net_select()

s32 net_select ( s32  maxfdp1,
fd_set readset,
fd_set writeset,
fd_set exceptset,
struct timeval timeout 
)
Here is the call graph for this function:

◆ net_selscan()

static s32 net_selscan ( s32  maxfdp1,
fd_set readset,
fd_set writeset,
fd_set exceptset 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ net_send()

s32 net_send ( s32  s,
const void data,
s32  len,
u32  flags 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ net_sendto()

s32 net_sendto ( s32  s,
const void data,
s32  len,
u32  flags,
struct sockaddr to,
socklen_t  tolen 
)
Here is the call graph for this function:

◆ net_setsockopt()

s32 net_setsockopt ( s32  s,
u32  level,
u32  optname,
const void optval,
socklen_t  optlen 
)
Here is the call graph for this function:

◆ net_shutdown()

s32 net_shutdown ( s32  s,
u32  how 
)

◆ net_socket()

s32 net_socket ( u32  domain,
u32  type,
u32  protocol 
)
Here is the call graph for this function:

◆ net_thread()

static void * net_thread ( void arg)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ net_write()

s32 net_write ( s32  s,
const void data,
s32  size 
)
Here is the call graph for this function:

◆ netbuf_copypartial()

static void netbuf_copypartial ( struct netbuf buf,
void dataptr,
u32  len,
u32  offset 
)
static
Here is the caller graph for this function:

◆ netbuf_delete()

static void netbuf_delete ( struct netbuf buf)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ netbuf_fromaddr()

static __inline__ struct ip_addr* netbuf_fromaddr ( struct netbuf buf)
static
Here is the caller graph for this function:

◆ netbuf_fromport()

static __inline__ u16 netbuf_fromport ( struct netbuf buf)
static
Here is the caller graph for this function:

◆ netbuf_len()

static __inline__ u16 netbuf_len ( struct netbuf buf)
static
Here is the caller graph for this function:

◆ netbuf_new()

static struct netbuf * netbuf_new ( )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ netbuf_ref()

static void netbuf_ref ( struct netbuf buf,
const void dataptr,
u32  size 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ netconn_accept()

static struct netconn * netconn_accept ( struct netconn conn)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ netconn_bind()

static err_t netconn_bind ( struct netconn conn,
struct ip_addr addr,
u16  port 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ netconn_connect()

static err_t netconn_connect ( struct netconn conn,
struct ip_addr addr,
u16  port 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ netconn_delete()

static err_t netconn_delete ( struct netconn conn)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ netconn_disconnect()

static err_t netconn_disconnect ( struct netconn conn)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ netconn_listen()

static err_t netconn_listen ( struct netconn conn)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ netconn_new_with_callback()

static struct netconn * netconn_new_with_callback ( enum netconn_type  t,
void(*)(struct netconn *, enum netconn_evt, u32 cb 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ netconn_new_with_proto_and_callback()

static struct netconn * netconn_new_with_proto_and_callback ( enum netconn_type  t,
u16  proto,
void(*)(struct netconn *, enum netconn_evt, u32 cb 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ netconn_peer()

static err_t netconn_peer ( struct netconn conn,
struct ip_addr addr,
u16 port 
)
static
Here is the caller graph for this function:

◆ netconn_recv()

static struct netbuf * netconn_recv ( struct netconn conn)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ netconn_send()

static err_t netconn_send ( struct netconn conn,
struct netbuf buf 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ netconn_type()

static enum netconn_type netconn_type ( struct netconn conn)
inlinestatic
Here is the caller graph for this function:

◆ netconn_write()

static err_t netconn_write ( struct netconn conn,
const void dataptr,
u32  size,
u8  copy 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ poll_tcp()

static err_t poll_tcp ( void arg,
struct tcp_pcb pcb 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ recv_raw()

static u8_t recv_raw ( void arg,
struct raw_pcb pcb,
struct pbuf p,
struct ip_addr addr 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ recv_tcp()

static err_t recv_tcp ( void arg,
struct tcp_pcb pcb,
struct pbuf p,
err_t  err 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ recv_udp()

static void recv_udp ( void arg,
struct udp_pcb pcb,
struct pbuf p,
struct ip_addr addr,
u16  port 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sent_tcp()

static err_t sent_tcp ( void arg,
struct tcp_pcb pcb,
u16  len 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setuptcp()

static void setuptcp ( struct netconn conn)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tcp_timer_needed()

void tcp_timer_needed ( void  )
Here is the call graph for this function:

◆ tmr_callback()

static void tmr_callback ( void arg)
static
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ arp_time_cntrl

wd_cntrl arp_time_cntrl
static

◆ decode

apimsg_decode decode[APIMSG_MAX]
static
Initial value:
= {
}
static void do_close(struct apimsg_msg *)
Definition: network.c:1212
static void do_write(struct apimsg_msg *)
Definition: network.c:1177
static void do_recv(struct apimsg_msg *)
Definition: network.c:1167
static void do_accept(struct apimsg_msg *)
Definition: network.c:1128
static void do_newconn(struct apimsg_msg *)
Definition: network.c:842
static void do_bind(struct apimsg_msg *)
Definition: network.c:939
static void do_disconnect(struct apimsg_msg *)
Definition: network.c:1074
static void do_connect(struct apimsg_msg *)
Definition: network.c:1003
static void do_send(struct apimsg_msg *)
Definition: network.c:1146
static void do_delconn(struct apimsg_msg *)
Definition: network.c:897
static void do_listen(struct apimsg_msg *)
Definition: network.c:1092

◆ dhcp_coarsetimer_cntrl

wd_cntrl dhcp_coarsetimer_cntrl
static

◆ dhcp_finetimer_cntrl

wd_cntrl dhcp_finetimer_cntrl
static

◆ dotab_stdnet

const devoptab_t dotab_stdnet

◆ g_hLoopIF

struct netif g_hLoopIF
static

◆ g_hNetIF

struct netif g_hNetIF
static

◆ g_netinitiated

u32 g_netinitiated = 0
static

◆ hnet_thread

sys_thread hnet_thread
static

◆ net_arp_ticks

u64 net_arp_ticks = 0
static

◆ net_dhcpcoarse_ticks

u64 net_dhcpcoarse_ticks = 0
static

◆ net_dhcpfine_ticks

u64 net_dhcpfine_ticks = 0
static

◆ net_tcp_ticks

u64 net_tcp_ticks = 0
static

◆ netsocket_sem

sys_sem netsocket_sem
static

◆ netthread_mbox

sys_mbox netthread_mbox
static

◆ netthread_stack

u8 netthread_stack[STACKSIZE]
static

◆ selectcb_list

struct netselect_cb* selectcb_list = NULL
static

◆ sockets

struct netsocket sockets[NUM_SOCKETS]
static

◆ sockselect_sem

sys_sem sockselect_sem
static

◆ tcp_timer_active

u32 tcp_timer_active = 0
static

◆ tcp_timer_cntrl

wd_cntrl tcp_timer_cntrl
static

◆ tcpiplayer_inited

u32 tcpiplayer_inited = 0
static