2012-12-06 11:49:06 +04:00
|
|
|
|
//Network library
|
2015-07-22 21:32:54 +03:00
|
|
|
|
#ifndef INCLUDE_NETWORK_H
|
|
|
|
|
#define INCLUDE_NETWORK_H
|
2012-12-06 11:49:06 +04:00
|
|
|
|
|
2015-07-22 21:32:54 +03:00
|
|
|
|
#ifndef INCLUDE_KOLIBRI_H
|
|
|
|
|
#include "../lib/kolibri.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef INCLUDE_DLL_H
|
|
|
|
|
#include "../lib/dll.h"
|
|
|
|
|
#endif
|
2012-12-06 11:49:06 +04:00
|
|
|
|
dword network_lib = #a_network_lib;
|
2018-04-21 15:28:00 +03:00
|
|
|
|
char a_network_lib[]="/sys/lib/network.obj";
|
2012-12-06 11:49:06 +04:00
|
|
|
|
|
2018-05-20 16:54:35 +03:00
|
|
|
|
dword network_lib_init = #aInet_init;
|
2012-12-06 11:49:06 +04:00
|
|
|
|
dword inet_addr = #aInet_addr; //"192.168.0.1" -> dword IP
|
|
|
|
|
dword inet_ntoa = #aInet_ntoa;
|
|
|
|
|
dword getaddrinfo = #aGetaddrinfo;
|
|
|
|
|
dword getaddrinfo_start = #aGetaddrinfo_start;
|
|
|
|
|
dword getaddrinfo_process = #aGetaddrinfo_process;
|
|
|
|
|
dword getaddrinfo_abort = #aGetaddrinfo_abort;
|
|
|
|
|
dword freeaddrinfo = #aFreeaddrinfo;
|
2013-07-26 18:41:31 +04:00
|
|
|
|
$DD 2 dup 0
|
2012-12-06 11:49:06 +04:00
|
|
|
|
|
2018-05-20 16:54:35 +03:00
|
|
|
|
char aInet_init[] = "lib_init";
|
2018-04-21 15:28:00 +03:00
|
|
|
|
char aInet_addr[] = "inet_addr";
|
|
|
|
|
char aInet_ntoa[] = "inet_ntoa";
|
|
|
|
|
char aGetaddrinfo[] = "getaddrinfo";
|
|
|
|
|
char aGetaddrinfo_start[] = "getaddrinfo_start";
|
|
|
|
|
char aGetaddrinfo_process[] = "getaddrinfo_process";
|
|
|
|
|
char aGetaddrinfo_abort[] = "getaddrinfo_abort";
|
|
|
|
|
char aFreeaddrinfo[] = "freeaddrinfo";
|
2012-12-06 11:49:06 +04:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
addr соответствует IP 10.101.102.103
|
|
|
|
|
itoa((addr&0xFF000000)>>24) равно 103
|
|
|
|
|
itoa((addr&0xFF0000)>>16) —это 102
|
|
|
|
|
itoa((addr&0xFF00)>>8) — это 101
|
|
|
|
|
itoa(addr&0xFF) — это 10
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
dword GetIPfromAdress(dword addr)
|
|
|
|
|
{
|
2012-12-15 03:55:44 +04:00
|
|
|
|
dword lpointer, IPa;
|
2012-12-06 11:49:06 +04:00
|
|
|
|
getaddrinfo stdcall (addr, 0, 0, #lpointer);
|
2012-12-15 03:55:44 +04:00
|
|
|
|
if (EAX!=0) IPa = 0; else IPa = DSDWORD[DSDWORD[lpointer+24]+4];
|
|
|
|
|
freeaddrinfo stdcall (lpointer);
|
|
|
|
|
return IPa;
|
2012-12-06 11:49:06 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
//Convert the string from standard IPv4 dotted notation to integer IP addr.
|
|
|
|
|
inet_addr stdcall ("192.168.0.1");
|
|
|
|
|
server_IP = EAX;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char* __stdcall inet_ntoa(struct in_addr in);
|
|
|
|
|
Convert the Internet host address to standard IPv4 dotted notation.
|
|
|
|
|
|
|
|
|
|
getaddrinfo(__in const char* hostname, __in const char* servname,
|
|
|
|
|
__in const struct addrinfo* hints, __out struct addrinfo **res);
|
|
|
|
|
struct addrinfo {
|
|
|
|
|
int ai_flags;
|
|
|
|
|
int ai_family;
|
|
|
|
|
int ai_socktype;
|
|
|
|
|
int ai_protocol;
|
|
|
|
|
size_t ai_addrlen;
|
|
|
|
|
struct sockaddr *ai_addr;
|
|
|
|
|
char *ai_canonname;
|
|
|
|
|
struct addrinfo *ai_next;
|
|
|
|
|
};
|
|
|
|
|
*/
|
2015-07-22 21:32:54 +03:00
|
|
|
|
|
|
|
|
|
#endif
|