blob: 5df158d87f9c94c440179873fdc27e5398d30381 [file] [log] [blame]
wubf975eac2019-08-19 19:41:01 -07001// Copyright (c) 2019 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.
4
QUICHE team5be974e2020-12-29 18:35:24 -05005#include "quic/qbone/qbone_packet_processor_test_tools.h"
wubf975eac2019-08-19 19:41:01 -07006
7#include <netinet/ip6.h>
8
9namespace quic {
10
QUICHE teamb80d7c32020-02-23 23:44:20 -080011std::string PrependIPv6HeaderForTest(const std::string& body, int hops) {
wubf975eac2019-08-19 19:41:01 -070012 ip6_hdr header;
13 memset(&header, 0, sizeof(header));
14
15 header.ip6_vfc = 6 << 4;
16 header.ip6_plen = htons(body.size());
17 header.ip6_nxt = IPPROTO_UDP;
18 header.ip6_hops = hops;
19 header.ip6_src = in6addr_loopback;
20 header.ip6_dst = in6addr_loopback;
21
QUICHE teamb80d7c32020-02-23 23:44:20 -080022 std::string packet(sizeof(header) + body.size(), '\0');
wubf975eac2019-08-19 19:41:01 -070023 memcpy(&packet[0], &header, sizeof(header));
24 memcpy(&packet[sizeof(header)], body.data(), body.size());
25 return packet;
26}
27
28} // namespace quic