MCPcopy Create free account
hub / github.com/apache/trafficserver / lookup_address

Function lookup_address

tools/http_load/http_load.c:751–877  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

749}
750
751static void
752lookup_address(int url_num)
753{
754 if (do_proxy && url_num > 0) {
755 urls[url_num].sock_family = urls[url_num - 1].sock_family;
756 urls[url_num].sock_type = urls[url_num - 1].sock_type;
757 urls[url_num].sock_protocol = urls[url_num - 1].sock_protocol;
758 urls[url_num].sa_len = urls[url_num - 1].sa_len;
759 urls[url_num].sa = urls[url_num - 1].sa;
760 return;
761 }
762 int i;
763 char *hostname;
764 unsigned short port;
765#ifdef USE_IPV6
766 struct addrinfo hints;
767 char portstr[10];
768 int gaierr;
769 struct addrinfo *ai;
770 struct addrinfo *ai2;
771 struct addrinfo *aiv4;
772 struct addrinfo *aiv6;
773#else /* USE_IPV6 */
774 struct hostent *he;
775#endif /* USE_IPV6 */
776
777 urls[url_num].sa_len = sizeof(urls[url_num].sa);
778 (void)memset((void *)&urls[url_num].sa, 0, urls[url_num].sa_len);
779
780 if (do_proxy)
781 hostname = proxy_hostname;
782 else
783 hostname = urls[url_num].hostname;
784 if (do_proxy)
785 port = proxy_port;
786 else
787 port = urls[url_num].port;
788
789 /* Try to do this using existing information */
790 for (i = 0; i < url_num; i++) {
791 if ((strcmp(hostname, urls[i].hostname) == 0) && (port == urls[i].port)) {
792 urls[url_num].sock_family = urls[i].sock_family;
793 urls[url_num].sock_type = urls[i].sock_type;
794 urls[url_num].sock_protocol = urls[i].sock_protocol;
795 urls[url_num].sa = urls[i].sa;
796 urls[url_num].sa_len = urls[i].sa_len;
797 return;
798 }
799 }
800
801#ifdef USE_IPV6
802
803 (void)memset(&hints, 0, sizeof(hints));
804 hints.ai_family = PF_UNSPEC;
805 hints.ai_socktype = SOCK_STREAM;
806 (void)snprintf(portstr, sizeof(portstr), "%d", (int)port);
807 if ((gaierr = getaddrinfo(hostname, portstr, &hints, &ai)) != 0) {
808 (void)fprintf(stderr, "%s: getaddrinfo %s - %s\n", argv0, hostname, gai_strerror(gaierr));

Callers 1

read_url_fileFunction · 0.85

Calls 2

memsetFunction · 0.85
strcmpFunction · 0.85

Tested by

no test coverage detected