2 * Copyright 2018 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
23 #include "include/link.h"
24 #include "include/phy.h"
25 #include "packets/link_layer/link_layer_packet_view.h"
26 #include "polled_socket.h"
28 namespace test_vendor_lib {
30 class LinkLayerSocketDevice : public Device {
32 LinkLayerSocketDevice(int socket_fd, Phy::Type phy_type);
33 LinkLayerSocketDevice(LinkLayerSocketDevice&& s) = default;
34 virtual ~LinkLayerSocketDevice() = default;
36 static std::shared_ptr<Device> Create(int socket_fd, Phy::Type phy_type) {
37 return std::make_shared<LinkLayerSocketDevice>(socket_fd, phy_type);
40 virtual std::string GetTypeString() const override {
41 return "link_layer_socket_device";
44 virtual void Initialize(const std::vector<std::string>&) override {}
46 virtual void IncomingPacket(packets::LinkLayerPacketView packet) override;
48 virtual void TimerTick() override;
51 net::PolledSocket socket_;
53 size_t bytes_left_{0};
55 std::shared_ptr<std::vector<uint8_t>> received_;
56 std::vector<packets::LinkLayerPacketView> packet_queue_;
59 } // namespace test_vendor_lib