Subversion Repositories Kolibri OS

Rev

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

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