void ICQClient::snac_lists(unsigned short type, unsigned short seq) { bool bFull = false; switch (type){ case ICQ_SNACxLISTS_RIGHTS: log(L_DEBUG, "List rights"); break; case ICQ_SNACxLISTS_ROSTER:{ char c; unsigned short list_len; log(L_DEBUG,"Rosters"); if (m_bRosters){ log(L_DEBUG, "Rosters part 2"); break; } readBuffer >> c; if (c){ log(L_WARN, "Bad first roster byte %02X", c); break; } vector<ICQGroup*>::iterator it_grp; list<ICQUser*>::iterator it_usr; for (it_grp = contacts.groups.begin(); it_grp != contacts.groups.end(); it_grp++) (*it_grp)->bChecked = false; for (it_usr = contacts.users.begin(); it_usr != contacts.users.end(); it_usr++){ if ((*it_usr)->Type != USER_TYPE_ICQ) continue; (*it_usr)->Id = 0; (*it_usr)->GrpId = 0; (*it_usr)->inIgnore = false; (*it_usr)->inVisible = false; (*it_usr)->inInvisible = false; } readBuffer >> list_len; for (unsigned i = 0; i < list_len; i++){ string str; unsigned short id, grp_id, type, len; readBuffer.unpackStr(str); readBuffer >> grp_id >> id >> type >> len; TlvList *inf = NULL; if (len){ Buffer b(len); b.pack(readBuffer.Data(readBuffer.readPos()), len); readBuffer.incReadPos(len); inf = new TlvList(b); } switch (type){ case 0x0000: /* User */{ unsigned long uin = atol(str.c_str()); if (uin == 0){ log(L_WARN, "Bad uin record %s\n", str.c_str()); break; } Tlv *tlv_name = NULL; if (inf) tlv_name = (*inf)(0x0131); string alias = tlv_name ? (char*)(*tlv_name) : ""; fromUTF(alias); bool needAuth = false; if (inf && (*inf)(0x0066)) needAuth = true; ICQUser *user = getUser(uin, true); user->Id = id; user->GrpId = grp_id; user->Alias = alias; user->WaitAuth = needAuth; break; } case ICQ_GROUPS:{ if (str.size() == 0) break; fromUTF(str); ICQGroup *grp = getGroup(grp_id, true); if (grp == NULL){ grp = new ICQGroup(); contacts.groups.push_back(grp); } grp->Id = grp_id; grp->Name = str; grp->bChecked = true; break; } case ICQ_VISIBLE_LIST:{ unsigned long uin = atol(str.c_str()); if (uin) getUser(atol(str.c_str()), true)->inVisible = true; break; } case ICQ_INVISIBLE_LIST:{ unsigned long uin = atol(str.c_str()); if (uin) getUser(atol(str.c_str()), true)->inInvisible = true; break; } case ICQ_IGNORE_LIST:{ unsigned long uin = atol(str.c_str()); if (uin) getUser(atol(str.c_str()), true)->inIgnore = true; break; } case ICQ_INVISIBLE_STATE: contacts.Invisible = id; break; case 0x0009: break; default: log(L_WARN,"Unknown roster type %04X", type); } if (inf) delete inf; } unsigned long time; readBuffer >> time; contacts.Time = time; for (;;){ bool ok = true; for (it_grp = contacts.groups.begin(); it_grp != contacts.groups.end(); it_grp++){ if (!(*it_grp)->bChecked){ contacts.groups.erase(it_grp); ok = false; break; } } if (ok) break; } for (it_usr = contacts.users.begin(); it_usr != contacts.users.end(); it_usr++){ unsigned short grpId = (*it_usr)->GrpId(); bool ok = false; for (it_grp = contacts.groups.begin(); it_grp != contacts.groups.end(); it_grp++){ if ((*it_grp)->Id() == grpId){ ok = true; break; } } if (!ok) (*it_usr)->GrpId = 0; } ICQEvent e(EVENT_GROUP_CHANGED); process_event(&e); m_state = Logged; bFull = true; } case ICQ_SNACxLISTS_ROSTERxOK: // FALLTHROUGH { m_bRosters = true; log(L_DEBUG, "Rosters OK"); snac(ICQ_SNACxFAM_LISTS, ICQ_SNACxLISTS_UNKNOWN); sendPacket(); sendCapability(); sendICMB(); sendLogonStatus(); sendClientReady(); sendMessageRequest(); sendPhoneInit(); sendPhoneStatus(); if (bFull || (Nick.size() == 0)){ addInfoRequest(Uin); searchByUin(Uin); } list<ICQUser*>::iterator it; for (it = contacts.users.begin(); it != contacts.users.end(); it++){ if ((*it)->inIgnore()) continue; if (!bFull && (*it)->Nick.size()) continue; addInfoRequest((*it)->Uin); } if (contacts.groups.size() == 0){ m_state = Logged; createGroup("General"); } break; } case ICQ_SNACxLISTS_ADDED:{ readBuffer.incReadPos(8); unsigned long uin = readBuffer.unpackUin(); ICQAddedToList *m = new ICQAddedToList; m->Uin.push_back(uin); messageReceived(m); break; } case ICQ_SNACxLISTS_AUTHxREQUEST:{ readBuffer.incReadPos(8); unsigned long uin = readBuffer.unpackUin(); ICQUser *u = getUser(uin); string message; string charset; unsigned short have_charset; readBuffer.unpackStr(message); readBuffer >> have_charset; if (have_charset){ readBuffer.incReadPos(2); readBuffer.unpackStr(charset); } if (charset.size()){ translate(localCharset(u), charset.c_str(), message); }else{ fromServer(message, u); } log(L_DEBUG, "Auth request %lu", uin); ICQAuthRequest *m = new ICQAuthRequest; m->Uin.push_back(uin); m->Message = message; messageReceived(m); break; } case ICQ_SNACxLISTS_AUTH:{ readBuffer.incReadPos(8); unsigned long uin = readBuffer.unpackUin(); char auth_ok; readBuffer >> auth_ok; string message; string charset; unsigned short have_charset; readBuffer.unpackStr(message); readBuffer >> have_charset; if (have_charset){ readBuffer.incReadPos(2); readBuffer.unpackStr(charset); } ICQUser *u = getUser(uin); if (charset.size()){ translate(localCharset(u), charset.c_str(), message); }else{ fromServer(message, u); } log(L_DEBUG, "Auth %u %lu", auth_ok, uin); if (auth_ok){ ICQUser *user = getUser(uin); if (user){ user->WaitAuth = false; ICQEvent e(EVENT_INFO_CHANGED, uin); process_event(&e); } ICQAuthGranted *m = new ICQAuthGranted(); m->Uin.push_back(uin); messageReceived(m); }else{ ICQAuthRefused *m = new ICQAuthRefused(); m->Uin.push_back(uin); m->Message = message; messageReceived(m); } break; } case ICQ_SNACxLISTS_DONE:{ ICQEvent *e = findListEvent(seq); if (e == NULL) break; readBuffer.incReadPos(8); unsigned short res; readBuffer >> res; e->processAnswer(this, readBuffer, res); delete e; break; } default: log(L_WARN, "Unknown lists family type %04X", type); } }
void LLXfer::resendLastPacket() { mRetries++; sendPacket(mPacketNum); }
void SshSendFacility::sendUserAuthServiceRequestPacket() { m_outgoingPacket.generateUserAuthServiceRequestPacket(); sendPacket(); }
AREXPORT bool ArDPPTU::init(void) { preparePacket(); myPacket.byteToBuf(ArDPPTUCommands::INIT); if (!sendPacket(&myPacket)) { ArLog::log(ArLog::Terse, "ArDPPTU: Error sending INIT to PTU! (Write error?)"); return false; } myPan = -1; //myPan and myTilt set to -1 for initial positioning myTilt = -1; setMovePower(PAN, LOW); setMovePower(TILT, LOW); setHoldPower(PAN, OFF); setHoldPower(PAN, OFF); switch(myDeviceType) { case PANTILT_PTUD47: //Assuming default accel and slew rates myPanSlew = 40; myBasePanSlew = 40; myTiltSlew = 40; myBaseTiltSlew = 40; myPanAccel = 80; myTiltAccel = 80; break; case PANTILT_PTUD46: case PANTILT_DEFAULT: default: //Assuming default accel and slew rates myPanSlew = 40; // 1000 positions/sec myBasePanSlew = 40; // 1000 positions/sec myTiltSlew = 40; // 1000 positions/sec myBaseTiltSlew = 40; // 1000 positions/sec myPanAccel = 80; // 2000 positions/sec^2 myTiltAccel = 80; // 2000 positions/sec^2 break; } if(myDeviceType == PANTILT_DEFAULT) { // query resolution, conversion factors will be // set again based on responses (replacing default value set // in constructor) preparePacket(); myPacket.byteToBuf('P'); myPacket.byteToBuf('R'); if(!sendPacket(&myPacket)) ArLog::log(ArLog::Terse, "ArDPPTU: Warning: write error sending pan resolution query"); // We can't distinguish PR and TR responses based on their content alone, so // we have to query pan resolution (PR), then after receiving resolution // response, query TR. (see readPacket() for TR). ///@todo query the device for pan and tilt limits, and when response is received, call ArPTZ::setLimits() to change. } query(); // do first position query if (!panTilt(0,0)) return false; myInit = true; return true; }
int cycle(Client* c, Timer* timer) { // read the socket, see what work is due unsigned short packet_type = readPacket(c, timer); int len = 0, rc = SUCCESS; switch (packet_type) { case CONNACK: case PUBACK: case SUBACK: break; case PUBLISH: { MQTTString topicName; MQTTMessage msg; if (MQTTDeserialize_publish((unsigned char*)&msg.dup, (int*)&msg.qos, (unsigned char*)&msg.retained, (unsigned short*)&msg.id, &topicName, (unsigned char**)&msg.payload, (int*)&msg.payloadlen, c->readbuf, c->readbuf_size) != 1) goto exit; deliverMessage(c, &topicName, &msg); if (msg.qos != QOS0) { if (msg.qos == QOS1) len = MQTTSerialize_ack(c->buf, c->buf_size, PUBACK, 0, msg.id); else if (msg.qos == QOS2) len = MQTTSerialize_ack(c->buf, c->buf_size, PUBREC, 0, msg.id); if (len <= 0) rc = FAILURE; else rc = sendPacket(c, len, timer); if (rc == FAILURE) goto exit; // there was a problem } break; } case PUBREC: { unsigned short mypacketid; unsigned char dup, type; if (MQTTDeserialize_ack(&type, &dup, &mypacketid, c->readbuf, c->readbuf_size) != 1) rc = FAILURE; else if ((len = MQTTSerialize_ack(c->buf, c->buf_size, PUBREL, 0, mypacketid)) <= 0) rc = FAILURE; else if ((rc = sendPacket(c, len, timer)) != SUCCESS) // send the PUBREL packet rc = FAILURE; // there was a problem if (rc == FAILURE) goto exit; // there was a problem break; } case PUBCOMP: break; case PINGRESP: c->ping_outstanding = 0; break; } keepalive(c); exit: if (rc == SUCCESS) rc = packet_type; return rc; }
/*********************************************************************** *%FUNCTION: sendPADR *%ARGUMENTS: * conn -- PPPoE connection structur *%RETURNS: * Nothing *%DESCRIPTION: * Sends a PADR packet ***********************************************************************/ void sendPADR(PPPoEConnection *conn) { PPPoEPacket packet; PPPoETag *svc = (PPPoETag *) packet.payload; unsigned char *cursor = packet.payload; UINT16_t namelen = 0; UINT16_t plen; if (conn->serviceName) { namelen = (UINT16_t) strlen(conn->serviceName); //printf("namelen=%d\n",namelen); } plen = TAG_HDR_SIZE + namelen; CHECK_ROOM(cursor, packet.payload, plen); memcpy(packet.ethHdr.h_dest, conn->peerEth, ETH_ALEN); memcpy(packet.ethHdr.h_source, conn->myEth, ETH_ALEN); packet.ethHdr.h_proto = htons(Eth_PPPOE_Discovery); packet.ver = 1; packet.type = 1; packet.code = CODE_PADR; packet.session = 0; svc->type = TAG_SERVICE_NAME; svc->length = htons(namelen); if (conn->serviceName) { memcpy(svc->payload, conn->serviceName, namelen); } cursor += namelen + TAG_HDR_SIZE; /* If we're using Host-Uniq, copy it over */ if (conn->useHostUniq) { PPPoETag hostUniq; pid_t pid = getpid(); hostUniq.type = htons(TAG_HOST_UNIQ); hostUniq.length = htons(sizeof(pid)); memcpy(hostUniq.payload, &pid, sizeof(pid)); CHECK_ROOM(cursor, packet.payload, sizeof(pid)+TAG_HDR_SIZE); memcpy(cursor, &hostUniq, sizeof(pid) + TAG_HDR_SIZE); cursor += sizeof(pid) + TAG_HDR_SIZE; plen += sizeof(pid) + TAG_HDR_SIZE; } /* Copy cookie and relay-ID if needed */ if (conn->cookie.type) { CHECK_ROOM(cursor, packet.payload, ntohs(conn->cookie.length) + TAG_HDR_SIZE); memcpy(cursor, &conn->cookie, ntohs(conn->cookie.length) + TAG_HDR_SIZE); cursor += ntohs(conn->cookie.length) + TAG_HDR_SIZE; plen += ntohs(conn->cookie.length) + TAG_HDR_SIZE; } if (conn->relayId.type) { CHECK_ROOM(cursor, packet.payload, ntohs(conn->relayId.length) + TAG_HDR_SIZE); memcpy(cursor, &conn->relayId, ntohs(conn->relayId.length) + TAG_HDR_SIZE); cursor += ntohs(conn->relayId.length) + TAG_HDR_SIZE; plen += ntohs(conn->relayId.length) + TAG_HDR_SIZE; } packet.length = htons(plen); sendPacket(conn, conn->discoverySocket, &packet, (int) (plen + HDR_SIZE)); if (conn->debugFile) { dumpPacket(conn->debugFile, &packet, "SENT"); fprintf(conn->debugFile, "\n"); fflush(conn->debugFile); } }
void AudioMixer::sendAudioEnvironmentPacket(SharedNodePointer node) { // Send stream properties bool hasReverb = false; float reverbTime, wetLevel; // find reverb properties for (int i = 0; i < _zoneReverbSettings.size(); ++i) { AudioMixerClientData* data = static_cast<AudioMixerClientData*>(node->getLinkedData()); glm::vec3 streamPosition = data->getAvatarAudioStream()->getPosition(); AABox box = _audioZones[_zoneReverbSettings[i].zone]; if (box.contains(streamPosition)) { hasReverb = true; reverbTime = _zoneReverbSettings[i].reverbTime; wetLevel = _zoneReverbSettings[i].wetLevel; // Modulate wet level with distance to wall float MIN_ATTENUATION_DISTANCE = 2.0f; float MAX_ATTENUATION = -12; // dB glm::vec3 distanceToWalls = (box.getDimensions() / 2.0f) - glm::abs(streamPosition - box.calcCenter()); float distanceToClosestWall = glm::min(distanceToWalls.x, distanceToWalls.z); if (distanceToClosestWall < MIN_ATTENUATION_DISTANCE) { wetLevel += MAX_ATTENUATION * (1.0f - distanceToClosestWall / MIN_ATTENUATION_DISTANCE); } break; } } AudioMixerClientData* nodeData = static_cast<AudioMixerClientData*>(node->getLinkedData()); AvatarAudioStream* stream = nodeData->getAvatarAudioStream(); bool dataChanged = (stream->hasReverb() != hasReverb) || (stream->hasReverb() && (stream->getRevebTime() != reverbTime || stream->getWetLevel() != wetLevel)); if (dataChanged) { // Update stream if (hasReverb) { stream->setReverb(reverbTime, wetLevel); } else { stream->clearReverb(); } } // Send at change or every so often float CHANCE_OF_SEND = 0.01f; bool sendData = dataChanged || (randFloat() < CHANCE_OF_SEND); if (sendData) { auto nodeList = DependencyManager::get<NodeList>(); unsigned char bitset = 0; int packetSize = sizeof(bitset); if (hasReverb) { packetSize += sizeof(reverbTime) + sizeof(wetLevel); } auto envPacket = NLPacket::create(PacketType::AudioEnvironment, packetSize); if (hasReverb) { setAtBit(bitset, HAS_REVERB_BIT); } envPacket->writePrimitive(bitset); if (hasReverb) { envPacket->writePrimitive(reverbTime); envPacket->writePrimitive(wetLevel); } nodeList->sendPacket(std::move(envPacket), *node); } }
bool PcapLiveDevice::sendPacket(Packet* packet) { RawPacket* rawPacket = packet->getRawPacket(); return sendPacket(*rawPacket); }
bool PacketHandler::handleQueryStatus(HANDLE_ARGS) { QueryStatus response; return sendPacket(peer, reinterpret_cast<uint8*>(&response), sizeof(QueryStatus), 3); }
void JabberClient::setStatus(unsigned status, const char *ar) { if (status != m_status){ time_t now; time(&now); data.owner.StatusTime = now; if (m_status == STATUS_OFFLINE) data.owner.OnlineTime = now; m_status = status; m_socket->writeBuffer.packetStart(); const char *priority = "5"; const char *show = NULL; const char *type = NULL; if (getInvisible()){ type = "invisible"; }else{ switch (status){ case STATUS_AWAY: show = "away"; break; case STATUS_NA: show = "xa"; break; case STATUS_DND: show = "dnd"; break; case STATUS_FFC: show = "chat"; break; case STATUS_OFFLINE: priority = NULL; type = "unavailable"; break; } } m_socket->writeBuffer << "<presence"; if (type) m_socket->writeBuffer << " type=\"" << type << "\""; m_socket->writeBuffer << ">\n"; if (show && *show) m_socket->writeBuffer << "<show>" << show << "</show>\n"; if (ar && *ar){ m_socket->writeBuffer << "<status>" << ar << "</status>\n"; } if (priority) m_socket->writeBuffer << "<priority>" << priority << "</priority>\n"; m_socket->writeBuffer << "</presence>"; sendPacket(); Event e(EventClientChanged, static_cast<Client*>(this)); e.process(); } if (status == STATUS_OFFLINE){ if (m_socket){ m_socket->writeBuffer.packetStart(); m_socket->writeBuffer << "</stream:stream>\n"; sendPacket(); } Contact *contact; ContactList::ContactIterator it; time_t now; time(&now); data.owner.StatusTime = now; while ((contact = ++it) != NULL){ JabberUserData *data; ClientDataIterator it(contact->clientData, this); while ((data = (JabberUserData*)(++it)) != NULL){ if (data->Status == STATUS_OFFLINE) continue; data->StatusTime = now; setOffline(data); StatusMessage m; m.setContact(contact->id()); m.setClient(dataName(data).c_str()); m.setFlags(MESSAGE_RECEIVED); m.setStatus(STATUS_OFFLINE); Event e(EventMessageReceived, &m); e.process(); } } } }
bool PcapLiveDevice::sendPacket(RawPacket const& rawPacket) { return sendPacket(((RawPacket&)rawPacket).getRawData(), ((RawPacket&)rawPacket).getRawDataLen()); }
bool JabberClient::send(Message *msg, void *_data) { if (getState() != Connected) return false; JabberUserData *data = (JabberUserData*)_data; switch (msg->type()){ case MessageAuthRefused:{ string grp; Group *group = NULL; Contact *contact = getContacts()->contact(msg->contact()); if (contact && contact->getGroup()) group = getContacts()->group(contact->getGroup()); if (group) grp = group->getName().utf8(); listRequest(data, data->Name, grp.c_str(), false); if (data->Subscribe & SUBSCRIBE_FROM){ m_socket->writeBuffer.packetStart(); m_socket->writeBuffer << "<presence to=\"" << data->ID; m_socket->writeBuffer << "\" type=\"unsubscribed\"><status>" << (const char*)(quoteString(msg->getPlainText(), false).utf8()) << "</status></presence>"; sendPacket(); if ((msg->getFlags() & MESSAGE_NOHISTORY) == 0){ msg->setClient(dataName(data).c_str()); Event e(EventSent, msg); e.process(); } Event e(EventMessageSent, msg); e.process(); delete msg; return true; } } case MessageGeneric:{ Contact *contact = getContacts()->contact(msg->contact()); if ((contact == NULL) || (data == NULL)) return false; m_socket->writeBuffer.packetStart(); m_socket->writeBuffer << "<message to=\"" << data->ID; m_socket->writeBuffer << "\"><body>" << (const char*)msg->getPlainText().utf8() << "</body></message>"; sendPacket(); if ((msg->getFlags() & MESSAGE_NOHISTORY) == 0){ msg->setClient(dataName(data).c_str()); Event e(EventSent, msg); e.process(); } Event e(EventMessageSent, msg); e.process(); delete msg; return true; } case MessageAuthRequest:{ m_socket->writeBuffer.packetStart(); m_socket->writeBuffer << "<presence to=\"" << data->ID; m_socket->writeBuffer << "\" type=\"subscribe\"><status>" << (const char*)(quoteString(msg->getPlainText(), false).utf8()) << "</status></presence>"; sendPacket(); if ((msg->getFlags() & MESSAGE_NOHISTORY) == 0){ msg->setClient(dataName(data).c_str()); Event e(EventSent, msg); e.process(); } Event e(EventMessageSent, msg); e.process(); delete msg; return true; } case MessageAuthGranted:{ m_socket->writeBuffer.packetStart(); m_socket->writeBuffer << "<presence to=\"" << data->ID; m_socket->writeBuffer << "\" type=\"subscribed\"></presence>"; sendPacket(); if ((msg->getFlags() & MESSAGE_NOHISTORY) == 0){ msg->setClient(dataName(data).c_str()); Event e(EventSent, msg); e.process(); } Event e(EventMessageSent, msg); e.process(); delete msg; return true; } case MessageJabberOnline: if (isAgent(data->ID) && (data->Status == STATUS_OFFLINE)){ m_socket->writeBuffer.packetStart(); m_socket->writeBuffer << "<presence to=\"" << data->ID << "\"></presence>"; sendPacket(); delete msg; return true; } break; case MessageJabberOffline: if (isAgent(data->ID) && (data->Status != STATUS_OFFLINE)){ m_socket->writeBuffer.packetStart(); m_socket->writeBuffer << "<presence to=\"" << data->ID << "\" type=\"unavailable\"></presence>"; sendPacket(); delete msg; return true; } break; } return false; }
void OctreeHeadlessViewer::queryOctree() { char serverType = getMyNodeType(); PacketType::Value packetType = getMyQueryMessageType(); NodeToJurisdictionMap& jurisdictions = *_jurisdictionListener->getJurisdictions(); bool wantExtraDebugging = false; if (wantExtraDebugging) { qCDebug(octree) << "OctreeHeadlessViewer::queryOctree() _jurisdictionListener=" << _jurisdictionListener; qCDebug(octree) << "---------------"; qCDebug(octree) << "_jurisdictionListener=" << _jurisdictionListener; qCDebug(octree) << "Jurisdictions..."; jurisdictions.lockForRead(); for (NodeToJurisdictionMapIterator i = jurisdictions.begin(); i != jurisdictions.end(); ++i) { qCDebug(octree) << i.key() << ": " << &i.value(); } jurisdictions.unlock(); qCDebug(octree) << "---------------"; } // These will be the same for all servers, so we can set them up once and then reuse for each server we send to. _octreeQuery.setWantLowResMoving(true); _octreeQuery.setWantColor(true); _octreeQuery.setWantDelta(true); _octreeQuery.setWantOcclusionCulling(false); _octreeQuery.setWantCompression(true); // TODO: should be on by default _octreeQuery.setCameraPosition(_viewFrustum.getPosition()); _octreeQuery.setCameraOrientation(_viewFrustum.getOrientation()); _octreeQuery.setCameraFov(_viewFrustum.getFieldOfView()); _octreeQuery.setCameraAspectRatio(_viewFrustum.getAspectRatio()); _octreeQuery.setCameraNearClip(_viewFrustum.getNearClip()); _octreeQuery.setCameraFarClip(_viewFrustum.getFarClip()); _octreeQuery.setCameraEyeOffsetPosition(glm::vec3()); _octreeQuery.setOctreeSizeScale(getVoxelSizeScale()); _octreeQuery.setBoundaryLevelAdjust(getBoundaryLevelAdjust()); // Iterate all of the nodes, and get a count of how many voxel servers we have... int totalServers = 0; int inViewServers = 0; int unknownJurisdictionServers = 0; DependencyManager::get<NodeList>()->eachNode([&](const SharedNodePointer& node){ // only send to the NodeTypes that are serverType if (node->getActiveSocket() && node->getType() == serverType) { totalServers++; // get the server bounds for this server QUuid nodeUUID = node->getUUID(); // if we haven't heard from this voxel server, go ahead and send it a query, so we // can get the jurisdiction... jurisdictions.lockForRead(); if (jurisdictions.find(nodeUUID) == jurisdictions.end()) { jurisdictions.unlock(); unknownJurisdictionServers++; } else { const JurisdictionMap& map = (jurisdictions)[nodeUUID]; unsigned char* rootCode = map.getRootOctalCode(); if (rootCode) { VoxelPositionSize rootDetails; voxelDetailsForCode(rootCode, rootDetails); jurisdictions.unlock(); AACube serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s); ViewFrustum::location serverFrustumLocation = _viewFrustum.cubeInFrustum(serverBounds); if (serverFrustumLocation != ViewFrustum::OUTSIDE) { inViewServers++; } } else { jurisdictions.unlock(); } } } }); if (wantExtraDebugging) { qCDebug(octree, "Servers: total %d, in view %d, unknown jurisdiction %d", totalServers, inViewServers, unknownJurisdictionServers); } int perServerPPS = 0; const int SMALL_BUDGET = 10; int perUnknownServer = SMALL_BUDGET; int totalPPS = getMaxPacketsPerSecond(); // determine PPS based on number of servers if (inViewServers >= 1) { // set our preferred PPS to be exactly evenly divided among all of the voxel servers... and allocate 1 PPS // for each unknown jurisdiction server perServerPPS = (totalPPS / inViewServers) - (unknownJurisdictionServers * perUnknownServer); } else { if (unknownJurisdictionServers > 0) { perUnknownServer = (totalPPS / unknownJurisdictionServers); } } if (wantExtraDebugging) { qCDebug(octree, "perServerPPS: %d perUnknownServer: %d", perServerPPS, perUnknownServer); } auto nodeList = DependencyManager::get<NodeList>(); nodeList->eachNode([&](const SharedNodePointer& node){ // only send to the NodeTypes that are serverType if (node->getActiveSocket() && node->getType() == serverType) { // get the server bounds for this server QUuid nodeUUID = node->getUUID(); bool inView = false; bool unknownView = false; // if we haven't heard from this voxel server, go ahead and send it a query, so we // can get the jurisdiction... jurisdictions.lockForRead(); if (jurisdictions.find(nodeUUID) == jurisdictions.end()) { jurisdictions.unlock(); unknownView = true; // assume it's in view if (wantExtraDebugging) { qCDebug(octree) << "no known jurisdiction for node " << *node << ", assume it's visible."; } } else { const JurisdictionMap& map = (jurisdictions)[nodeUUID]; unsigned char* rootCode = map.getRootOctalCode(); if (rootCode) { VoxelPositionSize rootDetails; voxelDetailsForCode(rootCode, rootDetails); jurisdictions.unlock(); AACube serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s); ViewFrustum::location serverFrustumLocation = _viewFrustum.cubeInFrustum(serverBounds); if (serverFrustumLocation != ViewFrustum::OUTSIDE) { inView = true; } else { inView = false; } } else { jurisdictions.unlock(); if (wantExtraDebugging) { qCDebug(octree) << "Jurisdiction without RootCode for node " << *node << ". That's unusual!"; } } } if (inView) { _octreeQuery.setMaxQueryPacketsPerSecond(perServerPPS); if (wantExtraDebugging) { qCDebug(octree) << "inView for node " << *node << ", give it budget of " << perServerPPS; } } else if (unknownView) { if (wantExtraDebugging) { qCDebug(octree) << "no known jurisdiction for node " << *node << ", give it budget of " << perUnknownServer << " to send us jurisdiction."; } // set the query's position/orientation to be degenerate in a manner that will get the scene quickly // If there's only one server, then don't do this, and just let the normal voxel query pass through // as expected... this way, we will actually get a valid scene if there is one to be seen if (totalServers > 1) { _octreeQuery.setCameraPosition(glm::vec3(-0.1,-0.1,-0.1)); const glm::quat OFF_IN_NEGATIVE_SPACE = glm::quat(-0.5, 0, -0.5, 1.0); _octreeQuery.setCameraOrientation(OFF_IN_NEGATIVE_SPACE); _octreeQuery.setCameraNearClip(0.1f); _octreeQuery.setCameraFarClip(0.1f); if (wantExtraDebugging) { qCDebug(octree) << "Using 'minimal' camera position for node" << *node; } } else { if (wantExtraDebugging) { qCDebug(octree) << "Using regular camera position for node" << *node; } } _octreeQuery.setMaxQueryPacketsPerSecond(perUnknownServer); } else { _octreeQuery.setMaxQueryPacketsPerSecond(0); } // setup the query packet auto queryPacket = NLPacket::create(packetType); _octreeQuery.getBroadcastData(reinterpret_cast<unsigned char*>(queryPacket->getPayload())); // ask the NodeList to send it nodeList->sendPacket(std::move(queryPacket), *node); } }); }
void ICQClient::processMsgQueueAuth() { list<ICQEvent*>::iterator it; for (it = msgQueue.begin(); it != msgQueue.end();){ ICQEvent *e = *it; if (e->message() == NULL){ msgQueue.remove(e); e->state = ICQEvent::Fail; process_event(e); it = msgQueue.begin(); continue; } switch (e->message()->Type()){ case ICQ_MSGxAUTHxREQUEST:{ ICQAuthRequest *msg = static_cast<ICQAuthRequest*>(e->message()); snac(ICQ_SNACxFAM_LISTS, ICQ_SNACxLISTS_REQUEST_AUTH); ICQUser *u = getUser(msg->getUin()); writeBuffer.packUin(msg->getUin()); string message = clearHTML(msg->Message.c_str()); toServer(message, u); writeBuffer << (unsigned short)(message.length()); writeBuffer << message.c_str(); writeBuffer << (unsigned short)0; sendPacket(); (*it)->state = ICQEvent::Success; break; } case ICQ_MSGxAUTHxGRANTED:{ ICQAuthRequest *msg = static_cast<ICQAuthRequest*>(e->message()); snac(ICQ_SNACxFAM_LISTS, ICQ_SNACxLISTS_AUTHxSEND); writeBuffer.packUin(msg->getUin()); writeBuffer << (char)0x01 << (unsigned long)0; sendPacket(); (*it)->state = ICQEvent::Success; break; } case ICQ_MSGxAUTHxREFUSED:{ ICQAuthRequest *msg = static_cast<ICQAuthRequest*>(e->message()); snac(ICQ_SNACxFAM_LISTS, ICQ_SNACxLISTS_REQUEST_AUTH); ICQUser *u = getUser(msg->getUin()); writeBuffer.packUin(msg->getUin()); string message = clearHTML(msg->Message.c_str()); string original = message; toServer(message, u); writeBuffer << (char) 0 << message << (unsigned long)0x00010001; if (message == original){ writeBuffer << (unsigned char)0; }else{ string charset = "utf-8"; writeBuffer << charset; } writeBuffer << (unsigned short)0; sendPacket(); (*it)->state = ICQEvent::Success; break; } } if (e->state != ICQEvent::Success){ it++; continue; } msgQueue.remove(e); process_event(e); it = msgQueue.begin(); } }
int rp_sendPacket(char const *ifname, int sock, const void *pkt, int size) { PPPoEConnection conn; conn.ifName=const_cast<char*>(ifname); return sendPacket(&conn, sock, static_cast<PPPoEPacket*>(const_cast<void*>(pkt)), size); }
bool PacketHandler::handleSkillUp(HANDLE_ARGS) { SkillUpPacket* skillUpPacket = reinterpret_cast<SkillUpPacket*>(packet->data); //!TODO Check if can up skill? :) SkillUpResponse skillUpResponse; skillUpResponse.skill = skillUpPacket->skill; skillUpResponse.level = 0x0001; // TESTING /* Eleazan uint8 heroRealSpawn[] = { 0xFF, 0x08, 0x09, 0xCA, 0x00, 0x00, 0x00, 0x00, 0xDC, 0x24, 0xF3, 0x36, 0x12, 0xCB, 0x00, 0xE7,\ 0x15, 0xC2, 0x3C, 0x78, 0xC3, 0x19, 0x00, 0x00, 0x40, 0x01, 0x06, 0x01, 0x00, 0xD1, 0x07, 0x00,\ 0x00, 0x00, 0x03, 0x08, 0x00, 0x00, 0x00, 0x6B, 0x9C, 0x0F, 0x42, 0xA5, 0xC6, 0x88, 0x43, 0x7D,\ 0x1B, 0x44, 0x3F, 0xBB, 0x8D, 0x24, 0x3F, 0x22, 0xB6, 0x00, 0x00, 0x00, 0xED, 0x43, 0x00, 0x00,\ 0xED, 0x43, 0x0A, 0xC3, 0xFC, 0x00, 0x00, 0x0B, 0xFF, 0x00, 0x00, 0x0B, 0xFF, 0x00, 0x00, 0x0B,\ 0xFE, 0x00, 0x00 }; sendPacket(peer, reinterpret_cast<uint8*>(heroRealSpawn), sizeof(heroRealSpawn), 3); */ uint8 lightHeroAndTop[] = { 0xFF, 0x08, 0x09, 0xCA, 0x00, 0x00, 0x00, 0x00, 0x97, 0xC4, 0x08, 0x37, 0x12, 0xCB, 0x00, 0xBE,\ 0x12, 0xAA, 0x3C, 0x78, 0xC3, 0x19, 0x00, 0x00, 0x40, 0x01, 0x06, 0x01, 0x00, 0xD1, 0x07, 0x00,\ 0x00, 0x00, 0x03, 0x08, 0x00, 0x00, 0x00, 0x6B, 0x9C, 0x0F, 0x42, 0xA5, 0xC6, 0x88, 0x43, 0x7D,\ 0x1B, 0x44, 0x3F, 0xBB, 0x8D, 0x24, 0x3F, 0x22, 0xB6, 0x00, 0x00, 0x80, 0xF8, 0x43, 0x00, 0x80,\ 0xF8, 0x43, 0x0A, 0xC3, 0xFC, 0x00, 0x00, 0x0B, 0xFF, 0x00, 0x00, 0x0B, 0xFF, 0x00, 0x00, 0x0B,\ 0xFE, 0x00, 0x00 }; sendPacket(peer, reinterpret_cast<uint8*>(lightHeroAndTop), sizeof(lightHeroAndTop), 3); uint8 lightMid[] = { 0xFF, 0x04, 0x07, 0xC3, 0x0A, 0x00, 0x00, 0x40, 0x00, 0x00, 0x0B, 0xFF, 0x00, 0x00, 0x0B, 0xFF,\ 0x00, 0x00, 0x0B, 0xFF, 0x00, 0x00 }; sendPacket(peer, reinterpret_cast<uint8*>(lightMid), sizeof(lightMid), 3); uint8 lightBot[] = { 0xFF, 0x03, 0x07, 0xC3, 0x03, 0x00, 0x00, 0x40, 0x00, 0x00, 0x0B, 0xFF, 0x00, 0x00, 0x0B, 0xFF,\ 0x00, 0x00 }; sendPacket(peer, reinterpret_cast<uint8*>(lightBot), sizeof(lightBot), 3); uint8 lightNexus[] = { 0xFF, 0x02, 0x06, 0xC3, 0x4C, 0x36, 0xEB, 0xFF, 0x00, 0x05, 0x71, 0x71, 0xB7, 0xFF, 0x00 }; sendPacket(peer, reinterpret_cast<uint8*>(lightNexus), sizeof(lightNexus), 3); uint8 lightBase[] = { 0xFF, 0x02, 0x06, 0xC3, 0x36, 0xB8, 0x53, 0xFF, 0x00, 0x05, 0xDB, 0xC6, 0x10, 0xFF, 0x00 }; sendPacket(peer, reinterpret_cast<uint8*>(lightBase), sizeof(lightBase), 3); uint8 lightSubNexus1[] = { 0xFF, 0x12, 0x06, 0xC3, 0x3E, 0x3C, 0xD2, 0xFF, 0x00, 0x05, 0xF1, 0x20, 0x4A, 0xFF, 0x00, 0x70,\ 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x48,\ 0x44, 0x01, 0x00, 0x00, 0x40, 0x00, 0x50, 0xC3, 0x46, 0x1A, 0x00, 0x00, 0x40, 0xBD, 0x92, 0x58,\ 0x00, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x48, 0x44, 0x02,\ 0x00, 0x00, 0x40, 0x00, 0x50, 0xC3, 0x46, 0x1B, 0x00, 0x00, 0x40, 0xAD, 0x50, 0x98, 0x05, 0x73,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x48, 0x44, 0x03, 0x00, 0x00,\ 0x40, 0x00, 0x50, 0xC3, 0x46, 0x1C, 0x00, 0x00, 0x40, 0xAD, 0x50, 0x98, 0x05, 0x73, 0x00, 0x01,\ 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x48, 0x44, 0x04, 0x00, 0x00, 0x40, 0x00,\ 0x50, 0xC3, 0x46, 0x1D, 0x00, 0x00, 0x40, 0xAD, 0x50, 0x98, 0x05, 0x73, 0x00, 0x01, 0x00, 0x00,\ 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x48, 0x44, 0x05, 0x00, 0x00, 0x40, 0x00, 0x50, 0xC3,\ 0x46, 0x1E, 0x00, 0x00, 0x40, 0xAD, 0x50, 0x98, 0x05, 0x73, 0x00, 0x01, 0x00, 0x00, 0x00, 0xFE,\ 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x48, 0x44, 0x06, 0x00, 0x00, 0x40, 0x00, 0x50, 0xC3, 0x46, 0x1F,\ 0x00, 0x00, 0x40, 0xAD, 0x50, 0x98, 0x05, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF,\ 0xFF, 0x00, 0x00, 0x48, 0x44, 0x07, 0x00, 0x00, 0x40, 0x00, 0x50, 0xC3, 0x46, 0x20, 0x00, 0x00,\ 0x40, 0xAD, 0x50, 0x98, 0x05, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x00,\ 0x00, 0x48, 0x44, 0x08, 0x00, 0x00, 0x40, 0x00, 0x50, 0xC3, 0x46, 0x21, 0x00, 0x00, 0x40, 0xAD,\ 0x50, 0x98, 0x05, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x48,\ 0x44, 0x09, 0x00, 0x00, 0x40, 0x00, 0x50, 0xC3, 0x46, 0x22, 0x00, 0x00, 0x40, 0xAD, 0x50, 0x98,\ 0x05, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x7A, 0x44, 0x0A,\ 0x00, 0x00, 0x40, 0x00, 0x50, 0xC3, 0x46, 0x23, 0x00, 0x00, 0x40, 0xAD, 0x50, 0x98, 0x05, 0x73,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x7A, 0x44, 0x0B, 0x00, 0x00,\ 0x40, 0x00, 0x50, 0xC3, 0x46, 0x24, 0x00, 0x00, 0x40, 0xAD, 0x50, 0x98, 0x05, 0x73, 0x00, 0x01,\ 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x48, 0x44, 0x0C, 0x00, 0x00, 0x40, 0x00,\ 0x50, 0xC3, 0x46, 0x25, 0x00, 0x00, 0x40, 0xAD, 0x50, 0x98, 0x05, 0x73, 0x00, 0x01, 0x00, 0x00,\ 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x48, 0x44, 0x0D, 0x00, 0x00, 0x40, 0x00, 0x50, 0xC3,\ 0x46, 0x26, 0x00, 0x00, 0x40, 0xAD, 0x50, 0x98, 0x05, 0x73, 0x00, 0x01, 0x00, 0x00, 0x00, 0xFE,\ 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x48, 0x44, 0x0E, 0x00, 0x00, 0x40, 0x00, 0x50, 0xC3, 0x46, 0x27,\ 0x00, 0x00, 0x40, 0xAD, 0x50, 0x98, 0x05, 0x73, 0x00, 0x01, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF,\ 0xFF, 0x00, 0x00, 0x7A, 0x44, 0x0F, 0x00, 0x00, 0x40, 0x00, 0x50, 0xC3, 0x46, 0x28, 0x00, 0x00,\ 0x40, 0xAD, 0x50, 0x98, 0x05, 0x73, 0x00, 0x01, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x00,\ 0x00, 0x7A, 0x44, 0x10, 0x00, 0x00, 0x40, 0x00, 0x50, 0xC3, 0x46, 0x29, 0x00, 0x00, 0x40, 0xAD,\ 0x50, 0x98, 0x05 }; sendPacket(peer, reinterpret_cast<uint8*>(lightSubNexus1), sizeof(lightSubNexus1), 3); uint8 lightSubNexus2[] = { 0xFF, 0x09, 0x21, 0x26, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF,\ 0x00, 0x00, 0xC8, 0x44, 0x12, 0x00, 0x00, 0x40, 0x00, 0x50, 0xC3, 0x46, 0x2A, 0x00, 0x00, 0x40,\ 0xAD, 0x50, 0x98, 0x05, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x00, 0x00,\ 0x48, 0x44, 0x13, 0x00, 0x00, 0x40, 0x00, 0x50, 0xC3, 0x46, 0x2B, 0x00, 0x00, 0x40, 0xAD, 0x50,\ 0x98, 0x05, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x48, 0x44,\ 0x14, 0x00, 0x00, 0x40, 0x00, 0x50, 0xC3, 0x46, 0x2C, 0x00, 0x00, 0x40, 0xAD, 0x50, 0x98, 0x05,\ 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x48, 0x44, 0x15, 0x00,\ 0x00, 0x40, 0x00, 0x50, 0xC3, 0x46, 0x2D, 0x00, 0x00, 0x40, 0xAD, 0x50, 0x98, 0x05, 0x73, 0x00,\ 0x01, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x48, 0x44, 0x16, 0x00, 0x00, 0x40,\ 0x00, 0x50, 0xC3, 0x46, 0x2E, 0x00, 0x00, 0x40, 0xAD, 0x50, 0x98, 0x05, 0x73, 0x00, 0x01, 0x00,\ 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x48, 0x44, 0x17, 0x00, 0x00, 0x40, 0x00, 0x50,\ 0xC3, 0x46, 0x2F, 0x00, 0x00, 0x40, 0xAD, 0x50, 0x98, 0x05, 0x73, 0x00, 0x01, 0x00, 0x00, 0x00,\ 0xFE, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x48, 0x44, 0x18, 0x00, 0x00, 0x40, 0x00, 0x50, 0xC3, 0x46,\ 0x30, 0x00, 0x00, 0x40, 0xAD, 0x50, 0x98, 0x05, 0xD6, 0x84, 0x00, 0x03, 0x00, 0x19, 0x00, 0x00,\ 0x40, 0x02, 0x00, 0x00, 0x70, 0x41, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x19, 0x00,\ 0x00, 0x40, 0x78, 0x00, 0x00, 0x0C, 0x42, 0x00, 0x00, 0x52, 0x43, 0x00, 0x00, 0x00, 0x00, 0x19,\ 0x00, 0x00, 0x40, 0x79, 0x00, 0x00, 0x11, 0x43, 0x00, 0x00, 0x91, 0x42, 0x00, 0x00, 0x87, 0x43,\ 0x50, 0xC0, 0x19, 0x00, 0x00, 0x40, 0x02, 0x01, 0x01, 0x00, 0x05, 0x63, 0xF9, 0x06, 0x00, 0x00,\ 0x00, 0x00, 0x00, 0x24, 0x74, 0x48, 0x19, 0x00, 0x00, 0x40 }; sendPacket(peer, reinterpret_cast<uint8*>(lightSubNexus2), sizeof(lightSubNexus2), 3); return sendPacket(peer, reinterpret_cast<uint8*>(&skillUpResponse),sizeof(skillUpResponse),CHL_GAMEPLAY); }
int processDatagram() { packetHeader header = readHeader(messageBuf); int packetType = header.packetType; // If filename if(packetType == DATA) { // Get filename, print message char* fileName = arrSubset(messageBuf, HDRSIZE, DATAFIELDSIZE); printf("Received request for file: %s\n", fileName); // Read file into file buffer readFile(fileName); base = 0; nextPacket = 0; end = cwnd; for(nextPacket; nextPacket <= end; nextPacket++) { if(nextPacket == maxPacket) { break; } sendPacket(nextPacket); } } // If ACK else if (packetType == ACK) { int seqNumber = header.seqNumber; int ignore = isPacketBad(pl, pc); if(ignore == 1) { printf("Packet with ACK #%d was 'lost', ignoring\n", seqNumber * DATAFIELDSIZE); return 0; } else if(ignore == 2) { printf("Packet with ACK #%d was corrupted, ignoring\n", seqNumber * DATAFIELDSIZE); return 0; } else { printf("Received packet with ACK for sequence #%d.\n", seqNumber * DATAFIELDSIZE); } // Stop if ACK last packet to send if (seqNumber == maxPacket - 1) { return 1; } // Only send new packets if it's an unacked packet, we haven't reached the end, and we aren't retransmitting if(retransmitting != 1 && seqNumber >= base && nextPacket != maxPacket) { int diff = seqNumber - base; base = seqNumber + 1; end += diff + 1; for(nextPacket; nextPacket <= end; nextPacket++) { if(nextPacket == maxPacket) { break; } sendPacket(nextPacket); // Serve up next packet } } } else { fprintf(stderr, "Unknown packet type recieved!\n"); } return 0; }
//building the map bool PacketHandler::handleSpawn(ENetPeer *peer, ENetPacket *packet) { uint8 bounds[] = {0x2c, 0x19, 0x00, 0x00, 0x40, 0x99, 0x14, 0x00, 0x00, 0x99, 0x14, 0x00, 0x00, 0x7f, 0x14, 0x00,\ 0x00, 0x7f, 0x14, 0x00, 0x00, 0x7f, 0x14, 0x00, 0x00, 0x7f, 0x14, 0x00, 0x00, 0x7f, 0x14, 0x00,\ 0x00, 0xe1, 0x14, 0x00, 0x00, 0xe1, 0x14, 0x00, 0x00, 0xe1, 0x14, 0x00, 0x00, 0x99, 0x14, 0x00,\ 0x00, 0x99, 0x14, 0x00, 0x00, 0xa9, 0x14, 0x00, 0x00, 0xa9, 0x14, 0x00, 0x00, 0xa9, 0x14, 0x00,\ 0x00, 0xa9, 0x14, 0x00, 0x00, 0xa9, 0x14, 0x00, 0x00, 0xc5, 0x14, 0x00, 0x00, 0xc5, 0x14, 0x00,\ 0x00, 0xc5, 0x14, 0x00, 0x00, 0xc5, 0x14, 0x00, 0x00, 0xa9, 0x14, 0x00, 0x00, 0xc5, 0x14, 0x00,\ 0x00, 0xa9, 0x14, 0x00, 0x00, 0xc5, 0x14, 0x00, 0x00, 0xa9, 0x14, 0x00, 0x00, 0xc5, 0x14, 0x00,\ 0x00, 0xa9, 0x14, 0x00, 0x00, 0xc5, 0x14, 0x00, 0x00, 0xc5, 0x14, 0x00, 0x00, 0x95, 0x86, 0x5e,\ 0x06, 0xa8, 0x6e, 0x49, 0x06, 0x64, 0x37, 0x00, 0x00, 0x01, 0x44, 0x36, 0x00, 0x00, 0x02, 0x41,\ 0x36, 0x00, 0x00, 0x01, 0x52, 0x37, 0x00, 0x00, 0x04, 0x71, 0x36, 0x00, 0x00, 0x01, 0x43, 0x36,\ 0x00, 0x00, 0x03, 0x42, 0x36, 0x00, 0x00, 0x03, 0x41, 0x37, 0x00, 0x00, 0x01, 0x64, 0x36, 0x00,\ 0x00, 0x01, 0x92, 0x36, 0x00, 0x00, 0x01, 0x52, 0x36, 0x00, 0x00, 0x04, 0x43, 0x37, 0x00, 0x00,\ 0x03, 0x61, 0x36, 0x00, 0x00, 0x01, 0x82, 0x36, 0x00, 0x00, 0x03, 0x62, 0x36, 0x00, 0x00, 0x01,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e}; uint8 turrets1[] = {0xff, 0x06, 0x4f, 0xa6, 0x01, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0x40, 0x40, 0x54, 0x75, 0x72,\ 0x72, 0x65, 0x74, 0x5f, 0x54, 0x31, 0x5f, 0x52, 0x5f, 0x30, 0x33, 0x5f, 0x41, 0x00, 0x74, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02, 0x00, 0x00, 0x03, 0x00, 0x1f, 0x00, 0xc5,\ 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74, 0x04,\ 0x01, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38, 0x14, 0x68, 0x00, 0x00,\ 0x80, 0x01, 0xff, 0x01, 0x4a, 0x02, 0x00, 0x00, 0x40, 0x40, 0x54, 0x75, 0x72, 0x72, 0x65, 0x74,\ 0x5f, 0x54, 0x31, 0x5f, 0x52, 0x5f, 0x30, 0x32, 0x5f, 0x41, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02, 0x00, 0x00, 0x03, 0x00, 0x1f, 0x00, 0xc5, 0x16, 0x68, 0x76,\ 0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74, 0x04, 0x01, 0x00, 0x00,\ 0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38, 0x14, 0x68, 0x00, 0x00, 0x80, 0x01, 0xff,\ 0x01, 0x4a, 0x03, 0x00, 0x00, 0x40, 0x40, 0x54, 0x75, 0x72, 0x72, 0x65, 0x74, 0x5f, 0x54, 0x31,\ 0x5f, 0x43, 0x5f, 0x30, 0x37, 0x5f, 0x41, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0xa0, 0x02, 0x00, 0x00, 0x03, 0x00, 0x1f, 0x00, 0xc5, 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59,\ 0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74, 0x04, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00,\ 0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38, 0x14, 0x68, 0x00, 0x00, 0x80, 0x01, 0xff, 0x01, 0x4a, 0x04,\ 0x00, 0x00, 0x40, 0x40, 0x54, 0x75, 0x72, 0x72, 0x65, 0x74, 0x5f, 0x54, 0x32, 0x5f, 0x52, 0x5f,\ 0x30, 0x33, 0x5f, 0x41, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02,\ 0x00, 0x00, 0x03, 0x00, 0x1f, 0x00, 0xc5, 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9,\ 0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74, 0x04, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8,\ 0x18, 0x00, 0x38, 0x14, 0x68, 0x00, 0x00, 0x80, 0x01, 0xff, 0x01, 0x4a, 0x05, 0x00, 0x00, 0x40,\ 0x40, 0x54, 0x75, 0x72, 0x72, 0x65, 0x74, 0x5f, 0x54, 0x32, 0x5f, 0x52, 0x5f, 0x30, 0x32, 0x5f,\ 0x41, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02, 0x00, 0x00, 0x03,\ 0x00, 0x1f, 0x00, 0xc5, 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2,\ 0xb9, 0xa8, 0x74, 0x04, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38,\ 0x14, 0x68, 0x00, 0x00, 0x80, 0x01, 0xff, 0x01, 0x4a, 0x06, 0x00, 0x00, 0x40, 0x40, 0x54, 0x75,\ 0x72, 0x72, 0x65, 0x74, 0x5f, 0x54, 0x32, 0x5f, 0x52, 0x5f, 0x30, 0x31, 0x5f, 0x41, 0x00, 0x74,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02, 0x00, 0x00, 0x03, 0x00, 0x1f, 0x00,\ 0xc5, 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74,\ 0x04, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38, 0x14, 0x68, 0x00,\ 0x00, 0x80, 0x01, 0x12, 0x00, 0x00, 0x00, 0x00}; uint8 turrets2[] = {0xff, 0x06, 0x4f, 0xa6, 0x07, 0x00, 0x00, 0x40, 0x07, 0x00, 0x00, 0x40, 0x40, 0x54, 0x75, 0x72,\ 0x72, 0x65, 0x74, 0x5f, 0x54, 0x31, 0x5f, 0x43, 0x5f, 0x30, 0x35, 0x5f, 0x41, 0x00, 0x74, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02, 0x00, 0x00, 0x03, 0x00, 0x1f, 0x00, 0xc5,\ 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74, 0x04,\ 0x01, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38, 0x14, 0x68, 0x00, 0x00,\ 0x80, 0x01, 0xff, 0x01, 0x4a, 0x08, 0x00, 0x00, 0x40, 0x40, 0x54, 0x75, 0x72, 0x72, 0x65, 0x74,\ 0x5f, 0x54, 0x31, 0x5f, 0x43, 0x5f, 0x30, 0x34, 0x5f, 0x41, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02, 0x00, 0x00, 0x03, 0x00, 0x1f, 0x00, 0xc5, 0x16, 0x68, 0x76,\ 0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74, 0x04, 0x01, 0x00, 0x00,\ 0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38, 0x14, 0x68, 0x00, 0x00, 0x80, 0x01, 0xff,\ 0x01, 0x4a, 0x09, 0x00, 0x00, 0x40, 0x40, 0x54, 0x75, 0x72, 0x72, 0x65, 0x74, 0x5f, 0x54, 0x31,\ 0x5f, 0x43, 0x5f, 0x30, 0x33, 0x5f, 0x41, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0xa0, 0x02, 0x00, 0x00, 0x03, 0x00, 0x1f, 0x00, 0xc5, 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59,\ 0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74, 0x04, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00,\ 0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38, 0x14, 0x68, 0x00, 0x00, 0x80, 0x01, 0xff, 0x01, 0x4a, 0x0a,\ 0x00, 0x00, 0x40, 0x40, 0x54, 0x75, 0x72, 0x72, 0x65, 0x74, 0x5f, 0x54, 0x31, 0x5f, 0x43, 0x5f,\ 0x30, 0x31, 0x5f, 0x41, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02,\ 0x00, 0x00, 0x03, 0x00, 0x1f, 0x00, 0xc5, 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9,\ 0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74, 0x04, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8,\ 0x18, 0x00, 0x38, 0x14, 0x68, 0x00, 0x00, 0x80, 0x01, 0xff, 0x01, 0x4a, 0x0b, 0x00, 0x00, 0x40,\ 0x40, 0x54, 0x75, 0x72, 0x72, 0x65, 0x74, 0x5f, 0x54, 0x31, 0x5f, 0x43, 0x5f, 0x30, 0x32, 0x5f,\ 0x41, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02, 0x00, 0x00, 0x03,\ 0x00, 0x1f, 0x00, 0xc5, 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2,\ 0xb9, 0xa8, 0x74, 0x04, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38,\ 0x14, 0x68, 0x00, 0x00, 0x80, 0x01, 0xff, 0x01, 0x4a, 0x0c, 0x00, 0x00, 0x40, 0x40, 0x54, 0x75,\ 0x72, 0x72, 0x65, 0x74, 0x5f, 0x54, 0x32, 0x5f, 0x43, 0x5f, 0x30, 0x35, 0x5f, 0x41, 0x00, 0x74,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02, 0x00, 0x00, 0x03, 0x00, 0x1f, 0x00,\ 0xc5, 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74,\ 0x04, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38, 0x14, 0x68, 0x00,\ 0x00, 0x80, 0x01}; uint8 turrets3[] = {0xff, 0x06, 0x4f, 0xa6, 0x0d, 0x00, 0x00, 0x40, 0x0d, 0x00, 0x00, 0x40, 0x40, 0x54, 0x75, 0x72,\ 0x72, 0x65, 0x74, 0x5f, 0x54, 0x32, 0x5f, 0x43, 0x5f, 0x30, 0x34, 0x5f, 0x41, 0x00, 0x74, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02, 0x00, 0x00, 0x03, 0x00, 0x1f, 0x00, 0xc5,\ 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74, 0x04,\ 0x01, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38, 0x14, 0x68, 0x00, 0x00,\ 0x80, 0x01, 0xff, 0x01, 0x4a, 0x0e, 0x00, 0x00, 0x40, 0x40, 0x54, 0x75, 0x72, 0x72, 0x65, 0x74,\ 0x5f, 0x54, 0x32, 0x5f, 0x43, 0x5f, 0x30, 0x33, 0x5f, 0x41, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02, 0x00, 0x00, 0x03, 0x00, 0x1f, 0x00, 0xc5, 0x16, 0x68, 0x76,\ 0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74, 0x04, 0x01, 0x00, 0x00,\ 0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38, 0x14, 0x68, 0x00, 0x00, 0x80, 0x01, 0xff,\ 0x01, 0x4a, 0x0f, 0x00, 0x00, 0x40, 0x40, 0x54, 0x75, 0x72, 0x72, 0x65, 0x74, 0x5f, 0x54, 0x32,\ 0x5f, 0x43, 0x5f, 0x30, 0x31, 0x5f, 0x41, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ 0x00, 0xa0, 0x02, 0x00, 0x00, 0x03, 0x00, 0x1f, 0x00, 0xc5, 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59,\ 0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74, 0x04, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00,\ 0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38, 0x14, 0x68, 0x00, 0x00, 0x80, 0x01, 0xff, 0x01, 0x4a, 0x10,\ 0x00, 0x00, 0x40, 0x40, 0x54, 0x75, 0x72, 0x72, 0x65, 0x74, 0x5f, 0x54, 0x32, 0x5f, 0x43, 0x5f,\ 0x30, 0x32, 0x5f, 0x41, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02,\ 0x00, 0x00, 0x03, 0x00, 0x1f, 0x00, 0xc5, 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9,\ 0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74, 0x04, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8,\ 0x18, 0x00, 0x38, 0x14, 0x68, 0x00, 0x00, 0x80, 0x01, 0xff, 0x01, 0x4a, 0x11, 0x00, 0x00, 0x40,\ 0x40, 0x54, 0x75, 0x72, 0x72, 0x65, 0x74, 0x5f, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x54, 0x75, 0x72,\ 0x72, 0x65, 0x74, 0x53, 0x68, 0x72, 0x69, 0x6e, 0x65, 0x5f, 0x41, 0x00, 0x02, 0x00, 0x00, 0x03,\ 0x00, 0x1f, 0x00, 0xc5, 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2,\ 0xb9, 0xa8, 0x74, 0x04, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38,\ 0x14, 0x68, 0x00, 0x00, 0x80, 0x01, 0xff, 0x01, 0x4a, 0x12, 0x00, 0x00, 0x40, 0x40, 0x54, 0x75,\ 0x72, 0x72, 0x65, 0x74, 0x5f, 0x43, 0x68, 0x61, 0x6f, 0x73, 0x54, 0x75, 0x72, 0x72, 0x65, 0x74,\ 0x53, 0x68, 0x72, 0x69, 0x6e, 0x65, 0x5f, 0x41, 0x00, 0x02, 0x00, 0x00, 0x03, 0x00, 0x1f, 0x00,\ 0xc5, 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74,\ 0x04, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38, 0x14, 0x68, 0x00,\ 0x00, 0x80, 0x01}; uint8 turrets4[] = {0xff, 0x07, 0x4f, 0xa6, 0x13, 0x00, 0x00, 0x40, 0x13, 0x00, 0x00, 0x40, 0x40, 0x54, 0x75, 0x72,\ 0x72, 0x65, 0x74, 0x5f, 0x54, 0x31, 0x5f, 0x4c, 0x5f, 0x30, 0x33, 0x5f, 0x41, 0x00, 0x74, 0x53,\ 0x68, 0x72, 0x69, 0x6e, 0x65, 0x5f, 0x41, 0x00, 0x02, 0x00, 0x00, 0x03, 0x00, 0x1f, 0x00, 0xc5,\ 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74, 0x04,\ 0x01, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38, 0x14, 0x68, 0x00, 0x00,\ 0x80, 0x01, 0xff, 0x01, 0x4a, 0x14, 0x00, 0x00, 0x40, 0x40, 0x54, 0x75, 0x72, 0x72, 0x65, 0x74,\ 0x5f, 0x54, 0x31, 0x5f, 0x4c, 0x5f, 0x30, 0x32, 0x5f, 0x41, 0x00, 0x74, 0x53, 0x68, 0x72, 0x69,\ 0x6e, 0x65, 0x5f, 0x41, 0x00, 0x02, 0x00, 0x00, 0x03, 0x00, 0x1f, 0x00, 0xc5, 0x16, 0x68, 0x76,\ 0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74, 0x04, 0x01, 0x00, 0x00,\ 0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38, 0x14, 0x68, 0x00, 0x00, 0x80, 0x01, 0xff,\ 0x01, 0x4a, 0x15, 0x00, 0x00, 0x40, 0x40, 0x54, 0x75, 0x72, 0x72, 0x65, 0x74, 0x5f, 0x54, 0x31,\ 0x5f, 0x43, 0x5f, 0x30, 0x36, 0x5f, 0x41, 0x00, 0x74, 0x53, 0x68, 0x72, 0x69, 0x6e, 0x65, 0x5f,\ 0x41, 0x00, 0x02, 0x00, 0x00, 0x03, 0x00, 0x1f, 0x00, 0xc5, 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59,\ 0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74, 0x04, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00,\ 0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38, 0x14, 0x68, 0x00, 0x00, 0x80, 0x01, 0xff, 0x01, 0x4a, 0x16,\ 0x00, 0x00, 0x40, 0x40, 0x54, 0x75, 0x72, 0x72, 0x65, 0x74, 0x5f, 0x54, 0x32, 0x5f, 0x4c, 0x5f,\ 0x30, 0x33, 0x5f, 0x41, 0x00, 0x74, 0x53, 0x68, 0x72, 0x69, 0x6e, 0x65, 0x5f, 0x41, 0x00, 0x02,\ 0x00, 0x00, 0x03, 0x00, 0x1f, 0x00, 0xc5, 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9,\ 0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74, 0x04, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8,\ 0x18, 0x00, 0x38, 0x14, 0x68, 0x00, 0x00, 0x80, 0x01, 0xff, 0x01, 0x4a, 0x17, 0x00, 0x00, 0x40,\ 0x40, 0x54, 0x75, 0x72, 0x72, 0x65, 0x74, 0x5f, 0x54, 0x32, 0x5f, 0x4c, 0x5f, 0x30, 0x32, 0x5f,\ 0x41, 0x00, 0x74, 0x53, 0x68, 0x72, 0x69, 0x6e, 0x65, 0x5f, 0x41, 0x00, 0x02, 0x00, 0x00, 0x03,\ 0x00, 0x1f, 0x00, 0xc5, 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2,\ 0xb9, 0xa8, 0x74, 0x04, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38,\ 0x14, 0x68, 0x00, 0x00, 0x80, 0x01, 0xff, 0x01, 0x4a, 0x18, 0x00, 0x00, 0x40, 0x40, 0x54, 0x75,\ 0x72, 0x72, 0x65, 0x74, 0x5f, 0x54, 0x32, 0x5f, 0x4c, 0x5f, 0x30, 0x31, 0x5f, 0x41, 0x00, 0x74,\ 0x53, 0x68, 0x72, 0x69, 0x6e, 0x65, 0x5f, 0x41, 0x00, 0x02, 0x00, 0x00, 0x03, 0x00, 0x1f, 0x00,\ 0xc5, 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74,\ 0x04, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38, 0x14, 0x68, 0x00,\ 0x00, 0x80, 0x01, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00}; HeroSpawnPacket *heroSpawn = HeroSpawnPacket::create(PKT_HeroSpawn, peerInfo(peer)->name, peerInfo(peer)->nameLen, peerInfo(peer)->type, peerInfo(peer)->typeLen); sendPacket(peer, reinterpret_cast<uint8*>(heroSpawn), heroSpawn->getPacketLength(), 3); sendPacket(peer, reinterpret_cast<uint8*>(bounds), sizeof(bounds), 3); sendPacket(peer, reinterpret_cast<uint8*>(turrets1), sizeof(turrets1), 3); sendPacket(peer, reinterpret_cast<uint8*>(turrets2), sizeof(turrets2), 3); sendPacket(peer, reinterpret_cast<uint8*>(turrets3), sizeof(turrets3), 3); sendPacket(peer, reinterpret_cast<uint8*>(turrets4), sizeof(turrets4), 3); return true; }
void FMS::periodic() { if(isConnected()) { //If it's time then send a heartbeat request if(millis() - fmsLastSeen > FMS_HEARTBEAT_DELAY) //Add stuff to prevent dropped packets maybe idc { disableWatchdogs(); // Make sure watchdogs don't die when checking on heartbeat //Serial.println(F("Checking on heartbeat")); //TODO: dleete this sendPacket(F("HB_LUB")); long hbStarted = millis(); while(str_equals(readLine(), "")) { if(millis() - hbStarted > FMS_HEARTBEAT_TIMEOUT) { connectedToFMS = false; client.close(); Serial.println(F("FMS connection dropped.")); setState(DISABLED); enableWatchdogs(); return; } } fmsLastSeen = millis(); enableWatchdogs(); } //handle packets from fms char* input = readLine(); if(!str_equals(input, "")) { if(str_startsWith(input, "S_S_")) { str_replace(input, "S_S_", ""); if(str_startsWith(input, "A")) { setState(AUTONOMOUS); } else if(str_startsWith(input, "D")) { setState(DISABLED); } else if(str_startsWith(input, "T")) { setState(TELEOP); } sendPacket(F("S_ACK")); } else Serial.println(input); //Something wrong happened so lets output it for debug fmsLastSeen = millis(); } } else { disableWatchdogs(); connect(); enableWatchdogs(); } }
int tuntap_write(struct net_device *net_dev, void *buf, size_t count) { if(net_dev->priv == NULL) return -1; return sendPacket((tap_win32*)net_dev->priv, buf, count); }
void AudioMixer::run() { ThreadedAssignment::commonInit(AUDIO_MIXER_LOGGING_TARGET_NAME, NodeType::AudioMixer); auto nodeList = DependencyManager::get<NodeList>(); nodeList->addNodeTypeToInterestSet(NodeType::Agent); nodeList->linkedDataCreateCallback = [](Node* node) { node->setLinkedData(new AudioMixerClientData()); }; // wait until we have the domain-server settings, otherwise we bail DomainHandler& domainHandler = nodeList->getDomainHandler(); qDebug() << "Waiting for domain settings from domain-server."; // block until we get the settingsRequestComplete signal QEventLoop loop; connect(&domainHandler, &DomainHandler::settingsReceived, &loop, &QEventLoop::quit); connect(&domainHandler, &DomainHandler::settingsReceiveFail, &loop, &QEventLoop::quit); domainHandler.requestDomainSettings(); loop.exec(); if (domainHandler.getSettingsObject().isEmpty()) { qDebug() << "Failed to retreive settings object from domain-server. Bailing on assignment."; setFinished(true); return; } const QJsonObject& settingsObject = domainHandler.getSettingsObject(); // check the settings object to see if we have anything we can parse out parseSettingsObject(settingsObject); int nextFrame = 0; QElapsedTimer timer; timer.start(); int usecToSleep = AudioConstants::NETWORK_FRAME_USECS; const int TRAILING_AVERAGE_FRAMES = 100; int framesSinceCutoffEvent = TRAILING_AVERAGE_FRAMES; while (!_isFinished) { const float STRUGGLE_TRIGGER_SLEEP_PERCENTAGE_THRESHOLD = 0.10f; const float BACK_OFF_TRIGGER_SLEEP_PERCENTAGE_THRESHOLD = 0.20f; const float RATIO_BACK_OFF = 0.02f; const float CURRENT_FRAME_RATIO = 1.0f / TRAILING_AVERAGE_FRAMES; const float PREVIOUS_FRAMES_RATIO = 1.0f - CURRENT_FRAME_RATIO; if (usecToSleep < 0) { usecToSleep = 0; } _trailingSleepRatio = (PREVIOUS_FRAMES_RATIO * _trailingSleepRatio) + (usecToSleep * CURRENT_FRAME_RATIO / (float) AudioConstants::NETWORK_FRAME_USECS); float lastCutoffRatio = _performanceThrottlingRatio; bool hasRatioChanged = false; if (framesSinceCutoffEvent >= TRAILING_AVERAGE_FRAMES) { if (_trailingSleepRatio <= STRUGGLE_TRIGGER_SLEEP_PERCENTAGE_THRESHOLD) { // we're struggling - change our min required loudness to reduce some load _performanceThrottlingRatio = _performanceThrottlingRatio + (0.5f * (1.0f - _performanceThrottlingRatio)); qDebug() << "Mixer is struggling, sleeping" << _trailingSleepRatio * 100 << "% of frame time. Old cutoff was" << lastCutoffRatio << "and is now" << _performanceThrottlingRatio; hasRatioChanged = true; } else if (_trailingSleepRatio >= BACK_OFF_TRIGGER_SLEEP_PERCENTAGE_THRESHOLD && _performanceThrottlingRatio != 0) { // we've recovered and can back off the required loudness _performanceThrottlingRatio = _performanceThrottlingRatio - RATIO_BACK_OFF; if (_performanceThrottlingRatio < 0) { _performanceThrottlingRatio = 0; } qDebug() << "Mixer is recovering, sleeping" << _trailingSleepRatio * 100 << "% of frame time. Old cutoff was" << lastCutoffRatio << "and is now" << _performanceThrottlingRatio; hasRatioChanged = true; } if (hasRatioChanged) { // set out min audability threshold from the new ratio _minAudibilityThreshold = LOUDNESS_TO_DISTANCE_RATIO / (2.0f * (1.0f - _performanceThrottlingRatio)); qDebug() << "Minimum audability required to be mixed is now" << _minAudibilityThreshold; framesSinceCutoffEvent = 0; } } if (!hasRatioChanged) { ++framesSinceCutoffEvent; } quint64 now = usecTimestampNow(); if (now - _lastPerSecondCallbackTime > USECS_PER_SECOND) { perSecondActions(); _lastPerSecondCallbackTime = now; } nodeList->eachNode([&](const SharedNodePointer& node) { if (node->getLinkedData()) { AudioMixerClientData* nodeData = (AudioMixerClientData*)node->getLinkedData(); // this function will attempt to pop a frame from each audio stream. // a pointer to the popped data is stored as a member in InboundAudioStream. // That's how the popped audio data will be read for mixing (but only if the pop was successful) nodeData->checkBuffersBeforeFrameSend(); // if the stream should be muted, send mute packet if (nodeData->getAvatarAudioStream() && shouldMute(nodeData->getAvatarAudioStream()->getQuietestFrameLoudness())) { auto mutePacket = NLPacket::create(PacketType::NoisyMute, 0); nodeList->sendPacket(std::move(mutePacket), *node); } if (node->getType() == NodeType::Agent && node->getActiveSocket() && nodeData->getAvatarAudioStream()) { int streamsMixed = prepareMixForListeningNode(node.data()); std::unique_ptr<NLPacket> mixPacket; if (streamsMixed > 0) { int mixPacketBytes = sizeof(quint16) + AudioConstants::NETWORK_FRAME_BYTES_STEREO; mixPacket = NLPacket::create(PacketType::MixedAudio, mixPacketBytes); // pack sequence number quint16 sequence = nodeData->getOutgoingSequenceNumber(); mixPacket->writePrimitive(sequence); // pack mixed audio samples mixPacket->write(reinterpret_cast<char*>(_mixSamples), AudioConstants::NETWORK_FRAME_BYTES_STEREO); } else { int silentPacketBytes = sizeof(quint16) + sizeof(quint16); mixPacket = NLPacket::create(PacketType::SilentAudioFrame, silentPacketBytes); // pack sequence number quint16 sequence = nodeData->getOutgoingSequenceNumber(); mixPacket->writePrimitive(sequence); // pack number of silent audio samples quint16 numSilentSamples = AudioConstants::NETWORK_FRAME_SAMPLES_STEREO; mixPacket->writePrimitive(numSilentSamples); } // Send audio environment sendAudioEnvironmentPacket(node); // send mixed audio packet nodeList->sendPacket(std::move(mixPacket), *node); nodeData->incrementOutgoingMixedAudioSequenceNumber(); // send an audio stream stats packet if it's time if (_sendAudioStreamStats) { nodeData->sendAudioStreamStatsPackets(node); _sendAudioStreamStats = false; } ++_sumListeners; } } }); ++_numStatFrames; // since we're a while loop we need to help Qt's event processing QCoreApplication::processEvents(); if (_isFinished) { // at this point the audio-mixer is done // check if we have a deferred delete event to process (which we should once finished) QCoreApplication::sendPostedEvents(this, QEvent::DeferredDelete); break; } usecToSleep = (++nextFrame * AudioConstants::NETWORK_FRAME_USECS) - timer.nsecsElapsed() / 1000; // ns to us if (usecToSleep > 0) { usleep(usecToSleep); } } }
void ICQClient::chn_login() { if (m_cookie.size()){ flap(ICQ_CHNxNEW); m_socket->writeBuffer << 0x00000001L; m_socket->writeBuffer.tlv(6, m_cookie.data(), (unsigned short)(m_cookie.size())); m_cookie.init(0); sendPacket(true); return; } if (data.owner.Uin.value){ string pswd = cryptPassword(); log(L_DEBUG, "Login %lu [%s]", data.owner.Uin.value, pswd.c_str()); char uin[20]; sprintf(uin, "%lu", data.owner.Uin.value); flap(ICQ_CHNxNEW); m_socket->writeBuffer << 0x00000001L; m_socket->writeBuffer.tlv(0x0001, uin); m_socket->writeBuffer.tlv(0x0002, pswd.c_str(), pswd.length()); m_socket->writeBuffer.tlv(0x0003, "ICQ Inc. - Product of ICQ (TM).2003b.5.56.1.3916.85"); m_socket->writeBuffer.tlv(0x0016, 0x010A); m_socket->writeBuffer.tlv(0x0017, 0x0002); m_socket->writeBuffer.tlv(0x0018, 0x0038); m_socket->writeBuffer.tlv(0x0019, 0x0001); m_socket->writeBuffer.tlv(0x001A, 0x0F4C); m_socket->writeBuffer.tlv(0x0014, 0x00000055L); m_socket->writeBuffer.tlv(0x000f, "en"); m_socket->writeBuffer.tlv(0x000e, "us"); sendPacket(true); return; } if (data.owner.Screen.ptr && *data.owner.Screen.ptr){ flap(ICQ_CHNxNEW); m_socket->writeBuffer << 0x00000001L; sendPacket(true); snac(ICQ_SNACxFAM_LOGIN, ICQ_SNACxLOGIN_AUTHxREQUEST, false, false); m_socket->writeBuffer.tlv(0x0001, data.owner.Screen.ptr); m_socket->writeBuffer.tlv(0x004B); m_socket->writeBuffer.tlv(0x005A); sendPacket(true); return; } flap(ICQ_CHNxNEW); m_socket->writeBuffer << 0x00000001L; sendPacket(true); snac(ICQ_SNACxFAM_LOGIN, ICQ_SNACxLOGIN_REGISTERxREQ); Buffer msg; msg << 0x00000000L << 0x28000300L << 0x00000000L << 0x00000000L << 0x94680000L << 0x94680000L << 0x00000000L << 0x00000000L << 0x00000000L << 0x00000000L; string pswd = getContacts()->fromUnicode(NULL, getPassword()); unsigned short len = (unsigned short)(pswd.length() + 1); msg.pack(len); msg.pack(pswd.c_str(), len); msg << 0x94680000L << 0x00000602L; m_socket->writeBuffer.tlv(0x0001, msg); sendPacket(true); }
/** A blank packet can be sent to exit monitor mode **/ AREXPORT bool ArDPPTU::blank(void) { myPacket.empty(); return sendPacket(&myPacket); }
/*********************************************************************** *%FUNCTION: sendPADI *%ARGUMENTS: * conn -- PPPoEConnection structure *%RETURNS: * Nothing *%DESCRIPTION: * Sends a PADI packet ***********************************************************************/ static void sendPADI(PPPoEConnection *conn) { PPPoEPacket packet; unsigned char *cursor = packet.payload; PPPoETag *svc = (PPPoETag *) (&packet.payload); UINT16_t namelen = 0; UINT16_t plen; int omit_service_name = 0; if (conn->serviceName) { namelen = (UINT16_t) strlen(conn->serviceName); if (!strcmp(conn->serviceName, "NO-SERVICE-NAME-NON-RFC-COMPLIANT")) { omit_service_name = 1; } } /* Set destination to Ethernet broadcast address */ memset(packet.ethHdr.h_dest, 0xFF, ETH_ALEN); memcpy(packet.ethHdr.h_source, conn->myEth, ETH_ALEN); packet.ethHdr.h_proto = htons(Eth_PPPOE_Discovery); packet.vertype = PPPOE_VER_TYPE(1, 1); packet.code = CODE_PADI; packet.session = 0; if (!omit_service_name) { plen = TAG_HDR_SIZE + namelen; CHECK_ROOM(cursor, packet.payload, plen); svc->type = TAG_SERVICE_NAME; svc->length = htons(namelen); if (conn->serviceName) { memcpy(svc->payload, conn->serviceName, strlen(conn->serviceName)); } cursor += namelen + TAG_HDR_SIZE; } else { plen = 0; } /* If we're using Host-Uniq, copy it over */ if (conn->useHostUniq) { PPPoETag hostUniq; pid_t pid = getpid(); hostUniq.type = htons(TAG_HOST_UNIQ); hostUniq.length = htons(sizeof(pid)); memcpy(hostUniq.payload, &pid, sizeof(pid)); CHECK_ROOM(cursor, packet.payload, sizeof(pid) + TAG_HDR_SIZE); memcpy(cursor, &hostUniq, sizeof(pid) + TAG_HDR_SIZE); cursor += sizeof(pid) + TAG_HDR_SIZE; plen += sizeof(pid) + TAG_HDR_SIZE; } /* Add our maximum MTU/MRU */ if (MIN(lcp_allowoptions[0].mru, lcp_wantoptions[0].mru) > ETH_PPPOE_MTU) { PPPoETag maxPayload; UINT16_t mru = htons(MIN(lcp_allowoptions[0].mru, lcp_wantoptions[0].mru)); maxPayload.type = htons(TAG_PPP_MAX_PAYLOAD); maxPayload.length = htons(sizeof(mru)); memcpy(maxPayload.payload, &mru, sizeof(mru)); CHECK_ROOM(cursor, packet.payload, sizeof(mru) + TAG_HDR_SIZE); memcpy(cursor, &maxPayload, sizeof(mru) + TAG_HDR_SIZE); cursor += sizeof(mru) + TAG_HDR_SIZE; plen += sizeof(mru) + TAG_HDR_SIZE; } packet.length = htons(plen); sendPacket(conn, conn->discoverySocket, &packet, (int) (plen + HDR_SIZE)); }
void LLXfer::sendNextPacket() { mRetries = 0; sendPacket(++mPacketNum); }
/*********************************************************************** *%FUNCTION: sendPADR *%ARGUMENTS: * conn -- PPPoE connection structur *%RETURNS: * Nothing *%DESCRIPTION: * Sends a PADR packet ***********************************************************************/ static void sendPADR(PPPoEConnection *conn) { PPPoEPacket packet; PPPoETag *svc = (PPPoETag *) packet.payload; unsigned char *cursor = packet.payload; UINT16_t namelen = 0; UINT16_t plen; if (conn->serviceName) { namelen = (UINT16_t) strlen(conn->serviceName); } plen = TAG_HDR_SIZE + namelen; CHECK_ROOM(cursor, packet.payload, plen); memcpy(packet.ethHdr.h_dest, conn->peerEth, ETH_ALEN); memcpy(packet.ethHdr.h_source, conn->myEth, ETH_ALEN); packet.ethHdr.h_proto = htons(Eth_PPPOE_Discovery); packet.vertype = PPPOE_VER_TYPE(1, 1); packet.code = CODE_PADR; packet.session = 0; svc->type = TAG_SERVICE_NAME; svc->length = htons(namelen); if (conn->serviceName) { memcpy(svc->payload, conn->serviceName, namelen); } cursor += namelen + TAG_HDR_SIZE; /* If we're using Host-Uniq, copy it over */ if (conn->useHostUniq) { PPPoETag hostUniq; pid_t pid = getpid(); hostUniq.type = htons(TAG_HOST_UNIQ); hostUniq.length = htons(sizeof(pid)); memcpy(hostUniq.payload, &pid, sizeof(pid)); CHECK_ROOM(cursor, packet.payload, sizeof(pid)+TAG_HDR_SIZE); memcpy(cursor, &hostUniq, sizeof(pid) + TAG_HDR_SIZE); cursor += sizeof(pid) + TAG_HDR_SIZE; plen += sizeof(pid) + TAG_HDR_SIZE; } /* Add our maximum MTU/MRU */ if (MIN(lcp_allowoptions[0].mru, lcp_wantoptions[0].mru) > ETH_PPPOE_MTU) { PPPoETag maxPayload; UINT16_t mru = htons(MIN(lcp_allowoptions[0].mru, lcp_wantoptions[0].mru)); maxPayload.type = htons(TAG_PPP_MAX_PAYLOAD); maxPayload.length = htons(sizeof(mru)); memcpy(maxPayload.payload, &mru, sizeof(mru)); CHECK_ROOM(cursor, packet.payload, sizeof(mru) + TAG_HDR_SIZE); memcpy(cursor, &maxPayload, sizeof(mru) + TAG_HDR_SIZE); cursor += sizeof(mru) + TAG_HDR_SIZE; plen += sizeof(mru) + TAG_HDR_SIZE; } /* Copy cookie and relay-ID if needed */ if (conn->cookie.type) { CHECK_ROOM(cursor, packet.payload, ntohs(conn->cookie.length) + TAG_HDR_SIZE); memcpy(cursor, &conn->cookie, ntohs(conn->cookie.length) + TAG_HDR_SIZE); cursor += ntohs(conn->cookie.length) + TAG_HDR_SIZE; plen += ntohs(conn->cookie.length) + TAG_HDR_SIZE; } if (conn->relayId.type) { CHECK_ROOM(cursor, packet.payload, ntohs(conn->relayId.length) + TAG_HDR_SIZE); memcpy(cursor, &conn->relayId, ntohs(conn->relayId.length) + TAG_HDR_SIZE); cursor += ntohs(conn->relayId.length) + TAG_HDR_SIZE; plen += ntohs(conn->relayId.length) + TAG_HDR_SIZE; } packet.length = htons(plen); sendPacket(conn, conn->discoverySocket, &packet, (int) (plen + HDR_SIZE)); }
bool Adafruit_BluefruitLE_SPI::sendInitializePattern(void) { return sendPacket(SDEP_CMDTYPE_INITIALIZE, NULL, 0, 0); }
// processEvents consults with the state and initiates packet handling // additionally, if a timeout occurs, it re-initiates or terminates transmission // does NOT RESET the flags! Also, initiates a packet transmission void EZRoboNetDevice::processEvents() { if (state == stPacketReady) { // the packet is assembled and ready // increase number of packets received if (ReceivedPacketsNum<2) { ReceivedPacketsNum++; ReceivedPackets[ReceivedPacketsNum-1] = bytes2Packet(CurrentPacket); } else // raise overflow flag PacketQueueOverflow = true; // disposing CurrentPacket free(CurrentPacket); // resetting the RoboNetDevice state = stIdle; PacketReceiverID = 0; TotalFrames = 0; FramesReceived = 0; } else if (state == stWaitingAcknowledge) { // waiting for acknowledge // checking time ellapsed unsigned long currentTime = millis(); unsigned long transmissionElapsed = currentTime - TransmissionStartTime; if (transmissionElapsed > PACKET_SENDING_TIMEOUT) { // transmission timedout // raising error flag Serial.println("Packet Sending Timedout!"); PacketSendTimeout = true; // quiting everything and resetting free(CurrentPacket); PacketSenderID = 0; PacketReceiverID = 0; TotalFrames = 0; FramesSent = 0; FramesReceived = 0; state = stIdle; } else { unsigned long elapsed = currentTime - FrameTransmissionStartTime; if (elapsed > FRAME_ACKNOWLEDGE_TIMEOUT) { // timeout occured Serial.println("Acknowledge timeout!"); // attempting to resend the frame state = stSending; // sending again sendNextFrame(); } } } else if (state == stReceiving) { // receiving a packet unsigned long currentTime = millis(); unsigned long receptionElapsed = currentTime - ReceptionStartTime; if (receptionElapsed > PACKET_SENDING_TIMEOUT) { // packet's timedout // raising error flag PacketReceiveTimeout = true; // disposing packet free(CurrentPacket); // resetting PacketReceiverID = 0; PacketSenderID = 0; TotalFrames = 0; FramesSent = 0; FramesReceived = 0; state = stIdle; } else { // checking time elapsed since last acknowledgement unsigned long elapsed = currentTime - FrameReceptionStartTime; if (elapsed > FRAME_ACKNOWLEDGE_TIMEOUT) { // next frame timedout // sending a new acknowledgement sendAcknowledge(PacketReceiverID); // reseting time FrameReceptionStartTime = millis(); state = stReceiving; } } } else if (state==stIdle) { if (OutboundPacketsNum>0) { // outbound queue is not empty. must initiate transmission // removing a packet from the outbound queue EZPacket* outpacket = OutboundPackets[0]; OutboundPacketsNum--; OutboundPackets[0] = NULL; // shifting the Outbound queue to the left int i; for (i=1; i<=OutboundPacketsNum; i++) { OutboundPackets[i-1] = OutboundPackets[i]; OutboundPackets[i] = NULL; } // outbound queue shifted // Now, sending packet sendPacket(outpacket); } } }
void SshSendFacility::sendUserAuthByKeyRequestPacket(const QByteArray &user, const QByteArray &service) { m_outgoingPacket.generateUserAuthByKeyRequestPacket(user, service); sendPacket(); }
/* success -> return packet type fail-> return FAIL */ int cycle(MQTTClient* c, Timer* timer) { int packet_type = readPacket(c, timer); int len = 0; int rc = SUCCESS; if (FAILURE == packet_type) { packet_type = NOPACKET; goto exit; } printf("received %s\n", MQTTPacket_names[packet_type]); switch (packet_type) { case CONNACK: case PUBACK: case SUBACK: break; case PUBLISH: { MQTTString topicName; MQTTMessage msg; int intQoS; if (MQTTDeserialize_publish(&msg.dup, &intQoS, &msg.retained, &msg.id, &topicName, (unsigned char**)&msg.payload, (int*)&msg.payloadlen, c->readbuf, c->readbuf_size) != 1) goto exit; msg.qos = (enum QoS)intQoS; //deliverMessage(c, &topicName, &msg); if (msg.qos != QOS0) { if (msg.qos == QOS1) len = MQTTSerialize_ack(c->buf, c->buf_size, PUBACK, 0, msg.id); else if (msg.qos == QOS2) len = MQTTSerialize_ack(c->buf, c->buf_size, PUBREC, 0, msg.id); if (len <= 0) rc = FAILURE; else rc = sendPacket(c, len, timer); if (rc == FAILURE) goto exit; // there was a problem } deliverMessage(c, &topicName, &msg); break; } case PUBREC: { unsigned short mypacketid; unsigned char dup, type; if (MQTTDeserialize_ack(&type, &dup, &mypacketid, c->readbuf, c->readbuf_size) != 1) rc = FAILURE; else if ((len = MQTTSerialize_ack(c->buf, c->buf_size, PUBREL, 0, mypacketid)) <= 0) rc = FAILURE; else if ((rc = sendPacket(c, len, timer)) != SUCCESS) // send the PUBREL packet rc = FAILURE; // there was a problem if (rc == FAILURE) goto exit; // there was a problem break; } case PUBCOMP: break; case PINGRESP: c->ping_outstanding = 0; //c->keepAliveFailCount = 0; break; case PUBREL: { unsigned short mypacketid; unsigned char dup, type; if (MQTTDeserialize_ack(&type, &dup, &mypacketid, c->readbuf, c->readbuf_size) != 1) rc = FAILURE; else if ((len = MQTTSerialize_ack(c->buf, c->buf_size, PUBCOMP, 0, mypacketid)) <= 0) rc = FAILURE; else if ((rc = sendPacket(c, len, timer)) != SUCCESS) // send the PUBCOMP packet rc = FAILURE; // there was a problem if (rc == FAILURE) goto exit; // there was a problem break; } } exit: if (FAILURE == keepalive(c)) { rc = FAILURE; } if (rc == SUCCESS) rc = packet_type; return rc; }