|
INET Framework for OMNeT++/OMNEST
|
This class implements a raw L3 socket. More...
#include <L3Socket.h>
Classes | |
| class | ICallback |
Public Member Functions | |
| L3Socket (const Protocol *l3Protocol, cGate *outputGate=nullptr) | |
| virtual | ~L3Socket () |
| void | setOutputGate (cGate *outputGate) |
| Sets the gate on which to send raw packets. More... | |
| virtual void | setCallback (INetworkSocket::ICallback *callback) override |
| Sets a callback object, to be used with processMessage(). More... | |
| void * | getUserData () const |
| void | setUserData (void *userData) |
| virtual int | getSocketId () const override |
| Returns the socket Id which is unique within the network node. More... | |
| virtual const Protocol * | getNetworkProtocol () const override |
| Returns the associated network protocol used to deliver datagrams by this socket. More... | |
| virtual bool | belongsToSocket (cMessage *msg) const override |
| Returns true if the message belongs to this socket. More... | |
| virtual void | processMessage (cMessage *msg) override |
| Examines the message, takes ownership, and updates socket state. More... | |
| virtual void | bind (const Protocol *protocol, L3Address localAddress) override |
| Binds this socket to the given protocol and local address. More... | |
| virtual void | connect (L3Address remoteAddress) override |
| Connects to a remote socket. More... | |
| virtual void | send (Packet *packet) override |
| virtual void | sendTo (Packet *packet, L3Address destAddress) override |
| Sends a packet to the given remote address using the associated network protocol. More... | |
| virtual void | close () override |
| Closes this socket releasing all resources. More... | |
| virtual void | destroy () override |
| Notify the protocol that the owner of ISocket has destroyed the socket. More... | |
| virtual bool | isOpen () const override |
Public Member Functions inherited from inet::ISocket | |
| virtual | ~ISocket () |
Protected Member Functions | |
| void | sendToOutput (cMessage *message) |
Protected Attributes | |
| bool | bound = false |
| bool | isOpen_ = false |
| const Protocol * | l3Protocol = nullptr |
| int | socketId = -1 |
| INetworkSocket::ICallback * | callback = nullptr |
| void * | userData = nullptr |
| cGate * | outputGate = nullptr |
This class implements a raw L3 socket.
| inet::L3Socket::L3Socket | ( | const Protocol * | l3Protocol, |
| cGate * | outputGate = nullptr |
||
| ) |
|
overridevirtual |
Returns true if the message belongs to this socket.
Implements inet::ISocket.
Referenced by processMessage().
Binds this socket to the given protocol and local address.
All incoming packets matching the given parameters will be delivered via the callback interface.
Implements inet::INetworkSocket.
|
overridevirtual |
Closes this socket releasing all resources.
Once closed, a closed socket may be bound to another (or the same) protocol, and reused.
Implements inet::INetworkSocket.
|
overridevirtual |
Connects to a remote socket.
The socket will only receive packets from the specified address, and you can use send() as opposed to sendTo() to send packets.
Implements inet::INetworkSocket.
|
overridevirtual |
Notify the protocol that the owner of ISocket has destroyed the socket.
Typically used when the owner of ISocket has crashed.
Implements inet::ISocket.
|
inlineoverridevirtual |
Returns the associated network protocol used to deliver datagrams by this socket.
Implements inet::INetworkSocket.
|
inlineoverridevirtual |
Returns the socket Id which is unique within the network node.
Implements inet::ISocket.
Referenced by belongsToSocket().
|
inline |
|
inlineoverridevirtual |
Implements inet::ISocket.
|
overridevirtual |
Examines the message, takes ownership, and updates socket state.
Implements inet::ISocket.
|
overridevirtual |
Sends a packet to the given remote address using the associated network protocol.
Implements inet::INetworkSocket.
|
protected |
|
overridevirtual |
Sets a callback object, to be used with processMessage().
This callback object may be your simple module itself (if it multiply inherits from ICallback too, that is you declared it as
class MyAppModule : public cSimpleModule, public ICallback
and redefined the necessary virtual functions; or you may use dedicated class (and objects) for this purpose.
Sockets don't delete the callback object in the destructor or on any other occasion.
Implements inet::INetworkSocket.
|
inline |
Sets the gate on which to send raw packets.
Must be invoked before socket can be used. Example: socket.setOutputGate(gate("ipOut"));
|
protected |
Referenced by bind(), close(), and processMessage().
|
protected |
Referenced by processMessage(), and setCallback().
|
protected |
Referenced by bind(), connect(), and processMessage().
|
protected |
Referenced by bind(), close(), destroy(), and sendToOutput().
|
protected |
Referenced by sendToOutput().
|
protected |
Referenced by belongsToSocket(), and sendToOutput().
|
protected |