[coap] remove get port (#3177)

diff --git a/src/core/coap/coap.hpp b/src/core/coap/coap.hpp
index 4e35dd1..14bac1f 100644
--- a/src/core/coap/coap.hpp
+++ b/src/core/coap/coap.hpp
@@ -486,14 +486,6 @@
     otError Stop(void);
 
     /**
-     * This method returns a port number used by CoAP service.
-     *
-     * @returns A port number.
-     *
-     */
-    uint16_t GetPort(void) { return mSocket.GetSockName().mPort; };
-
-    /**
      * This method adds a resource to the CoAP server.
      *
      * @param[in]  aResource  A reference to the resource.
diff --git a/src/core/meshcop/joiner.cpp b/src/core/meshcop/joiner.cpp
index 58950e9..7b959d8 100644
--- a/src/core/meshcop/joiner.cpp
+++ b/src/core/meshcop/joiner.cpp
@@ -159,7 +159,7 @@
     ThreadNetif &netif = GetNetif();
 
     netif.GetCoapSecure().Disconnect();
-    netif.GetIp6Filter().RemoveUnsecurePort(netif.GetCoapSecure().GetPort());
+    netif.GetIp6Filter().RemoveUnsecurePort(OPENTHREAD_CONFIG_JOINER_UDP_PORT);
 }
 
 void Joiner::Complete(otError aError)
@@ -290,7 +290,7 @@
 
         netif.GetMac().SetPanId(joinerRouter->mPanId);
         netif.GetMac().SetPanChannel(joinerRouter->mChannel);
-        netif.GetIp6Filter().AddUnsecurePort(netif.GetCoapSecure().GetPort());
+        netif.GetIp6Filter().AddUnsecurePort(OPENTHREAD_CONFIG_JOINER_UDP_PORT);
 
         messageInfo.GetPeerAddr().mFields.m16[0] = HostSwap16(0xfe80);
         messageInfo.GetPeerAddr().SetIid(joinerRouter->mExtAddr);