Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
microsoft.public.dotnet.framework.interop
UPnP NAT using C#
Anbu
6/18/2007 12:04:00 PM
Hi All,
http://technet.microsoft.com/en-us/library/bb4...
I have been developing an application which needs to establish NAT mapping
on a UPnP Internet Gateway Device in C#. Application uses the UPnPNAT.dll
(NATUPnP 1.0 Type Library).
The getPortMappingInfo implementation is as below,
// Builds port mappings list
ArrayList portMappings = new ArrayList();
// Enumerates the ports without using the foreach statement (causes the
interop to fail).
int count = uPnpNat.StaticPortMappingCollection.Count;
IEnumerator enumerator = uPnpNat.StaticPortMappingCollection.GetEnumerator();
enumerator.Reset();
for (int i = 0; i <= count; i++) {
IStaticPortMapping mapping = null;
try {
if (enumerator.MoveNext())
mapping = (IStaticPortMapping)enumerator.Current;
}
catch { }
if (mapping != null) {
portMappings.Add(new PortMappingInfo(
mapping.Description,
mapping.Protocol.ToUpper(),
mapping.InternalClient,
mapping.InternalPort,
IPAddress.Parse(mapping.ExternalIPAddress),
mapping.ExternalPort,
mapping.Enabled));
}
}
// Now copies the ArrayList to an array of PortMappingInfo.
PortMappingInfo[] portMappingInfos = new PortMappingInfo[portMappings.Count];
portMappings.CopyTo(portMappingInfos);
return portMappingInfos;
Scenario 1:
I have another test application which is used to verify the connectivity
between the IDG and the PC (UPnPTest.exe downloaded from the web). This
application validates the connectivity and returns the external IP address
and the port mappings. Even its able to create port mappings. Now, if I run
my application, I'm able to create new mapping and retrive the port mapping.
Scenario 2:
I restart the IDG and wait for couple of minute to complete all startups.
The IP was assigned to new IP from the IGD. Now, if I run my application, its
not able to create port mapping and not retriving the existing data,
including the external IP.
Test:
I used Ethereal (network sniffing software), to check the data calls. I
found that the application is sending "getGenericPortMappingEntry" Soap
request to the IGD and this is causing the failure.
Can anyone suggest what went wrong and how can I rectify this to make the
application work in the second scenario?
Thanks,
Anbu
3 Answers
Arkady Frenkel
6/18/2007 7:36:00 PM
0
Correct NG for your question is
microsoft.public.upnp
Arkadyy
"Anbu" <Anbu@discussions.microsoft.com> wrote in message
news:D9190ADC-C631-46E7-9934-ED4172FD2B78@microsoft.com...
> Hi All,
>
>
http://technet.microsoft.com/en-us/library/bb4...
>
> I have been developing an application which needs to establish NAT mapping
> on a UPnP Internet Gateway Device in C#. Application uses the UPnPNAT.dll
> (NATUPnP 1.0 Type Library).
>
> The getPortMappingInfo implementation is as below,
> // Builds port mappings list
> ArrayList portMappings = new ArrayList();
>
> // Enumerates the ports without using the foreach statement (causes the
> interop to fail).
> int count = uPnpNat.StaticPortMappingCollection.Count;
> IEnumerator enumerator =
> uPnpNat.StaticPortMappingCollection.GetEnumerator();
> enumerator.Reset();
>
> for (int i = 0; i <= count; i++) {
> IStaticPortMapping mapping = null;
> try {
> if (enumerator.MoveNext())
> mapping = (IStaticPortMapping)enumerator.Current;
> }
> catch { }
>
> if (mapping != null) {
> portMappings.Add(new PortMappingInfo(
> mapping.Description,
> mapping.Protocol.ToUpper(),
> mapping.InternalClient,
> mapping.InternalPort,
> IPAddress.Parse(mapping.ExternalIPAddress),
> mapping.ExternalPort,
> mapping.Enabled));
> }
> }
>
> // Now copies the ArrayList to an array of PortMappingInfo.
> PortMappingInfo[] portMappingInfos = new
> PortMappingInfo[portMappings.Count];
> portMappings.CopyTo(portMappingInfos);
>
> return portMappingInfos;
>
> Scenario 1:
> I have another test application which is used to verify the connectivity
> between the IDG and the PC (UPnPTest.exe downloaded from the web). This
> application validates the connectivity and returns the external IP address
> and the port mappings. Even its able to create port mappings. Now, if I
> run
> my application, I'm able to create new mapping and retrive the port
> mapping.
>
> Scenario 2:
> I restart the IDG and wait for couple of minute to complete all startups.
> The IP was assigned to new IP from the IGD. Now, if I run my application,
> its
> not able to create port mapping and not retriving the existing data,
> including the external IP.
>
> Test:
> I used Ethereal (network sniffing software), to check the data calls. I
> found that the application is sending "getGenericPortMappingEntry" Soap
> request to the IGD and this is causing the failure.
>
> Can anyone suggest what went wrong and how can I rectify this to make the
> application work in the second scenario?
>
> Thanks,
> Anbu
Anbu
6/19/2007 5:22:00 AM
0
Sorry, the group microsoft.public.upnp is very low active. Anyhow, I posted
there too. thanks,
"Arkady Frenkel" wrote:
> Correct NG for your question is
> microsoft.public.upnp
>
> Arkadyy
>
> "Anbu" <Anbu@discussions.microsoft.com> wrote in message
> news:D9190ADC-C631-46E7-9934-ED4172FD2B78@microsoft.com...
> > Hi All,
> >
> >
http://technet.microsoft.com/en-us/library/bb4...
> >
> > I have been developing an application which needs to establish NAT mapping
> > on a UPnP Internet Gateway Device in C#. Application uses the UPnPNAT.dll
> > (NATUPnP 1.0 Type Library).
> >
> > The getPortMappingInfo implementation is as below,
> > // Builds port mappings list
> > ArrayList portMappings = new ArrayList();
> >
> > // Enumerates the ports without using the foreach statement (causes the
> > interop to fail).
> > int count = uPnpNat.StaticPortMappingCollection.Count;
> > IEnumerator enumerator =
> > uPnpNat.StaticPortMappingCollection.GetEnumerator();
> > enumerator.Reset();
> >
> > for (int i = 0; i <= count; i++) {
> > IStaticPortMapping mapping = null;
> > try {
> > if (enumerator.MoveNext())
> > mapping = (IStaticPortMapping)enumerator.Current;
> > }
> > catch { }
> >
> > if (mapping != null) {
> > portMappings.Add(new PortMappingInfo(
> > mapping.Description,
> > mapping.Protocol.ToUpper(),
> > mapping.InternalClient,
> > mapping.InternalPort,
> > IPAddress.Parse(mapping.ExternalIPAddress),
> > mapping.ExternalPort,
> > mapping.Enabled));
> > }
> > }
> >
> > // Now copies the ArrayList to an array of PortMappingInfo.
> > PortMappingInfo[] portMappingInfos = new
> > PortMappingInfo[portMappings.Count];
> > portMappings.CopyTo(portMappingInfos);
> >
> > return portMappingInfos;
> >
> > Scenario 1:
> > I have another test application which is used to verify the connectivity
> > between the IDG and the PC (UPnPTest.exe downloaded from the web). This
> > application validates the connectivity and returns the external IP address
> > and the port mappings. Even its able to create port mappings. Now, if I
> > run
> > my application, I'm able to create new mapping and retrive the port
> > mapping.
> >
> > Scenario 2:
> > I restart the IDG and wait for couple of minute to complete all startups.
> > The IP was assigned to new IP from the IGD. Now, if I run my application,
> > its
> > not able to create port mapping and not retriving the existing data,
> > including the external IP.
> >
> > Test:
> > I used Ethereal (network sniffing software), to check the data calls. I
> > found that the application is sending "getGenericPortMappingEntry" Soap
> > request to the IGD and this is causing the failure.
> >
> > Can anyone suggest what went wrong and how can I rectify this to make the
> > application work in the second scenario?
> >
> > Thanks,
> > Anbu
>
>
>
Arkady Frenkel
6/19/2007 6:46:00 AM
0
But at least you'll receive the answer from Henry Rawas ( top UPnP
authority in MSFT )
Arkady
"Anbu" <Anbu@discussions.microsoft.com> wrote in message
news:4018E33A-6BAB-4008-BC10-E18AF1881A17@microsoft.com...
> Sorry, the group microsoft.public.upnp is very low active. Anyhow, I
> posted
> there too. thanks,
>
> "Arkady Frenkel" wrote:
>
>> Correct NG for your question is
>> microsoft.public.upnp
>>
>> Arkadyy
>>
>> "Anbu" <Anbu@discussions.microsoft.com> wrote in message
>> news:D9190ADC-C631-46E7-9934-ED4172FD2B78@microsoft.com...
>> > Hi All,
>> >
>> >
http://technet.microsoft.com/en-us/library/bb4...
>> >
>> > I have been developing an application which needs to establish NAT
>> > mapping
>> > on a UPnP Internet Gateway Device in C#. Application uses the
>> > UPnPNAT.dll
>> > (NATUPnP 1.0 Type Library).
>> >
>> > The getPortMappingInfo implementation is as below,
>> > // Builds port mappings list
>> > ArrayList portMappings = new ArrayList();
>> >
>> > // Enumerates the ports without using the foreach statement (causes the
>> > interop to fail).
>> > int count = uPnpNat.StaticPortMappingCollection.Count;
>> > IEnumerator enumerator =
>> > uPnpNat.StaticPortMappingCollection.GetEnumerator();
>> > enumerator.Reset();
>> >
>> > for (int i = 0; i <= count; i++) {
>> > IStaticPortMapping mapping = null;
>> > try {
>> > if (enumerator.MoveNext())
>> > mapping = (IStaticPortMapping)enumerator.Current;
>> > }
>> > catch { }
>> >
>> > if (mapping != null) {
>> > portMappings.Add(new PortMappingInfo(
>> > mapping.Description,
>> > mapping.Protocol.ToUpper(),
>> > mapping.InternalClient,
>> > mapping.InternalPort,
>> > IPAddress.Parse(mapping.ExternalIPAddress),
>> > mapping.ExternalPort,
>> > mapping.Enabled));
>> > }
>> > }
>> >
>> > // Now copies the ArrayList to an array of PortMappingInfo.
>> > PortMappingInfo[] portMappingInfos = new
>> > PortMappingInfo[portMappings.Count];
>> > portMappings.CopyTo(portMappingInfos);
>> >
>> > return portMappingInfos;
>> >
>> > Scenario 1:
>> > I have another test application which is used to verify the
>> > connectivity
>> > between the IDG and the PC (UPnPTest.exe downloaded from the web). This
>> > application validates the connectivity and returns the external IP
>> > address
>> > and the port mappings. Even its able to create port mappings. Now, if I
>> > run
>> > my application, I'm able to create new mapping and retrive the port
>> > mapping.
>> >
>> > Scenario 2:
>> > I restart the IDG and wait for couple of minute to complete all
>> > startups.
>> > The IP was assigned to new IP from the IGD. Now, if I run my
>> > application,
>> > its
>> > not able to create port mapping and not retriving the existing data,
>> > including the external IP.
>> >
>> > Test:
>> > I used Ethereal (network sniffing software), to check the data calls. I
>> > found that the application is sending "getGenericPortMappingEntry" Soap
>> > request to the IGD and this is causing the failure.
>> >
>> > Can anyone suggest what went wrong and how can I rectify this to make
>> > the
>> > application work in the second scenario?
>> >
>> > Thanks,
>> > Anbu
>>
>>
>>
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
UPnP NAT using C#
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password