1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "net/quic/quic_address_mismatch.h"
7 #include "net/base/ip_endpoint.h"
11 int GetAddressMismatch(const IPEndPoint
& first_address
,
12 const IPEndPoint
& second_address
) {
13 if (first_address
.address().empty() || second_address
.address().empty()) {
18 if (first_address
.address() != second_address
.address()) {
19 sample
= QUIC_ADDRESS_MISMATCH_BASE
;
20 } else if (first_address
.port() != second_address
.port()) {
21 sample
= QUIC_PORT_MISMATCH_BASE
;
23 sample
= QUIC_ADDRESS_AND_PORT_MATCH_BASE
;
26 // Add an offset to |sample|:
31 bool first_ipv4
= (first_address
.address().size() == kIPv4AddressSize
);
32 bool second_ipv4
= (second_address
.address().size() == kIPv4AddressSize
);
33 if (first_ipv4
!= second_ipv4
) {
34 CHECK_EQ(sample
, QUIC_ADDRESS_MISMATCH_BASE
);