Skip to content

Commit

Permalink
todo
Browse files Browse the repository at this point in the history
  • Loading branch information
levy committed Sep 25, 2024
1 parent e8e32d2 commit 00b2242
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/inet/linklayer/ethernet/basic/EthernetCsmaMac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ void EthernetCsmaMac::processReceivedDataFrame(Packet *packet)
emit(packetSentToUpperSignal, packet);
// pass up to upper layer
EV_INFO << "Sending " << packet << " to upper layer.\n";
send(packet, "upperLayerOut");
upperLayerSink.pushPacket(packet);
}

void EthernetCsmaMac::processReceivedControlFrame(Packet *packet)
Expand Down
8 changes: 8 additions & 0 deletions src/inet/linklayer/ieee8022/Ieee8022Llc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -265,5 +265,13 @@ void Ieee8022Llc::handleCrashOperation(LifecycleOperation *operation)
clearSockets();
}

void Ieee8022Llc::pushPacket(Packet *packet, const cGate *gate)
{
Enter_Method("pushPacket");
take(packet);
packet->setArrival(getId(), gate->getId());
handleMessageWhenUp(packet);
}

} // namespace inet

12 changes: 11 additions & 1 deletion src/inet/linklayer/ieee8022/Ieee8022Llc.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@
#include "inet/common/packet/Packet.h"
#include "inet/linklayer/ieee8022/Ieee8022LlcHeader_m.h"
#include "inet/linklayer/ieee8022/Ieee8022SnapHeader_m.h"
#include "inet/queueing/contract/IPassivePacketSink.h"

namespace inet {

class INET_API Ieee8022Llc : public OperationalBase
using namespace inet::queueing;

class INET_API Ieee8022Llc : public OperationalBase, public IPassivePacketSink
{
protected:
struct SocketDescriptor {
Expand Down Expand Up @@ -57,6 +60,13 @@ class INET_API Ieee8022Llc : public OperationalBase
virtual void handleStopOperation(LifecycleOperation *operation) override;
virtual void handleCrashOperation(LifecycleOperation *operation) override;

virtual bool canPushSomePacket(const cGate *gate) const override { return gate->isName("appIn") || gate->isName("ipIn"); }
virtual bool canPushPacket(Packet *packet, const cGate *gate) const override { return gate->isName("appIn") || gate->isName("ipIn"); }
virtual void pushPacket(Packet *packet, const cGate *gate) override;
virtual void pushPacketStart(Packet *packet, const cGate *gate, bps datarate) override { throw cRuntimeError("TODO"); }
virtual void pushPacketEnd(Packet *packet, const cGate *gate) override { throw cRuntimeError("TODO"); }
virtual void pushPacketProgress(Packet *packet, const cGate *gate, bps datarate, b position, b extraProcessableLength = b(0)) override { throw cRuntimeError("TODO"); }

public:
virtual ~Ieee8022Llc();
static const Protocol *getProtocol(const Ptr<const Ieee8022LlcHeader>& header);
Expand Down
2 changes: 1 addition & 1 deletion src/inet/networklayer/ipv4/Ipv4.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1188,11 +1188,11 @@ void Ipv4::sendPacketToNIC(Packet *packet)
if (auto networkInterfaceProtocol = networkInterface->getProtocol())
ensureEncapsulationProtocolReq(packet, networkInterfaceProtocol, true, false);
setDispatchProtocol(packet);
queueSink.pushPacket(packet);
EV_INFO << "Sending datagram to lower layer";
if (auto dispatchProtocolReq = packet->findTag<DispatchProtocolReq>())
EV_INFO << EV_FIELD(protocol, *dispatchProtocolReq->getProtocol());
EV_INFO << EV_FIELD(interface, networkInterface->getInterfaceName()) << EV_FIELD(packet) << EV_ENDL;
queueSink.pushPacket(packet);
}

// NetFilter:
Expand Down
1 change: 1 addition & 0 deletions src/inet/transportlayer/contract/ITcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class INET_API ITcp
public:
virtual void handleEstablished() = 0;
virtual void handleAvailable(TcpAvailableInfo *availableInfo) = 0;
virtual void handlePeerClosed() = 0;
};

public:
Expand Down
2 changes: 0 additions & 2 deletions src/inet/transportlayer/contract/tcp/TcpSocket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ void TcpSocket::connect(L3Address remoteAddress, int remotePort)
if (remotePort < 0 || remotePort > 65535)
throw cRuntimeError("TcpSocket::connect(): invalid remote port number %d", remotePort);

auto request = new Request("ActiveOPEN", TCP_C_OPEN_ACTIVE);

remoteAddr = remoteAddress;
remotePrt = remotePort;

Expand Down
4 changes: 4 additions & 0 deletions src/inet/transportlayer/contract/tcp/TcpSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,10 @@ class INET_API TcpSocket : public ISocket, public ITcp::ICallback
virtual void handleAvailable(TcpAvailableInfo *availableInfo) override {
cb->socketAvailable(this, availableInfo);
}

virtual void handlePeerClosed() override {
cb->socketPeerClosed(this);
}
};

} // namespace inet
Expand Down
2 changes: 1 addition & 1 deletion src/inet/transportlayer/tcp/TcpConnectionBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ void TcpConnection::stateEntered(int state, int oldState, TcpEventCode event)
case TCP_S_FIN_WAIT_2:
case TCP_S_CLOSING:
if (!peerClosedSentUp && state == TCP_S_CLOSE_WAIT && this->receiveQueue->getQueueLength() == 0) {
sendIndicationToApp(TCP_I_PEER_CLOSED);
callback->handlePeerClosed();
peerClosedSentUp = true;
}
// whether connection setup succeeded (ESTABLISHED) or not (others),
Expand Down

0 comments on commit 00b2242

Please sign in to comment.