diff options
author | julian <julian@FreeBSD.org> | 1996-07-23 01:18:47 +0000 |
---|---|---|
committer | julian <julian@FreeBSD.org> | 1996-07-23 01:18:47 +0000 |
commit | 7805978130bff3d12577cd0f7ab22e16fcf455ed (patch) | |
tree | 2385f2536a83e74266993dc1005df7f95645ba32 /sys/netatalk | |
parent | b38885b4106ac83ac9d14b4d9d6a8567a51abbbe (diff) | |
download | FreeBSD-src-7805978130bff3d12577cd0f7ab22e16fcf455ed.zip FreeBSD-src-7805978130bff3d12577cd0f7ab22e16fcf455ed.tar.gz |
Submitted by: archie@whistle.com
appletalk cleanups
Diffstat (limited to 'sys/netatalk')
-rw-r--r-- | sys/netatalk/aarp.c | 217 | ||||
-rw-r--r-- | sys/netatalk/aarp.h | 4 | ||||
-rw-r--r-- | sys/netatalk/at.h | 27 | ||||
-rw-r--r-- | sys/netatalk/at_control.c | 432 | ||||
-rw-r--r-- | sys/netatalk/at_proto.c | 31 | ||||
-rw-r--r-- | sys/netatalk/at_rmx.c | 2 | ||||
-rw-r--r-- | sys/netatalk/at_var.h | 10 | ||||
-rw-r--r-- | sys/netatalk/ddp_input.c | 51 | ||||
-rw-r--r-- | sys/netatalk/ddp_output.c | 126 | ||||
-rw-r--r-- | sys/netatalk/ddp_pcb.c | 66 | ||||
-rw-r--r-- | sys/netatalk/ddp_usrreq.c | 66 | ||||
-rw-r--r-- | sys/netatalk/endian.h | 62 | ||||
-rw-r--r-- | sys/netatalk/phase2.h | 73 |
13 files changed, 276 insertions, 891 deletions
diff --git a/sys/netatalk/aarp.c b/sys/netatalk/aarp.c index 84beef4..68c243f 100644 --- a/sys/netatalk/aarp.c +++ b/sys/netatalk/aarp.c @@ -8,30 +8,17 @@ #include <sys/socket.h> #include <sys/syslog.h> #include <sys/param.h> -#if defined( __FreeBSD__ ) #include <machine/endian.h> #include <sys/systm.h> #include <sys/proc.h> -#endif #include <sys/mbuf.h> #include <sys/time.h> -#ifndef _IBMR2 #include <sys/kernel.h> -#endif _IBMR2 #include <net/if.h> #include <net/route.h> -#if !defined( __FreeBSD__ ) -#include <net/af.h> -#endif #include <netinet/in.h> #undef s_net #include <netinet/if_ether.h> -#ifdef _IBMR2 -#include <netinet/in_netarp.h> -#include <net/spl.h> -#include <sys/errno.h> -#include <sys/err_rec.h> -#endif _IBMR2 #include <netatalk/at.h> #include <netatalk/at_var.h> @@ -43,13 +30,8 @@ static void aarptfree( struct aarptab *aat); static void at_aarpinput( struct arpcom *ac, struct mbuf *m); -#ifdef GATEWAY -#define AARPTAB_BSIZ 16 -#define AARPTAB_NB 37 -#else #define AARPTAB_BSIZ 9 #define AARPTAB_NB 19 -#endif GATEWAY #define AARPTAB_SIZE (AARPTAB_BSIZ * AARPTAB_NB) struct aarptab aarptab[AARPTAB_SIZE]; int aarptab_size = AARPTAB_SIZE; @@ -72,13 +54,9 @@ int aarptab_size = AARPTAB_SIZE; #define AARPT_KILLC 20 #define AARPT_KILLI 3 -#ifdef sun -extern struct ether_addr etherbroadcastaddr; -#else sun # if !defined( __FreeBSD__ ) extern u_char etherbroadcastaddr[6]; # endif __FreeBSD__ -#endif sun u_char atmulticastaddr[ 6 ] = { 0x09, 0x00, 0x07, 0xff, 0xff, 0xff, @@ -116,10 +94,8 @@ at_ifawithnet( sat, ifa ) struct sockaddr_at *sat; struct ifaddr *ifa; { - struct at_ifaddr *aa; for (; ifa; ifa = ifa->ifa_next ) { -#ifdef BSD4_4 if ( ifa->ifa_addr->sa_family != AF_APPLETALK ) { continue; } @@ -127,16 +103,6 @@ at_ifawithnet( sat, ifa ) sat->sat_addr.s_net ) { break; } -#else BSD4_4 - if ( ifa->ifa_addr.sa_family != AF_APPLETALK ) { - continue; - } - aa = (struct at_ifaddr *)ifa; - if ( ntohs( sat->sat_addr.s_net ) >= ntohs( aa->aa_firstnet ) && - ntohs( sat->sat_addr.s_net ) <= ntohs( aa->aa_lastnet )) { - break; - } -#endif BSD4_4 } return( ifa ); } @@ -151,20 +117,12 @@ aarpwhohas( struct arpcom *ac, struct sockaddr_at *sat ) struct llc *llc; struct sockaddr sa; -#ifdef BSD4_4 if (( m = m_gethdr( M_DONTWAIT, MT_DATA )) == NULL ) { return; } m->m_len = sizeof( *ea ); m->m_pkthdr.len = sizeof( *ea ); MH_ALIGN( m, sizeof( *ea )); -#else BSD4_4 - if (( m = m_get( M_DONTWAIT, MT_DATA )) == NULL ) { - return; - } - m->m_len = sizeof( *ea ); - m->m_off = MMAXOFF - sizeof( *ea ); -#endif BSD4_4 ea = mtod( m, struct ether_aarp *); bzero((caddr_t)ea, sizeof( *ea )); @@ -174,13 +132,8 @@ aarpwhohas( struct arpcom *ac, struct sockaddr_at *sat ) ea->aarp_hln = sizeof( ea->aarp_sha ); ea->aarp_pln = sizeof( ea->aarp_spu ); ea->aarp_op = htons( AARPOP_REQUEST ); -#ifdef sun - bcopy((caddr_t)&ac->ac_enaddr, (caddr_t)ea->aarp_sha, - sizeof( ea->aarp_sha )); -#else sun bcopy((caddr_t)ac->ac_enaddr, (caddr_t)ea->aarp_sha, sizeof( ea->aarp_sha )); -#endif sun /* * We need to check whether the output ethernet type should @@ -198,24 +151,10 @@ aarpwhohas( struct arpcom *ac, struct sockaddr_at *sat ) eh = (struct ether_header *)sa.sa_data; if ( aa->aa_flags & AFA_PHASE2 ) { -#ifdef sun - bcopy((caddr_t)atmulticastaddr, (caddr_t)&eh->ether_dhost, - sizeof( eh->ether_dhost )); -#else sun bcopy((caddr_t)atmulticastaddr, (caddr_t)eh->ether_dhost, sizeof( eh->ether_dhost )); -#endif sun -#if defined(sun) && defined(i386) eh->ether_type = htons(sizeof(struct llc) + sizeof(struct ether_aarp)); -#else - eh->ether_type = sizeof(struct llc) + sizeof(struct ether_aarp); -#endif -#ifdef BSD4_4 M_PREPEND( m, sizeof( struct llc ), M_WAIT ); -#else BSD4_4 - m->m_len += sizeof( struct llc ); - m->m_off -= sizeof( struct llc ); -#endif BSD4_4 llc = mtod( m, struct llc *); llc->llc_dsap = llc->llc_ssap = LLC_SNAP_LSAP; llc->llc_control = LLC_UI; @@ -229,18 +168,9 @@ aarpwhohas( struct arpcom *ac, struct sockaddr_at *sat ) ea->aarp_spnode = AA_SAT( aa )->sat_addr.s_node; ea->aarp_tpnode = sat->sat_addr.s_node; } else { -#ifdef sun - bcopy((caddr_t)ðerbroadcastaddr, (caddr_t)&eh->ether_dhost, - sizeof( eh->ether_dhost )); -#else sun bcopy((caddr_t)etherbroadcastaddr, (caddr_t)eh->ether_dhost, sizeof( eh->ether_dhost )); -#endif sun -#if defined(sun) && defined(i386) eh->ether_type = htons( ETHERTYPE_AARP ); -#else - eh->ether_type = ETHERTYPE_AARP; -#endif ea->aarp_spa = AA_SAT( aa )->sat_addr.s_node; ea->aarp_tpa = sat->sat_addr.s_node; @@ -252,15 +182,10 @@ aarpwhohas( struct arpcom *ac, struct sockaddr_at *sat ) AA_SAT( aa )->sat_addr.s_node); #endif NETATALKDEBUG -#ifdef BSD4_4 sa.sa_len = sizeof( struct sockaddr ); -#endif BSD4_4 sa.sa_family = AF_UNSPEC; - (*ac->ac_if.if_output)(&ac->ac_if, m, &sa -#if defined( __FreeBSD__ ) - , NULL /* XXX should be routing information */ -#endif __FreeBSD__ - ); + (*ac->ac_if.if_output)(&ac->ac_if, + m, &sa, NULL); /* XXX NULL should be routing information */ } int @@ -268,14 +193,9 @@ aarpresolve( ac, m, destsat, desten ) struct arpcom *ac; struct mbuf *m; struct sockaddr_at *destsat; -#ifdef sun - struct ether_addr *desten; -#else sun u_char *desten; -#endif sun { struct at_ifaddr *aa; - struct ifaddr ifa; struct aarptab *aat; int s; @@ -289,13 +209,8 @@ aarpresolve( ac, m, destsat, desten ) bcopy( (caddr_t)atmulticastaddr, (caddr_t)desten, sizeof( atmulticastaddr )); } else { -#ifdef sun - bcopy( (caddr_t)ðerbroadcastaddr, (caddr_t)desten, - sizeof( etherbroadcastaddr )); -#else sun bcopy( (caddr_t)etherbroadcastaddr, (caddr_t)desten, sizeof( etherbroadcastaddr )); -#endif sun } return( 1 ); } @@ -340,10 +255,6 @@ aarpinput( ac, m ) if ( ac->ac_if.if_flags & IFF_NOARP ) goto out; -#ifndef BSD4_4 - IF_ADJ( m ); -#endif BSD4_4 - if ( m->m_len < sizeof( struct arphdr )) { goto out; } @@ -374,7 +285,6 @@ out: static void at_aarpinput( struct arpcom *ac, struct mbuf *m) { - struct mbuf *m0; struct ether_aarp *ea; struct at_ifaddr *aa; struct aarptab *aat; @@ -383,33 +293,23 @@ at_aarpinput( struct arpcom *ac, struct mbuf *m) struct sockaddr_at sat; struct sockaddr sa; struct at_addr spa, tpa, ma; - int op, s; + int op; u_short net; ea = mtod( m, struct ether_aarp *); /* Check to see if from my hardware address */ -#ifdef sun - if ( !bcmp(( caddr_t )ea->aarp_sha, ( caddr_t )&ac->ac_enaddr, - sizeof( ac->ac_enaddr ))) { - m_freem( m ); - return; - } -#else sun if ( !bcmp(( caddr_t )ea->aarp_sha, ( caddr_t )ac->ac_enaddr, sizeof( ac->ac_enaddr ))) { m_freem( m ); return; } -#endif sun op = ntohs( ea->aarp_op ); bcopy( ea->aarp_tpnet, &net, sizeof( net )); if ( net != 0 ) { /* should be ATADDR_ANYNET? */ -#ifdef BSD4_4 sat.sat_len = sizeof(struct sockaddr_at); -#endif BSD4_4 sat.sat_family = AF_APPLETALK; sat.sat_addr.s_net = net; if (( aa = (struct at_ifaddr *)at_ifawithnet( &sat, @@ -463,16 +363,10 @@ at_aarpinput( struct arpcom *ac, struct mbuf *m) * that someone's saying they have the same source address * as the one we're using. Get upset... */ -#ifndef _IBMR2 -#ifdef ultrix - mprintf( LOG_ERR, -#else ultrix log( LOG_ERR, -#endif ultrix "aarp: duplicate AT address!! %x:%x:%x:%x:%x:%x\n", ea->aarp_sha[ 0 ], ea->aarp_sha[ 1 ], ea->aarp_sha[ 2 ], ea->aarp_sha[ 3 ], ea->aarp_sha[ 4 ], ea->aarp_sha[ 5 ]); -#endif _IBMR2 m_freem( m ); return; } @@ -495,32 +389,11 @@ at_aarpinput( struct arpcom *ac, struct mbuf *m) sizeof( ea->aarp_sha )); aat->aat_flags |= ATF_COM; if ( aat->aat_hold ) { -#ifdef _IBMR2 - /* - * Like in ddp_output(), we can't rely on the if_output - * routine to resolve AF_APPLETALK addresses, on the rs6k. - * So, we fill the destination ethernet address here. - * - * This should really be replaced with something like - * rsif_output(). XXX Will have to be for phase 2. - */ - /* XXX maybe fill in the rest of the frame header */ - sat.sat_family = AF_UNSPEC; - bcopy( aat->aat_enaddr, (*(struct sockaddr *)&sat).sa_data, - sizeof( aat->aat_enaddr )); -#else _IBMR2 -#ifdef BSD4_4 sat.sat_len = sizeof(struct sockaddr_at); -#endif BSD4_4 sat.sat_family = AF_APPLETALK; sat.sat_addr = spa; -#endif _IBMR2 (*ac->ac_if.if_output)( &ac->ac_if, aat->aat_hold, - (struct sockaddr *)&sat -#if defined( __FreeBSD__ ) - , NULL /* XXX */ -#endif __FreeBSD__ - ); + (struct sockaddr *)&sat, NULL); /* XXX */ aat->aat_hold = 0; } } @@ -546,47 +419,21 @@ at_aarpinput( struct arpcom *ac, struct mbuf *m) bcopy(( caddr_t )ea->aarp_sha, ( caddr_t )ea->aarp_tha, sizeof( ea->aarp_sha )); -#ifdef sun - bcopy(( caddr_t )&ac->ac_enaddr, ( caddr_t )ea->aarp_sha, - sizeof( ea->aarp_sha )); -#else sun bcopy(( caddr_t )ac->ac_enaddr, ( caddr_t )ea->aarp_sha, sizeof( ea->aarp_sha )); -#endif sun /* XXX */ eh = (struct ether_header *)sa.sa_data; -#ifdef sun - bcopy(( caddr_t )ea->aarp_tha, ( caddr_t )&eh->ether_dhost, - sizeof( eh->ether_dhost )); -#else sun bcopy(( caddr_t )ea->aarp_tha, ( caddr_t )eh->ether_dhost, sizeof( eh->ether_dhost )); -#endif sun if ( aa->aa_flags & AFA_PHASE2 ) { -#if defined(sun) && defined(i386) eh->ether_type = htons( sizeof( struct llc ) + sizeof( struct ether_aarp )); -#else - eh->ether_type = sizeof( struct llc ) + sizeof( struct ether_aarp ); -#endif -#ifdef BSD4_4 M_PREPEND( m, sizeof( struct llc ), M_DONTWAIT ); if ( m == NULL ) { return; } -#else BSD4_4 - MGET( m0, M_DONTWAIT, MT_HEADER ); - if ( m0 == NULL ) { - m_freem( m ); - return; - } - m0->m_next = m; - m = m0; - m->m_off = MMAXOFF - sizeof( struct llc ); - m->m_len = sizeof ( struct llc ); -#endif BSD4_4 llc = mtod( m, struct llc *); llc->llc_dsap = llc->llc_ssap = LLC_SNAP_LSAP; llc->llc_control = LLC_UI; @@ -596,26 +443,16 @@ at_aarpinput( struct arpcom *ac, struct mbuf *m) bcopy( ea->aarp_spnet, ea->aarp_tpnet, sizeof( ea->aarp_tpnet )); bcopy( &ma.s_net, ea->aarp_spnet, sizeof( ea->aarp_spnet )); } else { -#if defined(sun) && defined(i386) eh->ether_type = htons( ETHERTYPE_AARP ); -#else - eh->ether_type = ETHERTYPE_AARP; -#endif } ea->aarp_tpnode = ea->aarp_spnode; ea->aarp_spnode = ma.s_node; ea->aarp_op = htons( AARPOP_RESPONSE ); -#ifdef BSD4_4 sa.sa_len = sizeof( struct sockaddr ); -#endif BSD4_4 sa.sa_family = AF_UNSPEC; - (*ac->ac_if.if_output)( &ac->ac_if, m, &sa -#if defined( __FreeBSD__ ) - , NULL /* XXX */ -#endif - ); + (*ac->ac_if.if_output)( &ac->ac_if, m, &sa, NULL); /* XXX */ return; } @@ -703,20 +540,12 @@ aarpprobe( struct arpcom *ac ) timeout( (timeout_func_t)aarpprobe, (caddr_t)ac, hz / 5 ); } -#ifdef BSD4_4 if (( m = m_gethdr( M_DONTWAIT, MT_DATA )) == NULL ) { return; } m->m_len = sizeof( *ea ); m->m_pkthdr.len = sizeof( *ea ); MH_ALIGN( m, sizeof( *ea )); -#else BSD4_4 - if (( m = m_get( M_DONTWAIT, MT_DATA )) == NULL ) { - return; - } - m->m_len = sizeof( *ea ); - m->m_off = MMAXOFF - sizeof( *ea ); -#endif BSD4_4 ea = mtod( m, struct ether_aarp *); bzero((caddr_t)ea, sizeof( *ea )); @@ -726,36 +555,17 @@ aarpprobe( struct arpcom *ac ) ea->aarp_hln = sizeof( ea->aarp_sha ); ea->aarp_pln = sizeof( ea->aarp_spu ); ea->aarp_op = htons( AARPOP_PROBE ); -#ifdef sun - bcopy((caddr_t)&ac->ac_enaddr, (caddr_t)ea->aarp_sha, - sizeof( ea->aarp_sha )); -#else sun bcopy((caddr_t)ac->ac_enaddr, (caddr_t)ea->aarp_sha, sizeof( ea->aarp_sha )); -#endif sun eh = (struct ether_header *)sa.sa_data; if ( aa->aa_flags & AFA_PHASE2 ) { -#ifdef sun - bcopy((caddr_t)atmulticastaddr, (caddr_t)&eh->ether_dhost, - sizeof( eh->ether_dhost )); -#else sun bcopy((caddr_t)atmulticastaddr, (caddr_t)eh->ether_dhost, sizeof( eh->ether_dhost )); -#endif sun -#if defined(sun) && defined(i386) eh->ether_type = htons( sizeof( struct llc ) + sizeof( struct ether_aarp )); -#else - eh->ether_type = sizeof( struct llc ) + sizeof( struct ether_aarp ); -#endif -#ifdef BSD4_4 M_PREPEND( m, sizeof( struct llc ), M_WAIT ); -#else BSD4_4 - m->m_len += sizeof( struct llc ); - m->m_off -= sizeof( struct llc ); -#endif BSD4_4 llc = mtod( m, struct llc *); llc->llc_dsap = llc->llc_ssap = LLC_SNAP_LSAP; llc->llc_control = LLC_UI; @@ -768,18 +578,9 @@ aarpprobe( struct arpcom *ac ) sizeof( ea->aarp_tpnet )); ea->aarp_spnode = ea->aarp_tpnode = AA_SAT( aa )->sat_addr.s_node; } else { -#ifdef sun - bcopy((caddr_t)ðerbroadcastaddr, (caddr_t)&eh->ether_dhost, - sizeof( eh->ether_dhost )); -#else sun bcopy((caddr_t)etherbroadcastaddr, (caddr_t)eh->ether_dhost, sizeof( eh->ether_dhost )); -#endif sun -#if defined(sun) && defined(i386) eh->ether_type = htons( ETHERTYPE_AARP ); -#else - eh->ether_type = ETHERTYPE_AARP; -#endif ea->aarp_spa = ea->aarp_tpa = AA_SAT( aa )->sat_addr.s_node; } @@ -789,15 +590,9 @@ aarpprobe( struct arpcom *ac ) AA_SAT( aa )->sat_addr.s_node); #endif NETATALKDEBUG -#ifdef BSD4_4 sa.sa_len = sizeof( struct sockaddr ); -#endif BSD4_4 sa.sa_family = AF_UNSPEC; - (*ac->ac_if.if_output)(&ac->ac_if, m, &sa -#if defined( __FreeBSD__ ) - , NULL /* XXX */ -#endif __FreeBSD__ - ); + (*ac->ac_if.if_output)(&ac->ac_if, m, &sa, NULL); /* XXX */ aa->aa_probcnt--; } diff --git a/sys/netatalk/aarp.h b/sys/netatalk/aarp.h index 4911538..d97c31f 100644 --- a/sys/netatalk/aarp.h +++ b/sys/netatalk/aarp.h @@ -55,8 +55,6 @@ struct aarptab { #ifdef KERNEL struct aarptab *aarptnew(struct at_addr *); -#if !defined( __FreeBSD__ ) -int aarpprobe(); -#endif #endif + #endif /* _NETATALK_AARP_H_ */ diff --git a/sys/netatalk/at.h b/sys/netatalk/at.h index eca11fb..d9b4691 100644 --- a/sys/netatalk/at.h +++ b/sys/netatalk/at.h @@ -58,11 +58,7 @@ struct at_addr { u_char s_node; }; -#if defined( BSD4_4 ) && !defined( __FreeBSD__ ) -#define ATADDR_ANYNET (u_short)0xffff -#else #define ATADDR_ANYNET (u_short)0x0000 -#endif #define ATADDR_ANYNODE (u_char)0x00 #define ATADDR_ANYPORT (u_char)0x00 #define ATADDR_BCAST (u_char)0xff /* There is no BCAST for NET */ @@ -75,32 +71,11 @@ struct at_addr { * by the kernel. */ struct sockaddr_at { -#ifdef BSD4_4 u_char sat_len; u_char sat_family; -#else BSD4_4 - short sat_family; -#endif BSD4_4 u_char sat_port; struct at_addr sat_addr; -#ifdef notdef - struct { - u_char sh_type; -# define SATHINT_NONE 0 -# define SATHINT_CONFIG 1 -# define SATHINT_IFACE 2 - union { - char su_zero[ 7 ]; /* XXX check size */ - struct { - u_char sr_phase; - u_short sr_firstnet, sr_lastnet; - } su_range; - u_short su_interface; - } sh_un; - } sat_hints; -#else notdef - char sat_zero[ 8 ]; -#endif notdef + char sat_zero[ 8 ]; /* Hide a struct netrange in here */ }; struct netrange { diff --git a/sys/netatalk/at_control.c b/sys/netatalk/at_control.c index 5a1294f..8ae0f62 100644 --- a/sys/netatalk/at_control.c +++ b/sys/netatalk/at_control.c @@ -5,31 +5,19 @@ #include <sys/param.h> #include <sys/systm.h> -#ifdef ibm032 -#include <sys/dir.h> -#endif ibm032 #include <sys/proc.h> -#ifndef BSD4_4 -#include <sys/user.h> -#endif #include <sys/types.h> #include <sys/errno.h> #include <sys/ioctl.h> #include <sys/mbuf.h> -#ifndef _IBMR2 #include <sys/kernel.h> -#endif _IBMR2 #include <sys/socket.h> #include <sys/socketvar.h> #include <net/if.h> -/* #include <net/af.h> */ #include <net/route.h> #include <netinet/in.h> #undef s_net #include <netinet/if_ether.h> -#ifdef _IBMR2 -#include <net/spl.h> -#endif _IBMR2 #include "at.h" #include "at_var.h" @@ -37,47 +25,21 @@ #include "phase2.h" #include <netatalk/at_extern.h> +static int aa_addrangeroute(struct ifaddr *ifa, int first, int last); +static int aa_addsingleroute(struct ifaddr *ifa, + struct at_addr *addr, struct at_addr *mask); +static int aa_delsingleroute(struct ifaddr *ifa, + struct at_addr *addr, struct at_addr *mask); +static int aa_dosingleroute(struct ifaddr *ifa, struct at_addr *addr, + struct at_addr *mask, int cmd, int flags); static int at_scrub( struct ifnet *ifp, struct at_ifaddr *aa ); static int at_ifinit( struct ifnet *ifp, struct at_ifaddr *aa, struct sockaddr_at *sat ); -#ifdef BSD4_4 # define sateqaddr(a,b) ((a)->sat_len == (b)->sat_len && \ (a)->sat_family == (b)->sat_family && \ (a)->sat_addr.s_net == (b)->sat_addr.s_net && \ (a)->sat_addr.s_node == (b)->sat_addr.s_node ) -#else BSD4_4 -atalk_hash( sat, hp ) - struct sockaddr_at *sat; - struct afhash *hp; -{ - hp->afh_nethash = sat->sat_addr.s_net; - hp->afh_hosthash = ( sat->sat_addr.s_net << 8 ) + - sat->sat_addr.s_node; -} - -/* - * Note the magic to get ifa_ifwithnet() to work without adding an - * ifaddr entry for each net in our local range. - */ -int -atalk_netmatch( sat1, sat2 ) - struct sockaddr_at *sat1, *sat2; -{ - struct at_ifaddr *aa; - - for ( aa = at_ifaddr; aa; aa = aa->aa_next ) { - if ( AA_SAT( aa ) == sat1 ) { - break; - } - } - if ( aa ) { - return( ntohs( aa->aa_firstnet ) <= ntohs( sat2->sat_addr.s_net ) && - ntohs( aa->aa_lastnet ) >= ntohs( sat2->sat_addr.s_net )); - } - return( sat1->sat_addr.s_net == sat2->sat_addr.s_net ); -} -#endif BSD4_4 int at_control( int cmd, caddr_t data, struct ifnet *ifp, struct proc *p ) @@ -85,10 +47,8 @@ at_control( int cmd, caddr_t data, struct ifnet *ifp, struct proc *p ) struct ifreq *ifr = (struct ifreq *)data; struct sockaddr_at *sat; struct netrange *nr; -#ifdef BSD4_4 struct at_aliasreq *ifra = (struct at_aliasreq *)data; struct at_ifaddr *aa0; -#endif BSD4_4 struct at_ifaddr *aa = 0; struct mbuf *m; struct ifaddr *ifa; @@ -100,7 +60,6 @@ at_control( int cmd, caddr_t data, struct ifnet *ifp, struct proc *p ) } switch ( cmd ) { -#ifdef BSD4_4 case SIOCAIFADDR: case SIOCDIFADDR: if ( ifra->ifra_addr.sat_family == AF_APPLETALK ) { @@ -115,26 +74,11 @@ at_control( int cmd, caddr_t data, struct ifnet *ifp, struct proc *p ) return( EADDRNOTAVAIL ); } /*FALLTHROUGH*/ -#endif BSD4_4 case SIOCSIFADDR: -#ifdef BSD4_4 - /* - * What a great idea this is: Let's reverse the meaning of - * the return... - */ -#if defined( __FreeBSD__ ) if ( suser(p->p_ucred, &p->p_acflag) ) { -#else - if ( suser( u.u_cred, &u.u_acflag )) { -#endif - return( EPERM ); - } -#else BSD4_4 - if ( !suser()) { return( EPERM ); } -#endif BSD4_4 sat = satosat( &ifr->ifr_addr ); nr = (struct netrange *)sat->sat_zero; @@ -191,11 +135,9 @@ at_control( int cmd, caddr_t data, struct ifnet *ifp, struct proc *p ) ifp->if_addrlist = (struct ifaddr *)aa; } -#ifdef BSD4_4 aa->aa_ifa.ifa_addr = (struct sockaddr *)&aa->aa_addr; aa->aa_ifa.ifa_dstaddr = (struct sockaddr *)&aa->aa_addr; aa->aa_ifa.ifa_netmask = (struct sockaddr *)&aa->aa_netmask; -#endif BSD4_4 /* * Set/clear the phase 2 bit. @@ -236,17 +178,17 @@ at_control( int cmd, caddr_t data, struct ifnet *ifp, struct proc *p ) switch ( cmd ) { case SIOCGIFADDR: -#ifdef BSD4_4 - *(struct sockaddr_at *)&ifr->ifr_addr = aa->aa_addr; -#else BSD4_4 - ifr->ifr_addr = aa->aa_addr; -#endif BSD4_4 + sat = (struct sockaddr_at *)&ifr->ifr_addr; + *sat = aa->aa_addr; + ((struct netrange *)&sat->sat_zero)->nr_phase + = (aa->aa_flags & AFA_PHASE2) ? 2 : 1; + ((struct netrange *)&sat->sat_zero)->nr_firstnet = aa->aa_firstnet; + ((struct netrange *)&sat->sat_zero)->nr_lastnet = aa->aa_lastnet; break; case SIOCSIFADDR: return( at_ifinit( ifp, aa, (struct sockaddr_at *)&ifr->ifr_addr )); -#ifdef BSD4_4 case SIOCAIFADDR: if ( sateqaddr( &ifra->ifra_addr, &aa->aa_addr )) { return( 0 ); @@ -283,7 +225,6 @@ at_control( int cmd, caddr_t data, struct ifnet *ifp, struct proc *p ) } m_free( dtom( aa0 )); break; -#endif BSD4_4 default: if ( ifp == 0 || ifp->if_ioctl == 0 ) @@ -292,60 +233,25 @@ at_control( int cmd, caddr_t data, struct ifnet *ifp, struct proc *p ) } return( 0 ); } + static int at_scrub( ifp, aa ) struct ifnet *ifp; struct at_ifaddr *aa; { -#ifndef BSD4_4 - struct sockaddr_at netsat; - u_short net; -#endif BSD4_4 int error; if ( aa->aa_flags & AFA_ROUTE ) { -#ifdef BSD4_4 if (( error = rtinit( &(aa->aa_ifa), RTM_DELETE, ( ifp->if_flags & IFF_LOOPBACK ) ? RTF_HOST : 0 )) != 0 ) { return( error ); } aa->aa_ifa.ifa_flags &= ~IFA_ROUTE; -#else BSD4_4 - if ( ifp->if_flags & IFF_LOOPBACK ) { - rtinit( &aa->aa_addr, &aa->aa_addr, SIOCDELRT, RTF_HOST ); - } else { - bzero( &netsat, sizeof( struct sockaddr_at )); - netsat.sat_family = AF_APPLETALK; - netsat.sat_addr.s_node = ATADDR_ANYNODE; - - /* - * If the range is the full 0-fffe range, just use - * the default route. - */ - if ( aa->aa_firstnet == htons( 0x0000 ) && - aa->aa_lastnet == htons( 0xfffe )) { - netsat.sat_addr.s_net = 0; - rtinit((struct sockaddr *)&netsat, &aa->aa_addr, - (int)SIOCDELRT, 0 ); - } else { - for ( net = ntohs( aa->aa_firstnet ); - net <= ntohs( aa->aa_lastnet ); net++ ) { - netsat.sat_addr.s_net = htons( net ); - rtinit((struct sockaddr *)&netsat, &aa->aa_addr, - (int)SIOCDELRT, 0 ); - } - } - } -#endif BSD4_4 aa->aa_flags &= ~AFA_ROUTE; } return( 0 ); } -#if !defined( __FreeBSD__ ) -extern struct timeval time; -#endif __FreeBSD__ - static int at_ifinit( ifp, aa, sat ) struct ifnet *ifp; @@ -353,18 +259,15 @@ at_ifinit( ifp, aa, sat ) struct sockaddr_at *sat; { struct netrange nr, onr; -#ifdef BSD4_4 struct sockaddr_at oldaddr; -#else BSD4_4 - struct sockaddr oldaddr; -#endif BSD4_4 - struct sockaddr_at netaddr; - int s = splimp(), error = 0, i, j, netinc, nodeinc, nnets; + int s = splimp(), error = 0, i, j; + int flags = RTF_UP, netinc, nodeinc, nnets; u_short net; oldaddr = aa->aa_addr; bzero( AA_SAT( aa ), sizeof( struct sockaddr_at )); bcopy( sat->sat_zero, &nr, sizeof( struct netrange )); + bcopy( sat->sat_zero, AA_SAT( aa )->sat_zero, sizeof( struct netrange )); nnets = ntohs( nr.nr_lastnet ) - ntohs( nr.nr_firstnet ) + 1; onr.nr_firstnet = aa->aa_firstnet; @@ -372,6 +275,13 @@ at_ifinit( ifp, aa, sat ) aa->aa_firstnet = nr.nr_firstnet; aa->aa_lastnet = nr.nr_lastnet; +/* XXX ALC */ + printf("at_ifinit: %s: %u.%u range %u-%u phase %d\n", + ifp->if_name, + ntohs(sat->sat_addr.s_net), sat->sat_addr.s_node, + ntohs(aa->aa_firstnet), ntohs(aa->aa_lastnet), + (aa->aa_flags & AFA_PHASE2) ? 2 : 1); + /* * We could eliminate the need for a second phase 1 probe (post * autoconf) if we check whether we're resetting the node. Note @@ -379,17 +289,17 @@ at_ifinit( ifp, aa, sat ) * phase 2, both the net and node must be the same. */ if ( ifp->if_flags & IFF_LOOPBACK ) { -#ifdef BSD4_4 AA_SAT( aa )->sat_len = sat->sat_len; -#endif BSD4_4 AA_SAT( aa )->sat_family = AF_APPLETALK; AA_SAT( aa )->sat_addr.s_net = sat->sat_addr.s_net; AA_SAT( aa )->sat_addr.s_node = sat->sat_addr.s_node; +#if 0 + } else if ( fp->if_flags & IFF_POINTOPOINT) { + /* unimplemented */ +#endif } else { aa->aa_flags |= AFA_PROBING; -#ifdef BSD4_4 AA_SAT( aa )->sat_len = sizeof(struct sockaddr_at); -#endif BSD4_4 AA_SAT( aa )->sat_family = AF_APPLETALK; if ( aa->aa_flags & AFA_PHASE2 ) { if ( sat->sat_addr.s_net == ATADDR_ANYNET ) { @@ -431,14 +341,8 @@ at_ifinit( ifp, aa, sat ) aa->aa_probcnt = 10; timeout( (timeout_func_t)aarpprobe, (caddr_t)ifp, hz / 5 ); splx( s ); - if ( -#if defined( __FreeBSD__ ) - tsleep( aa, PPAUSE|PCATCH, "at_ifinit", 0 ) -#else - sleep( aa, PSLEP|PCATCH ) -#endif - ) { - printf( "at_ifinit why did this happen?!\n" ); + if ( tsleep( aa, PPAUSE|PCATCH, "at_ifinit", 0 )) { + printf( "at_ifinit: why did this happen?!\n" ); aa->aa_addr = oldaddr; aa->aa_firstnet = onr.nr_firstnet; aa->aa_lastnet = onr.nr_lastnet; @@ -467,86 +371,79 @@ at_ifinit( ifp, aa, sat ) if ( ifp->if_ioctl && ( error = (*ifp->if_ioctl)( ifp, SIOCSIFADDR, (caddr_t)aa ))) { - splx( s ); aa->aa_addr = oldaddr; aa->aa_firstnet = onr.nr_firstnet; aa->aa_lastnet = onr.nr_lastnet; + splx( s ); return( error ); } -#ifdef BSD4_4 - aa->aa_netmask.sat_len = 6/*sizeof(struct sockaddr_at)*/; + /* Initialize interface netmask, which is silly for us */ + + bzero(&aa->aa_netmask, sizeof(aa->aa_netmask)); + aa->aa_netmask.sat_len = sizeof(struct sockaddr_at); aa->aa_netmask.sat_family = AF_APPLETALK; - aa->aa_netmask.sat_addr.s_net = 0xffff; - aa->aa_netmask.sat_addr.s_node = 0; -#if defined( __FreeBSD__ ) - aa->aa_ifa.ifa_netmask =(struct sockaddr *) &(aa->aa_netmask); /* XXX */ -#endif __FreeBSD__ -#endif BSD4_4 + aa->aa_ifa.ifa_netmask = (struct sockaddr *) &aa->aa_netmask; + + /* "Add a route to the network" */ + + aa->aa_ifa.ifa_metric = ifp->if_metric; + if (ifp->if_flags & IFF_BROADCAST) { + bzero(&aa->aa_broadaddr, sizeof(aa->aa_broadaddr)); + aa->aa_broadaddr.sat_len = sat->sat_len; + aa->aa_broadaddr.sat_family = AF_APPLETALK; + aa->aa_broadaddr.sat_addr.s_net = htons(0); + aa->aa_broadaddr.sat_addr.s_node = 0xff; + aa->aa_ifa.ifa_broadaddr = (struct sockaddr *) &aa->aa_broadaddr; + aa->aa_netmask.sat_addr.s_net = htons(0xffff); /* XXX */ + aa->aa_netmask.sat_addr.s_node = htons(0); /* XXX */ + } else if (ifp->if_flags & IFF_LOOPBACK) { + aa->aa_ifa.ifa_dstaddr = aa->aa_ifa.ifa_addr; + aa->aa_netmask.sat_addr.s_net = htons(0xffff); /* XXX */ + aa->aa_netmask.sat_addr.s_node = htons(0xffff); /* XXX */ + flags |= RTF_HOST; + } else if (ifp->if_flags & IFF_POINTOPOINT) { + aa->aa_ifa.ifa_dstaddr = aa->aa_ifa.ifa_addr; + aa->aa_netmask.sat_addr.s_net = htons(0xffff); + aa->aa_netmask.sat_addr.s_node = htons(0xffff); + flags |= RTF_HOST; + } + error = rtinit(&(aa->aa_ifa), (int)RTM_ADD, flags); +#if 0 if ( ifp->if_flags & IFF_LOOPBACK ) { -#ifndef BSD4_4 - rtinit( &aa->aa_addr, &aa->aa_addr, (int)SIOCADDRT, - RTF_HOST|RTF_UP ); -#else BSD4_4 - error = rtinit( &(aa->aa_ifa), (int)RTM_ADD, -#if !defined( __FreeBSD__ ) - RTF_HOST | -#else - /* XXX not a host route? */ -#endif __FreeBSD__ - RTF_UP ); -#endif BSD4_4 + struct at_addr rtaddr, rtmask; + + bzero(&rtaddr, sizeof(rtaddr)); + bzero(&rtmask, sizeof(rtmask)); + rtaddr.s_net = AA_SAT( aa )->sat_addr.s_net; + rtaddr.s_node = AA_SAT( aa )->sat_addr.s_node; + rtmask.s_net = 0xffff; + rtmask.s_node = 0xff; + + error = aa_addsingleroute(&aa->aa_ifa, &rtaddr, &rtmask); + } else { -#ifndef BSD4_4 - /* - * rtrequest looks for point-to-point links first. The - * broadaddr is in the same spot as the destaddr. So, if - * ATADDR_ANYNET is 0, and we don't fill in the broadaddr, we - * get 0.0 routed out the ether interface. So, initialize the - * broadaddr, even tho we don't use it. - * - * We *could* use the broadaddr field to reduce some of the - * sockaddr_at overloading that we've done. E.g. Just send - * to INTERFACE-NET.255, and have the kernel reroute that - * to broadaddr, which would be 0.255 for phase 2 interfaces, - * and IFACE-NET.255 for phase 1 interfaces. - */ - ((struct sockaddr_at *)&aa->aa_broadaddr)->sat_addr.s_net = - sat->sat_addr.s_net; - ((struct sockaddr_at *)&aa->aa_broadaddr)->sat_addr.s_node = - ATADDR_BCAST; - - bzero( &netaddr, sizeof( struct sockaddr_at )); - netaddr.sat_family = AF_APPLETALK; - netaddr.sat_addr.s_node = ATADDR_ANYNODE; - if (( aa->aa_flags & AFA_PHASE2 ) == 0 ) { - netaddr.sat_addr.s_net = AA_SAT( aa )->sat_addr.s_net; - rtinit((struct sockaddr *)&netaddr, &aa->aa_addr, - (int)SIOCADDRT, RTF_UP ); - } else { - /* - * If the range is the full 0-fffe range, just use - * the default route. - */ - if ( aa->aa_firstnet == htons( 0x0000 ) && - aa->aa_lastnet == htons( 0xfffe )) { - netaddr.sat_addr.s_net = 0; - rtinit((struct sockaddr *)&netaddr, &aa->aa_addr, - (int)SIOCADDRT, RTF_UP ); - } else { - for ( net = ntohs( aa->aa_firstnet ); - net <= ntohs( aa->aa_lastnet ); net++ ) { - netaddr.sat_addr.s_net = htons( net ); - rtinit((struct sockaddr *)&netaddr, &aa->aa_addr, - (int)SIOCADDRT, RTF_UP ); - } - } - } -#else BSD4_4 - error = rtinit( &(aa->aa_ifa), (int)RTM_ADD, RTF_UP ); -#endif BSD4_4 + + /* Install routes for our own network, and then also for + all networks above and below it in the network range */ + + error = aa_addrangeroute(&aa->aa_ifa, + ntohs(aa->aa_addr.sat_addr.s_net), + ntohs(aa->aa_addr.sat_addr.s_net) + 1); + if (!error + && ntohs(aa->aa_firstnet) < ntohs(aa->aa_addr.sat_addr.s_net)) + error = aa_addrangeroute(&aa->aa_ifa, + ntohs(aa->aa_firstnet), ntohs(aa->aa_addr.sat_addr.s_net)); + if (!error + && ntohs(aa->aa_addr.sat_addr.s_net) < ntohs(aa->aa_lastnet)) + error = aa_addrangeroute(&aa->aa_ifa, + ntohs(aa->aa_addr.sat_addr.s_net) + 1, + ntohs(aa->aa_lastnet) + 1); } +#endif + + if ( error ) { aa->aa_addr = oldaddr; aa->aa_firstnet = onr.nr_firstnet; @@ -555,9 +452,7 @@ at_ifinit( ifp, aa, sat ) return( error ); } -#ifdef BSD4_4 aa->aa_ifa.ifa_flags |= IFA_ROUTE; -#endif BSD4_4 aa->aa_flags |= AFA_ROUTE; splx( s ); return( 0 ); @@ -586,6 +481,146 @@ at_broadcast( sat ) return( 0 ); } +/* + * aa_addrangeroute() + * + * Add a route for a range of networks from bot to top - 1. + * Algorithm: + * + * Split the range into three subranges such that the middle + * subrange is from (base + 2^N) to (base + 2^N + 2^(N-1)) for + * some N. Then add a route for the middle range and recurse on + * the upper and lower sub-ranges. As a degenerate case, it may + * be that the middle subrange is empty. + */ + +static int +aa_addrangeroute(struct ifaddr *ifa, int bot, int top) +{ + int base, mask, mbot, mtop; + int a, b, abit, bbit, error; + struct at_addr rtaddr, rtmask; + +/* Special case the whole range */ + + if (bot == 0 && top == 0xffff) + { + bzero(&rtaddr, sizeof(rtaddr)); + bzero(&rtmask, sizeof(rtmask)); + return(aa_addsingleroute(ifa, &rtaddr, &rtmask)); + } + + if (top <= bot) + panic("aa_addrangeroute"); + +/* Mask out the high order bits on which both bounds agree */ + + for (mask = 0xffff; (bot & mask) != (top & mask); mask <<= 1); + base = bot & mask; + a = bot & ~mask; + b = top & ~mask; + +/* Find suitable powers of two between a and b we can make a route with */ + + for (bbit = 0x8000; bbit > b; bbit >>= 1); + if (a == 0) + abit = 0; + else + { + for (abit = 0x0001; a > abit; abit <<= 1); + if ((abit << 1) > bbit) + bbit = abit; + else + bbit = abit << 1; + } + +/* Now we have a "square" middle chunk from abit to bbit, possibly empty */ + + mbot = base + abit; + mtop = base + bbit; + mask = ~(bbit - 1); + +/* Route to the middle chunk */ + + if (mbot < mtop) + { + bzero(&rtaddr, sizeof(rtaddr)); + bzero(&rtmask, sizeof(rtmask)); + rtaddr.s_net = htons((u_short) mbot); + rtmask.s_net = htons((u_short) mask); + if ((error = aa_addsingleroute(ifa, &rtaddr, &rtmask))) + return(error); + } + +/* Recurse on the upper and lower chunks we didn't get to */ + + if (bot < mbot) + if ((error = aa_addrangeroute(ifa, bot, mbot))) + { + if (mbot < mtop) + aa_delsingleroute(ifa, &rtaddr, &rtmask); + return(error); + } + if (mtop < top) + if ((error = aa_addrangeroute(ifa, mtop, top))) + { + if (mbot < mtop) + aa_delsingleroute(ifa, &rtaddr, &rtmask); + return(error); + } + return(0); +} + +static int +aa_addsingleroute(struct ifaddr *ifa, + struct at_addr *addr, struct at_addr *mask) +{ + int error; + + printf("aa_addsingleroute: %x.%x mask %x.%x ...\n", + ntohs(addr->s_net), addr->s_node, + ntohs(mask->s_net), mask->s_node); + + error = aa_dosingleroute(ifa, addr, mask, RTM_ADD, RTF_UP); + if (error) + printf("error %d\n", error); + return(error); +} + +static int +aa_delsingleroute(struct ifaddr *ifa, + struct at_addr *addr, struct at_addr *mask) +{ + int error; + + error = aa_dosingleroute(ifa, addr, mask, RTM_DELETE, 0); + if (error) + printf("aa_delsingleroute: error %d\n", error); + return(error); +} + +static int +aa_dosingleroute(struct ifaddr *ifa, + struct at_addr *at_addr, struct at_addr *at_mask, int cmd, int flags) +{ + struct sockaddr_at addr, mask; + + bzero(&addr, sizeof(addr)); + bzero(&mask, sizeof(mask)); + addr.sat_family = AF_APPLETALK; + addr.sat_len = sizeof(struct sockaddr_at); + addr.sat_addr.s_net = at_addr->s_net; + addr.sat_addr.s_node = at_addr->s_node; + mask.sat_addr.s_net = at_mask->s_net; + mask.sat_addr.s_node = at_mask->s_node; + if (at_mask->s_node) + flags |= RTF_HOST; + return(rtrequest(cmd, (struct sockaddr *) &addr, ifa->ifa_addr, + (struct sockaddr *) &mask, flags, NULL)); +} + +#if 0 + static void aa_clean(void) { @@ -612,3 +647,6 @@ aa_clean(void) } } } + +#endif + diff --git a/sys/netatalk/at_proto.c b/sys/netatalk/at_proto.c index 0c8fdbf..ce830b6 100644 --- a/sys/netatalk/at_proto.c +++ b/sys/netatalk/at_proto.c @@ -28,14 +28,12 @@ #include <sys/types.h> #include <sys/socket.h> -#if defined( __FreeBSD__ ) #include <sys/kernel.h> #include <net/if.h> #include <net/radix.h> #include <netinet/in.h> #include <netinet/if_ether.h> #include <net/route.h> -#endif #include "at.h" #include "ddp.h" @@ -44,12 +42,6 @@ #include <netatalk/at_extern.h> -#ifdef ultrix -extern int ddp_ifoutput(); -extern int ddp_ifinput(); -extern int ddp_ifioctl(); -#endif ultrix - struct protosw atalksw[] = { { /* Identifiers */ @@ -67,29 +59,16 @@ struct protosw atalksw[] = { ddp_usrreq, /* utility routines. */ ddp_init, 0, 0, 0, -#ifdef ultrix - /* interface hooks */ - ddp_ifoutput, ddp_ifinput, ddp_ifioctl, 0, -#endif ultrix }, }; -#if defined( __FreeBSD__ ) && defined ( NETATALKDEBUG ) -extern int at_inithead(); -#endif - struct domain atalkdomain = { AF_APPLETALK, "appletalk", 0, 0, 0, - atalksw, &atalksw[sizeof(atalksw)/sizeof(atalksw[0])] -#if defined( __FreeBSD__ ) -#ifdef NETATALKDEBUG - , 0, at_inithead, 32, sizeof(struct sockaddr_at) -#else - , 0, rn_inithead, 32, sizeof(struct sockaddr_at) -#endif -#endif + atalksw, &atalksw[sizeof(atalksw)/sizeof(atalksw[0])], + 0, rn_inithead, + ((caddr_t) &((struct sockaddr_at *) 0)->sat_addr - (caddr_t)0), + sizeof(struct sockaddr_at) }; -#if defined( __FreeBSD__ ) DOMAIN_SET(atalk); -#endif + diff --git a/sys/netatalk/at_rmx.c b/sys/netatalk/at_rmx.c index 73747b6..2dc4ffd 100644 --- a/sys/netatalk/at_rmx.c +++ b/sys/netatalk/at_rmx.c @@ -78,7 +78,6 @@ at_addroute(void *v_arg, void *n_arg, struct radix_node_head *head, struct radix_node *treenodes) { struct radix_node *rn; - struct sockaddr_at *dst = v_arg, *mask = n_arg; printf("at_addroute: v=%s\n", prsockaddr(v_arg)); printf("at_addroute: n=%s\n", prsockaddr(n_arg)); @@ -95,7 +94,6 @@ static struct radix_node * at_matroute(void *v_arg, struct radix_node_head *head) { struct radix_node *rn; - struct sockaddr_at *dst = v_arg; printf("at_matroute: v=%s\n", prsockaddr(v_arg)); printf("at_matroute: head=%x\n", head); diff --git a/sys/netatalk/at_var.h b/sys/netatalk/at_var.h index 31b4526..49af480 100644 --- a/sys/netatalk/at_var.h +++ b/sys/netatalk/at_var.h @@ -30,22 +30,16 @@ struct at_ifaddr { struct ifaddr aa_ifa; # define aa_ifp aa_ifa.ifa_ifp -#ifdef BSD4_4 struct sockaddr_at aa_addr; struct sockaddr_at aa_broadaddr; +# define aa_dstaddr aa_netmask struct sockaddr_at aa_netmask; -#else BSD4_4 -# define aa_addr aa_ifa.ifa_addr -# define aa_broadaddr aa_ifa.ifa_broadaddr -# define aa_dstaddr aa_ifa.ifa_dstaddr -#endif BSD4_4 int aa_flags; u_short aa_firstnet, aa_lastnet; int aa_probcnt; struct at_ifaddr *aa_next; }; -#ifdef BSD4_4 struct at_aliasreq { char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */ struct sockaddr_at ifra_addr; @@ -53,7 +47,6 @@ struct at_aliasreq { #define ifra_dstaddr ifra_broadaddr struct sockaddr_at ifra_mask; }; -#endif BSD4_4 #define AA_SAT(aa) \ ((struct sockaddr_at *)&((struct at_ifaddr *)(aa))->aa_addr) @@ -68,4 +61,5 @@ struct at_ifaddr *at_ifaddr; struct ifqueue atintrq1, atintrq2; int atdebug; #endif + #endif /* _NETATALK_AT_VAR_H_ */ diff --git a/sys/netatalk/ddp_input.c b/sys/netatalk/ddp_input.c index 45a0c28..ca8c0f1 100644 --- a/sys/netatalk/ddp_input.c +++ b/sys/netatalk/ddp_input.c @@ -5,20 +5,15 @@ #include <sys/types.h> #include <sys/param.h> -#if defined( __FreeBSD__ ) #include <sys/systm.h> #include <sys/kernel.h> #include <net/netisr.h> -#endif __FreeBSD__ #include <sys/mbuf.h> #include <sys/socket.h> #include <sys/socketvar.h> #include <sys/syslog.h> #include <net/if.h> #include <net/route.h> -#ifdef _IBMR2 -#include <net/spl.h> -#endif _IBMR2 #include <netinet/in.h> #include <netinet/if_ether.h> @@ -47,27 +42,17 @@ atintr( void ) int s; for (;;) { -#ifndef _IBMR2 s = splimp(); -#endif _IBMR2 -#ifdef BSD4_4 IF_DEQUEUE( &atintrq2, m ); -#else BSD4_4 - IF_DEQUEUEIF( &atintrq2, m, ifp ); -#endif BSD4_4 -#ifndef _IBMR2 splx( s ); -#endif _IBMR2 if ( m == 0 ) { /* no more queued packets */ break; } -#ifdef BSD4_4 ifp = m->m_pkthdr.rcvif; -#endif BSD4_4 for ( aa = at_ifaddr; aa; aa = aa->aa_next ) { if ( aa->aa_ifp == ifp && ( aa->aa_flags & AFA_PHASE2 )) { break; @@ -82,27 +67,17 @@ atintr( void ) } for (;;) { -#ifndef _IBMR2 s = splimp(); -#endif _IBMR2 -#ifdef BSD4_4 IF_DEQUEUE( &atintrq1, m ); -#else BSD4_4 - IF_DEQUEUEIF( &atintrq1, m, ifp ); -#endif BSD4_4 -#ifndef _IBMR2 splx( s ); -#endif _IBMR2 if ( m == 0 ) { /* no more queued packets */ break; } -#ifdef BSD4_4 ifp = m->m_pkthdr.rcvif; -#endif BSD4_4 for ( aa = at_ifaddr; aa; aa = aa->aa_next ) { if ( aa->aa_ifp == ifp && ( aa->aa_flags & AFA_PHASE2 ) == 0 ) { break; @@ -132,9 +107,7 @@ atintr( void ) return; } -#if defined( __FreeBSD__ ) NETISR_SET(NETISR_ATALK, atintr); -#endif __FreeBSD__ struct route forwro; @@ -148,13 +121,10 @@ ddp_input( m, ifp, elh, phase ) struct sockaddr_at from, to; struct ddpshdr *dsh, ddps; struct at_ifaddr *aa; - struct ddpehdr *deh, ddpe; -#ifndef BSD4_4 - struct mbuf *mp; -#endif BSD4_4 + struct ddpehdr *deh = NULL, ddpe; struct ddpcb *ddp; int dlen, mlen; - u_short cksum; + u_short cksum = 0; bzero( (caddr_t)&from, sizeof( struct sockaddr_at )); if ( elh ) { @@ -255,13 +225,7 @@ ddp_input( m, ifp, elh, phase ) * at a link layer. We do this before we attempt to forward a packet, * possibly on a different media. */ -#ifdef BSD4_4 mlen = m->m_pkthdr.len; -#else BSD4_4 - for ( mlen = 0, mp = m; mp; mp = mp->m_next ) { - mlen += mp->m_len; - } -#endif BSD4_4 if ( mlen < dlen ) { ddpstat.ddps_toosmall++; m_freem( m ); @@ -285,18 +249,12 @@ ddp_input( m, ifp, elh, phase ) to.sat_addr.s_net || satosat( &forwro.ro_dst )->sat_addr.s_node != to.sat_addr.s_node )) { -#ifdef ultrix - rtfree( forwro.ro_rt ); -#else ultrix RTFREE( forwro.ro_rt ); -#endif ultrix forwro.ro_rt = (struct rtentry *)0; } if ( forwro.ro_rt == (struct rtentry *)0 || forwro.ro_rt->rt_ifp == (struct ifnet *)0 ) { -#ifdef BSD4_4 forwro.ro_dst.sa_len = sizeof( struct sockaddr_at ); -#endif BSD4_4 forwro.ro_dst.sa_family = AF_APPLETALK; satosat( &forwro.ro_dst )->sat_addr.s_net = to.sat_addr.s_net; satosat( &forwro.ro_dst )->sat_addr.s_node = to.sat_addr.s_node; @@ -326,9 +284,7 @@ ddp_input( m, ifp, elh, phase ) return; } -#ifdef BSD4_4 from.sat_len = sizeof( struct sockaddr_at ); -#endif BSD4_4 from.sat_family = AF_APPLETALK; if ( elh ) { @@ -356,6 +312,8 @@ ddp_input( m, ifp, elh, phase ) sorwakeup( ddp->ddp_socket ); } +#if 0 + #define BPXLEN 48 #define BPALEN 16 #include <ctype.h> @@ -411,3 +369,4 @@ m_printm( struct mbuf *m ) bprint( mtod( m, char * ), m->m_len ); } } +#endif diff --git a/sys/netatalk/ddp_output.c b/sys/netatalk/ddp_output.c index 54a2c7a..be39935 100644 --- a/sys/netatalk/ddp_output.c +++ b/sys/netatalk/ddp_output.c @@ -23,9 +23,7 @@ #include <sys/types.h> #include <sys/param.h> -#if defined( __FreeBSD__ ) #include <sys/systm.h> -#endif __FreeBSD__ #include <sys/mbuf.h> #include <sys/socket.h> #include <sys/errno.h> @@ -50,44 +48,15 @@ int ddp_cksum = 1; int ddp_output( struct ddpcb *ddp, struct mbuf *m) { -#ifndef BSD4_4 - struct mbuf *m0; - int len; -#endif BSD4_4 - struct ifnet *ifp; - struct at_ifaddr *aa = NULL; struct ddpehdr *deh; - u_short net; -#ifdef BSD4_4 M_PREPEND( m, sizeof( struct ddpehdr ), M_WAIT ); -#else BSD4_4 - for ( len = 0, m0 = m; m; m = m->m_next ) { - len += m->m_len; - } - MGET( m, M_WAIT, MT_HEADER ); - if ( m == 0 ) { - m_freem( m0 ); - return( ENOBUFS ); - } - m->m_next = m0; -#endif BSD4_4 - -#ifndef BSD4_4 -# define align(a) (((a)+3)&0xfc) - m->m_off = MMINOFF + align( SZ_ELAPHDR ); - m->m_len = sizeof( struct ddpehdr ); -#endif BSD4_4 deh = mtod( m, struct ddpehdr *); deh->deh_pad = 0; deh->deh_hops = 0; -#ifdef BSD4_4 deh->deh_len = m->m_pkthdr.len; -#else BSD4_4 - deh->deh_len = len + sizeof( struct ddpehdr ); -#endif BSD4_4 deh->deh_dnet = ddp->ddp_fsat.sat_addr.s_net; deh->deh_dnode = ddp->ddp_fsat.sat_addr.s_node; @@ -145,15 +114,10 @@ ddp_route( struct mbuf *m, struct route *ro) struct mbuf *m0; struct at_ifaddr *aa = NULL; struct ifnet *ifp = NULL; - int mlen; u_short net; if ( ro->ro_rt && ( ifp = ro->ro_rt->rt_ifp )) { -#ifdef BSD4_4 net = satosat( ro->ro_rt->rt_gateway )->sat_addr.s_net; -#else BSD4_4 - net = satosat( &ro->ro_rt->rt_gateway )->sat_addr.s_net; -#endif BSD4_4 for ( aa = at_ifaddr; aa; aa = aa->aa_next ) { if ( aa->aa_ifp == ifp && ntohs( net ) >= ntohs( aa->aa_firstnet ) && @@ -174,35 +138,7 @@ printf( "ddp_route: oops\n" ); * This is bad for transition routing, since phase 1 and phase 2 * packets end up poorly aligned due to the three byte elap header. */ - if ( aa->aa_flags & AFA_PHASE2 ) { -#if defined( __FreeBSD__ ) - /* XXX don't need this because we can change if_ethersubr.c */ -#else - for ( mlen = 0, m0 = m; m0; m0 = m0->m_next ) { - mlen += m0->m_len; - } -#ifndef MIN -#define MIN(x,y) ((x)<(y)?(x):(y)) -#endif - if (( m = m_pullup( m, MIN( MLEN, mlen ))) == 0 ) { - printf("ddp_route: m_pullup of %d (mlen=%d) failed\n", - MIN( MLEN, mlen ), mlen); - return( ENOBUFS ); - } -#endif __FreeBSD__ - } else { -# ifdef notdef -#ifdef BSD4_4 - M_PREPEND( m, SZ_ELAPHDR, M_DONTWAIT ); - if ( m == NULL ) { - return( ENOBUFS ); - } -#else BSD4_4 - m->m_off -= SZ_ELAPHDR; - m->m_len += SZ_ELAPHDR; -#endif BSD4_4 -# endif notdef - + if ( !(aa->aa_flags & AFA_PHASE2) ) { MGET( m0, M_WAIT, MT_HEADER ); if ( m0 == 0 ) { m_freem( m ); @@ -210,12 +146,7 @@ printf( "ddp_route: oops\n" ); return( ENOBUFS ); } m0->m_next = m; - -#ifndef BSD4_4 - m0->m_off = MMINOFF + align( sizeof( struct ether_header )); -#else /* XXX perhaps we ought to align the header? */ -#endif BSD4_4 m0->m_len = SZ_ELAPHDR; m = m0; @@ -228,11 +159,7 @@ printf( "ddp_route: oops\n" ); ntohs( aa->aa_lastnet )) { elh->el_dnode = satosat( &ro->ro_dst )->sat_addr.s_node; } else { -#ifdef BSD4_4 elh->el_dnode = satosat( ro->ro_rt->rt_gateway )->sat_addr.s_node; -#else BSD4_4 - elh->el_dnode = satosat( &ro->ro_rt->rt_gateway )->sat_addr.s_node; -#endif BSD4_4 } } @@ -242,57 +169,10 @@ printf( "ddp_route: oops\n" ); ntohs( aa->aa_lastnet )) { gate = *satosat( &ro->ro_dst ); } else { -#ifdef BSD4_4 gate = *satosat( ro->ro_rt->rt_gateway ); -#else BSD4_4 - gate = *satosat( &ro->ro_rt->rt_gateway ); -#endif BSD4_4 } ro->ro_rt->rt_use++; -#ifdef ultrix - /* - * SAIEW: We can't make changes to net/if_loop.c, so we don't route - * further than this: if it's going to go through the lookback, - * short-circuit to ddp_input(). Who needs queuing? - * - * Note: Passing NULL for the elaphdr is cool, since we'll only ever - * try to send long form ddp throught the loopback. - */ - if ( ifp->if_flags & IFF_LOOPBACK ) { -#ifdef notdef - m->m_off += SZ_ELAPHDR; - m->m_len -= SZ_ELAPHDR; -#endif notdef - ddp_input( m, ifp, (struct elaphdr *)NULL, 2 ); - return( 0 ); - } -#endif ultrix - -#ifdef _IBMR2 - /* - * We can't make changes to the interface routines on RS6ks, and - * they don't provide hooks for if_output, so we just resolve - * our address here, and pass the packet as a raw ethernet packet. - * This doesn't work particularly well, if we aren't *on* ethernet, - * but it's ok for the moment. - */ - if ( ! ( ifp->if_flags & IFF_LOOPBACK )) { - struct ether_header eh; - - if ( !aarpresolve(( struct arpcom *)ifp, m, - &gate, eh.ether_dhost )) { - return( 0 ); - } - eh.ether_type = htons( ETHERTYPE_AT ); - gate.sat_family = AF_UNSPEC; - bcopy( &eh, (*(struct sockaddr *)&gate).sa_data, - sizeof( (*(struct sockaddr *)&gate).sa_data )); - } -#endif _IBMR2 - return((*ifp->if_output)( ifp, m, &gate -#if defined( __FreeBSD__ ) - , NULL /* XXX */ -#endif __FreeBSD__ - )); + return((*ifp->if_output)( ifp, + m, (struct sockaddr *)&gate, NULL)); /* XXX */ } diff --git a/sys/netatalk/ddp_pcb.c b/sys/netatalk/ddp_pcb.c index f2557ba..a9886b8 100644 --- a/sys/netatalk/ddp_pcb.c +++ b/sys/netatalk/ddp_pcb.c @@ -7,15 +7,7 @@ #include <sys/types.h> #include <sys/param.h> #include <sys/systm.h> -#if defined( __FreeBSD__ ) #include <sys/proc.h> -#endif __FreeBSD__ -#ifdef ibm032 -#include <sys/dir.h> -#endif ibm032 -#ifndef __FreeBSD__ -#include <sys/user.h> -#endif #include <sys/mbuf.h> #include <sys/ioctl.h> #include <sys/socket.h> @@ -25,9 +17,6 @@ #include <net/route.h> #include <netinet/in.h> #include <netinet/if_ether.h> -#ifdef _IBMR2 -#include <net/spl.h> -#endif _IBMR2 #include "at.h" #include "at_var.h" @@ -53,9 +42,7 @@ int ddp_usrreq( struct socket *so, int req, struct mbuf *m, struct mbuf *addr, struct mbuf *rights) { -#if defined( __FreeBSD__ ) struct proc *p = curproc; /* XXX */ -#endif __FreeBSD__ struct ddpcb *ddp; int error = 0; @@ -63,11 +50,7 @@ ddp_usrreq( struct socket *so, int req, struct mbuf *m, if ( req == PRU_CONTROL ) { return( at_control( (int) m, (caddr_t) addr, - (struct ifnet *) rights -#if defined( __FreeBSD__ ) - , (struct proc *)p -#endif __FreeBSD__ - )); + (struct ifnet *) rights, (struct proc *)p )); } if ( rights && rights->m_len ) { @@ -97,11 +80,7 @@ ddp_usrreq( struct socket *so, int req, struct mbuf *m, break; case PRU_BIND : - error = at_pcbsetaddr( ddp, addr -#if defined( __FreeBSD__ ) - , p -#endif __FreeBSD__ - ); + error = at_pcbsetaddr( ddp, addr, p ); break; case PRU_SOCKADDR : @@ -114,11 +93,7 @@ ddp_usrreq( struct socket *so, int req, struct mbuf *m, break; } - error = at_pcbconnect( ddp, addr -#if defined( __FreeBSD__ ) - , p -#endif __FreeBSD__ - ); + error = at_pcbconnect( ddp, addr, p ); if ( error == 0 ) soisconnected( so ); break; @@ -146,11 +121,7 @@ ddp_usrreq( struct socket *so, int req, struct mbuf *m, } s = splnet(); - error = at_pcbconnect( ddp, addr -#if defined( __FreeBSD__ ) - , p -#endif __FreeBSD__ - ); + error = at_pcbconnect( ddp, addr, p ); if ( error ) { splx( s ); break; @@ -260,29 +231,16 @@ at_pcbsetaddr( struct ddpcb *ddp, struct mbuf *addr, struct proc *p ) sat->sat_port >= ATPORT_LAST ) { return( EINVAL ); } -#ifdef BSD4_4 if ( sat->sat_port < ATPORT_RESERVED && -#if defined( __FreeBSD__ ) - suser( p->p_ucred, &p->p_acflag ) -#else - suser( u.u_cred, &u.u_acflag ) -#endif __FreeBSD__ - ) { - return( EACCES ); - } -#else BSD4_4 - if ( sat->sat_port < ATPORT_RESERVED && ( !suser())) { + suser( p->p_ucred, &p->p_acflag ) ) { return( EACCES ); } -#endif BSD4_4 } } else { bzero( (caddr_t)&lsat, sizeof( struct sockaddr_at )); -#ifdef BSD4_4 lsat.sat_len = sizeof(struct sockaddr_at); lsat.sat_addr.s_node = ATADDR_ANYNODE; lsat.sat_addr.s_net = ATADDR_ANYNET; -#endif BSD4_4 lsat.sat_family = AF_APPLETALK; sat = &lsat; } @@ -386,11 +344,7 @@ at_pcbconnect( struct ddpcb *ddp, struct mbuf *addr, struct proc *p) ( hintnet ? hintnet : sat->sat_addr.s_net ) || satosat( &ro->ro_dst )->sat_addr.s_node != sat->sat_addr.s_node )) { -#ifdef ultrix - rtfree( ro->ro_rt ); -#else ultrix RTFREE( ro->ro_rt ); -#endif ultrix ro->ro_rt = (struct rtentry *)0; } } @@ -400,9 +354,7 @@ at_pcbconnect( struct ddpcb *ddp, struct mbuf *addr, struct proc *p) */ if ( ro->ro_rt == (struct rtentry *)0 || ro->ro_rt->rt_ifp == (struct ifnet *)0 ) { -#ifdef BSD4_4 ro->ro_dst.sa_len = sizeof( struct sockaddr_at ); -#endif BSD4_4 ro->ro_dst.sa_family = AF_APPLETALK; if ( hintnet ) { satosat( &ro->ro_dst )->sat_addr.s_net = hintnet; @@ -430,11 +382,7 @@ at_pcbconnect( struct ddpcb *ddp, struct mbuf *addr, struct proc *p) ddp->ddp_fsat = *sat; if ( ddp->ddp_lsat.sat_port == ATADDR_ANYPORT ) { - return( at_pcbsetaddr( ddp, (struct mbuf *)0 -#if defined( __FreeBSD__ ) - , p -#endif __FreeBSD__ - )); + return( at_pcbsetaddr( ddp, (struct mbuf *)0, p )); } return( 0 ); } @@ -566,6 +514,7 @@ ddp_init(void ) atintrq2.ifq_maxlen = IFQ_MAXLEN; } +#if 0 static void ddp_clean(void ) { @@ -575,3 +524,4 @@ ddp_clean(void ) at_pcbdetach( ddp->ddp_socket, ddp ); } } +#endif diff --git a/sys/netatalk/ddp_usrreq.c b/sys/netatalk/ddp_usrreq.c index f2557ba..a9886b8 100644 --- a/sys/netatalk/ddp_usrreq.c +++ b/sys/netatalk/ddp_usrreq.c @@ -7,15 +7,7 @@ #include <sys/types.h> #include <sys/param.h> #include <sys/systm.h> -#if defined( __FreeBSD__ ) #include <sys/proc.h> -#endif __FreeBSD__ -#ifdef ibm032 -#include <sys/dir.h> -#endif ibm032 -#ifndef __FreeBSD__ -#include <sys/user.h> -#endif #include <sys/mbuf.h> #include <sys/ioctl.h> #include <sys/socket.h> @@ -25,9 +17,6 @@ #include <net/route.h> #include <netinet/in.h> #include <netinet/if_ether.h> -#ifdef _IBMR2 -#include <net/spl.h> -#endif _IBMR2 #include "at.h" #include "at_var.h" @@ -53,9 +42,7 @@ int ddp_usrreq( struct socket *so, int req, struct mbuf *m, struct mbuf *addr, struct mbuf *rights) { -#if defined( __FreeBSD__ ) struct proc *p = curproc; /* XXX */ -#endif __FreeBSD__ struct ddpcb *ddp; int error = 0; @@ -63,11 +50,7 @@ ddp_usrreq( struct socket *so, int req, struct mbuf *m, if ( req == PRU_CONTROL ) { return( at_control( (int) m, (caddr_t) addr, - (struct ifnet *) rights -#if defined( __FreeBSD__ ) - , (struct proc *)p -#endif __FreeBSD__ - )); + (struct ifnet *) rights, (struct proc *)p )); } if ( rights && rights->m_len ) { @@ -97,11 +80,7 @@ ddp_usrreq( struct socket *so, int req, struct mbuf *m, break; case PRU_BIND : - error = at_pcbsetaddr( ddp, addr -#if defined( __FreeBSD__ ) - , p -#endif __FreeBSD__ - ); + error = at_pcbsetaddr( ddp, addr, p ); break; case PRU_SOCKADDR : @@ -114,11 +93,7 @@ ddp_usrreq( struct socket *so, int req, struct mbuf *m, break; } - error = at_pcbconnect( ddp, addr -#if defined( __FreeBSD__ ) - , p -#endif __FreeBSD__ - ); + error = at_pcbconnect( ddp, addr, p ); if ( error == 0 ) soisconnected( so ); break; @@ -146,11 +121,7 @@ ddp_usrreq( struct socket *so, int req, struct mbuf *m, } s = splnet(); - error = at_pcbconnect( ddp, addr -#if defined( __FreeBSD__ ) - , p -#endif __FreeBSD__ - ); + error = at_pcbconnect( ddp, addr, p ); if ( error ) { splx( s ); break; @@ -260,29 +231,16 @@ at_pcbsetaddr( struct ddpcb *ddp, struct mbuf *addr, struct proc *p ) sat->sat_port >= ATPORT_LAST ) { return( EINVAL ); } -#ifdef BSD4_4 if ( sat->sat_port < ATPORT_RESERVED && -#if defined( __FreeBSD__ ) - suser( p->p_ucred, &p->p_acflag ) -#else - suser( u.u_cred, &u.u_acflag ) -#endif __FreeBSD__ - ) { - return( EACCES ); - } -#else BSD4_4 - if ( sat->sat_port < ATPORT_RESERVED && ( !suser())) { + suser( p->p_ucred, &p->p_acflag ) ) { return( EACCES ); } -#endif BSD4_4 } } else { bzero( (caddr_t)&lsat, sizeof( struct sockaddr_at )); -#ifdef BSD4_4 lsat.sat_len = sizeof(struct sockaddr_at); lsat.sat_addr.s_node = ATADDR_ANYNODE; lsat.sat_addr.s_net = ATADDR_ANYNET; -#endif BSD4_4 lsat.sat_family = AF_APPLETALK; sat = &lsat; } @@ -386,11 +344,7 @@ at_pcbconnect( struct ddpcb *ddp, struct mbuf *addr, struct proc *p) ( hintnet ? hintnet : sat->sat_addr.s_net ) || satosat( &ro->ro_dst )->sat_addr.s_node != sat->sat_addr.s_node )) { -#ifdef ultrix - rtfree( ro->ro_rt ); -#else ultrix RTFREE( ro->ro_rt ); -#endif ultrix ro->ro_rt = (struct rtentry *)0; } } @@ -400,9 +354,7 @@ at_pcbconnect( struct ddpcb *ddp, struct mbuf *addr, struct proc *p) */ if ( ro->ro_rt == (struct rtentry *)0 || ro->ro_rt->rt_ifp == (struct ifnet *)0 ) { -#ifdef BSD4_4 ro->ro_dst.sa_len = sizeof( struct sockaddr_at ); -#endif BSD4_4 ro->ro_dst.sa_family = AF_APPLETALK; if ( hintnet ) { satosat( &ro->ro_dst )->sat_addr.s_net = hintnet; @@ -430,11 +382,7 @@ at_pcbconnect( struct ddpcb *ddp, struct mbuf *addr, struct proc *p) ddp->ddp_fsat = *sat; if ( ddp->ddp_lsat.sat_port == ATADDR_ANYPORT ) { - return( at_pcbsetaddr( ddp, (struct mbuf *)0 -#if defined( __FreeBSD__ ) - , p -#endif __FreeBSD__ - )); + return( at_pcbsetaddr( ddp, (struct mbuf *)0, p )); } return( 0 ); } @@ -566,6 +514,7 @@ ddp_init(void ) atintrq2.ifq_maxlen = IFQ_MAXLEN; } +#if 0 static void ddp_clean(void ) { @@ -575,3 +524,4 @@ ddp_clean(void ) at_pcbdetach( ddp->ddp_socket, ddp ); } } +#endif diff --git a/sys/netatalk/endian.h b/sys/netatalk/endian.h index 919d351..255c226 100644 --- a/sys/netatalk/endian.h +++ b/sys/netatalk/endian.h @@ -21,67 +21,9 @@ * netatalk@itd.umich.edu */ -# ifndef _ATALK_ENDIAN_H_ +#ifndef _ATALK_ENDIAN_H_ #define _ATALK_ENDIAN_H_ -#ifdef _IBMR2 -#include <sys/machine.h> -#endif _IBMR2 - -#ifdef linux -#include <bytesex.h> -#define BYTE_ORDER __BYTE_ORDER -#endif linux - -#ifdef __FreeBSD__ #include <machine/endian.h> -#endif __FreeBSD__ - -# ifndef BYTE_ORDER -#define LITTLE_ENDIAN 1234 -#define BIG_ENDIAN 4321 -#define PDP_ENDIAN 3412 - -#ifdef sun -#ifdef i386 -#define BYTE_ORDER LITTLE_ENDIAN -#else i386 -#define BYTE_ORDER BIG_ENDIAN -#endif i386 -#else -#ifdef MIPSEB -#define BYTE_ORDER BIG_ENDIAN -#else -#ifdef MIPSEL -#define BYTE_ORDER LITTLE_ENDIAN -#else -Like, what is your byte order, man? -#endif MIPSEL -#endif MIPSEB -#endif sun -# endif BYTE_ORDER - -# ifndef ntohl -# if defined( sun ) || defined( ultrix ) || defined( _IBMR2 ) -#if BYTE_ORDER == BIG_ENDIAN -#define ntohl(x) (x) -#define ntohs(x) (x) -#define htonl(x) (x) -#define htons(x) (x) - -#else -#if defined( mips ) && defined( KERNEL ) -#define ntohl(x) nuxi_l(x) -#define ntohs(x) nuxi_s(x) -#define htonl(x) nuxi_l(x) -#define htons(x) nuxi_s(x) - -#else mips KERNEL -unsigned short ntohs(), htons(); -unsigned long ntohl(), htonl(); -#endif mips KERNEL -#endif BYTE_ORDER -# endif sun ultrix _IBMR2 -# endif ntohl -# endif _ATALK_ENDIAN_H_ +#endif _ATALK_ENDIAN_H_ diff --git a/sys/netatalk/phase2.h b/sys/netatalk/phase2.h index 9535a6a..112c062 100644 --- a/sys/netatalk/phase2.h +++ b/sys/netatalk/phase2.h @@ -3,83 +3,10 @@ * All Rights Reserved. */ -# if defined( ultrix ) || defined( BSD4_4 ) #include <net/if_llc.h> -# if defined( __FreeBSD__ ) -#define llc_org_code llc_un.type_snap.org_code -#define llc_ether_type llc_un.type_snap.ether_type -# endif __FreeBSD__ -# else ultrix BSD4_4 -#ifdef sun -#include <net/if_ieee802.h> -#endif sun - -/* - * Copyright (c) 1988 Regents of the University of California. - * All rights reserved. - * - * @(#)if_llc.h 7.2 (Berkeley) 6/28/90 - */ - -/* - * IEEE 802.2 Link Level Control headers, for use in conjunction with - * 802.{3,4,5} media access control methods. - * - * Headers here do not use bit fields due to shortcommings in many - * compilers. - */ - -struct llc { - u_char llc_dsap; - u_char llc_ssap; - union { - struct { - u_char control; - u_char format_id; - u_char class; - u_char window_x2; - } type_u; - struct { - u_char num_snd_x2; - u_char num_rcv_x2; - } type_i; - struct { - u_char control; - u_char num_rcv_x2; - } type_s; - struct { - u_char control; - u_char org_code[3]; - u_short ether_type; - } type_snap; - } llc_un; -}; -#define llc_control llc_un.type_u.control -#define llc_fid llc_un.type_u.format_id -#define llc_class llc_un.type_u.class -#define llc_window llc_un.type_u.window_x2 #define llc_org_code llc_un.type_snap.org_code #define llc_ether_type llc_un.type_snap.ether_type -#define LLC_UI 0x3 -#define LLC_UI_P 0x13 -#define LLC_XID 0xaf -#define LLC_XID_P 0xbf -#define LLC_TEST 0xe3 -#define LLC_TEST_P 0xf3 - -#define LLC_ISO_LSAP 0xfe -#define LLC_SNAP_LSAP 0xaa - -# endif ultrix BSD4_4 - -#if defined( sun ) || defined( ibm032 ) -#define SIOCPHASE1 _IOW(i, 100, struct ifreq) /* AppleTalk phase 1 */ -#define SIOCPHASE2 _IOW(i, 101, struct ifreq) /* AppleTalk phase 2 */ -#endif sun ibm032 - -#if defined( ultrix ) || defined( BSD4_4 ) || defined( _IBMR2 ) #define SIOCPHASE1 _IOW('i', 100, struct ifreq) /* AppleTalk phase 1 */ #define SIOCPHASE2 _IOW('i', 101, struct ifreq) /* AppleTalk phase 2 */ -#endif ultrix BSD4_4 _IBMR2 |