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