Rev 4587 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4587 | Rev 5116 | ||
---|---|---|---|
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 12... | Line 12... | ||
12 | ;; GNU GENERAL PUBLIC LICENSE ;; |
12 | ;; GNU GENERAL PUBLIC LICENSE ;; |
13 | ;; Version 2, June 1991 ;; |
13 | ;; Version 2, June 1991 ;; |
14 | ;; ;; |
14 | ;; ;; |
15 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
15 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 16... | Line 16... | ||
16 | 16 | ||
Line 17... | Line 17... | ||
17 | $Revision: 3346 $ |
17 | $Revision: 5015 $ |
18 | 18 | ||
Line 19... | Line 19... | ||
19 | ETH_FRAME_MINIMUM = 60 |
19 | ETH_FRAME_MINIMUM = 60 |
Line 143... | Line 143... | ||
143 | je IPv4_input |
143 | je IPv4_input |
Line 144... | Line 144... | ||
144 | 144 | ||
145 | cmp ax, ETHER_PROTO_ARP |
145 | cmp ax, ETHER_PROTO_ARP |
Line 146... | Line 146... | ||
146 | je ARP_input |
146 | je ARP_input |
147 | 147 | ||
Line 148... | Line 148... | ||
148 | cmp ax, ETHER_PROTO_IPv6 |
148 | ; cmp ax, ETHER_PROTO_IPv6 |
149 | je IPv6_input |
149 | ; je IPv6_input |
Line 150... | Line 150... | ||
150 | 150 | ||
151 | cmp ax, ETHER_PROTO_PPP_DISCOVERY |
151 | ; cmp ax, ETHER_PROTO_PPP_DISCOVERY |
Line 152... | Line 152... | ||
152 | je PPPoE_discovery_input |
152 | ; je PPPoE_discovery_input |
Line 153... | Line 153... | ||
153 | 153 | ||
154 | cmp ax, ETHER_PROTO_PPP_SESSION |
154 | ; cmp ax, ETHER_PROTO_PPP_SESSION |
Line 164... | Line 164... | ||
164 | 164 | ||
165 | ;----------------------------------------------------------------- |
165 | ;----------------------------------------------------------------- |
166 | ; |
166 | ; |
167 | ; ETH_output |
167 | ; ETH_output |
168 | ; |
168 | ; |
169 | ; IN: eax = pointer to source mac |
169 | ; IN: ax = protocol |
170 | ; ebx = device ptr |
170 | ; ebx = device ptr |
171 | ; ecx = packet size |
171 | ; ecx = payload size |
172 | ; edx = pointer to destination mac |
- | |
173 | ; di = protocol |
172 | ; edx = pointer to destination mac |
174 | ; |
173 | ; |
175 | ; OUT: edi = 0 on error, pointer to buffer otherwise |
174 | ; OUT: eax = start of ethernet frame / 0 on error |
176 | ; eax = buffer start |
175 | ; ebx = device ptr |
177 | ; ebx = to device structure |
176 | ; ecx = payload size |
178 | ; ecx = unchanged (packet size of embedded data) |
177 | ; edx = ethernet frame size |
179 | ; edx = size of complete buffer |
178 | ; edi = start of ethernet payload |
180 | ; |
179 | ; |
181 | ;----------------------------------------------------------------- |
180 | ;----------------------------------------------------------------- |
182 | align 4 |
181 | align 4 |
Line 183... | Line 182... | ||
183 | ETH_output: |
182 | ETH_output: |
Line 184... | Line 183... | ||
184 | 183 | ||
185 | 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 186... | Line 185... | ||
186 | 185 | ||
187 | cmp ecx, [ebx + NET_DEVICE.mtu] |
186 | cmp ecx, [ebx + ETH_DEVICE.mtu] |
Line 188... | Line 187... | ||
188 | ja .exit |
187 | ja .exit |
189 | 188 | ||
190 | push ecx |
189 | push ecx |
191 | push di eax edx |
190 | push ax edx |
192 | 191 | ||
Line 193... | Line 192... | ||
193 | add ecx, sizeof.ETH_header |
192 | add ecx, sizeof.ETH_header |
194 | stdcall kernel_alloc, ecx |
193 | stdcall kernel_alloc, ecx |
195 | test eax, eax |
194 | test eax, eax |
196 | jz .out_of_ram |
195 | jz .out_of_ram |
197 | mov edi, eax |
196 | mov edi, eax |
198 | 197 | ||
199 | pop esi |
198 | pop esi |
200 | movsd |
199 | movsd |
Line 220... | Line 219... | ||
220 | test edx, edx ; clear zero flag |
219 | test edx, edx ; clear zero flag |
221 | jmp .done |
220 | jmp .done |
Line 222... | Line 221... | ||
222 | 221 | ||
223 | .out_of_ram: |
222 | .out_of_ram: |
224 | DEBUGF DEBUG_NETWORK_ERROR, "ETH_output: Out of ram!\n" |
223 | DEBUGF DEBUG_NETWORK_ERROR, "ETH_output: Out of ram!\n" |
225 | add esp, 4+4+2+4 |
224 | add esp, 4+2+4 |
226 | sub edi, edi |
225 | xor eax, eax |
Line 227... | Line 226... | ||
227 | ret |
226 | ret |
228 | 227 | ||
229 | .exit: |
228 | .exit: |
230 | DEBUGF DEBUG_NETWORK_ERROR, "ETH_output: Packet too large!\n" |
229 | DEBUGF DEBUG_NETWORK_ERROR, "ETH_output: Packet too large!\n" |
Line 231... | Line 230... | ||
231 | sub edi, edi |
230 | xor eax, eax |