libpurple/protocols/bonjour/jabber.c

changeset 35554
fdd1f3a3c6df
parent 35499
c4c5e0a670b1
child 35578
e0826e3b631b
child 37111
efe4b7c5218a
equal deleted inserted replaced
35553:825d41ada522 35554:fdd1f3a3c6df
632 632
633 static void 633 static void
634 _server_socket_handler(gpointer data, int server_socket, PurpleInputCondition condition) 634 _server_socket_handler(gpointer data, int server_socket, PurpleInputCondition condition)
635 { 635 {
636 BonjourJabber *jdata = data; 636 BonjourJabber *jdata = data;
637 struct sockaddr_storage their_addr; /* connector's address information */ 637 common_sockaddr_t their_addr; /* connector's address information */
638 socklen_t sin_size = sizeof(struct sockaddr_storage); 638 socklen_t sin_size = sizeof(common_sockaddr_t);
639 int client_socket; 639 int client_socket;
640 int flags; 640 int flags;
641 #ifdef HAVE_INET_NTOP 641 #ifdef HAVE_INET_NTOP
642 char addrstr[INET6_ADDRSTRLEN]; 642 char addrstr[INET6_ADDRSTRLEN];
643 #endif 643 #endif
650 if (condition != PURPLE_INPUT_READ) 650 if (condition != PURPLE_INPUT_READ)
651 return; 651 return;
652 652
653 memset(&their_addr, 0, sin_size); 653 memset(&their_addr, 0, sin_size);
654 654
655 if ((client_socket = accept(server_socket, (struct sockaddr*)&their_addr, &sin_size)) == -1) 655 if ((client_socket = accept(server_socket, &their_addr.sa, &sin_size)) == -1)
656 return; 656 return;
657 657
658 flags = fcntl(client_socket, F_GETFL); 658 flags = fcntl(client_socket, F_GETFL);
659 fcntl(client_socket, F_SETFL, flags | O_NONBLOCK); 659 fcntl(client_socket, F_SETFL, flags | O_NONBLOCK);
660 #ifndef _WIN32 660 #ifndef _WIN32
661 fcntl(client_socket, F_SETFD, FD_CLOEXEC); 661 fcntl(client_socket, F_SETFD, FD_CLOEXEC);
662 #endif 662 #endif
663 663
664 /* Look for the buddy that has opened the conversation and fill information */ 664 /* Look for the buddy that has opened the conversation and fill information */
665 #ifdef HAVE_INET_NTOP 665 #ifdef HAVE_INET_NTOP
666 if (their_addr.ss_family == AF_INET6) { 666 if (their_addr.sa.sa_family == AF_INET6) {
667 address_text = inet_ntop(their_addr.ss_family, &((struct sockaddr_in6 *)&their_addr)->sin6_addr, 667 address_text = inet_ntop(their_addr.sa.sa_family,
668 addrstr, sizeof(addrstr)); 668 &their_addr.in6.sin6_addr, addrstr, sizeof(addrstr));
669 669
670 append_iface_if_linklocal(addrstr, 670 append_iface_if_linklocal(addrstr, their_addr.in6.sin6_scope_id);
671 ((struct sockaddr_in6 *)&their_addr)->sin6_scope_id); 671 } else {
672 } 672 address_text = inet_ntop(their_addr.sa.sa_family,
673 else 673 &their_addr.in.sin_addr, addrstr, sizeof(addrstr));
674 address_text = inet_ntop(their_addr.ss_family, &((struct sockaddr_in *)&their_addr)->sin_addr, 674 }
675 addrstr, sizeof(addrstr));
676 #else 675 #else
677 address_text = inet_ntoa(((struct sockaddr_in *)&their_addr)->sin_addr); 676 address_text = inet_ntoa(their_addr.in.sin_addr);
678 #endif 677 #endif
679 purple_debug_info("bonjour", "Received incoming connection from %s.\n", address_text); 678 purple_debug_info("bonjour", "Received incoming connection from %s.\n", address_text);
680 mbba = g_new0(struct _match_buddies_by_address_t, 1); 679 mbba = g_new0(struct _match_buddies_by_address_t, 1);
681 mbba->address = address_text; 680 mbba->address = address_text;
682 681

mercurial