Subversion Repositories Kolibri OS

Rev

Rev 3838 | Blame | Last modification | View Log | Download | RSS feed

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