From: Amos Jeffries Date: Thu, 25 Sep 2014 13:33:18 +0000 (-0700) Subject: Windows: rename Ip::Address::*AddrInfo() methods X-Git-Tag: SQUID_3_5_0_1~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=851614a8d2a20591f8df4a24aa6c5cd364139d75;p=thirdparty%2Fsquid.git Windows: rename Ip::Address::*AddrInfo() methods On MinGW at least macro replacement appears to be case insensitive. The lower-case freeaddrinfo/initaddrinfo system functions are defined with macros, both in MinGW headers and Squid libcompat. --- diff --git a/src/clients/FtpGateway.cc b/src/clients/FtpGateway.cc index f6f439820c..254db92db6 100644 --- a/src/clients/FtpGateway.cc +++ b/src/clients/FtpGateway.cc @@ -1868,7 +1868,7 @@ ftpSendPORT(Ftp::Gateway * ftpState) ftpState->writeCommand(cbuf); ftpState->state = Ftp::Client::SENT_PORT; - Ip::Address::FreeAddrInfo(AI); + Ip::Address::FreeAddr(AI); } static void diff --git a/src/comm.cc b/src/comm.cc index bb0210c77f..659cd27c32 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -120,10 +120,10 @@ comm_udp_recvfrom(int fd, void *buf, size_t len, int flags, Ip::Address &from) ++ statCounter.syscalls.sock.recvfroms; debugs(5,8, "comm_udp_recvfrom: FD " << fd << " from " << from); struct addrinfo *AI = NULL; - Ip::Address::InitAddrInfo(AI); + Ip::Address::InitAddr(AI); int x = recvfrom(fd, buf, len, flags, AI->ai_addr, &AI->ai_addrlen); from = *AI; - Ip::Address::FreeAddrInfo(AI); + Ip::Address::FreeAddr(AI); return x; } @@ -173,16 +173,16 @@ comm_local_port(int fd) if (F->sock_family == AF_INET) temp.setIPv4(); - Ip::Address::InitAddrInfo(addr); + Ip::Address::InitAddr(addr); if (getsockname(fd, addr->ai_addr, &(addr->ai_addrlen)) ) { debugs(50, DBG_IMPORTANT, "comm_local_port: Failed to retrieve TCP/UDP port number for socket: FD " << fd << ": " << xstrerror()); - Ip::Address::FreeAddrInfo(addr); + Ip::Address::FreeAddr(addr); return 0; } temp = *addr; - Ip::Address::FreeAddrInfo(addr); + Ip::Address::FreeAddr(addr); if (F->local_addr.isAnyAddr()) { /* save the whole local address, not just the port. */ @@ -347,7 +347,7 @@ comm_openex(int sock_type, /* try again as IPv4-native if possible */ if ( new_socket < 0 && Ip::EnableIpv6 && addr.isIPv6() && addr.setIPv4() ) { /* attempt to open this IPv4-only. */ - Ip::Address::FreeAddrInfo(AI); + Ip::Address::FreeAddr(AI); /* Setup the socket addrinfo details for use */ addr.getAddrInfo(AI); AI->ai_socktype = sock_type; @@ -369,7 +369,7 @@ comm_openex(int sock_type, debugs(50, DBG_CRITICAL, "comm_open: socket failure: " << xstrerror()); } - Ip::Address::FreeAddrInfo(AI); + Ip::Address::FreeAddr(AI); PROF_stop(comm_open); return -1; @@ -393,7 +393,7 @@ comm_openex(int sock_type, comm_init_opened(conn, note, AI); new_socket = comm_apply_flags(conn->fd, addr, flags, AI); - Ip::Address::FreeAddrInfo(AI); + Ip::Address::FreeAddr(AI); PROF_stop(comm_open); @@ -680,7 +680,7 @@ comm_connect_addr(int sock, const Ip::Address &address) } - Ip::Address::FreeAddrInfo(AI); + Ip::Address::FreeAddr(AI); PROF_stop(comm_connect_addr); @@ -951,7 +951,7 @@ comm_udp_sendto(int fd, struct addrinfo *AI = NULL; to_addr.getAddrInfo(AI, fd_table[fd].sock_family); int x = sendto(fd, buf, len, 0, AI->ai_addr, AI->ai_addrlen); - Ip::Address::FreeAddrInfo(AI); + Ip::Address::FreeAddr(AI); PROF_stop(comm_udp_sendto); diff --git a/src/comm/ConnOpener.cc b/src/comm/ConnOpener.cc index 3247d74098..b8eb95244e 100644 --- a/src/comm/ConnOpener.cc +++ b/src/comm/ConnOpener.cc @@ -407,16 +407,16 @@ void Comm::ConnOpener::lookupLocalAddress() { struct addrinfo *addr = NULL; - Ip::Address::InitAddrInfo(addr); + Ip::Address::InitAddr(addr); if (getsockname(conn_->fd, addr->ai_addr, &(addr->ai_addrlen)) != 0) { debugs(50, DBG_IMPORTANT, "ERROR: Failed to retrieve TCP/UDP details for socket: " << conn_ << ": " << xstrerror()); - Ip::Address::FreeAddrInfo(addr); + Ip::Address::FreeAddr(addr); return; } conn_->local = *addr; - Ip::Address::FreeAddrInfo(addr); + Ip::Address::FreeAddr(addr); debugs(5, 6, HERE << conn_); } diff --git a/src/comm/TcpAcceptor.cc b/src/comm/TcpAcceptor.cc index a214cae158..995de5fabf 100644 --- a/src/comm/TcpAcceptor.cc +++ b/src/comm/TcpAcceptor.cc @@ -336,13 +336,13 @@ Comm::TcpAcceptor::oldAccept(Comm::ConnectionPointer &details) ++statCounter.syscalls.sock.accepts; int sock; struct addrinfo *gai = NULL; - Ip::Address::InitAddrInfo(gai); + Ip::Address::InitAddr(gai); errcode = 0; // reset local errno copy. if ((sock = accept(conn->fd, gai->ai_addr, &gai->ai_addrlen)) < 0) { errcode = errno; // store last accept errno locally. - Ip::Address::FreeAddrInfo(gai); + Ip::Address::FreeAddr(gai); PROF_stop(comm_accept); @@ -365,21 +365,21 @@ Comm::TcpAcceptor::oldAccept(Comm::ConnectionPointer &details) if ( Config.client_ip_max_connections >= 0) { if (clientdbEstablished(details->remote, 0) > Config.client_ip_max_connections) { debugs(50, DBG_IMPORTANT, "WARNING: " << details->remote << " attempting more than " << Config.client_ip_max_connections << " connections."); - Ip::Address::FreeAddrInfo(gai); + Ip::Address::FreeAddr(gai); return Comm::COMM_ERROR; } } // lookup the local-end details of this new connection - Ip::Address::InitAddrInfo(gai); + Ip::Address::InitAddr(gai); details->local.setEmpty(); if (getsockname(sock, gai->ai_addr, &gai->ai_addrlen) != 0) { debugs(50, DBG_IMPORTANT, "ERROR: getsockname() failed to locate local-IP on " << details << ": " << xstrerror()); - Ip::Address::FreeAddrInfo(gai); + Ip::Address::FreeAddr(gai); return Comm::COMM_ERROR; } details->local = *gai; - Ip::Address::FreeAddrInfo(gai); + Ip::Address::FreeAddr(gai); /* fdstat update */ // XXX : these are not all HTTP requests. use a note about type and ip:port details-> diff --git a/src/icmp/Icmp4.cc b/src/icmp/Icmp4.cc index 75a012f33a..02f19d33a1 100644 --- a/src/icmp/Icmp4.cc +++ b/src/icmp/Icmp4.cc @@ -146,7 +146,7 @@ Icmp4::SendEcho(Ip::Address &to, int opcode, const char *payload, int len) } Log(to, ' ', NULL, 0, 0); - Ip::Address::FreeAddrInfo(S); + Ip::Address::FreeAddr(S); } void @@ -170,7 +170,7 @@ Icmp4::Recv(void) if (pkt == NULL) pkt = (char *)xmalloc(MAX_PKT4_SZ); - Ip::Address::InitAddrInfo(from); + Ip::Address::InitAddr(from); n = recvfrom(icmp_sock, (void *)pkt, MAX_PKT4_SZ, @@ -180,7 +180,7 @@ Icmp4::Recv(void) if (n <= 0) { debugs(42, DBG_CRITICAL, HERE << "Error when calling recvfrom() on ICMP socket."); - Ip::Address::FreeAddrInfo(from); + Ip::Address::FreeAddr(from); return; } @@ -219,12 +219,12 @@ Icmp4::Recv(void) icmp = (struct icmphdr *) (void *) (pkt + iphdrlen); if (icmp->icmp_type != ICMP_ECHOREPLY) { - Ip::Address::FreeAddrInfo(from); + Ip::Address::FreeAddr(from); return; } if (icmp->icmp_id != icmp_ident) { - Ip::Address::FreeAddrInfo(from); + Ip::Address::FreeAddr(from); return; } @@ -242,14 +242,14 @@ Icmp4::Recv(void) if (preply.psize < 0) { debugs(42, DBG_CRITICAL, HERE << "Malformed ICMP packet."); - Ip::Address::FreeAddrInfo(from); + Ip::Address::FreeAddr(from); return; } control.SendResult(preply, (sizeof(pingerReplyData) - MAX_PKT4_SZ + preply.psize) ); Log(preply.from, icmp->icmp_type, IcmpPacketType(icmp->icmp_type), preply.rtt, preply.hops); - Ip::Address::FreeAddrInfo(from); + Ip::Address::FreeAddr(from); } #endif /* USE_ICMP */ diff --git a/src/icmp/Icmp6.cc b/src/icmp/Icmp6.cc index 07b3bd232e..d9e3627689 100644 --- a/src/icmp/Icmp6.cc +++ b/src/icmp/Icmp6.cc @@ -183,7 +183,7 @@ Icmp6::SendEcho(Ip::Address &to, int opcode, const char *payload, int len) debugs(42,9, HERE << "x=" << x); Log(to, 0, NULL, 0, 0); - Ip::Address::FreeAddrInfo(S); + Ip::Address::FreeAddr(S); } /** @@ -210,7 +210,7 @@ Icmp6::Recv(void) pkt = (char *)xmalloc(MAX_PKT6_SZ); } - Ip::Address::InitAddrInfo(from); + Ip::Address::InitAddr(from); n = recvfrom(icmp_sock, (void *)pkt, @@ -221,7 +221,7 @@ Icmp6::Recv(void) if (n <= 0) { debugs(42, DBG_CRITICAL, HERE << "Error when calling recvfrom() on ICMPv6 socket."); - Ip::Address::FreeAddrInfo(from); + Ip::Address::FreeAddr(from); return; } @@ -282,13 +282,13 @@ Icmp6::Recv(void) debugs(42, 8, HERE << preply.from << " said: " << icmp6header->icmp6_type << "/" << (int)icmp6header->icmp6_code << " " << IcmpPacketType(icmp6header->icmp6_type)); } - Ip::Address::FreeAddrInfo(from); + Ip::Address::FreeAddr(from); return; } if (icmp6header->icmp6_id != icmp_ident) { debugs(42, 8, HERE << "dropping Icmp6 read. IDENT check failed. ident=='" << icmp_ident << "'=='" << icmp6header->icmp6_id << "'"); - Ip::Address::FreeAddrInfo(from); + Ip::Address::FreeAddr(from); return; } @@ -325,7 +325,7 @@ Icmp6::Recv(void) /* send results of the lookup back to squid.*/ control.SendResult(preply, (sizeof(pingerReplyData) - PINGER_PAYLOAD_SZ + preply.psize) ); - Ip::Address::FreeAddrInfo(from); + Ip::Address::FreeAddr(from); } #endif /* USE_ICMP */ diff --git a/src/ip/Address.cc b/src/ip/Address.cc index 6bae054387..682a20b8d2 100644 --- a/src/ip/Address.cc +++ b/src/ip/Address.cc @@ -649,7 +649,7 @@ Ip::Address::getAddrInfo(struct addrinfo *&dst, int force) const } void -Ip::Address::InitAddrInfo(struct addrinfo *&ai) +Ip::Address::InitAddr(struct addrinfo *&ai) { if (ai == NULL) { ai = new addrinfo; @@ -667,7 +667,7 @@ Ip::Address::InitAddrInfo(struct addrinfo *&ai) } void -Ip::Address::FreeAddrInfo(struct addrinfo *&ai) +Ip::Address::FreeAddr(struct addrinfo *&ai) { if (ai == NULL) return; diff --git a/src/ip/Address.h b/src/ip/Address.h index 03d0fa0773..d8a6f12626 100644 --- a/src/ip/Address.h +++ b/src/ip/Address.h @@ -256,13 +256,13 @@ public: * Get RFC 3493 addrinfo structure from the Ip::Address data * for protocol-neutral socket operations. * Should be passed a NULL pointer of type struct addrinfo* it will - * allocate memory for the structures involved. (see FreeAddrInfo to clear). + * allocate memory for the structures involved. (see FreeAddr() to clear). * Defaults to a TCP streaming socket, if other values (such as UDP) are needed * the caller MUST override these default settings. * Some situations may also require an actual call to the system getaddrinfo() * to pull relevant OS details for the socket. \par - * Ip::Address allocated objects MUST be destructed by Ip::Address::FreeAddrInfo + * Ip::Address allocated objects MUST be destructed by Ip::Address::FreeAddr * System getaddrinfo() allocated objects MUST be freed with system freeaddrinfo() * \param ai structure to be filled out. @@ -273,7 +273,7 @@ public: /** * Equivalent to the sysem call freeaddrinfo() but for Ip::Address allocated data */ - static void FreeAddrInfo(struct addrinfo *&ai); + static void FreeAddr(struct addrinfo *&ai); /** * Initializes an empty addrinfo properly for use. @@ -281,7 +281,7 @@ public: * about to be changed and the stored details may not match the new ones coming. \param ai addrinfo struct to be initialized as AF_UNSPEC with large address buffer */ - static void InitAddrInfo(struct addrinfo *&ai); + static void InitAddr(struct addrinfo *&ai); /** * Lookup a Host by Name. Equivalent to system call gethostbyname(char*) diff --git a/src/ip/testAddress.cc b/src/ip/testAddress.cc index 59147f9a87..182963cbc8 100644 --- a/src/ip/testAddress.cc +++ b/src/ip/testAddress.cc @@ -713,7 +713,7 @@ testIpAddress::testAddrInfo() CPPUNIT_ASSERT( memcmp( expect->ai_addr, ipval->ai_addr, expect->ai_addrlen ) == 0 ); freeaddrinfo(expect); - Ip::Address::FreeAddrInfo(ipval); + Ip::Address::FreeAddr(ipval); } void diff --git a/src/ipc.cc b/src/ipc.cc index 8da31cb3ec..0b6ecc0db1 100644 --- a/src/ipc.cc +++ b/src/ipc.cc @@ -183,10 +183,10 @@ ipcCreate(int type, const char *prog, const char *const args[], const char *name debugs(54, 3, "ipcCreate: cwfd FD " << cwfd); if (type == IPC_TCP_SOCKET || type == IPC_UDP_SOCKET) { - Ip::Address::InitAddrInfo(AI); + Ip::Address::InitAddr(AI); if (getsockname(pwfd, AI->ai_addr, &AI->ai_addrlen) < 0) { - Ip::Address::FreeAddrInfo(AI); + Ip::Address::FreeAddr(AI); debugs(54, DBG_CRITICAL, "ipcCreate: getsockname: " << xstrerror()); return ipcCloseAllFD(prfd, pwfd, crfd, cwfd); } @@ -195,19 +195,19 @@ ipcCreate(int type, const char *prog, const char *const args[], const char *name debugs(54, 3, "ipcCreate: FD " << pwfd << " sockaddr " << PaS); - Ip::Address::FreeAddrInfo(AI); + Ip::Address::FreeAddr(AI); - Ip::Address::InitAddrInfo(AI); + Ip::Address::InitAddr(AI); if (getsockname(crfd, AI->ai_addr, &AI->ai_addrlen) < 0) { - Ip::Address::FreeAddrInfo(AI); + Ip::Address::FreeAddr(AI); debugs(54, DBG_CRITICAL, "ipcCreate: getsockname: " << xstrerror()); return ipcCloseAllFD(prfd, pwfd, crfd, cwfd); } ChS = *AI; - Ip::Address::FreeAddrInfo(AI); + Ip::Address::FreeAddr(AI); debugs(54, 3, "ipcCreate: FD " << crfd << " sockaddr " << ChS ); diff --git a/src/ipc/SharedListen.cc b/src/ipc/SharedListen.cc index ecda01edd2..481f7b956e 100644 --- a/src/ipc/SharedListen.cc +++ b/src/ipc/SharedListen.cc @@ -152,7 +152,7 @@ void Ipc::SharedListenJoined(const SharedListenResponse &response) AI->ai_socktype = p.sock_type; AI->ai_protocol = p.proto; comm_import_opened(cbd->conn, FdNote(p.fdNote), AI); - Ip::Address::FreeAddrInfo(AI); + Ip::Address::FreeAddr(AI); } cbd->errNo = response.errNo; diff --git a/src/ipc/UdsOp.cc b/src/ipc/UdsOp.cc index 64be8c12a8..393d46b41f 100644 --- a/src/ipc/UdsOp.cc +++ b/src/ipc/UdsOp.cc @@ -202,7 +202,7 @@ Ipc::ImportFdIntoComm(const Comm::ConnectionPointer &conn, int socktype, int pro addr_info->ai_socktype = socktype; addr_info->ai_protocol = protocol; comm_import_opened(conn, Ipc::FdNote(noteId), addr_info); - Ip::Address::FreeAddrInfo(addr_info); + Ip::Address::FreeAddr(addr_info); } else { debugs(54, DBG_CRITICAL, "ERROR: Ipc::ImportFdIntoComm: " << conn << ' ' << xstrerror()); conn->close(); diff --git a/src/ipc_win32.cc b/src/ipc_win32.cc index 34fde64ee3..729407be38 100644 --- a/src/ipc_win32.cc +++ b/src/ipc_win32.cc @@ -180,30 +180,30 @@ ipcCreate(int type, const char *prog, const char *const args[], const char *name // AYJ: these flags should be neutral, but if not IPv6 version needs adding if (type == IPC_TCP_SOCKET || type == IPC_UDP_SOCKET) { - Ip::Address::InitAddrInfo(aiPS); + Ip::Address::InitAddr(aiPS); if (getsockname(pwfd, aiPS->ai_addr, &(aiPS->ai_addrlen) ) < 0) { debugs(54, DBG_CRITICAL, "ipcCreate: getsockname: " << xstrerror()); - Ip::Address::FreeAddrInfo(aiPS); + Ip::Address::FreeAddr(aiPS); return ipcCloseAllFD(prfd, pwfd, crfd, cwfd); } tmp_addr = *aiPS; - Ip::Address::FreeAddrInfo(aiPS); + Ip::Address::FreeAddr(aiPS); debugs(54, 3, "ipcCreate: FD " << pwfd << " sockaddr " << tmp_addr ); - Ip::Address::InitAddrInfo(aiCS); + Ip::Address::InitAddr(aiCS); if (getsockname(crfd, aiCS->ai_addr, &(aiCS->ai_addrlen) ) < 0) { debugs(54, DBG_CRITICAL, "ipcCreate: getsockname: " << xstrerror()); - Ip::Address::FreeAddrInfo(aiCS); + Ip::Address::FreeAddr(aiCS); return ipcCloseAllFD(prfd, pwfd, crfd, cwfd); } tmp_addr.setEmpty(); tmp_addr = *aiCS; - Ip::Address::FreeAddrInfo(aiCS); + Ip::Address::FreeAddr(aiCS); debugs(54, 3, "ipcCreate: FD " << crfd << " sockaddr " << tmp_addr ); } @@ -464,31 +464,31 @@ ipc_thread_1(void *in_params) goto cleanup; } - Ip::Address::InitAddrInfo(aiPS_ipc); + Ip::Address::InitAddr(aiPS_ipc); if (getsockname(pwfd_ipc, aiPS_ipc->ai_addr, &(aiPS_ipc->ai_addrlen)) < 0) { debugs(54, DBG_CRITICAL, "ipcCreate: getsockname: " << xstrerror()); ipcSend(cwfd, err_string, strlen(err_string)); - Ip::Address::FreeAddrInfo(aiPS_ipc); + Ip::Address::FreeAddr(aiPS_ipc); goto cleanup; } PS_ipc = *aiPS_ipc; - Ip::Address::FreeAddrInfo(aiPS_ipc); + Ip::Address::FreeAddr(aiPS_ipc); debugs(54, 3, "ipcCreate: FD " << pwfd_ipc << " sockaddr " << PS_ipc); - Ip::Address::InitAddrInfo(aiCS_ipc); + Ip::Address::InitAddr(aiCS_ipc); if (getsockname(crfd_ipc, aiCS_ipc->ai_addr, &(aiCS_ipc->ai_addrlen)) < 0) { debugs(54, DBG_CRITICAL, "ipcCreate: getsockname: " << xstrerror()); ipcSend(cwfd, err_string, strlen(err_string)); - Ip::Address::FreeAddrInfo(aiCS_ipc); + Ip::Address::FreeAddr(aiCS_ipc); goto cleanup; } CS_ipc = *aiCS_ipc; - Ip::Address::FreeAddrInfo(aiCS_ipc); + Ip::Address::FreeAddr(aiCS_ipc); debugs(54, 3, "ipcCreate: FD " << crfd_ipc << " sockaddr " << CS_ipc); diff --git a/src/tools.cc b/src/tools.cc index 83e9cb4e6c..178102de76 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -481,13 +481,13 @@ getMyHostname(void) present = 1; - Ip::Address::FreeAddrInfo(AI); + Ip::Address::FreeAddr(AI); if (strchr(host, '.')) return host; } - Ip::Address::FreeAddrInfo(AI); + Ip::Address::FreeAddr(AI); debugs(50, 2, "WARNING: failed to resolve " << sa << " to a fully qualified hostname"); } diff --git a/tools/cachemgr.cc b/tools/cachemgr.cc index b852f11f18..c77df831ef 100644 --- a/tools/cachemgr.cc +++ b/tools/cachemgr.cc @@ -822,7 +822,7 @@ process_request(cachemgr_request * req) #endif snprintf(buf, sizeof(buf), "socket: %s\n", xstrerror()); error_html(buf); - Ip::Address::FreeAddrInfo(AI); + Ip::Address::FreeAddr(AI); return 1; } @@ -831,12 +831,12 @@ process_request(cachemgr_request * req) S.toUrl(ipbuf,MAX_IPSTRLEN), xstrerror()); error_html(buf); - Ip::Address::FreeAddrInfo(AI); + Ip::Address::FreeAddr(AI); close(s); return 1; } - Ip::Address::FreeAddrInfo(AI); + Ip::Address::FreeAddr(AI); l = snprintf(buf, sizeof(buf), "GET cache_object://%s/%s%s%s HTTP/1.0\r\n" diff --git a/tools/squidclient/Transport.cc b/tools/squidclient/Transport.cc index 1abeada100..ac18f8fa6b 100644 --- a/tools/squidclient/Transport.cc +++ b/tools/squidclient/Transport.cc @@ -139,7 +139,7 @@ client_comm_bind(int sock, const Ip::Address &addr) static struct addrinfo *AI = NULL; addr.getAddrInfo(AI); int res = bind(sock, AI->ai_addr, AI->ai_addrlen); - Ip::Address::FreeAddrInfo(AI); + Ip::Address::FreeAddr(AI); return res; } @@ -168,10 +168,10 @@ resolveDestination(Ip::Address &iaddr) iaddr.getAddrInfo(AI); if ((conn = socket(AI->ai_family, AI->ai_socktype, 0)) < 0) { std::cerr << "ERROR: could not open socket to " << iaddr << std::endl; - Ip::Address::FreeAddrInfo(AI); + Ip::Address::FreeAddr(AI); exit(1); } - Ip::Address::FreeAddrInfo(AI); + Ip::Address::FreeAddr(AI); if (Transport::Config.localHost) { if (client_comm_bind(conn, iaddr) < 0) { @@ -199,7 +199,7 @@ client_comm_connect(int sock, const Ip::Address &addr) static struct addrinfo *AI = NULL; addr.getAddrInfo(AI); int res = connect(sock, AI->ai_addr, AI->ai_addrlen); - Ip::Address::FreeAddrInfo(AI); + Ip::Address::FreeAddr(AI); Ping::TimerStart(); return res; }