upnp: refactor to improve handling of port mappings renewal

The two main changes are:

1) Renewal requests are now sent for both UPnP and NAT-PMP mappings, not
   just NAT-PMP. The old code asked for an infinite lifetime when
   creating UPnP mappings and assumed that it got it, but this is not a
   safe assumption. (See GitLab issue below for more information.)

2) The updateMappingList function was removed. This function used to be
   called every 30 seconds to handle a bunch of unrelated tasks (one of
   which was renewing port mappings) and generated mostly unnecessary
   network traffic every time when using UPnP (because of the call to
   pruneMappingList). These tasks are now performed separately instead
   of being bundled together, and only when needed (either based on a
   timer or on certain events occuring, depending on the task).

GitLab: #31
Change-Id: Id0f60ddb76fb8eb4517eadbb971892d125cebfc7
diff --git a/src/upnp/protocol/mapping.cpp b/src/upnp/protocol/mapping.cpp
index 846553f..fa9b6c7 100644
--- a/src/upnp/protocol/mapping.cpp
+++ b/src/upnp/protocol/mapping.cpp
@@ -33,9 +33,7 @@
     , state_(MappingState::PENDING)
     , notifyCb_(nullptr)
     , autoUpdate_(false)
-#if HAVE_LIBNATPMP
-    , renewalTime_(sys_clock::now())
-#endif
+    , renewalTime_(sys_clock::time_point::max())
 {}
 
 Mapping::Mapping(const Mapping& other)
@@ -51,9 +49,8 @@
     state_ = other.state_;
     notifyCb_ = other.notifyCb_;
     autoUpdate_ = other.autoUpdate_;
-#if HAVE_LIBNATPMP
     renewalTime_ = other.renewalTime_;
-#endif
+    expiryTime_ = other.expiryTime_;
 }
 
 void
@@ -326,7 +323,6 @@
     return autoUpdate_;
 }
 
-#if HAVE_LIBNATPMP
 sys_clock::time_point
 Mapping::getRenewalTime() const
 {
@@ -340,7 +336,20 @@
     std::lock_guard lock(mutex_);
     renewalTime_ = time;
 }
-#endif
+
+sys_clock::time_point
+Mapping::getExpiryTime() const
+{
+    std::lock_guard lock(mutex_);
+    return expiryTime_;
+}
+
+void
+Mapping::setExpiryTime(sys_clock::time_point time)
+{
+    std::lock_guard lock(mutex_);
+    expiryTime_ = time;
+}
 
 } // namespace upnp
 } // namespace dhtnet