Subversion Repositories Kolibri OS

Rev

Rev 2859 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1164 hidnplayr 1
; Zero-config
2
; v 1.4
3
;
4
; DHCP code is based on that by Mike Hibbet (DHCP client for menuetos)
5
;
6
; Written by HidnPlayr & Derpenguin
7
 
2856 hidnplayr 8
format binary as ""
9
 
1164 hidnplayr 10
use32
2856 hidnplayr 11
               org    0x0
1164 hidnplayr 12
 
2856 hidnplayr 13
               db     'MENUET01'            ; 8 byte id
14
               dd     0x01                  ; header version
15
               dd     START                 ; start of code
16
               dd     IM_END                ; size of image
17
               dd     (I_END+0x100)         ; memory for app
18
               dd     (I_END+0x100)         ; esp
19
               dd     0x0 , path            ; I_Param , I_Icon
1164 hidnplayr 20
 
21
; CONFIGURATION
22
 
23
 
2856 hidnplayr 24
TIMEOUT             equ 60                  ; in seconds
25
BUFFER              equ 1024                ; in bytes
26
__DEBUG__           equ 1                   ; enable/disable
27
__DEBUG_LEVEL__     equ 1                   ; 1 = all, 2 = errors
1164 hidnplayr 28
 
29
; CONFIGURATION FOR LINK-LOCAL
30
 
2856 hidnplayr 31
PROBE_WAIT          equ 1                   ; second  (initial random delay)
32
PROBE_MIN           equ 1                   ; second  (minimum delay till repeated probe)
33
PROBE_MAX           equ 2                   ; seconds (maximum delay till repeated probe)
34
PROBE_NUM           equ 3                   ;         (number of probe packets)
1164 hidnplayr 35
 
2856 hidnplayr 36
ANNOUNCE_NUM        equ 2                   ;         (number of announcement packets)
37
ANNOUNCE_INTERVAL   equ 2                   ; seconds (time between announcement packets)
38
ANNOUNCE_WAIT       equ 2                   ; seconds (delay before announcing)
1164 hidnplayr 39
 
2856 hidnplayr 40
MAX_CONFLICTS       equ 10                  ;         (max conflicts before rate limiting)
1164 hidnplayr 41
 
2856 hidnplayr 42
RATE_LIMIT_INTERVAL equ 60                  ; seconds (delay between successive attempts)
1164 hidnplayr 43
 
2856 hidnplayr 44
DEFEND_INTERVAL     equ 10                  ; seconds (min. wait between defensive ARPs)
1164 hidnplayr 45
 
46
 
1166 hidnplayr 47
include '../proc32.inc'
48
include '../macros.inc'
49
include '../debug-fdo.inc'
1542 hidnplayr 50
include '../network.inc'
1164 hidnplayr 51
include 'dhcp.inc'
2856 hidnplayr 52
include '../dll.inc'
1164 hidnplayr 53
 
54
 
55
Ip2dword:
56
    push    edx
57
 
58
    ; This code validates if the query is an IP containing 4 numbers and 3 dots
59
 
2856 hidnplayr 60
    xor     al, al            ; make al (dot count) zero
1164 hidnplayr 61
 
62
   @@:
63
    cmp     byte[edx],'0'     ; check if this byte is a number, if not jump to no_IP
2856 hidnplayr 64
    jl      no_IP             ;
1164 hidnplayr 65
    cmp     byte[edx],'9'     ;
2856 hidnplayr 66
    jg      no_IP             ;
1164 hidnplayr 67
 
2856 hidnplayr 68
    inc     edx               ; the byte was a number, so lets check the next byte
1164 hidnplayr 69
 
70
    cmp     byte[edx],0       ; is this byte zero? (have we reached end of query?)
2856 hidnplayr 71
    jz      @f                ; jump to next @@ then
1164 hidnplayr 72
    cmp     byte[edx],':'
2856 hidnplayr 73
    jz      @f
1164 hidnplayr 74
 
75
    cmp     byte[edx],'.'     ; is this byte a dot?
2856 hidnplayr 76
    jne     @r                ; if not, jump to previous @@
1164 hidnplayr 77
 
2856 hidnplayr 78
    inc     al                ; the byte was a dot so increment al(dot count)
79
    inc     edx               ; next byte
80
    jmp     @r                ; lets check for numbers again (jump to previous @@)
1164 hidnplayr 81
 
2856 hidnplayr 82
   @@:                        ; we reach this when end of query reached
83
    cmp     al,3              ; check if there where 3 dots
84
    jnz     no_IP             ; if not, jump to no_IP
1164 hidnplayr 85
 
86
    ; The following code will convert this IP into a dword and output it in eax
87
    ; If there is also a port number specified, this will be returned in ebx, otherwise ebx is -1
88
 
2856 hidnplayr 89
    pop     esi               ; edx (query address) was pushed onto stack and is now popped in esi
1164 hidnplayr 90
 
2856 hidnplayr 91
    xor     edx, edx          ; result
92
    xor     eax, eax          ; current character
93
    xor     ebx, ebx          ; current byte
1164 hidnplayr 94
 
95
.outer_loop:
96
    shl     edx, 8
97
    add     edx, ebx
98
    xor     ebx, ebx
99
.inner_loop:
100
    lodsb
101
    test    eax, eax
2856 hidnplayr 102
    jz      .finish
1164 hidnplayr 103
    cmp     al, '.'
2856 hidnplayr 104
    jz      .outer_loop
1164 hidnplayr 105
    sub     eax, '0'
106
    imul    ebx, 10
107
    add     ebx, eax
108
    jmp     .inner_loop
109
.finish:
110
    shl     edx, 8
111
    add     edx, ebx
112
 
2856 hidnplayr 113
    bswap   edx               ; we want little endian order
1164 hidnplayr 114
 
115
    ret
116
 
117
no_IP:
118
    pop     edx
119
    xor     edx, edx
120
 
121
    ret
122
 
123
 
124
 
125
 
126
 
127
 
2856 hidnplayr 128
START:                                      ; start of execution
1164 hidnplayr 129
 
2856 hidnplayr 130
        mcall   40, 1 shl 7 ; network event
1164 hidnplayr 131
 
2856 hidnplayr 132
        DEBUGF  1,">Zero-config service:\n"
1164 hidnplayr 133
 
2856 hidnplayr 134
        mcall   76, API_ETH + 4
1164 hidnplayr 135
 
2856 hidnplayr 136
        cmp     eax, -1
137
        je      exit
1164 hidnplayr 138
 
2856 hidnplayr 139
        mov     word[MAC], bx
140
        mov     dword[MAC+2], eax
1164 hidnplayr 141
 
2856 hidnplayr 142
        DEBUGF  1,"->MAC: %x-%x-%x-%x-%x-%x\n",[MAC]:2,[MAC+1]:2,[MAC+2]:2,[MAC+3]:2,[MAC+4]:2,[MAC+5]:2
1164 hidnplayr 143
 
2856 hidnplayr 144
        cld
145
        mov     edi, path      ; Calculate the length of zero-terminated string
146
        xor     al , al
147
        mov     ecx, 1024
148
        repnz   scas byte[es:edi]
149
        dec     edi
1174 hidnplayr 150
 
2856 hidnplayr 151
        mov     esi, filename
152
        movsd
153
        movsb
1174 hidnplayr 154
 
2856 hidnplayr 155
        DEBUGF  1,"->path to ini: %s\n", path
1164 hidnplayr 156
 
2856 hidnplayr 157
        mcall   68,11
1164 hidnplayr 158
 
2856 hidnplayr 159
        stdcall dll.Load,@IMPORT
160
        or      eax,eax
161
        jnz     skip_ini
1164 hidnplayr 162
 
163
 
2856 hidnplayr 164
        invoke ini.get_str, path, str_ipconfig, str_type, inibuf, 16, 0
1164 hidnplayr 165
 
2856 hidnplayr 166
        mov    eax,dword[inibuf]
1164 hidnplayr 167
 
2856 hidnplayr 168
        cmp    eax,'stat'
169
        jne    skip_ini
1164 hidnplayr 170
 
2856 hidnplayr 171
        invoke ini.get_str, path, str_ipconfig, str_ip, inibuf, 16, 0
172
        mov    edx, inibuf
173
        call   Ip2dword
174
        mcall  76, API_IPv4 + 3, edx
1164 hidnplayr 175
 
2856 hidnplayr 176
        invoke ini.get_str, path, str_ipconfig, str_gateway, inibuf, 16, 0
177
        mov    edx, inibuf
178
        call   Ip2dword
179
        mcall  76, API_IPv4 + 9, edx
1164 hidnplayr 180
 
2856 hidnplayr 181
        invoke ini.get_str, path, str_ipconfig, str_dns, inibuf, 16, 0
182
        mov    edx, inibuf
183
        call   Ip2dword
184
        mcall  76, API_IPv4 + 5, edx
1164 hidnplayr 185
 
2856 hidnplayr 186
        invoke ini.get_str, path, str_ipconfig, str_subnet, inibuf, 16, 0
187
        mov    edx, inibuf
188
        call   Ip2dword
189
        mcall  76, API_IPv4 + 7, edx
1164 hidnplayr 190
 
191
 
2856 hidnplayr 192
        mcall  -1
1164 hidnplayr 193
 
194
 
195
skip_ini:
196
 
2856 hidnplayr 197
        DEBUGF  1,"->Skip ini\n"
1164 hidnplayr 198
 
2856 hidnplayr 199
        mcall 75, 0, AF_INET4, SOCK_DGRAM, 0      ; open socket (parameters: domain, type, reserved)
200
        cmp   eax, -1
201
        je    error
202
        mov   [socketNum], eax
1164 hidnplayr 203
 
2856 hidnplayr 204
        DEBUGF  1,"->socket %x opened\n", eax
1164 hidnplayr 205
 
2856 hidnplayr 206
        mcall 75, 2, [socketNum], sockaddr1, 18     ; bind socket to local port 68
207
        cmp   eax, -1
208
        je    error
1164 hidnplayr 209
 
2856 hidnplayr 210
        DEBUGF  1,"->Socket Bound to local port 68\n"
1164 hidnplayr 211
 
2856 hidnplayr 212
        mcall 75, 4, [socketNum], sockaddr2, 18     ; connect to 255.255.255.255 on port 67
213
        cmp   eax, -1
214
        je    error
1164 hidnplayr 215
 
2856 hidnplayr 216
        DEBUGF  1,"->Connected to 255.255.255.255 on port 67\n"
1164 hidnplayr 217
 
2856 hidnplayr 218
        mov     byte [dhcpMsgType], 0x01        ; DHCP discover
219
        mov     dword [dhcpLease], esi          ; esi is still -1 (-1 = forever)
1164 hidnplayr 220
 
2856 hidnplayr 221
        mcall   26, 9
222
        imul    eax,100
223
        mov     [currTime],eax
1164 hidnplayr 224
 
2856 hidnplayr 225
buildRequest:                               ; Creates a DHCP request packet.
1164 hidnplayr 226
 
2856 hidnplayr 227
        DEBUGF  1,"->Building request\n"
1164 hidnplayr 228
 
2856 hidnplayr 229
        stdcall mem.Alloc, BUFFER
230
        mov     [dhcpMsg], eax
231
        test    eax,eax
232
        jz      apipa
1164 hidnplayr 233
 
2856 hidnplayr 234
            ;;; todo: skip this bullcrap
1164 hidnplayr 235
 
2856 hidnplayr 236
        mov     edi, eax
237
        mov     ecx, BUFFER
238
        xor     eax, eax
239
        cld
240
        rep     stosb
1164 hidnplayr 241
 
2856 hidnplayr 242
            ;; todo: put this in a buffer instead of writing bytes and words!
1164 hidnplayr 243
 
2856 hidnplayr 244
        mov     edx,[dhcpMsg]
1164 hidnplayr 245
 
2856 hidnplayr 246
        mov     [edx], byte 0x01                ; Boot request
247
        mov     [edx+1], byte 0x01              ; Ethernet
248
        mov     [edx+2], byte 0x06              ; Ethernet h/w len
249
        mov     [edx+4], dword 0x11223344       ; xid                 ;;;;;;;
250
        mov     eax,[currTime]
251
        mov     [edx+8], eax                    ; secs, our uptime
252
        mov     [edx+10], byte 0x80             ; broadcast flag set
253
        mov     eax, dword [MAC]                ; first 4 bytes of MAC
254
        mov     [edx+28],dword eax
255
        mov     ax, word [MAC+4]                ; last 2 bytes of MAC
256
        mov     [edx+32],word ax
257
        mov     [edx+236], dword 0x63538263     ; magic cookie
258
        mov     [edx+240], word 0x0135          ; option DHCP msg type
259
        mov     al, [dhcpMsgType]
260
        mov     [edx+240+2], al
261
        mov     [edx+240+3], word 0x0433        ; option Lease time = infinity
262
        mov     eax, [dhcpLease]
263
        mov     [edx+240+5], eax
264
        mov     [edx+240+9], word 0x0432        ; option requested IP address
2859 hidnplayr 265
        mov     eax, [dhcp.ip]
2856 hidnplayr 266
        mov     [edx+240+11], eax
267
        mov     [edx+240+15], word 0x0437       ; option request list
268
        mov     [edx+240+17], dword 0x0f060301
1164 hidnplayr 269
 
2856 hidnplayr 270
        cmp     [dhcpMsgType], byte 0x01        ; Check which msg we are sending
271
        jne     request_options
1164 hidnplayr 272
 
2856 hidnplayr 273
        mov     [edx+240+21], byte 0xff         ; "Discover" options
1164 hidnplayr 274
 
2856 hidnplayr 275
        mov     [dhcpMsgLen], dword 262         ; end of options marker
276
        jmp     send_request
1514 hidnplayr 277
 
1164 hidnplayr 278
request_options:
2856 hidnplayr 279
        mov     [edx+240+21], word 0x0436       ; server IP
280
        mov     eax, [dhcpServerIP]
281
        mov     [edx+240+23], eax
1164 hidnplayr 282
 
2856 hidnplayr 283
        mov     [edx+240+27], byte 0xff         ; end of options marker
1164 hidnplayr 284
 
2856 hidnplayr 285
        mov     [dhcpMsgLen], dword 268
1164 hidnplayr 286
 
287
send_request:
2856 hidnplayr 288
        mcall   75, 6, [socketNum], [dhcpMsg], [dhcpMsgLen]     ; write to socket ( send broadcast request )
1164 hidnplayr 289
 
2856 hidnplayr 290
        mov     eax, [dhcpMsg]                          ; Setup the DHCP buffer to receive response
291
        mov     [dhcpMsgLen], eax                       ; Used as a pointer to the data
1164 hidnplayr 292
 
2856 hidnplayr 293
        mcall   23, TIMEOUT*10                          ; wait for data
1164 hidnplayr 294
 
2856 hidnplayr 295
read_data:                                              ; we have data - this will be the response
296
        mcall   75, 7, [socketNum], [dhcpMsg], BUFFER   ; read data from socket
1164 hidnplayr 297
 
2856 hidnplayr 298
        DEBUGF  1,"->%d bytes received\n", eax
1164 hidnplayr 299
 
2856 hidnplayr 300
        cmp     eax, -1
301
        je      error
1164 hidnplayr 302
 
2856 hidnplayr 303
        mov     [dhcpMsgLen], eax
1164 hidnplayr 304
 
305
    ; depending on which msg we sent, handle the response
306
    ; accordingly.
307
    ; If the response is to a dhcp discover, then:
308
    ;  1) If response is DHCP OFFER then
309
    ;  1.1) record server IP, lease time & IP address.
310
    ;  1.2) send a request packet
311
    ; If the response is to a dhcp request, then:
312
    ;  1) If the response is DHCP ACK then
313
    ;  1.1) extract the DNS & subnet fields. Set them in the stack
314
 
2856 hidnplayr 315
    cmp     [dhcpMsgType], byte 0x01        ; did we send a discover?
316
    je      discover
317
    cmp     [dhcpMsgType], byte 0x03        ; did we send a request?
318
    je      request
1164 hidnplayr 319
 
2856 hidnplayr 320
        jmp     exit                           ; really unknown, what we did
1164 hidnplayr 321
 
322
discover:
2856 hidnplayr 323
        call    parseResponse
1164 hidnplayr 324
 
2856 hidnplayr 325
        cmp     [dhcpMsgType], byte 0x02        ; Was the response an offer?
326
        jne     apipa                           ; NO - so we do zeroconf
327
        mov     [dhcpMsgType], byte 0x03        ; DHCP request
328
        jmp     buildRequest
1164 hidnplayr 329
 
330
request:
2856 hidnplayr 331
        call    parseResponse
1164 hidnplayr 332
 
2856 hidnplayr 333
        cmp     [dhcpMsgType], byte 0x05        ; Was the response an ACK? It should be
334
        jne     apipa                           ; NO - so we do zeroconf
1164 hidnplayr 335
 
2859 hidnplayr 336
        mcall 76, API_IPv4 + 3, [dhcp.ip]       ; ip
337
        mcall 76, API_IPv4 + 5, [dhcp.dns]      ; dns
338
        mcall 76, API_IPv4 + 7, [dhcp.subnet]   ; subnet
339
        mcall 76, API_IPv4 + 9, [dhcp.gateway]  ; gateway
340
 
2856 hidnplayr 341
        jmp     exit
1164 hidnplayr 342
 
343
;***************************************************************************
344
;   Function
345
;      parseResponse
346
;
347
;   Description
348
;      extracts the fields ( client IP address and options ) from
349
;      a DHCP response
350
;      The values go into
351
;       dhcpMsgType,dhcpLease,dhcpClientIP,dhcpServerIP,
352
;       dhcpDNSIP, dhcpSubnet
353
;      The message is stored in dhcpMsg
354
;
355
;***************************************************************************
356
parseResponse:
357
    DEBUGF  1,"Data received, parsing response\n"
358
    mov     edx, [dhcpMsg]
359
 
2859 hidnplayr 360
    push    dword [edx+16]
361
    pop     [dhcp.ip]
1164 hidnplayr 362
    DEBUGF  1,"Client: %u.%u.%u.%u\n",[edx+16]:1,[edx+17]:1,[edx+18]:1,[edx+19]:1
363
 
2856 hidnplayr 364
    add     edx, 240                        ; Point to first option
1164 hidnplayr 365
    xor     ecx, ecx
366
 
367
next_option:
368
    add     edx, ecx
369
pr001:
370
    mov     al, [edx]
2856 hidnplayr 371
    cmp     al, 0xff                        ; End of options?
372
    je      pr_exit
1164 hidnplayr 373
 
2856 hidnplayr 374
    cmp     al, dhcp_msg_type               ; Msg type is a single byte option
1164 hidnplayr 375
    jne     @f
376
 
377
    mov     al, [edx+2]
378
    mov     [dhcpMsgType], al
2859 hidnplayr 379
 
380
    DEBUGF  1,"DHCP Msg type: %u\n", al
381
 
1164 hidnplayr 382
    add     edx, 3
2856 hidnplayr 383
    jmp     pr001                           ; Get next option
1164 hidnplayr 384
 
385
@@:
386
    inc     edx
387
    movzx   ecx, byte [edx]
2856 hidnplayr 388
    inc     edx                             ; point to data
1164 hidnplayr 389
 
2856 hidnplayr 390
    cmp     al, dhcp_dhcp_server_id         ; server ip
1164 hidnplayr 391
    jne     @f
392
    mov     eax, [edx]
393
    mov     [dhcpServerIP], eax
394
    DEBUGF  1,"Server: %u.%u.%u.%u\n",[edx]:1,[edx+1]:1,[edx+2]:1,[edx+3]:1
395
    jmp     next_option
396
 
397
@@:
398
    cmp     al, dhcp_address_time
399
    jne     @f
400
 
401
    pusha
402
    mov     eax,[edx]
403
    bswap   eax
404
    mov     [dhcpLease],eax
405
    DEBUGF  1,"lease: %d\n",eax
406
    popa
407
 
408
    jmp     next_option
409
 
410
@@:
411
    cmp     al, dhcp_subnet_mask
412
    jne     @f
413
 
2859 hidnplayr 414
    push    dword [edx]
415
    pop     [dhcp.subnet]
1164 hidnplayr 416
    DEBUGF  1,"Subnet: %u.%u.%u.%u\n",[edx]:1,[edx+1]:1,[edx+2]:1,[edx+3]:1
417
    jmp     next_option
418
 
419
@@:
420
    cmp     al, dhcp_router
421
    jne     @f
422
 
2859 hidnplayr 423
    push    dword [edx]
424
    pop     [dhcp.gateway]
1164 hidnplayr 425
    DEBUGF  1,"Gateway: %u.%u.%u.%u\n",[edx]:1,[edx+1]:1,[edx+2]:1,[edx+3]:1
426
    jmp     next_option
427
 
428
 
429
@@:
430
    cmp     al, dhcp_domain_server
431
    jne     next_option
432
 
2859 hidnplayr 433
    push    dword [edx]
434
    pop     [dhcp.dns]
1164 hidnplayr 435
    DEBUGF  1,"DNS: %u.%u.%u.%u\n",[edx]:1,[edx+1]:1,[edx+2]:1,[edx+3]:1
436
    jmp     next_option
437
 
438
pr_exit:
439
 
2856 hidnplayr 440
        ret
441
 
1164 hidnplayr 442
;    DEBUGF  1,"Sending ARP announce\n"
1514 hidnplayr 443
;;;
1164 hidnplayr 444
 
445
 
446
apipa:
2857 hidnplayr 447
        mcall   close, [socketNum]
448
        stdcall mem.Free, [dhcpMsg]
1164 hidnplayr 449
 
450
link_local:
451
    call random
2856 hidnplayr 452
    mov  ecx,0xfea9                         ; IP 169.254.0.0 link local net, see RFC3927
1164 hidnplayr 453
    mov  cx,ax
2856 hidnplayr 454
    mcall 76, API_IPv4 + 3, ecx                          ; mask is 255.255.0.0
1164 hidnplayr 455
    DEBUGF 1,"Link Local IP assinged: 169.254.%u.%u\n",[generator+2]:1,[generator+3]:1
2856 hidnplayr 456
    mcall 76, API_IPv4 + 5, 0xffff
457
    mcall 76, API_IPv4 + 9, 0x0
458
    mcall 76, API_IPv4 + 7, 0x0
1164 hidnplayr 459
 
460
    mcall 5, PROBE_WAIT*100
461
 
462
    xor esi,esi
463
   probe_loop:
2856 hidnplayr 464
    call  random                            ; create a pseudo random number in eax (seeded by MAC)
1164 hidnplayr 465
 
2856 hidnplayr 466
    cmp   al,PROBE_MIN*100                  ; check if al is bigger then PROBE_MIN
467
    jge   @f                                ; all ok
468
    add   al,(PROBE_MAX-PROBE_MIN)*100      ; al is too small
1164 hidnplayr 469
   @@:
470
 
471
    cmp   al,PROBE_MAX*100
472
    jle   @f
473
    sub   al,(PROBE_MAX-PROBE_MIN)*100
474
   @@:
475
 
476
    movzx ebx,al
477
    DEBUGF  1,"Waiting %u0ms\n",ebx
478
    mcall 5
479
 
480
    DEBUGF  1,"Sending Probe\n"
481
;    eth.ARP_PROBE MAC
482
    inc   esi
483
 
484
    cmp   esi,PROBE_NUM
2856 hidnplayr 485
    jl    probe_loop
1164 hidnplayr 486
 
487
; now we wait further ANNOUNCE_WAIT seconds and send ANNOUNCE_NUM ARP announces. If any other host has assingned
488
; IP within this time, we should create another adress, that have to be done later
489
 
490
    DEBUGF  1,"Waiting %us\n",ANNOUNCE_WAIT
491
    mcall 5, ANNOUNCE_WAIT*100
492
    xor   esi,esi
493
   announce_loop:
494
 
495
    DEBUGF  1,"Sending Announce\n"
496
;    eth.ARP_ANNOUNCE MAC
497
 
498
    inc   esi
499
    cmp   esi,ANNOUNCE_NUM
2856 hidnplayr 500
    je    @f
1164 hidnplayr 501
 
502
    DEBUGF  1,"Waiting %us\n",ANNOUNCE_INTERVAL
503
    mcall 5, ANNOUNCE_INTERVAL*100
504
    jmp   announce_loop
505
   @@:
506
    ; we should, instead of closing, detect ARP conflicts and detect if cable keeps connected ;)
507
 
508
error:
1542 hidnplayr 509
exit:
1164 hidnplayr 510
    mcall -1
511
 
512
 
513
random:  ; Pseudo random actually
514
 
515
    mov   eax,[generator]
516
    add   eax,-43ab45b5h
517
    ror   eax,1
518
    bswap eax
519
    xor   eax,dword[MAC]
520
    ror   eax,1
521
    xor   eax,dword[MAC+2]
522
    mov   [generator],eax
523
 
524
ret
525
 
526
; DATA AREA
527
 
528
align 16
529
@IMPORT:
530
 
531
library \
2856 hidnplayr 532
        libini,'libini.obj'
1164 hidnplayr 533
 
2856 hidnplayr 534
import  libini, \
535
        ini.get_str,'ini_get_str'
1164 hidnplayr 536
 
537
include_debug_strings
538
 
539
filename db '.ini',0
540
str_ip db 'ip',0
541
str_subnet db 'subnet',0
542
str_gateway db 'gateway',0
543
str_dns db 'dns',0
544
str_ipconfig db 'ipconfig',0
545
str_type db 'type',0
546
 
547
 
548
sockaddr1:
549
 
2856 hidnplayr 550
        dw AF_INET4
2995 hidnplayr 551
        dw 68 shl 8     ; local port
2856 hidnplayr 552
        dd 0            ; local IP
1164 hidnplayr 553
 
2856 hidnplayr 554
        rb 10
1164 hidnplayr 555
 
556
 
557
sockaddr2:
558
 
2856 hidnplayr 559
        dw AF_INET4
2995 hidnplayr 560
        dw 67 shl 8     ; destination port
2856 hidnplayr 561
        dd -1           ; destination IP
1164 hidnplayr 562
 
2856 hidnplayr 563
        rb 10
1164 hidnplayr 564
 
565
 
566
IM_END:
567
 
2856 hidnplayr 568
inibuf          rb 16
1164 hidnplayr 569
 
2856 hidnplayr 570
dhcpMsgType     db  ?
571
dhcpLease       dd  ?
572
dhcpServerIP    dd  ?
1164 hidnplayr 573
 
2859 hidnplayr 574
dhcp:
575
.ip             dd  ?
576
.subnet         dd  ?
577
.dns            dd  ?
578
.gateway        dd  ?
579
 
580
 
2856 hidnplayr 581
dhcpMsgLen      dd  ?
582
socketNum       dd  ?
1164 hidnplayr 583
 
2856 hidnplayr 584
MAC             dp  ?
1164 hidnplayr 585
 
2856 hidnplayr 586
currTime        dd  ?
587
renewTime       dd  ?
588
generator       dd  ?
1164 hidnplayr 589
 
2856 hidnplayr 590
dhcpMsg         dd  ?
1164 hidnplayr 591
 
592
I_END_2:
593
 
2856 hidnplayr 594
path            rb  1024+5
1164 hidnplayr 595
 
2856 hidnplayr 596
                rb  65536
1542 hidnplayr 597
 
1164 hidnplayr 598
I_END: