X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/8f6c56a50524aa785f7e596d52dddfb331e18961..89b3af67bb32e691275bf6fa803d1834b2284115:/bsd/netat/ddp_aarp.c diff --git a/bsd/netat/ddp_aarp.c b/bsd/netat/ddp_aarp.c index d808f1892..9e6975b89 100644 --- a/bsd/netat/ddp_aarp.c +++ b/bsd/netat/ddp_aarp.c @@ -99,7 +99,6 @@ StaticProc void aarp_sched_req(void *); StaticProc int aarp_get_rand_node(); StaticProc int aarp_get_next_node(); StaticProc int aarp_get_rand_net(); -atlock_t arpinp_lock; extern void AARPwakeup(aarp_amt_t *); extern int pat_output(at_ifaddr_t *, gbuf_t *, unsigned char *, int); @@ -187,7 +186,7 @@ int aarp_rcv_pkt(pkt, elapp) aarp_pkt_t *pkt; at_ifaddr_t *elapp; { - switch (pkt->aarp_cmd) { + switch (ntohs(pkt->aarp_cmd)) { case AARP_REQ_CMD: return (aarp_req_cmd_in (pkt, elapp)); case AARP_RESP_CMD: @@ -287,7 +286,7 @@ StaticProc int aarp_resp_cmd_in (pkt, elapp) break; case PROBE_DONE : - AMT_LOOK(amt_ptr, pkt->src_at_addr, elapp); + AMT_LOOK(amt_ptr, pkt->src_at_addr, elapp) if (amt_ptr == NULL) return(-1); if (amt_ptr->tmo) { @@ -428,18 +427,18 @@ int aarp_chk_addr(ddp_hdrp, elapp) * will ALWAYS be removed. If the message is dropped, * it's not an "error". * + * Parameter dest_at_addr must have the net # in network byte order ****************************************************************************/ int aarp_send_data(m, elapp, dest_at_addr, loop) register gbuf_t *m; register at_ifaddr_t *elapp; - struct atalk_addr *dest_at_addr; + struct atalk_addr *dest_at_addr; /* net# in network byte order */ int loop; /* if true, loopback broadcasts */ { register aarp_amt_t *amt_ptr; register at_ddp_t *ddp_hdrp; int error; - int s; struct timeval timenow; getmicrouptime(&timenow); @@ -457,22 +456,19 @@ int aarp_send_data(m, elapp, dest_at_addr, loop) ddp_input(m, elapp); return(0); } - ATDISABLE(s, arpinp_lock); AMT_LOOK(amt_ptr, *dest_at_addr, elapp); if (amt_ptr) { - if (amt_ptr->m) { + if (amt_ptr->m) { /* * there's already a packet awaiting transmission, so * drop this one and let the upper layer retransmit * later. */ - ATENABLE(s, arpinp_lock); gbuf_freel(m); return (0); } - ATENABLE(s, arpinp_lock); return (pat_output(elapp, m, (unsigned char *)&amt_ptr->dest_addr, 0)); } @@ -484,7 +480,6 @@ int aarp_send_data(m, elapp, dest_at_addr, loop) gbuf_t *newm = 0; struct etalk_addr *dest_addr; - ATENABLE(s, arpinp_lock); dest_addr = &elapp->cable_multicast_addr; if (loop) newm = (gbuf_t *)gbuf_dupm(m); @@ -507,7 +502,7 @@ int aarp_send_data(m, elapp, dest_at_addr, loop) } return (error); } - NEW_AMT(amt_ptr, *dest_at_addr,elapp); + NEW_AMT(amt_ptr, *dest_at_addr, elapp) if (amt_ptr->m) { /* @@ -515,7 +510,6 @@ int aarp_send_data(m, elapp, dest_at_addr, loop) * drop this one and let the upper layer retransmit * later. */ - ATENABLE(s, arpinp_lock); gbuf_freel(m); return (0); } @@ -527,7 +521,6 @@ int aarp_send_data(m, elapp, dest_at_addr, loop) amt_ptr->m = m; amt_ptr->elapp = elapp; amt_ptr->no_of_retries = 0; - ATENABLE(s, arpinp_lock); if ((error = aarp_send_req(amt_ptr))) { aarp_delete_amt_info(amt_ptr); @@ -563,7 +556,7 @@ StaticProc int aarp_send_resp(elapp, pkt) new_pkt = (aarp_pkt_t *)gbuf_rptr(m); aarp_build_pkt(new_pkt, elapp); - new_pkt->aarp_cmd = AARP_RESP_CMD; + new_pkt->aarp_cmd = htons(AARP_RESP_CMD); new_pkt->dest_addr = pkt->src_addr; new_pkt->dest_at_addr = pkt->src_at_addr; @@ -605,7 +598,7 @@ register aarp_amt_t *amt_ptr; pkt = (aarp_pkt_t *)gbuf_rptr(m); aarp_build_pkt(pkt, amt_ptr->elapp); - pkt->aarp_cmd = AARP_REQ_CMD; + pkt->aarp_cmd = htons(AARP_REQ_CMD); pkt->dest_addr = et_zeroaddr; pkt->dest_at_addr = amt_ptr->dest_at_addr; pkt->dest_at_addr.atalk_unused = 0; @@ -648,7 +641,7 @@ StaticProc int aarp_send_probe() pkt = (aarp_pkt_t *)gbuf_rptr(m); aarp_build_pkt(pkt, probe_cb.elapp); - pkt->aarp_cmd = AARP_PROBE_CMD; + pkt->aarp_cmd = htons(AARP_PROBE_CMD); pkt->dest_addr = et_zeroaddr; ATALK_ASSIGN(pkt->src_at_addr, probe_cb.elapp->initial_addr.s_net, @@ -706,9 +699,7 @@ register aarp_pkt_t *pkt; at_ifaddr_t *elapp; { register aarp_amt_t *amt_ptr; - int s; - ATDISABLE(s, arpinp_lock); AMT_LOOK(amt_ptr, pkt->src_at_addr, elapp); if (amt_ptr == NULL) { @@ -718,10 +709,7 @@ at_ifaddr_t *elapp; NEW_AMT(amt_ptr, pkt->src_at_addr,elapp); if (amt_ptr->m) - { - ATENABLE(s, arpinp_lock); - return(0); /* no non-busy slots available in the cache */ - } + return(0); /* no non-busy slots available in the cache */ amt_ptr->dest_at_addr = pkt->src_at_addr; amt_ptr->dest_at_addr.atalk_unused = 0; @@ -734,7 +722,6 @@ at_ifaddr_t *elapp; amt_ptr->dest_addr = pkt->src_addr; if (FDDI_OR_TOKENRING(elapp->aa_ifp->if_type)) ddp_bit_reverse(&amt_ptr->dest_addr); - ATENABLE(s, arpinp_lock); return(1); } @@ -747,9 +734,7 @@ at_ifaddr_t *elapp; StaticProc int aarp_delete_amt_info(amt_ptr) register aarp_amt_t *amt_ptr; { - register s; register gbuf_t *m; - ATDISABLE(s, arpinp_lock); amt_ptr->last_time = 0; ATALK_ASSIGN(amt_ptr->dest_at_addr, 0, 0, 0); amt_ptr->no_of_retries = 0; @@ -757,11 +742,8 @@ register aarp_amt_t *amt_ptr; if (amt_ptr->m) { m = amt_ptr->m; amt_ptr->m = NULL; - ATENABLE(s, arpinp_lock); gbuf_freel(m); - } - else - ATENABLE(s, arpinp_lock); + } return(0); } @@ -800,8 +782,8 @@ StaticProc void aarp_build_pkt(pkt, elapp) register aarp_pkt_t *pkt; at_ifaddr_t *elapp; { - pkt->hardware_type = AARP_ETHER_HW_TYPE; - pkt->stack_type = AARP_AT_PROTO; + pkt->hardware_type = htons(AARP_ETHER_HW_TYPE); + pkt->stack_type = htons(AARP_AT_PROTO); pkt->hw_addr_len = ETHERNET_ADDR_LEN; pkt->stack_addr_len = AARP_AT_ADDR_LEN; bcopy(elapp->xaddr, pkt->src_addr.etalk_addr_octet, sizeof(elapp->xaddr)); @@ -817,7 +799,7 @@ StaticProc void aarp_build_pkt(pkt, elapp) StaticProc void aarp_sched_req(arg) void *arg; { - int s, i; + int i; aarp_amt_t *amt_ptr = (aarp_amt_t *)arg; atalk_lock(); @@ -835,21 +817,16 @@ StaticProc void aarp_sched_req(arg) /* * found match - pointer is valid */ - ATDISABLE(s, arpinp_lock); if (amt_ptr->tmo == 0) { - ATENABLE(s, arpinp_lock); atalk_unlock(); return; } if (amt_ptr->no_of_retries < AARP_MAX_REQ_RETRIES) { - ATENABLE(s, arpinp_lock); if (aarp_send_req(amt_ptr) == 0) { atalk_unlock(); return; } - ATDISABLE(s, arpinp_lock); } - ATENABLE(s, arpinp_lock); aarp_delete_amt_info(amt_ptr); break; } @@ -983,6 +960,8 @@ snmpAarpEnt_t *getAarp(elapId) aarp_amt_t *amtp; static snmpAarpEnt_t snmp[AMTSIZE]; snmpAarpEnt_t *snmpp; + struct atalk_addr addr; + u_short tmp_net; if (*elapId <0 || *elapId >= IF_TOTAL_MAX) @@ -999,7 +978,11 @@ snmpAarpEnt_t *getAarp(elapId) * & etalk_addr positions in the aarp_amt_t struct * has not changed and copy both at once */ - bcopy(&amtp->dest_at_addr, &snmpp->ap_ddpAddr, ENTRY_SIZE); + addr.atalk_unused = 0; + tmp_net = UAS_VALUE(amtp->dest_at_addr.atalk_net); + NET_ASSIGN(addr.atalk_net, tmp_net); + addr.atalk_node = amtp->dest_at_addr.atalk_node; + bcopy(&addr, &snmpp->ap_ddpAddr, ENTRY_SIZE); snmpp++; cnt++;