From b8e3da4a8359080d1f6ad95cb90677d6be0fe979 Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Mon, 22 Mar 2004 03:24:10 +0000 Subject: [PATCH] Since I have my hands all over netatalk adding locking and restructuring it, cinch the file's style closer to style(9) with regard to parenthesis: s/( /(/g s/ )/)/g s/return(/return (/g s/return 0/return (0)/ s/return 1/return (1)/ --- sys/netatalk/aarp.c | 422 +++++++++++++++++++------------------- sys/netatalk/at_control.c | 304 +++++++++++++-------------- sys/netatalk/ddp_output.c | 98 ++++----- sys/netatalk/ddp_pcb.c | 192 ++++++++--------- sys/netatalk/ddp_usrreq.c | 136 ++++++------ 5 files changed, 576 insertions(+), 576 deletions(-) diff --git a/sys/netatalk/aarp.c b/sys/netatalk/aarp.c index e5d0d7ac8e58..b789d3a5e186 100644 --- a/sys/netatalk/aarp.c +++ b/sys/netatalk/aarp.c @@ -28,8 +28,8 @@ #include #include -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 void at_aarpinput( struct arpcom *ac, struct mbuf *m); 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 @@ static struct aarptab aarptab[AARPTAB_SIZE]; #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 @@ aarptimer(void *ignored) 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 @@ aarptimer(void *ignored) * 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 @@ aarpwhohas( struct arpcom *ac, struct sockaddr_at *sat ) 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 @@ aarpwhohas( struct arpcom *ac, struct sockaddr_at *sat ) * 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 @@ aarpresolve( ac, m, destsat, desten ) 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 @@ aarpintr( m ) } 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 @@ at_aarpinput( struct arpcom *ac, struct mbuf *m) 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 @@ at_aarpinput( struct arpcom *ac, struct mbuf *m) */ 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 @@ aarptfree( struct aarptab *aat) } struct aarptab * -aarptnew( addr ) +aarptnew(addr) struct at_addr *addr; { int n; @@ -494,34 +494,34 @@ aarptnew( addr ) 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 @@ aarpprobe( void *arg ) */ 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 @@ aarp_clean(void) 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; } } diff --git a/sys/netatalk/at_control.c b/sys/netatalk/at_control.c index 891fd4757590..2a61d6316ed9 100644 --- a/sys/netatalk/at_control.c +++ b/sys/netatalk/at_control.c @@ -31,19 +31,19 @@ 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 ); +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 @@ at_control(struct socket *so, u_long cmd, caddr_t data, /* * 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 @@ at_control(struct socket *so, u_long cmd, caddr_t data, * so that they start to look more similar to other protocols etc. */ - switch ( cmd ) { + switch (cmd) { case SIOCAIFADDR: case SIOCDIFADDR: /* @@ -78,10 +78,10 @@ at_control(struct socket *so, u_long cmd, caddr_t data, * 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 @@ at_control(struct socket *so, u_long cmd, caddr_t data, * 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 @@ at_control(struct socket *so, u_long cmd, caddr_t data, /* * 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 @@ at_control(struct socket *so, u_long cmd, caddr_t data, * 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 @@ at_control(struct socket *so, u_long cmd, caddr_t data, * 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 @@ at_control(struct socket *so, u_long cmd, caddr_t data, /* * 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 @@ at_control(struct socket *so, u_long cmd, caddr_t data, /* * 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 @@ at_control(struct socket *so, u_long cmd, caddr_t data, /* * default to phase 2 */ - 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 ( aa == NULL ) - return( EADDRNOTAVAIL ); + if (aa == NULL) + return (EADDRNOTAVAIL); break; } @@ -233,7 +233,7 @@ at_control(struct socket *so, u_long cmd, caddr_t data, * By the time this switch is run we should be able to assume that * the "aa" pointer is valid when needed. */ - switch ( cmd ) { + switch (cmd) { case SIOCGIFADDR: /* @@ -252,19 +252,19 @@ at_control(struct socket *so, u_long cmd, caddr_t data, break; case SIOCSIFADDR: - return( at_ifinit( ifp, aa, (struct sockaddr_at *)&ifr->ifr_addr )); + return (at_ifinit(ifp, aa, (struct sockaddr_at *)&ifr->ifr_addr)); case SIOCAIFADDR: - if ( sateqaddr( &ifra->ifra_addr, &aa->aa_addr )) { - return( 0 ); + if (sateqaddr(&ifra->ifra_addr, &aa->aa_addr)) { + return (0); } - return( at_ifinit( ifp, aa, (struct sockaddr_at *)&ifr->ifr_addr )); + return (at_ifinit(ifp, aa, (struct sockaddr_at *)&ifr->ifr_addr)); case SIOCDIFADDR: /* * scrub all routes.. didn't we just DO this? XXX yes, del it */ - at_scrub( ifp, aa ); + at_scrub(ifp, aa); /* * remove the ifaddr from the interface @@ -277,20 +277,20 @@ at_control(struct socket *so, u_long cmd, caddr_t data, * as well, or we'd be in deep trouble */ aa0 = aa; - if ( aa0 == ( aa = at_ifaddr )) { + if (aa0 == (aa = at_ifaddr)) { at_ifaddr = aa->aa_next; } else { - while ( aa->aa_next && ( aa->aa_next != aa0 )) { + while (aa->aa_next && (aa->aa_next != aa0)) { aa = aa->aa_next; } /* * if we found it, remove it, otherwise we screwed up. */ - if ( aa->aa_next ) { + if (aa->aa_next) { aa->aa_next = aa0->aa_next; } else { - panic( "at_control" ); + panic("at_control"); } } @@ -301,11 +301,11 @@ at_control(struct socket *so, u_long cmd, caddr_t data, break; default: - if ( ifp == NULL || ifp->if_ioctl == NULL ) - return( EOPNOTSUPP ); - return( (*ifp->if_ioctl)( ifp, cmd, data )); + if (ifp == NULL || ifp->if_ioctl == NULL) + return (EOPNOTSUPP); + return ((*ifp->if_ioctl)(ifp, cmd, data)); } - return( 0 ); + return (0); } /* @@ -315,32 +315,32 @@ at_control(struct socket *so, u_long cmd, caddr_t data, * as aa->at_ifaddr.ifa_ifp should be the same. */ static int -at_scrub( ifp, aa ) +at_scrub(ifp, aa) struct ifnet *ifp; struct at_ifaddr *aa; { int error; - if ( aa->aa_flags & AFA_ROUTE ) { + if (aa->aa_flags & AFA_ROUTE) { if (ifp->if_flags & IFF_LOOPBACK) { if ((error = aa_delsingleroute(&aa->aa_ifa, &aa->aa_addr.sat_addr, &aa->aa_netmask.sat_addr)) != 0) { - return( error ); + return (error); } } else if (ifp->if_flags & IFF_POINTOPOINT) { - if ((error = rtinit( &aa->aa_ifa, RTM_DELETE, RTF_HOST)) != 0) - return( error ); + if ((error = rtinit(&aa->aa_ifa, RTM_DELETE, RTF_HOST)) != 0) + return (error); } else if (ifp->if_flags & IFF_BROADCAST) { error = aa_dorangeroute(&aa->aa_ifa, ntohs(aa->aa_firstnet), ntohs(aa->aa_lastnet), - RTM_DELETE ); + RTM_DELETE); } aa->aa_ifa.ifa_flags &= ~IFA_ROUTE; aa->aa_flags &= ~AFA_ROUTE; } - return( 0 ); + return (0); } /* @@ -348,7 +348,7 @@ at_scrub( ifp, aa ) * bang them all together at high speed and see what happens */ static int -at_ifinit( ifp, aa, sat ) +at_ifinit(ifp, aa, sat) struct ifnet *ifp; struct at_ifaddr *aa; struct sockaddr_at *sat; @@ -371,10 +371,10 @@ at_ifinit( ifp, aa, sat ) * at_ifnet (also given). Remember ing to update * those parts of the at_ifaddr that need special processing */ - 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; + 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; aa->aa_firstnet = nr.nr_firstnet; aa->aa_lastnet = nr.nr_lastnet; @@ -393,13 +393,13 @@ at_ifinit( ifp, aa, sat ) * that phase 1 probes use only nodes, not net.node pairs. Under * phase 2, both the net and node must be the same. */ - if ( ifp->if_flags & IFF_LOOPBACK ) { - AA_SAT( aa )->sat_len = sat->sat_len; - 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 (ifp->if_flags & IFF_LOOPBACK) { + AA_SAT(aa)->sat_len = sat->sat_len; + 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) { + } else if (fp->if_flags & IFF_POINTOPOINT) { /* unimplemented */ /* * we'd have to copy the dstaddr field over from the sat @@ -417,19 +417,19 @@ at_ifinit( ifp, aa, sat ) * we find an unused address. */ aa->aa_flags |= AFA_PROBING; /* if not loopback we Must probe? */ - AA_SAT( aa )->sat_len = sizeof(struct sockaddr_at); - AA_SAT( aa )->sat_family = AF_APPLETALK; - if ( aa->aa_flags & AFA_PHASE2 ) { - if ( sat->sat_addr.s_net == ATADDR_ANYNET ) { + AA_SAT(aa)->sat_len = sizeof(struct sockaddr_at); + AA_SAT(aa)->sat_family = AF_APPLETALK; + if (aa->aa_flags & AFA_PHASE2) { + if (sat->sat_addr.s_net == ATADDR_ANYNET) { /* * If we are phase 2, and the net was not specified * then we select a random net within the supplied netrange. * XXX use /dev/random? */ - if ( nnets != 1 ) { - net = ntohs( nr.nr_firstnet ) + time_second % ( nnets - 1 ); + if (nnets != 1) { + net = ntohs(nr.nr_firstnet) + time_second % (nnets - 1); } else { - net = ntohs( nr.nr_firstnet ); + net = ntohs(nr.nr_firstnet); } } else { /* @@ -437,25 +437,25 @@ at_ifinit( ifp, aa, sat ) * the netrange. If it is not then replace the old values * and return an error */ - if ( ntohs( sat->sat_addr.s_net ) < ntohs( nr.nr_firstnet ) || - ntohs( sat->sat_addr.s_net ) > ntohs( nr.nr_lastnet )) { + if (ntohs(sat->sat_addr.s_net) < ntohs(nr.nr_firstnet) || + ntohs(sat->sat_addr.s_net) > ntohs(nr.nr_lastnet)) { aa->aa_addr = oldaddr; aa->aa_firstnet = onr.nr_firstnet; aa->aa_lastnet = onr.nr_lastnet; splx(s); - return( EINVAL ); + return (EINVAL); } /* * otherwise just use the new net number.. */ - net = ntohs( sat->sat_addr.s_net ); + net = ntohs(sat->sat_addr.s_net); } } else { /* * we must be phase one, so just use whatever we were given. * I guess it really isn't going to be used... RIGHT? */ - net = ntohs( sat->sat_addr.s_net ); + net = ntohs(sat->sat_addr.s_net); } /* @@ -463,25 +463,25 @@ at_ifinit( ifp, aa, sat ) * If it's not specified, be random about it... * XXX use /dev/random? */ - if ( sat->sat_addr.s_node == ATADDR_ANYNODE ) { - AA_SAT( aa )->sat_addr.s_node = time_second; + if (sat->sat_addr.s_node == ATADDR_ANYNODE) { + AA_SAT(aa)->sat_addr.s_node = time_second; } else { - AA_SAT( aa )->sat_addr.s_node = sat->sat_addr.s_node; + AA_SAT(aa)->sat_addr.s_node = sat->sat_addr.s_node; } /* * Copy the phase. */ - AA_SAT( aa )->sat_range.r_netrange.nr_phase + AA_SAT(aa)->sat_range.r_netrange.nr_phase = ((aa->aa_flags & AFA_PHASE2) ? 2:1); /* * step through the nets in the range * starting at the (possibly random) start point. */ - for ( i = nnets, netinc = 1; i > 0; net = ntohs( nr.nr_firstnet ) + - (( net - ntohs( nr.nr_firstnet ) + netinc ) % nnets ), i-- ) { - AA_SAT( aa )->sat_addr.s_net = htons( net ); + for (i = nnets, netinc = 1; i > 0; net = ntohs(nr.nr_firstnet) + + ((net - ntohs(nr.nr_firstnet) + netinc) % nnets), i--) { + AA_SAT(aa)->sat_addr.s_net = htons(net); /* * using a rather strange stepping method, @@ -489,10 +489,10 @@ at_ifinit( ifp, aa, sat ) * Once again, starting at the (possibly random) * initial node address. */ - for ( j = 0, nodeinc = time_second | 1; j < 256; - j++, AA_SAT( aa )->sat_addr.s_node += nodeinc ) { - if ( AA_SAT( aa )->sat_addr.s_node > 253 || - AA_SAT( aa )->sat_addr.s_node < 1 ) { + for (j = 0, nodeinc = time_second | 1; j < 256; + j++, AA_SAT(aa)->sat_addr.s_node += nodeinc) { + if (AA_SAT(aa)->sat_addr.s_node > 253 || + AA_SAT(aa)->sat_addr.s_node < 1) { continue; } aa->aa_probcnt = 10; @@ -501,18 +501,18 @@ at_ifinit( ifp, aa, sat ) * start off the probes as an asynchronous activity. * though why wait 200mSec? */ - aa->aa_ch = timeout( aarpprobe, (caddr_t)ifp, hz / 5 ); - if ( tsleep( aa, PPAUSE|PCATCH, "at_ifinit", 0 )) { + aa->aa_ch = timeout(aarpprobe, (caddr_t)ifp, hz / 5); + if (tsleep(aa, PPAUSE|PCATCH, "at_ifinit", 0)) { /* * theoretically we shouldn't time out here * so if we returned with an error.. */ - printf( "at_ifinit: why did this happen?!\n" ); + printf("at_ifinit: why did this happen?!\n"); aa->aa_addr = oldaddr; aa->aa_firstnet = onr.nr_firstnet; aa->aa_lastnet = onr.nr_lastnet; - splx( s ); - return( EINTR ); + splx(s); + return (EINTR); } /* @@ -521,7 +521,7 @@ at_ifinit( ifp, aa, sat ) * a free spot, or if we need to iterate to the next * address to try. */ - if (( aa->aa_flags & AFA_PROBING ) == 0 ) { + if ((aa->aa_flags & AFA_PROBING) == 0) { break; } } @@ -529,11 +529,11 @@ at_ifinit( ifp, aa, sat ) /* * of course we need to break out through two loops... */ - if (( aa->aa_flags & AFA_PROBING ) == 0 ) { + if ((aa->aa_flags & AFA_PROBING) == 0) { break; } /* reset node for next network */ - AA_SAT( aa )->sat_addr.s_node = time_second; + AA_SAT(aa)->sat_addr.s_node = time_second; } /* @@ -541,12 +541,12 @@ at_ifinit( ifp, aa, sat ) * the possible addresses, so we need to give up */ - if ( aa->aa_flags & AFA_PROBING ) { + if (aa->aa_flags & AFA_PROBING) { aa->aa_addr = oldaddr; aa->aa_firstnet = onr.nr_firstnet; aa->aa_lastnet = onr.nr_lastnet; - splx( s ); - return( EADDRINUSE ); + splx(s); + return (EADDRINUSE); } } @@ -554,8 +554,8 @@ at_ifinit( ifp, aa, sat ) * Now that we have selected an address, we need to tell the interface * about it, just in case it needs to adjust something. */ - if ( ifp->if_ioctl && - ( error = (*ifp->if_ioctl)( ifp, SIOCSIFADDR, (caddr_t)aa ))) { + if (ifp->if_ioctl && + (error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, (caddr_t)aa))) { /* * of course this could mean that it objects violently * so if it does, we back out again.. @@ -563,8 +563,8 @@ at_ifinit( ifp, aa, sat ) aa->aa_addr = oldaddr; aa->aa_firstnet = onr.nr_firstnet; aa->aa_lastnet = onr.nr_lastnet; - splx( s ); - return( error ); + splx(s); + return (error); } /* @@ -590,10 +590,10 @@ at_ifinit( ifp, aa, sat ) if (ifp->if_flags & IFF_BROADCAST) { 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_ifa.ifa_broadaddr = (struct sockaddr *) &aa->aa_broadaddr; /* add the range of routes needed */ error = aa_dorangeroute(&aa->aa_ifa, - ntohs(aa->aa_firstnet), ntohs(aa->aa_lastnet), RTM_ADD ); + ntohs(aa->aa_firstnet), ntohs(aa->aa_lastnet), RTM_ADD); } else if (ifp->if_flags & IFF_POINTOPOINT) { struct at_addr rtaddr, rtmask; @@ -601,16 +601,16 @@ at_ifinit( ifp, aa, sat ) bzero(&rtaddr, sizeof(rtaddr)); bzero(&rtmask, sizeof(rtmask)); /* fill in the far end if we know it here XXX */ - aa->aa_ifa.ifa_dstaddr = (struct sockaddr *) &aa->aa_dstaddr; + aa->aa_ifa.ifa_dstaddr = (struct sockaddr *) &aa->aa_dstaddr; error = aa_addsingleroute(&aa->aa_ifa, &rtaddr, &rtmask); } - else if ( ifp->if_flags & IFF_LOOPBACK ) { + else if (ifp->if_flags & IFF_LOOPBACK) { 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; + 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 = 0x0; /* XXX should not be so.. should be HOST route */ error = aa_addsingleroute(&aa->aa_ifa, &rtaddr, &rtmask); @@ -626,13 +626,13 @@ at_ifinit( ifp, aa, sat ) * of course if we can't add these routes we back out, but it's getting * risky by now XXX */ - if ( error ) { - at_scrub( ifp, aa ); + if (error) { + at_scrub(ifp, aa); aa->aa_addr = oldaddr; aa->aa_firstnet = onr.nr_firstnet; aa->aa_lastnet = onr.nr_lastnet; - splx( s ); - return( error ); + splx(s); + return (error); } /* @@ -640,15 +640,15 @@ at_ifinit( ifp, aa, sat ) */ aa->aa_ifa.ifa_flags |= IFA_ROUTE; aa->aa_flags |= AFA_ROUTE; - splx( s ); - return( 0 ); + splx(s); + return (0); } /* * check whether a given address is a broadcast address for us.. */ int -at_broadcast( sat ) +at_broadcast(sat) struct sockaddr_at *sat; { struct at_ifaddr *aa; @@ -656,28 +656,28 @@ at_broadcast( sat ) /* * If the node is not right, it can't be a broadcast */ - if ( sat->sat_addr.s_node != ATADDR_BCAST ) { - return( 0 ); + if (sat->sat_addr.s_node != ATADDR_BCAST) { + return (0); } /* * If the node was right then if the net is right, it's a broadcast */ - if ( sat->sat_addr.s_net == ATADDR_ANYNET ) { - return( 1 ); + if (sat->sat_addr.s_net == ATADDR_ANYNET) { + return (1); } /* * failing that, if the net is one we have, it's a broadcast as well. */ - for ( aa = at_ifaddr; aa; aa = aa->aa_next ) { - if (( aa->aa_ifp->if_flags & IFF_BROADCAST ) - && ( ntohs( sat->sat_addr.s_net ) >= ntohs( aa->aa_firstnet ) - && ntohs( sat->sat_addr.s_net ) <= ntohs( aa->aa_lastnet ))) { - return( 1 ); + for (aa = at_ifaddr; aa; aa = aa->aa_next) { + if ((aa->aa_ifp->if_flags & IFF_BROADCAST) + && (ntohs(sat->sat_addr.s_net) >= ntohs(aa->aa_firstnet) + && ntohs(sat->sat_addr.s_net) <= ntohs(aa->aa_lastnet))) { + return (1); } } - return( 0 ); + return (0); } /* @@ -717,8 +717,8 @@ aa_dorangeroute(struct ifaddr *ifa, u_int bot, u_int top, int cmd) while (bot <= top) { mask1 = 1; - while ((( bot & ~mask1) >= bot) - && (( bot | mask1) <= top)) { + while (((bot & ~mask1) >= bot) + && ((bot | mask1) <= top)) { mask1 <<= 1; mask1 |= 1; } @@ -736,7 +736,7 @@ aa_dorangeroute(struct ifaddr *ifa, u_int bot, u_int top, int cmd) } bot = (bot | mask1) + 1; } - return 0; + return (0); } static int @@ -754,7 +754,7 @@ aa_addsingleroute(struct ifaddr *ifa, error = aa_dosingleroute(ifa, addr, mask, RTM_ADD, RTF_UP); if (error) printf("aa_addsingleroute: error %d\n", error); - return(error); + return (error); } static int @@ -766,7 +766,7 @@ aa_delsingleroute(struct ifaddr *ifa, error = aa_dosingleroute(ifa, addr, mask, RTM_DELETE, 0); if (error) printf("aa_delsingleroute: error %d\n", error); - return(error); + return (error); } static int @@ -787,7 +787,7 @@ aa_dosingleroute(struct ifaddr *ifa, mask.sat_addr.s_node = at_mask->s_node; if (at_mask->s_node) flags |= RTF_HOST; - return(rtrequest(cmd, (struct sockaddr *) &addr, + return (rtrequest(cmd, (struct sockaddr *) &addr, (flags & RTF_HOST)?(ifa->ifa_dstaddr):(ifa->ifa_addr), (struct sockaddr *) &mask, flags, NULL)); } @@ -801,21 +801,21 @@ aa_clean(void) struct ifaddr *ifa; struct ifnet *ifp; - while ( aa = at_ifaddr ) { + while (aa = at_ifaddr) { ifp = aa->aa_ifp; - at_scrub( ifp, aa ); + at_scrub(ifp, aa); at_ifaddr = aa->aa_next; - if (( ifa = ifp->if_addrlist ) == (struct ifaddr *)aa ) { + if ((ifa = ifp->if_addrlist) == (struct ifaddr *)aa) { ifp->if_addrlist = ifa->ifa_next; } else { - while ( ifa->ifa_next && - ( ifa->ifa_next != (struct ifaddr *)aa )) { + while (ifa->ifa_next && + (ifa->ifa_next != (struct ifaddr *)aa)) { ifa = ifa->ifa_next; } - if ( ifa->ifa_next ) { + if (ifa->ifa_next) { ifa->ifa_next = ((struct ifaddr *)aa)->ifa_next; } else { - panic( "at_entry" ); + panic("at_entry"); } } } @@ -832,7 +832,7 @@ aa_claim_addr(struct ifaddr *ifa, struct sockaddr *gw0) switch (gw->sat_range.r_netrange.nr_phase) { case 1: if(addr->sat_range.r_netrange.nr_phase == 1) - return 1; + return (1); case 0: case 2: /* @@ -843,14 +843,14 @@ aa_claim_addr(struct ifaddr *ifa, struct sockaddr *gw0) if ((addr->sat_addr.s_net == gw->sat_addr.s_net) || ((addr->sat_range.r_netrange.nr_lastnet) && (ntohs(gw->sat_addr.s_net) - >= ntohs(addr->sat_range.r_netrange.nr_firstnet )) + >= ntohs(addr->sat_range.r_netrange.nr_firstnet)) && (ntohs(gw->sat_addr.s_net) - <= ntohs(addr->sat_range.r_netrange.nr_lastnet )))) { - return 1; + <= ntohs(addr->sat_range.r_netrange.nr_lastnet)))) { + return (1); } break; default: printf("atalk: bad phase\n"); } - return 0; + return (0); } diff --git a/sys/netatalk/ddp_output.c b/sys/netatalk/ddp_output.c index e599b3af2b6c..3c0fe0b42cfe 100644 --- a/sys/netatalk/ddp_output.c +++ b/sys/netatalk/ddp_output.c @@ -46,20 +46,20 @@ int ddp_cksum = 1; int -ddp_output( struct mbuf *m, struct socket *so) +ddp_output(struct mbuf *m, struct socket *so) { struct ddpehdr *deh; - struct ddpcb *ddp = sotoddpcb( so ); + struct ddpcb *ddp = sotoddpcb(so); #ifdef MAC mac_create_mbuf_from_socket(so, m); #endif - M_PREPEND( m, sizeof( struct ddpehdr ), M_TRYWAIT ); - if ( m == NULL ) - return( ENOBUFS ); + M_PREPEND(m, sizeof(struct ddpehdr), M_TRYWAIT); + if (m == NULL) + return (ENOBUFS); - deh = mtod( m, struct ddpehdr *); + deh = mtod(m, struct ddpehdr *); deh->deh_pad = 0; deh->deh_hops = 0; @@ -76,50 +76,50 @@ ddp_output( struct mbuf *m, struct socket *so) * The checksum calculation is done after all of the other bytes have * been filled in. */ - if ( ddp_cksum ) { - deh->deh_sum = at_cksum( m, sizeof( int )); + if (ddp_cksum) { + deh->deh_sum = at_cksum(m, sizeof(int)); } else { deh->deh_sum = 0; } - deh->deh_bytes = htonl( deh->deh_bytes ); + deh->deh_bytes = htonl(deh->deh_bytes); #ifdef NETATALK_DEBUG printf ("ddp_output: from %d.%d:%d to %d.%d:%d\n", ntohs(deh->deh_snet), deh->deh_snode, deh->deh_sport, ntohs(deh->deh_dnet), deh->deh_dnode, deh->deh_dport); #endif - return( ddp_route( m, &ddp->ddp_route )); + return (ddp_route(m, &ddp->ddp_route)); } u_short -at_cksum( struct mbuf *m, int skip) +at_cksum(struct mbuf *m, int skip) { u_char *data, *end; u_long cksum = 0; - for (; m; m = m->m_next ) { - for ( data = mtod( m, u_char * ), end = data + m->m_len; data < end; - data++ ) { - if ( skip ) { + for (; m; m = m->m_next) { + for (data = mtod(m, u_char *), end = data + m->m_len; data < end; + data++) { + if (skip) { skip--; continue; } - cksum = ( cksum + *data ) << 1; - if ( cksum & 0x00010000 ) { + cksum = (cksum + *data) << 1; + if (cksum & 0x00010000) { cksum++; } cksum &= 0x0000ffff; } } - if ( cksum == 0 ) { + if (cksum == 0) { cksum = 0x0000ffff; } - return( (u_short)cksum ); + return ((u_short)cksum); } int -ddp_route( struct mbuf *m, struct route *ro) +ddp_route(struct mbuf *m, struct route *ro) { struct sockaddr_at gate; struct elaphdr *elh; @@ -140,24 +140,24 @@ ddp_route( struct mbuf *m, struct route *ro) * if we have a route, find the ifa that refers to this route. * I.e The ifa used to get to the gateway. */ - if ( (ro->ro_rt == NULL) - || ( ro->ro_rt->rt_ifa == NULL ) - || ( (ifp = ro->ro_rt->rt_ifa->ifa_ifp) == NULL )) { + if ((ro->ro_rt == NULL) + || (ro->ro_rt->rt_ifa == NULL) + || ((ifp = ro->ro_rt->rt_ifa->ifa_ifp) == NULL)) { rtalloc(ro); } - if ( (ro->ro_rt != NULL) - && ( ro->ro_rt->rt_ifa ) - && ( ifp = ro->ro_rt->rt_ifa->ifa_ifp )) { + if ((ro->ro_rt != NULL) + && (ro->ro_rt->rt_ifa) + && (ifp = ro->ro_rt->rt_ifa->ifa_ifp)) { net = ntohs(satosat(ro->ro_rt->rt_gateway)->sat_addr.s_net); - for ( aa = at_ifaddr; aa; aa = aa->aa_next ) { + for (aa = at_ifaddr; aa; aa = aa->aa_next) { if (((net == 0) || (aa->aa_ifp == ifp)) && - net >= ntohs( aa->aa_firstnet ) && - net <= ntohs( aa->aa_lastnet )) { + net >= ntohs(aa->aa_firstnet) && + net <= ntohs(aa->aa_lastnet)) { break; } } } else { - m_freem( m ); + m_freem(m); #ifdef NETATALK_DEBUG if (ro->ro_rt == NULL) printf ("ddp_route: no ro_rt.\n"); @@ -166,29 +166,29 @@ ddp_route( struct mbuf *m, struct route *ro) else printf ("ddp_route: no ro_rt->rt_ifa->ifa_ifp\n"); #endif - return( ENETUNREACH ); + return (ENETUNREACH); } - if ( aa == NULL ) { + if (aa == NULL) { #ifdef NETATALK_DEBUG - printf( "ddp_route: no atalk address found for %s\n", + printf("ddp_route: no atalk address found for %s\n", ifp->if_xname); #endif - m_freem( m ); - return( ENETUNREACH ); + m_freem(m); + return (ENETUNREACH); } /* * if the destination address is on a directly attached node use that, * else use the official gateway. */ - if ( ntohs( satosat( &ro->ro_dst )->sat_addr.s_net ) >= - ntohs( aa->aa_firstnet ) && - ntohs( satosat( &ro->ro_dst )->sat_addr.s_net ) <= - ntohs( aa->aa_lastnet )) { - gate = *satosat( &ro->ro_dst ); + if (ntohs(satosat(&ro->ro_dst)->sat_addr.s_net) >= + ntohs(aa->aa_firstnet) && + ntohs(satosat(&ro->ro_dst)->sat_addr.s_net) <= + ntohs(aa->aa_lastnet)) { + gate = *satosat(&ro->ro_dst); } else { - gate = *satosat( ro->ro_rt->rt_gateway ); + gate = *satosat(ro->ro_rt->rt_gateway); } /* @@ -197,12 +197,12 @@ ddp_route( struct mbuf *m, struct route *ro) * 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) ) { - MGET( m0, M_TRYWAIT, MT_HEADER ); - if ( m0 == NULL ) { - m_freem( m ); + if (!(aa->aa_flags & AFA_PHASE2)) { + MGET(m0, M_TRYWAIT, MT_HEADER); + if (m0 == NULL) { + m_freem(m); printf("ddp_route: no buffers\n"); - return( ENOBUFS ); + return (ENOBUFS); } #ifdef MAC mac_create_mbuf_from_mbuf(m, m0); @@ -212,8 +212,8 @@ ddp_route( struct mbuf *m, struct route *ro) m0->m_len = SZ_ELAPHDR; m = m0; - elh = mtod( m, struct elaphdr *); - elh->el_snode = satosat( &aa->aa_addr )->sat_addr.s_node; + elh = mtod(m, struct elaphdr *); + elh->el_snode = satosat(&aa->aa_addr)->sat_addr.s_node; elh->el_type = ELAP_DDPEXTEND; elh->el_dnode = gate.sat_addr.s_node; } @@ -237,6 +237,6 @@ ddp_route( struct mbuf *m, struct route *ro) return (if_simloop(ifp, m, gate.sat_family, 0)); } - return((*ifp->if_output)( ifp, + 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 900c9c8c64a1..4ee48d50e80e 100644 --- a/sys/netatalk/ddp_pcb.c +++ b/sys/netatalk/ddp_pcb.c @@ -38,41 +38,41 @@ at_pcbsetaddr(struct ddpcb *ddp, struct sockaddr *addr, struct thread *td) struct at_ifaddr *aa; struct ddpcb *ddpp; - if ( ddp->ddp_lsat.sat_port != ATADDR_ANYPORT ) { /* shouldn't be bound */ - return( EINVAL ); + if (ddp->ddp_lsat.sat_port != ATADDR_ANYPORT) { /* shouldn't be bound */ + return (EINVAL); } if (addr != NULL) { /* validate passed address */ sat = (struct sockaddr_at *)addr; if (sat->sat_family != AF_APPLETALK) { - return(EAFNOSUPPORT); + return (EAFNOSUPPORT); } - if ( sat->sat_addr.s_node != ATADDR_ANYNODE || - sat->sat_addr.s_net != ATADDR_ANYNET ) { - for ( aa = at_ifaddr; aa; aa = aa->aa_next ) { - if (( sat->sat_addr.s_net == AA_SAT( aa )->sat_addr.s_net ) && - ( sat->sat_addr.s_node == AA_SAT( aa )->sat_addr.s_node )) { + if (sat->sat_addr.s_node != ATADDR_ANYNODE || + sat->sat_addr.s_net != ATADDR_ANYNET) { + for (aa = at_ifaddr; aa; aa = aa->aa_next) { + if ((sat->sat_addr.s_net == AA_SAT(aa)->sat_addr.s_net) && + (sat->sat_addr.s_node == AA_SAT(aa)->sat_addr.s_node)) { break; } } - if ( !aa ) { - return( EADDRNOTAVAIL ); + if (!aa) { + return (EADDRNOTAVAIL); } } - if ( sat->sat_port != ATADDR_ANYPORT ) { - if ( sat->sat_port < ATPORT_FIRST || - sat->sat_port >= ATPORT_LAST ) { - return( EINVAL ); + if (sat->sat_port != ATADDR_ANYPORT) { + if (sat->sat_port < ATPORT_FIRST || + sat->sat_port >= ATPORT_LAST) { + return (EINVAL); } - if ( sat->sat_port < ATPORT_RESERVED && - suser(td) ) { - return( EACCES ); + if (sat->sat_port < ATPORT_RESERVED && + suser(td)) { + return (EACCES); } } } else { - bzero( (caddr_t)&lsat, sizeof( struct sockaddr_at )); + bzero((caddr_t)&lsat, sizeof(struct sockaddr_at)); lsat.sat_len = sizeof(struct sockaddr_at); lsat.sat_addr.s_node = ATADDR_ANYNODE; lsat.sat_addr.s_net = ATADDR_ANYNET; @@ -80,49 +80,49 @@ at_pcbsetaddr(struct ddpcb *ddp, struct sockaddr *addr, struct thread *td) sat = &lsat; } - if ( sat->sat_addr.s_node == ATADDR_ANYNODE && - sat->sat_addr.s_net == ATADDR_ANYNET ) { - if ( at_ifaddr == NULL ) { - return( EADDRNOTAVAIL ); + if (sat->sat_addr.s_node == ATADDR_ANYNODE && + sat->sat_addr.s_net == ATADDR_ANYNET) { + if (at_ifaddr == NULL) { + return (EADDRNOTAVAIL); } - sat->sat_addr = AA_SAT( at_ifaddr )->sat_addr; + sat->sat_addr = AA_SAT(at_ifaddr)->sat_addr; } ddp->ddp_lsat = *sat; /* * Choose port. */ - if ( sat->sat_port == ATADDR_ANYPORT ) { - for ( sat->sat_port = ATPORT_RESERVED; - sat->sat_port < ATPORT_LAST; sat->sat_port++ ) { - if ( ddp_ports[ sat->sat_port - 1 ] == NULL ) { + if (sat->sat_port == ATADDR_ANYPORT) { + for (sat->sat_port = ATPORT_RESERVED; + sat->sat_port < ATPORT_LAST; sat->sat_port++) { + if (ddp_ports[ sat->sat_port - 1 ] == NULL) { break; } } - if ( sat->sat_port == ATPORT_LAST ) { - return( EADDRNOTAVAIL ); + if (sat->sat_port == ATPORT_LAST) { + return (EADDRNOTAVAIL); } ddp->ddp_lsat.sat_port = sat->sat_port; ddp_ports[ sat->sat_port - 1 ] = ddp; } else { - for ( ddpp = ddp_ports[ sat->sat_port - 1 ]; ddpp; - ddpp = ddpp->ddp_pnext ) { - if ( ddpp->ddp_lsat.sat_addr.s_net == sat->sat_addr.s_net && - ddpp->ddp_lsat.sat_addr.s_node == sat->sat_addr.s_node ) { + for (ddpp = ddp_ports[ sat->sat_port - 1 ]; ddpp; + ddpp = ddpp->ddp_pnext) { + if (ddpp->ddp_lsat.sat_addr.s_net == sat->sat_addr.s_net && + ddpp->ddp_lsat.sat_addr.s_node == sat->sat_addr.s_node) { break; } } - if ( ddpp != NULL ) { - return( EADDRINUSE ); + if (ddpp != NULL) { + return (EADDRINUSE); } ddp->ddp_pnext = ddp_ports[ sat->sat_port - 1 ]; ddp_ports[ sat->sat_port - 1 ] = ddp; - if ( ddp->ddp_pnext ) { + if (ddp->ddp_pnext) { ddp->ddp_pnext->ddp_pprev = ddp; } } - return( 0 ); + return (0); } int @@ -135,7 +135,7 @@ at_pcbconnect(struct ddpcb *ddp, struct sockaddr *addr, struct thread *td) u_short hintnet = 0, net; if (sat->sat_family != AF_APPLETALK) { - return(EAFNOSUPPORT); + return (EAFNOSUPPORT); } /* @@ -143,10 +143,10 @@ at_pcbconnect(struct ddpcb *ddp, struct sockaddr *addr, struct thread *td) * network" to mean the network the control block is bound to. * If the control block is not bound, there is an error. */ - if ( sat->sat_addr.s_net == ATADDR_ANYNET - && sat->sat_addr.s_node != ATADDR_ANYNODE ) { - if ( ddp->ddp_lsat.sat_port == ATADDR_ANYPORT ) { - return( EADDRNOTAVAIL ); + if (sat->sat_addr.s_net == ATADDR_ANYNET + && sat->sat_addr.s_node != ATADDR_ANYNODE) { + if (ddp->ddp_lsat.sat_port == ATADDR_ANYPORT) { + return (EADDRNOTAVAIL); } hintnet = ddp->ddp_lsat.sat_addr.s_net; } @@ -157,27 +157,27 @@ at_pcbconnect(struct ddpcb *ddp, struct sockaddr *addr, struct thread *td) * If we've changed our address, we may have an old "good looking" * route here. Attempt to detect it. */ - if ( ro->ro_rt ) { - if ( hintnet ) { + if (ro->ro_rt) { + if (hintnet) { net = hintnet; } else { net = sat->sat_addr.s_net; } aa = NULL; if ((ifp = ro->ro_rt->rt_ifp) != NULL) { - for ( aa = at_ifaddr; aa; aa = aa->aa_next ) { - if ( aa->aa_ifp == ifp && - ntohs( net ) >= ntohs( aa->aa_firstnet ) && - ntohs( net ) <= ntohs( aa->aa_lastnet )) { + for (aa = at_ifaddr; aa; aa = aa->aa_next) { + if (aa->aa_ifp == ifp && + ntohs(net) >= ntohs(aa->aa_firstnet) && + ntohs(net) <= ntohs(aa->aa_lastnet)) { break; } } } - if ( aa == NULL || ( satosat( &ro->ro_dst )->sat_addr.s_net != - ( hintnet ? hintnet : sat->sat_addr.s_net ) || - satosat( &ro->ro_dst )->sat_addr.s_node != - sat->sat_addr.s_node )) { - RTFREE( ro->ro_rt ); + if (aa == NULL || (satosat(&ro->ro_dst)->sat_addr.s_net != + (hintnet ? hintnet : sat->sat_addr.s_net) || + satosat(&ro->ro_dst)->sat_addr.s_node != + sat->sat_addr.s_node)) { + RTFREE(ro->ro_rt); ro->ro_rt = NULL; } } @@ -185,42 +185,42 @@ at_pcbconnect(struct ddpcb *ddp, struct sockaddr *addr, struct thread *td) /* * If we've got no route for this interface, try to find one. */ - if ( ro->ro_rt == NULL || ro->ro_rt->rt_ifp == NULL ) { - ro->ro_dst.sa_len = sizeof( struct sockaddr_at ); + if (ro->ro_rt == NULL || ro->ro_rt->rt_ifp == NULL) { + ro->ro_dst.sa_len = sizeof(struct sockaddr_at); ro->ro_dst.sa_family = AF_APPLETALK; - if ( hintnet ) { - satosat( &ro->ro_dst )->sat_addr.s_net = hintnet; + if (hintnet) { + satosat(&ro->ro_dst)->sat_addr.s_net = hintnet; } else { - satosat( &ro->ro_dst )->sat_addr.s_net = sat->sat_addr.s_net; + satosat(&ro->ro_dst)->sat_addr.s_net = sat->sat_addr.s_net; } - satosat( &ro->ro_dst )->sat_addr.s_node = sat->sat_addr.s_node; - rtalloc( ro ); + satosat(&ro->ro_dst)->sat_addr.s_node = sat->sat_addr.s_node; + rtalloc(ro); } /* * Make sure any route that we have has a valid interface. */ aa = NULL; - if ( ro->ro_rt && ( ifp = ro->ro_rt->rt_ifp )) { - for ( aa = at_ifaddr; aa; aa = aa->aa_next ) { - if ( aa->aa_ifp == ifp ) { + if (ro->ro_rt && (ifp = ro->ro_rt->rt_ifp)) { + for (aa = at_ifaddr; aa; aa = aa->aa_next) { + if (aa->aa_ifp == ifp) { break; } } } - if ( aa == NULL ) { - return( ENETUNREACH ); + if (aa == NULL) { + return (ENETUNREACH); } ddp->ddp_fsat = *sat; - if ( ddp->ddp_lsat.sat_port == ATADDR_ANYPORT ) { - return(at_pcbsetaddr(ddp, NULL, td)); + if (ddp->ddp_lsat.sat_port == ATADDR_ANYPORT) { + return (at_pcbsetaddr(ddp, NULL, td)); } - return( 0 ); + return (0); } void -at_pcbdisconnect( struct ddpcb *ddp ) +at_pcbdisconnect(struct ddpcb *ddp) { ddp->ddp_fsat.sat_addr.s_net = ATADDR_ANYNET; ddp->ddp_fsat.sat_addr.s_node = ATADDR_ANYNODE; @@ -228,7 +228,7 @@ at_pcbdisconnect( struct ddpcb *ddp ) } int -at_pcballoc( struct socket *so ) +at_pcballoc(struct socket *so) { struct ddpcb *ddp; @@ -246,39 +246,39 @@ at_pcballoc( struct socket *so ) ddp->ddp_socket = so; so->so_pcb = (caddr_t)ddp; - return(0); + return (0); } void -at_pcbdetach( struct socket *so, struct ddpcb *ddp) +at_pcbdetach(struct socket *so, struct ddpcb *ddp) { - soisdisconnected( so ); + soisdisconnected(so); so->so_pcb = NULL; sotryfree(so); /* remove ddp from ddp_ports list */ - if ( ddp->ddp_lsat.sat_port != ATADDR_ANYPORT && - ddp_ports[ ddp->ddp_lsat.sat_port - 1 ] != NULL ) { - if ( ddp->ddp_pprev != NULL ) { + if (ddp->ddp_lsat.sat_port != ATADDR_ANYPORT && + ddp_ports[ ddp->ddp_lsat.sat_port - 1 ] != NULL) { + if (ddp->ddp_pprev != NULL) { ddp->ddp_pprev->ddp_pnext = ddp->ddp_pnext; } else { ddp_ports[ ddp->ddp_lsat.sat_port - 1 ] = ddp->ddp_pnext; } - if ( ddp->ddp_pnext != NULL ) { + if (ddp->ddp_pnext != NULL) { ddp->ddp_pnext->ddp_pprev = ddp->ddp_pprev; } } - if ( ddp->ddp_route.ro_rt ) { - RTFREE( ddp->ddp_route.ro_rt ); + if (ddp->ddp_route.ro_rt) { + RTFREE(ddp->ddp_route.ro_rt); } - if ( ddp->ddp_prev ) { + if (ddp->ddp_prev) { ddp->ddp_prev->ddp_next = ddp->ddp_next; } else { ddpcb = ddp->ddp_next; } - if ( ddp->ddp_next ) { + if (ddp->ddp_next) { ddp->ddp_next->ddp_prev = ddp->ddp_prev; } FREE(ddp, M_PCB); @@ -291,7 +291,7 @@ at_pcbdetach( struct socket *so, struct ddpcb *ddp) * sockets (pcbs). */ struct ddpcb * -ddp_search( struct sockaddr_at *from, struct sockaddr_at *to, +ddp_search(struct sockaddr_at *from, struct sockaddr_at *to, struct at_ifaddr *aa) { struct ddpcb *ddp; @@ -299,39 +299,39 @@ ddp_search( struct sockaddr_at *from, struct sockaddr_at *to, /* * Check for bad ports. */ - if ( to->sat_port < ATPORT_FIRST || to->sat_port >= ATPORT_LAST ) { - return( NULL ); + if (to->sat_port < ATPORT_FIRST || to->sat_port >= ATPORT_LAST) { + return (NULL); } /* * Make sure the local address matches the sent address. What about * the interface? */ - for ( ddp = ddp_ports[ to->sat_port - 1 ]; ddp; ddp = ddp->ddp_pnext ) { + for (ddp = ddp_ports[ to->sat_port - 1 ]; ddp; ddp = ddp->ddp_pnext) { /* XXX should we handle 0.YY? */ /* XXXX.YY to socket on destination interface */ - if ( to->sat_addr.s_net == ddp->ddp_lsat.sat_addr.s_net && - to->sat_addr.s_node == ddp->ddp_lsat.sat_addr.s_node ) { + if (to->sat_addr.s_net == ddp->ddp_lsat.sat_addr.s_net && + to->sat_addr.s_node == ddp->ddp_lsat.sat_addr.s_node) { break; } /* 0.255 to socket on receiving interface */ - if ( to->sat_addr.s_node == ATADDR_BCAST && ( to->sat_addr.s_net == 0 || - to->sat_addr.s_net == ddp->ddp_lsat.sat_addr.s_net ) && - ddp->ddp_lsat.sat_addr.s_net == AA_SAT( aa )->sat_addr.s_net ) { + if (to->sat_addr.s_node == ATADDR_BCAST && (to->sat_addr.s_net == 0 || + to->sat_addr.s_net == ddp->ddp_lsat.sat_addr.s_net) && + ddp->ddp_lsat.sat_addr.s_net == AA_SAT(aa)->sat_addr.s_net) { break; } /* XXXX.0 to socket on destination interface */ - if ( to->sat_addr.s_net == aa->aa_firstnet && + if (to->sat_addr.s_net == aa->aa_firstnet && to->sat_addr.s_node == 0 && - ntohs( ddp->ddp_lsat.sat_addr.s_net ) >= - ntohs( aa->aa_firstnet ) && - ntohs( ddp->ddp_lsat.sat_addr.s_net ) <= - ntohs( aa->aa_lastnet )) { + ntohs(ddp->ddp_lsat.sat_addr.s_net) >= + ntohs(aa->aa_firstnet) && + ntohs(ddp->ddp_lsat.sat_addr.s_net) <= + ntohs(aa->aa_lastnet)) { break; } } - return( ddp ); + return (ddp); } diff --git a/sys/netatalk/ddp_usrreq.c b/sys/netatalk/ddp_usrreq.c index c2a1a8a7bb8a..490d907bba9c 100644 --- a/sys/netatalk/ddp_usrreq.c +++ b/sys/netatalk/ddp_usrreq.c @@ -23,7 +23,7 @@ #include static u_long ddp_sendspace = DDP_MAXSZ; /* Max ddp size + 1 (ddp_type) */ -static u_long ddp_recvspace = 10 * ( 587 + sizeof( struct sockaddr_at )); +static u_long ddp_recvspace = 10 * (587 + sizeof(struct sockaddr_at)); static struct ifqueue atintrq1, atintrq2, aarpintrq; @@ -35,18 +35,18 @@ ddp_attach(struct socket *so, int proto, struct thread *td) int s; - ddp = sotoddpcb( so ); - if ( ddp != NULL ) { - return( EINVAL); + ddp = sotoddpcb(so); + if (ddp != NULL) { + return (EINVAL); } s = splnet(); - error = at_pcballoc( so ); + error = at_pcballoc(so); splx(s); if (error) { return (error); } - return (soreserve( so, ddp_sendspace, ddp_recvspace )); + return (soreserve(so, ddp_sendspace, ddp_recvspace)); } static int @@ -55,14 +55,14 @@ ddp_detach(struct socket *so) struct ddpcb *ddp; int s; - ddp = sotoddpcb( so ); - if ( ddp == NULL ) { - return( EINVAL); + ddp = sotoddpcb(so); + if (ddp == NULL) { + return (EINVAL); } s = splnet(); - at_pcbdetach( so, ddp ); + at_pcbdetach(so, ddp); splx(s); - return(0); + return (0); } static int @@ -72,9 +72,9 @@ ddp_bind(struct socket *so, struct sockaddr *nam, struct thread *td) int error = 0; int s; - ddp = sotoddpcb( so ); - if ( ddp == NULL ) { - return( EINVAL); + ddp = sotoddpcb(so); + if (ddp == NULL) { + return (EINVAL); } s = splnet(); error = at_pcbsetaddr(ddp, nam, td); @@ -89,21 +89,21 @@ ddp_connect(struct socket *so, struct sockaddr *nam, struct thread *td) int error = 0; int s; - ddp = sotoddpcb( so ); - if ( ddp == NULL ) { - return( EINVAL); + ddp = sotoddpcb(so); + if (ddp == NULL) { + return (EINVAL); } - if ( ddp->ddp_fsat.sat_port != ATADDR_ANYPORT ) { - return(EISCONN); + if (ddp->ddp_fsat.sat_port != ATADDR_ANYPORT) { + return (EISCONN); } s = splnet(); - error = at_pcbconnect( ddp, nam, td ); + error = at_pcbconnect(ddp, nam, td); splx(s); - if ( error == 0 ) - soisconnected( so ); - return(error); + if (error == 0) + soisconnected(so); + return (error); } static int @@ -113,20 +113,20 @@ ddp_disconnect(struct socket *so) struct ddpcb *ddp; int s; - ddp = sotoddpcb( so ); - if ( ddp == NULL ) { - return( EINVAL); + ddp = sotoddpcb(so); + if (ddp == NULL) { + return (EINVAL); } - if ( ddp->ddp_fsat.sat_addr.s_node == ATADDR_ANYNODE ) { - return(ENOTCONN); + if (ddp->ddp_fsat.sat_addr.s_node == ATADDR_ANYNODE) { + return (ENOTCONN); } s = splnet(); - at_pcbdisconnect( ddp ); + at_pcbdisconnect(ddp); ddp->ddp_fsat.sat_addr.s_node = ATADDR_ANYNODE; splx(s); - soisdisconnected( so ); - return(0); + soisdisconnected(so); + return (0); } static int @@ -134,12 +134,12 @@ ddp_shutdown(struct socket *so) { struct ddpcb *ddp; - ddp = sotoddpcb( so ); - if ( ddp == NULL ) { - return( EINVAL); + ddp = sotoddpcb(so); + if (ddp == NULL) { + return (EINVAL); } - socantsendmore( so ); - return(0); + socantsendmore(so); + return (0); } static int @@ -150,39 +150,39 @@ ddp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, int error = 0; int s; - ddp = sotoddpcb( so ); - if ( ddp == NULL ) { - return(EINVAL); + ddp = sotoddpcb(so); + if (ddp == NULL) { + return (EINVAL); } - if ( control && control->m_len ) { - return(EINVAL); + if (control && control->m_len) { + return (EINVAL); } - if ( addr ) { - if ( ddp->ddp_fsat.sat_port != ATADDR_ANYPORT ) { - return(EISCONN); + if (addr) { + if (ddp->ddp_fsat.sat_port != ATADDR_ANYPORT) { + return (EISCONN); } s = splnet(); error = at_pcbconnect(ddp, addr, td); - splx( s ); - if ( error ) { - return(error); + splx(s); + if (error) { + return (error); } } else { - if ( ddp->ddp_fsat.sat_port == ATADDR_ANYPORT ) { - return(ENOTCONN); + if (ddp->ddp_fsat.sat_port == ATADDR_ANYPORT) { + return (ENOTCONN); } } s = splnet(); - error = ddp_output( m, so ); - if ( addr ) { - at_pcbdisconnect( ddp ); + error = ddp_output(m, so); + if (addr) { + at_pcbdisconnect(ddp); } splx(s); - return(error); + return (error); } static int @@ -191,15 +191,15 @@ ddp_abort(struct socket *so) struct ddpcb *ddp; int s; - ddp = sotoddpcb( so ); - if ( ddp == NULL ) { - return(EINVAL); + ddp = sotoddpcb(so); + if (ddp == NULL) { + return (EINVAL); } - soisdisconnected( so ); + soisdisconnected(so); s = splnet(); - at_pcbdetach( so, ddp ); + at_pcbdetach(so, ddp); splx(s); - return(0); + return (0); } void @@ -219,12 +219,12 @@ ddp_init(void) #if 0 static void -ddp_clean(void ) +ddp_clean(void) { struct ddpcb *ddp; - for ( ddp = ddpcb; ddp; ddp = ddp->ddp_next ) { - at_pcbdetach( ddp->ddp_socket, ddp ); + for (ddp = ddpcb; ddp; ddp = ddp->ddp_next) { + at_pcbdetach(ddp->ddp_socket, ddp); } } #endif @@ -232,7 +232,7 @@ ddp_clean(void ) static int at_setpeeraddr(struct socket *so, struct sockaddr **nam) { - return(EOPNOTSUPP); + return (EOPNOTSUPP); } static int @@ -240,12 +240,12 @@ at_setsockaddr(struct socket *so, struct sockaddr **nam) { struct ddpcb *ddp; - ddp = sotoddpcb( so ); - if ( ddp == NULL ) { - return( EINVAL); + ddp = sotoddpcb(so); + if (ddp == NULL) { + return (EINVAL); } - at_sockaddr( ddp, nam ); - return(0); + at_sockaddr(ddp, nam); + return (0); } struct pr_usrreqs ddp_usrreqs = {