/* Write a DID response on the output channel. */
static int write_did_response(void *chout_p, uint8_t response_code, uint16_t did, const void *data_p, size_t size)
/* Write a DID response on the output channel. */
static int write_did_response(void *chout_p, uint8_t response_code, uint16_t did, const void *data_p, size_t size)
{
    uint32_t length;
    length = (sizeof(response_code)
              + sizeof(did)
              + size);
    length = htonl(length);
    did = htons(did);
    chan_write(chout_p, &length, sizeof(length));
    chan_write(chout_p, &response_code, sizeof(response_code));
    chan_write(chout_p, &did, sizeof(did));
    chan_write(chout_p, data_p, size);
    return (0);
}