Date: Sun, 21 Mar 2004 19:26:28 -0800 (PST) From: Robert Watson <rwatson@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 49494 for review Message-ID: <200403220326.i2M3QScV093649@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=49494 Change 49494 by rwatson@rwatson_paprika on 2004/03/21 19:26:04 Integrate gratuitous style reformatting of netatalk code, largely relating to parenthesis. Affected files ... .. //depot/projects/netperf_socket/sys/netatalk/aarp.c#3 integrate .. //depot/projects/netperf_socket/sys/netatalk/at_control.c#3 integrate .. //depot/projects/netperf_socket/sys/netatalk/ddp_output.c#3 integrate .. //depot/projects/netperf_socket/sys/netatalk/ddp_pcb.c#3 integrate .. //depot/projects/netperf_socket/sys/netatalk/ddp_usrreq.c#6 integrate Differences ... ==== //depot/projects/netperf_socket/sys/netatalk/aarp.c#3 (text+ko) ==== @@ -2,7 +2,7 @@ * Copyright (c) 1990,1991 Regents of The University of Michigan. * All Rights Reserved. * - * $FreeBSD: src/sys/netatalk/aarp.c,v 1.25 2004/03/13 05:27:17 rwatson Exp $ + * $FreeBSD: src/sys/netatalk/aarp.c,v 1.26 2004/03/22 03:24:10 rwatson Exp $ */ #include "opt_atalk.h" @@ -28,8 +28,8 @@ #include <netatalk/phase2.h> #include <netatalk/at_extern.h> -static void aarptfree( struct aarptab *aat); -static void at_aarpinput( struct arpcom *ac, struct mbuf *m); +static void aarptfree(struct aarptab *aat); +static void at_aarpinput(struct arpcom *ac, struct mbuf *m); #define AARPTAB_BSIZ 9 #define AARPTAB_NB 19 @@ -37,16 +37,16 @@ static struct aarptab aarptab[AARPTAB_SIZE]; #define AARPTAB_HASH(a) \ - ((((a).s_net << 8 ) + (a).s_node ) % AARPTAB_NB ) + ((((a).s_net << 8) + (a).s_node) % AARPTAB_NB) #define AARPTAB_LOOK(aat,addr) { \ int n; \ aat = &aarptab[ AARPTAB_HASH(addr) * AARPTAB_BSIZ ]; \ - for ( n = 0; n < AARPTAB_BSIZ; n++, aat++ ) \ - if ( aat->aat_ataddr.s_net == (addr).s_net && \ - aat->aat_ataddr.s_node == (addr).s_node ) \ + for (n = 0; n < AARPTAB_BSIZ; n++, aat++) \ + if (aat->aat_ataddr.s_net == (addr).s_net && \ + aat->aat_ataddr.s_node == (addr).s_node) \ break; \ - if ( n >= AARPTAB_BSIZ ) \ + if (n >= AARPTAB_BSIZ) \ aat = 0; \ } @@ -54,7 +54,7 @@ #define AARPT_KILLC 20 #define AARPT_KILLI 3 -# if !defined( __FreeBSD__ ) +# if !defined(__FreeBSD__) extern u_char etherbroadcastaddr[6]; # endif /* __FreeBSD__ */ @@ -81,17 +81,17 @@ struct aarptab *aat; int i, s; - aarptimer_ch = timeout( aarptimer, (caddr_t)0, AARPT_AGE * hz ); + aarptimer_ch = timeout(aarptimer, (caddr_t)0, AARPT_AGE * hz); aat = aarptab; - for ( i = 0; i < AARPTAB_SIZE; i++, aat++ ) { - if ( aat->aat_flags == 0 || ( aat->aat_flags & ATF_PERM )) + for (i = 0; i < AARPTAB_SIZE; i++, aat++) { + if (aat->aat_flags == 0 || (aat->aat_flags & ATF_PERM)) continue; - if ( ++aat->aat_timer < (( aat->aat_flags & ATF_COM ) ? - AARPT_KILLC : AARPT_KILLI )) + if (++aat->aat_timer < ((aat->aat_flags & ATF_COM) ? + AARPT_KILLC : AARPT_KILLI)) continue; s = splimp(); - aarptfree( aat ); - splx( s ); + aarptfree(aat); + splx(s); } } @@ -101,27 +101,27 @@ * consideration. */ struct at_ifaddr * -at_ifawithnet(struct sockaddr_at *sat ) +at_ifawithnet(struct sockaddr_at *sat) { struct at_ifaddr *aa; struct sockaddr_at *sat2; - for ( aa = at_ifaddr; aa; aa = aa->aa_next ) { + for (aa = at_ifaddr; aa; aa = aa->aa_next) { sat2 = &(aa->aa_addr); - if ( sat2->sat_addr.s_net == sat->sat_addr.s_net ) { + if (sat2->sat_addr.s_net == sat->sat_addr.s_net) { break; } - if( (aa->aa_flags & AFA_PHASE2 ) + if((aa->aa_flags & AFA_PHASE2) && (ntohs(aa->aa_firstnet) <= ntohs(sat->sat_addr.s_net)) && (ntohs(aa->aa_lastnet) >= ntohs(sat->sat_addr.s_net))) { break; } } - return( aa ); + return (aa); } static void -aarpwhohas( struct arpcom *ac, struct sockaddr_at *sat ) +aarpwhohas(struct arpcom *ac, struct sockaddr_at *sat) { struct mbuf *m; struct ether_header *eh; @@ -130,26 +130,26 @@ struct llc *llc; struct sockaddr sa; - if (( m = m_gethdr( M_DONTWAIT, MT_DATA )) == NULL ) { + if ((m = m_gethdr(M_DONTWAIT, MT_DATA)) == NULL) { return; } #ifdef MAC mac_create_mbuf_linklayer(&ac->ac_if, m); #endif - m->m_len = sizeof( *ea ); - m->m_pkthdr.len = sizeof( *ea ); - MH_ALIGN( m, sizeof( *ea )); + m->m_len = sizeof(*ea); + m->m_pkthdr.len = sizeof(*ea); + MH_ALIGN(m, sizeof(*ea)); - ea = mtod( m, struct ether_aarp *); - bzero((caddr_t)ea, sizeof( *ea )); + ea = mtod(m, struct ether_aarp *); + bzero((caddr_t)ea, sizeof(*ea)); - ea->aarp_hrd = htons( AARPHRD_ETHER ); - ea->aarp_pro = htons( ETHERTYPE_AT ); - ea->aarp_hln = sizeof( ea->aarp_sha ); - ea->aarp_pln = sizeof( ea->aarp_spu ); - ea->aarp_op = htons( AARPOP_REQUEST ); + ea->aarp_hrd = htons(AARPHRD_ETHER); + ea->aarp_pro = htons(ETHERTYPE_AT); + ea->aarp_hln = sizeof(ea->aarp_sha); + ea->aarp_pln = sizeof(ea->aarp_spu); + ea->aarp_op = htons(AARPOP_REQUEST); bcopy((caddr_t)ac->ac_enaddr, (caddr_t)ea->aarp_sha, - sizeof( ea->aarp_sha )); + sizeof(ea->aarp_sha)); /* * We need to check whether the output ethernet type should @@ -158,55 +158,55 @@ * interface with the same address as we're looking for. If the * net is phase 2, generate an 802.2 and SNAP header. */ - if ((aa = at_ifawithnet( sat )) == NULL) { - m_freem( m ); + if ((aa = at_ifawithnet(sat)) == NULL) { + m_freem(m); return; } eh = (struct ether_header *)sa.sa_data; - if ( aa->aa_flags & AFA_PHASE2 ) { - bcopy(atmulticastaddr, eh->ether_dhost, sizeof( eh->ether_dhost )); + if (aa->aa_flags & AFA_PHASE2) { + bcopy(atmulticastaddr, eh->ether_dhost, sizeof(eh->ether_dhost)); eh->ether_type = htons(sizeof(struct llc) + sizeof(struct ether_aarp)); - M_PREPEND( m, sizeof( struct llc ), M_TRYWAIT ); - if ( m == NULL ) { + M_PREPEND(m, sizeof(struct llc), M_TRYWAIT); + if (m == NULL) { return; } - llc = mtod( m, struct llc *); + llc = mtod(m, struct llc *); llc->llc_dsap = llc->llc_ssap = LLC_SNAP_LSAP; llc->llc_control = LLC_UI; bcopy(aarp_org_code, llc->llc_org_code, sizeof(aarp_org_code)); - llc->llc_ether_type = htons( ETHERTYPE_AARP ); + llc->llc_ether_type = htons(ETHERTYPE_AARP); - bcopy( &AA_SAT( aa )->sat_addr.s_net, ea->aarp_spnet, - sizeof( ea->aarp_spnet )); - bcopy( &sat->sat_addr.s_net, ea->aarp_tpnet, - sizeof( ea->aarp_tpnet )); - ea->aarp_spnode = AA_SAT( aa )->sat_addr.s_node; + bcopy(&AA_SAT(aa)->sat_addr.s_net, ea->aarp_spnet, + sizeof(ea->aarp_spnet)); + bcopy(&sat->sat_addr.s_net, ea->aarp_tpnet, + sizeof(ea->aarp_tpnet)); + ea->aarp_spnode = AA_SAT(aa)->sat_addr.s_node; ea->aarp_tpnode = sat->sat_addr.s_node; } else { bcopy(ac->ac_if.if_broadcastaddr, (caddr_t)eh->ether_dhost, - sizeof( eh->ether_dhost )); - eh->ether_type = htons( ETHERTYPE_AARP ); + sizeof(eh->ether_dhost)); + eh->ether_type = htons(ETHERTYPE_AARP); - ea->aarp_spa = AA_SAT( aa )->sat_addr.s_node; + ea->aarp_spa = AA_SAT(aa)->sat_addr.s_node; ea->aarp_tpa = sat->sat_addr.s_node; } #ifdef NETATALKDEBUG printf("aarp: sending request for %u.%u\n", - ntohs(AA_SAT( aa )->sat_addr.s_net), - AA_SAT( aa )->sat_addr.s_node); + ntohs(AA_SAT(aa)->sat_addr.s_net), + AA_SAT(aa)->sat_addr.s_node); #endif /* NETATALKDEBUG */ - sa.sa_len = sizeof( struct sockaddr ); + sa.sa_len = sizeof(struct sockaddr); sa.sa_family = AF_UNSPEC; (*ac->ac_if.if_output)(&ac->ac_if, m, &sa, NULL); /* XXX NULL should be routing information */ } int -aarpresolve( ac, m, destsat, desten ) +aarpresolve(ac, m, destsat, desten) struct arpcom *ac; struct mbuf *m; struct sockaddr_at *destsat; @@ -216,79 +216,79 @@ struct aarptab *aat; int s; - if ( at_broadcast( destsat )) { + if (at_broadcast(destsat)) { m->m_flags |= M_BCAST; - if ((aa = at_ifawithnet( destsat )) == NULL) { - m_freem( m ); - return( 0 ); + if ((aa = at_ifawithnet(destsat)) == NULL) { + m_freem(m); + return (0); } - if ( aa->aa_flags & AFA_PHASE2 ) { + if (aa->aa_flags & AFA_PHASE2) { bcopy(atmulticastaddr, (caddr_t)desten, sizeof(atmulticastaddr)); } else { - bcopy( ac->ac_if.if_broadcastaddr, (caddr_t)desten, - sizeof( ac->ac_if.if_addrlen )); + bcopy(ac->ac_if.if_broadcastaddr, (caddr_t)desten, + sizeof(ac->ac_if.if_addrlen)); } - return( 1 ); + return (1); } s = splimp(); - AARPTAB_LOOK( aat, destsat->sat_addr ); - if ( aat == 0 ) { /* No entry */ - aat = aarptnew( &destsat->sat_addr ); - if ( aat == 0 ) { - panic( "aarpresolve: no free entry" ); + AARPTAB_LOOK(aat, destsat->sat_addr); + if (aat == 0) { /* No entry */ + aat = aarptnew(&destsat->sat_addr); + if (aat == 0) { + panic("aarpresolve: no free entry"); } aat->aat_hold = m; - aarpwhohas( ac, destsat ); - splx( s ); - return( 0 ); + aarpwhohas(ac, destsat); + splx(s); + return (0); } /* found an entry */ aat->aat_timer = 0; - if ( aat->aat_flags & ATF_COM ) { /* entry is COMplete */ - bcopy( (caddr_t)aat->aat_enaddr, (caddr_t)desten, - sizeof( aat->aat_enaddr )); - splx( s ); - return( 1 ); + if (aat->aat_flags & ATF_COM) { /* entry is COMplete */ + bcopy((caddr_t)aat->aat_enaddr, (caddr_t)desten, + sizeof(aat->aat_enaddr)); + splx(s); + return (1); } /* entry has not completed */ - if ( aat->aat_hold ) { - m_freem( aat->aat_hold ); + if (aat->aat_hold) { + m_freem(aat->aat_hold); } aat->aat_hold = m; - aarpwhohas( ac, destsat ); - splx( s ); - return( 0 ); + aarpwhohas(ac, destsat); + splx(s); + return (0); } void -aarpintr( m ) +aarpintr(m) struct mbuf *m; { struct arphdr *ar; struct arpcom *ac; ac = (struct arpcom *)m->m_pkthdr.rcvif; - if ( ac->ac_if.if_flags & IFF_NOARP ) + if (ac->ac_if.if_flags & IFF_NOARP) goto out; - if ( m->m_len < sizeof( struct arphdr )) { + if (m->m_len < sizeof(struct arphdr)) { goto out; } - ar = mtod( m, struct arphdr *); - if ( ntohs( ar->ar_hrd ) != AARPHRD_ETHER ) { + ar = mtod(m, struct arphdr *); + if (ntohs(ar->ar_hrd) != AARPHRD_ETHER) { goto out; } - if ( m->m_len < sizeof( struct arphdr ) + 2 * ar->ar_hln + - 2 * ar->ar_pln ) { + if (m->m_len < sizeof(struct arphdr) + 2 * ar->ar_hln + + 2 * ar->ar_pln) { goto out; } - switch( ntohs( ar->ar_pro )) { + switch(ntohs(ar->ar_pro)) { case ETHERTYPE_AT : - at_aarpinput( ac, m ); + at_aarpinput(ac, m); return; default: @@ -296,11 +296,11 @@ } out: - m_freem( m ); + m_freem(m); } static void -at_aarpinput( struct arpcom *ac, struct mbuf *m) +at_aarpinput(struct arpcom *ac, struct mbuf *m) { struct ether_aarp *ea; struct at_ifaddr *aa; @@ -315,28 +315,28 @@ GIANT_REQUIRED; - ea = mtod( m, struct ether_aarp *); + ea = mtod(m, struct ether_aarp *); /* Check to see if from my hardware address */ - if ( !bcmp(( caddr_t )ea->aarp_sha, ( caddr_t )ac->ac_enaddr, - sizeof( ac->ac_enaddr ))) { - m_freem( m ); + if (!bcmp((caddr_t)ea->aarp_sha, (caddr_t)ac->ac_enaddr, + sizeof(ac->ac_enaddr))) { + m_freem(m); return; } - op = ntohs( ea->aarp_op ); - bcopy( ea->aarp_tpnet, &net, sizeof( net )); + op = ntohs(ea->aarp_op); + bcopy(ea->aarp_tpnet, &net, sizeof(net)); - if ( net != 0 ) { /* should be ATADDR_ANYNET? */ + if (net != 0) { /* should be ATADDR_ANYNET? */ sat.sat_len = sizeof(struct sockaddr_at); sat.sat_family = AF_APPLETALK; sat.sat_addr.s_net = net; - if ((aa = at_ifawithnet( &sat )) == NULL) { - m_freem( m ); + if ((aa = at_ifawithnet(&sat)) == NULL) { + m_freem(m); return; } - bcopy( ea->aarp_spnet, &spa.s_net, sizeof( spa.s_net )); - bcopy( ea->aarp_tpnet, &tpa.s_net, sizeof( tpa.s_net )); + bcopy(ea->aarp_spnet, &spa.s_net, sizeof(spa.s_net)); + bcopy(ea->aarp_tpnet, &tpa.s_net, sizeof(tpa.s_net)); } else { /* * Since we don't know the net, we just look for the first @@ -344,141 +344,141 @@ */ for (aa = (struct at_ifaddr *)TAILQ_FIRST(&ac->ac_if.if_addrhead); aa; aa = (struct at_ifaddr *)aa->aa_ifa.ifa_link.tqe_next) { - if ( AA_SAT( aa )->sat_family == AF_APPLETALK && - ( aa->aa_flags & AFA_PHASE2 ) == 0 ) { + if (AA_SAT(aa)->sat_family == AF_APPLETALK && + (aa->aa_flags & AFA_PHASE2) == 0) { break; } } - if ( aa == NULL ) { - m_freem( m ); + if (aa == NULL) { + m_freem(m); return; } - tpa.s_net = spa.s_net = AA_SAT( aa )->sat_addr.s_net; + tpa.s_net = spa.s_net = AA_SAT(aa)->sat_addr.s_net; } spa.s_node = ea->aarp_spnode; tpa.s_node = ea->aarp_tpnode; - ma.s_net = AA_SAT( aa )->sat_addr.s_net; - ma.s_node = AA_SAT( aa )->sat_addr.s_node; + ma.s_net = AA_SAT(aa)->sat_addr.s_net; + ma.s_node = AA_SAT(aa)->sat_addr.s_node; /* * This looks like it's from us. */ - if ( spa.s_net == ma.s_net && spa.s_node == ma.s_node ) { - if ( aa->aa_flags & AFA_PROBING ) { + if (spa.s_net == ma.s_net && spa.s_node == ma.s_node) { + if (aa->aa_flags & AFA_PROBING) { /* * We're probing, someone either responded to our probe, or * probed for the same address we'd like to use. Change the * address we're probing for. */ - untimeout( aarpprobe, ac, aa->aa_ch ); - wakeup( aa ); - m_freem( m ); + untimeout(aarpprobe, ac, aa->aa_ch); + wakeup(aa); + m_freem(m); return; - } else if ( op != AARPOP_PROBE ) { + } else if (op != AARPOP_PROBE) { /* * This is not a probe, and we're not probing. This means * that someone's saying they have the same source address * as the one we're using. Get upset... */ - log( LOG_ERR, + log(LOG_ERR, "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 ]); - m_freem( m ); + m_freem(m); return; } } - AARPTAB_LOOK( aat, spa ); - if ( aat ) { - if ( op == AARPOP_PROBE ) { + AARPTAB_LOOK(aat, spa); + if (aat) { + if (op == AARPOP_PROBE) { /* * Someone's probing for spa, dealocate the one we've got, * so that if the prober keeps the address, we'll be able * to arp for him. */ - aarptfree( aat ); - m_freem( m ); + aarptfree(aat); + m_freem(m); return; } - bcopy(( caddr_t )ea->aarp_sha, ( caddr_t )aat->aat_enaddr, - sizeof( ea->aarp_sha )); + bcopy((caddr_t)ea->aarp_sha, (caddr_t)aat->aat_enaddr, + sizeof(ea->aarp_sha)); aat->aat_flags |= ATF_COM; - if ( aat->aat_hold ) { + if (aat->aat_hold) { struct mbuf *mhold = aat->aat_hold; aat->aat_hold = NULL; sat.sat_len = sizeof(struct sockaddr_at); sat.sat_family = AF_APPLETALK; sat.sat_addr = spa; - (*ac->ac_if.if_output)( &ac->ac_if, mhold, + (*ac->ac_if.if_output)(&ac->ac_if, mhold, (struct sockaddr *)&sat, NULL); /* XXX */ } } else if ((tpa.s_net == ma.s_net) && (tpa.s_node == ma.s_node) && (op != AARPOP_PROBE) - && ((aat = aarptnew( &spa )) != NULL)) { - bcopy(( caddr_t )ea->aarp_sha, ( caddr_t )aat->aat_enaddr, - sizeof( ea->aarp_sha )); - aat->aat_flags |= ATF_COM; + && ((aat = aarptnew(&spa)) != NULL)) { + bcopy((caddr_t)ea->aarp_sha, (caddr_t)aat->aat_enaddr, + sizeof(ea->aarp_sha)); + aat->aat_flags |= ATF_COM; } /* * Don't respond to responses, and never respond if we're * still probing. */ - if ( tpa.s_net != ma.s_net || tpa.s_node != ma.s_node || - op == AARPOP_RESPONSE || ( aa->aa_flags & AFA_PROBING )) { - m_freem( m ); + if (tpa.s_net != ma.s_net || tpa.s_node != ma.s_node || + op == AARPOP_RESPONSE || (aa->aa_flags & AFA_PROBING)) { + m_freem(m); return; } - bcopy(( caddr_t )ea->aarp_sha, ( caddr_t )ea->aarp_tha, - sizeof( ea->aarp_sha )); - bcopy(( caddr_t )ac->ac_enaddr, ( caddr_t )ea->aarp_sha, - sizeof( ea->aarp_sha )); + bcopy((caddr_t)ea->aarp_sha, (caddr_t)ea->aarp_tha, + sizeof(ea->aarp_sha)); + bcopy((caddr_t)ac->ac_enaddr, (caddr_t)ea->aarp_sha, + sizeof(ea->aarp_sha)); /* XXX */ eh = (struct ether_header *)sa.sa_data; - bcopy(( caddr_t )ea->aarp_tha, ( caddr_t )eh->ether_dhost, - sizeof( eh->ether_dhost )); + bcopy((caddr_t)ea->aarp_tha, (caddr_t)eh->ether_dhost, + sizeof(eh->ether_dhost)); - if ( aa->aa_flags & AFA_PHASE2 ) { - eh->ether_type = htons( sizeof( struct llc ) + - sizeof( struct ether_aarp )); - M_PREPEND( m, sizeof( struct llc ), M_DONTWAIT ); - if ( m == NULL ) { + if (aa->aa_flags & AFA_PHASE2) { + eh->ether_type = htons(sizeof(struct llc) + + sizeof(struct ether_aarp)); + M_PREPEND(m, sizeof(struct llc), M_DONTWAIT); + if (m == NULL) { return; } - llc = mtod( m, struct llc *); + llc = mtod(m, struct llc *); llc->llc_dsap = llc->llc_ssap = LLC_SNAP_LSAP; llc->llc_control = LLC_UI; - bcopy( aarp_org_code, llc->llc_org_code, sizeof( aarp_org_code )); - llc->llc_ether_type = htons( ETHERTYPE_AARP ); + bcopy(aarp_org_code, llc->llc_org_code, sizeof(aarp_org_code)); + llc->llc_ether_type = htons(ETHERTYPE_AARP); - bcopy( ea->aarp_spnet, ea->aarp_tpnet, sizeof( ea->aarp_tpnet )); - bcopy( &ma.s_net, ea->aarp_spnet, sizeof( ea->aarp_spnet )); + bcopy(ea->aarp_spnet, ea->aarp_tpnet, sizeof(ea->aarp_tpnet)); + bcopy(&ma.s_net, ea->aarp_spnet, sizeof(ea->aarp_spnet)); } else { - eh->ether_type = htons( ETHERTYPE_AARP ); + eh->ether_type = htons(ETHERTYPE_AARP); } ea->aarp_tpnode = ea->aarp_spnode; ea->aarp_spnode = ma.s_node; - ea->aarp_op = htons( AARPOP_RESPONSE ); + ea->aarp_op = htons(AARPOP_RESPONSE); - sa.sa_len = sizeof( struct sockaddr ); + sa.sa_len = sizeof(struct sockaddr); sa.sa_family = AF_UNSPEC; - (*ac->ac_if.if_output)( &ac->ac_if, m, &sa, NULL); /* XXX */ + (*ac->ac_if.if_output)(&ac->ac_if, m, &sa, NULL); /* XXX */ return; } static void -aarptfree( struct aarptab *aat) +aarptfree(struct aarptab *aat) { - if ( aat->aat_hold ) - m_freem( aat->aat_hold ); + if (aat->aat_hold) + m_freem(aat->aat_hold); aat->aat_hold = NULL; aat->aat_timer = aat->aat_flags = 0; aat->aat_ataddr.s_net = 0; @@ -486,7 +486,7 @@ } struct aarptab * -aarptnew( addr ) +aarptnew(addr) struct at_addr *addr; { int n; @@ -494,34 +494,34 @@ struct aarptab *aat, *aato = NULL; static int first = 1; - if ( first ) { + if (first) { first = 0; - aarptimer_ch = timeout( aarptimer, (caddr_t)0, hz ); + aarptimer_ch = timeout(aarptimer, (caddr_t)0, hz); } - aat = &aarptab[ AARPTAB_HASH( *addr ) * AARPTAB_BSIZ ]; - for ( n = 0; n < AARPTAB_BSIZ; n++, aat++ ) { - if ( aat->aat_flags == 0 ) + aat = &aarptab[ AARPTAB_HASH(*addr) * AARPTAB_BSIZ ]; + for (n = 0; n < AARPTAB_BSIZ; n++, aat++) { + if (aat->aat_flags == 0) goto out; - if ( aat->aat_flags & ATF_PERM ) + if (aat->aat_flags & ATF_PERM) continue; - if ((int) aat->aat_timer > oldest ) { + if ((int) aat->aat_timer > oldest) { oldest = aat->aat_timer; aato = aat; } } - if ( aato == NULL ) - return( NULL ); + if (aato == NULL) + return (NULL); aat = aato; - aarptfree( aat ); + aarptfree(aat); out: aat->aat_ataddr = *addr; aat->aat_flags = ATF_INUSE; - return( aat ); + return (aat); } void -aarpprobe( void *arg ) +aarpprobe(void *arg) { struct arpcom *ac = arg; struct mbuf *m; @@ -540,80 +540,80 @@ */ for (aa = (struct at_ifaddr *)TAILQ_FIRST(&ac->ac_if.if_addrhead); aa; aa = (struct at_ifaddr *)aa->aa_ifa.ifa_link.tqe_next) { - if ( AA_SAT( aa )->sat_family == AF_APPLETALK && - ( aa->aa_flags & AFA_PROBING )) { + if (AA_SAT(aa)->sat_family == AF_APPLETALK && + (aa->aa_flags & AFA_PROBING)) { break; } } - if ( aa == NULL ) { /* serious error XXX */ - printf( "aarpprobe why did this happen?!\n" ); + if (aa == NULL) { /* serious error XXX */ + printf("aarpprobe why did this happen?!\n"); return; } - if ( aa->aa_probcnt <= 0 ) { + if (aa->aa_probcnt <= 0) { aa->aa_flags &= ~AFA_PROBING; - wakeup( aa ); + wakeup(aa); return; } else { - aa->aa_ch = timeout( aarpprobe, (caddr_t)ac, hz / 5 ); + aa->aa_ch = timeout(aarpprobe, (caddr_t)ac, hz / 5); } - if (( m = m_gethdr( M_DONTWAIT, MT_DATA )) == NULL ) { + if ((m = m_gethdr(M_DONTWAIT, MT_DATA)) == NULL) { return; } #ifdef MAC mac_create_mbuf_linklayer(&ac->ac_if, m); #endif - m->m_len = sizeof( *ea ); - m->m_pkthdr.len = sizeof( *ea ); - MH_ALIGN( m, sizeof( *ea )); + m->m_len = sizeof(*ea); + m->m_pkthdr.len = sizeof(*ea); + MH_ALIGN(m, sizeof(*ea)); - ea = mtod( m, struct ether_aarp *); - bzero((caddr_t)ea, sizeof( *ea )); + ea = mtod(m, struct ether_aarp *); + bzero((caddr_t)ea, sizeof(*ea)); - ea->aarp_hrd = htons( AARPHRD_ETHER ); - ea->aarp_pro = htons( ETHERTYPE_AT ); - ea->aarp_hln = sizeof( ea->aarp_sha ); - ea->aarp_pln = sizeof( ea->aarp_spu ); - ea->aarp_op = htons( AARPOP_PROBE ); + ea->aarp_hrd = htons(AARPHRD_ETHER); + ea->aarp_pro = htons(ETHERTYPE_AT); + ea->aarp_hln = sizeof(ea->aarp_sha); + ea->aarp_pln = sizeof(ea->aarp_spu); + ea->aarp_op = htons(AARPOP_PROBE); bcopy((caddr_t)ac->ac_enaddr, (caddr_t)ea->aarp_sha, - sizeof( ea->aarp_sha )); + sizeof(ea->aarp_sha)); eh = (struct ether_header *)sa.sa_data; - if ( aa->aa_flags & AFA_PHASE2 ) { - bcopy(atmulticastaddr, eh->ether_dhost, sizeof( eh->ether_dhost )); - eh->ether_type = htons( sizeof( struct llc ) + - sizeof( struct ether_aarp )); - M_PREPEND( m, sizeof( struct llc ), M_TRYWAIT ); - if ( m == NULL ) { + if (aa->aa_flags & AFA_PHASE2) { + bcopy(atmulticastaddr, eh->ether_dhost, sizeof(eh->ether_dhost)); + eh->ether_type = htons(sizeof(struct llc) + + sizeof(struct ether_aarp)); + M_PREPEND(m, sizeof(struct llc), M_TRYWAIT); + if (m == NULL) { return; } - llc = mtod( m, struct llc *); + llc = mtod(m, struct llc *); llc->llc_dsap = llc->llc_ssap = LLC_SNAP_LSAP; llc->llc_control = LLC_UI; - bcopy( aarp_org_code, llc->llc_org_code, sizeof( aarp_org_code )); - llc->llc_ether_type = htons( ETHERTYPE_AARP ); + bcopy(aarp_org_code, llc->llc_org_code, sizeof(aarp_org_code)); + llc->llc_ether_type = htons(ETHERTYPE_AARP); - bcopy( &AA_SAT( aa )->sat_addr.s_net, ea->aarp_spnet, - sizeof( ea->aarp_spnet )); - bcopy( &AA_SAT( aa )->sat_addr.s_net, ea->aarp_tpnet, - sizeof( ea->aarp_tpnet )); - ea->aarp_spnode = ea->aarp_tpnode = AA_SAT( aa )->sat_addr.s_node; + bcopy(&AA_SAT(aa)->sat_addr.s_net, ea->aarp_spnet, + sizeof(ea->aarp_spnet)); + bcopy(&AA_SAT(aa)->sat_addr.s_net, ea->aarp_tpnet, + sizeof(ea->aarp_tpnet)); + ea->aarp_spnode = ea->aarp_tpnode = AA_SAT(aa)->sat_addr.s_node; } else { bcopy(ac->ac_if.if_broadcastaddr, (caddr_t)eh->ether_dhost, - sizeof( eh->ether_dhost )); - eh->ether_type = htons( ETHERTYPE_AARP ); - ea->aarp_spa = ea->aarp_tpa = AA_SAT( aa )->sat_addr.s_node; + sizeof(eh->ether_dhost)); + eh->ether_type = htons(ETHERTYPE_AARP); + ea->aarp_spa = ea->aarp_tpa = AA_SAT(aa)->sat_addr.s_node; } #ifdef NETATALKDEBUG printf("aarp: sending probe for %u.%u\n", - ntohs(AA_SAT( aa )->sat_addr.s_net), - AA_SAT( aa )->sat_addr.s_node); + ntohs(AA_SAT(aa)->sat_addr.s_net), + AA_SAT(aa)->sat_addr.s_node); #endif /* NETATALKDEBUG */ - sa.sa_len = sizeof( struct sockaddr ); + sa.sa_len = sizeof(struct sockaddr); sa.sa_family = AF_UNSPEC; (*ac->ac_if.if_output)(&ac->ac_if, m, &sa, NULL); /* XXX */ aa->aa_probcnt--; @@ -625,10 +625,10 @@ struct aarptab *aat; int i; - untimeout( aarptimer, 0, aarptimer_ch ); - for ( i = 0, aat = aarptab; i < AARPTAB_SIZE; i++, aat++ ) { - if ( aat->aat_hold ) { - m_freem( aat->aat_hold ); + untimeout(aarptimer, 0, aarptimer_ch); + for (i = 0, aat = aarptab; i < AARPTAB_SIZE; i++, aat++) { + if (aat->aat_hold) { + m_freem(aat->aat_hold); aat->aat_hold = NULL; } } ==== //depot/projects/netperf_socket/sys/netatalk/at_control.c#3 (text+ko) ==== @@ -2,7 +2,7 @@ * Copyright (c) 1990,1991 Regents of The University of Michigan. * All Rights Reserved. * - * $FreeBSD: src/sys/netatalk/at_control.c,v 1.36 2004/03/21 03:28:08 rwatson Exp $ + * $FreeBSD: src/sys/netatalk/at_control.c,v 1.37 2004/03/22 03:24:10 rwatson Exp $ */ #include <sys/param.h> @@ -31,19 +31,19 @@ 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 ); +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); static int aa_claim_addr(struct ifaddr *ifa, struct sockaddr *gw); # 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 ) + (a)->sat_addr.s_node == (b)->sat_addr.s_node) int at_control(struct socket *so, u_long cmd, caddr_t data, - struct ifnet *ifp, struct thread *td ) + struct ifnet *ifp, struct thread *td) { struct ifreq *ifr = (struct ifreq *)data; struct sockaddr_at *sat; @@ -56,9 +56,9 @@ /* * If we have an ifp, then find the matching at_ifaddr if it exists */ - if ( ifp ) { - for ( aa = at_ifaddr; aa; aa = aa->aa_next ) { - if ( aa->aa_ifp == ifp ) break; + if (ifp) { + for (aa = at_ifaddr; aa; aa = aa->aa_next) { + if (aa->aa_ifp == ifp) break; } } @@ -68,7 +68,7 @@ * so that they start to look more similar to other protocols etc. */ - switch ( cmd ) { + switch (cmd) { case SIOCAIFADDR: case SIOCDIFADDR: /* @@ -78,10 +78,10 @@ * This may leave aa pointing to the first address on the * NEXT interface! */ - if ( ifra->ifra_addr.sat_family == AF_APPLETALK ) { - for ( ; aa; aa = aa->aa_next ) { - if ( aa->aa_ifp == ifp && - sateqaddr( &aa->aa_addr, &ifra->ifra_addr )) { + if (ifra->ifra_addr.sat_family == AF_APPLETALK) { + for (; aa; aa = aa->aa_next) { + if (aa->aa_ifp == ifp && + sateqaddr(&aa->aa_addr, &ifra->ifra_addr)) { break; } } @@ -90,8 +90,8 @@ * If we a retrying to delete an addres but didn't find such, * then rewurn with an error */ - if ( cmd == SIOCDIFADDR && aa == NULL ) { - return( EADDRNOTAVAIL ); + if (cmd == SIOCDIFADDR && aa == NULL) { + return (EADDRNOTAVAIL); } /*FALLTHROUGH*/ @@ -99,21 +99,21 @@ /* * If we are not superuser, then we don't get to do these ops. */ - if ( suser(td) ) { - return( EPERM ); + if (suser(td)) { + return (EPERM); } - sat = satosat( &ifr->ifr_addr ); + sat = satosat(&ifr->ifr_addr); nr = (struct netrange *)sat->sat_zero; - if ( nr->nr_phase == 1 ) { + if (nr->nr_phase == 1) { /* * Look for a phase 1 address on this interface. * This may leave aa pointing to the first address on the * NEXT interface! */ - for ( ; aa; aa = aa->aa_next ) { - if ( aa->aa_ifp == ifp && - ( aa->aa_flags & AFA_PHASE2 ) == 0 ) { + for (; aa; aa = aa->aa_next) { + if (aa->aa_ifp == ifp && + (aa->aa_flags & AFA_PHASE2) == 0) { break; } } @@ -123,23 +123,23 @@ * This may leave aa pointing to the first address on the * NEXT interface! */ - for ( ; aa; aa = aa->aa_next ) { - if ( aa->aa_ifp == ifp && ( aa->aa_flags & AFA_PHASE2 )) { + for (; aa; aa = aa->aa_next) { + if (aa->aa_ifp == ifp && (aa->aa_flags & AFA_PHASE2)) { break; } } } - if ( ifp == NULL ) - panic( "at_control" ); + if (ifp == NULL) + panic("at_control"); /* * If we failed to find an existing at_ifaddr entry, then we * allocate a fresh one. */ - if ( aa == NULL ) { + if (aa == NULL) { aa0 = malloc(sizeof(struct at_ifaddr), M_IFADDR, M_WAITOK | M_ZERO); - if (( aa = at_ifaddr ) != NULL ) { + if ((aa = at_ifaddr) != NULL) { /* * Don't let the loopback be first, since the first * address is the machine's default address for @@ -147,12 +147,12 @@ * If it is, stick ourself in front, otherwise * go to the back of the list. */ - if ( at_ifaddr->aa_ifp->if_flags & IFF_LOOPBACK ) { + if (at_ifaddr->aa_ifp->if_flags & IFF_LOOPBACK) { aa = aa0; aa->aa_next = at_ifaddr; at_ifaddr = aa; } else { - for ( ; aa->aa_next; aa = aa->aa_next ) + for (; aa->aa_next; aa = aa->aa_next) ; aa->aa_next = aa0; } @@ -181,7 +181,7 @@ /* * Set/clear the phase 2 bit. */ - if ( nr->nr_phase == 1 ) { + if (nr->nr_phase == 1) { aa->aa_flags &= ~AFA_PHASE2; } else { aa->aa_flags |= AFA_PHASE2; @@ -195,21 +195,21 @@ /* * If we DID find one then we clobber any routes dependent on it.. */ - at_scrub( ifp, aa ); + at_scrub(ifp, aa); } break; case SIOCGIFADDR : - sat = satosat( &ifr->ifr_addr ); + sat = satosat(&ifr->ifr_addr); nr = (struct netrange *)sat->sat_zero; - if ( nr->nr_phase == 1 ) { + if (nr->nr_phase == 1) { /* * If the request is specifying phase 1, then * only look at a phase one address */ - for ( ; aa; aa = aa->aa_next ) { - if ( aa->aa_ifp == ifp && - ( aa->aa_flags & AFA_PHASE2 ) == 0 ) { + for (; aa; aa = aa->aa_next) { + if (aa->aa_ifp == ifp && + (aa->aa_flags & AFA_PHASE2) == 0) { break; } } @@ -217,15 +217,15 @@ /* * default to phase 2 */ - for ( ; aa; aa = aa->aa_next ) { - if ( aa->aa_ifp == ifp && ( aa->aa_flags & AFA_PHASE2 )) { >>> TRUNCATED FOR MAIL (1000 lines) <<<
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200403220326.i2M3QScV093649>