PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
ps2ip.h
Go to the documentation of this file.
1/*
2# _____ ___ ____ ___ ____
3# ____| | ____| | | |____|
4# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5#-----------------------------------------------------------------------
6# Copyright (c) 2003 Marcus R. Brown <mrbrown@0xd6.org>
7# Licenced under Academic Free License version 2.0
8# Review ps2sdk README & LICENSE files for further details.
9*/
10
16#ifndef __PS2IP_H__
17#define __PS2IP_H__
18
19#include <types.h>
20#include <irx.h>
21
22#include <tcpip.h>
23
24#include <sys/time.h>
25
26/* From include/lwip/sockets.h: */
27
28extern int lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
29extern int lwip_bind(int s, struct sockaddr *name, socklen_t namelen);
30extern int lwip_close(int s);
31extern int lwip_connect(int s, struct sockaddr *name, socklen_t namelen);
32extern int lwip_listen(int s, int backlog);
33extern int lwip_recv(int s, void *mem, int len, unsigned int flags);
34extern int lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
35 struct sockaddr *from, socklen_t *fromlen);
36extern int lwip_send(int s, void *dataptr, int size, unsigned int flags);
37extern int lwip_sendto(int s, void *dataptr, int size, unsigned int flags,
38 struct sockaddr *to, socklen_t tolen);
39extern int lwip_socket(int domain, int type, int protocol);
40extern int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
41 struct timeval *timeout);
42extern int lwip_ioctl(int s, long cmd, void *argp);
43extern int lwip_getpeername (int s, struct sockaddr *name, socklen_t *namelen);
44extern int lwip_getsockname (int s, struct sockaddr *name, socklen_t *namelen);
45extern int lwip_getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen);
46extern int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen);
47
48extern int ps2ip_setconfig(const t_ip_info* ip_info);
49extern int ps2ip_getconfig(char* netif_name,t_ip_info* ip_info);
50extern void ps2ip_input(struct pbuf *p, struct netif *inp);
51
52extern int lwip_shutdown(int s, int how);
53extern int lwip_fcntl(int s, int cmd, int val);
54
55/* From include/netif/etharp.h: */
56extern err_t etharp_output(struct netif *netif, struct pbuf *q, const ip_addr_t *ipaddr);
57
58/* From include/lwip/tcpip.h: */
59extern err_t tcpip_input(struct pbuf *p, struct netif *inp);
60
62typedef void (*tcpip_callback_fn)(void *ctx);
63
64extern err_t tcpip_callback_with_block(tcpip_callback_fn function, void *ctx, u8 block);
65
70#define tcpip_callback(f, ctx) tcpip_callback_with_block(f, ctx, 1)
71
72/* From include/lwip/netif.h: */
73extern struct netif *netif_add(struct netif *netif,
74#if LWIP_IPV4
75 const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, const ip4_addr_t *gw,
76#endif /* LWIP_IPV4 */
78
79/* Returns a network interface given its name. The name is of the form
80 "et0", where the first two letters are the "name" field in the
81 netif structure, and the digit is in the num field in the same
82 structure. */
83extern struct netif* netif_find(const char *name);
84extern void netif_set_default(struct netif *netif);
85extern void netif_set_ipaddr(struct netif *netif, const ip4_addr_t *ipaddr);
86extern void netif_set_netmask(struct netif *netif, const ip4_addr_t *netmask);
87extern void netif_set_gw(struct netif *netif, const ip4_addr_t *gw);
88extern void netif_set_up(struct netif *netif);
89extern void netif_set_down(struct netif *netif);
90
91extern void netif_set_link_up(struct netif *netif);
92extern void netif_set_link_down(struct netif *netif);
93
94/* From include/lwip/pbuf.h: */
95extern struct pbuf* pbuf_alloc(pbuf_layer l, u16 size, pbuf_type type);
96extern void pbuf_realloc(struct pbuf *p, u16 size);
97extern u8 pbuf_header(struct pbuf *p, s16 header_size);
98extern void pbuf_ref(struct pbuf *p);
99extern u8 pbuf_free(struct pbuf *p);
100extern u8 pbuf_clen(struct pbuf *p);
101extern void pbuf_chain(struct pbuf *h, struct pbuf *t);
102extern struct pbuf* pbuf_dechain(struct pbuf *p);
103extern struct pbuf* pbuf_take(struct pbuf *f);
104extern struct pbuf* pbuf_coalesce(struct pbuf *p, pbuf_layer layer);
105
106/* From include/lwip/inet.h: */
107/* directly map this to the lwip internal functions */
108#define inet_addr(cp) ipaddr_addr(cp)
109#define inet_aton(cp, addr) ip4addr_aton(cp, (ip4_addr_t*)addr)
110#define inet_ntoa(addr) ip4addr_ntoa((const ip4_addr_t*)&(addr))
111#define inet_ntoa_r(addr, buf, buflen) ip4addr_ntoa_r((const ip4_addr_t*)&(addr), buf, buflen)
112
113extern u32 ipaddr_addr(const char *cp);
114extern int ip4addr_aton(const char *cp, ip4_addr_t *addr);
116extern char *ip4addr_ntoa(const ip4_addr_t *addr);
117extern char *ip4addr_ntoa_r(const ip4_addr_t *addr, char *buf, int buflen);
118
119#ifdef PS2IP_DNS
120/* From include/lwip/netdb.h: */
121extern struct hostent *lwip_gethostbyname(const char *name);
122extern int lwip_gethostbyname_r(const char *name, struct hostent *ret, char *buf,
123 size_t buflen, struct hostent **result, int *h_errnop);
124extern void lwip_freeaddrinfo(struct addrinfo *ai);
125extern int lwip_getaddrinfo(const char *nodename,
126 const char *servname,
127 const struct addrinfo *hints,
128 struct addrinfo **res);
129
130/* From include/lwip/dns.h: */
131extern void dns_setserver(u8 numdns, const ip_addr_t *dnsserver);
132extern const ip_addr_t* dns_getserver(u8 numdns);
133#endif
134
135/* Compatibility macros. */
136
137#define accept lwip_accept
138#define bind lwip_bind
139#define disconnect lwip_close
140#define closesocket lwip_close
141#define shutdown lwip_shutdown
142#define connect lwip_connect
143#define listen lwip_listen
144#define recv lwip_recv
145#define recvfrom lwip_recvfrom
146#define send lwip_send
147#define sendto lwip_sendto
148#define socket lwip_socket
149#define select lwip_select
150#define ioctlsocket lwip_ioctl
151#define fcntlsocket lwip_fcntl
152#define gethostbyname lwip_gethostbyname
153#define gethostbyname_r lwip_gethostbyname_r
154#define freeaddrinfo lwip_freeaddrinfo
155#define getaddrinfo lwip_getaddrinfo
156
157// ntba2
158#define getsockname lwip_getsockname
159#define getpeername lwip_getpeername
160#define getsockopt lwip_getsockopt
161#define setsockopt lwip_setsockopt
162
163#define ipaddr4_aton(...) ip4addr_aton(__VA_ARGS__)
164
165#define ps2ip_IMPORTS_start DECLARE_IMPORT_TABLE(ps2ip, 2, 6)
166#define ps2ip_IMPORTS_end END_IMPORT_TABLE
167
168#define I_lwip_accept DECLARE_IMPORT(4, lwip_accept)
169#define I_lwip_bind DECLARE_IMPORT(5, lwip_bind)
170#define I_lwip_close DECLARE_IMPORT(6, lwip_close)
171#define I_lwip_connect DECLARE_IMPORT(7, lwip_connect)
172#define I_lwip_listen DECLARE_IMPORT(8, lwip_listen)
173#define I_lwip_recv DECLARE_IMPORT(9, lwip_recv)
174#define I_lwip_recvfrom DECLARE_IMPORT(10, lwip_recvfrom)
175#define I_lwip_send DECLARE_IMPORT(11, lwip_send)
176#define I_lwip_sendto DECLARE_IMPORT(12, lwip_sendto)
177#define I_lwip_socket DECLARE_IMPORT(13, lwip_socket)
178#define I_lwip_select DECLARE_IMPORT(14, lwip_select)
179#define I_lwip_ioctl DECLARE_IMPORT(15, lwip_ioctl)
180#define I_lwip_getpeername DECLARE_IMPORT(16, lwip_getpeername)
181#define I_lwip_getsockname DECLARE_IMPORT(17, lwip_getsockname)
182#define I_lwip_getsockopt DECLARE_IMPORT(18, lwip_getsockopt)
183#define I_lwip_setsockopt DECLARE_IMPORT(19, lwip_setsockopt)
184#define I_ps2ip_setconfig DECLARE_IMPORT(20, ps2ip_setconfig)
185#define I_ps2ip_getconfig DECLARE_IMPORT(21, ps2ip_getconfig)
186#define I_ps2ip_input DECLARE_IMPORT(22, ps2ip_input)
187#define I_lwip_shutdown DECLARE_IMPORT(46, lwip_shutdown)
188#define I_lwip_fcntl DECLARE_IMPORT(47, lwip_fcntl)
189#define I_etharp_output DECLARE_IMPORT(23, etharp_output)
190#define I_tcpip_input DECLARE_IMPORT(25, tcpip_input)
191#define I_tcpip_callback_with_block DECLARE_IMPORT(56, tcpip_callback_with_block)
192#define I_netif_add DECLARE_IMPORT(26, netif_add)
193#define I_netif_find DECLARE_IMPORT(27, netif_find)
194#define I_netif_set_default DECLARE_IMPORT(28, netif_set_default)
195#define I_netif_set_ipaddr DECLARE_IMPORT(29, netif_set_ipaddr)
196#define I_netif_set_netmask DECLARE_IMPORT(30, netif_set_netmask)
197#define I_netif_set_gw DECLARE_IMPORT(31, netif_set_gw)
198#define I_netif_set_up DECLARE_IMPORT(32, netif_set_up)
199#define I_netif_set_down DECLARE_IMPORT(33, netif_set_down)
200#define I_netif_set_link_up DECLARE_IMPORT(54, netif_set_link_up)
201#define I_netif_set_link_down DECLARE_IMPORT(55, netif_set_link_down)
202#define I_pbuf_alloc DECLARE_IMPORT(34, pbuf_alloc)
203#define I_pbuf_realloc DECLARE_IMPORT(35, pbuf_realloc)
204#define I_pbuf_header DECLARE_IMPORT(36, pbuf_header)
205#define I_pbuf_ref DECLARE_IMPORT(37, pbuf_ref)
206#define I_pbuf_free DECLARE_IMPORT(38, pbuf_free)
207#define I_pbuf_clen DECLARE_IMPORT(39, pbuf_clen)
208#define I_pbuf_chain DECLARE_IMPORT(40, pbuf_chain)
209#define I_pbuf_dechain DECLARE_IMPORT(41, pbuf_dechain)
210#define I_pbuf_take DECLARE_IMPORT(42, pbuf_take)
211#define I_pbuf_coalesce DECLARE_IMPORT(57, pbuf_coalesce)
212#define I_ipaddr_addr DECLARE_IMPORT(24, ipaddr_addr)
213#define I_ip4addr_aton DECLARE_IMPORT(43, ip4addr_aton)
214#define I_ip4addr_ntoa DECLARE_IMPORT(44, ip4addr_ntoa)
215#define I_ip4addr_ntoa_r DECLARE_IMPORT(45, ip4addr_ntoa_r)
216#define I_lwip_gethostbyname DECLARE_IMPORT(48, lwip_gethostbyname)
217#define I_lwip_gethostbyname_r DECLARE_IMPORT(49, lwip_gethostbyname_r)
218#define I_lwip_freeaddrinfo DECLARE_IMPORT(50, lwip_freeaddrinfo)
219#define I_lwip_getaddrinfo DECLARE_IMPORT(51, lwip_getaddrinfo)
220#define I_dns_setserver DECLARE_IMPORT(52, dns_setserver)
221#define I_dns_getserver DECLARE_IMPORT(53, dns_getserver)
222
223#define I_inet_addr I_ipaddr_addr
224#define I_ipaddr4_aton I_ip4addr_aton
225#define I_inet_aton I_ip4addr_aton
226#define I_inet_ntoa I_ip4addr_ntoa
227#define I_inet_ntoa_r I_ip4addr_ntoa_r
228
229#endif /* __PS2IP_H__ */
struct netif * netif_find(const char *name)
void(* tcpip_callback_fn)(void *ctx)
Definition ps2ip.h:62
char * ip4addr_ntoa(const ip4_addr_t *addr)
err_t(* netif_init_fn)(struct netif *netif)
Definition tcpip.h:1162
char name[2]
Definition tcpip.h:1315
void * state
Definition tcpip.h:1287
netif_input_fn input
Definition tcpip.h:1252
err_t(* netif_input_fn)(struct pbuf *p, struct netif *inp)
Definition tcpip.h:1169
pbuf_type
Definition tcpip.h:173
u8 type
Definition tcpip.h:220
pbuf_layer
Definition tcpip.h:144
Definition tcpip.h:200
Definition time.h:29