Subversion Repositories Kolibri OS

Rev

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

  1. eax = 74 - Work directly with network interface
  2. ebx = -1 (Get number of active network devices)
  3.  
  4.     out:
  5.         eax = number of active network devices
  6.  
  7. bh = device number, for all following functions !
  8.  
  9. bl = 0 (Get device type)
  10.  
  11.     out:
  12.         eax = device type number
  13.  
  14. bl = 1 (Get device name)
  15.  
  16.     in:
  17.         ecx = pointer to 64 byte buffer
  18.     out:
  19.         name is copied into the buffer
  20.         eax = -1 on error
  21.  
  22. bl = 2 (Reset the device)
  23.  
  24.     in
  25.         none
  26.     out
  27.         eax = -1 on error
  28.  
  29. bl = 3 (Stop device)
  30.  
  31.     in
  32.         none
  33.     out
  34.         eax = -1 on error
  35.  
  36. TO BE FIGURED OUT
  37.  
  38. eax = 75 - Work with Sockets
  39.  
  40. These functions work like the ones found in UNIX (and windows)
  41. for more info, please read http://beej.us/guide/bgnet/
  42.  
  43. bl = 0 (Open Socket)
  44.  
  45.     in:
  46.         ecx = domain
  47.         edx = type
  48.         esi = protocol
  49.     out:
  50.         eax = socket number, -1 on error
  51.  
  52. bl = 1 (Close Socket)
  53.  
  54.     in:
  55.         ecx = socket number
  56.     out:
  57.         eax = -1 on error
  58.  
  59. bl = 2 (Bind)
  60.  
  61.     in:
  62.         ecx = socket number
  63.         edx = pointer to sockaddr structure
  64.         esi = length of sockaddr structure
  65.     out:
  66.         eax = -1 on error
  67.  
  68. bl = 3 (Listen)
  69.  
  70.     in:
  71.         ecx = socket number
  72.         edx = backlog
  73.     out:
  74.         eax = -1 on error
  75.  
  76. bl = 4 (connect)
  77.  
  78.     in:
  79.         ecx = socket number
  80.         edx = pointer to sockaddr structure
  81.         esi = length of sockaddr structure
  82.     out:
  83.         eax = -1 on error
  84.  
  85. bl = 5 (accept)
  86.  
  87.     in:
  88.         ecx = socket number
  89.         edx = pointer to sockaddr structure
  90.         esi = length of sockaddr structure
  91.     out:
  92.         eax = socket number, -1 on error
  93.  
  94. bl = 6 (send)
  95.  
  96.     in:
  97.         ecx = socket number
  98.         edx = pointer to buffer
  99.         esi = length of buffer
  100.         edi = flags
  101.     out:
  102.         eax = -1 on error
  103.  
  104. bl = 7 (receive)
  105.  
  106.     in:
  107.         ecx = socket number
  108.         edx = pointer to buffer
  109.         esi = length of buffer
  110.         edi = flags
  111.     out:
  112.         eax = number of bytes copied, -1 on error
  113.  
  114. bl = 8 (set socket options)
  115.  
  116.     in:
  117.         ecx = socket number
  118.         edx = ptr to optstruct
  119.  
  120.   Optstruct: dd level
  121.              dd optionname
  122.              dd optlength
  123.              db options...
  124.  
  125. The buffer's first dword is the length of the buffer, minus the first dword offcourse
  126.  
  127.     out:
  128.         eax = -1 on error
  129.  
  130. bl = 9 (get socket options)
  131.  
  132.     in:
  133.         ecx = socket number
  134.         edx = ptr to optstruct
  135.  
  136.   Optstruct: dd level
  137.              dd optionname
  138.              dd optlength
  139.              db options...
  140.     out:
  141.         eax = -1 on error, socket option otherwise
  142.  
  143. bl = 10 (get IPC socketpair)
  144.  
  145.     in:
  146.         /
  147.     out:
  148.         eax = -1 on error, socketnum1 otherwise
  149.         ebx = socketnum2
  150.  
  151. TIP
  152.  
  153. when you import 'network.inc' and 'macros.inc' into your source code, you can use the following syntax to work with sockets:
  154.  
  155.  
  156. for example, to open a socket
  157.  
  158. mcall socket, AF_INET, SOCK_DGRAM,0
  159. mov [socketnum], eax
  160.  
  161. then to connect to a server
  162.  
  163. mcall connect, [socketnum], sockaddr, 18
  164.  
  165.  
  166. eax = 76 - Work with protocols
  167.  
  168. high half of ebx = protocol number (for all subfunctions!)
  169. bh = device number (for all subfunctions!)
  170. bl = subfunction number, depends on protocol type
  171.  
  172. For Ethernet protocol
  173.  
  174. 0 - Read # Packets send
  175. 1 - Read # Packets received
  176. 2 - Read # Bytes send
  177. 3 - Read # Bytes received
  178. 4 - Read MAC
  179. 5 - Write MAC
  180. 6 - Read IN-QUEUE size
  181. 7 - Read OUT-QUEUE size
  182. For IPv4 protocol
  183.  
  184. 0 - Read # IP packets send
  185. 1 - Read # IP packets received
  186. 2 - Read IP
  187. 3 - Write IP
  188. 4 - Read DNS
  189. 5 - Write DNS
  190. 6 - Read subnet
  191. 7 - Write subnet
  192. 8 - Read gateway
  193. 9 - Write gateway
  194. For ARP protocol
  195.  
  196. 0 - Read # ARP packets send
  197. 1 - Read # ARP packets received
  198. 2 - Get # ARP entry's
  199. 3 - Read ARP entry
  200. 4 - Add static ARP entry
  201. 5 - Remove ARP entry (-1 = remove all)
  202. For ICMP protocol
  203.  
  204. 0 - Read # ICMP packets send
  205. 1 - Read # ICMP packets received
  206. 3 - enable/disable ICMP echo reply
  207. For UDP protocol
  208.  
  209. 0 - Read # UDP packets send
  210. 1 - Read # UDP packets received
  211. For TCP protocol
  212.  
  213. 0 - Read # TCP packets send
  214. 1 - Read # TCP packets received