Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Compare with Previous | 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.  
  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;
  38.         getaddrinfo stdcall (addr, 0, 0, #lpointer);
  39.         if (EAX!=0) return 0; //если ошибка
  40.         return DSDWORD[DSDWORD[lpointer+24]+4];
  41. }
  42.  
  43. /*dword GetIPfromAdressASM(dword addr)
  44. {
  45.         dword lpointer;
  46.  
  47.         ESP=#lpointer;
  48.         $push   esp     // lpointer
  49.         $push   esp     // fourth parameter
  50.         $push   0       // third parameter
  51.         $push   0       // second parameter
  52.         EAX = addr;
  53.         $push   eax     // first parameter
  54.         $call   getaddrinfo
  55.         if (EAX!=0) return 0; //ошибка
  56.         $pop    esi
  57.         $mov    ebx, DSDWORD[lpointer+24]
  58.         $mov    eax, DSDWORD[EBX+4]
  59.        
  60.         return EAX;
  61. }*/
  62.  
  63.  
  64. /*
  65. //Convert the string from standard IPv4 dotted notation to integer IP addr.
  66. inet_addr stdcall ("192.168.0.1");
  67. server_IP = EAX;
  68.  
  69.  
  70. char* __stdcall inet_ntoa(struct in_addr in);
  71. Convert the Internet host address to standard IPv4 dotted notation.
  72.  
  73. getaddrinfo(__in const char* hostname, __in const char* servname,
  74.             __in const struct addrinfo* hints, __out struct addrinfo **res);    
  75. struct addrinfo {
  76.     int     ai_flags;
  77.     int     ai_family;
  78.     int     ai_socktype;
  79.     int     ai_protocol;
  80.     size_t  ai_addrlen;
  81.     struct sockaddr *ai_addr;
  82.     char   *ai_canonname;
  83.     struct addrinfo *ai_next;
  84. };
  85. */
  86.