2 * Acess2 Networking Toolkit
3 * By John Hodge (thePowersGang)
11 #include <acess/sys.h>
13 int Net_OpenSocket(int AddrType, void *Addr, const char *Filename)
15 int addrLen = Net_GetAddressSize(AddrType);
17 uint8_t *addrBuffer = Addr;
18 char hexAddr[addrLen*2+1];
20 for( i = 0; i < addrLen; i ++ )
21 sprintf(hexAddr+i*2, "%02x", addrBuffer[i]);
25 int len = snprintf(NULL, 100, "/Devices/ip/routes/@%i:%s/%s", AddrType, hexAddr, Filename);
27 snprintf(path, 100, "/Devices/ip/routes/@%i:%s/%s", AddrType, hexAddr, Filename);
28 _SysDebug("%s", path);
29 return open(path, OPENFLAG_READ|OPENFLAG_WRITE);
33 int len = snprintf(NULL, 100, "/Devices/ip/routes/@%i:%s", AddrType, hexAddr);
35 snprintf(path, 100, "/Devices/ip/routes/@%i:%s", AddrType, hexAddr);
36 return open(path, OPENFLAG_READ);
40 int Net_OpenSocket_TCPC(int AddrType, void *Addr, int Port)
42 int fd = Net_OpenSocket(AddrType, Addr, "tcpc");
43 if( fd == -1 ) return -1;
45 ioctl(fd, 5, &Port); // Remote Port
46 ioctl(fd, 6, Addr); // Remote address
47 ioctl(fd, 7, NULL); // connect