]> sjero.net Git - linphone/commitdiff
Add better uPnP description
authorYann Diorcet <yann.diorcet@belledonne-communications.com>
Tue, 8 Jan 2013 16:28:01 +0000 (17:28 +0100)
committerYann Diorcet <yann.diorcet@belledonne-communications.com>
Tue, 8 Jan 2013 16:28:01 +0000 (17:28 +0100)
coreapi/upnp.c

index 30e31345929874de474a1800689a84b51770a7f2..bb7dcd8dfac836f98a6525cce1c4a3874e2faa56 100644 (file)
@@ -321,6 +321,7 @@ void upnp_context_uninit(LinphoneCore *lc) {
 int upnp_context_send_add_port_binding(LinphoneCore *lc, UpnpPortBinding *port) {
        UpnpContext *lupnp = &lc->upnp;
        upnp_igd_port_mapping mapping;
+       char description[128];
        int ret;
        if(port->state == LinphoneUpnpStateIdle) {
                port->retry = 0;
@@ -339,11 +340,15 @@ int upnp_context_send_add_port_binding(LinphoneCore *lc, UpnpPortBinding *port)
                mapping.local_port = port->local_port;
                mapping.local_host = port->local_addr;
                if(port->external_port == -1)
-                       mapping.remote_port = rand()%(0xffff - 1024) + 1024; // TODO: use better method
+                       mapping.remote_port = rand()%(0xffff - 1024) + 1024;
                else
                        mapping.remote_port = port->external_port;
                mapping.remote_host = "";
-               mapping.description = PACKAGE_NAME;
+               snprintf(description, 128, "%s %s at %s:%d",
+                               PACKAGE_NAME,
+                               (port->protocol == UPNP_IGD_IP_PROTOCOL_TCP)? "TCP": "UDP",
+                               port->local_addr, port->local_port);
+               mapping.description = description;
                mapping.protocol = port->protocol;
 
                port->retry++;