-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTCP.ASM
More file actions
executable file
·120 lines (100 loc) · 3.73 KB
/
TCP.ASM
File metadata and controls
executable file
·120 lines (100 loc) · 3.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
;Source by Six of Style (Oliver VieBrooks)
;http://style64.org http://thedarkside.ath.cx mailto:six@darklordsofchaos.com
;
;Last Updated Feb/3/2006
;
;ICMP PROTOCOL================================================================
; _,.-------.,_
;ICMP PACKET FORMAT: ,;~' '~;,
;+----------+---------+-----------+ ,; ;,
;|$00-$0d |$0e-$20 |$21-$ | ; ;
;+----------+---------+-----------+ ,' Style 2006 ',
;|MAC Header|IP Header|TCP Header | ,; ;,
;+----------+---------+-----------+ ; ; . . ; ;
; | ; ______ ______ ; |
;MAC Header Fields: | `/~" ~" . "~ "~\' |
;$00 - Destination MAC | ~ ,-~~~^~, | ,~^~~~-, ~ |
;$06 - Source MAC | | }:{ | |
;$0c - Packet Type | ! / | \ ! |
; .~ (__,.--" .^. "--.,__) ~.
;IP Header Fields: | ---;' / | \ `;--- |
;$0e - IP Version \__. \/^\/ .__/
;$0f - Type of Service V| \ / |V
;$12 - Total Length of packet | |T~\___!___!___/~T| |
;$13 - Protocol Address Size | |`IIII_I_I_I_IIII'| |
;$14 - Opcode | \,III I I I III,/ |
; \ `~~~~~~~~~~' /
; \ . . /
; \. ^ ./
; ^~~~^~~~^
TCP_STATUS_IDLE = 0
;client status
TCP_STATUS_CONNECTING = 1 ;Sent SYN PACKET, waiting for SYN-ACK
TCP_STATUS_AWAITING_ACK = 2 ;Sent Segments, awaiting ACK
TCP_STATUS_AWAITING_DATA = 3 ;Waiting for data (idle)
TCP_STATUS_ACKING = 4 ;Received Data, sending ACK
TCP_STATUS_FIN_WAIT1 = 5 ;Sent FIN, awaiting ACK
TCP_STATUS_FIN_WAIT2 = 6 ;Sent Last ACK, awaiting Server Last ACK
TCP_STATUS_TIME_WAIT = 7 ;Waiting for FIN-RETRY,
SOCKET_STATUS_CLOSED = 1
SOCKET_STATUS_LISTEN = 2
SOCKET_STATUS_SYN_SENT = 3
SOCKET_STATUS_SYN_RECEIVED = 4
SOCKET_STATUS_ESTABLISHED = 5
TCP_CLIENT_LOCAL_PORT dc.w $0064
TCP_CLIENT_REMOTE_PORT dc.w $0000
TCP_CLIENT_REMOTE_IP dc.b $00,$00,$00,$00
TCP_CLIENT_STATUS dc.b $00
TCP_HEADER
TCP_SOURCE_PORT dc.w $0000
TCP_DEST_PORT dc.w $0000
TCP_SEQ_NUM dc.w $0000,$0000
TCP_ACK_NUM dc.w $0000,$0000
TCP_CONTROL_WORD dc.w $0000
TCP_WINDOW dc.w $0000
TCP_CHECKSUM dc.w $0000
TCP_URGENT dc.w $0000
TCP_OPTIONS dc.w $0000,$0000
TCP_DATA ds.b $400
TCP_PROCESS ;process incoming packet
rts
;Before TCP_CONNECT
;
TCP_CONNECT
TCP_SEND
;Before TCP_SEND
;Set Source Port
;Set Dest Port
;Set Data Len
;Copy Data
;Set Dest IP
;Generate Checksum
;jsr TCP_GEN_PSEUDO
;jsr TCP_SET_CSUM
;lda #IP_PROTOCOL_TCP
;jsr IP_SETPROTOCOL
;lda #<CARD_IP
;ldx #>CARD_IP
;jsr IP_SET_SRC
;lda #<TCP_DEST_IP
;ldx #>TCP_DEST_IP
;jsr IP_SETDEST
;lda #$80
;jsr IP_SETTTL
;Copy UDP Header+Data to IP_DATA
;lda #<TCP_HEADER
;sta CPY_SRC
;lda #>TCP_HEADER
;sta CPY_SRC+1
;lda #<IP_DATA
;sta CPY_DST
;lda #>IP_DATA
;sta CPY_DST+1
;ldx TCP_LEN+1
;lda TCP_LEN
;jsr copyblock
;lda TCP_LEN
;ldx TCP_LEN+1
;jsr IP_SET_DATALEN
;jsr IP_SEND
rts