blob: ebeac88710d4655afee10f611f2df9177de10cd1 [file] [log] [blame]
Taoyu Li906553a2019-10-18 13:44:41 +09001// Copyright 2019 The Chromium OS 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
Garrick Evans3388a032020-03-24 11:25:55 +09005#include "patchpanel/ndproxy.h"
Taoyu Li906553a2019-10-18 13:44:41 +09006
Garrick Evans3388a032020-03-24 11:25:55 +09007namespace patchpanel {
Taoyu Li906553a2019-10-18 13:44:41 +09008
9namespace {
10
Taoyu Lie47df4a2019-11-08 12:48:57 +090011constexpr MacAddress guest_if_mac({0xd2, 0x47, 0xf7, 0xc5, 0x9e, 0x53});
Taoyu Li906553a2019-10-18 13:44:41 +090012
13extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
14 // Turn off logging.
15 logging::SetMinLogLevel(logging::LOG_FATAL);
16
Taoyu Li18041fe2019-11-13 15:49:31 +090017 uint8_t* out_buffer_extended = new uint8_t[size + 4];
18 uint8_t* out_buffer = NDProxy::AlignFrameBuffer(out_buffer_extended);
Taoyu Lie47df4a2019-11-08 12:48:57 +090019 NDProxy ndproxy;
20 ndproxy.Init();
21 ndproxy.TranslateNDFrame(data, size, guest_if_mac, out_buffer);
Taoyu Li2b9f0912020-10-13 18:16:59 +090022
23 memcpy(out_buffer, data, size);
Taoyu Lia0727dc2020-09-24 19:54:59 +090024 const nd_opt_prefix_info* prefix_info =
25 NDProxy::GetPrefixInfoOption(out_buffer, size);
26 // Just to consume GetPrefixInfoOption() output
27 if (prefix_info != nullptr)
28 out_buffer_extended[0] = prefix_info->nd_opt_pi_prefix_len;
Taoyu Li18041fe2019-11-13 15:49:31 +090029 delete[] out_buffer_extended;
Taoyu Li906553a2019-10-18 13:44:41 +090030
31 return 0;
32}
33
34} // namespace
Garrick Evans3388a032020-03-24 11:25:55 +090035} // namespace patchpanel