Subversion Repositories Kolibri OS

Rev

Rev 337 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 337 Rev 339
Line 3... Line 3...
3
;
3
;
4
; with thanks to authors of DHCP client for menuetos: Mike Hibbet
4
; with thanks to authors of DHCP client for menuetos: Mike Hibbet
5
;
5
;
6
; by HidnPlayr & Derpenguin
6
; by HidnPlayr & Derpenguin
Line 7... Line -...
7
 
-
 
8
 
-
 
9
TIMEOUT equ 60 ; in seconds
-
 
10
BUFFER	equ 1024
-
 
11
__DEBUG__ equ 1
-
 
12
__DEBUG_LEVEL__ equ 1; 1 = all, 2 = errors
-
 
13
 
7
 
14
use32
8
use32
Line 15... Line 9...
15
	       org    0x0
9
	       org    0x0
16
 
10
 
Line 20... Line 14...
20
	       dd     IM_END		      ; size of image
14
	       dd     IM_END		    ; size of image
21
	       dd     I_END		      ; memory for app
15
	       dd     I_END		    ; memory for app
22
	       dd     I_END		      ; esp
16
	       dd     I_END		    ; esp
23
	       dd     0x0 , 0x0 	      ; I_Param , I_Icon
17
	       dd     0x0 , 0x0 	    ; I_Param , I_Icon
Line 24... Line -...
24
 
-
 
25
;include 'macros.inc'
18
 
26
include 'eth.inc'
-
 
Line 27... Line -...
27
include 'debug-fdo.inc'
-
 
28
 
-
 
29
 
-
 
30
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
 
31
; CONFIGURATION FOR LINK-LOCAL                                                         ;
19
; CONFIGURATION
32
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
20
 
33
				       ;                                               ;
21
 
34
PROBE_WAIT	    equ 1	       ; second  (initial random delay)                ;
-
 
35
PROBE_MIN	    equ 1	       ; second  (minimum delay till repeated probe)   ;
-
 
36
PROBE_MAX	    equ 2	       ; seconds (maximum delay till repeated probe)   ;
-
 
37
PROBE_NUM	    equ 3	       ;         (number of probe packets)             ;
-
 
38
				       ;                                               ;
-
 
39
ANNOUNCE_NUM	    equ 2	       ;         (number of announcement packets)      ;
-
 
40
ANNOUNCE_INTERVAL   equ 2	       ; seconds (time between announcement packets)   ;
-
 
41
ANNOUNCE_WAIT	    equ 2	       ; seconds (delay before announcing)             ;
-
 
42
				       ;                                               ;
-
 
43
MAX_CONFLICTS	    equ 10	       ;         (max conflicts before rate limiting)  ;
-
 
44
				       ;                                               ;
-
 
45
RATE_LIMIT_INTERVAL equ 60	       ; seconds (delay between successive attempts)   ;
22
TIMEOUT 	    equ 60		    ; in seconds
46
				       ;                                               ;
-
 
Line -... Line 23...
-
 
23
BUFFER		    equ 1024		    ; in bytes
Line -... Line 24...
-
 
24
__DEBUG__	    equ 1		    ; enable/disable
-
 
25
__DEBUG_LEVEL__     equ 1		    ; 1 = all, 2 = errors
-
 
26
 
47
DEFEND_INTERVAL     equ 10	       ; seconds (min. wait between defensive ARPs)    ;
27
; CONFIGURATION FOR LINK-LOCAL
Line 48... Line 28...
48
				       ;                                               ;
28
 
49
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
29
PROBE_WAIT	    equ 1		    ; second  (initial random delay)
50
 
30
PROBE_MIN	    equ 1		    ; second  (minimum delay till repeated probe)
Line 51... Line 31...
51
 
31
PROBE_MAX	    equ 2		    ; seconds (maximum delay till repeated probe)
-
 
32
PROBE_NUM	    equ 3		    ;         (number of probe packets)
-
 
33
 
-
 
34
ANNOUNCE_NUM	    equ 2		    ;         (number of announcement packets)
-
 
35
ANNOUNCE_INTERVAL   equ 2		    ; seconds (time between announcement packets)
-
 
36
ANNOUNCE_WAIT	    equ 2		    ; seconds (delay before announcing)
-
 
37
 
52
START:				       ; start of execution
38
MAX_CONFLICTS	    equ 10		    ;         (max conflicts before rate limiting)
53
 
39
 
54
    mov     eax,40		       ; Report events
40
RATE_LIMIT_INTERVAL equ 60		    ; seconds (delay between successive attempts)
-
 
41
 
-
 
42
DEFEND_INTERVAL     equ 10		    ; seconds (min. wait between defensive ARPs)
-
 
43
 
-
 
44
include 'macros.inc'
-
 
45
include 'eth.inc'
Line -... Line 46...
-
 
46
include 'debug-fdo.inc'
-
 
47
include 'dhcp.inc'
-
 
48
include 'events.inc'
55
    mov     ebx,10000000b	       ; Only Stack
49
include 'common.inc'
Line 56... Line 50...
56
    int     0x40
50
 
57
 
51
 
58
    mov     eax,52		       ; first, enable the stack (packet driver)
52
START:					    ; start of execution
59
    mov     ebx,2
53
 
60
    mov     ecx,0x00000383
54
    set_event_mask	event_network
Line 61... Line 55...
61
    int     0x40
55
    eth.set_network_drv 0x00000383
62
 
56
 
63
    DEBUGF  1,"DHCP: Stack Initialized.\n"
57
    DEBUGF  1,"Stack Initialized.\n"
64
 
58
 
65
    eth.status eax		       ; Read the Stack status
59
    eth.status eax			    ; Read the Stack status
66
    test    eax,eax		       ; if eax is zero, no driver was found
60
    test    eax,eax			    ; if eax is zero, no driver was found
67
    jnz     @f
61
    jnz     @f
68
    DEBUGF  1,"DHCP: No Card detected\n"
-
 
69
    jmp     close
-
 
70
 
62
    DEBUGF  1,"No Card detected\n"
71
   @@:
-
 
72
    DEBUGF  1,"DHCP: Detected card: %x\n",eax
-
 
73
   @@:
63
    jmp     close
Line 74... Line 64...
74
    eth.check_cable eax
64
 
75
    test    al,al
65
   @@:
Line 76... Line 66...
76
    jnz     @f
66
    DEBUGF  1,"Detected card: %x\n",eax
77
    DEBUGF  1,"DHCP: Ethernet Cable not connected\n"
67
   @@:
78
 
-
 
79
    mov     eax,5
-
 
80
    mov     ebx,500		       ; loop until cable is connected (check every 5 sec)
-
 
81
    int     0x40
-
 
82
 
-
 
83
    jmp     @r
-
 
84
 
-
 
85
   @@:
-
 
86
    DEBUGF  1,"DHCP: Ethernet Cable status: %d\n",al
-
 
87
 
-
 
Line 88... Line 68...
88
    eth.read_mac MAC
68
    eth.check_cable eax
89
    DEBUGF  1,"DHCP: MAC address: %x-%x-%x-%x-%x-%x\n",[MAC]:2,[MAC+1]:2,[MAC+2]:2,[MAC+3]:2,[MAC+4]:2,[MAC+5]:2
69
    test    al,al
90
 
70
    jnz     @f
Line 91... Line 71...
91
;    jmp     apipa   ; comment this out if you want to skip DHCP and continue with link-local
71
    DEBUGF  1,"Ethernet Cable not connected\n"
92
 
72
    wait 500				    ; loop until cable is connected (check every 5 sec)
Line 93... Line 73...
93
;***************************************************************************
73
    jmp     @r
94
;
74
 
95
;  DHCP rubish starts here
75
   @@:
96
;
76
    DEBUGF  1,"Ethernet Cable status: %d\n",al
97
;***************************************************************************
77
 
98
 
78
    eth.read_mac MAC
Line 99... Line 79...
99
 
79
    DEBUGF  1,"MAC address: %x-%x-%x-%x-%x-%x\n",[MAC]:2,[MAC+1]:2,[MAC+2]:2,[MAC+3]:2,[MAC+4]:2,[MAC+5]:2
100
 
-
 
101
    eth.check_port 68,eax	       ; Check if port 68 is available
-
 
102
    cmp     eax,1
80
 
103
    je	    @f
81
    eth.check_port 68,eax		    ; Check if port 68 is available
Line 104... Line -...
104
 
-
 
105
    DEBUGF  1,"DHCP: Port 68 is already in use.\n"
-
 
106
    jmp     close
-
 
107
 
-
 
108
   @@:
-
 
109
    eth.open_udp 68,67,-1,[socketNum]  ; open socket (local,remote,ip,socket)
82
    cmp     eax,1
110
    DEBUGF  1,"DHCP: Socket opened: %d\n",eax
-
 
111
				       ; Setup the first msg we will send
-
 
112
    mov     byte [dhcpMsgType], 0x01   ; DHCP discover
-
 
113
    mov     dword [dhcpLease], esi     ; esi is still -1 (-1 = forever)
83
    je	    @f
114
 
84
 
115
    mov     eax,26
85
    DEBUGF  1,"Port 68 is already in use!\n"
116
    mov     ebx,9
86
    jmp     close
117
    int     0x40
87
 
Line 140... Line 110...
140
    mov     [edx+2], byte 0x06		    ; Ethernet h/w len
110
    mov     [edx+2], byte 0x06		    ; Ethernet h/w len
141
    mov     [edx+4], dword 0x11223344	    ; xid
111
    mov     [edx+4], dword 0x11223344	    ; xid
142
    mov     eax,[currTime]
112
    mov     eax,[currTime]
143
    mov     [edx+8], eax		    ; secs, our uptime
113
    mov     [edx+8], eax		    ; secs, our uptime
144
    mov     [edx+10], byte 0x80 	    ; broadcast flag set
114
    mov     [edx+10], byte 0x80 	    ; broadcast flag set
145
 
-
 
146
    mov     eax, dword [MAC]		    ; first 4 bytes of MAC
115
    mov     eax, dword [MAC]		    ; first 4 bytes of MAC
147
    mov     [edx+28],dword eax
116
    mov     [edx+28],dword eax
148
    mov     ax, word [MAC+4]		    ; last 2 bytes of MAC
117
    mov     ax, word [MAC+4]		    ; last 2 bytes of MAC
149
    mov     [edx+32],word ax
118
    mov     [edx+32],word ax
150
 
-
 
151
    mov     [edx+236], dword 0x63538263     ; magic number
119
    mov     [edx+236], dword 0x63538263     ; magic number
152
 
-
 
153
    mov     [edx+240], word 0x0135	    ; option DHCP msg type
120
    mov     [edx+240], word 0x0135	    ; option DHCP msg type
154
    mov     al, [dhcpMsgType]
121
    mov     al, [dhcpMsgType]
155
    mov     [edx+240+2], al
122
    mov     [edx+240+2], al
156
 
-
 
157
    mov     [edx+240+3], word 0x0433	    ; option Lease time = infinity
123
    mov     [edx+240+3], word 0x0433	    ; option Lease time = infinity
158
    mov     eax, [dhcpLease]
124
    mov     eax, [dhcpLease]
159
    mov     [edx+240+5], eax
125
    mov     [edx+240+5], eax
160
 
-
 
161
    mov     [edx+240+9], word 0x0432	    ; option requested IP address
126
    mov     [edx+240+9], word 0x0432	    ; option requested IP address
162
    mov     eax, [dhcpClientIP]
127
    mov     eax, [dhcpClientIP]
163
    mov     [edx+240+11], eax
128
    mov     [edx+240+11], eax
164
 
-
 
165
    mov     [edx+240+15], word 0x0437	    ; option request list
129
    mov     [edx+240+15], word 0x0437	    ; option request list
166
    mov     [edx+240+17], dword 0x0f060301
130
    mov     [edx+240+17], dword 0x0f060301
Line 167... Line 131...
167
 
131
 
168
    cmp     [dhcpMsgType], byte 0x01	    ; Check which msg we are sending
132
    cmp     [dhcpMsgType], byte 0x01	    ; Check which msg we are sending
Line 169... Line 133...
169
    jne     br001
133
    jne     request_options
Line 170... Line 134...
170
 
134
 
171
    mov     [edx+240+21], byte 0xff	    ; "Discover" options
135
    mov     [edx+240+21], byte 0xff	    ; "Discover" options
172
 
-
 
173
    mov     [dhcpMsgLen], dword 262	    ; end of options marker
-
 
Line -... Line 136...
-
 
136
 
174
    jmp     ctr000
137
    mov     [dhcpMsgLen], dword 262	    ; end of options marker
175
 
138
    jmp     send_request
176
br001:					    ; "Request" options
139
 
Line 177... Line 140...
177
 
140
request_options:
Line 178... Line 141...
178
    mov     [edx+240+21], word 0x0436	    ; server IP
141
    mov     [edx+240+21], word 0x0436	    ; server IP
Line 179... Line 142...
179
    mov     eax, [dhcpServerIP]
142
    mov     eax, [dhcpServerIP]
180
    mov     [edx+240+23], eax
-
 
181
 
143
    mov     [edx+240+23], eax
Line 182... Line 144...
182
    mov     [edx+240+27], byte 0xff	    ; end of options marker
144
 
183
 
145
    mov     [edx+240+27], byte 0xff	    ; end of options marker
Line 195... Line 157...
195
    int     0x40
157
    int     0x40
Line 196... Line 158...
196
 
158
 
Line 197... Line 159...
197
    eth.poll [socketNum]
159
    eth.poll [socketNum]
198
 
160
 
Line 199... Line 161...
199
    test    eax,eax
161
    test    eax,eax
200
    jnz     ctr002
162
    jnz     read_data
201
 
163
 
Line 202... Line 164...
202
    DEBUGF  2,"DHCP: Timeout!\n"
164
    DEBUGF  2,"Timeout!\n"
203
    eth.close_udp [socketNum]
165
    eth.close_udp [socketNum]
204
    jmp    apipa			    ; no server found, lets try zeroconf
166
    jmp    apipa			    ; no server found, lets try zeroconf
205
 
167
 
Line 206... Line 168...
206
 
168
 
Line 238... Line 200...
238
    call     parseResponse
200
    call    parseResponse
Line 239... Line 201...
239
 
201
 
240
    cmp     [dhcpMsgType], byte 0x05	    ; Was the response an ACK? It should be
202
    cmp     [dhcpMsgType], byte 0x05	    ; Was the response an ACK? It should be
Line 241... Line -...
241
    jne     apipa			    ; NO - so we do zeroconf
-
 
242
 
-
 
243
close:
-
 
244
    DEBUGF  1,"DHCP: Exiting\n"
-
 
245
 
203
    jne     apipa			    ; NO - so we do zeroconf
246
    mov     eax,-1			    ; at last, exit
-
 
Line 247... Line 204...
247
    int     0x40
204
 
248
 
205
    jmp     close
249
 
206
 
250
;***************************************************************************
207
;***************************************************************************
Line 259... Line 216...
259
;       dhcpDNSIP, dhcpSubnet
216
;       dhcpDNSIP, dhcpSubnet
260
;      The message is stored in dhcpMsg
217
;      The message is stored in dhcpMsg
261
;
218
;
262
;***************************************************************************
219
;***************************************************************************
263
parseResponse:
220
parseResponse:
264
    DEBUGF  1,"DHCP: Data received, parsing response\n"
221
    DEBUGF  1,"Data received, parsing response\n"
265
    mov     edx, dhcpMsg
222
    mov     edx, dhcpMsg
Line 266... Line 223...
266
 
223
 
267
    pusha
224
    pusha
268
    eth.set_IP [edx+16]
225
    eth.set_IP [edx+16]
269
    mov     eax,[edx]
226
    mov     eax,[edx]
270
    mov     [dhcpClientIP],eax
227
    mov     [dhcpClientIP],eax
271
    DEBUGF  1,"DHCP: Client: %u.%u.%u.%u\n",[edx+16]:1,[edx+17]:1,[edx+18]:1,[edx+19]:1
228
    DEBUGF  1,"Client: %u.%u.%u.%u\n",[edx+16]:1,[edx+17]:1,[edx+18]:1,[edx+19]:1
Line 272... Line 229...
272
    popa
229
    popa
-
 
230
 
Line -... Line 231...
-
 
231
    add     edx, 240			    ; Point to first option
-
 
232
    xor     ecx, ecx
273
 
233
 
274
    add     edx, 240	    ; Point to first option
234
next_option:
275
 
235
    add     edx, ecx
276
pr001:
236
pr001:
Line 277... Line 237...
277
    mov     al, [edx]
237
    mov     al, [edx]
278
    cmp     al, 0xff	    ; End of options?
238
    cmp     al, 0xff			    ; End of options?
Line 279... Line 239...
279
    je	    pr_exit
239
    je	    pr_exit
280
 
240
 
281
    cmp     al, 53	    ; Msg type is a single byte option
241
    cmp     al, dhcp_msg_type		    ; Msg type is a single byte option
282
    jne     pr002
242
    jne     @f
Line 283... Line 243...
283
 
243
 
284
    mov     al, [edx+2]
244
    mov     al, [edx+2]
285
    mov     [dhcpMsgType], al
245
    mov     [dhcpMsgType], al
286
    add     edx, 3
246
    add     edx, 3
Line 287... Line 247...
287
    jmp     pr001	    ; Get next option
247
    jmp     pr001			    ; Get next option
288
 
248
 
289
pr002:
249
@@:
290
    inc     edx
250
    inc     edx
291
    movzx   ecx, byte [edx]
251
    movzx   ecx, byte [edx]
292
    inc     edx 	    ; point to data
252
    inc     edx 			    ; point to data
Line 293... Line 253...
293
 
253
 
294
    cmp     al, 54	    ; server id
254
    cmp     al, dhcp_dhcp_server_id	    ; server ip
295
    jne     pr0021
255
    jne     @f
Line 296... Line 256...
296
    mov     eax, [edx]	    ; All options are 4 bytes, so get it
256
    mov     eax, [edx]
297
    mov     [dhcpServerIP], eax
-
 
298
    DEBUGF  1,"DHCP: Server: %u.%u.%u.%u\n",[edx]:1,[edx+1]:1,[edx+2]:1,[edx+3]:1
257
    mov     [dhcpServerIP], eax
299
    jmp     pr003
258
    DEBUGF  1,"Server: %u.%u.%u.%u\n",[edx]:1,[edx+1]:1,[edx+2]:1,[edx+3]:1
300
 
259
    jmp     next_option
301
pr0021:
-
 
302
    cmp     al, 51	    ; lease
-
 
303
    jne     pr0022
-
 
304
 
-
 
305
    pusha
-
 
306
    DEBUGF  1,"DHCP: lease: "
260
 
307
    mov eax,[edx]
-
 
308
    bswap eax
261
@@:
Line 309... Line 262...
309
    mov  [dhcpLease],eax
262
    cmp     al, dhcp_address_time
Line 310... Line 263...
310
    cmp  dword[edx],-1	    ; i really don't know, how to test it
263
    jne     @f
311
    jne  no_lease_forever
264
 
312
    DEBUGF  1,"forever\n"
265
    pusha
Line 313... Line 266...
313
    jmp  @f
266
    mov     eax,[edx]
314
   no_lease_forever:
267
    bswap   eax
315
    DEBUGF  1,"%d\n",eax
268
    mov     [dhcpLease],eax
316
   @@:
269
    DEBUGF  1,"lease: %d\n",eax
Line 317... Line 270...
317
    popa
270
    popa
Line 318... Line 271...
318
 
271
 
319
    jmp     pr003
272
    jmp     next_option
320
 
273
 
Line 321... Line 274...
321
pr0022:
274
@@:
322
    cmp     al, 1	    ; subnet mask
275
    cmp     al, dhcp_subnet_mask
323
    jne     pr0023
276
    jne     @f
324
 
277
 
Line -... Line 278...
-
 
278
    pusha
-
 
279
    eth.set_SUBNET [edx]
Line 325... Line 280...
325
    pusha
280
    DEBUGF  1,"Subnet: %u.%u.%u.%u\n",[edx]:1,[edx+1]:1,[edx+2]:1,[edx+3]:1
326
    eth.set_SUBNET [edx]
281
    popa
327
    DEBUGF  1,"DHCP: Subnet: %u.%u.%u.%u\n",[edx]:1,[edx+1]:1,[edx+2]:1,[edx+3]:1
282
 
Line 328... Line 283...
328
    popa
283
    jmp     next_option
329
 
284
 
330
    jmp     pr003
285
@@:
331
 
286
    cmp     al, dhcp_router
Line 332... Line -...
332
pr0023:
-
 
333
    cmp     al, 3	    ; gateway ip
-
 
334
    jne     pr0024
-
 
335
 
287
    jne     @f
Line 336... Line 288...
336
    pusha
288
 
Line 337... Line 289...
337
    eth.set_GATEWAY [edx]
289
    pusha
338
    DEBUGF  1,"DHCP: Gateway: %u.%u.%u.%u\n",[edx]:1,[edx+1]:1,[edx+2]:1,[edx+3]:1
290
    eth.set_GATEWAY [edx]
Line 339... Line 291...
339
    popa
291
    DEBUGF  1,"Gateway: %u.%u.%u.%u\n",[edx]:1,[edx+1]:1,[edx+2]:1,[edx+3]:1
Line 340... Line 292...
340
 
292
    popa
341
 
293
 
342
pr0024:
294
    jmp     next_option
343
    cmp     al, 6	    ; dns ip
295
 
344
    jne     pr003
296
 
345
 
297
@@:
346
    pusha
298
    cmp     al, dhcp_domain_server
347
    eth.set_DNS [edx]
299
    jne     next_option
348
    DEBUGF  1,"DHCP: DNS: %u.%u.%u.%u\n",[edx]:1,[edx+1]:1,[edx+2]:1,[edx+3]:1
300
 
Line 349... Line -...
349
    popa
-
 
350
 
301
    pusha
351
 
-
 
Line 352... Line 302...
352
pr003:
302
    eth.set_DNS [edx]
353
    add     edx, ecx
303
    DEBUGF  1,"DNS: %u.%u.%u.%u\n",[edx]:1,[edx+1]:1,[edx+2]:1,[edx+3]:1
354
    jmp     pr001
304
    popa
Line 387... Line 337...
387
    jle   @f
337
    jle   @f
388
    sub   al,(PROBE_MAX-PROBE_MIN)*100
338
    sub   al,(PROBE_MAX-PROBE_MIN)*100
389
   @@:
339
   @@:
Line 390... Line 340...
390
 
340
 
391
    movzx ebx,al
341
    movzx ebx,al
392
    DEBUGF  1,"ZeroConf: Waiting %u0ms\n",ebx
342
    DEBUGF  1,"Waiting %u0ms\n",ebx
393
    mov   eax,5
-
 
Line 394... Line 343...
394
    int   0x40
343
    wait  ebx
395
 
344
 
396
    DEBUGF  1,"ZeroConf: Sending Probe\n"
345
    DEBUGF  1,"Sending Probe\n"
Line 397... Line 346...
397
;    eth.ARP_PROBE MAC2
346
;    eth.ARP_PROBE MAC
398
    inc   esi
347
    inc   esi
Line 399... Line 348...
399
 
348
 
400
    cmp   esi,PROBE_NUM
349
    cmp   esi,PROBE_NUM
Line 401... Line 350...
401
    jl	  probe_loop
350
    jl	  probe_loop
402
 
-
 
403
; now we wait further ANNOUNCE_WAIT seconds and send ANNOUNCE_NUM ARP announces. If any other host has assingnd
351
 
404
; IP within this time, we should create another adress, that have to be done later
-
 
405
 
-
 
406
    DEBUGF  1,"ZeroConf: Waiting %us\n",ANNOUNCE_WAIT
352
; now we wait further ANNOUNCE_WAIT seconds and send ANNOUNCE_NUM ARP announces. If any other host has assingned
407
    mov   eax,5
353
; IP within this time, we should create another adress, that have to be done later
Line 408... Line 354...
408
    mov   ebx,ANNOUNCE_WAIT*100
354
 
409
    int   0x40
355
    DEBUGF  1,"Waiting %us\n",ANNOUNCE_WAIT
Line 410... Line 356...
410
 
356
    wait ANNOUNCE_WAIT*100
411
    xor   esi,esi
357
    xor   esi,esi
412
   announce_loop:
358
   announce_loop:
Line 413... Line 359...
413
 
359
 
414
    DEBUGF  1,"ZeroConf: Sending Announce\n"
-
 
415
;    eth.ARP_ANNOUNCE MAC2
360
    DEBUGF  1,"Sending Announce\n"
416
 
-
 
417
    inc   esi
-
 
418
    cmp   esi,ANNOUNCE_NUM
361
;    eth.ARP_ANNOUNCE MAC
419
    je	  @f
362
 
420
 
363
    inc   esi
-
 
364
    cmp   esi,ANNOUNCE_NUM
-
 
365
    je	  @f
-
 
366
 
-
 
367
    DEBUGF  1,"Waiting %us\n",ANNOUNCE_INTERVAL
-
 
368
    wait  ANNOUNCE_INTERVAL*100
Line 421... Line 369...
421
    DEBUGF  1,"ZeroConf: Waiting %us\n",ANNOUNCE_INTERVAL
369
    jmp   announce_loop
-
 
370
   @@:
422
    mov   eax,5
371
    ; we should, instead of closing, detect ARP conflicts and detect if cable keeps connected ;)
423
    mov   ebx,ANNOUNCE_INTERVAL*100
372
 
424
    int   0x40
373
close:
425
 
374
    DEBUGF  1,"Exiting\n"
426
    jmp   announce_loop
375
    exit				    ; at last, exit
427
   @@:
376
 
428
    jmp   close   ; we should, instead of closing, detect ARP conflicts and detect if cable keeps connected ;)
377
 
429
 
378
random:
430
random:
-
 
431
    mov   eax,[generator]
-
 
Line -... Line 379...
-
 
379
 
Line 432... Line 380...
432
    add   eax,-43ab45b5h
380
    mov   eax,[generator]
Line 433... Line 381...
433
    ror   eax,1
381
    add   eax,-43ab45b5h
Line 434... Line 382...
434
    bswap eax
382
    ror   eax,1
Line 435... Line 383...
435
    xor   eax,dword[MAC]
383
    bswap eax
436
    ror   eax,1
384
    xor   eax,dword[MAC]