1*1548c07cSAndrew GeisslerFrom 2a361989b5f84ec23ba7ccb6e527a5590ff55deb Mon Sep 17 00:00:00 2001 2*1548c07cSAndrew GeisslerFrom: Khem Raj <raj.khem@gmail.com> 3*1548c07cSAndrew GeisslerDate: Sun, 20 Jan 2019 23:11:56 -0800 4*1548c07cSAndrew GeisslerSubject: [PATCH] Fix building with libc++ 5*1548c07cSAndrew Geissler 6*1548c07cSAndrew GeisslerUpstream-Status: Pending 7*1548c07cSAndrew Geissler 8*1548c07cSAndrew GeisslerSigned-off-by: Khem Raj <raj.khem@gmail.com> 9*1548c07cSAndrew Geissler--- 10*1548c07cSAndrew Geissler nping/EchoServer.cc | 16 ++++++++-------- 11*1548c07cSAndrew Geissler 1 file changed, 8 insertions(+), 8 deletions(-) 12*1548c07cSAndrew Geissler 13*1548c07cSAndrew Geisslerdiff --git a/nping/EchoServer.cc b/nping/EchoServer.cc 14*1548c07cSAndrew Geisslerindex 40cd4d6..04433e1 100644 15*1548c07cSAndrew Geissler--- a/nping/EchoServer.cc 16*1548c07cSAndrew Geissler+++ b/nping/EchoServer.cc 17*1548c07cSAndrew Geissler@@ -282,14 +282,14 @@ int EchoServer::nep_listen_socket(){ 18*1548c07cSAndrew Geissler server_addr6.sin6_len = sizeof(struct sockaddr_in6); 19*1548c07cSAndrew Geissler #endif 20*1548c07cSAndrew Geissler /* Bind to local address and the specified port */ 21*1548c07cSAndrew Geissler- if( bind(master_sd, (struct sockaddr *)&server_addr6, sizeof(server_addr6)) != 0 ){ 22*1548c07cSAndrew Geissler+ if( ::bind(master_sd, (struct sockaddr *)&server_addr6, sizeof(server_addr6)) != 0 ){ 23*1548c07cSAndrew Geissler nping_warning(QT_3, "Failed to bind to source address %s. Trying to bind to port %d...", IPtoa(server_addr6.sin6_addr), port); 24*1548c07cSAndrew Geissler /* If the bind failed for the supplied address, just try again with in6addr_any */ 25*1548c07cSAndrew Geissler if( o.spoofSource() ){ 26*1548c07cSAndrew Geissler server_addr6.sin6_addr = in6addr_any; 27*1548c07cSAndrew Geissler- if( bind(master_sd, (struct sockaddr *)&server_addr6, sizeof(server_addr6)) != 0 ){ 28*1548c07cSAndrew Geissler+ if( ::bind(master_sd, (struct sockaddr *)&server_addr6, sizeof(server_addr6)) != 0 ){ 29*1548c07cSAndrew Geissler nping_fatal(QT_3, "Could not bind to port %d (%s).", port, strerror(errno)); 30*1548c07cSAndrew Geissler- }else{ 31*1548c07cSAndrew Geissler+ }else{ 32*1548c07cSAndrew Geissler nping_print(VB_1, "Server bound to port %d", port); 33*1548c07cSAndrew Geissler } 34*1548c07cSAndrew Geissler } 35*1548c07cSAndrew Geissler@@ -320,12 +320,12 @@ int EchoServer::nep_listen_socket(){ 36*1548c07cSAndrew Geissler #endif 37*1548c07cSAndrew Geissler 38*1548c07cSAndrew Geissler /* Bind to local address and the specified port */ 39*1548c07cSAndrew Geissler- if( bind(master_sd, (struct sockaddr *)&server_addr4, sizeof(server_addr4)) != 0 ){ 40*1548c07cSAndrew Geissler+ if( ::bind(master_sd, (struct sockaddr *)&server_addr4, sizeof(server_addr4)) != 0 ){ 41*1548c07cSAndrew Geissler nping_warning(QT_3, "Failed to bind to source address %s. Trying to bind to port %d...", IPtoa(server_addr4.sin_addr), port); 42*1548c07cSAndrew Geissler /* If the bind failed for the supplied address, just try again with in6addr_any */ 43*1548c07cSAndrew Geissler if( o.spoofSource() ){ 44*1548c07cSAndrew Geissler server_addr4.sin_addr.s_addr=INADDR_ANY; 45*1548c07cSAndrew Geissler- if( bind(master_sd, (struct sockaddr *)&server_addr4, sizeof(server_addr4)) != 0 ){ 46*1548c07cSAndrew Geissler+ if( ::bind(master_sd, (struct sockaddr *)&server_addr4, sizeof(server_addr4)) != 0 ){ 47*1548c07cSAndrew Geissler nping_fatal(QT_3, "Could not bind to port %d (%s).", port, strerror(errno)); 48*1548c07cSAndrew Geissler }else{ 49*1548c07cSAndrew Geissler nping_print(VB_1, "Server bound to port %d", port); 50*1548c07cSAndrew Geissler@@ -561,7 +561,7 @@ clientid_t EchoServer::nep_match_headers(IPv4Header *ip4, IPv6Header *ip6, TCPHe 51*1548c07cSAndrew Geissler nping_print(DBG_3, ";"); 52*1548c07cSAndrew Geissler /* The payload magic may affect the score only between 53*1548c07cSAndrew Geissler * zero and 4 bytes. This is done to prevent long 54*1548c07cSAndrew Geissler- * common strings like "GET / HTTP/1.1\r\n" 55*1548c07cSAndrew Geissler+ * common strings like "GET / HTTP/1.1\r\n" 56*1548c07cSAndrew Geissler * increasing the score a lot and cause problems for 57*1548c07cSAndrew Geissler * the matching logic. */ 58*1548c07cSAndrew Geissler current_score+= MIN(4, fspec->len)*FACTOR_PAYLOAD_MAGIC; 59*1548c07cSAndrew Geissler@@ -571,7 +571,7 @@ clientid_t EchoServer::nep_match_headers(IPv4Header *ip4, IPv6Header *ip6, TCPHe 60*1548c07cSAndrew Geissler default: 61*1548c07cSAndrew Geissler nping_warning(QT_2, "Bogus field specifier found in client #%d context. Please report a bug", ctx->getIdentifier()); 62*1548c07cSAndrew Geissler break; 63*1548c07cSAndrew Geissler- } 64*1548c07cSAndrew Geissler+ } 65*1548c07cSAndrew Geissler } /* End of field specifiers loop */ 66*1548c07cSAndrew Geissler 67*1548c07cSAndrew Geissler nping_print(DBG_3, "%s() current_score=%.02f candidate_score=%.02f", __func__, current_score, candidate_score); 68*1548c07cSAndrew Geissler@@ -650,7 +650,7 @@ clientid_t EchoServer::nep_match_packet(const u8 *pkt, size_t pktlen){ 69*1548c07cSAndrew Geissler }else{ 70*1548c07cSAndrew Geissler if( (tcplen=tcp.validate())==OP_FAILURE){ 71*1548c07cSAndrew Geissler return CLIENT_NOT_FOUND; 72*1548c07cSAndrew Geissler- }else{ 73*1548c07cSAndrew Geissler+ }else{ 74*1548c07cSAndrew Geissler if( (int)pktlen > (iplen+tcplen) ){ 75*1548c07cSAndrew Geissler if( payload.storeRecvData(pkt+iplen+tcplen, pktlen-iplen-tcplen)!=OP_FAILURE) 76*1548c07cSAndrew Geissler payload_included=true; 77