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