blob: 002af7ba39d2f62eece50f67c5135d38c308575e [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 Lia0727dc2020-09-24 19:54:59 +090022 const nd_opt_prefix_info* prefix_info =
23 NDProxy::GetPrefixInfoOption(out_buffer, size);
24 // Just to consume GetPrefixInfoOption() output
25 if (prefix_info != nullptr)
26 out_buffer_extended[0] = prefix_info->nd_opt_pi_prefix_len;
Taoyu Li18041fe2019-11-13 15:49:31 +090027 delete[] out_buffer_extended;
Taoyu Li906553a2019-10-18 13:44:41 +090028
29 return 0;
30}
31
32} // namespace
Garrick Evans3388a032020-03-24 11:25:55 +090033} // namespace patchpanel