2 * iphlpapi dll implementation -- Setting and storing route information
4 * These are stubs for functions that set routing information on the target
5 * operating system. They are grouped here because their implementation will
6 * vary widely by operating system.
8 * Copyright (C) 2004 Art Yerkes
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "iphlpapi_private.h"
27 #define IP_FORWARD_ADD 3
28 #define IP_FORWARD_DEL 2
30 WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi
);
32 DWORD
createIpForwardEntry( PMIB_IPFORWARDROW pRoute
) {
34 NTSTATUS status
= openTcpFile( &tcpFile
);
35 TCP_REQUEST_SET_INFORMATION_EX_ROUTE_ENTRY req
=
36 TCP_REQUEST_SET_INFORMATION_INIT
;
43 if( NT_SUCCESS(status
) ) {
44 status
= getNthIpEntity( tcpFile
, pRoute
->dwForwardIfIndex
, &id
);
46 if( NT_SUCCESS(status
) ) {
47 req
.Req
.ID
.toi_class
= INFO_CLASS_PROTOCOL
;
48 req
.Req
.ID
.toi_type
= INFO_TYPE_PROVIDER
;
49 req
.Req
.ID
.toi_id
= IP_MIB_ARPTABLE_ENTRY_ID
;
50 req
.Req
.ID
.toi_entity
.tei_instance
= id
.tei_instance
;
51 req
.Req
.ID
.toi_entity
.tei_entity
= CL_NL_ENTITY
;
52 req
.Req
.BufferSize
= sizeof(*rte
);
54 (IPRouteEntry
*)&req
.Req
.Buffer
[0];
58 rte
->ire_dest
= pRoute
->dwForwardDest
;
59 rte
->ire_mask
= pRoute
->dwForwardMask
;
60 rte
->ire_gw
= pRoute
->dwForwardNextHop
;
61 rte
->ire_index
= pRoute
->dwForwardIfIndex
;
62 rte
->ire_type
= IP_FORWARD_ADD
;
63 rte
->ire_proto
= pRoute
->dwForwardProto
;
64 rte
->ire_age
= pRoute
->dwForwardAge
;
65 rte
->ire_metric1
= pRoute
->dwForwardMetric1
;
66 rte
->ire_metric2
= pRoute
->dwForwardMetric2
;
67 rte
->ire_metric3
= pRoute
->dwForwardMetric3
;
68 rte
->ire_metric4
= pRoute
->dwForwardMetric4
;
69 rte
->ire_metric5
= pRoute
->dwForwardMetric5
;
71 status
= DeviceIoControl( tcpFile
,
72 IOCTL_TCP_SET_INFORMATION_EX
,
81 closeTcpFile( tcpFile
);
84 TRACE("Returning: %08x (IOCTL was %08x)\n", status
, IOCTL_TCP_SET_INFORMATION_EX
);
86 if( NT_SUCCESS(status
) )
92 DWORD
setIpForwardEntry( PMIB_IPFORWARDROW pRoute
) {
97 DWORD
deleteIpForwardEntry( PMIB_IPFORWARDROW pRoute
) {
99 NTSTATUS status
= openTcpFile( &tcpFile
);
100 TCP_REQUEST_SET_INFORMATION_EX_ROUTE_ENTRY req
=
101 TCP_REQUEST_SET_INFORMATION_INIT
;
104 DWORD returnSize
= 0;
108 if( NT_SUCCESS(status
) ) {
109 status
= getNthIpEntity( tcpFile
, pRoute
->dwForwardIfIndex
, &id
);
111 if( NT_SUCCESS(status
) ) {
112 req
.Req
.ID
.toi_class
= INFO_CLASS_PROTOCOL
;
113 req
.Req
.ID
.toi_type
= INFO_TYPE_PROVIDER
;
114 req
.Req
.ID
.toi_id
= IP_MIB_ARPTABLE_ENTRY_ID
;
115 req
.Req
.ID
.toi_entity
.tei_instance
= id
.tei_instance
;
116 req
.Req
.ID
.toi_entity
.tei_entity
= CL_NL_ENTITY
;
117 req
.Req
.BufferSize
= sizeof(*rte
);
119 (IPRouteEntry
*)&req
.Req
.Buffer
[0];
122 // dwForwardNextHopAS
123 rte
->ire_dest
= pRoute
->dwForwardDest
;
124 rte
->ire_mask
= INADDR_NONE
;
125 rte
->ire_gw
= pRoute
->dwForwardNextHop
;
126 rte
->ire_index
= pRoute
->dwForwardIfIndex
;
127 rte
->ire_type
= IP_FORWARD_DEL
;
128 rte
->ire_proto
= pRoute
->dwForwardProto
;
129 rte
->ire_age
= pRoute
->dwForwardAge
;
130 rte
->ire_metric1
= pRoute
->dwForwardMetric1
;
131 rte
->ire_metric2
= INADDR_NONE
;
132 rte
->ire_metric3
= INADDR_NONE
;
133 rte
->ire_metric4
= INADDR_NONE
;
134 rte
->ire_metric5
= INADDR_NONE
;
136 status
= DeviceIoControl( tcpFile
,
137 IOCTL_TCP_SET_INFORMATION_EX
,
146 closeTcpFile( tcpFile
);
149 TRACE("Returning: %08x (IOCTL was %08x)\n", status
, IOCTL_TCP_SET_INFORMATION_EX
);
151 if( NT_SUCCESS(status
) )