[Olsr-cvs] olsrd-current/src/win32 ifnet.c, 1.32, 1.33 kernel_routes.c, 1.15, 1.16

Thomas Lopatic (spam-protected)
Mon Mar 26 17:33:47 CEST 2007


Update of /cvsroot/olsrd/olsrd-current/src/win32
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv14916

Modified Files:
	ifnet.c kernel_routes.c 
Log Message:
Vista fixes.

Index: ifnet.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/win32/ifnet.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** ifnet.c	11 Oct 2006 20:58:45 -0000	1.32
--- ifnet.c	26 Mar 2007 15:33:44 -0000	1.33
***************
*** 55,62 ****
--- 55,109 ----
  #include <iprtrmib.h>
  
+ struct MibIpInterfaceRow
+ {
+   USHORT Family;
+   ULONG64 InterfaceLuid;
+   ULONG InterfaceIndex;
+   ULONG MaxReassemblySize;
+   ULONG64 InterfaceIdentifier;
+   ULONG MinRouterAdvertisementInterval;
+   ULONG MaxRouterAdvertisementInterval;
+   BOOLEAN AdvertisingEnabled;
+   BOOLEAN ForwardingEnabled;
+   BOOLEAN WeakHostSend;
+   BOOLEAN WeakHostReceive;
+   BOOLEAN UseAutomaticMetric;
+   BOOLEAN UseNeighborUnreachabilityDetection;   
+   BOOLEAN ManagedAddressConfigurationSupported;
+   BOOLEAN OtherStatefulConfigurationSupported;
+   BOOLEAN AdvertiseDefaultRoute;
+   INT RouterDiscoveryBehavior;
+   ULONG DadTransmits;
+   ULONG BaseReachableTime;
+   ULONG RetransmitTime;
+   ULONG PathMtuDiscoveryTimeout;
+   INT LinkLocalAddressBehavior;
+   ULONG LinkLocalAddressTimeout;
+   ULONG ZoneIndices[16];
+   ULONG SitePrefixLength;
+   ULONG Metric;
+   ULONG NlMtu;    
+   BOOLEAN Connected;
+   BOOLEAN SupportsWakeUpPatterns;   
+   BOOLEAN SupportsNeighborDiscovery;
+   BOOLEAN SupportsRouterDiscovery;
+   ULONG ReachableTime;
+   BYTE TransmitOffload;
+   BYTE ReceiveOffload; 
+   BOOLEAN DisableDefaultRoutes;
+ };
+ 
+ typedef DWORD (__stdcall *GETIPINTERFACEENTRY)
+   (struct MibIpInterfaceRow *Row);
+ 
+ typedef DWORD (__stdcall *GETADAPTERSADDRESSES)
+   (ULONG Family, DWORD Flags, PVOID Reserved,
+    PIP_ADAPTER_ADDRESSES pAdapterAddresses, PULONG pOutBufLen);
+ 
  struct InterfaceInfo
  {
    unsigned int Index;
    int Mtu;
+   int Metric;
    unsigned int Addr;
    unsigned int Mask;
***************
*** 135,143 ****
  static int FriendlyNameToMiniIndex(int *MiniIndex, char *String)
  {
-   typedef DWORD (*GETADAPTERSADDRESSES)(ULONG Family,
-                                         DWORD Flags,
-                                         PVOID Reserved,
-                                         PIP_ADAPTER_ADDRESSES pAdapterAddresses,
-                                         PULONG pOutBufLen);
    unsigned long BuffLen;
    unsigned long Res;
--- 182,185 ----
***************
*** 203,206 ****
--- 245,250 ----
    int TabIdx;
    IP_ADAPTER_INFO AdInfo[MAX_INTERFACES], *Walker;
+   HMODULE Lib;
+   struct MibIpInterfaceRow Row;
  
    if (olsr_cnf->ip_version == AF_INET6)
***************
*** 261,264 ****
--- 305,349 ----
      UDP_IPV6_HDRSIZE : UDP_IPV4_HDRSIZE;
  
+   Lib = LoadLibrary("iphlpapi.dll");
+ 
+   if (Lib == NULL)
+   {
+     fprintf(stderr, "Cannot load iphlpapi.dll: %08lx\n", GetLastError());
+     return -1;
+   }
+ 
+   GETIPINTERFACEENTRY InterfaceEntry =
+     (GETIPINTERFACEENTRY)GetProcAddress(Lib, "GetIpInterfaceEntry");
+ 
+   if (InterfaceEntry == NULL)
+   {
+     OLSR_PRINTF(5, "Not running on Vista - setting interface metric to 0.\n");
+ 
+     Info->Metric = 0;
+   }
+ 
+   else
+   {
+     memset(&Row, 0, sizeof (struct MibIpInterfaceRow));
+ 
+     Row.Family = AF_INET;
+     Row.InterfaceIndex = Info->Index;
+ 
+     Res = InterfaceEntry(&Row);
+ 
+     if (Res != NO_ERROR)
+     {
+       fprintf(stderr, "GetIpInterfaceEntry() = %08lx", Res);
+       FreeLibrary(Lib);
+       return -1;
+     }
+ 
+     Info->Metric = Row.Metric;
+ 
+     OLSR_PRINTF(5, "Running on Vista - interface metric is %d.\n", Info->Metric);
+   }
+ 
+   FreeLibrary(Lib);
+ 
    BuffLen = sizeof (AdInfo);
  
***************
*** 358,362 ****
      CloseHandle(DevHand);
  
!     if (ErrNo == ERROR_GEN_FAILURE)
      {
        OLSR_PRINTF(5, "OID not supported. Device probably not wireless.\n")
--- 443,447 ----
      CloseHandle(DevHand);
  
!     if (ErrNo == ERROR_GEN_FAILURE || ErrNo == ERROR_INVALID_PARAMETER)
      {
        OLSR_PRINTF(5, "OID not supported. Device probably not wireless.\n")
***************
*** 740,744 ****
  
      else
!       Int->int_metric = IsWlan;
  
      Res = 1;
--- 825,829 ----
  
      else
!       Int->int_metric = Info.Metric;
  
      Res = 1;
***************
*** 912,916 ****
  
    else
!     New->int_metric = IsWlan;
  
    New->olsr_seqnum = random() & 0xffff;
--- 997,1001 ----
  
    else
!     New->int_metric = Info.Metric;
  
    New->olsr_seqnum = random() & 0xffff;

Index: kernel_routes.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/win32/kernel_routes.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** kernel_routes.c	27 Feb 2005 10:48:05 -0000	1.15
--- kernel_routes.c	26 Mar 2007 15:33:44 -0000	1.16
***************
*** 64,68 ****
  
    OLSR_PRINTF(1, "Adding IPv4 route with metric %d to %s/%s via %s and I/F 0x%x.\n",
!               Dest->rt_metric, Str1, Str2, Str3, Dest->rt_if->if_index)
  
    memset(&Row, 0, sizeof (MIB_IPFORWARDROW));
--- 64,68 ----
  
    OLSR_PRINTF(1, "Adding IPv4 route with metric %d to %s/%s via %s and I/F 0x%x.\n",
!               Dest->rt_metric + Dest->rt_if->int_metric, Str1, Str2, Str3, Dest->rt_if->if_index)
  
    memset(&Row, 0, sizeof (MIB_IPFORWARDROW));
***************
*** 70,78 ****
    Row.dwForwardDest = Dest->rt_dst.v4;
    Row.dwForwardMask = Dest->rt_mask.v4;
    Row.dwForwardNextHop = Dest->rt_router.v4;
    Row.dwForwardIfIndex = Dest->rt_if->if_index;
    Row.dwForwardType = (Dest->rt_dst.v4 == Dest->rt_router.v4) ? 3 : 4;
!   Row.dwForwardProto = 3; // PROTO_IP_NETMGMT
!   Row.dwForwardMetric1 = Dest->rt_metric;
  
    Res = SetIpForwardEntry(&Row);
--- 70,86 ----
    Row.dwForwardDest = Dest->rt_dst.v4;
    Row.dwForwardMask = Dest->rt_mask.v4;
+   Row.dwForwardPolicy = 0;
    Row.dwForwardNextHop = Dest->rt_router.v4;
    Row.dwForwardIfIndex = Dest->rt_if->if_index;
+   // MIB_IPROUTE_TYPE_DIRECT and MIB_IPROUTE_TYPE_INDIRECT
    Row.dwForwardType = (Dest->rt_dst.v4 == Dest->rt_router.v4) ? 3 : 4;
!   Row.dwForwardProto = 3; // MIB_IPPROTO_NETMGMT
!   Row.dwForwardAge = INFINITE;
!   Row.dwForwardNextHopAS = 0;
!   Row.dwForwardMetric1 = Dest->rt_metric + Dest->rt_if->int_metric;
!   Row.dwForwardMetric2 = -1;
!   Row.dwForwardMetric3 = -1;
!   Row.dwForwardMetric4 = -1;
!   Row.dwForwardMetric5 = -1;
  
    Res = SetIpForwardEntry(&Row);
***************
*** 120,124 ****
  
    OLSR_PRINTF(1, "Deleting IPv4 route with metric %d to %s/%s via %s and I/F 0x%x.\n",
!               Dest->rt_metric, Str1, Str2, Str3, Dest->rt_if->if_index)
  
    memset(&Row, 0, sizeof (MIB_IPFORWARDROW));
--- 128,132 ----
  
    OLSR_PRINTF(1, "Deleting IPv4 route with metric %d to %s/%s via %s and I/F 0x%x.\n",
!               Dest->rt_metric + Dest->rt_if->int_metric, Str1, Str2, Str3, Dest->rt_if->if_index)
  
    memset(&Row, 0, sizeof (MIB_IPFORWARDROW));
***************
*** 126,134 ****
    Row.dwForwardDest = Dest->rt_dst.v4;
    Row.dwForwardMask = Dest->rt_mask.v4;
    Row.dwForwardNextHop = Dest->rt_router.v4;
    Row.dwForwardIfIndex = Dest->rt_if->if_index;
    Row.dwForwardType = (Dest->rt_dst.v4 == Dest->rt_router.v4) ? 3 : 4;
!   Row.dwForwardProto = 3; // PROTO_IP_NETMGMT
!   Row.dwForwardMetric1 = Dest->rt_metric;
  
    Res = DeleteIpForwardEntry(&Row);
--- 134,150 ----
    Row.dwForwardDest = Dest->rt_dst.v4;
    Row.dwForwardMask = Dest->rt_mask.v4;
+   Row.dwForwardPolicy = 0;
    Row.dwForwardNextHop = Dest->rt_router.v4;
    Row.dwForwardIfIndex = Dest->rt_if->if_index;
+   // MIB_IPROUTE_TYPE_DIRECT and MIB_IPROUTE_TYPE_INDIRECT
    Row.dwForwardType = (Dest->rt_dst.v4 == Dest->rt_router.v4) ? 3 : 4;
!   Row.dwForwardProto = 3; // MIB_IPPROTO_NETMGMT
!   Row.dwForwardAge = INFINITE;
!   Row.dwForwardNextHopAS = 0;
!   Row.dwForwardMetric1 = Dest->rt_metric + Dest->rt_if->int_metric;
!   Row.dwForwardMetric2 = -1;
!   Row.dwForwardMetric3 = -1;
!   Row.dwForwardMetric4 = -1;
!   Row.dwForwardMetric5 = -1;
  
    Res = DeleteIpForwardEntry(&Row);





More information about the Olsr-cvs mailing list