1/*- 2 * Copyright (c) 1999, 2000 Boris Popov 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/sys/net/if_ef.c 111888 2003-03-04 23:19:55Z jlemon $ |
27 */ 28 29#include "opt_inet.h" 30#include "opt_ipx.h" 31#include "opt_ef.h" 32 33#include <sys/param.h> 34#include <sys/systm.h> --- 200 unchanged lines hidden (view full) --- 235 return; 236} 237 238/* 239 * Inline functions do not put additional overhead to procedure call or 240 * parameter passing but simplify the code 241 */ 242static int __inline |
243ef_inputEII(struct mbuf *m, struct ether_header *eh, u_short ether_type) |
244{ |
245 int isr; 246 |
247 switch(ether_type) { 248#ifdef IPX |
249 case ETHERTYPE_IPX: 250 isr = NETISR_IPX; |
251 break; 252#endif 253#ifdef INET |
254 case ETHERTYPE_IP: |
255 if (ipflow_fastforward(m)) |
256 return (0); 257 isr = NETISR_IP; |
258 break; 259 |
260 case ETHERTYPE_ARP: 261 isr = NETISR_ARP; |
262 break; 263#endif |
264 default: 265 return (EPROTONOSUPPORT); |
266 } |
267 netisr_dispatch(isr, m); 268 return (0); |
269} 270 271static int __inline 272ef_inputSNAP(struct mbuf *m, struct ether_header *eh, struct llc* l, |
273 u_short ether_type) |
274{ |
275 int isr; 276 |
277 switch(ether_type) { 278#ifdef IPX |
279 case ETHERTYPE_IPX: |
280 m_adj(m, 8); |
281 isr = NETISR_IPX; |
282 break; 283#endif |
284 default: 285 return (EPROTONOSUPPORT); |
286 } |
287 netisr_dispatch(isr, m); 288 return (0); |
289} 290 291static int __inline 292ef_input8022(struct mbuf *m, struct ether_header *eh, struct llc* l, |
293 u_short ether_type) |
294{ |
295 int isr; 296 |
297 switch(ether_type) { 298#ifdef IPX |
299 case 0xe0: |
300 m_adj(m, 3); |
301 isr = NETISR_IPX; |
302 break; 303#endif |
304 default: 305 return (EPROTONOSUPPORT); |
306 } |
307 netisr_dispatch(isr, m); 308 return (0); |
309} |
310 |
311/* 312 * Called from ether_input() 313 */ 314static int 315ef_input(struct ifnet *ifp, struct ether_header *eh, struct mbuf *m) 316{ 317 u_short ether_type; 318 int ft = -1; |
319 struct efnet *efp; 320 struct ifnet *eifp; 321 struct llc *l; 322 struct ef_link *efl; |
323 int isr; |
324 325 ether_type = ntohs(eh->ether_type); 326 if (ether_type < ETHERMTU) { 327 l = mtod(m, struct llc*); 328 if (l->llc_dsap == 0xff && l->llc_ssap == 0xff) { 329 /* 330 * Novell's "802.3" frame 331 */ --- 44 unchanged lines hidden (view full) --- 376 m0.m_next = m; 377 m0.m_len = ETHER_HDR_LEN; 378 m0.m_data = (char *)eh; 379 BPF_MTAP(eifp, &m0); 380 } 381 /* 382 * Now we ready to adjust mbufs and pass them to protocol intr's 383 */ |
384 switch(ft) { |
385 case ETHER_FT_EII: 386 return (ef_inputEII(m, eh, ether_type)); |
387 break; 388#ifdef IPX |
389 case ETHER_FT_8023: /* only IPX can be here */ 390 isr = NETISR_IPX; |
391 break; 392#endif |
393 case ETHER_FT_SNAP: 394 return (ef_inputSNAP(m, eh, l, ether_type)); |
395 break; |
396 case ETHER_FT_8022: 397 return (ef_input8022(m, eh, l, ether_type)); |
398 break; |
399 default: |
400 EFDEBUG("No support for frame %d and proto %04x\n", 401 ft, ether_type); |
402 return (EPROTONOSUPPORT); |
403 } |
404 netisr_dispatch(isr, m); 405 return (0); |
406} 407 408static int 409ef_output(struct ifnet *ifp, struct mbuf **mp, struct sockaddr *dst, short *tp, 410 int *hlen) 411{ 412 struct mbuf *m = *mp; 413 u_char *cp; --- 191 unchanged lines hidden --- |