Rev 115 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 115 | Rev 261 | ||
---|---|---|---|
Line 12... | Line 12... | ||
12 | ;; v0.6 : Added reset handling in the established state ;; |
12 | ;; v0.6 : Added reset handling in the established state ;; |
13 | ;; Added a timer per socket to allow delays when rx window ;; |
13 | ;; Added a timer per socket to allow delays when rx window ;; |
14 | ;; gets below 1KB ;; |
14 | ;; gets below 1KB ;; |
15 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
15 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line -... | Line 16... | ||
- | 16 | ||
- | 17 | ; TCP TCB states |
|
- | 18 | TCB_LISTEN equ 1 |
|
- | 19 | TCB_SYN_SENT equ 2 |
|
- | 20 | TCB_SYN_RECEIVED equ 3 |
|
- | 21 | TCB_ESTABLISHED equ 4 |
|
- | 22 | TCB_FIN_WAIT_1 equ 5 |
|
- | 23 | TCB_FIN_WAIT_2 equ 6 |
|
- | 24 | TCB_CLOSE_WAIT equ 7 |
|
- | 25 | TCB_CLOSING equ 8 |
|
- | 26 | TCB_LAST_ACK equ 9 |
|
- | 27 | TCB_TIME_WAIT equ 10 |
|
- | 28 | TCB_CLOSED equ 11 |
|
- | 29 | ||
- | 30 | TWOMSL equ 10 ; # of secs to wait before closing socket |
|
- | 31 | ||
- | 32 | TCP_RETRIES equ 5 ; Number of times to resend a packet |
|
Line 16... | Line 33... | ||
16 | 33 | TCP_TIMEOUT equ 10 ; resend if not replied to in x hs |
|
17 | 34 | ||
18 | ;******************************************************************* |
35 | ;******************************************************************* |
19 | ; Interface |
36 | ; Interface |
Line 25... | Line 42... | ||
25 | ; tcp_tcb_handler 1s timer, to erase tcb's in TIME_WAIT state |
42 | ; tcp_tcb_handler 1s timer, to erase tcb's in TIME_WAIT state |
26 | ; |
43 | ; |
27 | ;******************************************************************* |
44 | ;******************************************************************* |
Line -... | Line 45... | ||
- | 45 | ||
- | 46 | ||
- | 47 | ; TCP Payload ( Data field in IP datagram ) |
|
- | 48 | ; |
|
- | 49 | ; 0 1 2 3 |
|
- | 50 | ; 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
|
- | 51 | ; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
- | 52 | ;20 | Source Port | Destination Port | |
|
- | 53 | ; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
- | 54 | ;24 | Sequence Number | |
|
- | 55 | ; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
- | 56 | ;28 | Acknowledgment Number | |
|
- | 57 | ; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
- | 58 | ;32 | Data | |U|A|P|R|S|F| | |
|
- | 59 | ; | Offset| Reserved |R|C|S|S|Y|I| Window | |
|
- | 60 | ; | | |G|K|H|T|N|N| | |
|
- | 61 | ; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
- | 62 | ;36 | Checksum | Urgent Pointer | |
|
- | 63 | ; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
- | 64 | ;40 | Options | Padding | |
|
- | 65 | ; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
- | 66 | ; | data |
|
- | 67 | ||
- | 68 | ||
- | 69 | struc TCP_PACKET |
|
- | 70 | { .SourcePort dw ? ;+00 |
|
- | 71 | .DestinationPort dw ? ;+02 |
|
- | 72 | .SequenceNumber dd ? ;+04 |
|
- | 73 | .AckNumber dd ? ;+08 |
|
- | 74 | .DataOffset db ? ;+12 - DataOffset[0-3 bits] and Reserved[4-7] |
|
- | 75 | .Flags db ? ;+13 - Reserved[0-1 bits]|URG|ACK|PSH|RST|SYN|FIN |
|
- | 76 | .Window dw ? ;+14 |
|
- | 77 | .Checksum dw ? ;+16 |
|
- | 78 | .UrgentPointer dw ? ;+18 |
|
- | 79 | .Options rb 3 ;+20 |
|
- | 80 | .Padding db ? ;+23 |
|
- | 81 | .Data db ? ;+24 |
|
- | 82 | } |
|
- | 83 | ||
- | 84 | virtual at 0 |
|
- | 85 | TCP_PACKET TCP_PACKET |
|
- | 86 | end virtual |
|
Line 28... | Line 87... | ||
28 | 87 | ||
29 | 88 | ||
30 | 89 | ||
31 | ;*************************************************************************** |
90 | ;*************************************************************************** |
Line 492... | Line 551... | ||
492 | 551 | ||
493 | mov [edx + 20 + 16], ah |
552 | mov [edx + 20 + 16], ah |
Line 494... | Line 553... | ||
494 | mov [edx + 20 + 17], al |
553 | mov [edx + 20 + 17], al |
495 | - | ||
496 | ; Fill in the IP header checksum |
- | |
497 | mov eax, edx |
554 | |
498 | mov [checkAdd1], eax |
- | |
499 | mov [checkSize1], word 20 |
555 | ; Fill in the IP header checksum |
Line 500... | Line -... | ||
500 | mov [checkAdd2], dword 0 |
- | |
501 | mov [checkSize2], word 0 |
- | |
502 | - | ||
503 | call checksum |
556 | GET_IHL eax,edx ; get IP-Header length |
504 | 557 | stdcall checksum_jb,edx,eax ; buf_ptr, buf_size |
|
Line 505... | Line 558... | ||
505 | mov ax, [checkResult] |
558 |