std::vector<SystemCmd> IfAddrs::asCommands(const std::string &dev) const { // LOG(INFO) << "asCommands:1"; std::vector<SystemCmd> ret; for (auto &dst : getDests()) { //LOG(INFO) << "asCommands:1a"; // missing ipv4 ipv6 sorting for (auto &addr : addrs) { if (!dst.ip_same_kind(addr)) { continue; } if (addr.includes(dst)) { //LOG(INFO) << "asCommands:2"; ret.push_back(SystemCmd("/sbin/ifconfig").arg(dev).arg(addr.to_s()).arg(dst.to_s())); } else { ret.push_back(SystemCmd("/sbin/ifconfig").arg(dev).arg("alias").arg(addr.to_string())); } } } //LOG(INFO) << "asCommands:3"; for (auto &route : routes) { //LOG(INFO) << "asCommands:4"; ret.push_back(SystemCmd("/sbin/route").arg("add") .arg(route.dest.to_string()).arg(route.via.to_s()) .arg("-ifscope").arg(dev)); } //LOG(INFO) << "asCommands:5"; ret.push_back(SystemCmd("/sbin/ifconfig").arg(dev) .arg("mtu").arg(mtu).arg("up")); //LOG(INFO) << "asCommands:6"; return ret; }
bool TUIClientApp::connectWithTUIServer( int mySendPortNr, int myReceivePortNr, const std::string & serverAddress, IEventSink * systemNotificationSink, bool ownership) { this->myReceivePortNr = myReceivePortNr; this->systemNotificationSink = systemNotificationSink; this->outHostMsgDispatcher.addDstAddress(HostAddress(serverAddress)); this->udpSenderSocket.setMyPort(mySendPortNr); this->udpReceiverSocket.setMyPort(myReceivePortNr); this->create(); SystemCmdMsg * msg = new SystemCmdMsg(); msg->setPayload(SystemCmd(SystemCmd::requestConnection, static_cast<unsigned short>(this->myReceivePortNr))); this->outEventQueue.push(msg); if (ownership) { this->executeOutputLoop(); } return true; }
void TUIClientApp::handleMulticastGroupInvitationMsg(MulticastGroupInvitationMsg * event) { TFDEBUG("TUIClientApp::handleMulticastGroupInvitationMsg " << event); const HostAddress & address = event->getPayload(); this->multicastListener.setMCGroupIPAddress(address.getIPAddress()); this->multicastListener.setPort(address.getPortNr()); this->multicastListener.create(); this->multicastListenerActivated = true; SystemCmdMsg * msg = new SystemCmdMsg(); msg->setPayload(SystemCmd(SystemCmd::removeConnection, static_cast<unsigned short>(this->myReceivePortNr))); this->outEventQueue.push(msg); }