in src/tpm_socket_comm.c [117:153]
static int send_socket_bytes(TPM_SOCKET_INFO* socket_info, const unsigned char* cmd_val, size_t byte_len)
{
int result;
#if SHOW_TRACE
printf("<- ");
for (size_t index = 0; index < byte_len; index++)
{
printf("%x", cmd_val[index]);
}
printf("\r\n");
#endif
int sent_bytes = 0;
int send_amt = (int)byte_len;
const char* pIterator = (const char*)cmd_val;
while (send_amt > 0)
{
sent_bytes = send(socket_info->socket_conn, pIterator, (int)send_amt, 0);
if (sent_bytes <= 0)
{
LogError("Failure sending packet.");
break;
}
pIterator += sent_bytes;
send_amt -= sent_bytes;
}
if (sent_bytes < (int)byte_len)
{
LogError("sent byte amoutn is less than desired send amount.");
result = MU_FAILURE;
}
else
{
result = 0;
}
return result;
}