Author: alanmc
Date: 2007-05-23 21:01:46 -0400 (Wed, 23 May 2007)
New Revision: 77884

Modified:
   trunk/Mono.Nat/AsyncResults/GetAllMappingsAsyncResult.cs
   trunk/Mono.Nat/AsyncResults/PortMapAsyncResult.cs
   trunk/Mono.Nat/Mapping.cs
   
trunk/Mono.Nat/Messages/uPnPMessages/Requests/GetSpecificPortMappingEntryMessage.cs
   trunk/Mono.Nat/UpnpNatDevice.cs
Log:
Updated GetSpecificMapping to display proper values

Modified: trunk/Mono.Nat/AsyncResults/GetAllMappingsAsyncResult.cs
===================================================================
--- trunk/Mono.Nat/AsyncResults/GetAllMappingsAsyncResult.cs    2007-05-24 
01:00:59 UTC (rev 77883)
+++ trunk/Mono.Nat/AsyncResults/GetAllMappingsAsyncResult.cs    2007-05-24 
01:01:46 UTC (rev 77884)
@@ -8,11 +8,17 @@
     internal class GetAllMappingsAsyncResult : PortMapAsyncResult
     {
         private List<Mapping> mappings;
+        private Mapping specificMapping;
 
         public List<Mapping> Mappings
         {
             get { return this.mappings; }
         }
+        public Mapping SpecificMapping
+        {
+            get { return this.specificMapping; }
+            set { this.specificMapping = value; }
+        }
 
         public GetAllMappingsAsyncResult(WebRequest request, AsyncCallback 
callback, object asyncState)
             : base(request, callback, asyncState)

Modified: trunk/Mono.Nat/AsyncResults/PortMapAsyncResult.cs
===================================================================
--- trunk/Mono.Nat/AsyncResults/PortMapAsyncResult.cs   2007-05-24 01:00:59 UTC 
(rev 77883)
+++ trunk/Mono.Nat/AsyncResults/PortMapAsyncResult.cs   2007-05-24 01:01:46 UTC 
(rev 77884)
@@ -110,9 +110,17 @@
 
         internal static PortMapAsyncResult Create(MessageBase message, 
WebRequest request, AsyncCallback storedCallback, object asyncState)
         {
-            if (message is GetGenericPortMappingEntry || message is 
GetSpecificPortMappingEntryMessage)
+            if (message is GetGenericPortMappingEntry)
                 return new GetAllMappingsAsyncResult(request, storedCallback, 
asyncState);
 
+            if (message is GetSpecificPortMappingEntryMessage)
+            {
+                GetSpecificPortMappingEntryMessage mapMessage = message as 
GetSpecificPortMappingEntryMessage;
+                GetAllMappingsAsyncResult result = new 
GetAllMappingsAsyncResult(request, storedCallback, asyncState);
+                result.SpecificMapping = new Mapping(mapMessage.externalPort, 
mapMessage.protocol);
+                return result;
+            }
+
             return new PortMapAsyncResult(request, storedCallback, asyncState);
         }
     }

Modified: trunk/Mono.Nat/Mapping.cs
===================================================================
--- trunk/Mono.Nat/Mapping.cs   2007-05-24 01:00:59 UTC (rev 77883)
+++ trunk/Mono.Nat/Mapping.cs   2007-05-24 01:01:46 UTC (rev 77884)
@@ -45,11 +45,13 @@
         public int Port
         {
             get { return this.port; }
+            set { this.port = value; }
         }
 
         public Protocol Protocol
         {
             get { return this.protocol; }
+            set { this.protocol = value; }
         }
 
         #endregion Properties

Modified: 
trunk/Mono.Nat/Messages/uPnPMessages/Requests/GetSpecificPortMappingEntryMessage.cs
===================================================================
--- 
trunk/Mono.Nat/Messages/uPnPMessages/Requests/GetSpecificPortMappingEntryMessage.cs
 2007-05-24 01:00:59 UTC (rev 77883)
+++ 
trunk/Mono.Nat/Messages/uPnPMessages/Requests/GetSpecificPortMappingEntryMessage.cs
 2007-05-24 01:01:46 UTC (rev 77884)
@@ -8,8 +8,8 @@
 {
        internal class GetSpecificPortMappingEntryMessage : MessageBase
        {
-               private int externalPort;
-               private Protocol protocol;
+               internal int externalPort;
+        internal Protocol protocol;
 
                public GetSpecificPortMappingEntryMessage(int externalPort, 
Protocol protocol, UpnpNatDevice device)
                        : base(device)

Modified: trunk/Mono.Nat/UpnpNatDevice.cs
===================================================================
--- trunk/Mono.Nat/UpnpNatDevice.cs     2007-05-24 01:00:59 UTC (rev 77883)
+++ trunk/Mono.Nat/UpnpNatDevice.cs     2007-05-24 01:01:46 UTC (rev 77884)
@@ -351,7 +351,15 @@
                     throw new MappingException(message.ErrorCode, 
message.Description);
                 }
             }
-            return (mappingResult.Mappings.Count == 0) ? new Mapping(-1, 
Protocol.Tcp) : mappingResult.Mappings[0];
+            if (mappingResult.Mappings.Count == 0)
+                return new Mapping(-1, Protocol.Tcp);
+
+            //FIXME: Nasty hack. We need to store the external port and 
protocol we searched
+            // for and restore the values to the mapping as they aren't 
returned by the router
+            Mapping m = mappingResult.Mappings[0];
+            m.Port = mappingResult.SpecificMapping.Port;
+            m.Protocol = mappingResult.SpecificMapping.Protocol;
+            return m;
         }
 
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to