add ports

This commit is contained in:
Robert 2023-07-02 13:53:56 +02:00
parent dc966782b5
commit 89fcef5619
5 changed files with 52 additions and 0 deletions

View file

@ -3,7 +3,10 @@
#include <sstream>
#include <iostream>
#include "Port.hpp"
Device::Device(const std::string& macAddress) {
port = std::make_shared<Port>();
parseAndSetMac(macAddress);
}

23
netsim/src/Port.cpp Normal file
View file

@ -0,0 +1,23 @@
#include "Port.hpp"
Port::Port()
{
}
void Port::Connect(std::shared_ptr<Port> port) {
this->connection = std::weak_ptr<Port>(port);
}
void Port::Send(const std::vector<uint8_t>& data) {
this->data = data;
}
std::vector<uint8_t> Port::Receive() {
if (this->connection.expired()) {
return {};
}
std::shared_ptr<Port> other_port = connection.lock();
return other_port->data;
}