signed WriteParameters1 (struct plc * plc, unsigned module, const struct nvm_header1 * nvm_header) { struct channel * channel = (struct channel *)(plc->channel); struct message * message = (struct message *)(plc->message); #ifndef __GNUC__ #pragma pack (push,1) #endif struct __packed vs_wr_mem_request { struct ethernet_hdr ethernet; struct qualcomm_hdr qualcomm; uint32_t MOFFSET; uint32_t MLENGTH; uint8_t BUFFER [PLC_RECORD_SIZE]; } * request = (struct vs_wr_mem_request *) (message); struct __packed vs_wr_mem_confirm { struct ethernet_hdr ethernet; struct qualcomm_hdr qualcomm; uint8_t MSTATUS; uint32_t MOFFSET; uint32_t MLENGTH; } * confirm = (struct vs_wr_mem_confirm *) (message); #ifndef __GNUC__ #pragma pack (pop) #endif uint32_t length = PLC_RECORD_SIZE; uint32_t offset = LE32TOH (nvm_header->IMAGEADDRESS); uint32_t extent = LE32TOH (nvm_header->IMAGELENGTH); Request (plc, "Write %s (%d) (%08X:%d)", plc->PIB.name, module, offset, extent); while (extent) { memset (message, 0, sizeof (* message)); EthernetHeader (&request->ethernet, channel->peer, channel->host, channel->type); QualcommHeader (&request->qualcomm, 0, (VS_WR_MEM | MMTYPE_REQ)); if (length > extent) { length = extent; } if (read (plc->PIB.file, request->BUFFER, length) != (signed)(length)) { error (1, errno, FILE_CANTREAD, plc->PIB.name); } request->MLENGTH = HTOLE32 (length); request->MOFFSET = HTOLE32 (offset); plc->packetsize = sizeof (* request); if (SendMME (plc) <= 0) { error (PLC_EXIT (plc), errno, CHANNEL_CANTSEND); return (-1); } if (ReadMME (plc, 0, (VS_WR_MEM | MMTYPE_CNF)) <= 0) { error (PLC_EXIT (plc), errno, CHANNEL_CANTREAD); return (-1); } if (confirm->MSTATUS) { Failure (plc, PLC_WONTDOIT); return (-1); } if (LE32TOH (confirm->MLENGTH) != length) { error (PLC_EXIT (plc), 0, PLC_ERR_LENGTH); return (-1); } if (LE32TOH (confirm->MOFFSET) != offset) { error (PLC_EXIT (plc), 0, PLC_ERR_OFFSET); return (-1); } offset += length; extent -= length; } return (0); }
signed SetNMK (struct int6k * int6k) { struct channel * channel = (struct channel *)(int6k->channel); struct message * message = (struct message *)(int6k->message); #ifndef __GNUC__ #pragma pack (push,1) #endif struct __packed vs_set_key_request { struct header_eth ethernet; struct header_int intellon; uint8_t EKS; uint8_t NMK [HPAVKEY_NMK_LEN]; uint8_t PEKS; uint8_t RDA [ETHER_ADDR_LEN]; uint8_t DAK [HPAVKEY_DAK_LEN]; } * request = (struct vs_set_key_request *) (message); struct __packed vs_set_key_confirm { struct header_eth ethernet; struct header_int intellon; uint8_t MSTATUS; } * confirm = (struct vs_set_key_confirm *) (message); #ifndef __GNUC__ #pragma pack (pop) #endif memset (message, 0, sizeof (struct message)); EthernetHeader (&message->ethernet, channel->peer, channel->host); IntellonHeader (&message->intellon, (VS_SET_KEY | MMTYPE_REQ)); int6k->packetsize = sizeof (struct vs_set_key_request); request->EKS = 0x01; memcpy (request->NMK, int6k->NMK, sizeof (request->NMK)); if (_anyset (int6k->flags, INT6K_SETREMOTEKEY)) { Request (int6k, "Set Remote Network Membership Key"); memcpy (request->RDA, int6k->RDA, sizeof (request->RDA)); memcpy (request->DAK, int6k->DAK, sizeof (request->DAK)); request->PEKS = 0x00; } else { Request (int6k, "Set Local Network Membership Key"); memset (request->RDA, 0, sizeof (request->RDA)); memset (request->DAK, 0, sizeof (request->DAK)); request->PEKS = 0x0F; } if (SendMME (int6k) <= 0) { error ((int6k->flags & INT6K_BAILOUT), ECANCELED, INT6K_CANTSEND); return (-1); } if (ReadMME (int6k, (VS_SET_KEY | MMTYPE_CNF)) <= 0) { error ((int6k->flags & INT6K_BAILOUT), ECANCELED, INT6K_CANTREAD); return (-1); } if (confirm->MSTATUS) { Failure (int6k, INT6K_WONTDOIT); return (-1); } Confirm (int6k, "Setting ..."); return (0); }
processRequestResponse(req, true); return rid; } //--------------------------------------------------------------------- void DefaultWorkQueueBase::addRequestWithRID(WorkQueue::RequestID rid, uint16 channel, uint16 requestType, const Any& rData, uint8 retryCount) { // lock to push request to the queue OGRE_LOCK_MUTEX(mRequestMutex) if (mShuttingDown) return; Request* req = OGRE_NEW Request(channel, requestType, rData, retryCount, rid); LogManager::getSingleton().stream(LML_TRIVIAL) << "DefaultWorkQueueBase('" << mName << "') - REQUEUED(thread:" << #if OGRE_THREAD_SUPPORT OGRE_THREAD_CURRENT_ID #else "main" #endif << "): ID=" << rid << " channel=" << channel << " requestType=" << requestType; #if OGRE_THREAD_SUPPORT mRequestQueue.push_back(req); notifyWorkers(); #else processRequestResponse(req, true);
//-***************************************************************************** Reader::Request Reader::property( const std::string &name, const std::string &pre_ininterp, const PropertyInfo &info ) { // Fix interp for versions prior to 3. std::string ininterp = pre_ininterp; if ( fileHeader().version < 3 ) { ininterp = GTO_INTERPRET_DEFAULT; } if ( m_objects == NULL ) { GTC_THROW( "Reader reading without objects" ); } std::string interp; // In case you need the property container, here it is. // PropertyContainer *pc = // reinterpret_cast<PropertyContainer*>( // info.component->object->objectData ); Component *c = reinterpret_cast<Component*>( info.component->componentData ); Property *p = c->find( name ); Property *np = NULL; // Only use the part of the interpretation up to the first semicolon. size_t sq = ininterp.find( ';' ); if ( sq != std::string::npos ) { interp = ininterp.substr( 0, sq ); } else { interp = ininterp; } // If there's no interpretation, change the interpretation to // GTO_INTERPRET_DEFAULT if ( interp == "" ) { interp = GTO_INTERPRET_DEFAULT; } // If the property doesn't exist, try the virtual 'newProperty' function // which returns NULL by default. If it makes a property, awesome! Use // that. If not, continue below. if ( p == NULL ) { if ( (np = newProperty( name, info )) ) { c->add( np ); np->resize( info.size ); return Request( true, np ); } } // From the layout, width & interpretation, build us a new // property, OR, verify that the old property is the right upcastable // type. Layout layout = gtoTypeToLayout( ( Gto::DataType )( info.type ) ); const MetaProperty *metaProp = findMetaProperty( layout, info.width, interp ); if ( metaProp == NULL ) { std::cerr << "GtoContainer::Reader WARNING: " << "Ignoring property \"" << name << "\"" << std::endl; return Request( false ); } Property *newProp = NULL; if ( p != NULL ) { if ( !metaProp->validUpcast( p ) ) { throw TypeMismatchExc(); } newProp = p; } else { newProp = metaProp->create( name ); c->add( newProp ); } // If we get here, we've got a new property, ready to receive data. // Resize it and send out the Request. assert( newProp != NULL ); newProp->resize( info.size ); return Request( true, newProp ); }
void MediaKeySystemAccessManager::RetryRequest(PendingRequest& aRequest) { aRequest.CancelTimer(); Request(aRequest.mPromise, aRequest.mKeySystem, aRequest.mConfigs, RequestType::Subsequent); }
nsresult nsHttpPipeline::WriteSegments(nsAHttpSegmentWriter *writer, uint32_t count, uint32_t *countWritten) { LOG(("nsHttpPipeline::WriteSegments [this=%p count=%u]\n", this, count)); MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); if (mClosed) return NS_SUCCEEDED(mStatus) ? NS_BASE_STREAM_CLOSED : mStatus; nsAHttpTransaction *trans; nsresult rv; trans = Response(0); // This code deals with the establishment of a CONNECT tunnel through // an HTTP proxy. It allows the connection to do the CONNECT/200 // HTTP transaction to establish a tunnel as a precursor to the // actual pipeline of regular HTTP transactions. if (!trans && mRequestQ.Length() && mConnection->IsProxyConnectInProgress()) { LOG(("nsHttpPipeline::WriteSegments [this=%p] Forced Delegation\n", this)); trans = Request(0); } if (!trans) { if (mRequestQ.Length() > 0) rv = NS_BASE_STREAM_WOULD_BLOCK; else rv = NS_BASE_STREAM_CLOSED; } else { // // ask the transaction to consume data from the connection. // PushBack may be called recursively. // rv = trans->WriteSegments(writer, count, countWritten); if (rv == NS_BASE_STREAM_CLOSED || trans->IsDone()) { trans->Close(NS_OK); // Release the transaction if it is not IsProxyConnectInProgress() if (trans == Response(0)) { mResponseQ.RemoveElementAt(0); mResponseIsPartial = false; ++mHttp1xTransactionCount; } // ask the connection manager to add additional transactions // to our pipeline. RefPtr<nsHttpConnectionInfo> ci; GetConnectionInfo(getter_AddRefs(ci)); if (ci) gHttpHandler->ConnMgr()->ProcessPendingQForEntry(ci); } else mResponseIsPartial = true; } if (mPushBackLen) { nsHttpPushBackWriter pushBackWriter(mPushBackBuf, mPushBackLen); uint32_t len = mPushBackLen, n; mPushBackLen = 0; // This progress notification has previously been sent from // the socket transport code, but it was delivered to the // previous transaction on the pipeline. nsITransport *transport = Transport(); if (transport) OnTransportStatus(transport, NS_NET_STATUS_RECEIVING_FROM, mReceivingFromProgress); // the push back buffer is never larger than NS_HTTP_SEGMENT_SIZE, // so we are guaranteed that the next response will eat the entire // push back buffer (even though it might again call PushBack). rv = WriteSegments(&pushBackWriter, len, &n); } return rv; }
void plResPatcher::RequestFile(const plFileName& srvName, const plFileName& cliName) { fRequests.push(Request(srvName, kFile, cliName)); }
signed StartFirmware2 (struct plc * plc, unsigned module, const struct nvm_header2 * nvm_header) { struct channel * channel = (struct channel *)(plc->channel); struct message * message = (struct message *)(plc->message); #ifndef __GNUC__ #pragma pack (push,1) #endif struct __packed vs_st_mac_request { struct ethernet_std ethernet; struct qualcomm_std qualcomm; uint8_t MODULEID; uint8_t RESERVED [3]; uint32_t IMAGEBOOT; uint32_t IMAGELENGTH; uint32_t IMAGECHECKSUM; uint32_t IMAGESTART; } * request = (struct vs_st_mac_request *) (message); struct __packed vs_st_mac_confirm { struct ethernet_std ethernet; struct qualcomm_std qualcomm; uint8_t MSTATUS; uint8_t MODULEID; } * confirm = (struct vs_st_mac_confirm *) (message); #ifndef __GNUC__ #pragma pack (pop) #endif memset (message, 0, sizeof (* message)); Request (plc, "Start %s (%d) (%08X)", plc->NVM.name, module, LE32TOH (nvm_header->EntryPoint)); EthernetHeader (&request->ethernet, channel->peer, channel->host, channel->type); QualcommHeader (&request->qualcomm, 0, (VS_ST_MAC | MMTYPE_REQ)); plc->packetsize = (ETHER_MIN_LEN - ETHER_CRC_LEN); request->IMAGEBOOT = nvm_header->ImageAddress; request->IMAGELENGTH = nvm_header->ImageLength; request->IMAGECHECKSUM = nvm_header->ImageChecksum; request->IMAGESTART = nvm_header->EntryPoint; request->MODULEID = VS_MODULE_MAC; if (SendMME (plc) <= 0) { error ((plc->flags & PLC_BAILOUT), errno, CHANNEL_CANTSEND); return (-1); } if (ReadMME (plc, 0, (VS_ST_MAC | MMTYPE_CNF)) <= 0) { error ((plc->flags & PLC_BAILOUT), errno, CHANNEL_CANTREAD); return (-1); } if (confirm->MSTATUS) { Failure (plc, PLC_WONTDOIT); return (-1); } return (0); }
int main( int argc, char* argv[] ) { char *ptr; int del; sname = GetCmdOpt( "-s", argc, argv ); if( !sname ) { printf( "missing opt -s ( servername )\n" ); exit( -1 ); } hp = gethostbyname( sname ); if( !hp->h_addr ) { printf( "gethostbyname: failed ( name: %s )\n", sname ); exit( -1 ); } memcpy( sip, hp->h_addr, 4 ); printf( "server ip:\t%i.%i.%i.%i\n",( unsigned char ) sip[0],( unsigned char ) sip[1],( unsigned char ) sip[2], ( unsigned char ) sip[3]); gethostname( hostname, sizeof( hostname ) ); hp = gethostbyname( hostname ); if( !hp->h_addr ) { printf( "gethostbyname: failed ( name: %s )\n", hostname ); exit( -1 ); } memcpy( mip, hp->h_addr, 4 ); printf( "client ip:\t%i.%i.%i.%i\n",( unsigned char ) mip[0],( unsigned char ) mip[1],( unsigned char ) mip[2], ( unsigned char ) mip[3]); sport = 26002; portname = GetCmdOpt( "-p", argc, argv ); if( portname ) { sport = atoi( portname ); } printf( "server port:\t%d\n", sport ); ssock = socket( AF_INET, SOCK_STREAM, 0 ); memcpy( ( char* )&sadd.sin_addr, ( char* )sip, 4 ); sadd.sin_family = AF_INET; sadd.sin_port = htons(sport); del = 60000000; // detting delay to 60 s ptr = GetCmdOpt( "-d", argc, argv ); if( ptr ) del = atoi( ptr )*1000000; printf( "delay:\t%d\n", del ); for( ;; ) { Request(); usleep( del ); } }
signed function (struct plc * plc) { struct channel * channel = (struct channel *)(plc->channel); struct message * message = (struct message *)(plc->message); static char const * actions [] = { "start device", "store firmware", "store parameters", "update host", "config memory", "restore defaults", "unknown" }; #ifndef __GNUC__ #pragma pack (push,1) #endif struct __packed vs_host_action_ind { struct ethernet_std ethernet; struct qualcomm_std qualcomm; uint8_t MACTION; uint8_t MAJOR_VERSION; uint8_t MINOR_VERSION; } * indicate = (struct vs_host_action_ind *) (message); #ifndef __GNUC__ #pragma pack (pop) #endif char const * FactoryNVM = plc->NVM.name; char const * FactoryPIB = plc->PIB.name; signed status; signed action; Request (plc, "Waiting for Host Action"); while (1) { status = ReadMME (plc, 0, (VS_HOST_ACTION | MMTYPE_IND)); if (status < 0) { break; } if (status > 0) { printf ("\n"); if (indicate->MACTION < SIZEOF (actions)) { Confirm (plc, "Host Action Request is (%d) %s.", indicate->MACTION, actions [indicate->MACTION]); } else { error (0, ENOTSUP, "Host Action 0x%0X", indicate->MACTION); continue; } action = indicate->MACTION; memcpy (channel->peer, indicate->ethernet.OSA, sizeof (channel->peer)); if (HostActionResponse (plc)) { return (-1); } if (action == 0x00) { if (BootDevice1 (plc)) { return (-1); } if (_anyset (plc->flags, PLC_FLASH_DEVICE)) { FlashDevice1 (plc); } continue; } if (action == 0x01) { close (plc->NVM.file); if (ReadFirmware1 (plc)) { return (-1); } if ((plc->NVM.file = open (plc->NVM.name = plc->nvm.name, O_BINARY|O_RDONLY)) == -1) { error (1, errno, "%s", plc->NVM.name); } if (ResetDevice (plc)) { return (-1); } continue; } if (action == 0x02) { close (plc->PIB.file); if (ReadParameters1 (plc)) { return (-1); } if ((plc->PIB.file = open (plc->PIB.name = plc->pib.name, O_BINARY|O_RDONLY)) == -1) { error (1, errno, "%s", plc->PIB.name); } if (ResetDevice (plc)) { return (-1); } continue; } if (action == 0x03) { close (plc->PIB.file); if (ReadParameters1 (plc)) { return (-1); } if ((plc->PIB.file = open (plc->PIB.name = plc->pib.name, O_BINARY|O_RDONLY)) == -1) { error (1, errno, "%s", plc->PIB.name); } close (plc->NVM.file); if (ReadFirmware1 (plc)) { return (-1); } if ((plc->NVM.file = open (plc->NVM.name = plc->nvm.name, O_BINARY|O_RDONLY)) == -1) { error (1, errno, "%s", plc->NVM.name); } if (ResetDevice (plc)) { return (-1); } continue; } if (action == 0x04) { if (InitDevice1 (plc)) { return (-1); } continue; } if (action == 0x05) { close (plc->PIB.file); if ((plc->PIB.file = open (plc->PIB.name = FactoryPIB, O_BINARY|O_RDONLY)) == -1) { error (1, errno, "%s", plc->PIB.name); } close (plc->NVM.file); if ((plc->NVM.file = open (plc->NVM.name = FactoryNVM, O_BINARY|O_RDONLY)) == -1) { error (1, errno, "%s", plc->NVM.name); } if (ResetDevice (plc)) { return (-1); } continue; } if (action == 0x06) { close (plc->PIB.file); if (ReadParameters1 (plc)) { return (-1); } if ((plc->PIB.file = open (plc->PIB.name = plc->pib.name, O_BINARY|O_RDONLY)) == -1) { error (1, errno, "%s", plc->PIB.name); } continue; } error (0, ENOSYS, "Host Action 0x%02X", action); } } return (0); }
nsresult nsHttpPipeline::FillSendBuf() { // reads from request queue, moving transactions to response queue // when they have been completely read. nsresult rv; if (!mSendBufIn) { // allocate a single-segment pipe rv = NS_NewPipe(getter_AddRefs(mSendBufIn), getter_AddRefs(mSendBufOut), nsIOService::gDefaultSegmentSize, /* segment size */ nsIOService::gDefaultSegmentSize, /* max size */ true, true); if (NS_FAILED(rv)) return rv; } PRUint32 n, avail; nsAHttpTransaction *trans; nsITransport *transport = Transport(); while ((trans = Request(0)) != nsnull) { avail = trans->Available(); if (avail) { rv = trans->ReadSegments(this, avail, &n); if (NS_FAILED(rv)) return rv; if (n == 0) { LOG(("send pipe is full")); break; } mSendingToProgress += n; if (!mSuppressSendEvents && transport) { // Simulate a SENDING_TO event trans->OnTransportStatus(transport, NS_NET_STATUS_SENDING_TO, mSendingToProgress); } } avail = trans->Available(); if (avail == 0) { // move transaction from request queue to response queue mRequestQ.RemoveElementAt(0); mResponseQ.AppendElement(trans); mRequestIsPartial = false; if (!mSuppressSendEvents && transport) { // Simulate a WAITING_FOR event trans->OnTransportStatus(transport, NS_NET_STATUS_WAITING_FOR, mSendingToProgress); } } else mRequestIsPartial = true; } return NS_OK; }
signed ModuleRead (struct plc * plc, struct _file_ * file, uint16_t source, uint16_t module, uint16_t submodule) { struct channel * channel = (struct channel *)(plc->channel); struct message * message = (struct message *)(plc->message); #ifndef __GNUC__ #pragma pack (push,1) #endif struct __packed vs_module_operation_read_request { struct ethernet_hdr ethernet; struct qualcomm_hdr qualcomm; uint32_t RESERVED; uint8_t NUM_OP_DATA; struct __packed { uint16_t MOD_OP; uint16_t MOD_OP_DATA_LEN; uint32_t MOD_OP_RSVD; uint16_t MODULE_ID; uint16_t MODULE_SUB_ID; uint16_t MODULE_LENGTH; uint32_t MODULE_OFFSET; } MODULE_SPEC; } * request = (struct vs_module_operation_read_request *)(message); struct __packed vs_module_operation_read_confirm { struct ethernet_hdr ethernet; struct qualcomm_hdr qualcomm; uint16_t MSTATUS; uint16_t ERR_REC_CODE; uint32_t RESERVED; uint8_t NUM_OP_DATA; struct __packed { uint16_t MOD_OP; uint16_t MOD_OP_DATA_LEN; uint32_t MOD_OP_RSVD; uint16_t MODULE_ID; uint16_t MODULE_SUB_ID; uint16_t MODULE_LENGTH; uint32_t MODULE_OFFSET; } MODULE_SPEC; uint8_t MODULE_DATA [PLC_MODULE_SIZE]; } * confirm = (struct vs_module_operation_read_confirm *)(message); #ifndef __GNUC__ #pragma pack (pop) #endif unsigned timer = channel->timeout; uint16_t length = PLC_MODULE_SIZE; uint32_t offset = 0; Request (plc, "Read Module from %s", source? "Flash": "Memory"); if (lseek (file->file, 0, SEEK_SET) == -1) { error (PLC_EXIT (plc), errno, FILE_CANTHOME, file->name); return (-1); } while (length == PLC_MODULE_SIZE) { memset (message, 0, sizeof (* message)); EthernetHeader (&request->ethernet, channel->peer, channel->host, channel->type); QualcommHeader (&request->qualcomm, 0, (VS_MODULE_OPERATION | MMTYPE_REQ)); plc->packetsize = (ETHER_MIN_LEN - ETHER_CRC_LEN); request->NUM_OP_DATA = 1; request->MODULE_SPEC.MOD_OP = HTOLE16 (source); request->MODULE_SPEC.MOD_OP_DATA_LEN = HTOLE16 (sizeof (request->MODULE_SPEC)); request->MODULE_SPEC.MOD_OP_RSVD = HTOLE32 (0); request->MODULE_SPEC.MODULE_ID = HTOLE16 (module); request->MODULE_SPEC.MODULE_SUB_ID = HTOLE16 (submodule); request->MODULE_SPEC.MODULE_LENGTH = HTOLE16 (length); request->MODULE_SPEC.MODULE_OFFSET = HTOLE32 (offset); #if 0 #if defined (__GNUC__) #warning "Debug code active in module ModuleRead" #endif fprintf (stderr, "----- \n"); fprintf (stderr, "RESERVED 0x%08X\n", LE32TOH (request->RESERVED)); fprintf (stderr, "NUM_OP_DATA %d\n", request->NUM_OP_DATA); fprintf (stderr, "MOD_OP 0x%02X\n", LE16TOH (request->MODULE_SPEC.MOD_OP)); fprintf (stderr, "MOD_OP_DATA_LEN %d\n", LE16TOH (request->MODULE_SPEC.MOD_OP_DATA_LEN)); fprintf (stderr, "RESERVED 0x%08X\n", LE32TOH (request->MODULE_SPEC.MOD_OP_RSVD)); fprintf (stderr, "MODULE_ID 0x%04X\n", LE16TOH (request->MODULE_SPEC.MODULE_ID)); fprintf (stderr, "MODULE_SUB_ID 0x%04X\n", LE16TOH (request->MODULE_SPEC.MODULE_SUB_ID)); fprintf (stderr, "MODULE_LENGTH %d\n", LE16TOH (request->MODULE_SPEC.MODULE_LENGTH)); fprintf (stderr, "MODULE_OFFSET 0x%08X\n", LE32TOH (request->MODULE_SPEC.MODULE_OFFSET)); fprintf (stderr, "\n"); #endif if (SendMME (plc) <= 0) { error (PLC_EXIT (plc), errno, CHANNEL_CANTSEND); return (-1); } channel->timeout = PLC_MODULE_READ_TIMEOUT; if (ReadMME (plc, 0, (VS_MODULE_OPERATION | MMTYPE_CNF)) <= 0) { error (PLC_EXIT (plc), errno, CHANNEL_CANTREAD); return (-1); } channel->timeout = timer; #if 0 #if defined (__GNUC__) #warning "Debug code active in module ModuleRead" #endif fprintf (stderr, "MSTATUS 0x%04X\n", LE16TOH (confirm->MSTATUS)); fprintf (stderr, "ERROR_REC_CODE %d\n", LE16TOH (confirm->ERR_REC_CODE)); fprintf (stderr, "RESERVED 0x%08X\n", LE32TOH (confirm->RESERVED)); fprintf (stderr, "NUM_OP_DATA %d\n", confirm->NUM_OP_DATA); fprintf (stderr, "MOD_OP 0x%02X\n", LE16TOH (confirm->MODULE_SPEC.MOD_OP)); fprintf (stderr, "MOD_OP_DATA_LEN %d\n", LE16TOH (confirm->MODULE_SPEC.MOD_OP_DATA_LEN)); fprintf (stderr, "RESERVED 0x%08X\n", LE32TOH (confirm->MODULE_SPEC.MOD_OP_RSVD)); fprintf (stderr, "MODULE_ID 0x%04X\n", LE16TOH (confirm->MODULE_SPEC.MODULE_ID)); fprintf (stderr, "MODULE_SUB_ID 0x%04X\n", LE16TOH (confirm->MODULE_SPEC.MODULE_SUB_ID)); fprintf (stderr, "MODULE_LENGTH %d\n", LE16TOH (confirm->MODULE_SPEC.MODULE_LENGTH)); fprintf (stderr, "MODULE_OFFSET 0x%08X\n", LE32TOH (confirm->MODULE_SPEC.MODULE_OFFSET)); fprintf (stderr, "\n"); #endif if (LE16TOH (confirm->MSTATUS)) { Failure (plc, PLC_WONTDOIT); return (-1); } length = LE16TOH (confirm->MODULE_SPEC.MODULE_LENGTH); offset = LE32TOH (confirm->MODULE_SPEC.MODULE_OFFSET); if (write (file->file, confirm->MODULE_DATA, length) != (signed)(length)) { error (PLC_EXIT (plc), errno, FILE_CANTSAVE, file->name); return (-1); } offset += length; } return (0); }
signed Identity1 (struct plc * plc) { struct channel * channel = (struct channel *)(plc->channel); struct message * message = (struct message *)(plc->message); #ifndef __GNUC__ #pragma pack (push,1) #endif struct __packed vs_rd_mod_request { struct ethernet_std ethernet; struct qualcomm_std qualcomm; uint8_t MODULEID; uint8_t MACCESS; uint16_t MLENGTH; uint32_t MOFFSET; uint8_t MSECRET [16]; } * request = (struct vs_rd_mod_request *) (message); struct __packed vs_rd_mod_confirm { struct ethernet_std ethernet; struct qualcomm_std qualcomm; uint8_t MSTATUS; uint8_t RES [3]; uint8_t MODULEID; uint8_t RESERVED; uint16_t MLENGTH; uint32_t MOFFSET; uint32_t MCHKSUM; uint8_t BUFFER [PLC_RECORD_SIZE]; } * confirm = (struct vs_rd_mod_confirm *) (message); #ifndef __GNUC__ #pragma pack (pop) #endif Request (plc, "Device Identity"); memset (message, 0, sizeof (* message)); EthernetHeader (&request->ethernet, channel->peer, channel->host, HOMEPLUG_MTYPE); QualcommHeader (&request->qualcomm, 0, (VS_RD_MOD | MMTYPE_REQ)); plc->packetsize = (ETHER_MIN_LEN - ETHER_CRC_LEN); request->MODULEID = VS_MODULE_PIB; request->MLENGTH = HTOLE16 (sizeof (confirm->BUFFER)); request->MOFFSET = HTOLE32 (0); if (SendMME (plc) <= 0) { error ((plc->flags & PLC_BAILOUT), errno, CHANNEL_CANTSEND); return (-1); } while (ReadMME (plc, 0, (VS_RD_MOD | MMTYPE_CNF)) > 0) { if (confirm->MSTATUS) { Failure (plc, PLC_WONTDOIT); continue; } Confirm (plc, "-------"); pibpeek1 (confirm->BUFFER); } return (0); }
void plResPatcher::RequestManifest(const plString& age) { fRequests.push(Request(age, kManifest)); }
void CTPntBufTest::FinishedTests() { Request(); }
signed ReadPIB (struct int6k *int6k) { struct channel * channel = (struct channel *)(int6k->channel); struct message * message = (struct message *)(int6k->message); #ifndef __GNUC__ #pragma pack (push,1) #endif struct __packed vs_rd_mod_request { struct header_eth ethernet; struct header_int intellon; uint8_t MODULEID; uint8_t MACCESS; uint16_t MLENGTH; uint32_t MOFFSET; uint8_t MSECRET [16]; } * request = (struct vs_rd_mod_request *) (message); struct __packed vs_rd_mod_confirm { struct header_eth ethernet; struct header_int intellon; uint8_t MSTATUS; uint8_t RESERVED1 [3]; uint8_t MODULEID; uint8_t RESERVED; uint16_t MLENGTH; uint32_t MOFFSET; uint32_t CHKSUM; uint8_t BUFFER [INT6K_BLOCKSIZE]; } * confirm = (struct vs_rd_mod_confirm *) (message); #ifndef __GNUC__ #pragma pack (pop) #endif uint32_t extent = 0; uint32_t offset = 0; signed length = INT6K_BLOCKSIZE; Request (int6k, "Read Parameters from Device"); if (lseek (int6k->pib.file, 0, SEEK_SET)) { error ((int6k->flags & INT6K_BAILOUT), errno, "Can't rewind %s", filepart (int6k->pib.name)); return (1); } memset (message, 0, sizeof (struct message)); do { EthernetHeader (&message->ethernet, channel->peer, channel->host); IntellonHeader (&message->intellon, (VS_RD_MOD | MMTYPE_REQ)); int6k->packetsize = ETHER_MIN_LEN; request->MODULEID = VS_MODULE_PIB; request->MLENGTH = HTOLE16 (length); request->MOFFSET = HTOLE32 (offset); if (SendMME (int6k) <= 0) { error ((int6k->flags & INT6K_BAILOUT), ECANCELED, INT6K_CANTSEND); return (-1); } if (ReadMME (int6k, (VS_RD_MOD | MMTYPE_CNF)) <= 0) { error ((int6k->flags & INT6K_BAILOUT), ECANCELED, INT6K_CANTREAD); return (-1); } if (confirm->MSTATUS) { Failure (int6k, INT6K_WONTDOIT); return (-1); } #if 1 if (LE16TOH (confirm->MLENGTH) != length) { Failure (int6k, INT6K_ERR_LENGTH); return (-1); } if (LE32TOH (confirm->MOFFSET) != offset) { Failure (int6k, INT6K_ERR_OFFSET); return (-1); } #else if (LE16TOH (confirm->MLENGTH) != length) { error ((int6k->flags & INT6K_BAILOUT), 0, INT6K_ERR_LENGTH); length = INT6K_BLOCKSIZE; offset = 0; continue; } if (LE32TOH (confirm->MOFFSET) != offset) { error ((int6k->flags & INT6K_BAILOUT), 0, INT6K_ERR_OFFSET); length = INT6K_BLOCKSIZE; offset = 0; continue; } #endif length = LE16TOH (confirm->MLENGTH); offset = LE32TOH (confirm->MOFFSET); if (checksum_32 (confirm->BUFFER, length, confirm->CHKSUM)) { error ((int6k->flags & INT6K_BAILOUT), ECANCELED, "Bad Packet Checksum"); return (-1); } if (offset == extent) { struct header_pib * header_pib = (struct header_pib *) (confirm->BUFFER); extent = header_pib->PIBLENGTH; } if ((offset + length) > extent) { length = extent - offset; } if (lseek (int6k->pib.file, offset, SEEK_SET) != offset) { error ((int6k->flags & INT6K_BAILOUT), errno, "can't seek %s", filepart (int6k->pib.name)); return (-1); } if (write (int6k->pib.file, confirm->BUFFER, length) < length) { error ((int6k->flags & INT6K_BAILOUT), errno, "can't save %s", filepart (int6k->pib.name)); return (-1); } offset += length; } while (offset < extent); Confirm (int6k, "Read %s", int6k->pib.name); return (0); }
void nsHttpPipeline::OnTransportStatus(nsITransport* transport, nsresult status, int64_t progress) { LOG(("nsHttpPipeline::OnStatus [this=%p status=%x progress=%lld]\n", this, status, progress)); MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); nsAHttpTransaction *trans; int32_t i, count; switch (status) { case NS_NET_STATUS_RESOLVING_HOST: case NS_NET_STATUS_RESOLVED_HOST: case NS_NET_STATUS_CONNECTING_TO: case NS_NET_STATUS_CONNECTED_TO: // These should only appear at most once per pipeline. // Deliver to the first transaction. trans = Request(0); if (!trans) trans = Response(0); if (trans) trans->OnTransportStatus(transport, status, progress); break; case NS_NET_STATUS_SENDING_TO: // This is generated by the socket transport when (part) of // a transaction is written out // // In pipelining this is generated out of FillSendBuf(), but it cannot do // so until the connection is confirmed by CONNECTED_TO. // See patch for bug 196827. // if (mSuppressSendEvents) { mSuppressSendEvents = false; // catch up by sending the event to all the transactions that have // moved from request to response and any that have been partially // sent. Also send WAITING_FOR to those that were completely sent count = mResponseQ.Length(); for (i = 0; i < count; ++i) { Response(i)->OnTransportStatus(transport, NS_NET_STATUS_SENDING_TO, progress); Response(i)->OnTransportStatus(transport, NS_NET_STATUS_WAITING_FOR, progress); } if (mRequestIsPartial && Request(0)) Request(0)->OnTransportStatus(transport, NS_NET_STATUS_SENDING_TO, progress); mSendingToProgress = progress; } // otherwise ignore it break; case NS_NET_STATUS_WAITING_FOR: // Created by nsHttpConnection when request pipeline has been totally // sent. Ignore it here because it is simulated in FillSendBuf() when // a request is moved from request to response. // ignore it break; case NS_NET_STATUS_RECEIVING_FROM: // Forward this only to the transaction currently recieving data. It is // normally generated by the socket transport, but can also // be repeated by the pushbackwriter if necessary. mReceivingFromProgress = progress; if (Response(0)) Response(0)->OnTransportStatus(transport, status, progress); break; default: // forward other notifications to all request transactions count = mRequestQ.Length(); for (i = 0; i < count; ++i) Request(i)->OnTransportStatus(transport, status, progress); break; } }
signed GetProperty (struct plc * plc, struct plcproperty * plcproperty) { struct channel * channel = (struct channel *)(plc->channel); struct message * message = (struct message *)(plc->message); #ifndef __GNUC__ #pragma pack (push,1) #endif struct __packed vs_get_property_request { struct ethernet_std ethernet; struct qualcomm_std qualcomm; uint32_t COOKIE; uint8_t DATA_FORMAT; uint8_t PROP_FORMAT; uint8_t RESERVED [2]; uint32_t PROP_VERSION; uint32_t PROP_LENGTH; uint8_t PROP_NUMBER; } * request = (struct vs_get_property_request *) (message); struct __packed vs_get_property_confirm { struct ethernet_std ethernet; struct qualcomm_std qualcomm; uint32_t MSTATUS; uint32_t COOKIE; uint8_t DATA_FORMAT; uint8_t RESERVED [3]; uint32_t DATA_LENGTH; uint32_t DATA_BUFFER [1]; } * confirm = (struct vs_get_property_confirm *) (message); #ifndef __GNUC__ #pragma pack (pop) #endif Request (plc, "Get Property"); memset (message, 0, sizeof (* message)); EthernetHeader (&request->ethernet, channel->peer, channel->host, HOMEPLUG_MTYPE); QualcommHeader (&request->qualcomm, 0, (VS_GET_PROPERTY | MMTYPE_REQ)); request->COOKIE = HTOLE32 (plc->cookie); request->DATA_FORMAT = plcproperty->DATA_FORMAT; request->PROP_FORMAT = plcproperty->PROP_FORMAT; request->PROP_VERSION = HTOLE32 (plcproperty->PROP_VERSION); request->PROP_LENGTH = HTOLE32 (plcproperty->PROP_LENGTH); request->PROP_NUMBER = HTOLE32 (plcproperty->PROP_NUMBER); plc->packetsize = (ETHER_MIN_LEN - ETHER_CRC_LEN); if (SendMME (plc) <= 0) { error ((plc->flags & PLC_BAILOUT), errno, CHANNEL_CANTSEND); return (-1); } while (ReadMME (plc, 0, (VS_GET_PROPERTY | MMTYPE_CNF)) > 0) { if (confirm->MSTATUS) { Failure (plc, PLC_WONTDOIT); continue; } if (plcproperty->DATA_FORMAT == PLC_FORMAT_BIN) { binout (confirm->DATA_BUFFER, confirm->DATA_LENGTH, ' ', '\n', stdout); continue; } if (plcproperty->DATA_FORMAT == PLC_FORMAT_HEX) { hexout (confirm->DATA_BUFFER, confirm->DATA_LENGTH, ' ', '\n', stdout); continue; } if (plcproperty->DATA_FORMAT == PLC_FORMAT_DEC) { decout (confirm->DATA_BUFFER, confirm->DATA_LENGTH, ' ', '\n', stdout); continue; } if (plcproperty->DATA_FORMAT == PLC_FORMAT_ASC) { chrout (confirm->DATA_BUFFER, confirm->DATA_LENGTH, '.', '\n', stdout); continue; } } return (0); }
nsresult nsHttpPipeline::FillSendBuf() { // reads from request queue, moving transactions to response queue // when they have been completely read. nsresult rv; if (!mSendBufIn) { // allocate a single-segment pipe rv = NS_NewPipe(getter_AddRefs(mSendBufIn), getter_AddRefs(mSendBufOut), nsIOService::gDefaultSegmentSize, /* segment size */ nsIOService::gDefaultSegmentSize, /* max size */ true, true); if (NS_FAILED(rv)) return rv; } uint32_t n; uint64_t avail; RefPtr<nsAHttpTransaction> trans; nsITransport *transport = Transport(); while ((trans = Request(0)) != nullptr) { avail = trans->Available(); if (avail) { // if there is already a response in the responseq then this // new data comprises a pipeline. Update the transaction in the // response queue to reflect that if necessary. We are now sending // out a request while we haven't received all responses. nsAHttpTransaction *response = Response(0); if (response && !response->PipelinePosition()) response->SetPipelinePosition(1); rv = trans->ReadSegments(this, (uint32_t)std::min(avail, (uint64_t)UINT32_MAX), &n); if (NS_FAILED(rv)) return rv; if (n == 0) { LOG(("send pipe is full")); break; } mSendingToProgress += n; if (!mSuppressSendEvents && transport) { // Simulate a SENDING_TO event trans->OnTransportStatus(transport, NS_NET_STATUS_SENDING_TO, mSendingToProgress); } } avail = trans->Available(); if (avail == 0) { // move transaction from request queue to response queue mRequestQ.RemoveElementAt(0); mResponseQ.AppendElement(trans); mRequestIsPartial = false; if (!mSuppressSendEvents && transport) { // Simulate a WAITING_FOR event trans->OnTransportStatus(transport, NS_NET_STATUS_WAITING_FOR, mSendingToProgress); } // It would be good to re-enable data read handlers via ResumeRecv() // except the read handler code can be synchronously dispatched on // the stack. } else mRequestIsPartial = true; } return NS_OK; }
void CMTPSetObjectPropList::RunL() { if (iStatus == KErrNone) // send request to the next dp { if (!iDpListCreated) { // Data provider list under construction. iResponseCode = EMTPRespCodeOK; const TUint KElementCount(iObjectPropList->NumberOfElements()); const TUint KRunLength(32); for (TUint i(0); ((i < KRunLength) && (iPropertyIdx < KElementCount) && (iResponseCode == EMTPRespCodeOK)); ++i) { iPropertyIdx++; CMTPTypeObjectPropListElement& element=iObjectPropList->GetNextElementL(); const TUint32 KHandle(element.Uint32L(CMTPTypeObjectPropListElement::EObjectHandle)); const TUint16 KPropCode(element.Uint16L(CMTPTypeObjectPropListElement::EPropertyCode)); CMTPParserRouter::TRoutingParameters params(*iRequest, iConnection); params.SetParam(CMTPParserRouter::TRoutingParameters::EParamObjectHandle, KHandle); params.SetParam(CMTPParserRouter::TRoutingParameters::EParamObjectPropCode, KPropCode); CMTPObjectMetaData* meta(CMTPObjectMetaData::NewLC()); if (!iSingletons.ObjectMgr().ObjectL(KHandle, *meta)) { // Invalid object handle. iResponseCode = EMTPRespCodeInvalidObjectHandle; } else if(!iSingletons.StorageMgr().IsReadWriteStorage(meta->Uint(CMTPObjectMetaData::EStorageId))) { iResponseCode = EMTPRespCodeAccessDenied; } else { RArray<TUint> targets; CleanupClosePushL(targets); iSingletons.Router().RouteOperationRequestL(params, targets); __ASSERT_DEBUG((targets.Count() <= 1), User::Invariant()); if (targets.Count() == 1) { iDpList.InsertInOrder(targets[0]); } else { // Unsupported object propertycode. iResponseCode = EMTPRespCodeObjectPropNotSupported; } CleanupStack::PopAndDestroy(&targets); } CleanupStack::PopAndDestroy(meta); if (iResponseCode != EMTPRespCodeOK) { // If an error occurs at this point then no properties have been updated. iPropertyIdx = 0; iDpList.Reset(); } } if ((iPropertyIdx < KElementCount) && (iResponseCode == EMTPRespCodeOK)) { Reschedule(KErrNone); } else { iDpListCreated = ETrue; } } if (iDpListCreated) { if (iDpIdx < iDpList.Count()) { iSingletons.DpController().DataProviderL(iDpList[iDpIdx]).ExecuteProxyRequestL(Request(), Connection(), *this); } else { SendResponseL(iResponseCode, 1, &iPropertyIdx); } } } else { if (!iDpListCreated) { /* If an error occurs prior to starting the proxy transaction cycles then no properties have been updated. */ iPropertyIdx = 0; } if (iResponseCode == EMTPRespCodeOK) { iResponseCode = EMTPRespCodeGeneralError; } SendResponseL(iResponseCode, 1, &iPropertyIdx); } }