[kea-dev] hook library question: parsing DHO_DHCP_AGENT_OPTIONS sub options in incoming packets

Angelo Failla pallotron at fb.com
Thu Nov 3 15:51:39 UTC 2016


Never mind I solved my issue.I needed to build the option and suboptions like this in my unit test:

// add options 82 (both suboptions) to the request.
  OptionDefinitionPtr rai_def =
      LibDHCP::getOptionDef(Option::V4, DHO_DHCP_AGENT_OPTIONS);
  ASSERT_TRUE(rai_def);
  OptionCustomPtr rai(new OptionCustom(*rai_def, Option::V4));

  const uint8_t circuit_id_data[] = {
    0x01, 0x11, // Agent Circuit ID (length = 17)
    // "Ethernet10:2026"
    0x00, 0x0f, 0x45, 0x74, 0x68, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x31, 0x30,
    0x3a, 0x32, 0x30, 0x32, 0x36
  };
  OptionPtr circuit_id(new Option(
      Option::V4,
      RAI_OPTION_AGENT_CIRCUIT_ID,
      OptionBuffer(
          circuit_id_data, circuit_id_data + sizeof(circuit_id_data))));
  rai->addOption(circuit_id);

  const uint8_t agent_remote_id_data[] = {
    0x02, 0x13, // Agent Remote ID (length = 19)
    // "00:1c:73:8c:d0:e5"
    0x00, 0x11, 0x30, 0x30, 0x3a, 0x31, 0x63, 0x3a, 0x37, 0x33, 0x3a, 0x38,
    0x63, 0x3a, 0x64, 0x30, 0x3a, 0x65, 0x35
  };
  OptionPtr agent_remote_id(new Option(
      Option::V4,
      RAI_OPTION_REMOTE_ID,
      OptionBuffer(
          agent_remote_id_data,
          agent_remote_id_data + sizeof(agent_remote_id_data))));
  // OptionBuffer agent_info_buf = createAgentInformationOption();
  rai->addOption(agent_remote_id);

  // auto agent_info = boost::make_shared<Option>(
  //     Option::V4, DHO_DHCP_AGENT_OPTIONS, agent_info_buf);
  query->addOption(rai);

  handle_->setArgument("query4", query);



Then on the server side:

OptionDefinitionPtr rai_def =
      LibDHCP::getOptionDef(Option::V4, DHO_DHCP_AGENT_OPTIONS);
 OptionCustomPtr rai = boost::dynamic_pointer_cast<OptionCustom>(
       query4_ptr->getOption(DHO_DHCP_AGENT_OPTIONS));
 OptionPtr circuit_id_opt = rai->getOption(RAI_OPTION_AGENT_CIRCUIT_ID);


-- 
Angelo Failla

Cluster Infrastructure - Dublin
Pallotron at fb.com

On 11/3/16, 2:55 PM, "kea-dev on behalf of Angelo Failla" <kea-dev-bounces at lists.isc.org on behalf of pallotron at fb.com> wrote:

    On 11/3/16, 11:34 AM, "kea-dev on behalf of Angelo Failla" <kea-dev-bounces at lists.isc.org on behalf of pallotron at fb.com> wrote:
    
    >   Hi,
    >    I have a question about retrieving DHO_DHCP_AGENT_OPTIONS from an incoming dhcpv4 DISCOVER packet.
        
    Do I have to use user-defined options in the kea config file?
    
    -- 
    Angelo Failla
    
    Cluster Infrastructure - Dublin
    Pallotron at fb.com
    
    
    _______________________________________________
    kea-dev mailing list
    kea-dev at lists.isc.org
    https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.isc.org_mailman_listinfo_kea-2Ddev&d=DQICAg&c=5VD0RTtNlTh3ycd41b3MUw&r=XQHjLQh2eTTW8a0c8kaZ9Q&m=2K0efoRQ7oy0V1GYLFYmfCLXWHYrJGJN7oB4MNbEwWU&s=I26BEEOW0DCCLRo71OOrM-tIsnOJyxSe3f80Fvq2S-8&e= 
    



More information about the kea-dev mailing list