Subversion Repositories Kolibri OS

Rev

Rev 5676 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #ifndef INCLUDE_SOCKET_H
  2. #define INCLUDE_SOCKET_H
  3. #print "[include <socket.h>]\n"
  4.  
  5. #ifndef INCLUDE_KOLIBRI_H
  6. #include "../lib/kolibri.h"
  7. #endif
  8.  
  9. #define SOCK_STREAM 1
  10. #define SOCK_DGRAM 2
  11.  
  12. #define AF_INET4 2
  13.  
  14. #define MSG_PEEK 0x02
  15. #define MSG_DONTWAIT 0x40
  16.  
  17. struct  SockAddr
  18. {
  19.   word    sin_family;
  20.   char    data[14];
  21. };
  22.  
  23. // ecx = domain
  24. // edx = type
  25. // esi = protocol
  26. inline fastcall dword socket_open(ECX, EDX, ESI)
  27. {
  28.         $mov    eax, 75
  29.         $mov    bl, 0
  30.         $int    0x40
  31. }
  32.  
  33. // ecx = socket number
  34. inline fastcall dword socket_close(ECX)
  35. {
  36.         $mov    eax, 75
  37.         $mov    bl, 1
  38.         $int    0x40
  39. }
  40.  
  41. // ecx = socket number
  42. // edx = pointer to sockaddr structure
  43. // esi = length of sockaddr structure
  44. inline fastcall dword socket_bind(ECX, EDX, ESI)
  45. {
  46.         $mov    eax, 75
  47.         $mov    bl, 2
  48.         $int    0x40
  49. }
  50.  
  51. // ecx = socket number
  52. // edx = backlog
  53. inline fastcall dword socket_listen(ECX, EDX)
  54. {
  55.         $mov    eax, 75
  56.         $mov    bl, 3
  57.         $int    0x40
  58. }
  59.  
  60. // ecx = socket number
  61. // edx = pointer to sockaddr structure
  62. // esi = length of sockaddr structure
  63. inline fastcall dword socket_connect(ECX, EDX, ESI)
  64. {
  65.         $mov    eax, 75
  66.         $mov    bl, 4
  67.         $int    0x40
  68. }
  69.  
  70. // ecx = socket number
  71. // edx = pointer to sockaddr structure
  72. // esi = length of sockaddr structure
  73. inline fastcall dword socket_accept(ECX, EDX, ESI)
  74. {
  75.         $mov    eax, 75
  76.         $mov    bl, 5
  77.         $int    0x40
  78. }
  79.  
  80. // ecx = socket number
  81. // edx = pointer to buffer
  82. // esi = length of buffer
  83. // edi = flags
  84. inline fastcall dword socket_send(ECX, EDX, ESI, EDI)
  85. {
  86.         $mov    eax, 75
  87.         $mov    bl, 6
  88.         $int    0x40
  89. }
  90.  
  91. // ecx = socket number
  92. // edx = pointer to buffer
  93. // esi = length of buffer
  94. // edi = flags
  95. inline fastcall dword socket_receive(ECX, EDX, ESI, EDI)
  96. {
  97.         $mov    eax, 75
  98.         $mov    bl, 7
  99.         $int    0x40
  100. }
  101.  
  102. #endif