I've posted this question in
'microsoft.publ ic.dotnet.frame work.compactfra mework' as well, but
despite the great help I still haven't solved the problem. So before
going the C++ route I would like to see if anybody in this group may
have the answer.
What I'm trying to do is change the route table of my Windows Mobile 5
Pocket PC (.Net CF) device (TyTN) using C#. This is probably similar as
doing it on standard CF. Using Iphlpapi.dll I can retrieve the route
table, but I am unable to change/add a route. I have specified the
following structs/pinvokes:
=========START= ==========
[StructLayout(La youtKind.Sequen tial)]
public struct MIB_IPFORWARDRO W {
public UInt32 dwForwardDest; //destination IP address.
public UInt32 dwForwardMask; //Subnet mask
public UInt32 dwForwardPolicy ; //conditions for multi-path
route. Unused, specify 0.
public UInt32 dwForwardNextHo p; //IP address of the next hop.
Own address?
public UInt32 dwForwardIfInde x; //index of interface
public UInt32 dwForwardType; //route type
public UInt32 dwForwardProto; //routing protocol.
public UInt32 dwForwardAge; //age of route.
public UInt32 dwForwardNextHo pAS; //autonomous system number. 0
if not relevant
public int dwForwardMetric 1; //-1 if not used (goes for all
metrics)
public int dwForwardMetric 2;
public int dwForwardMetric 3;
public int dwForwardMetric 4;
public int dwForwardMetric 5;
}
[StructLayout(La youtKind.Sequen tial)]
public struct MIB_IPFORWARDTA BLE {
public int dwNumEntries; //number of route entries in
the table.
public MIB_IPFORWARDRO W[] table;
}
[DllImport("Iphl papi.dll")]
[return: MarshalAs(Unman agedType.U4)]
public static extern int CreateIpForward Entry(ref MIB_IPFORWARDRO W
pRoute);
[DllImport("Iphl papi.dll")]
[return: MarshalAs(Unman agedType.U4)]
public static extern int DeleteIpForward Entry(ref MIB_IPFORWARDRO W
pRoute);
[DllImport("Iphl papi.dll")]
[return: MarshalAs(Unman agedType.U4)]
public static extern int SetIpForwardEnt ry(ref MIB_IPFORWARDRO W
pRoute);
[DllImport("Iphl papi.dll")]
[return: MarshalAs(Unman agedType.U4)]
public static extern int GetIpForwardTab le(byte[] pIpForwardTable , out
int pdwSize, bool bOrder);
=========END=== ========
I invoke these methods as follows:
=========START= ==========
public int createIpForward Entry(UInt32 destIPAddress, UInt32 destMask,
UInt32 nextHopIPAddres s,
UInt32 ifIndex) {
MIB_IPFORWARDRO W mifr = new MIB_IPFORWARDRO W();
mifr.dwForwardD est = destIPAddress;
mifr.dwForwardM ask = destMask;
mifr.dwForwardP olicy = Convert.ToUInt3 2(0);
mifr.dwForwardN extHop = nextHopIPAddres s;
mifr.dwForwardI fIndex = ifIndex; //?
mifr.dwForwardT ype = Convert.ToUInt3 2(4);
mifr.dwForwardP roto = Convert.ToUInt3 2(3);
mifr.dwForwardA ge = Convert.ToUInt3 2(0);
mifr.dwForwardN extHopAS = Convert.ToUInt3 2(0);
mifr.dwForwardM etric1 = -1;
mifr.dwForwardM etric2 = -1;
mifr.dwForwardM etric3 = -1;
mifr.dwForwardM etric4 = -1;
mifr.dwForwardM etric5 = -1;
return CreateIpForward Entry(ref mifr);
}
=========END=== ========
All IP addresses are added as unsigned ints (double checked whether
they are correct. I even tried adding a row that I just successfully
retrieved (thereby skipping my own structure). If that gives me an
error code 87 (invalid param).
Is there anybody here that has successfully done this or has a few
relevant pointers? Preferably C# examples, but C++ examples are a step
in the right direction. Thanks! 3 6982
Probably can find something here: http://msdn2.microsoft.com/en-us/library/aa915714.aspx
chanmm
"cyberco" <cy*****@gmail. comwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.com.. .
I've posted this question in
'microsoft.publ ic.dotnet.frame work.compactfra mework' as well, but
despite the great help I still haven't solved the problem. So before
going the C++ route I would like to see if anybody in this group may
have the answer.
What I'm trying to do is change the route table of my Windows Mobile 5
Pocket PC (.Net CF) device (TyTN) using C#. This is probably similar as
doing it on standard CF. Using Iphlpapi.dll I can retrieve the route
table, but I am unable to change/add a route. I have specified the
following structs/pinvokes:
=========START= ==========
[StructLayout(La youtKind.Sequen tial)]
public struct MIB_IPFORWARDRO W {
public UInt32 dwForwardDest; //destination IP address.
public UInt32 dwForwardMask; //Subnet mask
public UInt32 dwForwardPolicy ; //conditions for multi-path
route. Unused, specify 0.
public UInt32 dwForwardNextHo p; //IP address of the next hop.
Own address?
public UInt32 dwForwardIfInde x; //index of interface
public UInt32 dwForwardType; //route type
public UInt32 dwForwardProto; //routing protocol.
public UInt32 dwForwardAge; //age of route.
public UInt32 dwForwardNextHo pAS; //autonomous system number. 0
if not relevant
public int dwForwardMetric 1; //-1 if not used (goes for all
metrics)
public int dwForwardMetric 2;
public int dwForwardMetric 3;
public int dwForwardMetric 4;
public int dwForwardMetric 5;
}
[StructLayout(La youtKind.Sequen tial)]
public struct MIB_IPFORWARDTA BLE {
public int dwNumEntries; //number of route entries in
the table.
public MIB_IPFORWARDRO W[] table;
}
[DllImport("Iphl papi.dll")]
[return: MarshalAs(Unman agedType.U4)]
public static extern int CreateIpForward Entry(ref MIB_IPFORWARDRO W
pRoute);
[DllImport("Iphl papi.dll")]
[return: MarshalAs(Unman agedType.U4)]
public static extern int DeleteIpForward Entry(ref MIB_IPFORWARDRO W
pRoute);
[DllImport("Iphl papi.dll")]
[return: MarshalAs(Unman agedType.U4)]
public static extern int SetIpForwardEnt ry(ref MIB_IPFORWARDRO W
pRoute);
[DllImport("Iphl papi.dll")]
[return: MarshalAs(Unman agedType.U4)]
public static extern int GetIpForwardTab le(byte[] pIpForwardTable , out
int pdwSize, bool bOrder);
=========END=== ========
I invoke these methods as follows:
=========START= ==========
public int createIpForward Entry(UInt32 destIPAddress, UInt32 destMask,
UInt32 nextHopIPAddres s,
UInt32 ifIndex) {
MIB_IPFORWARDRO W mifr = new MIB_IPFORWARDRO W();
mifr.dwForwardD est = destIPAddress;
mifr.dwForwardM ask = destMask;
mifr.dwForwardP olicy = Convert.ToUInt3 2(0);
mifr.dwForwardN extHop = nextHopIPAddres s;
mifr.dwForwardI fIndex = ifIndex; //?
mifr.dwForwardT ype = Convert.ToUInt3 2(4);
mifr.dwForwardP roto = Convert.ToUInt3 2(3);
mifr.dwForwardA ge = Convert.ToUInt3 2(0);
mifr.dwForwardN extHopAS = Convert.ToUInt3 2(0);
mifr.dwForwardM etric1 = -1;
mifr.dwForwardM etric2 = -1;
mifr.dwForwardM etric3 = -1;
mifr.dwForwardM etric4 = -1;
mifr.dwForwardM etric5 = -1;
return CreateIpForward Entry(ref mifr);
}
=========END=== ========
All IP addresses are added as unsigned ints (double checked whether
they are correct. I even tried adding a row that I just successfully
retrieved (thereby skipping my own structure). If that gives me an
error code 87 (invalid param).
Is there anybody here that has successfully done this or has a few
relevant pointers? Preferably C# examples, but C++ examples are a step
in the right direction. Thanks!
Those look like really useful utilities, but, forgive me for asking an
obvious question, where can I get those tools? The location at the top
of the page doesn't mean much to me... :(
chanmm wrote:
Probably can find something here: http://msdn2.microsoft.com/en-us/library/aa915714.aspx
chanmm
I figured maybe the problem is that I should reserve some memory for
the new MIB_IPFORWARDRO W I'm creating (as I do in the following code)?
=========START= ==========
public int createIpForward Entry(UInt32 destIPAddress, UInt32 destMask,
UInt32 nextHopIPAddres s,
UInt32 ifIndex) {
MIB_IPFORWARDRO W mifr = new MIB_IPFORWARDRO W();
mifr.dwForwardD est = destIPAddress;
mifr.dwForwardM ask = destMask;
mifr.dwForwardP olicy = Convert.ToUInt3 2(0);
mifr.dwForwardN extHop = nextHopIPAddres s;
mifr.dwForwardI fIndex = ifIndex; //?
mifr.dwForwardT ype = Convert.ToUInt3 2(4);
mifr.dwForwardP roto = Convert.ToUInt3 2(3);
mifr.dwForwardA ge = Convert.ToUInt3 2(0);
mifr.dwForwardN extHopAS = Convert.ToUInt3 2(0);
mifr.dwForwardM etric1 = -1;
mifr.dwForwardM etric2 = -1;
mifr.dwForwardM etric3 = -1;
mifr.dwForwardM etric4 = -1;
mifr.dwForwardM etric5 = -1;
return CreateIpForward Entry(ref mifr);}
=========END=== ========
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: jason |
last post by:
If one is attempting to insert data into tables at the same time what is the
best way to do this. I could do it the way below - but is there any reason I
should not do it this way or perhaps follow a better route. The second
table is really an audit table to track changes made by the user
Set cnn = CreateObject("ADODB.Connection")...
|
by: Jon Brunson |
last post by:
Is it possible to use a DataAdapter to fill a DataTable, change the
DataColumns of that DataTable (and maybe even it's name) and then commit
those changes to the database (in my case SQL Server 2000)?
Eg:
Dim dc As New SqlCommand("SELECT TOP 0 * FROM SomeTable",
SomeSqlConnection)
|
by: Jothi |
last post by:
Hi All,
I implemented source to notify any changes in route table using
"NotifyRouteChange". ie., I am monitoring the route table, if any
change in PC. If any body(process/application) changes routetable,
NotifyRouteChange notifying via, Overlapped.hEvent that I registed
earlier. It is working fine.
I would like to know which application...
|
by: Paolo Pignatelli |
last post by:
I am trying to get an output/file like this (below) in an XML file
(MyXmlFile.xml) (which I will use for a slide show)
--
<gallery timer="3" order="sequential" fadetime="2" looping="yes" xpos="0"
ypos="0">
<image path="images2/Test1.jpg" />
|
by: Alpha |
last post by:
I have a window application. On one of the form, there is a listbox and a
few combox. The lstSchItem has a dataview as a datasource. The comboxes are
bind to its selected value but through the dataset table. Now when I change
the selection in the lstSchItem the comboxes are staying the same and not
reflecting the changes. I tried...
| |
by: Tommy Martin |
last post by:
If I add a web reference to my code it works fine. I need to know how to
dynamically set the url for the web reference. Sometimes URL's change and
would be nice to let the user enter a new URL in a setup form instead of
having to send out updated code.
Is this possible. If so how?
Thanks.
|
by: michael ngong |
last post by:
pramod@rtimes.com (Pramod Ramachandran) wrote in message news:<6616e304.0306240122.4dd3ecd5@posting.google.com>...
Permit me start with the second question.
It would be easier to be more precise if it were pinned down to a
specific situation.Anyway .........
User errors vary widely ,It may not be feasible to pinpoint all the
different...
|
by: Darkside12 |
last post by:
Hi,
I'm trying to build a dynamic query by form. The idea is that a user can select a table in the database via a combo box and this will then change all of the text box labels on the form to match the field headers for the selected table. It also hides any text boxes that are surplus to the number of fields of the selected table.
The user...
|
by: Glenton |
last post by:
Hi All
Here is a very simple little class for finding a shortest route on a network, following Dijkstra's Algorithm:
#!/usr/bin/env python
#This is meant to solve a maze with Dijkstra's algorithm
from numpy import inf
from copy import copy
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |