Subversion Repositories Kolibri OS

Rev

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

Rev 1173 Rev 1196
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
2
;;                                                                 ;;
3
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved.    ;;
3
;; Copyright (C) KolibriOS team 2004-2009. 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
;;  UDP.INC                                                        ;;
6
;;  UDP.INC                                                        ;;
7
;;                                                                 ;;
7
;;                                                                 ;;
8
;;  Part of the tcp/ip network stack for KolibriOS                 ;;
8
;;  Part of the tcp/ip network stack for KolibriOS                 ;;
Line 71... Line 71...
71
;       pointer to UDP Packet data in edx
71
;       pointer to UDP Packet data in edx
72
;  OUT: /
72
;  OUT: /
73
;
73
;
74
;-----------------------------------------------------------------
74
;-----------------------------------------------------------------
Line 75... Line 75...
75
 
75
 
Line 76... Line 76...
76
UDP_Handler:
76
UDP_handler:
77
 
77
 
Line 78... Line 78...
78
	DEBUGF 1,"UDP_Handler\n"
78
	DEBUGF 1,"UDP_Handler\n"
Line 108... Line 108...
108
	jne	.try_more					      ; Quit if the source IP is not valid, check for more sockets with this IP/PORT combination
108
	jne	.try_more					      ; Quit if the source IP is not valid, check for more sockets with this IP/PORT combination
Line 109... Line 109...
109
 
109
 
110
    @@:
110
    @@:
Line 111... Line -...
111
	DEBUGF 1,"Found valid UDP packet for socket %x\n", esi
-
 
112
 
111
	DEBUGF 1,"Found valid UDP packet for socket %x\n", esi
113
 
112
 
Line 114... Line 113...
114
;        sub     ecx, UDP_Packet.Data                    ; get # of bytes in ecx
113
;        sub     ecx, UDP_Packet.Data                    ; get # of bytes in ecx
115
;        mov     eax, ecx
114
;        mov     eax, ecx
Line 197... Line 196...
197
; Note: UDP works only on top of IP protocol :)
196
; Note: UDP works only on top of IP protocol :)
198
;
197
;
199
; IN: eax = dest ip
198
; IN: eax = dest ip
200
;     ebx = source ip
199
;     ebx = source ip
201
;     ecx = data length
200
;     ecx = data length
202
;     edx = remote port shl 16 + local port
201
;     edx = remote port shl 16 + local port (both in INET order)
203
;     esi = data offset
202
;     esi = data offset
204
;
203
;
205
;-----------------------------------------------------------------
204
;-----------------------------------------------------------------
Line 206... Line 205...
206
 
205
 
Line 207... Line 206...
207
UDP_create_Packet:
206
UDP_create_packet:
Line 208... Line 207...
208
 
207
 
Line 209... Line 208...
209
	DEBUGF 1,"Create UDP Packet\n"
208
	DEBUGF 1,"Create UDP Packet\n"
210
 
209
 
Line 211... Line 210...
211
	push	edx esi
210
	push	edx esi
Line 212... Line 211...
212
 
211
 
213
	add	ecx, UDP_Packet.Data
212
	add	ecx, UDP_Packet.Data
214
	mov	di , IP_PROTO_UDP
213
	mov	di , IP_PROTO_UDP
Line -... Line 214...
-
 
214
 
215
 
215
;       dx  = fragment id
216
;       dx  = fragment id
216
 
217
 
-
 
Line 218... Line 217...
218
	call	IPv4_create_Packet				; TODO: figure out a way to choose between IPv4 and IPv6
217
	call	IPv4_create_packet				; TODO: figure out a way to choose between IPv4 and IPv6
219
	cmp	edi, -1
218
	cmp	edi, -1
220
	je	.exit
219
	je	.exit
221
 
220
 
Line 233... Line 232...
233
	and	cx , 3
232
	and	cx , 3
234
	rep	movsb
233
	rep	movsb
235
	pop	edi
234
	pop	edi
Line 236... Line 235...
236
 
235
 
237
	pop	ecx
236
	pop	ecx
238
	bswap	ecx						; convert little endian - big endian
237
;        bswap   ecx                                             ; convert little endian - big endian
239
	rol	ecx, 16 					;
238
;        rol     ecx, 16                                         ;
Line 240... Line 239...
240
	mov	dword [edi + UDP_Packet.SourcePort], ecx	; notice: we write both port's at once
239
	mov	dword [edi + UDP_Packet.SourcePort], ecx	; notice: we write both port's at once