Mercurial > pidgin.yaz
comparison src/upnp.c @ 11566:7897207b522d
[gaim-migrate @ 13832]
Don't use the gtk wrapper when you can use glib directly - upnp shouldn't depend on gtk. Also some trailing whitespace fixes - this whole file is using spaces instead of tabs.
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Fri, 23 Sep 2005 02:39:32 +0000 |
parents | 18c6a6659770 |
children | 03cd74ca2562 |
comparison
equal
deleted
inserted
replaced
11565:2aa7d8dd61d7 | 11566:7897207b522d |
---|---|
21 * You should have received a copy of the GNU General Public License | 21 * You should have received a copy of the GNU General Public License |
22 * along with this program; if not, write to the Free Software | 22 * along with this program; if not, write to the Free Software |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
24 */ | 24 */ |
25 #include "internal.h" | 25 #include "internal.h" |
26 #include "gtkgaim.h" | 26 #include "gaim.h" |
27 | 27 |
28 #include "debug.h" | 28 #include "debug.h" |
29 #include "util.h" | 29 #include "util.h" |
30 #include "proxy.h" | 30 #include "proxy.h" |
31 #include "xmlnode.h" | 31 #include "xmlnode.h" |
198 nrd->inpa = gaim_input_add(sock, GAIM_INPUT_READ, | 198 nrd->inpa = gaim_input_add(sock, GAIM_INPUT_READ, |
199 gaim_upnp_http_read, nrd); | 199 gaim_upnp_http_read, nrd); |
200 } | 200 } |
201 } | 201 } |
202 | 202 |
203 static void | 203 static void |
204 gaim_upnp_http_send(gpointer data, | 204 gaim_upnp_http_send(gpointer data, |
205 gint sock, | 205 gint sock, |
206 GaimInputCondition cond) | 206 GaimInputCondition cond) |
207 { | 207 { |
208 int sizeSent, totalSizeSent = 0; | 208 int sizeSent, totalSizeSent = 0; |
230 nrd->tima = gaim_timeout_add(RECEIVE_TIMEOUT, | 230 nrd->tima = gaim_timeout_add(RECEIVE_TIMEOUT, |
231 (GSourceFunc)gaim_upnp_timeout, nrd); | 231 (GSourceFunc)gaim_upnp_timeout, nrd); |
232 nrd->inpa = gaim_input_add(sock, GAIM_INPUT_READ, | 232 nrd->inpa = gaim_input_add(sock, GAIM_INPUT_READ, |
233 gaim_upnp_http_read, nrd); | 233 gaim_upnp_http_read, nrd); |
234 while (!nrd->done) { | 234 while (!nrd->done) { |
235 gtk_main_iteration(); | 235 g_main_context_iteration(NULL, TRUE); |
236 } | 236 } |
237 close(sock); | 237 close(sock); |
238 } | 238 } |
239 | 239 |
240 static gchar* | 240 static gchar* |
248 nrd->recvBuffer = (gchar*)g_malloc(MAX_DESCRIPTION_RECEIVE_SIZE); | 248 nrd->recvBuffer = (gchar*)g_malloc(MAX_DESCRIPTION_RECEIVE_SIZE); |
249 | 249 |
250 nrd->tima = gaim_timeout_add(RECEIVE_TIMEOUT, | 250 nrd->tima = gaim_timeout_add(RECEIVE_TIMEOUT, |
251 (GSourceFunc)gaim_upnp_timeout, nrd); | 251 (GSourceFunc)gaim_upnp_timeout, nrd); |
252 | 252 |
253 if(gaim_proxy_connect(NULL, address, port, | 253 if(gaim_proxy_connect(NULL, address, port, |
254 gaim_upnp_http_send, nrd)) { | 254 gaim_upnp_http_send, nrd)) { |
255 | 255 |
256 gaim_debug_error("upnp", "Connect Failed: Address: %s @@@ Port %d @@@ Request %s\n\n", | 256 gaim_debug_error("upnp", "Connect Failed: Address: %s @@@ Port %d @@@ Request %s\n\n", |
257 address, port, nrd->sendBuffer); | 257 address, port, nrd->sendBuffer); |
258 | 258 |
259 gaim_timeout_remove(nrd->tima); | 259 gaim_timeout_remove(nrd->tima); |
260 g_free(nrd->recvBuffer); | 260 g_free(nrd->recvBuffer); |
261 nrd->recvBuffer = NULL; | 261 nrd->recvBuffer = NULL; |
262 } else { | 262 } else { |
263 while (!nrd->done) { | 263 while (!nrd->done) { |
264 gtk_main_iteration(); | 264 g_main_context_iteration(NULL, TRUE); |
265 } | 265 } |
266 } | 266 } |
267 | 267 |
268 recvBuffer = nrd->recvBuffer; | 268 recvBuffer = nrd->recvBuffer; |
269 g_free(nrd); | 269 g_free(nrd); |
297 } | 297 } |
298 | 298 |
299 | 299 |
300 | 300 |
301 static gchar* | 301 static gchar* |
302 gaim_upnp_parse_description_response(const gchar* httpResponse, | 302 gaim_upnp_parse_description_response(const gchar* httpResponse, |
303 const gchar* httpURL, | 303 const gchar* httpURL, |
304 const gchar* serviceType) | 304 const gchar* serviceType) |
305 { | 305 { |
306 gchar* xmlRoot; | 306 gchar* xmlRoot; |
307 gchar* baseURL; | 307 gchar* baseURL; |
318 "parse_description_response(): Failed In HTTP_OK\n\n"); | 318 "parse_description_response(): Failed In HTTP_OK\n\n"); |
319 return NULL; | 319 return NULL; |
320 } | 320 } |
321 | 321 |
322 /* find the root of the xml document */ | 322 /* find the root of the xml document */ |
323 if((xmlRoot = g_strstr_len(httpResponse, strlen(httpResponse), | 323 if((xmlRoot = g_strstr_len(httpResponse, strlen(httpResponse), |
324 "<root")) == NULL) { | 324 "<root")) == NULL) { |
325 gaim_debug_error("upnp", | 325 gaim_debug_error("upnp", |
326 "parse_description_response(): Failed finding root\n\n"); | 326 "parse_description_response(): Failed finding root\n\n"); |
327 return NULL; | 327 return NULL; |
328 } | 328 } |
342 baseURL = g_strdup(httpURL); | 342 baseURL = g_strdup(httpURL); |
343 } | 343 } |
344 | 344 |
345 /* get the serviceType child that has the service type as it's data */ | 345 /* get the serviceType child that has the service type as it's data */ |
346 | 346 |
347 /* get urn:schemas-upnp-org:device:InternetGatewayDevice:1 | 347 /* get urn:schemas-upnp-org:device:InternetGatewayDevice:1 |
348 and it's devicelist */ | 348 and it's devicelist */ |
349 serviceTypeNode = xmlnode_get_child(xmlRootNode, "device"); | 349 serviceTypeNode = xmlnode_get_child(xmlRootNode, "device"); |
350 while(!gaim_upnp_compare_device(serviceTypeNode, | 350 while(!gaim_upnp_compare_device(serviceTypeNode, |
351 "urn:schemas-upnp-org:device:InternetGatewayDevice:1") && | 351 "urn:schemas-upnp-org:device:InternetGatewayDevice:1") && |
352 serviceTypeNode != NULL) { | 352 serviceTypeNode != NULL) { |
362 gaim_debug_error("upnp", | 362 gaim_debug_error("upnp", |
363 "parse_description_response(): could not get serviceTypeNode 2\n\n"); | 363 "parse_description_response(): could not get serviceTypeNode 2\n\n"); |
364 return NULL; | 364 return NULL; |
365 } | 365 } |
366 | 366 |
367 /* get urn:schemas-upnp-org:device:WANDevice:1 | 367 /* get urn:schemas-upnp-org:device:WANDevice:1 |
368 and it's devicelist */ | 368 and it's devicelist */ |
369 serviceTypeNode = xmlnode_get_child(serviceTypeNode, "device"); | 369 serviceTypeNode = xmlnode_get_child(serviceTypeNode, "device"); |
370 while(!gaim_upnp_compare_device(serviceTypeNode, | 370 while(!gaim_upnp_compare_device(serviceTypeNode, |
371 "urn:schemas-upnp-org:device:WANDevice:1") && | 371 "urn:schemas-upnp-org:device:WANDevice:1") && |
372 serviceTypeNode != NULL) { | 372 serviceTypeNode != NULL) { |
382 gaim_debug_error("upnp", | 382 gaim_debug_error("upnp", |
383 "parse_description_response(): could not get serviceTypeNode 4\n\n"); | 383 "parse_description_response(): could not get serviceTypeNode 4\n\n"); |
384 return NULL; | 384 return NULL; |
385 } | 385 } |
386 | 386 |
387 /* get urn:schemas-upnp-org:device:WANConnectionDevice:1 | 387 /* get urn:schemas-upnp-org:device:WANConnectionDevice:1 |
388 and it's servicelist */ | 388 and it's servicelist */ |
389 serviceTypeNode = xmlnode_get_child(serviceTypeNode, "device"); | 389 serviceTypeNode = xmlnode_get_child(serviceTypeNode, "device"); |
390 while(!gaim_upnp_compare_device(serviceTypeNode, | 390 while(!gaim_upnp_compare_device(serviceTypeNode, |
391 "urn:schemas-upnp-org:device:WANConnectionDevice:1") && | 391 "urn:schemas-upnp-org:device:WANConnectionDevice:1") && |
392 serviceTypeNode != NULL) { | 392 serviceTypeNode != NULL) { |
418 "parse_description_response(): could not get serviceTypeNode 7\n\n"); | 418 "parse_description_response(): could not get serviceTypeNode 7\n\n"); |
419 return NULL; | 419 return NULL; |
420 } | 420 } |
421 | 421 |
422 /* get the controlURL of the service */ | 422 /* get the controlURL of the service */ |
423 if((controlURLNode = xmlnode_get_child(serviceTypeNode, | 423 if((controlURLNode = xmlnode_get_child(serviceTypeNode, |
424 "controlURL")) == NULL) { | 424 "controlURL")) == NULL) { |
425 gaim_debug_error("upnp", | 425 gaim_debug_error("upnp", |
426 "parse_description_response(): Could not find controlURL\n\n"); | 426 "parse_description_response(): Could not find controlURL\n\n"); |
427 return NULL; | 427 return NULL; |
428 } | 428 } |
429 | 429 |
430 if(g_strstr_len(xmlnode_get_data(controlURLNode), | 430 if(g_strstr_len(xmlnode_get_data(controlURLNode), |
431 SIZEOF_HTTP, "http://") == NULL && | 431 SIZEOF_HTTP, "http://") == NULL && |
432 g_strstr_len(xmlnode_get_data(controlURLNode), | 432 g_strstr_len(xmlnode_get_data(controlURLNode), |
433 SIZEOF_HTTP, "HTTP://") == NULL) { | 433 SIZEOF_HTTP, "HTTP://") == NULL) { |
434 controlURL = g_strdup_printf("%s%s", baseURL, | 434 controlURL = g_strdup_printf("%s%s", baseURL, |
435 xmlnode_get_data(controlURLNode)); | 435 xmlnode_get_data(controlURLNode)); |
436 }else{ | 436 }else{ |
437 controlURL = g_strdup(xmlnode_get_data(controlURLNode)); | 437 controlURL = g_strdup(xmlnode_get_data(controlURLNode)); |
438 } | 438 } |
439 g_free(baseURL); | 439 g_free(baseURL); |
456 gchar* descriptionAddressPort; | 456 gchar* descriptionAddressPort; |
457 gchar* descriptionAddress; | 457 gchar* descriptionAddress; |
458 gchar descriptionPort[MAX_PORT_SIZE]; | 458 gchar descriptionPort[MAX_PORT_SIZE]; |
459 int port = 0; | 459 int port = 0; |
460 | 460 |
461 /* parse the 4 above variables out of the descriptionURL | 461 /* parse the 4 above variables out of the descriptionURL |
462 example description URL: http://192.168.1.1:5678/rootDesc.xml */ | 462 example description URL: http://192.168.1.1:5678/rootDesc.xml */ |
463 | 463 |
464 /* parse the url into address, port, path variables */ | 464 /* parse the url into address, port, path variables */ |
465 if(!gaim_url_parse(descriptionURL, &descriptionAddress, | 465 if(!gaim_url_parse(descriptionURL, &descriptionAddress, |
466 &port, &descriptionXMLAddress, NULL, NULL)) { | 466 &port, &descriptionXMLAddress, NULL, NULL)) { |
468 } | 468 } |
469 if(port == 0 || port == -1) { | 469 if(port == 0 || port == -1) { |
470 port = DEFAULT_HTTP_PORT; | 470 port = DEFAULT_HTTP_PORT; |
471 } | 471 } |
472 g_ascii_dtostr(descriptionPort, MAX_PORT_SIZE, port); | 472 g_ascii_dtostr(descriptionPort, MAX_PORT_SIZE, port); |
473 descriptionAddressPort = g_strdup_printf("%s:%s", descriptionAddress, | 473 descriptionAddressPort = g_strdup_printf("%s:%s", descriptionAddress, |
474 descriptionPort); | 474 descriptionPort); |
475 | 475 |
476 fullURL = g_strdup_printf("http://%s", descriptionAddressPort); | 476 fullURL = g_strdup_printf("http://%s", descriptionAddressPort); |
477 | 477 |
478 /* for example... | 478 /* for example... |
491 g_free(httpRequest); | 491 g_free(httpRequest); |
492 g_free(fullURL); | 492 g_free(fullURL); |
493 return NULL; | 493 return NULL; |
494 } | 494 } |
495 | 495 |
496 controlURL = gaim_upnp_parse_description_response(httpResponse, | 496 controlURL = gaim_upnp_parse_description_response(httpResponse, |
497 fullURL, serviceType); | 497 fullURL, serviceType); |
498 | 498 |
499 g_free(descriptionXMLAddress); | 499 g_free(descriptionXMLAddress); |
500 g_free(descriptionAddress); | 500 g_free(descriptionAddress); |
501 g_free(descriptionAddressPort); | 501 g_free(descriptionAddressPort); |
609 int sizeSent, totalSizeSent; | 609 int sizeSent, totalSizeSent; |
610 gchar wanIP[] = "WANIPConnection:1"; | 610 gchar wanIP[] = "WANIPConnection:1"; |
611 gchar wanPPP[] = "WANPPPConnection:1"; | 611 gchar wanPPP[] = "WANPPPConnection:1"; |
612 gchar* serviceToUse; | 612 gchar* serviceToUse; |
613 gchar* sendMessage = NULL; | 613 gchar* sendMessage = NULL; |
614 | 614 |
615 /* UDP RECEIVE VARIABLES */ | 615 /* UDP RECEIVE VARIABLES */ |
616 GaimUPnPControlInfo* controlInfo = g_malloc(sizeof(GaimUPnPControlInfo)); | 616 GaimUPnPControlInfo* controlInfo = g_malloc(sizeof(GaimUPnPControlInfo)); |
617 NetResponseData* nrd = g_malloc(sizeof(NetResponseData)); | 617 NetResponseData* nrd = g_malloc(sizeof(NetResponseData)); |
618 | 618 |
619 /* Set up the sockets */ | 619 /* Set up the sockets */ |
620 sock = socket(AF_INET, SOCK_DGRAM, 0); | 620 sock = socket(AF_INET, SOCK_DGRAM, 0); |
621 if (sock == -1) { | 621 if (sock == -1) { |
622 close(sock); | 622 close(sock); |
623 gaim_debug_error("upnp", | 623 gaim_debug_error("upnp", |
641 hp->h_length); | 641 hp->h_length); |
642 server.sin_port = htons(HTTPMU_HOST_PORT); | 642 server.sin_port = htons(HTTPMU_HOST_PORT); |
643 | 643 |
644 /* because we are sending over UDP, if there is a failure | 644 /* because we are sending over UDP, if there is a failure |
645 we should retry the send NUM_UDP_ATTEMPTS times. Also, | 645 we should retry the send NUM_UDP_ATTEMPTS times. Also, |
646 try different requests for WANIPConnection and | 646 try different requests for WANIPConnection and |
647 WANPPPConnection*/ | 647 WANPPPConnection*/ |
648 for(i = 0; i < NUM_UDP_ATTEMPTS; i++) { | 648 for(i = 0; i < NUM_UDP_ATTEMPTS; i++) { |
649 sentSuccess = TRUE; | 649 sentSuccess = TRUE; |
650 recvSuccess = TRUE; | 650 recvSuccess = TRUE; |
651 totalSizeSent = 0; | 651 totalSizeSent = 0; |
680 } | 680 } |
681 totalSizeSent += sizeSent; | 681 totalSizeSent += sizeSent; |
682 } | 682 } |
683 | 683 |
684 if(sentSuccess) { | 684 if(sentSuccess) { |
685 nrd->tima = gaim_timeout_add(DISCOVERY_TIMEOUT, | 685 nrd->tima = gaim_timeout_add(DISCOVERY_TIMEOUT, |
686 (GSourceFunc)gaim_upnp_timeout, nrd); | 686 (GSourceFunc)gaim_upnp_timeout, nrd); |
687 nrd->inpa = gaim_input_add(sock, GAIM_INPUT_READ, | 687 nrd->inpa = gaim_input_add(sock, GAIM_INPUT_READ, |
688 gaim_upnp_discover_udp_read, nrd); | 688 gaim_upnp_discover_udp_read, nrd); |
689 while (!nrd->done) { | 689 while (!nrd->done) { |
690 gtk_main_iteration(); | 690 g_main_context_iteration(NULL, TRUE); |
691 } | 691 } |
692 if(nrd->recvBuffer == NULL) { | 692 if(nrd->recvBuffer == NULL) { |
693 recvSuccess = FALSE; | 693 recvSuccess = FALSE; |
694 } else { | 694 } else { |
695 /* parse the response, and see if it was a success */ | 695 /* parse the response, and see if it was a success */ |
734 } | 734 } |
735 | 735 |
736 | 736 |
737 static char* | 737 static char* |
738 gaim_upnp_generate_action_message_and_send(const GaimUPnPControlInfo* controlInfo, | 738 gaim_upnp_generate_action_message_and_send(const GaimUPnPControlInfo* controlInfo, |
739 const gchar* actionName, | 739 const gchar* actionName, |
740 const gchar* actionParams) | 740 const gchar* actionParams) |
741 { | 741 { |
742 gchar* actionMessage; | 742 gchar* actionMessage; |
743 gchar* soapMessage; | 743 gchar* soapMessage; |
744 gchar* totalSendMessage; | 744 gchar* totalSendMessage; |
774 addressOfControl, portOfControl); | 774 addressOfControl, portOfControl); |
775 | 775 |
776 /* set the HTTP Header */ | 776 /* set the HTTP Header */ |
777 actionMessage = g_strdup_printf(HTTP_HEADER_ACTION, | 777 actionMessage = g_strdup_printf(HTTP_HEADER_ACTION, |
778 pathOfControl, addressPortOfControl, | 778 pathOfControl, addressPortOfControl, |
779 controlInfo->serviceType, actionName, | 779 controlInfo->serviceType, actionName, |
780 strlen(soapMessage)); | 780 strlen(soapMessage)); |
781 | 781 |
782 /* append to the header the body */ | 782 /* append to the header the body */ |
783 totalSendMessage = g_strdup_printf("%s%s", actionMessage, soapMessage); | 783 totalSendMessage = g_strdup_printf("%s%s", actionMessage, soapMessage); |
784 | 784 |
785 /* get the return of the http response */ | 785 /* get the return of the http response */ |
786 httpResponse = gaim_upnp_http_request(addressOfControl, | 786 httpResponse = gaim_upnp_http_request(addressOfControl, |
787 port, totalSendMessage); | 787 port, totalSendMessage); |
788 if(httpResponse == NULL) { | 788 if(httpResponse == NULL) { |
789 gaim_debug_error("upnp", | 789 gaim_debug_error("upnp", |
790 "generate_action_message_and_send(): Failed In httpResponse\n\n"); | 790 "generate_action_message_and_send(): Failed In httpResponse\n\n"); |
791 } | 791 } |
811 gchar actionName[] = "GetExternalIPAddress"; | 811 gchar actionName[] = "GetExternalIPAddress"; |
812 gchar actionParams[] = ""; | 812 gchar actionParams[] = ""; |
813 gchar* temp, *temp2; | 813 gchar* temp, *temp2; |
814 | 814 |
815 httpResponse = gaim_upnp_generate_action_message_and_send(controlInfo, | 815 httpResponse = gaim_upnp_generate_action_message_and_send(controlInfo, |
816 actionName, | 816 actionName, |
817 actionParams); | 817 actionParams); |
818 if(httpResponse == NULL) { | 818 if(httpResponse == NULL) { |
819 gaim_debug_error("upnp", | 819 gaim_debug_error("upnp", |
820 "gaim_upnp_get_public_ip(): Failed In httpResponse\n\n"); | 820 "gaim_upnp_get_public_ip(): Failed In httpResponse\n\n"); |
821 return NULL; | 821 return NULL; |
863 | 863 |
864 close(sock); | 864 close(sock); |
865 } | 865 } |
866 | 866 |
867 static gchar* | 867 static gchar* |
868 gaim_upnp_get_local_ip_address(const gchar* address) | 868 gaim_upnp_get_local_ip_address(const gchar* address) |
869 { | 869 { |
870 gchar* ip; | 870 gchar* ip; |
871 gchar* pathOfControl; | 871 gchar* pathOfControl; |
872 gchar* addressOfControl; | 872 gchar* addressOfControl; |
873 int port = 0; | 873 int port = 0; |
874 NetResponseData* nrd = (NetResponseData*)g_malloc0(sizeof(NetResponseData)); | 874 NetResponseData* nrd = (NetResponseData*)g_malloc0(sizeof(NetResponseData)); |
875 | 875 |
876 if(!gaim_url_parse(address, &addressOfControl, | 876 if(!gaim_url_parse(address, &addressOfControl, |
877 &port, &pathOfControl, NULL, NULL)) { | 877 &port, &pathOfControl, NULL, NULL)) { |
878 gaim_debug_error("upnp", | 878 gaim_debug_error("upnp", |
879 "get_local_ip_address(): Failed In Parse URL\n\n"); | 879 "get_local_ip_address(): Failed In Parse URL\n\n"); |
880 return NULL; | 880 return NULL; |
884 } | 884 } |
885 | 885 |
886 nrd->tima = gaim_timeout_add(RECEIVE_TIMEOUT, | 886 nrd->tima = gaim_timeout_add(RECEIVE_TIMEOUT, |
887 (GSourceFunc)gaim_upnp_timeout, nrd); | 887 (GSourceFunc)gaim_upnp_timeout, nrd); |
888 | 888 |
889 if(gaim_proxy_connect(NULL, addressOfControl, port, | 889 if(gaim_proxy_connect(NULL, addressOfControl, port, |
890 gaim_upnp_get_local_system_ip, nrd)) { | 890 gaim_upnp_get_local_system_ip, nrd)) { |
891 | 891 |
892 gaim_debug_error("upnp", "Get Local IP Connect Failed: Address: %s @@@ Port %d @@@ Request %s\n\n", | 892 gaim_debug_error("upnp", "Get Local IP Connect Failed: Address: %s @@@ Port %d @@@ Request %s\n\n", |
893 address, port, nrd->sendBuffer); | 893 address, port, nrd->sendBuffer); |
894 | 894 |
895 gaim_timeout_remove(nrd->tima); | 895 gaim_timeout_remove(nrd->tima); |
896 } else { | 896 } else { |
897 while (!nrd->done) { | 897 while (!nrd->done) { |
898 gtk_main_iteration(); | 898 g_main_context_iteration(NULL, TRUE); |
899 } | 899 } |
900 } | 900 } |
901 | 901 |
902 ip = nrd->recvBuffer; | 902 ip = nrd->recvBuffer; |
903 g_free(nrd); | 903 g_free(nrd); |
908 } | 908 } |
909 | 909 |
910 | 910 |
911 | 911 |
912 gboolean | 912 gboolean |
913 gaim_upnp_set_port_mapping(const GaimUPnPControlInfo* controlInfo, | 913 gaim_upnp_set_port_mapping(const GaimUPnPControlInfo* controlInfo, |
914 unsigned short portMap, | 914 unsigned short portMap, |
915 const gchar* protocol) | 915 const gchar* protocol) |
916 { | 916 { |
917 gchar* httpResponse; | 917 gchar* httpResponse; |
918 gchar actionName[] = "AddPortMapping"; | 918 gchar actionName[] = "AddPortMapping"; |
926 "gaim_upnp_set_port_mapping(): couldn't get local ip\n\n"); | 926 "gaim_upnp_set_port_mapping(): couldn't get local ip\n\n"); |
927 return FALSE; | 927 return FALSE; |
928 } | 928 } |
929 | 929 |
930 /* make the portMappingParams variable */ | 930 /* make the portMappingParams variable */ |
931 actionParams = g_strdup_printf(ADD_PORT_MAPPING_PARAMS, portMap, | 931 actionParams = g_strdup_printf(ADD_PORT_MAPPING_PARAMS, portMap, |
932 protocol, portMap, internalIP); | 932 protocol, portMap, internalIP); |
933 | 933 |
934 httpResponse = gaim_upnp_generate_action_message_and_send(controlInfo, | 934 httpResponse = gaim_upnp_generate_action_message_and_send(controlInfo, |
935 actionName, | 935 actionName, |
936 actionParams); | 936 actionParams); |
937 if(httpResponse == NULL) { | 937 if(httpResponse == NULL) { |
938 gaim_debug_error("upnp", | 938 gaim_debug_error("upnp", |
939 "gaim_upnp_set_port_mapping(): Failed In httpResponse\n\n"); | 939 "gaim_upnp_set_port_mapping(): Failed In httpResponse\n\n"); |
940 g_free(actionParams); | 940 g_free(actionParams); |
960 return TRUE; | 960 return TRUE; |
961 } | 961 } |
962 | 962 |
963 | 963 |
964 gboolean | 964 gboolean |
965 gaim_upnp_remove_port_mapping(const GaimUPnPControlInfo* controlInfo, | 965 gaim_upnp_remove_port_mapping(const GaimUPnPControlInfo* controlInfo, |
966 unsigned short portMap, | 966 unsigned short portMap, |
967 const char* protocol) | 967 const char* protocol) |
968 { | 968 { |
969 gchar* httpResponse; | 969 gchar* httpResponse; |
970 gchar actionName[] = "DeletePortMapping"; | 970 gchar actionName[] = "DeletePortMapping"; |
973 /* make the portMappingParams variable */ | 973 /* make the portMappingParams variable */ |
974 actionParams = g_strdup_printf(DELETE_PORT_MAPPING_PARAMS, | 974 actionParams = g_strdup_printf(DELETE_PORT_MAPPING_PARAMS, |
975 portMap, protocol); | 975 portMap, protocol); |
976 | 976 |
977 httpResponse = gaim_upnp_generate_action_message_and_send(controlInfo, | 977 httpResponse = gaim_upnp_generate_action_message_and_send(controlInfo, |
978 actionName, | 978 actionName, |
979 actionParams); | 979 actionParams); |
980 | 980 |
981 if(httpResponse == NULL) { | 981 if(httpResponse == NULL) { |
982 gaim_debug_error("upnp", | 982 gaim_debug_error("upnp", |
983 "gaim_upnp_remove_port_mapping(): Failed In httpResponse\n\n"); | 983 "gaim_upnp_remove_port_mapping(): Failed In httpResponse\n\n"); |