static void MichaelGetMIC( struct michel_mic_t *Mic, uint8_t *dst ) { uint8_t *data = Mic->M; switch (Mic->nBytesInM) { case 0: Mic->L ^= 0x5a; break; case 1: Mic->L ^= data[0] | 0x5a00; break; case 2: Mic->L ^= data[0] | (data[1] << 8) | 0x5a0000; break; case 3: Mic->L ^= data[0] | (data[1] << 8) | (data[2] << 16) | 0x5a000000; break; } MichaelBlockFunction(Mic->L, Mic->R); MichaelBlockFunction(Mic->L, Mic->R); // The appendByte function has already computed the result. putUInt32( dst, 0, Mic->L ); putUInt32( dst, 4, Mic->R ); // Reset to the empty message. MichaelClear(Mic); }
void MtpDataPacket::putAUInt32(const UInt32List* list) { if (!list) { putEmptyArray(); } else { size_t size = list->size(); putUInt32(size); for (size_t i = 0; i < size; i++) putUInt32((*list)[i]); } }
void NetMessage::putString(const std::string &value) { unsigned strSize = value.size(); unsigned i; putUInt32(strSize); for (i = 0; i < strSize; i++) { putUInt8(value.c_str()[i]); } }
// write our buffer to the given endpoint (host mode) int MtpRequestPacket::write(struct usb_request *request) { putUInt32(MTP_CONTAINER_LENGTH_OFFSET, mPacketSize); putUInt16(MTP_CONTAINER_TYPE_OFFSET, MTP_CONTAINER_TYPE_COMMAND); request->buffer = mBuffer; request->buffer_length = mPacketSize; return transfer(request); }
void MtpPacket::setParameter(int index, uint32_t value) { if (index < 1 || index > 5) { ALOGE("index %d out of range in MtpPacket::setParameter", index); return; } int offset = MTP_CONTAINER_PARAMETER_OFFSET + (index - 1) * sizeof(uint32_t); if (mPacketSize < offset + sizeof(uint32_t)) mPacketSize = offset + sizeof(uint32_t); putUInt32(offset, value); }
int MtpEventPacket::write(int fd) { struct mtp_event event; putUInt32(MTP_CONTAINER_LENGTH_OFFSET, mPacketSize); putUInt16(MTP_CONTAINER_TYPE_OFFSET, MTP_CONTAINER_TYPE_EVENT); event.data = mBuffer; event.length = mPacketSize; int ret = ::ioctl(fd, MTP_SEND_EVENT, (unsigned long)&event); return (ret < 0 ? ret : 0); }
int MtpEventPacket::write(int fd) { struct mtp_event event; putUInt32(MTP_CONTAINER_LENGTH_OFFSET, mPacketSize); putUInt16(MTP_CONTAINER_TYPE_OFFSET, MTP_CONTAINER_TYPE_EVENT); event.data = mBuffer; event.length = mPacketSize; int ret = ::ioctl(fd, MTP_SEND_EVENT, (unsigned long)&event); //Added for USB Develpment debug, more log for more debuging help sxlog_printf(ANDROID_LOG_VERBOSE, "MtpEventPacket", "%s: mBuffer = %p, mPacketSize = 0x%d, &event = %p \n", __func__, mBuffer, mPacketSize, (&event)); //Added for USB Develpment debug, more log for more debuging help return (ret < 0 ? ret : 0); }
void MtpPacket::setTransactionID(MtpTransactionID id) { putUInt32(MTP_CONTAINER_TRANSACTION_ID_OFFSET, id); }
int MtpResponsePacket::write(int fd) { putUInt32(MTP_CONTAINER_LENGTH_OFFSET, mPacketSize); putUInt16(MTP_CONTAINER_TYPE_OFFSET, MTP_CONTAINER_TYPE_RESPONSE); int ret = ::write(fd, mBuffer, mPacketSize); return (ret < 0 ? ret : 0); }
void MtpDataPacket::putAUInt64(const uint64_t* values, int count) { putUInt32(count); for (int i = 0; i < count; i++) putUInt64(*values++); }
void MtpDataPacket::putAInt32(const int32_t* values, int count) { putUInt32(count); for (int i = 0; i < count; i++) putInt32(*values++); }
void MtpDataPacket::putAUInt16(const UInt16List* values) { size_t count = (values ? values->size() : 0); putUInt32(count); for (size_t i = 0; i < count; i++) putUInt16((*values)[i]); }
void MtpDataPacket::putUInt128(const uint128_t& value) { putUInt32(value[0]); putUInt32(value[1]); putUInt32(value[2]); putUInt32(value[3]); }