/** * Extract HTML/CSS/JS/Media files to the local file system. */ void HybridMoblet::extractFileSystem() { // You can display splash screen if this is the // first time launch or if the checksum has changed. // TODO: Add library support for this? At least // document how to do it yourself. if (checksumHasChanged()) { // Extract bundled files to the local file system. mFileUtil->extractLocalFiles(); // Write the current checksum. writeChecksum(); } }
/* * PROTOCOL - Payload Packet * ------------------------------------------------------------------------------- * | Header | Length | Sub-Payloads | CHECKSUM | * ------------------------------------------------------------------------------- * | 4 BYTES | 2 BYTES | n BYTES (74 Bytes Max for each Sub-Payload | 2 BYTES | * ------------------------------------------------------------------------------- * * * Sub-Payload Packet (Max 74 Bytes) * ------------------------------------------------------------------------------------------------- * | Length | ID | TYPE | ACCESS | LOCATION | VALUE | DESCRIPTION | * ------------------------------------------------------------------------------------------------- * | 1 BYTE | 2 BYTES | 1 BYTE | 1 BYTE | 1 BYTE | 4 BYTES | n BYTES (Max 30) | * ------------------------------------------------------------------------------------------------- * * * Joins the full message buffer to be sent to the controller * */ int writePayload(Datapoint datapoints[], byte protocolBuffer[]) { writeHeader(protocolBuffer); // First sub-payload starts at index 6 (starting from 0) // 4 bytes HEADER + 2 bytes PAYLOAD LENGTH int length = 6; for(int i=0;i < NUMBER_DATAPOINTS; i++) { length += datapoints[i].writeSubPayload(protocolBuffer, length); } // The length comes before the sub-payloads but is only known after they are processed writeLength(length - 6, protocolBuffer); length += writeChecksum(length, protocolBuffer); return length; }
/*----------------------------------------------------------------------------*/ void sendViaEth(ethernet_frame_t* eth) { uint8_t sendBuffer[max_frame_size]; // the byte array that will be sent uint8_t current_offset; // keeps track of current offset in the buffer uint8_t padding_len; // how much padding is required uint8_t message_len; // length of the message being sent createMac((uint8_t*)&(eth->eth_header.dest),dom0mac); createMac((uint8_t*)&(eth->eth_header.source),mymac); eth->eth_header.data_len = 0x0008; // 0x0008 means frame's content is IP writeEthernetHeader(sendBuffer, &(eth->eth_header), ethernet_header_offset); writeIPHeader(sendBuffer, &(eth->ip_header), ip_header_offset); writeUdpHeader(sendBuffer, &(eth->udp_header), udp_header_offset); writeMessage(sendBuffer, ð->message, message_offset); message_len = eth->message.length; current_offset = message_offset+message_len; if(sum_headers_len + message_len < min_frame_size) { padding_len = min_frame_size - (sum_headers_len + message_len ); writePadding(sendBuffer, current_offset, padding_len); current_offset += padding_len; } else { padding_len = 0; } writeChecksum(sendBuffer, current_offset); //netfront_xmit(xen_network_device,(unsigned char*) sendBuffer, current_offset+frame_checksum_length); netfront_xmit(net_dev,(unsigned char*) sendBuffer, current_offset+frame_checksum_length);//change it to linux version }