Skip to content

Commit e289416

Browse files
authored
Merge pull request #795 from uyjulian/netcnf
Add implementation of netcnf and netcnfif modules
2 parents 52a519d + 679d15e commit e289416

File tree

14 files changed

+6799
-0
lines changed

14 files changed

+6799
-0
lines changed

iop/network/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
# Review ps2sdk README & LICENSE files for further details.
88

99
SUBDIRS = \
10+
netcnf \
11+
netcnfif \
1012
netman \
1113
smap \
1214
smap-modular-netman \

iop/network/netcnf/Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# _____ ___ ____ ___ ____
2+
# ____| | ____| | | |____|
3+
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
4+
#-----------------------------------------------------------------------
5+
# Copyright ps2dev - http://www.ps2dev.org
6+
# Licenced under Academic Free License version 2.0
7+
# Review ps2sdk README & LICENSE files for further details.
8+
9+
IOP_BIN ?= netcnf.irx
10+
11+
IOP_IMPORT_INCS += \
12+
system/heaplib \
13+
system/loadcore \
14+
system/threadman \
15+
system/sysclib \
16+
system/iomanx \
17+
system/stdio \
18+
cdvd/cdvdman
19+
20+
IOP_OBJS = netcnf.o exports.o imports.o
21+
22+
include $(PS2SDKSRC)/Defs.make
23+
include $(PS2SDKSRC)/iop/Rules.bin.make
24+
include $(PS2SDKSRC)/iop/Rules.make
25+
include $(PS2SDKSRC)/iop/Rules.release

iop/network/netcnf/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Network configuration library
2+
3+
This module provides functions to access the "Your Network Configuration File"
4+
(YNCF) stored on the memory card, the hard drive, or other device.
5+
6+
## Configurations
7+
8+
There are multiple configurations of this library, allowing the choice of
9+
balancing between size, speed, and features.
10+
11+
* `netcnf` -> The recommended version.
12+
13+
## How to use this module in your program
14+
15+
In order to use this module in your program, use `LoadModule` or \
16+
`LoadModuleBuffer` with no arguments.
Lines changed: 280 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,280 @@
1+
/*
2+
# _____ ___ ____ ___ ____
3+
# ____| | ____| | | |____|
4+
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5+
#-----------------------------------------------------------------------
6+
# Copyright ps2dev - http://www.ps2dev.org
7+
# Licenced under Academic Free License version 2.0
8+
# Review ps2sdk README & LICENSE files for further details.
9+
*/
10+
11+
#ifndef _NETCNF_H
12+
#define _NETCNF_H
13+
14+
typedef struct sceNetCnfList
15+
{
16+
int type;
17+
int stat;
18+
char sys_name[256];
19+
char usr_name[256];
20+
} sceNetCnfList_t;
21+
22+
typedef struct sceNetCnfAddress
23+
{
24+
int reserved;
25+
char data[16];
26+
} sceNetCnfAddress_t;
27+
28+
typedef struct sceNetCnfCommand
29+
{
30+
struct sceNetCnfCommand *forw;
31+
struct sceNetCnfCommand *back;
32+
int code;
33+
} sceNetCnfCommand_t;
34+
35+
typedef struct sceNetCnfUnknown
36+
{
37+
struct sceNetCnfUnknown *forw;
38+
struct sceNetCnfUnknown *back;
39+
} sceNetCnfUnknown_t;
40+
41+
typedef struct sceNetCnfUnknownList
42+
{
43+
struct sceNetCnfUnknown *head;
44+
struct sceNetCnfUnknown *tail;
45+
} sceNetCnfUnknownList_t;
46+
47+
typedef int (*sceNetCnfOpenFunction)(const char *device, const char *pathname, int flags, int mode, int *filesize);
48+
typedef int (*sceNetCnfReadFunction)(int fd, const char *device, const char *pathname, void *buf, int offset, int size);
49+
typedef int (*sceNetCnfCloseFunction)(int fd);
50+
51+
typedef struct sceNetCnfCallback
52+
{
53+
int type;
54+
sceNetCnfOpenFunction open;
55+
sceNetCnfReadFunction read;
56+
sceNetCnfCloseFunction close;
57+
} sceNetCnfCallback_t;
58+
59+
struct sceNetCnfInterface_want_allow
60+
{
61+
unsigned char mru_nego;
62+
unsigned char accm_nego;
63+
unsigned char magic_nego;
64+
unsigned char prc_nego;
65+
unsigned char acc_nego;
66+
unsigned char address_nego;
67+
unsigned char vjcomp_nego;
68+
unsigned char dns1_nego;
69+
unsigned char dns2_nego;
70+
unsigned char reserved_nego[7];
71+
unsigned short mru;
72+
unsigned int accm;
73+
unsigned char auth;
74+
unsigned char f_mru;
75+
unsigned char f_accm;
76+
unsigned char f_auth;
77+
unsigned char *ip_address;
78+
unsigned char *ip_mask;
79+
unsigned char *dns1;
80+
unsigned char *dns2;
81+
unsigned int reserved_value[8];
82+
};
83+
84+
typedef struct sceNetCnfInterface
85+
{
86+
int type;
87+
unsigned char *vendor;
88+
unsigned char *product;
89+
unsigned char *location;
90+
unsigned char dhcp;
91+
unsigned char *dhcp_host_name;
92+
unsigned char dhcp_host_name_null_terminated;
93+
unsigned char dhcp_release_on_stop;
94+
unsigned char *address;
95+
unsigned char *netmask;
96+
unsigned char *chat_additional;
97+
int redial_count;
98+
int redial_interval;
99+
unsigned char *outside_number;
100+
unsigned char *outside_delay;
101+
unsigned char *phone_numbers[10];
102+
unsigned char answer_mode;
103+
int answer_timeout;
104+
int dialing_type;
105+
unsigned char *chat_login;
106+
unsigned char *auth_name;
107+
unsigned char *auth_key;
108+
unsigned char *peer_name;
109+
unsigned char *peer_key;
110+
int lcp_timeout;
111+
int ipcp_timeout;
112+
int idle_timeout;
113+
int connect_timeout;
114+
struct sceNetCnfInterface_want_allow want;
115+
struct sceNetCnfInterface_want_allow allow;
116+
int log_flags;
117+
unsigned char force_chap_type;
118+
unsigned char omit_empty_frame;
119+
unsigned char pppoe;
120+
unsigned char pppoe_host_uniq_auto;
121+
unsigned char pppoe_reserved[2];
122+
unsigned char *pppoe_service_name;
123+
unsigned char *pppoe_ac_name;
124+
int mtu;
125+
unsigned char lcp_max_configure;
126+
unsigned char lcp_max_terminate;
127+
unsigned char ipcp_max_configure;
128+
unsigned char ipcp_max_terminate;
129+
unsigned char auth_timeout;
130+
unsigned char auth_max_failure;
131+
unsigned char reserved[6];
132+
int phy_config;
133+
struct sceNetCnfCommand *cmd_head;
134+
struct sceNetCnfCommand *cmd_tail;
135+
struct sceNetCnfUnknownList unknown_list;
136+
} sceNetCnfInterface_t;
137+
138+
typedef struct sceNetCnfDial
139+
{
140+
unsigned char *tone_dial;
141+
unsigned char *pulse_dial;
142+
unsigned char *any_dial;
143+
unsigned char *chat_init;
144+
unsigned char *chat_dial;
145+
unsigned char *chat_answer;
146+
unsigned char *redial_string;
147+
struct sceNetCnfUnknownList unknown_list;
148+
} sceNetCnfDial_t;
149+
150+
typedef struct sceNetCnfCtl
151+
{
152+
struct sceNetCnfDial *dial;
153+
struct sceNetCnfInterface *ifc;
154+
int id;
155+
int phone_index;
156+
int redial_index;
157+
char interface[9];
158+
} sceNetCnfCtl_t;
159+
160+
typedef struct sceNetCnfPair
161+
{
162+
struct sceNetCnfPair *forw;
163+
struct sceNetCnfPair *back;
164+
unsigned char *display_name;
165+
unsigned char *attach_ifc;
166+
unsigned char *attach_dev;
167+
struct sceNetCnfInterface *ifc;
168+
struct sceNetCnfInterface *dev;
169+
struct sceNetCnfUnknownList unknown_list;
170+
struct sceNetCnfCtl *ctl;
171+
} sceNetCnfPair_t;
172+
173+
typedef struct sceNetCnfRoot
174+
{
175+
struct sceNetCnfPair *pair_head;
176+
struct sceNetCnfPair *pair_tail;
177+
int version;
178+
unsigned char *chat_additional;
179+
int redial_count;
180+
int redial_interval;
181+
unsigned char *outside_number;
182+
unsigned char *outside_delay;
183+
int dialing_type;
184+
struct sceNetCnfUnknownList unknown_list;
185+
} sceNetCnfRoot_t;
186+
187+
typedef struct sceNetCnfEnv
188+
{
189+
char *dir_name;
190+
char *arg_fname;
191+
void *mem_base;
192+
void *mem_ptr;
193+
void *mem_last;
194+
int req;
195+
struct sceNetCnfRoot *root;
196+
struct sceNetCnfInterface *ifc;
197+
int f_no_check_magic;
198+
int f_no_decode;
199+
int f_verbose;
200+
int file_err;
201+
int alloc_err;
202+
int syntax_err;
203+
const char *fname;
204+
int lno;
205+
unsigned char lbuf[1024];
206+
unsigned char dbuf[1024];
207+
int ac;
208+
const char *av[11];
209+
} sceNetCnfEnv_t;
210+
211+
typedef struct sceNetCnfRoutingEntry
212+
{
213+
struct sceNetCnfAddress dstaddr;
214+
struct sceNetCnfAddress gateway;
215+
struct sceNetCnfAddress genmask;
216+
int flags;
217+
int mss;
218+
int window;
219+
char interface[9];
220+
} sceNetCnfRoutingEntry_t;
221+
222+
typedef struct route
223+
{
224+
sceNetCnfCommand_t cmd;
225+
sceNetCnfRoutingEntry_t re;
226+
} route_t;
227+
228+
typedef struct nameserver
229+
{
230+
sceNetCnfCommand_t cmd;
231+
sceNetCnfAddress_t address;
232+
} nameserver_t;
233+
234+
extern int sceNetCnfGetCount(const char *fname, int type);
235+
extern int sceNetCnfGetList(const char *fname, int type, sceNetCnfList_t *p);
236+
extern int sceNetCnfLoadEntry(const char *fname, int type, const char *usr_name, sceNetCnfEnv_t *e);
237+
extern int sceNetCnfAddEntry(const char *fname, int type, const char *usr_name, sceNetCnfEnv_t *e);
238+
extern int sceNetCnfDeleteEntry(const char *fname, int type, const char *usr_name);
239+
extern int sceNetCnfSetLatestEntry(const char *fname, int type, const char *usr_name);
240+
extern void *sceNetCnfAllocMem(sceNetCnfEnv_t *e, int size, int align);
241+
extern int sceNetCnfInitIFC(sceNetCnfInterface_t *ifc);
242+
extern int sceNetCnfLoadConf(sceNetCnfEnv_t *e);
243+
extern int sceNetCnfLoadDial(sceNetCnfEnv_t *e, sceNetCnfPair_t *pair);
244+
extern int sceNetCnfMergeConf(sceNetCnfEnv_t *e);
245+
extern int sceNetCnfName2Address(sceNetCnfAddress_t *paddr, const char *buf);
246+
extern int sceNetCnfAddress2String(char *buf, int len, const sceNetCnfAddress_t *paddr);
247+
extern int
248+
sceNetCnfEditEntry(const char *fname, int type, const char *usr_name, const char *new_usr_name, sceNetCnfEnv_t *e);
249+
extern int sceNetCnfDeleteAll(const char *dev);
250+
extern int sceNetCnfCheckCapacity(const char *fname);
251+
extern int sceNetCnfConvA2S(char *sp_, char *dp_, int len);
252+
extern int sceNetCnfConvS2A(char *sp_, char *dp_, int len);
253+
extern int sceNetCnfCheckSpecialProvider(const char *fname, int type, const char *usr_name, sceNetCnfEnv_t *e);
254+
extern void sceNetCnfSetCallback(sceNetCnfCallback_t *pcallback);
255+
256+
#define netcnf_IMPORTS_start DECLARE_IMPORT_TABLE(netcnf, 1, 32)
257+
#define netcnf_IMPORTS_end END_IMPORT_TABLE
258+
259+
#define I_sceNetCnfGetCount DECLARE_IMPORT(4, sceNetCnfGetCount)
260+
#define I_sceNetCnfGetList DECLARE_IMPORT(5, sceNetCnfGetList)
261+
#define I_sceNetCnfLoadEntry DECLARE_IMPORT(6, sceNetCnfLoadEntry)
262+
#define I_sceNetCnfAddEntry DECLARE_IMPORT(7, sceNetCnfAddEntry)
263+
#define I_sceNetCnfDeleteEntry DECLARE_IMPORT(8, sceNetCnfDeleteEntry)
264+
#define I_sceNetCnfSetLatestEntry DECLARE_IMPORT(9, sceNetCnfSetLatestEntry)
265+
#define I_sceNetCnfAllocMem DECLARE_IMPORT(10, sceNetCnfAllocMem)
266+
#define I_sceNetCnfInitIFC DECLARE_IMPORT(11, sceNetCnfInitIFC)
267+
#define I_sceNetCnfLoadConf DECLARE_IMPORT(12, sceNetCnfLoadConf)
268+
#define I_sceNetCnfLoadDial DECLARE_IMPORT(13, sceNetCnfLoadDial)
269+
#define I_sceNetCnfMergeConf DECLARE_IMPORT(14, sceNetCnfMergeConf)
270+
#define I_sceNetCnfName2Address DECLARE_IMPORT(15, sceNetCnfName2Address)
271+
#define I_sceNetCnfAddress2String DECLARE_IMPORT(16, sceNetCnfAddress2String)
272+
#define I_sceNetCnfEditEntry DECLARE_IMPORT(17, sceNetCnfEditEntry)
273+
#define I_sceNetCnfDeleteAll DECLARE_IMPORT(18, sceNetCnfDeleteAll)
274+
#define I_sceNetCnfCheckCapacity DECLARE_IMPORT(19, sceNetCnfCheckCapacity)
275+
#define I_sceNetCnfConvA2S DECLARE_IMPORT(20, sceNetCnfConvA2S)
276+
#define I_sceNetCnfConvS2A DECLARE_IMPORT(21, sceNetCnfConvS2A)
277+
#define I_sceNetCnfCheckSpecialProvider DECLARE_IMPORT(22, sceNetCnfCheckSpecialProvider)
278+
#define I_sceNetCnfSetCallback DECLARE_IMPORT(23, sceNetCnfSetCallback)
279+
280+
#endif

iop/network/netcnf/src/exports.tab

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
DECLARE_EXPORT_TABLE(netcnf, 1, 32)
3+
DECLARE_EXPORT(_start)
4+
DECLARE_EXPORT(_retonly)
5+
DECLARE_EXPORT(_retonly)
6+
DECLARE_EXPORT(_retonly)
7+
DECLARE_EXPORT(sceNetCnfGetCount)
8+
DECLARE_EXPORT(sceNetCnfGetList)
9+
DECLARE_EXPORT(sceNetCnfLoadEntry)
10+
DECLARE_EXPORT(sceNetCnfAddEntry)
11+
DECLARE_EXPORT(sceNetCnfDeleteEntry)
12+
DECLARE_EXPORT(sceNetCnfSetLatestEntry)
13+
DECLARE_EXPORT(sceNetCnfAllocMem)
14+
DECLARE_EXPORT(sceNetCnfInitIFC)
15+
DECLARE_EXPORT(sceNetCnfLoadConf)
16+
DECLARE_EXPORT(sceNetCnfLoadDial)
17+
DECLARE_EXPORT(sceNetCnfMergeConf)
18+
DECLARE_EXPORT(sceNetCnfName2Address)
19+
DECLARE_EXPORT(sceNetCnfAddress2String)
20+
DECLARE_EXPORT(sceNetCnfEditEntry)
21+
DECLARE_EXPORT(sceNetCnfDeleteAll)
22+
DECLARE_EXPORT(sceNetCnfCheckCapacity)
23+
DECLARE_EXPORT(sceNetCnfConvA2S)
24+
DECLARE_EXPORT(sceNetCnfConvS2A)
25+
DECLARE_EXPORT(sceNetCnfCheckSpecialProvider)
26+
DECLARE_EXPORT(sceNetCnfSetCallback)
27+
END_EXPORT_TABLE
28+
29+
void _retonly() {}

0 commit comments

Comments
 (0)