Exemple #1
0
/********************************************************************
 * Function:
 *
 * Purpose:
 *
 * Arguments:
 *
 * Returns:
 *
 ********************************************************************/
const char * DCE2_UuidToStr(const Uuid *uuid, DceRpcBoFlag byte_order)
{
#define UUID_BUF_SIZE  50
    static char uuid_buf1[UUID_BUF_SIZE];
    static char uuid_buf2[UUID_BUF_SIZE];
    static int buf_num = 0;
    char *uuid_buf;

    if (buf_num == 0)
    {
        uuid_buf = uuid_buf1;
        buf_num = 1;
    }
    else
    {
        uuid_buf = uuid_buf2;
        buf_num = 0;
    }

    snprintf(uuid_buf, UUID_BUF_SIZE,
             "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
             DceRpcHtonl(&uuid->time_low, byte_order),
             DceRpcHtons(&uuid->time_mid, byte_order),
             DceRpcHtons(&uuid->time_high_and_version, byte_order),
             uuid->clock_seq_and_reserved, uuid->clock_seq_low,
             uuid->node[0], uuid->node[1], uuid->node[2],
             uuid->node[3], uuid->node[4], uuid->node[5]);

    uuid_buf[UUID_BUF_SIZE - 1] = '\0';

    return uuid_buf;
}
Exemple #2
0
/********************************************************************
 * Function: DCE2_ClSetRdata()
 *
 * Sets relevant data fields in the reassembly packet.
 *
 * Arguments:
 *  DCE2_ClActTracker *
 *      Pointer to the activity tracker associated with the
 *      reassemble packet.
 *  DceRpcClHdr *
 *      Pointer to the connectionless header in the wire packet.
 *  uint8_t *
 *      Pointer to the start of the reassembly buffer.
 *  uint16_t
 *      The length of the stub data.
 *
 * Returns: None
 *
 ********************************************************************/
static inline void DCE2_ClSetRdata(DCE2_ClActTracker *at, const DceRpcClHdr *pkt_cl_hdr,
                                   uint8_t *cl_ptr, uint16_t stub_len)
{
    DCE2_ClFragTracker *ft = &at->frag_tracker;
    DceRpcClHdr *cl_hdr = (DceRpcClHdr *)cl_ptr;
    uint16_t opnum = (ft->opnum != DCE2_SENTINEL) ? (uint16_t)ft->opnum : DceRpcClOpnum(pkt_cl_hdr);

    cl_hdr->len = DceRpcHtons(&stub_len, DCERPC_BO_FLAG__LITTLE_ENDIAN);
    DCE2_CopyUuid(&cl_hdr->object, &pkt_cl_hdr->object, DceRpcClByteOrder(cl_hdr));
    DCE2_CopyUuid(&cl_hdr->if_id, &ft->iface, DCERPC_BO_FLAG__LITTLE_ENDIAN);
    DCE2_CopyUuid(&cl_hdr->act_id, &at->act, DCERPC_BO_FLAG__LITTLE_ENDIAN);
    cl_hdr->if_vers = DceRpcHtonl(&ft->iface_vers, DCERPC_BO_FLAG__LITTLE_ENDIAN);
    cl_hdr->opnum = DceRpcHtons(&opnum, DCERPC_BO_FLAG__LITTLE_ENDIAN);
}