184 switch (msg->getKind()) {
186 UDPBindCommand *ctrl = check_and_cast<UDPBindCommand *>(msg->getControlInfo());
187 bind(ctrl->getSockId(), msg->getArrivalGate()->getIndex(), ctrl->getLocalAddr(), ctrl->getLocalPort());
192 UDPConnectCommand *ctrl = check_and_cast<UDPConnectCommand *>(msg->getControlInfo());
193 connect(ctrl->getSockId(), msg->getArrivalGate()->getIndex(), ctrl->getRemoteAddr(), ctrl->getRemotePort());
198 UDPCloseCommand *ctrl = check_and_cast<UDPCloseCommand *>(msg->getControlInfo());
199 close(ctrl->getSockId());
204 UDPSetOptionCommand *ctrl = check_and_cast<UDPSetOptionCommand *>(msg->getControlInfo());
205 SockDesc *sd =
getOrCreateSocket(ctrl->getSockId(), msg->getArrivalGate()->getIndex());
207 if (dynamic_cast<UDPSetTimeToLiveCommand *>(ctrl))
208 setTimeToLive(sd, ((UDPSetTimeToLiveCommand *)ctrl)->getTtl());
209 else if (dynamic_cast<UDPSetTypeOfServiceCommand *>(ctrl))
211 else if (dynamic_cast<UDPSetBroadcastCommand *>(ctrl))
212 setBroadcast(sd, ((UDPSetBroadcastCommand *)ctrl)->getBroadcast());
213 else if (dynamic_cast<UDPSetMulticastInterfaceCommand *>(ctrl))
215 else if (dynamic_cast<UDPSetMulticastLoopCommand *>(ctrl))
217 else if (dynamic_cast<UDPSetReuseAddressCommand *>(ctrl))
218 setReuseAddress(sd, ((UDPSetReuseAddressCommand *)ctrl)->getReuseAddress());
219 else if (dynamic_cast<UDPJoinMulticastGroupsCommand *>(ctrl)) {
220 UDPJoinMulticastGroupsCommand *cmd = (UDPJoinMulticastGroupsCommand *)ctrl;
221 std::vector<L3Address> addresses;
222 std::vector<int> interfaceIds;
223 for (
int i = 0; i < (int)cmd->getMulticastAddrArraySize(); i++)
224 addresses.push_back(cmd->getMulticastAddr(i));
225 for (
int i = 0; i < (int)cmd->getInterfaceIdArraySize(); i++)
226 interfaceIds.push_back(cmd->getInterfaceId(i));
229 else if (dynamic_cast<UDPLeaveMulticastGroupsCommand *>(ctrl)) {
230 UDPLeaveMulticastGroupsCommand *cmd = (UDPLeaveMulticastGroupsCommand *)ctrl;
231 std::vector<L3Address> addresses;
232 for (
int i = 0; i < (int)cmd->getMulticastAddrArraySize(); i++)
233 addresses.push_back(cmd->getMulticastAddr(i));
236 else if (dynamic_cast<UDPBlockMulticastSourcesCommand *>(ctrl)) {
237 UDPBlockMulticastSourcesCommand *cmd = (UDPBlockMulticastSourcesCommand *)ctrl;
239 std::vector<L3Address> sourceList;
240 for (
int i = 0; i < (int)cmd->getSourceListArraySize(); i++)
241 sourceList.push_back(cmd->getSourceList(i));
244 else if (dynamic_cast<UDPUnblockMulticastSourcesCommand *>(ctrl)) {
245 UDPUnblockMulticastSourcesCommand *cmd = (UDPUnblockMulticastSourcesCommand *)ctrl;
247 std::vector<L3Address> sourceList;
248 for (
int i = 0; i < (int)cmd->getSourceListArraySize(); i++)
249 sourceList.push_back(cmd->getSourceList(i));
252 else if (dynamic_cast<UDPJoinMulticastSourcesCommand *>(ctrl)) {
253 UDPJoinMulticastSourcesCommand *cmd = (UDPJoinMulticastSourcesCommand *)ctrl;
255 std::vector<L3Address> sourceList;
256 for (
int i = 0; i < (int)cmd->getSourceListArraySize(); i++)
257 sourceList.push_back(cmd->getSourceList(i));
260 else if (dynamic_cast<UDPLeaveMulticastSourcesCommand *>(ctrl)) {
261 UDPLeaveMulticastSourcesCommand *cmd = (UDPLeaveMulticastSourcesCommand *)ctrl;
263 std::vector<L3Address> sourceList;
264 for (
int i = 0; i < (int)cmd->getSourceListArraySize(); i++)
265 sourceList.push_back(cmd->getSourceList(i));
268 else if (dynamic_cast<UDPSetMulticastSourceFilterCommand *>(ctrl)) {
269 UDPSetMulticastSourceFilterCommand *cmd = (UDPSetMulticastSourceFilterCommand *)ctrl;
271 std::vector<L3Address> sourceList;
272 for (
int i = 0; i < (int)cmd->getSourceListArraySize(); i++)
273 sourceList.push_back(cmd->getSourceList(i));
277 throw cRuntimeError(
"Unknown subclass of UDPSetOptionCommand received from app: %s", ctrl->getClassName());
282 throw cRuntimeError(
"Unknown command code (message kind) %d received from app", msg->getKind());
virtual InterfaceEntry * getInterfaceById(int id) const =0
Returns an interface by its Id.
Definition: UDPControlInfo_m.h:61
virtual void setMulticastLoop(SockDesc *sd, bool loop)
Definition: UDP.cc:883
UDPSourceFilterMode
Enum generated from inet/transportlayer/contract/udp/UDPControlInfo.msg:331 by nedtool.
Definition: UDPControlInfo_m.h:1130
Definition: UDPControlInfo_m.h:60
IInterfaceTable * ift
Definition: UDP.h:105
virtual void setMulticastSourceFilter(SockDesc *sd, InterfaceEntry *ie, L3Address multicastAddress, UDPSourceFilterMode filterMode, const std::vector< L3Address > &sourceList)
Definition: UDP.cc:1115
virtual void setTimeToLive(SockDesc *sd, int ttl)
Definition: UDP.cc:863
virtual void close(int sockId)
Definition: UDP.cc:605
virtual void leaveMulticastSources(SockDesc *sd, InterfaceEntry *ie, L3Address multicastAddress, const std::vector< L3Address > &sourceList)
Definition: UDP.cc:1081
virtual void connect(int sockId, int gateIndex, const L3Address &remoteAddr, int remotePort)
Definition: UDP.cc:570
virtual void setTypeOfService(SockDesc *sd, int typeOfService)
Definition: UDP.cc:868
virtual void joinMulticastSources(SockDesc *sd, InterfaceEntry *ie, L3Address multicastAddress, const std::vector< L3Address > &sourceList)
Definition: UDP.cc:1046
virtual void setBroadcast(SockDesc *sd, bool broadcast)
Definition: UDP.cc:873
virtual void setReuseAddress(SockDesc *sd, bool reuseAddr)
Definition: UDP.cc:888
virtual void leaveMulticastGroups(SockDesc *sd, const std::vector< L3Address > &multicastAddresses)
Definition: UDP.cc:951
virtual void blockMulticastSources(SockDesc *sd, InterfaceEntry *ie, L3Address multicastAddress, const std::vector< L3Address > &sourceList)
Definition: UDP.cc:984
Definition: UDPControlInfo_m.h:62
virtual void joinMulticastGroups(SockDesc *sd, const std::vector< L3Address > &multicastAddresses, const std::vector< int > interfaceIds)
Definition: UDP.cc:893
virtual void bind(int sockId, int gateIndex, const L3Address &localAddr, int localPort)
Definition: UDP.cc:535
virtual SockDesc * getOrCreateSocket(int sockId, int gateIndex)
Definition: UDP.cc:850
virtual void setMulticastOutputInterface(SockDesc *sd, int interfaceId)
Definition: UDP.cc:878
Definition: UDPControlInfo_m.h:59