:orphan: .. index:: pair: group; DHCP .. _doxid-group__tapi__tad__dhcp: DHCP ==== .. toctree:: :hidden: enum_dhcp_message_type.rst enum_dhcp_option_type.rst struct_dhcp_message.rst struct_dhcp_option.rst Overview ~~~~~~~~ Declarations of API for TAPI DHCP. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block // typedefs typedef enum :ref:`dhcp_option_type` :ref:`dhcp_option_type`; typedef struct :ref:`dhcp_message` :ref:`dhcp_message`; // enums enum :ref:`dhcp_message_type`; enum :ref:`dhcp_option_type`; // structs struct :ref:`dhcp_message`; struct :ref:`dhcp_option`; // global functions int :target:`ndn_dhcpv4_packet_to_plain`(const :ref:`asn_value`* pkt, struct :ref:`dhcp_message`** dhcp_msg); int :target:`ndn_dhcpv4_plain_to_packet`(const :ref:`dhcp_message`* dhcp_msg, :ref:`asn_value`** pkt); struct :ref:`dhcp_message`* :ref:`dhcpv4_message_create`(:ref:`dhcp_message_type` msg_type); struct :ref:`dhcp_message`* :ref:`dhcpv4_bootp_message_create`(uint8_t op); void :target:`dhcpv4_message_destroy`(struct :ref:`dhcp_message`*); int :target:`tapi_dhcpv4_plain_csap_create`(const char* ta_name, const char* iface, dhcp_csap_mode mode, :ref:`csap_handle_t`* dhcp_csap); int :target:`tapi_dhcpv4_message_send`(const char* ta_name, :ref:`csap_handle_t` dhcp_csap, const struct :ref:`dhcp_message`* dhcp_msg); int :ref:`dhcpv4_prepare_traffic_template`(const :ref:`dhcp_message`* dhcp_msg, const char** templ_fname); int :ref:`dhcpv4_prepare_traffic_pattern`(const :ref:`dhcp_message`* dhcp_msg, char** pattern_fname); int :ref:`dhcpv4_message_start_recv`(const char* ta_name, :ref:`csap_handle_t` dhcp_csap, unsigned int timeout, :ref:`dhcp_message_type` msg_type); struct :ref:`dhcp_message`* :target:`dhcpv4_message_capture`(const char* ta_name, :ref:`csap_handle_t` dhcp_csap, unsigned int* timeout); struct :ref:`dhcp_message`* :target:`tapi_dhcpv4_send_recv`(const char* ta_name, :ref:`csap_handle_t` dhcp_csap, const struct :ref:`dhcp_message`* dhcp_msg, unsigned int* tv, const char** err_msg); int :target:`tapi_dhcpv4_csap_get_ipaddr`(const char* ta_name, :ref:`csap_handle_t` dhcp_csap, void* addr); const struct :ref:`dhcp_option`* :target:`dhcpv4_message_get_option`(const struct :ref:`dhcp_message`* dhcp_msg, uint8_t type); const struct :ref:`dhcp_option`* :target:`dhcpv4_message_get_sub_option`(const struct :ref:`dhcp_option`* opt, uint8_t type); void :target:`dhcpv4_message_fill_reply_from_req`(struct :ref:`dhcp_message`* dhcp_rep, const struct :ref:`dhcp_message`* dhcp_req); struct :ref:`dhcp_option`* :target:`dhcpv4_option_create`(uint8_t type, uint8_t len, uint8_t val_len, uint8_t* val); int :target:`dhcpv4_option_add_subopt`(struct :ref:`dhcp_option`* opt, uint8_t type, uint8_t len, uint8_t* val); int :target:`dhcpv4_option_insert_subopt`(struct :ref:`dhcp_option`* opt, struct :ref:`dhcp_option`* subopt); int :target:`dhcpv4_message_add_option`(struct :ref:`dhcp_message`* dhcp_msg, uint8_t type, uint8_t len, const void* val); int :target:`dhcpv4_message_insert_option`(struct :ref:`dhcp_message`* dhcp_msg, struct :ref:`dhcp_option`* opt); bool :target:`dhcpv4_option55_has_code`(const struct :ref:`dhcp_option`* opt, uint8_t type); :ref:`te_errno` :ref:`tapi_dhcp_request_ip_addr`(char const* ta, char const* if_name, uint8_t const mac[ETHER_ADDR_LEN], struct sockaddr* ip_addr); :ref:`te_errno` :ref:`tapi_dhcp_release_ip_addr`(char const* ta, char const* if_name, struct sockaddr const* ip_addr); int :target:`tapi_dhcpv6_plain_csap_create`(const char* ta_name, const char* iface, dhcp6_csap_mode mode, :ref:`csap_handle_t`* dhcp_csap); int :target:`dhcpv6_prepare_traffic_template`(const :ref:`asn_value`* dhcp6_msg, :ref:`asn_value`** templ_p); int :target:`dhcpv6_prepare_traffic_pattern`(const :ref:`asn_value`* dhcp_msg, :ref:`asn_value`** pattern_p); // macros #define :target:`CONST_STRING_LENGTH`(str_) #define :ref:`DHCPV4_HDR_CHADDR_SIZE` #define :ref:`DHCPV4_HDR_FILE_SIZE` #define :ref:`DHCPV4_HDR_SNAME_SIZE` #define :ref:`DHCP_HW_TYPE_ETHERNET_10MB` #define :target:`DHCP_OP_CODE_BOOTREPLY` #define :target:`DHCP_OP_CODE_BOOTREQUEST` #define :target:`ETHER_ADDR_LEN` #define :ref:`FLAG_BROADCAST` #define :target:`dhcpv4_message_get_chaddr`(msg_) #define :target:`dhcpv4_message_get_ciaddr`(msg_) #define :ref:`dhcpv4_message_get_field`(msg_, field_) #define :target:`dhcpv4_message_get_flags`(msg_) #define :target:`dhcpv4_message_get_giaddr`(msg_) #define :target:`dhcpv4_message_get_hlen`(msg_) #define :target:`dhcpv4_message_get_htype`(msg_) #define :target:`dhcpv4_message_get_op`(msg_) #define :target:`dhcpv4_message_get_siaddr`(msg_) #define :target:`dhcpv4_message_get_xid`(msg_) #define :target:`dhcpv4_message_get_yiaddr`(msg_) #define :ref:`dhcpv4_message_set_array_field`(msg_, field_, value_) #define :ref:`dhcpv4_message_set_chaddr`(msg_, value_) #define :target:`dhcpv4_message_set_ciaddr`(msg_, value_) #define :ref:`dhcpv4_message_set_file`(msg_, value_) #define :target:`dhcpv4_message_set_flags`(msg_, value_) #define :target:`dhcpv4_message_set_giaddr`(msg_, value_) #define :target:`dhcpv4_message_set_hlen`(msg_, value_) #define :target:`dhcpv4_message_set_hops`(msg_, value_) #define :target:`dhcpv4_message_set_htype`(msg_, value_) #define :target:`dhcpv4_message_set_op`(msg_, value_) #define :target:`dhcpv4_message_set_secs`(msg_, value_) #define :target:`dhcpv4_message_set_siaddr`(msg_, value_) #define :ref:`dhcpv4_message_set_simple_field`(msg_, field_, value_) #define :ref:`dhcpv4_message_set_sname`(msg_, value_) #define :target:`dhcpv4_message_set_xid`(msg_, value_) #define :target:`dhcpv4_message_set_yiaddr`(msg_, value_) .. _details-group__tapi__tad__dhcp: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Declarations of API for TAPI DHCP. Copyright (C) 2004-2022 OKTET Labs Ltd. All rights reserved. Typedefs -------- .. index:: pair: typedef; dhcp_option_type .. _doxid-group__tapi__tad__dhcp_1ga839a1fb2b883b9d6fe2d9e416e35dc08: .. ref-code-block:: cpp :class: doxyrest-title-code-block typedef enum :ref:`dhcp_option_type` dhcp_option_type Type of DHCP Options .. index:: pair: typedef; dhcp_message .. _doxid-group__tapi__tad__dhcp_1ga90aba9d65e4f4e7e1e41a98bb63bcd8b: .. ref-code-block:: cpp :class: doxyrest-title-code-block typedef struct :ref:`dhcp_message` dhcp_message Structure of DHCP message Global Functions ---------------- .. index:: pair: function; dhcpv4_message_create .. _doxid-group__tapi__tad__dhcp_1ga2547e62e90fa61877cc599061665bf7f: .. ref-code-block:: cpp :class: doxyrest-title-code-block struct :ref:`dhcp_message`* dhcpv4_message_create(:ref:`dhcp_message_type` msg_type) Creates DHCP message of specified type. It fills the following fields as: op - According to 'msg_type' htype - Ethernet (10Mb) hlen - ETHER_ADDR_LEN All other fields are left unspecified It adds Option 53 in DHCP message with value 'msg_type' .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - msg_type - Type of the DHCP message to be created .. rubric:: Returns: Pointer to the message handle or NULL if there is not enough memory .. index:: pair: function; dhcpv4_bootp_message_create .. _doxid-group__tapi__tad__dhcp_1gaa8118d6c232258e58b0f2c477c556e2f: .. ref-code-block:: cpp :class: doxyrest-title-code-block struct :ref:`dhcp_message`* dhcpv4_bootp_message_create(uint8_t op) Creates DHCP BOOTP message with specified operation set. It fills the following fields as: op - According to 'op' htype - Ethernet (10Mb) hlen - ETHER_ADDR_LEN All other fields are left unspecified .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - op - Operation .. rubric:: Returns: Pointer to the message handle or NULL .. index:: pair: function; dhcpv4_prepare_traffic_template .. _doxid-group__tapi__tad__dhcp_1gabb4602d0edea9edb41862ed721d81073: .. ref-code-block:: cpp :class: doxyrest-title-code-block int dhcpv4_prepare_traffic_template(const :ref:`dhcp_message`* dhcp_msg, const char** templ_fname) Creates ASN.1 text file with traffic template of one DHCPv4 message .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - dhcp_msg - DHCPv4 message * - templ_fname - Traffic template file name (OUT) .. rubric:: Returns: status code .. index:: pair: function; dhcpv4_prepare_traffic_pattern .. _doxid-group__tapi__tad__dhcp_1ga68189eb4ec57e7d7e35280d424916fbc: .. ref-code-block:: cpp :class: doxyrest-title-code-block int dhcpv4_prepare_traffic_pattern(const :ref:`dhcp_message`* dhcp_msg, char** pattern_fname) Creates ASN.1 text file with traffic pattern of one DHCPv4 message .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - dhcp_msg - DHCPv4 message to be used as a pattern * - pattern_fname - Traffic pattern file name (OUT) .. rubric:: Returns: status code .. index:: pair: function; dhcpv4_message_start_recv .. _doxid-group__tapi__tad__dhcp_1gadfb9c5e5ff0fbe0e7308ff7a5c993932: .. ref-code-block:: cpp :class: doxyrest-title-code-block int dhcpv4_message_start_recv(const char* ta_name, :ref:`csap_handle_t` dhcp_csap, unsigned int timeout, :ref:`dhcp_message_type` msg_type) Star receive of DHCP message of desired type during timeout. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - ta_name - Name of Test Agent * - dhcp_csap - ID of DHCP CSAP, which should receive message * - timeout - Time while CSAP will receive, measured in milliseconds, counted wince start receive, may be TAD_TIMEOUT_INF for infinitive wait * - msg_type - Desired type of message .. rubric:: Returns: status code .. index:: pair: function; tapi_dhcp_request_ip_addr .. _doxid-group__tapi__tad__dhcp_1ga68c20af195cf95636d686ae1b2f7afe8: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` tapi_dhcp_request_ip_addr(char const* ta, char const* if_name, uint8_t const mac[ETHER_ADDR_LEN], struct sockaddr* ip_addr) Request IP address via DHCP protocol .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - ta - Test agent name * - if_name - Name of the interface to request from * - mac - MAC address to use in request * - ip_addr - Storage for IP address that is returned .. rubric:: Returns: status code .. index:: pair: function; tapi_dhcp_release_ip_addr .. _doxid-group__tapi__tad__dhcp_1ga39fdb4f0459dba39213b52ab0c199e59: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` tapi_dhcp_release_ip_addr(char const* ta, char const* if_name, struct sockaddr const* ip_addr) Release IP address via DHCP protocol .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - ta - Test agent name * - if_name - Name of the interface to send release request from * - ip_addr - Storage for IP address that is to release .. rubric:: Returns: status code Macros ------ .. index:: pair: define; DHCPV4_HDR_CHADDR_SIZE .. _doxid-group__tapi__tad__dhcp_1ga959270e081d45c053d24367eff8b8938: .. ref-code-block:: cpp :class: doxyrest-title-code-block #define DHCPV4_HDR_CHADDR_SIZE Size 'chaddr' field of DHCP message .. index:: pair: define; DHCPV4_HDR_FILE_SIZE .. _doxid-group__tapi__tad__dhcp_1gadbaa5f1849640b8755963034ffa338cd: .. ref-code-block:: cpp :class: doxyrest-title-code-block #define DHCPV4_HDR_FILE_SIZE Size 'file' field of DHCP message .. index:: pair: define; DHCPV4_HDR_SNAME_SIZE .. _doxid-group__tapi__tad__dhcp_1gacf031ad64e29a3f74a4484bc4e8a4ec3: .. ref-code-block:: cpp :class: doxyrest-title-code-block #define DHCPV4_HDR_SNAME_SIZE Size 'sname' field of DHCP message .. index:: pair: define; DHCP_HW_TYPE_ETHERNET_10MB .. _doxid-group__tapi__tad__dhcp_1gaef9122048185bd6e021309c17e99f2d2: .. ref-code-block:: cpp :class: doxyrest-title-code-block #define DHCP_HW_TYPE_ETHERNET_10MB Value used in DHCP 'htype' field for Ethernet (10Mb) hardware type [RFC 1700] .. index:: pair: define; FLAG_BROADCAST .. _doxid-group__tapi__tad__dhcp_1ga37612f05dbf3d90745066d70898bb411: .. ref-code-block:: cpp :class: doxyrest-title-code-block #define FLAG_BROADCAST BROADCAST flag .. index:: pair: define; dhcpv4_message_get_field .. _doxid-group__tapi__tad__dhcp_1ga85d8f28106549ff1ee327c48f08e962e: .. ref-code-block:: cpp :class: doxyrest-title-code-block #define dhcpv4_message_get_field(msg_, field_) Gets the value of the field in :ref:`dhcp_message ` structure .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - msg\_ - Pointer to DHCP message * - field\_ - Field name whose value to be got .. index:: pair: define; dhcpv4_message_set_array_field .. _doxid-group__tapi__tad__dhcp_1gab80e46173128df1956f8b98bf368de8e: .. ref-code-block:: cpp :class: doxyrest-title-code-block #define dhcpv4_message_set_array_field(msg_, field_, value_) Sets a new value in :ref:`dhcp_message ` structure (It is used to update array fields of the structure) .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - msg\_ - Pointer to DHCP message * - field\_ - Field name to be updated * - value\_ - Pointer to the new value .. index:: pair: define; dhcpv4_message_set_chaddr .. _doxid-group__tapi__tad__dhcp_1ga0c139eb2bf7766644d0f17f4fd75a6ad: .. ref-code-block:: cpp :class: doxyrest-title-code-block #define dhcpv4_message_set_chaddr(msg_, value_) Note that 'value\_' MUST be a pointer to a buffer with at least DHCPV4_HDR_CHADDR_SIZE valid bytes .. index:: pair: define; dhcpv4_message_set_file .. _doxid-group__tapi__tad__dhcp_1gab0061b153c28cd9bf1f8b60821912582: .. ref-code-block:: cpp :class: doxyrest-title-code-block #define dhcpv4_message_set_file(msg_, value_) Note that 'value\_' MUST be a pointer to a buffer with at least DHCPV4_HDR_FILE_SIZE valid bytes .. index:: pair: define; dhcpv4_message_set_simple_field .. _doxid-group__tapi__tad__dhcp_1ga8b2d0a171e27a5cf74ba3979f96ad71c: .. ref-code-block:: cpp :class: doxyrest-title-code-block #define dhcpv4_message_set_simple_field(msg_, field_, value_) Sets a new value in :ref:`dhcp_message ` structure (It is used to update simple type fields - not arrays) .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - msg\_ - Pointer to DHCP message * - field\_ - Field name to be updated * - value\_ - Pointer to the new value .. index:: pair: define; dhcpv4_message_set_sname .. _doxid-group__tapi__tad__dhcp_1ga54eee3f69be30902c8a314f28c57408a: .. ref-code-block:: cpp :class: doxyrest-title-code-block #define dhcpv4_message_set_sname(msg_, value_) Note that 'value\_' MUST be a pointer to a buffer with at least DHCPV4_HDR_SNAME_SIZE valid bytes