From 5b2e117347ba7627ea49d6ebc115ee5b4d4234ea Mon Sep 17 00:00:00 2001 From: Matias Fontanini Date: Tue, 22 Jan 2013 23:24:10 -0300 Subject: [PATCH] Implemented every DHCPv6 option getter/setter, except for those involving DUIDs. --- include/dhcpv6.h | 551 ++++++++++++++++++++++++++++++++++++++++++- src/dhcpv6.cpp | 377 ++++++++++++++++++++++++++++- tests/src/dhcpv6.cpp | 226 +++++++++++++++++- 3 files changed, 1137 insertions(+), 17 deletions(-) diff --git a/include/dhcpv6.h b/include/dhcpv6.h index 0688d76..e83ac15 100644 --- a/include/dhcpv6.h +++ b/include/dhcpv6.h @@ -120,6 +120,109 @@ public: container_type value_; }; + /** + * The message types. + */ + enum MessageType { + SOLICIT = 1, + ADVERTISE, + REQUEST, + CONFIRM, + RENEW, + REBIND, + REPLY, + RELEASE, + DECLINE, + RECONFIGURE, + INFO_REQUEST, + RELAY_FORWARD, + RELAY_REPLY, + LEASE_QUERY, + LEASE_QUERY_REPLY, + LEASE_QUERY_DONE, + LEASE_QUERY_DATA + }; + + /** + * The DHCPv6 options. + */ + enum Option { + CLIENTID = 1, + SERVERID, + IA_NA, + IA_TA, + IA_ADDR, + OPTION_REQUEST, + PREFERENCE, + ELAPSED_TIME, + RELAY_MSG, + AUTH = 11, + UNICAST, + STATUS_CODE, + RAPID_COMMIT, + USER_CLASS, + VENDOR_CLASS, + VENDOR_OPTS, + INTERFACE_ID, + RECONF_MSG, + RECONF_ACCEPT, + SIP_SERVER_D, + SIP_SERVER_A, + DNS_SERVERS, + DOMAIN_LIST, + IA_PD, + IAPREFIX, + NIS_SERVERS, + NISP_SERVERS, + NIS_DOMAIN_NAME, + NISP_DOMAIN_NAME, + SNTP_SERVERS, + INFORMATION_REFRESH_TIME, + BCMCS_SERVER_D, + BCMCS_SERVER_A, + GEOCONF_CIVIC = 36, + REMOTE_ID, + SUBSCRIBER_ID, + CLIENT_FQDN, + PANA_AGENT, + NEW_POSIX_TIMEZONE, + NEW_TZDB_TIMEZONE, + ERO, + LQ_QUERY, + CLIENT_DATA, + CLT_TIME, + LQ_RELAY_DATA, + LQ_CLIENT_LINK, + MIP6_HNIDF, + MIP6_VDINF, + V6_LOST, + CAPWAP_AC_V6, + RELAY_ID, + NTP_SERVER, + V6_ACCESS_DOMAIN, + SIP_UA_CS_LIST, + BOOTFILE_URL, + BOOTFILE_PARAM, + CLIENT_ARCH_TYPE, + NII, + GEOLOCATION, + AFTR_NAME, + ERP_LOCAL_DOMAIN_NAME, + RSOO, + PD_EXCLUDE, + VSS, + MIP6_IDINF, + MIP6_UDINF, + MIP6_HNP, + MIP6_HAA, + MIP6_HAF, + RDNSS_SELECTION, + KRB_PRINCIPAL_NAME, + KRB_REALM_NAME, + KRB_DEFAULT_REALM_NAME, + KRB_KDC + }; + /** * The type used to store the DHCPv6 options. */ @@ -135,6 +238,136 @@ public: */ static const PDU::PDUType pdu_flag = PDU::DHCPv6; + /** + * The type used to store the Identity Association for Non-Temporary + * Addresses option. + */ + struct ia_na_type { + typedef std::vector options_type; + + uint32_t id, t1, t2; + options_type options; + + ia_na_type(uint32_t id = 0, uint32_t t1 = 0, uint32_t t2 = 0, + const options_type& options = options_type()) + : id(id), t1(t1), t2(t2), options(options) {} + }; + + /** + * The type used to store the Identity Association for Temporary + * Addresses option. + */ + struct ia_ta_type { + typedef std::vector options_type; + + uint32_t id; + options_type options; + + ia_ta_type(uint32_t id = 0, + const options_type& options = options_type()) + : id(id), options(options) {} + }; + + /** + * The type used to store the Identity Association Address option. + */ + struct ia_address_type { + typedef std::vector options_type; + + ipaddress_type address; + uint32_t preferred_lifetime, valid_lifetime; + options_type options; + + ia_address_type(ipaddress_type address = ipaddress_type(), + uint32_t preferred_lifetime = 0, uint32_t valid_lifetime = 0, + const options_type& options = options_type()) + : address(address), preferred_lifetime(preferred_lifetime), + valid_lifetime(valid_lifetime), options(options) {} + }; + + /** + * The type used to store the Authentication option. + */ + struct authentication_type { + typedef std::vector auth_info_type; + + uint8_t protocol, algorithm, rdm; + uint64_t replay_detection; + auth_info_type auth_info; + + authentication_type(uint8_t protocol = 0, uint8_t algorithm = 0, + uint8_t rdm = 0, uint64_t replay_detection = 0, + const auth_info_type &auth_info = auth_info_type()) + : protocol(protocol), algorithm(algorithm), rdm(rdm), + replay_detection(replay_detection), auth_info(auth_info) {} + }; + + /** + * The type used to store the Status Code option. + */ + struct status_code_type { + uint16_t code; + std::string message; + + status_code_type(uint16_t code = 0, const std::string &message = "") + : code(code), message(message) { } + }; + + /** + * The type used to store the Vendor-specific Information option. + */ + struct vendor_info_type { + typedef std::vector data_type; + + uint32_t enterprise_number; + data_type data; + + vendor_info_type(uint32_t enterprise_number = 0, + const data_type &data = data_type()) + : enterprise_number(enterprise_number), data(data) { } + }; + + + /** + * The type used to store the User Class option's user class data. + */ + typedef std::vector class_option_data_type; + + /** + * The type used to store the User Class option. + */ + typedef std::vector user_class_type; + + /** + * The type used to store the Vendor Class option. + */ + struct vendor_class_type { + typedef std::vector class_data_type; + + uint32_t enterprise_number; + class_data_type vendor_class_data; + + vendor_class_type(uint32_t enterprise_number = 0, + const class_data_type &vendor_class_data = class_data_type()) + : enterprise_number(enterprise_number), + vendor_class_data(vendor_class_data) { } + }; + + /** + * The type used to store the Option Request option. + */ + typedef std::vector