Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3107 leency 1
//Network library
2
 
3
dword network_lib = #a_network_lib;
4
char a_network_lib[21]="/sys/lib/network.obj\0";
5
 
6
dword network_lib_init    = #aLib_init;
7
dword inet_addr           = #aInet_addr;  //"192.168.0.1" -> dword IP
8
dword inet_ntoa           = #aInet_ntoa;
9
dword getaddrinfo         = #aGetaddrinfo;
10
dword getaddrinfo_start   = #aGetaddrinfo_start;
11
dword getaddrinfo_process = #aGetaddrinfo_process;
12
dword getaddrinfo_abort   = #aGetaddrinfo_abort;
13
dword freeaddrinfo        = #aFreeaddrinfo;
14
 
15
dword  am3__ = 0x0;
16
dword  bm3__ = 0x0;
17
 
18
char aLib_init[9]              = "lib_init\0";
19
char aInet_addr[10]            = "inet_addr\0";
20
char aInet_ntoa[10]            = "inet_ntoa\0";
21
char aGetaddrinfo[12]          = "getaddrinfo\0";
22
char aGetaddrinfo_start[18]    = "getaddrinfo_start\0";
23
char aGetaddrinfo_process[20]  = "getaddrinfo_process\0";
24
char aGetaddrinfo_abort[18]    = "getaddrinfo_abort\0";
25
char aFreeaddrinfo[13]         = "freeaddrinfo\0";
26
 
27
/*
28
addr соответствует IP 10.101.102.103
29
itoa((addr&0xFF000000)>>24) равно 103
30
itoa((addr&0xFF0000)>>16) —это 102
31
itoa((addr&0xFF00)>>8) — это 101
32
itoa(addr&0xFF) — это 10
33
*/
34
 
35
dword GetIPfromAdress(dword addr)
36
{
37
	dword lpointer, IPa;
38
	getaddrinfo stdcall (addr, 0, 0, #lpointer);
39
	if (EAX!=0) IPa = 0; else IPa = DSDWORD[DSDWORD[lpointer+24]+4];
40
	freeaddrinfo stdcall (lpointer);
41
	return IPa;
42
}
43
 
44
/*
45
//Convert the string from standard IPv4 dotted notation to integer IP addr.
46
inet_addr stdcall ("192.168.0.1");
47
server_IP = EAX;
48
 
49
 
50
char* __stdcall inet_ntoa(struct in_addr in);
51
Convert the Internet host address to standard IPv4 dotted notation.
52
 
53
getaddrinfo(__in const char* hostname, __in const char* servname,
54
            __in const struct addrinfo* hints, __out struct addrinfo **res);
55
struct addrinfo {
56
    int     ai_flags;
57
    int     ai_family;
58
    int     ai_socktype;
59
    int     ai_protocol;
60
    size_t  ai_addrlen;
61
    struct sockaddr *ai_addr;
62
    char   *ai_canonname;
63
    struct addrinfo *ai_next;
64
};
65
*/