Subversion Repositories Kolibri OS

Rev

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

Rev 3148 Rev 3159
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
2
;;                                                                 ;;
3
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved.    ;;
3
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved.    ;;
4
;; Distributed under terms of the GNU General Public License       ;;
4
;; Distributed under terms of the GNU General Public License       ;;
5
;;                                                                 ;;
5
;;                                                                 ;;
6
;;  ARP.INC                                                        ;;
6
;;  ARP.INC                                                        ;;
7
;;                                                                 ;;
7
;;                                                                 ;;
8
;;  Part of the tcp/ip network stack for KolibriOS                 ;;
8
;;  Part of the tcp/ip network stack for KolibriOS                 ;;
Line 14... Line 14...
14
;;          GNU GENERAL PUBLIC LICENSE                             ;;
14
;;          GNU GENERAL PUBLIC LICENSE                             ;;
15
;;             Version 2, June- 1991                               ;;
15
;;             Version 2, June- 1991                               ;;
16
;;                                                                 ;;
16
;;                                                                 ;;
17
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
17
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 18... Line 18...
18
 
18
 
Line 19... Line 19...
19
$Revision: 3148 $
19
$Revision: 3159 $
20
 
20
 
21
ARP_NO_ENTRY            = 0
21
ARP_NO_ENTRY            = 0
22
ARP_VALID_MAPPING       = 1
22
ARP_VALID_MAPPING       = 1
Line 155... Line 155...
155
;
155
;
156
;  IN:  Pointer to buffer in [esp]
156
;  IN:  Pointer to buffer in [esp]
157
;       size of buffer in [esp+4]
157
;       size of buffer in [esp+4]
158
;       packet size (without ethernet header) in ecx
158
;       packet size (without ethernet header) in ecx
159
;       packet ptr in edx
159
;       packet ptr in edx
-
 
160
;       device ptr in ebx
160
;  OUT: /
161
;  OUT: /
161
;
162
;
162
;-----------------------------------------------------------------
163
;-----------------------------------------------------------------
163
align 4
164
align 4
164
ARP_input:
165
ARP_input:
Line -... Line 166...
-
 
166
 
-
 
167
        call    NET_ptr_to_num
-
 
168
        cmp     edi, -1
-
 
169
        jz      .exit
165
 
170
 
166
        cmp     ecx, sizeof.ARP_header
171
        cmp     ecx, sizeof.ARP_header
Line 167... Line 172...
167
        jb      .exit
172
        jb      .exit
168
 
173
 
Line 169... Line 174...
169
;---------------------
174
;---------------------
170
; Handle Reply packets
175
; Handle reply packets
Line 171... Line 176...
171
 
176
 
172
        cmp     [edx + ARP_header.Opcode], ARP_REP_OPCODE
177
        cmp     [edx + ARP_header.Opcode], ARP_REP_OPCODE
173
        jne     .maybe_request
178
        jne     .maybe_request
Line -... Line 179...
-
 
179
 
-
 
180
        DEBUGF  1,"ARP_input: got reply packet from %u.%u.%u.%u\n",\
174
 
181
        [edx + ARP_header.SenderIP]:1, [edx + ARP_header.SenderIP + 1]:1,\
175
        DEBUGF  1,"ARP_input: got reply packet from %u.%u.%u.%u\n",\
182
        [edx + ARP_header.SenderIP + 2]:1, [edx + ARP_header.SenderIP + 3]:1
176
        [edx + ARP_header.SenderIP]:1, [edx + ARP_header.SenderIP + 1]:1,\
183
 
Line 177... Line 184...
177
        [edx + ARP_header.SenderIP + 2]:1, [edx + ARP_header.SenderIP + 3]:1
184
        inc     [ARP_PACKETS_RX + 4*edi]
-
 
185
 
-
 
186
        mov     ecx, [NumARP]
178
 
187
        test    ecx, ecx
179
        mov     ecx, [NumARP]
188
        jz      .exit
180
        test    ecx, ecx
189
 
181
        jz      .exit
190
        mov     eax, [edx + ARP_header.SenderIP]
182
 
191
        cmp     eax, [IP_LIST + 4*edi]                  ; check for IP collision
Line 208... Line 217...
208
        mov     cx, word [edx + ARP_header.SenderMAC + 4]
217
        mov     cx, word [edx + ARP_header.SenderMAC + 4]
209
        mov     word [esi + ARP_entry.MAC + 4], cx
218
        mov     word [esi + ARP_entry.MAC + 4], cx
Line 210... Line 219...
210
 
219
 
Line -... Line 220...
-
 
220
        jmp     .exit
-
 
221
 
-
 
222
  .collision:
-
 
223
        DEBUGF  1,"ARP_input: IP address conflict detected!\n"
Line 211... Line 224...
211
        jmp     .exit
224
 
212
 
225
        jmp     .exit
Line 213... Line 226...
213
 
226
 
214
;-----------------------
227
;-----------------------
215
; Handle Request packets
228
; Handle request packets
Line 216... Line -...
216
 
-
 
217
  .maybe_request:
-
 
218
        cmp     [edx + ARP_header.Opcode], ARP_REQ_OPCODE
-
 
219
        jne     .exit
229
 
220
 
230
  .maybe_request:
Line 221... Line 231...
221
        call    NET_ptr_to_num
231
        cmp     [edx + ARP_header.Opcode], ARP_REQ_OPCODE
222
        cmp     edi, -1
232
        jne     .exit
Line 288... Line 298...
288
align 4
298
align 4
289
ARP_output_request:
299
ARP_output_request:
Line 290... Line 300...
290
 
300
 
291
        push    eax                             ; DestIP
301
        push    eax                             ; DestIP
-
 
302
        pushd   [IP_LIST + edi]                 ; SenderIP
Line 292... Line 303...
292
        pushd   [IP_LIST + edi]                 ; SenderIP
303
        inc     [ARP_PACKETS_TX + edi]          ; assume we will succeed
293
 
304
 
Line 294... Line 305...
294
        DEBUGF  1,"ARP_output_request: ip=%u.%u.%u.%u\n",\
305
        DEBUGF  1,"ARP_output_request: ip=%u.%u.%u.%u\n",\