RCSID
("$Header$");
-#ifndef AFS_DJGPP_ENV
#ifndef KERNEL
#ifndef AFS_NT40_ENV
#include <sys/types.h>
#include <net/if.h>
#include <netinet/in.h>
#include <sys/ioctl.h>
+#include <string.h>
#if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
#include <sys/sysctl.h>
#include <net/route.h>
* By including this, we get any system dependencies. In particular,
* the pthreads for solaris requires the socket call to be mapped.
*/
+#include "rx_internal.h"
#include "rx.h"
#include "rx_globals.h"
#endif /* AFS_NT40_ENV */
#ifdef UKERNEL
#include "rx/rx_kcommon.h"
#else /* UKERNEL */
+#include "rx/rx_internal.h"
#include "rx/rx.h"
#endif /* UKERNEL */
#endif /* KERNEL */
#ifdef KERNEL
/* only used for generating random noise */
-afs_int32 rxi_tempAddr = 0; /* default attempt */
+afs_uint32 rxi_tempAddr = 0; /* default attempt */
/* set the advisory noise */
void
-rxi_setaddr(afs_int32 x)
+rxi_setaddr(afs_uint32 x)
{
rxi_tempAddr = x;
}
/* get approx to net addr */
-afs_int32
+afs_uint32
rxi_getaddr(void)
{
return rxi_tempAddr;
/* to satisfy those who call setaddr */
void
-rxi_setaddr(afs_int32 x)
+rxi_setaddr(afs_uint32 x)
{
}
/* Return our internet address as a long in network byte order. Returns zero
* if it can't find one.
*/
-afs_int32
+afs_uint32
rxi_getaddr(void)
{
- afs_int32 buffer[1024];
+ afs_uint32 buffer[1024];
int count;
count = rx_getAllAddr(buffer, 1024);
*/
#if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
int
-rx_getAllAddr_internal(afs_int32 buffer[], int maxSize, int loopbacks)
+rx_getAllAddr_internal(afs_uint32 buffer[], int maxSize, int loopbacks)
{
size_t needed;
int mib[6];
/* Expand the compacted addresses */
rt_xaddrs((char *)(ifam + 1), ifam->ifam_msglen + (char *)ifam,
&info);
- if (info.rti_info[RTAX_IFA]->sa_family != AF_INET)
+ if (info.rti_info[RTAX_IFA]->sa_family != AF_INET) {
+ addrcount--;
continue;
+ }
a = (struct sockaddr_in *) info.rti_info[RTAX_IFA];
if (count >= maxSize) /* no more space */
dpf(("Too many interfaces..ignoring 0x%x\n",
a->sin_addr.s_addr));
- else if (!loopbacks && a->sin_addr.s_addr == htonl(0x7f000001))
+ else if (!loopbacks && a->sin_addr.s_addr == htonl(0x7f000001)) {
+ addrcount--;
continue; /* skip loopback address as well. */
- else if (loopbacks && ifm->ifm_flags & IFF_LOOPBACK)
+ } else if (loopbacks && ifm->ifm_flags & IFF_LOOPBACK) {
+ addrcount--;
continue; /* skip aliased loopbacks as well. */
- else
+ } else
buffer[count++] = a->sin_addr.s_addr;
addrcount--;
ifam = (struct ifa_msghdr *)((char *)ifam + ifam->ifam_msglen);
}
int
-rxi_getAllAddrMaskMtu(afs_int32 addrBuffer[], afs_int32 maskBuffer[],
- afs_int32 mtuBuffer[], int maxSize)
+rx_getAllAddrMaskMtu(afs_uint32 addrBuffer[], afs_uint32 maskBuffer[],
+ afs_uint32 mtuBuffer[], int maxSize)
{
int s;
char *buf, *lim, *next;
int count = 0, addrcount = 0;
-#if !defined(AFS_USERSPACE_IP_ADDR)
- count = rx_getAllAddr_internal(addrBuffer, 1024, 0);
- for (i = 0; i < count; i++) {
- maskBuffer[i] = htonl(0xffffffff);
- mtuBuffer[i] = htonl(1500);
- }
- return count;
-#else /* AFS_USERSPACE_IP_ADDR */
mib[0] = CTL_NET;
mib[1] = PF_ROUTE;
mib[2] = 0;
/* Expand the compacted addresses */
rt_xaddrs((char *)(ifam + 1), ifam->ifam_msglen + (char *)ifam,
&info);
- if (info.rti_info[RTAX_IFA]->sa_family != AF_INET)
+ if (info.rti_info[RTAX_IFA]->sa_family != AF_INET) {
+ addrcount--;
continue;
+ }
a = (struct sockaddr_in *) info.rti_info[RTAX_IFA];
if (a->sin_addr.s_addr != htonl(0x7f000001) ) {
maskBuffer[count] = a->sin_addr.s_addr;
else
maskBuffer[count] = htonl(0xffffffff);
- memset(&ifr, sizeof(ifr), 0);
+ memset(&ifr, 0, sizeof(ifr));
ifr.ifr_addr.sa_family = AF_INET;
strncpy(ifr.ifr_name, sdl->sdl_data, sdl->sdl_nlen);
if (ioctl(s, SIOCGIFMTU, (caddr_t) & ifr) < 0)
}
free(buf);
return count;
-#endif
}
int
-rx_getAllAddr(afs_int32 buffer[], int maxSize)
+rx_getAllAddr(afs_uint32 buffer[], int maxSize)
{
return rx_getAllAddr_internal(buffer, maxSize, 0);
}
*/
#else
static int
-rx_getAllAddr_internal(afs_int32 buffer[], int maxSize, int loopbacks)
+rx_getAllAddr_internal(afs_uint32 buffer[], int maxSize, int loopbacks)
{
int s;
int i, len, count = 0;
}
int
-rx_getAllAddr(afs_int32 buffer[], int maxSize)
+rx_getAllAddr(afs_uint32 buffer[], int maxSize)
{
return rx_getAllAddr_internal(buffer, maxSize, 0);
}
* by afsi_SetServerIPRank().
*/
int
-rxi_getAllAddrMaskMtu(afs_int32 addrBuffer[], afs_int32 maskBuffer[],
- afs_int32 mtuBuffer[], int maxSize)
+rx_getAllAddrMaskMtu(afs_uint32 addrBuffer[], afs_uint32 maskBuffer[],
+ afs_uint32 mtuBuffer[], int maxSize)
{
int s;
int i, len, count = 0;
#endif /* ! AFS_NT40_ENV */
#endif /* !KERNEL || UKERNEL */
-
-#endif /* !AFS_DJGPP_ENV */