Rev 260 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 260 | Rev 485 | ||
---|---|---|---|
Line 10... | Line 10... | ||
10 | ; |
10 | ; |
11 | ; v1.0: 18 august 2006 original release |
11 | ; v1.0: 18 august 2006 original release |
12 | ; v1.1: december 2006 bugfixes and improvements |
12 | ; v1.1: december 2006 bugfixes and improvements |
13 | ; |
13 | ; |
Line 14... | Line -... | ||
14 | - | ||
15 | 14 | ||
16 | macro mov arg1,arg2 { |
15 | macro mov arg1,arg2 { |
17 | if arg1 eq arg2 |
16 | if arg1 eq arg2 |
18 | else |
17 | else |
19 | mov arg1,arg2 |
18 | mov arg1,arg2 |
Line 41... | Line 40... | ||
41 | ; |
40 | ; |
42 | ; gets the current IP that is defined in Stack (return in eax in this example) |
41 | ; gets the current IP that is defined in Stack (return in eax in this example) |
43 | macro eth.get_IP IP { |
42 | macro eth.get_IP IP { |
44 | mov ebx,1 |
43 | mov ebx,1 |
45 | mov eax,52 |
44 | mov eax,52 |
46 | int 0x40 |
45 | mcall |
Line 47... | Line 46... | ||
47 | 46 | ||
48 | mov IP ,eax |
47 | mov IP ,eax |
Line 49... | Line 48... | ||
49 | } |
48 | } |
50 | 49 | ||
51 | ; eth.get_GATEWAY eax |
50 | ; eth.get_GATEWAY eax |
52 | ; |
51 | ; |
53 | ; gets the current GATEWAY that is defined in Stack (return in eax in this example) |
52 | ; gets the current GATEWAY that is defined in Stack (return in eax in this example) |
54 | macro eth.get_GATEWAY GATEWAY { |
53 | macro eth.get_GATEWAY GATEWAY { |
55 | mov ebx,9 |
54 | mov ebx,9 |
56 | mov eax,52 |
55 | mov eax,52 |
57 | int 0x40 |
56 | mcall |
Line 58... | Line 57... | ||
58 | move GATEWAY ,eax |
57 | move GATEWAY ,eax |
59 | } |
58 | } |
60 | 59 | ||
61 | ; eth.get_SUBNET eax |
60 | ; eth.get_SUBNET eax |
62 | ; |
61 | ; |
63 | ; gets the current SUBNET that is defined in Stack (return in eax in this example) |
62 | ; gets the current SUBNET that is defined in Stack (return in eax in this example) |
64 | macro eth.get_SUBNET SUBNET { |
63 | macro eth.get_SUBNET SUBNET { |
65 | mov ebx,10 |
64 | mov ebx,10 |
66 | mov eax,52 |
65 | mov eax,52 |
Line 67... | Line 66... | ||
67 | int 0x40 |
66 | mcall |
68 | mov SUBNET ,eax |
67 | mov SUBNET ,eax |
69 | } |
68 | } |
70 | 69 | ||
71 | ; eth.get_DNS eax |
70 | ; eth.get_DNS eax |
72 | ; |
71 | ; |
73 | ; gets the current DNS that is defined in Stack (return in eax in this example) |
72 | ; gets the current DNS that is defined in Stack (return in eax in this example) |
74 | macro eth.get_DNS DNS { |
73 | macro eth.get_DNS DNS { |
75 | mov ebx,13 |
74 | mov ebx,13 |
Line 76... | Line 75... | ||
76 | mov eax,52 |
75 | mov eax,52 |
77 | int 0x40 |
76 | mcall |
78 | mov DNS ,eax |
77 | mov DNS ,eax |
79 | } |
78 | } |
80 | 79 | ||
81 | ; eth.set_IP eax |
80 | ; eth.set_IP eax |
82 | ; |
81 | ; |
83 | ; set a new IP in stack (input in eax in this example) |
82 | ; set a new IP in stack (input in eax in this example) |
84 | macro eth.set_IP IP { |
83 | macro eth.set_IP IP { |
Line 85... | Line 84... | ||
85 | mov ecx,IP |
84 | mov ecx,IP |
86 | mov ebx,3 |
85 | mov ebx,3 |
87 | mov eax,52 |
86 | mov eax,52 |
88 | int 0x40 |
87 | mcall |
89 | } |
88 | } |
90 | 89 | ||
91 | ; eth.set_GATEWAY eax |
90 | ; eth.set_GATEWAY eax |
92 | ; |
91 | ; |
93 | ; set a new GATEWAY in stack (input in eax in this example) |
92 | ; set a new GATEWAY in stack (input in eax in this example) |
Line 94... | Line 93... | ||
94 | macro eth.set_GATEWAY GATEWAY { |
93 | macro eth.set_GATEWAY GATEWAY { |
95 | mov ecx,GATEWAY |
94 | mov ecx,GATEWAY |
96 | mov ebx,11 |
95 | mov ebx,11 |
97 | mov eax,52 |
96 | mov eax,52 |
98 | int 0x40 |
97 | mcall |
99 | } |
98 | } |
100 | 99 | ||
101 | ; eth.set_SUBNET eax |
100 | ; eth.set_SUBNET eax |
102 | ; |
101 | ; |
Line 103... | Line 102... | ||
103 | ; set a new SUBNET in stack (input in eax in this example) |
102 | ; set a new SUBNET in stack (input in eax in this example) |
104 | macro eth.set_SUBNET SUBNET { |
103 | macro eth.set_SUBNET SUBNET { |
105 | mov ecx,SUBNET |
104 | mov ecx,SUBNET |
106 | mov ebx,12 |
105 | mov ebx,12 |
107 | mov eax,52 |
106 | mov eax,52 |
108 | int 0x40 |
107 | mcall |
109 | } |
108 | } |
110 | 109 | ||
111 | ; eth.set_DNS eax |
110 | ; eth.set_DNS eax |
Line 112... | Line 111... | ||
112 | ; |
111 | ; |
113 | ; set a new DNS in stack (input in eax in this example) |
112 | ; set a new DNS in stack (input in eax in this example) |
114 | macro eth.set_DNS DNS { |
113 | macro eth.set_DNS DNS { |
Line 126... | Line 125... | ||
126 | mov ecx, local |
125 | mov ecx, local |
127 | mov edx, remote |
126 | mov edx, remote |
128 | mov esi, ip |
127 | mov esi, ip |
129 | mov ebx, 0 |
128 | mov ebx, 0 |
130 | mov eax, 53 |
129 | mov eax, 53 |
131 | int 0x40 |
130 | mcall |
Line 132... | Line 131... | ||
132 | 131 | ||
133 | mov socket,eax |
132 | mov socket,eax |
Line 134... | Line 133... | ||
134 | } |
133 | } |
Line 138... | Line 137... | ||
138 | ; closes socket on socketnumber [socket] |
137 | ; closes socket on socketnumber [socket] |
139 | macro eth.close_udp socket { |
138 | macro eth.close_udp socket { |
140 | mov ecx, socket |
139 | mov ecx, socket |
141 | mov ebx, 1 |
140 | mov ebx, 1 |
142 | mov eax, 53 |
141 | mov eax, 53 |
143 | int 0x40 |
142 | mcall |
144 | } |
143 | } |
Line 145... | Line 144... | ||
145 | 144 | ||
146 | ; eth.poll [socket],eax |
145 | ; eth.poll [socket],eax |
147 | ; |
146 | ; |
148 | ; polls [socket] for data |
147 | ; polls [socket] for data |
149 | ; eax = 0 when there is data |
148 | ; eax = 0 when there is data |
150 | macro eth.poll socket { |
149 | macro eth.poll socket { |
151 | mov ecx, socket |
150 | mov ecx, socket |
152 | mov ebx, 2 |
151 | mov ebx, 2 |
153 | mov eax, 53 |
152 | mov eax, 53 |
154 | int 0x40 |
153 | mcall |
Line 155... | Line 154... | ||
155 | } |
154 | } |
156 | 155 | ||
157 | ; eth.read_byte [socket], bl |
156 | ; eth.read_byte [socket], bl |
158 | ; |
157 | ; |
159 | ; reads a byte from the socket and returns in bl |
158 | ; reads a byte from the socket and returns in bl |
160 | macro eth.read_byte socket, result { |
159 | macro eth.read_byte socket, result { |
161 | mov ecx, socket |
160 | mov ecx, socket |
162 | mov ebx, 3 |
161 | mov ebx, 3 |
Line 163... | Line 162... | ||
163 | mov eax, 53 |
162 | mov eax, 53 |
164 | int 0x40 |
163 | mcall |
Line 165... | Line 164... | ||
165 | 164 | ||
Line 172... | Line 171... | ||
172 | macro eth.read_packet socket, result { |
171 | macro eth.read_packet socket, result { |
173 | mov edx, result |
172 | mov edx, result |
174 | mov ecx, socket |
173 | mov ecx, socket |
175 | mov ebx, 10 |
174 | mov ebx, 10 |
176 | mov eax, 53 |
175 | mov eax, 53 |
177 | int 0x40 |
176 | mcall |
178 | } |
177 | } |
Line 179... | Line 178... | ||
179 | 178 | ||
180 | ; eth.write [socket],12,msg |
179 | ; eth.write [socket],12,msg |
181 | ; msg db 'hello world!' |
180 | ; msg db 'hello world!' |
Line 185... | Line 184... | ||
185 | mov ecx, socket |
184 | mov ecx, socket |
186 | mov edx, length |
185 | mov edx, length |
187 | mov esi, msg |
186 | mov esi, msg |
188 | mov ebx, 4 |
187 | mov ebx, 4 |
189 | mov eax, 53 |
188 | mov eax, 53 |
190 | int 0x40 |
189 | mcall |
Line 191... | Line 190... | ||
191 | 190 | ||
192 | if verify eq 1 |
191 | if verify eq 1 |
193 | call verifysend |
192 | call verifysend |
Line 201... | Line 200... | ||
201 | ret |
200 | ret |
202 | @@: |
201 | @@: |
203 | pusha |
202 | pusha |
204 | mov eax,5 |
203 | mov eax,5 |
205 | mov ebx,100 |
204 | mov ebx,100 |
206 | int 0x40 |
205 | mcall |
- | 206 | ||
207 | popa |
207 | popa |
208 | int 0x40 |
208 | mcall |
209 | ret |
209 | ret |
Line 210... | Line 210... | ||
210 | 210 | ||
211 | ; eth.open_tcp 80,80,eax,0,[socket] |
211 | ; eth.open_tcp 80,80,eax,0,[socket] |
212 | ; |
212 | ; |
Line 218... | Line 218... | ||
218 | mov edx, remote |
218 | mov edx, remote |
219 | mov esi, ip |
219 | mov esi, ip |
220 | mov edi, passive ; 0 = PASSIVE open |
220 | mov edi, passive ; 0 = PASSIVE open |
221 | mov ebx, 5 |
221 | mov ebx, 5 |
222 | mov eax, 53 |
222 | mov eax, 53 |
223 | int 0x40 |
223 | mcall |
Line 224... | Line 224... | ||
224 | 224 | ||
225 | mov socket,eax |
225 | mov socket,eax |
Line 226... | Line 226... | ||
226 | } |
226 | } |
Line 230... | Line 230... | ||
230 | ; returns socket status in eax |
230 | ; returns socket status in eax |
231 | macro eth.socket_status socket,result { |
231 | macro eth.socket_status socket,result { |
232 | mov ecx, socket |
232 | mov ecx, socket |
233 | mov ebx, 6 |
233 | mov ebx, 6 |
234 | mov eax, 53 |
234 | mov eax, 53 |
235 | int 0x40 |
235 | mcall |
Line 236... | Line 236... | ||
236 | 236 | ||
237 | mov result,eax |
237 | mov result,eax |
Line 238... | Line 238... | ||
238 | } |
238 | } |
Line 246... | Line 246... | ||
246 | mov ecx, socket |
246 | mov ecx, socket |
247 | mov edx, length |
247 | mov edx, length |
248 | mov esi, msg |
248 | mov esi, msg |
249 | mov ebx, 7 |
249 | mov ebx, 7 |
250 | mov eax, 53 |
250 | mov eax, 53 |
251 | int 0x40 |
251 | mcall |
Line 252... | Line 252... | ||
252 | 252 | ||
253 | if verify eq 1 |
253 | if verify eq 1 |
254 | call verifysend |
254 | call verifysend |
255 | end if |
255 | end if |
Line 260... | Line 260... | ||
260 | ; closes tcp socket [socket] |
260 | ; closes tcp socket [socket] |
261 | macro eth.close_tcp socket { |
261 | macro eth.close_tcp socket { |
262 | mov ecx, socket |
262 | mov ecx, socket |
263 | mov ebx, 8 |
263 | mov ebx, 8 |
264 | mov eax, 53 |
264 | mov eax, 53 |
265 | int 0x40 |
265 | mcall |
266 | } |
266 | } |
Line 267... | Line 267... | ||
267 | 267 | ||
268 | ; eth.check_port 165,eax |
268 | ; eth.check_port 165,eax |
269 | ; |
269 | ; |
270 | ; checks if port 165 is used |
270 | ; checks if port 165 is used |
271 | ; return is 0 when port is free |
271 | ; return is 0 when port is free |
272 | macro eth.check_port port,result { |
272 | macro eth.check_port port,result { |
273 | mov ecx, port |
273 | mov ecx, port |
274 | mov ebx, 9 |
274 | mov ebx, 9 |
275 | mov eax, 53 |
275 | mov eax, 53 |
Line 276... | Line 276... | ||
276 | int 0x40 |
276 | mcall |
277 | 277 | ||
Line 278... | Line 278... | ||
278 | mov result,eax |
278 | mov result,eax |
Line 283... | Line 283... | ||
283 | ; returns socket status in eax |
283 | ; returns socket status in eax |
284 | macro eth.status status { |
284 | macro eth.status status { |
285 | mov ebx, 255 |
285 | mov ebx, 255 |
286 | mov ecx, 6 |
286 | mov ecx, 6 |
287 | mov eax, 53 |
287 | mov eax, 53 |
288 | int 0x40 |
288 | mcall |
Line 289... | Line 289... | ||
289 | 289 | ||
290 | mov status,eax |
290 | mov status,eax |
Line 291... | Line 291... | ||
291 | } |
291 | } |
Line 338... | Line 338... | ||
338 | 338 | ||
339 | mov edx,0 |
339 | mov edx,0 |
340 | .loop: |
340 | .loop: |
341 | mov eax,5 |
341 | mov eax,5 |
342 | mov ebx,1 |
342 | mov ebx,1 |
Line 343... | Line 343... | ||
343 | int 0x40 |
343 | mcall |
Line 344... | Line 344... | ||
344 | 344 | ||
345 | eth.poll socket |
345 | eth.poll socket |
Line 374... | Line 374... | ||
374 | dec edx |
374 | dec edx |
375 | jz abort |
375 | jz abort |
Line 376... | Line 376... | ||
376 | 376 | ||
377 | mov eax,5 ; wait here for event |
377 | mov eax,5 ; wait here for event |
378 | mov ebx,10 |
378 | mov ebx,10 |
Line 379... | Line 379... | ||
379 | int 0x40 |
379 | mcall |
380 | 380 | ||
Line 381... | Line 381... | ||
381 | jmp @r |
381 | jmp @r |