Rev 4265 | Rev 5565 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4265 | Rev 5201 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
5 | ;; ;; |
6 | ;; ETHERNET.INC ;; |
6 | ;; ETHERNET.INC ;; |
7 | ;; ;; |
7 | ;; ;; |
8 | ;; Ethernet network layer for KolibriOS ;; |
8 | ;; Ethernet network layer for KolibriOS ;; |
Line 84... | Line 84... | ||
84 | ETH_input: |
84 | ETH_input: |
Line 85... | Line 85... | ||
85 | 85 | ||
86 | push ebx |
86 | push ebx |
Line 87... | Line -... | ||
87 | mov esi, esp |
- | |
88 | - | ||
89 | pushf |
87 | mov esi, esp |
90 | cli |
- | |
91 | add_to_queue ETH_queue, ETH_QUEUE_SIZE, sizeof.ETH_queue_entry, .fail |
- | |
92 | popf |
88 | |
Line 93... | Line 89... | ||
93 | 89 | add_to_queue ETH_queue, ETH_QUEUE_SIZE, sizeof.ETH_queue_entry, .fail |
|
94 | add esp, sizeof.ETH_queue_entry |
90 | add esp, sizeof.ETH_queue_entry |
95 | 91 | ||
Line 100... | Line 96... | ||
100 | call raise_event |
96 | call raise_event |
Line 101... | Line 97... | ||
101 | 97 | ||
Line 102... | Line 98... | ||
102 | ret |
98 | ret |
103 | - | ||
104 | .fail: |
99 | |
Line 105... | Line 100... | ||
105 | popf |
100 | .fail: |
106 | DEBUGF DEBUG_NETWORK_VERBOSE, "ETH incoming queue is full, discarding packet!\n" |
101 | DEBUGF DEBUG_NETWORK_ERROR, "ETH incoming queue is full, discarding packet!\n" |
107 | 102 | ||
Line 108... | Line 103... | ||
108 | add esp, sizeof.ETH_queue_entry - 8 |
103 | pop ebx |
Line 148... | Line 143... | ||
148 | je IPv4_input |
143 | je IPv4_input |
Line 149... | Line 144... | ||
149 | 144 | ||
150 | cmp ax, ETHER_PROTO_ARP |
145 | cmp ax, ETHER_PROTO_ARP |
Line 151... | Line 146... | ||
151 | je ARP_input |
146 | je ARP_input |
152 | 147 | ||
Line 153... | Line 148... | ||
153 | cmp ax, ETHER_PROTO_IPv6 |
148 | ; cmp ax, ETHER_PROTO_IPv6 |
154 | je IPv6_input |
149 | ; je IPv6_input |
Line 155... | Line 150... | ||
155 | 150 | ||
156 | cmp ax, ETHER_PROTO_PPP_DISCOVERY |
151 | ; cmp ax, ETHER_PROTO_PPP_DISCOVERY |
Line 157... | Line 152... | ||
157 | je PPPoE_discovery_input |
152 | ; je PPPoE_discovery_input |
Line 158... | Line 153... | ||
158 | 153 | ||
159 | cmp ax, ETHER_PROTO_PPP_SESSION |
154 | ; cmp ax, ETHER_PROTO_PPP_SESSION |
Line 169... | Line 164... | ||
169 | 164 | ||
170 | ;----------------------------------------------------------------- |
165 | ;----------------------------------------------------------------- |
171 | ; |
166 | ; |
172 | ; ETH_output |
167 | ; ETH_output |
173 | ; |
168 | ; |
174 | ; IN: eax = pointer to source mac |
169 | ; IN: ax = protocol |
175 | ; ebx = device ptr |
170 | ; ebx = device ptr |
176 | ; ecx = packet size |
171 | ; ecx = payload size |
177 | ; edx = pointer to destination mac |
- | |
178 | ; di = protocol |
172 | ; edx = pointer to destination mac |
179 | ; |
173 | ; |
180 | ; OUT: edi = 0 on error, pointer to buffer otherwise |
174 | ; OUT: eax = start of ethernet frame / 0 on error |
181 | ; eax = buffer start |
175 | ; ebx = device ptr |
182 | ; ebx = to device structure |
176 | ; ecx = payload size |
183 | ; ecx = unchanged (packet size of embedded data) |
177 | ; edx = ethernet frame size |
184 | ; edx = size of complete buffer |
178 | ; edi = start of ethernet payload |
185 | ; |
179 | ; |
186 | ;----------------------------------------------------------------- |
180 | ;----------------------------------------------------------------- |
187 | align 4 |
181 | align 4 |
Line 188... | Line 182... | ||
188 | ETH_output: |
182 | ETH_output: |
Line 189... | Line 183... | ||
189 | 183 | ||
190 | DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_output: size=%u device=%x\n", ecx, ebx |
184 | DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_output: size=%u device=%x\n", ecx, ebx |
Line 191... | Line 185... | ||
191 | 185 | ||
192 | cmp ecx, [ebx + NET_DEVICE.mtu] |
186 | cmp ecx, [ebx + ETH_DEVICE.mtu] |
Line 193... | Line 187... | ||
193 | ja .exit |
187 | ja .exit |
194 | 188 | ||
195 | push ecx |
189 | push ecx |
196 | push di eax edx |
190 | push ax edx |
197 | 191 | ||
Line 198... | Line 192... | ||
198 | add ecx, sizeof.ETH_header |
192 | add ecx, sizeof.ETH_header |
199 | stdcall kernel_alloc, ecx |
193 | stdcall kernel_alloc, ecx |
200 | test eax, eax |
194 | test eax, eax |
201 | jz .out_of_ram |
195 | jz .out_of_ram |
202 | mov edi, eax |
196 | mov edi, eax |
203 | 197 | ||
204 | pop esi |
198 | pop esi |
205 | movsd |
199 | movsd |
Line 225... | Line 219... | ||
225 | test edx, edx ; clear zero flag |
219 | test edx, edx ; clear zero flag |
226 | jmp .done |
220 | jmp .done |
Line 227... | Line 221... | ||
227 | 221 | ||
228 | .out_of_ram: |
222 | .out_of_ram: |
229 | DEBUGF DEBUG_NETWORK_ERROR, "ETH_output: Out of ram!\n" |
223 | DEBUGF DEBUG_NETWORK_ERROR, "ETH_output: Out of ram!\n" |
230 | add esp, 4+4+2+4 |
224 | add esp, 4+2+4 |
231 | sub edi, edi |
225 | xor eax, eax |
Line 232... | Line 226... | ||
232 | ret |
226 | ret |
233 | 227 | ||
234 | .exit: |
228 | .exit: |
235 | DEBUGF DEBUG_NETWORK_ERROR, "ETH_output: Packet too large!\n" |
229 | DEBUGF DEBUG_NETWORK_ERROR, "ETH_output: Packet too large!\n" |
Line 236... | Line 230... | ||
236 | sub edi, edi |
230 | xor eax, eax |