Ejemplo n.º 1
0
DHCPv6::duid_type DHCPv6::server_id() const {
    const option *opt = safe_search_option<std::less>(
        SERVERID, sizeof(uint16_t) + 1
    );
    return duid_type(
        Endian::be_to_host(*(const uint16_t*)opt->data_ptr()),
        serialization_type(
            opt->data_ptr() + sizeof(uint16_t),
            opt->data_ptr() + opt->data_size()
        )
    );
}
Ejemplo n.º 2
0
DHCPv6::duid_type DHCPv6::duid_type::from_option(const option &opt)
{
    if(opt.data_size() < sizeof(uint16_t) + 1)
        throw malformed_option();

    uint16_t uint16_t_buffer;
    std::memcpy(&uint16_t_buffer, opt.data_ptr(), sizeof(uint16_t));
    return duid_type(
        Endian::be_to_host(uint16_t_buffer),
        serialization_type(
            opt.data_ptr() + sizeof(uint16_t),
            opt.data_ptr() + opt.data_size()
        )
    );
}