Subversion Repositories Kolibri OS

Rev

Rev 9976 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3545 hidnplayr 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
8866 rgimad 3
;; Copyright (C) KolibriOS team 2004-2021. All rights reserved.    ;;
3545 hidnplayr 4
;; Distributed under terms of the GNU General Public License       ;;
5
;;                                                                 ;;
6
;;  Part of the TCP/IP network stack for KolibriOS                 ;;
7
;;                                                                 ;;
8
;;   Written by hidnplayr@kolibrios.org,                           ;;
9
;;     and Clevermouse.                                            ;;
10
;;                                                                 ;;
11
;;       Based on code by mike.dld                                 ;;
12
;;                                                                 ;;
13
;;         GNU GENERAL PUBLIC LICENSE                              ;;
14
;;          Version 2, June 1991                                   ;;
15
;;                                                                 ;;
16
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
17
 
4850 mario79 18
$Revision: 9993 $
3545 hidnplayr 19
 
20
struct  SOCKET
21
 
5976 hidnplayr 22
        NextPtr                 dd ?    ; pointer to next socket in list
23
        PrevPtr                 dd ?    ; pointer to previous socket in list
24
        Number                  dd ?    ; socket number
3545 hidnplayr 25
 
26
        mutex                   MUTEX
27
 
5976 hidnplayr 28
        PID                     dd ?    ; process ID
29
        TID                     dd ?    ; thread ID
30
        Domain                  dd ?    ; INET4/INET6/LOCAL/..
31
        Type                    dd ?    ; RAW/STREAM/DGRAM
32
        Protocol                dd ?    ; UDP/TCP/ARP/ICMP
3545 hidnplayr 33
        errorcode               dd ?
5976 hidnplayr 34
        device                  dd ?    ; device pointer, paired socket pointer if it's a local socket
3545 hidnplayr 35
 
36
        options                 dd ?
37
        state                   dd ?
5976 hidnplayr 38
        backlog                 dw ?    ; number of incoming connections that can be queued
3545 hidnplayr 39
 
40
        snd_proc                dd ?
41
        rcv_proc                dd ?
4030 hidnplayr 42
        connect_proc            dd ?
9917 Doczom 43
        ;sndto_proc              dd ?
44
        ;rcvfrom_proc            dd ?
3545 hidnplayr 45
 
46
ends
47
 
48
struct  IP_SOCKET               SOCKET
49
 
5976 hidnplayr 50
        LocalIP                 rd 4    ; network byte order
51
        RemoteIP                rd 4    ; network byte order
5842 hidnplayr 52
        ttl                     db ?
5976 hidnplayr 53
                                rb 3    ; align
3545 hidnplayr 54
 
55
ends
56
 
57
struct  TCP_SOCKET              IP_SOCKET
58
 
5976 hidnplayr 59
        LocalPort               dw ?    ; network byte order
60
        RemotePort              dw ?    ; network byte order
3545 hidnplayr 61
 
5976 hidnplayr 62
        t_state                 dd ?    ; TCB state
3545 hidnplayr 63
        t_rxtshift              db ?
5976 hidnplayr 64
                                rb 3    ; align
3545 hidnplayr 65
        t_rxtcur                dd ?
66
        t_dupacks               dd ?
67
        t_maxseg                dd ?
68
        t_flags                 dd ?
69
 
70
;---------------
71
; RFC783 page 21
72
 
73
; send sequence
5976 hidnplayr 74
        SND_UNA                 dd ?    ; sequence number of unack'ed sent Packets
75
        SND_NXT                 dd ?    ; next send sequence number to use
76
        SND_UP                  dd ?    ; urgent pointer
6476 hidnplayr 77
        SND_WL1                 dd ?    ; the sequence number of the last segment used to update the send window
78
        SND_WL2                 dd ?    ; the acknowledgment number of the last segment used to update the send window
5976 hidnplayr 79
        ISS                     dd ?    ; initial send sequence number
80
        SND_WND                 dd ?    ; send window
3545 hidnplayr 81
 
82
; receive sequence
5976 hidnplayr 83
        RCV_WND                 dd ?    ; receive window
84
        RCV_NXT                 dd ?    ; next receive sequence number to use
85
        RCV_UP                  dd ?    ; urgent pointer
86
        IRS                     dd ?    ; initial receive sequence number
3545 hidnplayr 87
 
88
;---------------------
89
; Additional variables
90
 
91
; receive variables
92
        RCV_ADV                 dd ?
93
 
94
; retransmit variables
95
        SND_MAX                 dd ?
96
 
97
; congestion control
4339 hidnplayr 98
        SND_CWND                dd ?    ; congestion window
99
        SND_SSTHRESH            dd ?    ; slow start threshold
3545 hidnplayr 100
 
101
;----------------------
102
; Transmit timing stuff
103
        t_idle                  dd ?
5442 hidnplayr 104
        t_rtt                   dd ?    ; round trip time
3545 hidnplayr 105
        t_rtseq                 dd ?
5442 hidnplayr 106
        t_srtt                  dd ?    ; smoothed round trip time
3545 hidnplayr 107
        t_rttvar                dd ?
108
        t_rttmin                dd ?
109
        max_sndwnd              dd ?
110
 
111
;-----------------
112
; Out-of-band data
113
        t_oobflags              dd ?
114
        t_iobc                  dd ?
115
        t_softerror             dd ?
116
 
117
 
118
;---------
119
; RFC 1323                              ; the order of next 4 elements may not change
120
 
121
        SND_SCALE               db ?
122
        RCV_SCALE               db ?
123
        requested_s_scale       db ?
124
        request_r_scale         db ?
125
 
126
        ts_recent               dd ?    ; a copy of the most-recent valid timestamp from the other end
127
        ts_recent_age           dd ?
128
        last_ack_sent           dd ?
129
 
130
 
131
;-------
132
; Timers
3600 hidnplayr 133
        timer_flags             dd ?
5976 hidnplayr 134
        timer_retransmission    dd ?    ; rexmt
3545 hidnplayr 135
        timer_persist           dd ?
5976 hidnplayr 136
        timer_keepalive         dd ?    ; keepalive/syn timeout
137
        timer_timed_wait        dd ?    ; also used as 2msl timer
4021 hidnplayr 138
        timer_connect           dd ?
3545 hidnplayr 139
 
140
; extra
141
 
5976 hidnplayr 142
        ts_ecr                  dd ?    ; timestamp echo reply
3545 hidnplayr 143
        ts_val                  dd ?
144
 
5976 hidnplayr 145
        seg_next                dd ?    ; re-assembly queue
3545 hidnplayr 146
 
147
ends
148
 
149
struct  UDP_SOCKET              IP_SOCKET
150
 
5976 hidnplayr 151
        LocalPort               dw ?    ; in network byte order
152
        RemotePort              dw ?    ; in network byte order
3545 hidnplayr 153
 
154
ends
155
 
156
struct  RING_BUFFER
157
 
158
        mutex                   MUTEX
5976 hidnplayr 159
        start_ptr               dd ?    ; Pointer to start of buffer
160
        end_ptr                 dd ?    ; pointer to end of buffer
161
        read_ptr                dd ?    ; Read pointer
162
        write_ptr               dd ?    ; Write pointer
163
        size                    dd ?    ; Number of bytes buffered
3545 hidnplayr 164
 
165
ends
166
 
167
struct  STREAM_SOCKET           TCP_SOCKET
168
 
169
        rcv                     RING_BUFFER
170
        snd                     RING_BUFFER
171
 
172
ends
173
 
9739 turbocat 174
struct sockaddr
175
 
176
        family                  dw ?    ; Address family
177
        port                    dw ?    ; 16 bit TCP/UDP port number
178
        ip                      dd ?    ; 32 bit IP address
179
        _zero                   rb 8    ; Not use, for align
180
 
181
ends
182
 
3545 hidnplayr 183
struct  socket_queue_entry
184
 
185
        data_ptr                dd ?
5522 hidnplayr 186
        data_size               dd ?
3545 hidnplayr 187
        buf_ptr                 dd ?
188
 
189
ends
190
 
5976 hidnplayr 191
struct  socket_options
3545 hidnplayr 192
 
5976 hidnplayr 193
        level                   dd ?
194
        optname                 dd ?
195
        optlen                  dd ?
196
        optval                  dd ?
3545 hidnplayr 197
 
5976 hidnplayr 198
ends
199
 
6413 hidnplayr 200
SOCKET_STRUCT_SIZE      = 4096          ; in bytes
5976 hidnplayr 201
 
202
SOCKET_QUEUE_SIZE       = 10            ; maximum number of incoming packets queued for 1 socket
3545 hidnplayr 203
; the incoming packet queue for sockets is placed in the socket struct itself, at this location from start
6413 hidnplayr 204
SOCKET_QUEUE_LOCATION   = (SOCKET_STRUCT_SIZE - SOCKET_QUEUE_SIZE*sizeof.socket_queue_entry - sizeof.queue)
3545 hidnplayr 205
 
206
uglobal
3698 hidnplayr 207
align 4
208
 
3545 hidnplayr 209
        net_sockets     rd 4