Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenroute_reactos.c
Go to the documentation of this file.
00001 /* 00002 * iphlpapi dll implementation -- Setting and storing route information 00003 * 00004 * These are stubs for functions that set routing information on the target 00005 * operating system. They are grouped here because their implementation will 00006 * vary widely by operating system. 00007 * 00008 * Copyright (C) 2004 Art Yerkes 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 2.1 of the License, or (at your option) any later version. 00013 * 00014 * This library is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 * Lesser General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU Lesser General Public 00020 * License along with this library; if not, write to the Free Software 00021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00022 */ 00023 00024 #include "config.h" 00025 #include "iphlpapi_private.h" 00026 00027 #define IP_FORWARD_ADD 3 00028 #define IP_FORWARD_DEL 2 00029 00030 WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi); 00031 00032 DWORD createIpForwardEntry( PMIB_IPFORWARDROW pRoute ) { 00033 HANDLE tcpFile; 00034 NTSTATUS status = openTcpFile( &tcpFile ); 00035 TCP_REQUEST_SET_INFORMATION_EX_ROUTE_ENTRY req = 00036 TCP_REQUEST_SET_INFORMATION_INIT; 00037 IPRouteEntry *rte; 00038 TDIEntityID id; 00039 DWORD returnSize = 0; 00040 00041 TRACE("Called.\n"); 00042 00043 if( NT_SUCCESS(status) ) { 00044 status = getNthIpEntity( tcpFile, pRoute->dwForwardIfIndex, &id ); 00045 00046 if( NT_SUCCESS(status) ) { 00047 req.Req.ID.toi_class = INFO_CLASS_PROTOCOL; 00048 req.Req.ID.toi_type = INFO_TYPE_PROVIDER; 00049 req.Req.ID.toi_id = IP_MIB_ARPTABLE_ENTRY_ID; 00050 req.Req.ID.toi_entity.tei_instance = id.tei_instance; 00051 req.Req.ID.toi_entity.tei_entity = CL_NL_ENTITY; 00052 req.Req.BufferSize = sizeof(*rte); 00053 rte = 00054 (IPRouteEntry *)&req.Req.Buffer[0]; 00055 00056 // dwForwardPolicy 00057 // dwForwardNextHopAS 00058 rte->ire_dest = pRoute->dwForwardDest; 00059 rte->ire_mask = pRoute->dwForwardMask; 00060 rte->ire_gw = pRoute->dwForwardNextHop; 00061 rte->ire_index = pRoute->dwForwardIfIndex; 00062 rte->ire_type = IP_FORWARD_ADD; 00063 rte->ire_proto = pRoute->dwForwardProto; 00064 rte->ire_age = pRoute->dwForwardAge; 00065 rte->ire_metric1 = pRoute->dwForwardMetric1; 00066 rte->ire_metric2 = pRoute->dwForwardMetric2; 00067 rte->ire_metric3 = pRoute->dwForwardMetric3; 00068 rte->ire_metric4 = pRoute->dwForwardMetric4; 00069 rte->ire_metric5 = pRoute->dwForwardMetric5; 00070 00071 status = DeviceIoControl( tcpFile, 00072 IOCTL_TCP_SET_INFORMATION_EX, 00073 &req, 00074 sizeof(req), 00075 NULL, 00076 0, 00077 &returnSize, 00078 NULL ); 00079 } 00080 00081 closeTcpFile( tcpFile ); 00082 } 00083 00084 TRACE("Returning: %08x (IOCTL was %08x)\n", status, IOCTL_TCP_SET_INFORMATION_EX); 00085 00086 if( NT_SUCCESS(status) ) 00087 return NO_ERROR; 00088 else 00089 return status; 00090 } 00091 00092 DWORD setIpForwardEntry( PMIB_IPFORWARDROW pRoute ) { 00093 FIXME(":stub\n"); 00094 return (DWORD) 0; 00095 } 00096 00097 DWORD deleteIpForwardEntry( PMIB_IPFORWARDROW pRoute ) { 00098 HANDLE tcpFile; 00099 NTSTATUS status = openTcpFile( &tcpFile ); 00100 TCP_REQUEST_SET_INFORMATION_EX_ROUTE_ENTRY req = 00101 TCP_REQUEST_SET_INFORMATION_INIT; 00102 IPRouteEntry *rte; 00103 TDIEntityID id; 00104 DWORD returnSize = 0; 00105 00106 TRACE("Called.\n"); 00107 00108 if( NT_SUCCESS(status) ) { 00109 status = getNthIpEntity( tcpFile, pRoute->dwForwardIfIndex, &id ); 00110 00111 if( NT_SUCCESS(status) ) { 00112 req.Req.ID.toi_class = INFO_CLASS_PROTOCOL; 00113 req.Req.ID.toi_type = INFO_TYPE_PROVIDER; 00114 req.Req.ID.toi_id = IP_MIB_ARPTABLE_ENTRY_ID; 00115 req.Req.ID.toi_entity.tei_instance = id.tei_instance; 00116 req.Req.ID.toi_entity.tei_entity = CL_NL_ENTITY; 00117 req.Req.BufferSize = sizeof(*rte); 00118 rte = 00119 (IPRouteEntry *)&req.Req.Buffer[0]; 00120 00121 // dwForwardPolicy 00122 // dwForwardNextHopAS 00123 rte->ire_dest = pRoute->dwForwardDest; 00124 rte->ire_mask = INADDR_NONE; 00125 rte->ire_gw = pRoute->dwForwardNextHop; 00126 rte->ire_index = pRoute->dwForwardIfIndex; 00127 rte->ire_type = IP_FORWARD_DEL; 00128 rte->ire_proto = pRoute->dwForwardProto; 00129 rte->ire_age = pRoute->dwForwardAge; 00130 rte->ire_metric1 = pRoute->dwForwardMetric1; 00131 rte->ire_metric2 = INADDR_NONE; 00132 rte->ire_metric3 = INADDR_NONE; 00133 rte->ire_metric4 = INADDR_NONE; 00134 rte->ire_metric5 = INADDR_NONE; 00135 00136 status = DeviceIoControl( tcpFile, 00137 IOCTL_TCP_SET_INFORMATION_EX, 00138 &req, 00139 sizeof(req), 00140 NULL, 00141 0, 00142 &returnSize, 00143 NULL ); 00144 } 00145 00146 closeTcpFile( tcpFile ); 00147 } 00148 00149 TRACE("Returning: %08x (IOCTL was %08x)\n", status, IOCTL_TCP_SET_INFORMATION_EX); 00150 00151 if( NT_SUCCESS(status) ) 00152 return NO_ERROR; 00153 else 00154 return status; 00155 } Generated on Sun May 27 2012 04:24:11 for ReactOS by
1.7.6.1
|