void Z_OSCMessage::setAddress(uint8_t *_ip , uint16_t _port){ setIpAddress(_ip); portNumber=_port; }
void Z_OSCMessage::flush(){ if(oscAddress!=NULL) free(oscAddress); oscAddress=NULL; oscAdrSize=0; oscAdrPacSize=0; if(typeTag!=NULL) free(typeTag); typeTag=NULL; typeTagSize=0; typeTagPacSize=0; if(arguments!=NULL){ for (uint16_t i=0; i< argsNum; i++) { free((void*)arguments[i]); arguments[i]=NULL; } free(arguments); } argsNum=0; argsPacSize=0; arguments=NULL; setIpAddress(0,0,0,0); portNumber=0; DBG_LOGLN("flush message obj"); }
ConnectionDialog::ConnectionDialog(QWidget *parent) : QDialog(parent), ui(new Ui::ConnectionDialog) { ui->setupUi(this); connect(ui->saveButton, SIGNAL(clicked()), this, SLOT(setIpAddress())); connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(close())); }
bool LogType::parseIpAddress() { setIpAddress ( iniGetValue( ini::SECTION, ini::VAR_SWA_IP, ini::settings::ipAddress ) ); if (iniGetError()) { writeError( "Can't get 'IP Address'" ); return false; } if( getIpAddress().empty() ) { writeError( "'IP Address' invalid" ); return false; } writeInfo ( "IP Address = %s", getIpAddress().c_str()); return true; }
LogType::LogType(LogType& copy): LogSyslog(false) { copy.closeUdp(); setVerbose(copy.getVerbose()); setConfigFile(copy.getConfigFile()); setStorageType(copy.getStorageType()); setIpAddress(copy.getIpAddress()); setRemotePort(copy.getRemotePort()); setSourcePort(copy.getSourcePort()); setUdpBufferSize(copy.getUdpBufferSize()); __swaParser = boost::make_shared<SWAParser>( boost::bind(&LogType::callbackSWA, this, _1, _2, _3)); if (!__swaParser) { writeError ("SWA Parser not allocated"); // impossible, but if something corrupt memory. throw std::runtime_error( "Wrong log priority." ); } // check if config file exists if( !iniParse(getConfigFile()) ) { writeError ("Can't parse config FILE = %s", getConfigFile().c_str()); // impossible, but if something corrupt memory. throw std::runtime_error( "Wrong log priority." ); } __threadRun = false; __swaHelloReceive = false; __terminate = false; __udp_socket = NULL; __udp_remote_endpoint = NULL; }
/*! Initialize the connexion with the Sick LD-MRS laser scanner. \param ip_address : Ethernet address of the laser. \param com_port : Ethernet port of the laser. \return true if the device was initialized, false otherwise. */ bool vpSickLDMRS::setup(std::string ip_address, int com_port) { setIpAddress( ip_address ); setPort( com_port ); return ( this->setup() ); }
/** * Offer a TCP socket over this stream tube. * * This method offers a TCP socket over this tube. The socket's address is given as * a QHostAddress and a numerical port in native byte order. * * If your application uses QTcpServer as the local TCP server implementation, you can use the * offerTcpSocket(const QTcpServer *, const QVariantMap &) overload instead to more easily pass the * server's listen address. * * It is guaranteed that when the PendingOperation returned by this method will be completed, * the tube will be opened and ready to be used. * * Connection managers adhering to the \telepathy_spec should always support offering IPv4 TCP * sockets. IPv6 sockets are only supported if supportsIPv6SocketsOnLocalhost() is \c true. * * Note that the library will try to use #SocketAccessControlPort access control whenever possible, * as it allows to map connections to users based on their source addresses. If * supportsIPv4SocketsWithSpecifiedAddress() or supportsIPv6SocketsWithSpecifiedAddress() for IPv4 * and IPv6 sockets respectively is \c false, this feature is not available, and the * connectionsForSourceAddresses() map won't contain useful distinct keys. * * Arbitrary parameters can be associated with the offer to bootstrap legacy protocols; these will * in particular be available as IncomingStreamTubeChannel::parameters() for a tube receiver * implemented using TelepathyQt in the other end. * * This method requires OutgoingStreamTubeChannel::FeatureCore to be ready. * * \param address A valid IPv4 or IPv6 address pointing to an existing socket. * \param port The port the socket is listening for connections to. * \param parameters A dictionary of arbitrary parameters to send with the tube offer. * \return A PendingOperation which will emit PendingOperation::finished * when the stream tube is ready to be used * (hence in the #TubeStateOpen state). */ PendingOperation *OutgoingStreamTubeChannel::offerTcpSocket( const QHostAddress &address, quint16 port, const QVariantMap ¶meters) { if (!isReady(OutgoingStreamTubeChannel::FeatureCore)) { warning() << "OutgoingStreamTubeChannel::FeatureCore must be ready before " "calling offerTube"; return new PendingFailure(TP_QT_ERROR_NOT_AVAILABLE, QLatin1String("Channel not ready"), OutgoingStreamTubeChannelPtr(this)); } // The tube must be not offered if (state() != TubeChannelStateNotOffered) { warning() << "You can not expose more than a socket for each Stream Tube"; return new PendingFailure(TP_QT_ERROR_NOT_AVAILABLE, QLatin1String("Channel busy"), OutgoingStreamTubeChannelPtr(this)); } SocketAccessControl accessControl = SocketAccessControlLocalhost; // Check if port is supported QHostAddress hostAddress = address; #if QT_VERSION >= 0x050000 if (hostAddress == QHostAddress::Any) { hostAddress = QHostAddress::AnyIPv4; } #endif // In this specific overload, we're handling an IPv4/IPv6 socket if (hostAddress.protocol() == QAbstractSocket::IPv4Protocol) { // IPv4 case SocketAccessControl accessControl; // Do some heuristics to find out the best access control.We always prefer port for tracking // connections and source addresses. if (supportsIPv4SocketsWithSpecifiedAddress()) { accessControl = SocketAccessControlPort; } else if (supportsIPv4SocketsOnLocalhost()) { accessControl = SocketAccessControlLocalhost; } else { // There are no combinations supported for this socket warning() << "You requested an address type/access control combination " "not supported by this channel"; return new PendingFailure(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("The requested address type/access control " "combination is not supported"), OutgoingStreamTubeChannelPtr(this)); } setAddressType(SocketAddressTypeIPv4); setAccessControl(accessControl); setIpAddress(qMakePair<QHostAddress, quint16>(hostAddress, port)); SocketAddressIPv4 addr; addr.address = hostAddress.toString(); addr.port = port; PendingVoid *pv = new PendingVoid( interface<Client::ChannelTypeStreamTubeInterface>()->Offer( SocketAddressTypeIPv4, QDBusVariant(QVariant::fromValue(addr)), accessControl, parameters), OutgoingStreamTubeChannelPtr(this)); PendingOpenTube *op = new PendingOpenTube(pv, parameters, OutgoingStreamTubeChannelPtr(this)); return op; } else if (hostAddress.protocol() == QAbstractSocket::IPv6Protocol) { // IPv6 case // Do some heuristics to find out the best access control.We always prefer port for tracking // connections and source addresses. if (supportsIPv6SocketsWithSpecifiedAddress()) { accessControl = SocketAccessControlPort; } else if (supportsIPv6SocketsOnLocalhost()) { accessControl = SocketAccessControlLocalhost; } else { // There are no combinations supported for this socket warning() << "You requested an address type/access control combination " "not supported by this channel"; return new PendingFailure(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("The requested address type/access control " "combination is not supported"), OutgoingStreamTubeChannelPtr(this)); } setAddressType(SocketAddressTypeIPv6); setAccessControl(accessControl); setIpAddress(qMakePair<QHostAddress, quint16>(hostAddress, port)); SocketAddressIPv6 addr; addr.address = hostAddress.toString(); addr.port = port; PendingVoid *pv = new PendingVoid( interface<Client::ChannelTypeStreamTubeInterface>()->Offer( SocketAddressTypeIPv6, QDBusVariant(QVariant::fromValue(addr)), accessControl, parameters), OutgoingStreamTubeChannelPtr(this)); PendingOpenTube *op = new PendingOpenTube(pv, parameters, OutgoingStreamTubeChannelPtr(this)); return op; } else { // We're handling an IPv4/IPv6 socket only warning() << "offerTube can be called only with a QHostAddress representing " "an IPv4 or IPv6 address"; return new PendingFailure(TP_QT_ERROR_INVALID_ARGUMENT, QLatin1String("Invalid host given"), OutgoingStreamTubeChannelPtr(this)); } }
void OSCMessage::setAddress(uint8_t *_ipAddr , uint16_t _portNum){ setIpAddress(_ipAddr); _port = _portNum; }
void CIP::unpack() { quint8 byte; int b = 0; quint8 size; QByteArray tmpArray; QString cipString; // Header: request (1) byte = packet.at(b++); setRequest(byte); // Header: profile (1) byte = packet.at(b++); setProfile(byte); // Header: verion (1) byte = packet.at(b++); setVersion(byte); // Header: channel (1) byte = packet.at(b++); setChannel(byte); // Header: UUID (16) tmpArray = packet.mid(b, 16); b += 16; ciHead.setUuid(QUuid::fromRfc4122(tmpArray)); // Header: IP address (4) tmpArray.clear(); tmpArray = packet.mid(b, 4); b += 4; in_addr ip; memcpy(&ip, tmpArray, 4); setIpAddress(QHostAddress(inet_ntoa(ip))); // Header: IP port (2) tmpArray.clear(); tmpArray = packet.mid(b, 2); b += 2; ciHead.setIpPort((tmpArray.at(0)<<8) + tmpArray.at(1)); // Header: time (8) tmpArray.clear(); tmpArray = packet.mid(b, 8); b += 8; time_t unixTime; memcpy(&unixTime, tmpArray, 8); ciHead.getTime().setTime_t((uint) unixTime); // Header: type (1) byte = packet.at(b++); ciHead.setHeadDataType(byte); // Header: size (1) byte = packet.at(b++); ciHead.setHeadDataSize(byte); size = byte; // Header: additional data (size) tmpArray.clear(); tmpArray = packet.mid(b, size); b += size; ciHead.setHeadData(tmpArray); // CI: type (1) byte = packet.at(b++); setCiType(byte); // CI root-CIC (2) byte = packet.at(b++); quint8 content = byte; byte = packet.at(b++); ci.setRootCicContent(content); ci.setRootCicMask(byte); // CI: size (1) byte = packet.at(b++); setCiSize(byte); size = byte; // CI: additional data (size) tmpArray.clear(); tmpArray = packet.mid(b, size*2); b += size*2; ci.setCiBricks(tmpArray); // Application Data: type (1) byte = packet.at(b++); ciData.setAppDataType(byte); // Application Data: size (1) byte = packet.at(b++); ciData.setAppDataSize(byte); size = byte; // Application Data: additional data (size) tmpArray.clear(); tmpArray = packet.mid(b, size); b += size; ciData.setAppData(tmpArray); } //