/* * Given two arrays of addresses, masks and mtus find the common ones * and return them in the first buffer. Return number of common * entries. */ static int filterAddrs(afs_uint32 addr1[], afs_uint32 addr2[], afs_uint32 mask1[], afs_uint32 mask2[], afs_uint32 mtu1[], afs_uint32 mtu2[], int n1, int n2) { afs_uint32 taddr[MAXIPADDRS]; afs_uint32 tmask[MAXIPADDRS]; afs_uint32 tmtu[MAXIPADDRS]; int count = 0, i = 0, j = 0, found = 0; opr_Assert(addr1); opr_Assert(addr2); opr_Assert(mask1); opr_Assert(mask2); opr_Assert(mtu1); opr_Assert(mtu2); for (i = 0; i < n1; i++) { found = 0; for (j = 0; j < n2; j++) { if (addr1[i] == addr2[j]) { found = 1; break; } } /* Always mask loopback address */ if (found && rx_IsLoopbackAddr(addr1[i])) found = 0; if (found) { taddr[count] = addr1[i]; tmask[count] = mask1[i]; tmtu[count] = mtu1[i]; count++; } } /* copy everything into addr1, mask1 and mtu1 */ for (i = 0; i < count; i++) { addr1[i] = taddr[i]; if (mask1) { mask1[i] = tmask[i]; mtu1[i] = tmtu[i]; } } /* and zero out the rest */ for (i = count; i < n1; i++) { addr1[i] = 0; if (mask1) { mask1[i] = 0; mtu1[i] = 0; } } return count; }
int rxi_GetIFInfo() { int i = 0; int different = 0; #ifndef AFS_SUN510_ENV ill_t *ill; ipif_t *ipif; #endif int rxmtu, maxmtu; int mtus[ADDRSPERSITE]; afs_uint32 addrs[ADDRSPERSITE]; afs_uint32 ifinaddr; memset(mtus, 0, sizeof(mtus)); memset(addrs, 0, sizeof(addrs)); #ifdef AFS_SUN510_ENV (void) rw_enter(&afsifinfo_lock, RW_READER); for (i = 0; (afsifinfo[i].ipaddr != NULL) && (i < ADDRSPERSITE); i++) { /* Ignore addresses which are down.. */ if (!(afsifinfo[i].flags & IFF_UP)) continue; /* Compute the Rx interface MTU */ rxmtu = (afsifinfo[i].mtu - RX_IPUDP_SIZE); ifinaddr = afsifinfo[i].ipaddr; if (myNetAddrs[i] != ifinaddr) different++; /* Copy interface MTU and address; adjust maxmtu */ mtus[i] = rxmtu; rxmtu = rxi_AdjustIfMTU(rxmtu); maxmtu = rxmtu * rxi_nRecvFrags + ((rxi_nRecvFrags - 1) * UDP_HDR_SIZE); maxmtu = rxi_AdjustMaxMTU(rxmtu, maxmtu); addrs[i] = ifinaddr; if (!rx_IsLoopbackAddr(ifinaddr) && maxmtu > rx_maxReceiveSize) { rx_maxReceiveSize = MIN(RX_MAX_PACKET_SIZE, maxmtu); rx_maxReceiveSize = MIN(rx_maxReceiveSize, rx_maxReceiveSizeUser); } } (void) rw_exit(&afsifinfo_lock); rx_maxJumboRecvSize = RX_HEADER_SIZE + rxi_nDgramPackets * RX_JUMBOBUFFERSIZE + (rxi_nDgramPackets - 1) * RX_JUMBOHEADERSIZE; rx_maxJumboRecvSize = MAX(rx_maxJumboRecvSize, rx_maxReceiveSize); if (different) { int j; for (j = 0; j < i; j++) { myNetMTUs[j] = mtus[j]; myNetAddrs[j] = addrs[j]; } } return different; }