|
INET Framework for OMNeT++/OMNEST
|
This class implements a raw IPv6 socket.
More...
#include <Ipv6Socket.h>
This class implements a raw IPv6 socket.
◆ Ipv6Socket()
| inet::Ipv6Socket::Ipv6Socket |
( |
cGate * |
outputGate = nullptr | ) |
|
20 socketId(getEnvir()->getUniqueNumber()),
◆ ~Ipv6Socket()
| virtual inet::Ipv6Socket::~Ipv6Socket |
( |
| ) |
|
|
inlinevirtual |
◆ belongsToSocket()
| bool inet::Ipv6Socket::belongsToSocket |
( |
cMessage * |
msg | ) |
const |
|
overridevirtual |
Returns true if the message belongs to this socket.
Implements inet::ISocket.
32 auto&
tags = check_and_cast<ITaggedObject *>(msg)->getTags();
Referenced by processMessage().
◆ bind() [1/2]
63 auto *command =
new Ipv6SocketBindCommand();
65 command->setLocalAddress(localAddress);
67 request->setControlInfo(command);
◆ bind() [2/2]
| virtual void inet::Ipv6Socket::bind |
( |
const Protocol * |
protocol, |
|
|
L3Address |
localAddress |
|
) |
| |
|
inlineoverrideprotectedvirtual |
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.
Referenced by bind().
◆ close()
| void inet::Ipv6Socket::close |
( |
| ) |
|
|
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.
98 Ipv6SocketCloseCommand *command =
new Ipv6SocketCloseCommand();
100 request->setControlInfo(command);
◆ connect() [1/2]
| void inet::Ipv6Socket::connect |
( |
Ipv6Address |
remoteAddress | ) |
|
|
virtual |
76 auto *command =
new Ipv6SocketConnectCommand();
77 command->setRemoteAddress(remoteAddress);
79 request->setControlInfo(command);
◆ connect() [2/2]
| virtual void inet::Ipv6Socket::connect |
( |
L3Address |
remoteAddress | ) |
|
|
inlineoverrideprotectedvirtual |
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.
76 {
connect(remoteAddress.toIpv6()); }
Referenced by connect().
◆ destroy()
| void inet::Ipv6Socket::destroy |
( |
| ) |
|
|
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.
106 auto *command =
new Ipv6SocketDestroyCommand();
108 request->setControlInfo(command);
◆ getNetworkProtocol()
| virtual const Protocol* inet::Ipv6Socket::getNetworkProtocol |
( |
| ) |
const |
|
inlineoverridevirtual |
Returns the associated network protocol used to deliver datagrams by this socket.
Implements inet::INetworkSocket.
◆ getSocketId()
| virtual int inet::Ipv6Socket::getSocketId |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ getUserData()
| void* inet::Ipv6Socket::getUserData |
( |
| ) |
const |
|
inline |
◆ isOpen()
| virtual bool inet::Ipv6Socket::isOpen |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ processMessage()
| void inet::Ipv6Socket::processMessage |
( |
cMessage * |
msg | ) |
|
|
overridevirtual |
Examines the message, takes ownership, and updates socket state.
Implements inet::ISocket.
40 switch (msg->getKind()) {
48 check_and_cast<Indication *>(msg);
55 throw cRuntimeError(
"Ipv6Socket: invalid msg kind %d, one of the IPv6_I_xxx constants expected", msg->getKind());
◆ send()
| void inet::Ipv6Socket::send |
( |
Packet * |
packet | ) |
|
|
overridevirtual |
◆ sendTo() [1/2]
90 auto addressReq = packet->addTagIfAbsent<L3AddressReq>();
91 addressReq->setDestAddress(destAddress);
◆ sendTo() [2/2]
| virtual void inet::Ipv6Socket::sendTo |
( |
Packet * |
packet, |
|
|
L3Address |
remoteAddress |
|
) |
| |
|
inlineoverrideprotectedvirtual |
Sends a packet to the given remote address using the associated network protocol.
Implements inet::INetworkSocket.
77 {
sendTo(packet, destAddress.toIpv6()); }
Referenced by sendTo().
◆ sendToOutput()
| void inet::Ipv6Socket::sendToOutput |
( |
cMessage * |
message | ) |
|
|
protected |
115 throw cRuntimeError(
"Ipv6Socket: setOutputGate() must be invoked before the socket can be used");
116 auto&
tags = check_and_cast<ITaggedObject *>(message)->getTags();
118 tags.addTagIfAbsent<SocketReq>()->setSocketId(
socketId);
Referenced by bind(), close(), connect(), destroy(), and send().
◆ setCallback()
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.
◆ setOutputGate()
| void inet::Ipv6Socket::setOutputGate |
( |
cGate * |
outputGate | ) |
|
|
inline |
Sets the gate on which to send raw packets.
Must be invoked before socket can be used. Example: socket.setOutputGate(gate("ipOut"));
◆ setUserData()
| void inet::Ipv6Socket::setUserData |
( |
void * |
userData | ) |
|
|
inline |
◆ bound
| bool inet::Ipv6Socket::bound = false |
|
protected |
◆ callback
◆ isOpen_
| bool inet::Ipv6Socket::isOpen_ = false |
|
protected |
◆ outputGate
| cGate* inet::Ipv6Socket::outputGate = nullptr |
|
protected |
◆ socketId
| int inet::Ipv6Socket::socketId = -1 |
|
protected |
◆ userData
| void* inet::Ipv6Socket::userData = nullptr |
|
protected |
The documentation for this class was generated from the following files:
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down protocol
Definition: IUdp-gates.txt:25
virtual void send(Packet *packet) override
Definition: Ipv6Socket.cc:83
void * userData
Definition: Ipv6Socket.h:40
static const Protocol ipv6
Definition: Protocol.h:94
INetworkSocket::ICallback * callback
Definition: Ipv6Socket.h:39
virtual void socketClosed(INetworkSocket *socket)=0
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down DispatchProtocolReq
Definition: IUdp-gates.txt:25
cGate * outputGate
Definition: Ipv6Socket.h:41
virtual int getSocketId() const override
Returns the socket Id which is unique within the network node.
Definition: Ipv6Socket.h:60
virtual bool belongsToSocket(cMessage *msg) const override
Returns true if the message belongs to this socket.
Definition: Ipv6Socket.cc:30
@ IPv6_I_DATA
Definition: Ipv6SocketCommand_m.h:84
@ IPv6_C_CLOSE
Definition: Ipv6SocketCommand_m.h:66
virtual void connect(Ipv6Address remoteAddress)
Definition: Ipv6Socket.cc:73
virtual void socketDataArrived(INetworkSocket *socket, Packet *packet)=0
virtual void sendTo(Packet *packet, Ipv6Address destAddress)
Definition: Ipv6Socket.cc:88
@ IPv6_C_CONNECT
Definition: Ipv6SocketCommand_m.h:65
int socketId
Definition: Ipv6Socket.h:38
bool bound
Definition: Ipv6Socket.h:36
@ IPv6_C_DESTROY
Definition: Ipv6SocketCommand_m.h:67
@ IPv6_C_BIND
Definition: Ipv6SocketCommand_m.h:64
* tags
Definition: IUdp-gates.txt:3
bool isOpen_
Definition: Ipv6Socket.h:37
void sendToOutput(cMessage *message)
Definition: Ipv6Socket.cc:112
virtual void bind(const Protocol *protocol, Ipv6Address localAddress)
Definition: Ipv6Socket.cc:60
@ IPv6_I_SOCKET_CLOSED
Definition: Ipv6SocketCommand_m.h:85