Subversion Repositories Kolibri OS

Rev

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

Rev 2890 Rev 2891
Line 12... Line 12...
12
;;          GNU GENERAL PUBLIC LICENSE                             ;;
12
;;          GNU GENERAL PUBLIC LICENSE                             ;;
13
;;             Version 2, June 1991                                ;;
13
;;             Version 2, June 1991                                ;;
14
;;                                                                 ;;
14
;;                                                                 ;;
15
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 16... Line 16...
16
 
16
 
Line 17... Line 17...
17
$Revision: 2890 $
17
$Revision: 2891 $
Line 18... Line 18...
18
 
18
 
Line 114... Line 114...
114
;
114
;
115
;-----------------------------------------------------------------
115
;-----------------------------------------------------------------
116
align 4
116
align 4
117
UDP_input:
117
UDP_input:
Line 118... Line 118...
118
 
118
 
Line 119... Line 119...
119
        DEBUGF  1,"UDP_input, size:%u\n", ecx
119
        DEBUGF  1,"UDP_input: size=%u\n", ecx
Line 120... Line 120...
120
 
120
 
121
        ; First validate, checksum
121
        ; First validate, checksum
Line 127... Line 127...
127
 
127
 
128
        UDP_checksum (edi), (edi+4)
128
        UDP_checksum (edi), (edi+4)
Line 129... Line 129...
129
        jnz     .checksum_mismatch
129
        jnz     .checksum_mismatch
130
 
130
 
Line 131... Line 131...
131
  .no_checksum:
131
  .no_checksum:
Line 132... Line 132...
132
        DEBUGF  1,"UDP Checksum is correct\n"
132
        DEBUGF  1,"UDP_input: checksum ok\n"
133
 
133
 
Line 158... Line 158...
158
        jne     .next_socket
158
        jne     .next_socket
Line 159... Line 159...
159
 
159
 
160
        cmp     [eax + UDP_SOCKET.LocalPort], dx
160
        cmp     [eax + UDP_SOCKET.LocalPort], dx
Line 161... Line 161...
161
        jne     .next_socket
161
        jne     .next_socket
Line 162... Line 162...
162
 
162
 
Line 163... Line 163...
163
        DEBUGF  1,"using socket: %x\n", eax
163
        DEBUGF  1,"UDP_input: socket=%x\n", eax
164
 
164
 
Line 182... Line 182...
182
        lea     ecx, [eax + SOCKET.mutex]
182
        lea     ecx, [eax + SOCKET.mutex]
183
        call    mutex_lock
183
        call    mutex_lock
184
        popa
184
        popa
Line 185... Line 185...
185
 
185
 
186
  .updatesock:
186
  .updatesock:
187
        inc     [UDP_PACKETS_RX]
-
 
-
 
187
        inc     [UDP_PACKETS_RX]        ; Fixme: correct interface?
188
        DEBUGF  1,"Found valid UDP packet for socket %x\n", eax
188
 
189
        movzx   ecx, [esi + UDP_header.Length]
189
        movzx   ecx, [esi + UDP_header.Length]
190
        sub     ecx, sizeof.UDP_header
190
        sub     ecx, sizeof.UDP_header
Line 191... Line 191...
191
        add     esi, sizeof.UDP_header
191
        add     esi, sizeof.UDP_header
Line 196... Line 196...
196
        pusha
196
        pusha
197
        lea     ecx, [eax + SOCKET.mutex]
197
        lea     ecx, [eax + SOCKET.mutex]
198
        call    mutex_lock
198
        call    mutex_lock
199
        popa
199
        popa
Line 200... Line 200...
200
 
200
 
201
        DEBUGF  1,"Changing remote port to: %u\n", cx
201
        DEBUGF  1,"UDP_input: new remote port=%u\n", cx
202
        mov     [eax + UDP_SOCKET.RemotePort], cx
202
        mov     [eax + UDP_SOCKET.RemotePort], cx
Line 203... Line 203...
203
        inc     [eax + UDP_SOCKET.firstpacket]
203
        inc     [eax + UDP_SOCKET.firstpacket]
Line 204... Line 204...
204
 
204
 
205
        jmp     .updatesock
-
 
206
 
205
        jmp     .updatesock
Line 207... Line 206...
207
 
206
 
208
  .checksum_mismatch:
207
 
209
 
208
  .checksum_mismatch:
210
        DEBUGF  2,"UDP_Handler - checksum mismatch\n"
209
        DEBUGF  2,"UDP_input: checksum mismatch\n"
Line 211... Line 210...
211
 
210
 
Line 230... Line 229...
230
;-----------------------------------------------------------------
229
;-----------------------------------------------------------------
Line 231... Line 230...
231
 
230
 
232
align 4
231
align 4
Line 233... Line 232...
233
UDP_output:
232
UDP_output:
Line 234... Line 233...
234
 
233
 
235
        DEBUGF  1,"UDP_output: socket:%x, bytes: %u, data ptr: %x\n", eax, ecx, esi
234
        DEBUGF  1,"UDP_output: socket=%x bytes=%u data_ptr=%x\n", eax, ecx, esi
236
 
235
 
237
        mov     dx, [eax + UDP_SOCKET.RemotePort]
236
        mov     dx, [eax + UDP_SOCKET.RemotePort]
238
        DEBUGF  1,"UDP_output: remote port: %u, ", dx
237
        DEBUGF  1,"UDP_output: remote port=%u, ", dx
239
        rol     dx, 8
238
        rol     dx, 8
240
        rol     edx, 16
239
        rol     edx, 16
Line 241... Line 240...
241
        mov     dx, [eax + UDP_SOCKET.LocalPort]
240
        mov     dx, [eax + UDP_SOCKET.LocalPort]
242
        DEBUGF  1,"local port: %u\n", dx
241
        DEBUGF  1,"local port=%u\n", dx
243
        rol     dx, 8
242
        rol     dx, 8
Line 275... Line 274...
275
        mov     [edi + UDP_header.Checksum], 0
274
        mov     [edi + UDP_header.Checksum], 0
276
        UDP_checksum (edi-4), (edi-8)                           ; FIXME: IPv4 packet could have options..
275
        UDP_checksum (edi-4), (edi-8)                           ; FIXME: IPv4 packet could have options..
Line 277... Line 276...
277
 
276
 
Line 278... Line 277...
278
        inc     [UDP_PACKETS_TX]                                ; FIXME: correct device?
277
        inc     [UDP_PACKETS_TX]                                ; FIXME: correct device?
279
 
-
 
280
        DEBUGF  1,"UDP_output: sending to device %x\n", ebx
278
 
281
 
279
        DEBUGF  1,"UDP_output: sending with device %x\n", ebx
Line 282... Line 280...
282
        call    [ebx + NET_DEVICE.transmit]
280
        call    [ebx + NET_DEVICE.transmit]
283
        ret
281
        ret