1/* 2 * Copyright (c) 1990,1994 Regents of The University of Michigan. 3 * All Rights Reserved. See COPYRIGHT. 4 *
| 1/* 2 * Copyright (c) 1990,1994 Regents of The University of Michigan. 3 * All Rights Reserved. See COPYRIGHT. 4 *
|
5 * $FreeBSD: head/sys/netatalk/ddp_input.c 101937 2002-08-15 18:58:44Z rwatson $
| 5 * $FreeBSD: head/sys/netatalk/ddp_input.c 111888 2003-03-04 23:19:55Z jlemon $
|
6 */ 7 8#include "opt_mac.h" 9 10#include <sys/param.h> 11#include <sys/kernel.h> 12#include <sys/lock.h> 13#include <sys/mac.h> 14#include <sys/mbuf.h> 15#include <sys/signalvar.h> 16#include <sys/socket.h> 17#include <sys/socketvar.h> 18#include <sys/sx.h> 19#include <sys/systm.h> 20#include <net/if.h>
| 6 */ 7 8#include "opt_mac.h" 9 10#include <sys/param.h> 11#include <sys/kernel.h> 12#include <sys/lock.h> 13#include <sys/mac.h> 14#include <sys/mbuf.h> 15#include <sys/signalvar.h> 16#include <sys/socket.h> 17#include <sys/socketvar.h> 18#include <sys/sx.h> 19#include <sys/systm.h> 20#include <net/if.h>
|
21#include <net/intrq.h> 22#include <net/netisr.h>
| |
23#include <net/route.h> 24 25#include <netatalk/at.h> 26#include <netatalk/at_var.h> 27#include <netatalk/ddp.h> 28#include <netatalk/ddp_var.h> 29#include <netatalk/at_extern.h> 30 31static volatile int ddp_forward = 1; 32static volatile int ddp_firewall = 0; 33static struct ddpstat ddpstat; 34static struct route forwro; 35 36static void ddp_input(struct mbuf *, struct ifnet *, struct elaphdr *, int); 37 38/* 39 * Could probably merge these two code segments a little better... 40 */
| 21#include <net/route.h> 22 23#include <netatalk/at.h> 24#include <netatalk/at_var.h> 25#include <netatalk/ddp.h> 26#include <netatalk/ddp_var.h> 27#include <netatalk/at_extern.h> 28 29static volatile int ddp_forward = 1; 30static volatile int ddp_firewall = 0; 31static struct ddpstat ddpstat; 32static struct route forwro; 33 34static void ddp_input(struct mbuf *, struct ifnet *, struct elaphdr *, int); 35 36/* 37 * Could probably merge these two code segments a little better... 38 */
|
41static void 42atintr( void )
| 39void 40at2intr(struct mbuf *m)
|
43{
| 41{
|
44 struct elaphdr *elhp, elh; 45 struct ifnet *ifp; 46 struct mbuf *m; 47 int s;
| |
48
| 42
|
49 /* 50 * First pull off all the phase 2 packets. 51 */ 52 for (;;) { 53 s = splimp();
| 43 /* 44 * Phase 2 packet handling 45 */ 46 ddp_input(m, m->m_pkthdr.rcvif, NULL, 2); 47 return; 48}
|
54
| 49
|
55 IF_DEQUEUE( &atintrq2, m );
| 50void 51at1intr(struct mbuf *m) 52{ 53 struct elaphdr *elhp, elh;
|
56
| 54
|
57 splx( s ); 58 59 if ( m == 0 ) { /* no more queued packets */ 60 break;
| 55 /* 56 * Phase 1 packet handling 57 */ 58 if (m->m_len < SZ_ELAPHDR && ((m = m_pullup(m, SZ_ELAPHDR)) == 0)) { 59 ddpstat.ddps_tooshort++; 60 return;
|
61 } 62
| 61 } 62
|
63 ifp = m->m_pkthdr.rcvif; 64 ddp_input( m, ifp, (struct elaphdr *)NULL, 2 ); 65 } 66 67 /* 68 * Then pull off all the phase 1 packets. 69 */ 70 for (;;) { 71 s = splimp(); 72 73 IF_DEQUEUE( &atintrq1, m ); 74 75 splx( s ); 76 77 if ( m == 0 ) { /* no more queued packets */ 78 break; 79 } 80 81 ifp = m->m_pkthdr.rcvif; 82 83 if ( m->m_len < SZ_ELAPHDR && 84 (( m = m_pullup( m, SZ_ELAPHDR )) == 0 )) { 85 ddpstat.ddps_tooshort++; 86 continue; 87 } 88
| |
89 /*
| 63 /*
|
90 * this seems a little dubios, but I don't know phase 1 so leave it.
| 64 * This seems a little dubious, but I don't know phase 1 so leave it.
|
91 */
| 65 */
|
92 elhp = mtod( m, struct elaphdr *); 93 m_adj( m, SZ_ELAPHDR );
| 66 elhp = mtod(m, struct elaphdr *); 67 m_adj(m, SZ_ELAPHDR);
|
94
| 68
|
95 if ( elhp->el_type == ELAP_DDPEXTEND ) { 96 ddp_input( m, ifp, (struct elaphdr *)NULL, 1 );
| 69 if (elhp->el_type == ELAP_DDPEXTEND) { 70 ddp_input(m, m->m_pkthdr.rcvif, NULL, 1);
|
97 } else {
| 71 } else {
|
98 bcopy((caddr_t)elhp, (caddr_t)&elh, SZ_ELAPHDR ); 99 ddp_input( m, ifp, &elh, 1 );
| 72 bcopy((caddr_t)elhp, (caddr_t)&elh, SZ_ELAPHDR); 73 ddp_input(m, m->m_pkthdr.rcvif, &elh, 1);
|
100 }
| 74 }
|
101 } 102 return;
| 75 return;
|
103} 104 105static void
| 76} 77 78static void
|
106netisr_atalk_setup(void *dummy __unused) 107{ 108 109 register_netisr(NETISR_ATALK, atintr); 110} 111SYSINIT(atalk_setup, SI_SUB_CPU, SI_ORDER_ANY, netisr_atalk_setup, NULL); 112 113static void
| |
114ddp_input( m, ifp, elh, phase ) 115 struct mbuf *m; 116 struct ifnet *ifp; 117 struct elaphdr *elh; 118 int phase; 119{ 120 struct sockaddr_at from, to; 121 struct ddpshdr *dsh, ddps;
--- 364 unchanged lines hidden --- | 79ddp_input( m, ifp, elh, phase ) 80 struct mbuf *m; 81 struct ifnet *ifp; 82 struct elaphdr *elh; 83 int phase; 84{ 85 struct sockaddr_at from, to; 86 struct ddpshdr *dsh, ddps;
--- 364 unchanged lines hidden --- |