本文整理汇总了C++中QualcommHeader函数的典型用法代码示例。如果您正苦于以下问题:C++ QualcommHeader函数的具体用法?C++ QualcommHeader怎么用?C++ QualcommHeader使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了QualcommHeader函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DefaultVLANIDs
static signed DefaultVLANIDs (struct plc * plc, struct item list [], unsigned items)
{
struct channel * channel = (struct channel *)(plc->channel);
struct message * message = (struct message *)(plc->message);
#ifndef __GNUC__
#pragma pack (push,1)
#endif
struct __packed vs_forward_config_request
{
struct ethernet_hdr ethernet;
struct qualcomm_hdr qualcomm;
uint8_t RESERVED1;
uint8_t MREQUEST;
uint8_t MVERSION;
uint32_t RESERVED2;
uint16_t VLANID;
uint16_t RESERVED3;
}
* request = (struct vs_forward_config_request *) (message);
struct __packed vs_forward_config_confirm
{
struct ethernet_hdr ethernet;
struct qualcomm_hdr qualcomm;
uint8_t RESERVED1;
uint8_t RESULTCODE;
uint8_t OPERATION;
uint8_t MVERSION;
uint32_t RESERVED2;
}
* confirm = (struct vs_forward_config_confirm *) (message);
#ifndef __GNUC__
#pragma pack (pop)
#endif
memset (message, 0, sizeof (* message));
EthernetHeader (&request->ethernet, channel->peer, channel->host, channel->type);
QualcommHeader (&request->qualcomm, 0, (VS_FORWARD_CONFIG | MMTYPE_REQ));
request->MREQUEST = PLCFWD_SET;
request->MVERSION = PLCFWD_VER;
request->VLANID = HTOLE16 (list [0].VLANID [0]);
plc->packetsize = (ETHER_MIN_LEN - ETHER_CRC_LEN);
if (SendMME (plc) <= 0)
{
error (PLC_EXIT (plc), errno, CHANNEL_CANTSEND);
return (-1);
}
while (ReadMME (plc, 0, (VS_FORWARD_CONFIG | MMTYPE_CNF)) > 0)
{
if (confirm->RESULTCODE)
{
Failure (plc, PLC_WONTDOIT);
continue;
}
}
return (0);
}
示例2: RemoteHosts
signed RemoteHosts (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_sw_ver_request
{
struct ethernet_hdr ethernet;
struct qualcomm_hdr qualcomm;
}
* request = (struct vs_sw_ver_request *) (message);
struct __packed vs_sw_ver_confirm
{
struct ethernet_hdr ethernet;
struct qualcomm_hdr qualcomm;
uint8_t MSTATUS;
uint32_t NUMDEVICES;
struct __packed
{
uint8_t MACADDRESS [ETHER_ADDR_LEN];
uint8_t ENUMID;
}
DEVICE [1];
}
* confirm = (struct vs_sw_ver_confirm *) (message);
#ifndef __GNUC__
#pragma pack (pop)
#endif
Request (plc, "Request Enumeration ID Table");
memset (message, 0, sizeof (* message));
EthernetHeader (&request->ethernet, channel->peer, channel->host, channel->type);
QualcommHeader (&request->qualcomm, 0, (VS_EM_ID_TABLE | MMTYPE_REQ));
plc->packetsize = (ETHER_MIN_LEN - ETHER_CRC_LEN);
if (SendMME (plc) <= 0)
{
error (PLC_EXIT (plc), errno, CHANNEL_CANTSEND);
return (-1);
}
while (ReadMME (plc, 0, (VS_EM_ID_TABLE | MMTYPE_CNF)) > 0)
{
unsigned count = LE32TOH (confirm->NUMDEVICES);
if (confirm->MSTATUS)
{
Failure (plc, PLC_WONTDOIT);
continue;
}
while (count--)
{
hexout (confirm->DEVICE [count].MACADDRESS, ETHER_ADDR_LEN, ':', count? ' ': '\n', stdout);
}
}
return (0);
}
示例3: mod_conn
static signed mod_conn (struct plc * plc, uint8_t TYPE, uint16_t CID)
{
struct channel * channel = (struct channel *)(plc->channel);
struct message * message = (struct message *)(plc->message);
#ifndef __GNUC__
#pragma pack (push,1)
#endif
struct __packed vs_mod_conn_req
{
struct ethernet_std ethernet;
struct qualcomm_std qualcomm;
uint32_t REQ_ID;
uint32_t RSVD;
uint16_t CID;
uint8_t MOD_CTRL;
}
* request = (struct vs_mod_conn_req *)(message);
struct __packed vs_mod_conn_cnf
{
struct ethernet_std ethernet;
struct qualcomm_std qualcomm;
uint32_t REQ_ID;
uint8_t MSTATUS;
uint16_t ERR_REC_CODE;
uint32_t RSVD;
uint16_t CID;
}
* confirm = (struct vs_mod_conn_cnf *)(message);
#ifndef __GNUC__
#pragma pack (pop)
#endif
Request (plc, "COQOS modify connection");
memset (message, 0, sizeof (* message));
EthernetHeader (&request->ethernet, channel->peer, channel->host, HOMEPLUG_MTYPE);
QualcommHeader (&request->qualcomm, 0, (VS_MOD_CONN | MMTYPE_REQ));
plc->packetsize = (ETHER_MIN_LEN - ETHER_CRC_LEN);
request->MOD_CTRL = TYPE;
request->CID = CID;
if (SendMME (plc) <= 0)
{
error ((plc->flags & PLC_BAILOUT), errno, CHANNEL_CANTSEND);
return (-1);
}
while (ReadMME (plc, 0, (VS_MOD_CONN | MMTYPE_CNF)) > 0)
{
if (confirm->MSTATUS)
{
Failure (plc, PLC_WONTDOIT);
return (-1);
}
Confirm (plc, "%s connection %04X", (TYPE == ACTION_SPND)? "Suspended": "Resumed", CID);
}
return (0);
}
示例4: rel_conn
signed rel_conn (struct plc * plc, uint16_t CID)
{
struct channel * channel = (struct channel *)(plc->channel);
struct message * message = (struct message *)(plc->message);
#ifndef __GNUC__
#pragma pack (push,1)
#endif
struct __packed vs_rel_conn_req
{
struct ethernet_hdr ethernet;
struct qualcomm_hdr qualcomm;
uint32_t REQ_ID;
uint32_t RSVD;
uint16_t CID;
}
* request = (struct vs_rel_conn_req *)(message);
struct __packed vs_rel_conn_cnf
{
struct ethernet_hdr ethernet;
struct qualcomm_hdr qualcomm;
uint32_t REQ_ID;
uint8_t MSTATUS;
uint16_t ERR_REC_CODE;
uint32_t RSVD;
}
* confirm = (struct vs_rel_conn_cnf *)(message);
#ifndef __GNUC__
#pragma pack (pop)
#endif
Request (plc, "Release COQOS connection");
memset (message, 0, sizeof (* message));
EthernetHeader (&request->ethernet, channel->peer, channel->host, channel->type);
QualcommHeader (&request->qualcomm, 0, (VS_CONN_REL | MMTYPE_REQ));
plc->packetsize = (ETHER_MIN_LEN - ETHER_CRC_LEN);
request->CID = CID;
if (SendMME (plc) <= 0)
{
error (PLC_EXIT (plc), errno, CHANNEL_CANTSEND);
return (-1);
}
while (ReadMME (plc, 0, (VS_CONN_REL | MMTYPE_CNF)) > 0)
{
if (confirm->MSTATUS)
{
Failure (plc, PLC_WONTDOIT);
return (-1);
}
Confirm (plc, "Released %04X", CID);
}
return (0);
}
示例5: Classification
signed Classification (struct plc * plc, struct MMERule * rule)
{
struct channel * channel = (struct channel *)(plc->channel);
struct message * message = (struct message *)(plc->message);
#ifndef __GNUC__
#pragma pack (push,1)
#endif
struct __packed vs_classification_request
{
struct ethernet_std ethernet;
struct qualcomm_std qualcomm;
struct MMERule rule;
}
* request = (struct vs_classification_request *)(message);
struct __packed vs_classification_confirm
{
struct ethernet_std ethernet;
struct qualcomm_std qualcomm;
uint8_t MSTATUS;
}
* confirm = (struct vs_classification_confirm *)(message);
#ifndef __GNUC__
#pragma pack (pop)
#endif
Request (plc, "Set Classification Rules");
memset (message, 0, sizeof (* message));
EthernetHeader (&request->ethernet, channel->peer, channel->host, channel->type);
QualcommHeader (&request->qualcomm, 0, (VS_CLASSIFICATION | MMTYPE_REQ));
plc->packetsize = sizeof (struct vs_classification_request);
memcpy (&request->rule, rule, sizeof (request->rule));
if (SendMME (plc) <= 0)
{
error ((plc->flags & PLC_BAILOUT), errno, CHANNEL_CANTSEND);
return (-1);
}
if (ReadMME (plc, 0, (VS_CLASSIFICATION | MMTYPE_CNF)) <= 0)
{
error ((plc->flags & PLC_BAILOUT), errno, CHANNEL_CANTREAD);
return (-1);
}
if (confirm->MSTATUS)
{
Failure (plc, PLC_WONTDOIT);
return (-1);
}
Confirm (plc, "Setting ...");
return (0);
}
示例6: FlashNVM
signed FlashNVM (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_mod_nvm_request
{
struct ethernet_std ethernet;
struct qualcomm_std qualcomm;
uint8_t MODULEID;
}
* request = (struct vs_mod_nvm_request *) (message);
struct __packed vs_mod_nvm_confirm
{
struct ethernet_std ethernet;
struct qualcomm_std qualcomm;
uint8_t MSTATUS;
uint8_t MODULEID;
}
* confirm = (struct vs_mod_nvm_confirm *) (message);
#ifndef __GNUC__
#pragma pack (pop)
#endif
Request (plc, "Flash device");
memset (message, 0, sizeof (* message));
EthernetHeader (&request->ethernet, channel->peer, channel->host, channel->type);
QualcommHeader (&request->qualcomm, 0, (VS_MOD_NVM | MMTYPE_REQ));
request->MODULEID = plc->module;
plc->packetsize = (ETHER_MIN_LEN - ETHER_CRC_LEN);
if (SendMME (plc) <= 0)
{
error ((plc->flags & PLC_BAILOUT), errno, CHANNEL_CANTSEND);
return (-1);
}
if (ReadMME (plc, 0, (VS_MOD_NVM | MMTYPE_CNF)) <= 0)
{
error ((plc->flags & PLC_BAILOUT), errno, CHANNEL_CANTREAD);
return (-1);
}
if (confirm->MSTATUS)
{
Failure (plc, PLC_WONTDOIT);
return (-1);
}
return (0);
}
示例7: VersionInfo1
signed VersionInfo1 (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_sw_ver_request
{
struct ethernet_std ethernet;
struct qualcomm_std qualcomm;
}
* request = (struct vs_sw_ver_request *) (message);
struct __packed vs_sw_ver_confirm
{
struct ethernet_std ethernet;
struct qualcomm_std qualcomm;
uint8_t MSTATUS;
uint8_t MDEVICEID;
uint8_t MVERLENGTH;
char MVERSION [PLC_VERSION_STRING];
}
* confirm = (struct vs_sw_ver_confirm *) (message);
#ifndef __GNUC__
#pragma pack (pop)
#endif
Request (plc, "Request Version Information");
memset (message, 0, sizeof (* message));
EthernetHeader (&request->ethernet, channel->peer, channel->host, channel->type);
QualcommHeader (&request->qualcomm, 0, (VS_SW_VER | MMTYPE_REQ));
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_SW_VER | MMTYPE_CNF)) > 0)
{
if (confirm->MSTATUS)
{
Failure (plc, PLC_WONTDOIT);
continue;
}
chipset (confirm);
Display (plc, "%s %s", chipsetname (confirm->MDEVICEID), confirm->MVERSION);
}
return (0);
}
示例8: HostActionIndicate
signed HostActionIndicate (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_host_action_ind
{
struct ethernet_hdr ethernet;
struct qualcomm_hdr qualcomm;
uint8_t MACTION;
uint8_t MAJOR_VERSION;
uint8_t MINOR_VERSION;
}
* indicate = (struct vs_host_action_ind *) (message);
struct __packed vs_host_action_rsp
{
struct ethernet_hdr ethernet;
struct qualcomm_hdr qualcomm;
uint8_t MSTATUS;
}
* response = (struct vs_host_action_rsp *) (message);
#ifndef __GNUC__
#pragma pack (pop)
#endif
Request (plc, "Start Host Action");
memset (message, 0, sizeof (* message));
EthernetHeader (&indicate->ethernet, channel->peer, channel->host, channel->type);
QualcommHeader (&indicate->qualcomm, 0, (VS_HOST_ACTION | MMTYPE_IND));
plc->packetsize = (ETHER_MIN_LEN - ETHER_CRC_LEN);
indicate->MACTION = plc->action;
if (SendMME (plc) <= 0)
{
error (PLC_EXIT (plc), errno, CHANNEL_CANTSEND);
return (-1);
}
while (ReadMME (plc, 0, (VS_HOST_ACTION | MMTYPE_RSP)) > 0)
{
if (response->MSTATUS)
{
Failure (plc, PLC_WONTDOIT);
continue;
}
Confirm (plc, "Start.");
}
return (0);
}
示例9: Antiphon
signed Antiphon (struct plc * plc, byte source [], byte target [])
{
struct channel * channel = (struct channel *)(plc->channel);
struct message * message = (struct message *)(plc->message);
#ifndef __GNUC__
#pragma pack (push,1)
#endif
struct __packed vs_fr_lbk_request
{
struct ethernet_std ethernet;
struct qualcomm_std qualcomm;
uint8_t DURATION;
uint8_t RESERVED;
uint16_t LENGTH;
uint8_t PACKET [1038];
}
* request = (struct vs_fr_lbk_request *) (message);
#ifndef __GNUC__
#pragma pack (pop)
#endif
if (_allclr (plc->flags, PLC_SILENCE))
{
char sourcename [ETHER_ADDR_LEN * 3];
char targetname [ETHER_ADDR_LEN * 3];
hexdecode (source, ETHER_ADDR_LEN, sourcename, sizeof (sourcename));
hexdecode (target, ETHER_ADDR_LEN, targetname, sizeof (targetname));
fprintf (stderr, "%s %s %s\n", channel->ifname, sourcename, targetname);
}
memset (message, 0, sizeof (* message));
EthernetHeader (&message->ethernet, source, channel->host, HOMEPLUG_MTYPE);
QualcommHeader (&message->qualcomm, 0, (VS_FR_LBK | MMTYPE_REQ));
request->DURATION = plc->timer;
request->LENGTH = HTOLE16 (sizeof (request->PACKET));
memset (request->PACKET, 0xA5, sizeof (request->PACKET));
EthernetHeader (request->PACKET, target, source, ETHERTYPE_IP);
plc->packetsize = sizeof (* request);
if (SendMME (plc) <= 0)
{
error (1, errno, CHANNEL_CANTSEND);
}
if (ReadMME (plc, 0, (VS_FR_LBK | MMTYPE_CNF)) <= 0)
{
error (1, errno, CHANNEL_CANTREAD);
}
sleep (plc->timer);
return (0);
}
示例10: Platform
signed Platform (struct channel * channel, const uint8_t device [])
{
struct message message;
ssize_t packetsize;
#ifndef __GNUC__
#pragma pack (push,1)
#endif
struct __packed vs_sw_ver_request
{
struct ethernet_std ethernet;
struct qualcomm_std qualcomm;
}
* request = (struct vs_sw_ver_request *) (&message);
struct __packed vs_sw_ver_confirm
{
struct ethernet_std ethernet;
struct qualcomm_std qualcomm;
uint8_t MSTATUS;
uint8_t MDEVICEID;
uint8_t MVERLENGTH;
char MVERSION [PLC_VERSION_STRING];
}
* confirm = (struct vs_sw_ver_confirm *) (&message);
#ifndef __GNUC__
#pragma pack (pop)
#endif
memset (&message, 0, sizeof (message));
EthernetHeader (&request->ethernet, device, channel->host, channel->type);
QualcommHeader (&request->qualcomm, 0, (VS_SW_VER | MMTYPE_REQ));
if (sendpacket (channel, &message, (ETHER_MIN_LEN - ETHER_CRC_LEN)) > 0)
{
while ((packetsize = readpacket (channel, &message, sizeof (message))) > 0)
{
if (!UnwantedMessage (&message, packetsize, 0, (VS_SW_VER | MMTYPE_CNF)))
{
chipset (confirm);
printf (" %s", chipsetname (confirm->MDEVICEID));
printf (" %s", confirm->MVERSION);
return (0);
}
}
}
return (-1);
}
示例11: FactoryDefaults
signed FactoryDefaults (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_fac_defaults_request
{
struct ethernet_hdr ethernet;
struct qualcomm_hdr qualcomm;
}
* request = (struct vs_fac_defaults_request *) (message);
struct __packed vs_fac_defaults_confirm
{
struct ethernet_hdr ethernet;
struct qualcomm_hdr qualcomm;
uint8_t MSTATUS;
}
* confirm = (struct vs_fac_defaults_confirm *) (message);
#ifndef __GNUC__
#pragma pack (pop)
#endif
Request (plc, "Restore Factory Defaults");
memset (message, 0, sizeof (* message));
EthernetHeader (&request->ethernet, channel->peer, channel->host, channel->type);
QualcommHeader (&request->qualcomm, 0, (VS_FAC_DEFAULTS | MMTYPE_REQ));
plc->packetsize = (ETHER_MIN_LEN - ETHER_CRC_LEN);
if (SendMME (plc) <= 0)
{
error (PLC_EXIT (plc), errno, CHANNEL_CANTSEND);
return (-1);
}
while (ReadMME (plc, 0, (VS_FAC_DEFAULTS | MMTYPE_CNF)) > 0)
{
if (confirm->MSTATUS)
{
Failure (plc, PLC_WONTDOIT);
continue;
}
Confirm (plc, "Restoring ...");
}
return (0);
}
示例12: ListLocalDevices
signed ListLocalDevices (struct plc * plc, char const * space, char const * comma)
{
struct channel * channel = (struct channel *)(plc->channel);
struct message * message = (struct message *)(plc->message);
ssize_t packetsize;
#ifndef __GNUC__
#pragma pack (push,1)
#endif
struct __packed vs_sw_ver_request
{
struct ethernet_hdr ethernet;
struct qualcomm_hdr qualcomm;
}
* request = (struct vs_sw_ver_request *) (message);
#ifndef __GNUC__
#pragma pack (pop)
#endif
memset (message, 0, sizeof (* message));
EthernetHeader (&request->ethernet, channel->peer, channel->host, channel->type);
QualcommHeader (&request->qualcomm, 0, (VS_SW_VER | MMTYPE_REQ));
if (sendpacket (channel, message, (ETHER_MIN_LEN - ETHER_CRC_LEN)) <= 0)
{
return (-1);
}
while ((packetsize = readpacket (channel, message, sizeof (* message))) > 0)
{
if (UnwantedMessage (message, packetsize, 0, (VS_SW_VER | MMTYPE_CNF)))
{
continue;
}
hexout (request->ethernet.OSA, sizeof (request->ethernet.OSA), HEX_EXTENDER, 0, stdout);
if ((space) && (*space))
{
printf ("%s", space);
}
}
if ((comma) && (* comma))
{
printf ("%s", comma);
}
return (0);
}
示例13: LocalDevices
unsigned LocalDevices (struct channel const * channel, struct message * message, void * memory, size_t extent)
{
extern const byte localcast [ETHER_ADDR_LEN];
struct vs_sw_ver_request
{
struct ethernet_hdr ethernet;
struct qualcomm_hdr qualcomm;
}
* request = (struct vs_sw_ver_request *)(message);
uint8_t * origin = (uint8_t *)(memory);
uint8_t * offset = (uint8_t *)(memory);
ssize_t packetsize;
memset (memory, 0, extent);
memset (message, 0, sizeof (* message));
EthernetHeader (&request->ethernet, localcast, channel->host, channel->type);
QualcommHeader (&request->qualcomm, 0, (VS_SW_VER | MMTYPE_REQ));
if (sendpacket (channel, message, (ETHER_MIN_LEN - ETHER_CRC_LEN)) <= 0)
{
return (0);
}
while ((packetsize = readpacket (channel, message, sizeof (* message))) > 0)
{
if (UnwantedMessage (message, packetsize, 0, (VS_SW_VER | MMTYPE_CNF)))
{
continue;
}
if (extent >= sizeof (message->ethernet.OSA))
{
memcpy (offset, message->ethernet.OSA, sizeof (message->ethernet.OSA));
offset += sizeof (message->ethernet.OSA);
extent -= sizeof (message->ethernet.OSA);
}
}
return ((unsigned)(offset - origin) / ETHER_ADDR_LEN);
}
示例14: Identity1
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_hdr ethernet;
struct qualcomm_hdr 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_hdr ethernet;
struct qualcomm_hdr 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, channel->type);
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_EXIT (plc), 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);
}
示例15: ModuleWrite
signed ModuleWrite (struct plc * plc, struct _file_ * file, unsigned index, struct vs_module_spec * vs_module_spec)
{
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_write_request
{
struct ethernet_std ethernet;
struct qualcomm_std 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;
uint32_t MOD_OP_SESSION_ID;
uint8_t MODULE_IDX;
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];
}
* request = (struct vs_module_operation_write_request *)(message);
struct __packed vs_module_operation_write_confirm
{
struct ethernet_std ethernet;
struct qualcomm_std 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;
uint32_t MOD_OP_SESSION_ID;
uint8_t MODULE_IDX;
uint16_t MODULE_ID;
uint16_t MODULE_SUB_ID;
uint16_t MODULE_LENGTH;
uint32_t MODULE_OFFSET;
}
MODULE_SPEC;
}
* confirm = (struct vs_module_operation_write_confirm *)(message);
#ifndef __GNUC__
#pragma pack (pop)
#endif
unsigned timeout = channel->timeout;
uint16_t length = PLC_MODULE_SIZE;
uint32_t extent = vs_module_spec->MODULE_LENGTH;
uint32_t offset = 0;
Request (plc, "Flash %s", file->name);
while (extent)
{
memset (message, 0, sizeof (* message));
EthernetHeader (&request->ethernet, channel->peer, channel->host, HOMEPLUG_MTYPE);
QualcommHeader (&request->qualcomm, 0, (VS_MODULE_OPERATION | MMTYPE_REQ));
plc->packetsize = sizeof (struct vs_module_operation_write_request);
if (length > extent)
{
length = extent;
}
if (read (file->file, request->MODULE_DATA, length) != length)
{
error (1, errno, FILE_CANTREAD, file->name);
}
request->NUM_OP_DATA = 1;
request->MODULE_SPEC.MOD_OP = HTOLE16 (PLC_MOD_OP_WRITE_MODULE);
request->MODULE_SPEC.MOD_OP_DATA_LEN = HTOLE16 (sizeof (request->MODULE_SPEC) + sizeof (request->MODULE_DATA));
request->MODULE_SPEC.MOD_OP_SESSION_ID = HTOLE32 (plc->cookie);
request->MODULE_SPEC.MODULE_IDX = index;
request->MODULE_SPEC.MODULE_ID = HTOLE16 (vs_module_spec->MODULE_ID);
request->MODULE_SPEC.MODULE_SUB_ID = HTOLE16 (vs_module_spec->MODULE_SUB_ID);
request->MODULE_SPEC.MODULE_LENGTH = HTOLE16 (length);
request->MODULE_SPEC.MODULE_OFFSET = HTOLE32 (offset);
#if 0
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));
//.........这里部分代码省略.........