Rev 1206 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1206 | Rev 1249 | ||
---|---|---|---|
Line 15... | Line 15... | ||
15 | ;; GNU GENERAL PUBLIC LICENSE ;; |
15 | ;; GNU GENERAL PUBLIC LICENSE ;; |
16 | ;; Version 2, June 1991 ;; |
16 | ;; Version 2, June 1991 ;; |
17 | ;; ;; |
17 | ;; ;; |
18 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
18 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 19... | Line 19... | ||
19 | 19 | ||
Line 20... | Line 20... | ||
20 | $Revision: 1206 $ |
20 | $Revision: 1249 $ |
21 | 21 | ||
22 | uglobal |
22 | uglobal |
23 | last_1sTick db ? |
23 | last_1sTick db ? |
Line 31... | Line 31... | ||
31 | 31 | ||
32 | ETHER equ 1337 |
32 | ETHER equ 1337 |
Line 33... | Line 33... | ||
33 | ETHER_ARP equ 0x0608 |
33 | ETHER_ARP equ 0x0608 |
34 | 34 | ||
35 | ;AF_UNSPEC equ 0 |
35 | ;AF_UNSPEC equ 0 |
36 | ;AF_UNIX equ 1 |
36 | AF_UNIX equ 1 |
37 | AF_INET4 equ 2 |
37 | AF_INET4 equ 2 |
38 | ;AF_AX25 equ 3 |
38 | ;AF_AX25 equ 3 |
39 | ;AF_IPX equ 4 |
39 | ;AF_IPX equ 4 |
Line 62... | Line 62... | ||
62 | include "queue.inc" |
62 | include "queue.inc" |
63 | include "ARP.inc" |
63 | include "ARP.inc" |
64 | include "IPv4.inc" |
64 | include "IPv4.inc" |
65 | include "ethernet.inc" |
65 | include "ethernet.inc" |
66 | include "socket.inc" |
66 | include "socket.inc" |
67 | ;include "tcp.inc" |
67 | include "tcp.inc" |
68 | include "udp.inc" |
68 | include "udp.inc" |
69 | include "icmp.inc" |
69 | include "icmp.inc" |
Line 70... | Line 70... | ||
70 | 70 | ||
71 | ;----------------------------------------------- |
71 | ;----------------------------------------------- |
Line 84... | Line 84... | ||
84 | 84 | ||
85 | call ETH_init |
85 | call ETH_init |
86 | call IPv4_init |
86 | call IPv4_init |
87 | call ARP_init |
87 | call ARP_init |
- | 88 | call UDP_init |
|
88 | call UDP_init |
89 | call TCP_init |
89 | call ICMP_init |
90 | call ICMP_init |
Line 90... | Line 91... | ||
90 | call socket_init |
91 | call socket_init |
91 | 92 | ||
Line 113... | Line 114... | ||
113 | stack_handler: |
114 | stack_handler: |
Line 114... | Line 115... | ||
114 | 115 | ||
115 | cmp [ETH_RUNNING], 0 |
116 | cmp [ETH_RUNNING], 0 |
Line 116... | Line -... | ||
116 | je .exit |
- | |
117 | - | ||
118 | call ETH_handler ; handle all queued ethernet packets |
- | |
119 | call ETH_send_queued |
117 | je .exit |
120 | 118 | ||
121 | ; Test for 10ms tick, call tcp timer |
119 | ; Test for 10ms tick |
122 | mov eax, [timer_ticks] |
120 | mov eax, [timer_ticks] |
Line 123... | Line 121... | ||
123 | cmp eax, [last_1hsTick] |
121 | cmp eax, [last_1hsTick] |
- | 122 | je .exit |
|
- | 123 | ||
- | 124 | mov [last_1hsTick], eax |
|
124 | je .exit |
125 | |
Line 125... | Line 126... | ||
125 | 126 | call ETH_handler ; handle all queued ethernet packets |
|
Line 126... | Line 127... | ||
126 | mov [last_1hsTick], eax |
127 | call ETH_send_queued |
127 | ; call tcp_tx_handler |
128 | call TCP_send_queued |
128 | 129 | ||
129 | .sec_tick: |
130 | .sec_tick: |
130 | 131 | ||
131 | ; Test for 1 second event, call 1s timer functions |
132 | ; Test for 1 second event |
Line 132... | Line 133... | ||
132 | mov al, 0x0 ;second |
133 | mov al, 0x0 ;second |
Line 133... | Line 134... | ||
133 | out 0x70, al |
134 | out 0x70, al |
134 | in al, 0x71 |
135 | in al, 0x71 |
135 | cmp al, [last_1sTick] |
136 | cmp al, [last_1sTick] |
Line 136... | Line 137... | ||
136 | je .exit |
137 | je .exit |
137 | 138 | ||
Line 138... | Line -... | ||
138 | mov [last_1sTick], al |
- | |
139 | - | ||
140 | call ARP_decrease_entry_ttls |
- | |
141 | call IPv4_decrease_fragment_ttls |
- | |
142 | ; call tcp_tcb_handler |
- | |
143 | - | ||
144 | .exit: |
- | |
145 | ret |
- | |
146 | - | ||
147 | - | ||
148 | - | ||
Line 149... | Line -... | ||
149 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
- | |
150 | ;; Checksum [by Johnny_B] |
- | |
151 | ;; IN: |
- | |
152 | ;; buf_ptr=POINTER to buffer |
- | |
153 | ;; buf_size=SIZE of buffer |
- | |
154 | ;; OUT: |
- | |
155 | ;; AX=16-bit checksum |
- | |
156 | ;; Saves all used registers |
- | |
157 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
- | |
Line -... | Line 139... | ||
- | 139 | mov [last_1sTick], al |
|
- | 140 | ||
- | 141 | call ARP_decrease_entry_ttls |
|
- | 142 | call IPv4_decrease_fragment_ttls |
|
- | 143 | call TCP_decrease_socket_ttls |
|
- | 144 | ||
- | 145 | .exit: |
|
- | 146 | ret |
|
- | 147 | ||
- | 148 | ||
- | 149 | ||
- | 150 | ||
- | 151 | ||
- | 152 | ;----------------------------------------------------------------- |
|
- | 153 | ; |
|
- | 154 | ; checksum_1 |
|
- | 155 | ; |
|
- | 156 | ; This is the first of two functions needed to calculate the TCP checksum. |
|
- | 157 | ; |
|
158 | proc checksum_jb stdcall uses ebx esi ecx,\ |
158 | ; IN: edx = start offeset for semi-checksum |
159 | buf_ptr:DWORD, buf_size:DWORD |
159 | ; esi = pointer to data |
160 | 160 | ; ecx = data size |
|
161 | xor eax, eax |
161 | ; OUT: edx = semi-checksum |
162 | xor ebx, ebx ;accumulator |
162 | ; |
Line -... | Line 163... | ||
- | 163 | ;----------------------------------------------------------------- |
|
- | 164 | ||
- | 165 | align 4 |
|
- | 166 | checksum_1: |
|
- | 167 | ||
- | 168 | xor eax, eax |
|
- | 169 | shr ecx, 1 |
|
- | 170 | pushf |
|
- | 171 | .loop: |
|
- | 172 | lodsw |
|
- | 173 | xchg al, ah |
|
- | 174 | add edx, eax |
|
- | 175 | loop .loop |
|
- | 176 | ||
- | 177 | popf |
|
- | 178 | jnc .end |
|
- | 179 | ||
- | 180 | lodsb |
|
- | 181 | shl ax, 8 |
|
- | 182 | add edx, eax |
|
- | 183 | ||
- | 184 | .end: |
|
- | 185 | ||
- | 186 | ret |
|
- | 187 | ||
- | 188 | ||
- | 189 | ||
- | 190 | ;----------------------------------------------------------------- |
|
- | 191 | ; |
|
- | 192 | ; checksum_2 |
|
- | 193 | ; |
|
163 | mov esi, dword[buf_ptr] |
194 | ; This function calculates the final ip/tcp/udp checksum for you |
164 | mov ecx, dword[buf_size] |
195 | ; |
165 | shr ecx, 1 ; ecx=ecx/2 |
196 | ; IN: edx = semi-checksum |
- | 197 | ; OUT: dx = checksum (in INET byte order) |
|
- | 198 | ; |
|
- | 199 | ;----------------------------------------------------------------- |
|
- | 200 | ||
166 | jnc @f ; if CF==0 then size is even number |
201 | align 4 |
- | 202 | checksum_2: |
|
- | 203 | ||
- | 204 | mov ecx, edx |
|
Line 167... | Line 205... | ||
167 | mov bh, byte[esi + ecx*2] |
205 | shr ecx, 16 |
168 | @@: |
- | |
Line 169... | Line 206... | ||
169 | cld |
206 | and edx, 0xffff |
170 | 207 | add edx, ecx |
|
Line 248... | Line 285... | ||
248 | mov esi, [esi + ETH_DRV_LIST] |
285 | mov esi, [esi + ETH_DRV_LIST] |
249 | call [esi + ETH_DEVICE.unload] |
286 | call [esi + ETH_DEVICE.unload] |
250 | jmp .return |
287 | jmp .return |
Line 251... | Line 288... | ||
251 | 288 | ||
- | 289 | @@: |
|
- | 290 | dec bl ; 4 = Get driver pointer |
|
- | 291 | jnz @f |
|
- | 292 | ||
- | 293 | ; ..; |
|
- | 294 | ||
- | 295 | ||
- | 296 | @@: |
|
Line 252... | Line 297... | ||
252 | @@: |
297 | ; ... ; 5 Get driver name |
253 | 298 | ||
254 | .doesnt_exist: |
299 | .doesnt_exist: |