/* PRNG service */
{"RANDOM_REQ", prng_e, 0x00, prng_param_e},
- {"RANDOM_RESP", prng_e, 0x01, status_e},
+ {"RANDOM_RESP", prng_e, 0x01, raw_data_e},
/* Control service */
{"STATUS_REQ", control_e, 0x00, nopdu_e},
{"REBOOT_RESP", control_e, 0x05, status_e},
{"ZEROIZE_REQ", control_e, 0x04, nopdu_e},
{"ZEROIZE_RESP", control_e, 0x05, status_e},
- {"LOCK_REQ", control_e, 0xFE, nopdu_e},
- {"LOCK_RESP", control_e, 0xFF, status_e},
+ {"LOCK_CRYPTO_REQ", control_e, 0xFE, nopdu_e},
+ {"LOCK_CRYPTO_RESP", control_e, 0xFF, status_e},
/* End of list */
{"", noserv_e, 0x00, undef_pdu_e}
(comm_list + nbcomms)->etype = strrchr (url, '/') + 1;
for (int i = 0; (service_list + i)->service_id != noserv_e; i++) {
service_t *s = service_list + i;
- if (strcmp (s->name, servname) == 0) {
+ if (s && servname && (strcmp (s->name, servname) == 0)) {
memcpy (mode ? &(s->rx) : &(s->tx), comm_list + nbcomms, sizeof (comm_t));
break;
}
/* parse message */
pdu = msg->pdu;
switch (pdu) {
+ case nopdu_e:
+ break;
case channel_e:
parse_channel (line + offset, &msg_channel);
break;
uint8_t msgtype = 0;
uint8_t payload[1496] = {0};
- int seqnum = MOREP_Receive (comm->morep, &msgtype, payload, &len);
+ seqnum = MOREP_Receive (comm->morep, &msgtype, payload, &len);
/* check pdu type */
pdu = undef_pdu_e;
/* deserialize message */
switch (pdu) {
+ case nopdu_e:
+ break;
case channel_e:
deserial_channel (payload, len, &msg_channel);
break;
serv->name, comm->etype, seqnum, msg->msgtype, len, pdu, msg->name);
char buffer[1496 * 3 + 256] = {0};
switch (pdu) {
+ case nopdu_e:
+ break;
case channel_e:
format_channel (&msg_channel, buffer, sizeof (buffer));
break;
/* test: morep_simulator.exe -r 2>&1 | grep 'url not specified' */
/* test: morep_simulator.exe -s 2>&1 | grep 'service not specified' */
/* test: morep_simulator.exe -t 2>&1 | grep 'url not specified' */
-/* test: morep_simulator.exe -l - -t lo://00:00:00:00:00:00/0809 -v 4 script-l0.eth */
+/* test: morep_simulator.exe -l - -t lo://00:00:00:00:00:00/0809 -v 4 script-lo.eth */
/* test: morep_simulator.exe -l script-cross_crypto.log -s CROSS_CRYPTO -t lo://00:00:00:00:00:00/0808 -r lo://00:00:00:00:00:00/0808 script-cross_crypto.eth */
+/* test: morep_simulator.exe -l script-cross_crypto.log -s CROSS_CRYPTO -t lo://00:00:00:00:00:00/0808 -r lo://00:00:00:00:00:00/0808 script-cross_crypto.eth | grep -v WARNING */
/* test: morep_simulator.exe -l script-local_crypto.log -s LOCAL_CRYPTO -t lo://00:00:00:00:00:00/0808 -r lo://00:00:00:00:00:00/0808 script-local_crypto.eth */
+/* test: morep_simulator.exe -l script-local_crypto.log -s LOCAL_CRYPTO -t lo://00:00:00:00:00:00/0808 -r lo://00:00:00:00:00:00/0808 script-local_crypto.eth | grep -v WARNING */
/* test: morep_simulator.exe -l script-provisioning.log -s PROVISIONING -t lo://00:00:00:00:00:00/0808 -r lo://00:00:00:00:00:00/0808 script-provisioning.eth */
+/* test: morep_simulator.exe -l script-provisioning.log -s PROVISIONING -t lo://00:00:00:00:00:00/0808 -r lo://00:00:00:00:00:00/0808 script-provisioning.eth | grep -v WARNING */
/* test: morep_simulator.exe -l script-prng.log -s PRNG -t lo://00:00:00:00:00:00/0808 -r lo://00:00:00:00:00:00/0808 script-prng.eth */
+/* test: morep_simulator.exe -l script-prng.log -s PRNG -t lo://00:00:00:00:00:00/0808 -r lo://00:00:00:00:00:00/0808 script-prng.eth | grep -v WARNING */
/* test: morep_simulator.exe -l script-bypass.log -s BYPASS -t lo://00:00:00:00:00:00/0808 -r lo://00:00:00:00:00:00/0808 script-bypass.eth */
-/* test: morep_simulator.exe -l script-control.log -s CONTROL -t lo://00:00:00:00:00:00/0808 -r lo://00:00:00:00:00:00/0808 script-control.eth -v 4 */
+/* test: morep_simulator.exe -l script-bypass.log -s BYPASS -t lo://00:00:00:00:00:00/0808 -r lo://00:00:00:00:00:00/0808 script-bypass.eth | grep -v WARNING */
+/* test: morep_simulator.exe -l script-control.log -s CONTROL -t lo://00:00:00:00:00:00/0808 -r lo://00:00:00:00:00:00/0808 script-control.eth -v 3 */
+/* test: morep_simulator.exe -l script-control.log -s CONTROL -t lo://00:00:00:00:00:00/0808 -r lo://00:00:00:00:00:00/0808 script-control.eth -v 3 | grep -v WARNING */
/* vim: set ts=4 sw=4 si et: */
*/
#define SERIAL_ARRAY(name, field) \
if (field##_len < _maxlen - len) { \
- memcpy (_buffer + len, field, field##_len); \
+ memcpy (_buffer + len, field, (uint16_t)field##_len); \
len += field##_len; \
} else { \
VERBOSE (morep, WARNING, PRINTF ("field '%s' too large\n", name)); \
*/
#define SERIAL_TAB(name, field) \
if ((int)sizeof (field) < _maxlen - len) { \
- memcpy (_buffer + len, field, sizeof (field)); \
+ memcpy (_buffer + len, field, (uint16_t)sizeof (field)); \
len += sizeof (field); \
} else { \
VERBOSE (morep, WARNING, PRINTF ("field '%s' too large\n", name)); \
*/
#define DESERIAL_TAB(name, field) \
if ((int)sizeof (field) < end - ptr) { \
- memcpy (field, ptr, sizeof (field)); \
- ptr += sizeof (field); \
+ memcpy (field, ptr, (uint16_t)sizeof (field)); \
+ ptr += sizeof (field); \
} else { \
VERBOSE (morep, WARNING, PRINTF ("no data for field '%s'\n", name)); \
ptr = end + 1; \
*/
#define DESERIAL_ARRAY(name, field, ...) \
if ((0 == __VA_ARGS__ + 0) && (ptr < end)) { \
- memcpy (field, ptr, end - ptr); \
+ memcpy (field, ptr, (uint16_t)(end - ptr)); \
field##_len = end - ptr; \
ptr = end; \
} else if (field##_len < end - ptr) { \
- memcpy (field, ptr, field##_len); \
+ memcpy (field, ptr, (uint16_t)field##_len); \
ptr += field##_len; \
- } else { \
+ } else if (field##_len > 0) { \
VERBOSE (morep, WARNING, PRINTF ("no data for field '%s'\n", name)); \
ptr = end + 1; \
}