netrestrict-netinfo-20081129
[openafs.git] / src / rx / rx_user.c
index c5a370c..efd5f22 100644 (file)
@@ -48,6 +48,7 @@ RCSID
 #ifndef AFS_NT40_ENV
 # include <sys/time.h>
 #endif
+# include "rx_internal.h"
 # include "rx.h"
 # include "rx_globals.h"
 
@@ -219,11 +220,13 @@ rxi_GetUDPSocket(u_short port)
 }
 
 void
-osi_Panic(msg, a1, a2, a3) 
-     char *msg; 
+osi_Panic(char *msg, ...)
 {
+    va_list ap;
+    va_start(ap, msg);
     (osi_Msg "Fatal Rx error: ");
-    (osi_Msg msg, a1, a2, a3);
+    (osi_VMsg msg, ap);
+    va_end(ap);
     fflush(stderr);
     fflush(stdout);
     afs_abort();
@@ -298,21 +301,21 @@ rxi_getaddr(void)
 ** maxSize - max number of interfaces to return.
 */
 int
-rx_getAllAddr(afs_int32 * buffer, int maxSize)
+rx_getAllAddr(afs_uint32 * buffer, int maxSize)
 {
     int count = 0, offset = 0;
 
     /* The IP address list can change so we must query for it */
     rx_GetIFInfo();
 
-#ifndef AFS_NT40_ENV
+#ifdef AFS_DJGPP_ENV
     /* we don't want to use the loopback adapter which is first */
     /* this is a bad bad hack.
      * and doesn't hold true on Windows.
      */
     if ( rxi_numNetAddrs > 1 )
         offset = 1;
-#endif /* AFS_NT40_ENV */
+#endif /* AFS_DJGPP_ENV */
 
     for (count = 0; offset < rxi_numNetAddrs && maxSize > 0;
         count++, offset++, maxSize--)
@@ -320,6 +323,39 @@ rx_getAllAddr(afs_int32 * buffer, int maxSize)
 
     return count;
 }
+
+/* this function returns the total number of interface addresses
+ * the buffer has to be passed in by the caller. It also returns
+ * the matching interface mask and mtu.  All values are returned
+ * in network byte order.
+ */
+int
+rx_getAllAddrMaskMtu(afs_uint32 addrBuffer[], afs_uint32 maskBuffer[],
+                     afs_uint32 mtuBuffer[], int maxSize)
+{
+    int count = 0, offset = 0;
+
+    /* The IP address list can change so we must query for it */
+    rx_GetIFInfo();
+
+#ifdef AFS_DJGPP_ENV
+    /* we don't want to use the loopback adapter which is first */
+    /* this is a bad bad hack.
+     * and doesn't hold true on Windows.
+     */
+    if ( rxi_numNetAddrs > 1 )
+        offset = 1;
+#endif /* AFS_DJGPP_ENV */
+
+    for (count = 0; 
+         offset < rxi_numNetAddrs && maxSize > 0;
+         count++, offset++, maxSize--) {
+       addrBuffer[count] = htonl(rxi_NetAddrs[offset]);
+       maskBuffer[count] = htonl(myNetMasks[offset]);
+       mtuBuffer[count]  = htonl(myNetMTUs[offset]);
+    }
+    return count;
+}
 #endif
 
 #ifdef AFS_NT40_ENV