Rev 3908 | Rev 5201 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3908 | Rev 4265 | ||
---|---|---|---|
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: 3908 $ |
17 | $Revision: 4265 $ |
Line 18... | Line 18... | ||
18 | 18 | ||
Line 180... | Line 180... | ||
180 | ; jne .next_socket |
180 | ; jne .next_socket |
181 | ; @@: |
181 | ; @@: |
182 | ; |
182 | ; |
183 | ; FIXME: UDP should check remote IP, but not under all circumstances! |
183 | ; FIXME: UDP should check remote IP, but not under all circumstances! |
Line 184... | Line 184... | ||
184 | 184 | ||
185 | cmp [eax + UDP_SOCKET.firstpacket], 0 |
185 | cmp [eax + UDP_SOCKET.RemotePort], 0 |
Line 186... | Line 186... | ||
186 | je .updateport |
186 | je .updateport |
187 | 187 | ||
Line 209... | Line 209... | ||
209 | call mutex_lock |
209 | call mutex_lock |
210 | popa |
210 | popa |
Line 211... | Line 211... | ||
211 | 211 | ||
212 | DEBUGF DEBUG_NETWORK_VERBOSE, "UDP_input: new remote port=%x\n", cx ; FIXME: find a way to print big endian values with debugf |
212 | DEBUGF DEBUG_NETWORK_VERBOSE, "UDP_input: new remote port=%x\n", cx ; FIXME: find a way to print big endian values with debugf |
213 | mov [eax + UDP_SOCKET.RemotePort], cx |
- | |
214 | inc [eax + UDP_SOCKET.firstpacket] |
- | |
215 | 213 | mov [eax + UDP_SOCKET.RemotePort], cx |
|
Line 216... | Line 214... | ||
216 | jmp .updatesock |
214 | jmp .updatesock |
Line 217... | Line 215... | ||
217 | 215 | ||
Line 260... | Line 258... | ||
260 | mov dx, [eax + UDP_SOCKET.LocalPort] |
258 | mov dx, [eax + UDP_SOCKET.LocalPort] |
261 | DEBUGF DEBUG_NETWORK_VERBOSE, "local port=%x\n", dx |
259 | DEBUGF DEBUG_NETWORK_VERBOSE, "local port=%x\n", dx |
Line 262... | Line 260... | ||
262 | 260 | ||
263 | sub esp, 8 ; Data ptr and data size will be placed here |
261 | sub esp, 8 ; Data ptr and data size will be placed here |
264 | push edx esi |
- | |
265 | mov ebx, [eax + SOCKET.device] |
262 | push edx esi |
266 | mov edx, [eax + IP_SOCKET.LocalIP] |
263 | mov edx, [eax + IP_SOCKET.LocalIP] |
267 | mov eax, [eax + IP_SOCKET.RemoteIP] |
264 | mov eax, [eax + IP_SOCKET.RemoteIP] |
268 | mov di, IP_PROTO_UDP shl 8 + 128 |
265 | mov di, IP_PROTO_UDP shl 8 + 128 |
269 | add ecx, sizeof.UDP_header |
266 | add ecx, sizeof.UDP_header |
Line 309... | Line 306... | ||
309 | or eax, -1 |
306 | or eax, -1 |
310 | ret |
307 | ret |
Line -... | Line 308... | ||
- | 308 | ||
- | 309 | ||
- | 310 | ||
- | 311 | ||
- | 312 | ;----------------------------------------------------------------- |
|
- | 313 | ; |
|
- | 314 | ; UDP_connect |
|
- | 315 | ; |
|
- | 316 | ; IN: eax = socket pointer |
|
- | 317 | ; OUT: eax = 0 ok / -1 error |
|
- | 318 | ; ebx = error code |
|
- | 319 | ; |
|
- | 320 | ;------------------------- |
|
- | 321 | align 4 |
|
- | 322 | UDP_connect: |
|
- | 323 | ||
- | 324 | test [eax + SOCKET.state], SS_ISCONNECTED |
|
- | 325 | jz @f |
|
- | 326 | call UDP_disconnect |
|
- | 327 | @@: |
|
- | 328 | ||
- | 329 | push eax edx |
|
- | 330 | lea ecx, [eax + SOCKET.mutex] |
|
- | 331 | call mutex_lock |
|
- | 332 | pop edx eax |
|
- | 333 | ||
- | 334 | ; Fill in local IP |
|
- | 335 | cmp [eax + IP_SOCKET.LocalIP], 0 |
|
- | 336 | jne @f |
|
- | 337 | push [IP_LIST + 4] ; FIXME: use correct local IP |
|
- | 338 | pop [eax + IP_SOCKET.LocalIP] |
|
- | 339 | ||
- | 340 | ; Fill in remote port and IP, overwriting eventually previous values |
|
- | 341 | pushw [edx + 2] |
|
- | 342 | pop [eax + UDP_SOCKET.RemotePort] |
|
- | 343 | ||
- | 344 | pushd [edx + 4] |
|
- | 345 | pop [eax + IP_SOCKET.RemoteIP] |
|
- | 346 | ||
- | 347 | ; Find a local port, if user didnt define one |
|
- | 348 | cmp [eax + UDP_SOCKET.LocalPort], 0 |
|
- | 349 | jne @f |
|
- | 350 | call SOCKET_find_port |
|
- | 351 | @@: |
|
- | 352 | ||
- | 353 | push eax |
|
- | 354 | init_queue (eax + SOCKET_QUEUE_LOCATION) ; Set up data receiving queue |
|
- | 355 | pop eax |
|
- | 356 | ||
- | 357 | push eax |
|
- | 358 | lea ecx, [eax + SOCKET.mutex] |
|
- | 359 | call mutex_unlock |
|
- | 360 | pop eax |
|
- | 361 | ||
- | 362 | call SOCKET_is_connected |
|
- | 363 | ||
- | 364 | xor eax, eax |
|
- | 365 | ret |
|
- | 366 | ||
- | 367 | ||
- | 368 | ;----------------------------------------------------------------- |
|
- | 369 | ; |
|
- | 370 | ; UDP_disconnect |
|
- | 371 | ; |
|
- | 372 | ; IN: eax = socket pointer |
|
- | 373 | ; OUT: eax = socket pointer |
|
- | 374 | ; |
|
- | 375 | ;------------------------- |
|
- | 376 | align 4 |
|
- | 377 | UDP_disconnect: |
|
- | 378 | ||
- | 379 | ; TODO: remove the pending received data |
|
- | 380 | ||
- | 381 | call SOCKET_is_disconnected |
|
- | 382 | ||
- | 383 | ret |
|
- | 384 | ||
- | 385 | ||
311 | 386 | ||
312 | 387 | ||
313 | 388 | ||
314 | ;--------------------------------------------------------------------------- |
389 | ;--------------------------------------------------------------------------- |
315 | ; |
390 | ; |