Cleanup: Use common IP overhead definitions in test and prod code
This avoid duplication. As part of this moving the overhead calculation to the IP address class so it's easier to find and more natural to use. Bug: webrtc:9883 Change-Id: If4d865f445bc1a302572896932966ce30294e339 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/169445 Commit-Queue: Sebastian Jansson <srte@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30657}
This commit is contained in:
committed by
Commit Bot
parent
61f74d91f8
commit
db5d7e470f
@ -9,17 +9,9 @@
|
||||
*/
|
||||
#include "api/test/network_emulation/network_emulation_interfaces.h"
|
||||
|
||||
#include "rtc_base/net_helper.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
namespace {
|
||||
constexpr int kIPv4HeaderSize = 20;
|
||||
constexpr int kIPv6HeaderSize = 40;
|
||||
constexpr int kUdpHeaderSize = 8;
|
||||
int IpHeaderSize(const rtc::SocketAddress& address) {
|
||||
return (address.family() == AF_INET) ? kIPv4HeaderSize : kIPv6HeaderSize;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
EmulatedIpPacket::EmulatedIpPacket(const rtc::SocketAddress& from,
|
||||
const rtc::SocketAddress& to,
|
||||
rtc::CopyOnWriteBuffer data,
|
||||
@ -28,7 +20,8 @@ EmulatedIpPacket::EmulatedIpPacket(const rtc::SocketAddress& from,
|
||||
: from(from),
|
||||
to(to),
|
||||
data(data),
|
||||
headers_size(IpHeaderSize(to) + application_overhead + kUdpHeaderSize),
|
||||
headers_size(to.ipaddr().overhead() + application_overhead +
|
||||
cricket::kUdpHeaderSize),
|
||||
arrival_time(arrival_time) {
|
||||
RTC_DCHECK(to.family() == AF_INET || to.family() == AF_INET6);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user