37 #include <boost/algorithm/string/classification.hpp>
38 #include <boost/algorithm/string/split.hpp>
39 #include <boost/assert.hpp>
40 #include <boost/unordered_map.hpp>
55 typedef std::vector<uint8_t> HostIdentifier;
61 tuple<HostIdentifier, Host::IdentifierType, SubnetID, SubnetID, IOAddress> HostKey;
74 typedef std::unordered_map<HostKey, HostPtr, boost::hash<HostKey>> HostMap;
77 typedef std::pair<HostKey, HostPtr> HostPair;
80 struct OptionWrapper {
82 : option_descriptor_(option_descriptor), option_space_(option_space) {
85 std::string option_space_;
91 static constexpr cass_int32_t MAX_IDENTIFIER_TYPE =
static_cast<cass_int32_t
>(Host::IDENT_FLEX);
95 static constexpr
char NULL_DHCP4_SERVER_HOSTNAME[] =
"";
96 static constexpr
char NULL_DHCP4_BOOT_FILE_NAME[] =
"";
97 static constexpr
char NULL_USER_CONTEXT[] =
"";
98 static constexpr
char NULL_RESERVED_IPV6_PREFIX_ADDRESS[] =
"::";
99 static constexpr cass_int32_t NULL_RESERVED_IPV6_PREFIX_LENGTH = 0;
100 static constexpr cass_int32_t NULL_RESERVED_IPV6_PREFIX_ADDRESS_TYPE = -1;
101 static constexpr cass_int32_t NULL_IAID = -1;
102 static constexpr cass_int32_t NULL_OPTION_UNIVERSE = -1;
103 static constexpr cass_int32_t NULL_OPTION_CODE = -1;
105 static constexpr
char NULL_OPTION_FORMATTED_VALUE[] =
"";
106 static constexpr
char NULL_OPTION_SPACE[] =
"";
107 static constexpr cass_bool_t NULL_OPTION_IS_PERSISTENT = cass_false;
108 static constexpr
char NULL_OPTION_CLIENT_CLASS[] =
"";
109 static constexpr cass_int32_t NULL_OPTION_SUBNET_ID = -1;
110 static constexpr
char NULL_OPTION_USER_CONTEXT[] =
"";
111 static constexpr cass_int32_t NULL_OPTION_SCOPE_ID = -1;
116 static const IPv6Resrv NULL_IPV6_RESERVATION =
158 void prepareExchange(
const HostPtr& host,
161 const std::string& option_space,
177 void createBindForMutation(
const HostPtr& host,
180 const std::string& option_space,
198 void createBindForDelete(
const HostPtr& host,
201 const std::string& option_space,
216 uint64_t hashIntoId()
const;
223 uint64_t hashIntoKey()
const;
230 std::string hostKey()
const;
239 virtual boost::any retrieve()
override;
247 const IPv6Resrv retrieveReservation()
const;
255 const OptionWrapper retrieveOption()
const;
268 static constexpr
StatementTag GET_HOST_BY_HOST_ID =
"GET_HOST_BY_HOST_ID";
272 static constexpr
StatementTag GET_HOST_BY_IPV4_ADDRESS =
"GET_HOST_BY_IPV4_ADDRESS";
277 "GET_HOST_BY_IPV4_SUBNET_ID_AND_HOST_ID";
283 "GET_HOST_BY_IPV6_SUBNET_ID_AND_HOST_ID";
288 "GET_HOST_BY_IPV4_SUBNET_ID_AND_ADDRESS";
296 static constexpr
StatementTag GET_HOST_BY_IPV6_PREFIX =
"GET_HOST_BY_IPV6_PREFIX";
301 "GET_HOST_BY_IPV6_SUBNET_ID_AND_ADDRESS";
310 "GET_HOST_BY_IPV4_SUBNET_ID";
315 "GET_HOST_BY_IPV6_SUBNET_ID";
320 "GET_HOST_BY_HOST_NAME";
324 static constexpr
StatementTag GET_HOST_BY_HOST_NAME_AND_IPV4_SUBNET_ID =
325 "GET_HOST_BY_HOST_NAME_AND_IPV4_SUBNET_ID";
329 static constexpr
StatementTag GET_HOST_BY_HOST_NAME_AND_IPV6_SUBNET_ID =
330 "GET_HOST_BY_HOST_NAME_AND_IPV6_SUBNET_ID";
335 "GET_HOST_BY_IPV4_SUBNET_ID_LIMIT";
340 "GET_HOST_BY_IPV4_SUBNET_ID_NEXT_KEY";
345 "GET_HOST_BY_IPV4_SUBNET_ID_PAGE";
350 "GET_HOST_BY_IPV6_SUBNET_ID_LIMIT";
355 "GET_HOST_BY_IPV6_SUBNET_ID_NEXT_KEY";
361 "GET_HOST_BY_IPV6_SUBNET_ID_PAGE";
402 cass_int32_t host_identifier_type_;
405 cass_int32_t host_ipv4_subnet_id_;
408 cass_int32_t host_ipv6_subnet_id_;
411 cass_int32_t host_ipv4_address_;
414 cass_int32_t host_ipv4_next_server_;
417 std::string host_ipv4_server_hostname_;
420 std::string host_ipv4_boot_file_name_;
423 std::string auth_key_;
426 std::string hostname_;
429 std::string lower_case_hostname_;
432 std::string user_context_;
435 std::string host_ipv4_client_classes_;
438 std::string host_ipv6_client_classes_;
441 std::string reserved_ipv6_prefix_address_;
444 cass_int32_t reserved_ipv6_prefix_length_;
448 cass_int32_t reserved_ipv6_prefix_address_type_;
455 cass_int32_t option_universe_;
458 cass_int32_t option_code_;
464 std::string option_formatted_value_;
467 std::string option_space_;
470 cass_bool_t option_is_persistent_;
473 std::string option_client_class_;
476 cass_int32_t option_subnet_id_;
479 std::string option_user_context_;
482 cass_int32_t option_scope_id_;
487 constexpr
StatementTag CqlHostExchange::GET_HOST_BY_HOST_ID;
488 constexpr
StatementTag CqlHostExchange::GET_HOST_BY_IPV4_ADDRESS;
489 constexpr
StatementTag CqlHostExchange::GET_HOST_BY_IPV4_SUBNET_ID_AND_HOST_ID;
490 constexpr
StatementTag CqlHostExchange::GET_HOST_BY_IPV6_SUBNET_ID_AND_HOST_ID;
491 constexpr
StatementTag CqlHostExchange::GET_HOST_BY_IPV4_SUBNET_ID_AND_ADDRESS;
492 constexpr
StatementTag CqlHostExchange::GET_HOST_BY_IPV6_PREFIX;
493 constexpr
StatementTag CqlHostExchange::GET_HOST_BY_IPV6_SUBNET_ID_AND_ADDRESS;
494 constexpr
StatementTag CqlHostExchange::GET_HOST_BY_IPV4_SUBNET_ID;
495 constexpr
StatementTag CqlHostExchange::GET_HOST_BY_IPV6_SUBNET_ID;
496 constexpr
StatementTag CqlHostExchange::GET_HOST_BY_HOST_NAME;
497 constexpr
StatementTag CqlHostExchange::GET_HOST_BY_HOST_NAME_AND_IPV4_SUBNET_ID;
498 constexpr
StatementTag CqlHostExchange::GET_HOST_BY_HOST_NAME_AND_IPV6_SUBNET_ID;
499 constexpr
StatementTag CqlHostExchange::GET_HOST_BY_IPV4_SUBNET_ID_LIMIT;
500 constexpr
StatementTag CqlHostExchange::GET_HOST_BY_IPV6_SUBNET_ID_LIMIT;
501 constexpr
StatementTag CqlHostExchange::GET_HOST_BY_IPV4_SUBNET_ID_NEXT_KEY;
502 constexpr
StatementTag CqlHostExchange::GET_HOST_BY_IPV6_SUBNET_ID_NEXT_KEY;
503 constexpr
StatementTag CqlHostExchange::GET_HOST_BY_IPV4_SUBNET_ID_PAGE;
504 constexpr
StatementTag CqlHostExchange::GET_HOST_BY_IPV6_SUBNET_ID_PAGE;
506 constexpr
StatementTag CqlHostExchange::GET_HOST_NEXT_KEY;
514 "INSERT INTO hosts ( "
518 "host_identifier_type, "
519 "host_ipv4_subnet_id, "
520 "host_ipv6_subnet_id, "
521 "host_ipv4_address, "
522 "host_ipv4_next_server, "
523 "host_ipv4_server_hostname, "
524 "host_ipv4_boot_file_name, "
527 "lower_case_hostname, "
529 "host_ipv4_client_classes, "
530 "host_ipv6_client_classes, "
531 "reserved_ipv6_prefix_address, "
532 "reserved_ipv6_prefix_length, "
533 "reserved_ipv6_prefix_address_type, "
538 "option_formatted_value, "
540 "option_is_persistent, "
541 "option_client_class, "
543 "option_user_context, "
551 "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, "
553 "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? "
564 "host_identifier_type, "
565 "host_ipv4_subnet_id, "
566 "host_ipv6_subnet_id, "
567 "host_ipv4_address, "
568 "host_ipv4_next_server, "
569 "host_ipv4_server_hostname, "
570 "host_ipv4_boot_file_name, "
574 "host_ipv4_client_classes, "
575 "host_ipv6_client_classes, "
576 "reserved_ipv6_prefix_address, "
577 "reserved_ipv6_prefix_length, "
578 "reserved_ipv6_prefix_address_type, "
583 "option_formatted_value, "
585 "option_is_persistent, "
586 "option_client_class, "
588 "option_user_context, "
593 {GET_HOST_BY_HOST_ID,
594 {GET_HOST_BY_HOST_ID,
599 "host_identifier_type, "
600 "host_ipv4_subnet_id, "
601 "host_ipv6_subnet_id, "
602 "host_ipv4_address, "
603 "host_ipv4_next_server, "
604 "host_ipv4_server_hostname, "
605 "host_ipv4_boot_file_name, "
609 "host_ipv4_client_classes, "
610 "host_ipv6_client_classes, "
611 "reserved_ipv6_prefix_address, "
612 "reserved_ipv6_prefix_length, "
613 "reserved_ipv6_prefix_address_type, "
618 "option_formatted_value, "
620 "option_is_persistent, "
621 "option_client_class, "
623 "option_user_context, "
626 "WHERE host_identifier = ? "
627 "AND host_identifier_type = ? "
631 {GET_HOST_BY_IPV4_ADDRESS,
632 {GET_HOST_BY_IPV4_ADDRESS,
637 "host_identifier_type, "
638 "host_ipv4_subnet_id, "
639 "host_ipv6_subnet_id, "
640 "host_ipv4_address, "
641 "host_ipv4_next_server, "
642 "host_ipv4_server_hostname, "
643 "host_ipv4_boot_file_name, "
647 "host_ipv4_client_classes, "
648 "host_ipv6_client_classes, "
649 "reserved_ipv6_prefix_address, "
650 "reserved_ipv6_prefix_length, "
651 "reserved_ipv6_prefix_address_type, "
656 "option_formatted_value, "
658 "option_is_persistent, "
659 "option_client_class, "
661 "option_user_context, "
664 "WHERE host_ipv4_address = ? "
668 {GET_HOST_BY_IPV4_SUBNET_ID_AND_HOST_ID,
669 {GET_HOST_BY_IPV4_SUBNET_ID_AND_HOST_ID,
674 "host_identifier_type, "
675 "host_ipv4_subnet_id, "
676 "host_ipv6_subnet_id, "
677 "host_ipv4_address, "
678 "host_ipv4_next_server, "
679 "host_ipv4_server_hostname, "
680 "host_ipv4_boot_file_name, "
684 "host_ipv4_client_classes, "
685 "host_ipv6_client_classes, "
686 "reserved_ipv6_prefix_address, "
687 "reserved_ipv6_prefix_length, "
688 "reserved_ipv6_prefix_address_type, "
693 "option_formatted_value, "
695 "option_is_persistent, "
696 "option_client_class, "
698 "option_user_context, "
701 "WHERE host_ipv4_subnet_id = ? "
702 "AND host_identifier = ? "
703 "AND host_identifier_type = ? "
707 {GET_HOST_BY_IPV6_SUBNET_ID_AND_HOST_ID,
708 {GET_HOST_BY_IPV6_SUBNET_ID_AND_HOST_ID,
713 "host_identifier_type, "
714 "host_ipv4_subnet_id, "
715 "host_ipv6_subnet_id, "
716 "host_ipv4_address, "
717 "host_ipv4_next_server, "
718 "host_ipv4_server_hostname, "
719 "host_ipv4_boot_file_name, "
723 "host_ipv4_client_classes, "
724 "host_ipv6_client_classes, "
725 "reserved_ipv6_prefix_address, "
726 "reserved_ipv6_prefix_length, "
727 "reserved_ipv6_prefix_address_type, "
732 "option_formatted_value, "
734 "option_is_persistent, "
735 "option_client_class, "
737 "option_user_context, "
740 "WHERE host_ipv6_subnet_id = ? "
741 "AND host_identifier = ? "
742 "AND host_identifier_type = ? "
746 {GET_HOST_BY_IPV4_SUBNET_ID_AND_ADDRESS,
747 {GET_HOST_BY_IPV4_SUBNET_ID_AND_ADDRESS,
752 "host_identifier_type, "
753 "host_ipv4_subnet_id, "
754 "host_ipv6_subnet_id, "
755 "host_ipv4_address, "
756 "host_ipv4_next_server, "
757 "host_ipv4_server_hostname, "
758 "host_ipv4_boot_file_name, "
762 "host_ipv4_client_classes, "
763 "host_ipv6_client_classes, "
764 "reserved_ipv6_prefix_address, "
765 "reserved_ipv6_prefix_length, "
766 "reserved_ipv6_prefix_address_type, "
771 "option_formatted_value, "
773 "option_is_persistent, "
774 "option_client_class, "
776 "option_user_context, "
779 "WHERE host_ipv4_subnet_id = ? "
780 "AND host_ipv4_address = ? "
784 {GET_HOST_BY_IPV6_PREFIX,
785 {GET_HOST_BY_IPV6_PREFIX,
790 "host_identifier_type, "
791 "host_ipv4_subnet_id, "
792 "host_ipv6_subnet_id, "
793 "host_ipv4_address, "
794 "host_ipv4_next_server, "
795 "host_ipv4_server_hostname, "
796 "host_ipv4_boot_file_name, "
800 "host_ipv4_client_classes, "
801 "host_ipv6_client_classes, "
802 "reserved_ipv6_prefix_address, "
803 "reserved_ipv6_prefix_length, "
804 "reserved_ipv6_prefix_address_type, "
809 "option_formatted_value, "
811 "option_is_persistent, "
812 "option_client_class, "
814 "option_user_context, "
817 "WHERE reserved_ipv6_prefix_address = ? "
818 "AND reserved_ipv6_prefix_length = ? "
822 {GET_HOST_BY_IPV6_SUBNET_ID_AND_ADDRESS,
823 {GET_HOST_BY_IPV6_SUBNET_ID_AND_ADDRESS,
828 "host_identifier_type, "
829 "host_ipv4_subnet_id, "
830 "host_ipv6_subnet_id, "
831 "host_ipv4_address, "
832 "host_ipv4_next_server, "
833 "host_ipv4_server_hostname, "
834 "host_ipv4_boot_file_name, "
838 "host_ipv4_client_classes, "
839 "host_ipv6_client_classes, "
840 "reserved_ipv6_prefix_address, "
841 "reserved_ipv6_prefix_length, "
842 "reserved_ipv6_prefix_address_type, "
847 "option_formatted_value, "
849 "option_is_persistent, "
850 "option_client_class, "
852 "option_user_context, "
855 "WHERE host_ipv6_subnet_id = ? "
856 "AND reserved_ipv6_prefix_address = ? "
860 {GET_HOST_BY_IPV4_SUBNET_ID,
861 {GET_HOST_BY_IPV4_SUBNET_ID,
866 "host_identifier_type, "
867 "host_ipv4_subnet_id, "
868 "host_ipv6_subnet_id, "
869 "host_ipv4_address, "
870 "host_ipv4_next_server, "
871 "host_ipv4_server_hostname, "
872 "host_ipv4_boot_file_name, "
876 "host_ipv4_client_classes, "
877 "host_ipv6_client_classes, "
878 "reserved_ipv6_prefix_address, "
879 "reserved_ipv6_prefix_length, "
880 "reserved_ipv6_prefix_address_type, "
885 "option_formatted_value, "
887 "option_is_persistent, "
888 "option_client_class, "
890 "option_user_context, "
893 "WHERE host_ipv4_subnet_id = ? "
897 {GET_HOST_BY_IPV6_SUBNET_ID,
898 {GET_HOST_BY_IPV6_SUBNET_ID,
903 "host_identifier_type, "
904 "host_ipv4_subnet_id, "
905 "host_ipv6_subnet_id, "
906 "host_ipv4_address, "
907 "host_ipv4_next_server, "
908 "host_ipv4_server_hostname, "
909 "host_ipv4_boot_file_name, "
913 "host_ipv4_client_classes, "
914 "host_ipv6_client_classes, "
915 "reserved_ipv6_prefix_address, "
916 "reserved_ipv6_prefix_length, "
917 "reserved_ipv6_prefix_address_type, "
922 "option_formatted_value, "
924 "option_is_persistent, "
925 "option_client_class, "
927 "option_user_context, "
930 "WHERE host_ipv6_subnet_id = ? "
934 {GET_HOST_BY_HOST_NAME,
935 {GET_HOST_BY_HOST_NAME,
940 "host_identifier_type, "
941 "host_ipv4_subnet_id, "
942 "host_ipv6_subnet_id, "
943 "host_ipv4_address, "
944 "host_ipv4_next_server, "
945 "host_ipv4_server_hostname, "
946 "host_ipv4_boot_file_name, "
950 "host_ipv4_client_classes, "
951 "host_ipv6_client_classes, "
952 "reserved_ipv6_prefix_address, "
953 "reserved_ipv6_prefix_length, "
954 "reserved_ipv6_prefix_address_type, "
959 "option_formatted_value, "
961 "option_is_persistent, "
962 "option_client_class, "
964 "option_user_context, "
967 "WHERE lower_case_hostname = ? "
971 {GET_HOST_BY_HOST_NAME_AND_IPV4_SUBNET_ID,
972 {GET_HOST_BY_HOST_NAME_AND_IPV4_SUBNET_ID,
977 "host_identifier_type, "
978 "host_ipv4_subnet_id, "
979 "host_ipv6_subnet_id, "
980 "host_ipv4_address, "
981 "host_ipv4_next_server, "
982 "host_ipv4_server_hostname, "
983 "host_ipv4_boot_file_name, "
987 "host_ipv4_client_classes, "
988 "host_ipv6_client_classes, "
989 "reserved_ipv6_prefix_address, "
990 "reserved_ipv6_prefix_length, "
991 "reserved_ipv6_prefix_address_type, "
996 "option_formatted_value, "
998 "option_is_persistent, "
999 "option_client_class, "
1000 "option_subnet_id, "
1001 "option_user_context, "
1004 "WHERE lower_case_hostname = ? "
1005 "AND host_ipv4_subnet_id = ? "
1009 {GET_HOST_BY_HOST_NAME_AND_IPV6_SUBNET_ID,
1010 {GET_HOST_BY_HOST_NAME_AND_IPV6_SUBNET_ID,
1015 "host_identifier_type, "
1016 "host_ipv4_subnet_id, "
1017 "host_ipv6_subnet_id, "
1018 "host_ipv4_address, "
1019 "host_ipv4_next_server, "
1020 "host_ipv4_server_hostname, "
1021 "host_ipv4_boot_file_name, "
1025 "host_ipv4_client_classes, "
1026 "host_ipv6_client_classes, "
1027 "reserved_ipv6_prefix_address, "
1028 "reserved_ipv6_prefix_length, "
1029 "reserved_ipv6_prefix_address_type, "
1034 "option_formatted_value, "
1036 "option_is_persistent, "
1037 "option_client_class, "
1038 "option_subnet_id, "
1039 "option_user_context, "
1042 "WHERE lower_case_hostname = ? "
1043 "AND host_ipv6_subnet_id = ? "
1047 {GET_HOST_BY_IPV4_SUBNET_ID_LIMIT,
1048 {GET_HOST_BY_IPV4_SUBNET_ID_LIMIT,
1053 "host_identifier_type, "
1054 "host_ipv4_subnet_id, "
1055 "host_ipv6_subnet_id, "
1056 "host_ipv4_address, "
1057 "host_ipv4_next_server, "
1058 "host_ipv4_server_hostname, "
1059 "host_ipv4_boot_file_name, "
1063 "host_ipv4_client_classes, "
1064 "host_ipv6_client_classes, "
1065 "reserved_ipv6_prefix_address, "
1066 "reserved_ipv6_prefix_length, "
1067 "reserved_ipv6_prefix_address_type, "
1072 "option_formatted_value, "
1074 "option_is_persistent, "
1075 "option_client_class, "
1076 "option_subnet_id, "
1077 "option_user_context, "
1080 "WHERE host_ipv4_subnet_id = ? "
1085 {GET_HOST_BY_IPV4_SUBNET_ID_NEXT_KEY,
1086 {GET_HOST_BY_IPV4_SUBNET_ID_NEXT_KEY,
1091 "host_identifier_type, "
1092 "host_ipv4_subnet_id, "
1093 "host_ipv6_subnet_id, "
1094 "host_ipv4_address, "
1095 "host_ipv4_next_server, "
1096 "host_ipv4_server_hostname, "
1097 "host_ipv4_boot_file_name, "
1101 "host_ipv4_client_classes, "
1102 "host_ipv6_client_classes, "
1103 "reserved_ipv6_prefix_address, "
1104 "reserved_ipv6_prefix_length, "
1105 "reserved_ipv6_prefix_address_type, "
1110 "option_formatted_value, "
1112 "option_is_persistent, "
1113 "option_client_class, "
1114 "option_subnet_id, "
1115 "option_user_context, "
1118 "WHERE host_ipv4_subnet_id = ? "
1119 "AND TOKEN(key) > TOKEN(?) "
1124 {GET_HOST_BY_IPV4_SUBNET_ID_PAGE,
1125 {GET_HOST_BY_IPV4_SUBNET_ID_PAGE,
1130 "host_identifier_type, "
1131 "host_ipv4_subnet_id, "
1132 "host_ipv6_subnet_id, "
1133 "host_ipv4_address, "
1134 "host_ipv4_next_server, "
1135 "host_ipv4_server_hostname, "
1136 "host_ipv4_boot_file_name, "
1140 "host_ipv4_client_classes, "
1141 "host_ipv6_client_classes, "
1142 "reserved_ipv6_prefix_address, "
1143 "reserved_ipv6_prefix_length, "
1144 "reserved_ipv6_prefix_address_type, "
1149 "option_formatted_value, "
1151 "option_is_persistent, "
1152 "option_client_class, "
1153 "option_subnet_id, "
1154 "option_user_context, "
1157 "WHERE host_ipv4_subnet_id = ? "
1163 {GET_HOST_BY_IPV6_SUBNET_ID_LIMIT,
1164 {GET_HOST_BY_IPV6_SUBNET_ID_LIMIT,
1169 "host_identifier_type, "
1170 "host_ipv4_subnet_id, "
1171 "host_ipv6_subnet_id, "
1172 "host_ipv4_address, "
1173 "host_ipv4_next_server, "
1174 "host_ipv4_server_hostname, "
1175 "host_ipv4_boot_file_name, "
1179 "host_ipv4_client_classes, "
1180 "host_ipv6_client_classes, "
1181 "reserved_ipv6_prefix_address, "
1182 "reserved_ipv6_prefix_length, "
1183 "reserved_ipv6_prefix_address_type, "
1188 "option_formatted_value, "
1190 "option_is_persistent, "
1191 "option_client_class, "
1192 "option_subnet_id, "
1193 "option_user_context, "
1196 "WHERE host_ipv6_subnet_id = ? "
1201 {GET_HOST_BY_IPV6_SUBNET_ID_NEXT_KEY,
1202 {GET_HOST_BY_IPV6_SUBNET_ID_NEXT_KEY,
1207 "host_identifier_type, "
1208 "host_ipv4_subnet_id, "
1209 "host_ipv6_subnet_id, "
1210 "host_ipv4_address, "
1211 "host_ipv4_next_server, "
1212 "host_ipv4_server_hostname, "
1213 "host_ipv4_boot_file_name, "
1217 "host_ipv4_client_classes, "
1218 "host_ipv6_client_classes, "
1219 "reserved_ipv6_prefix_address, "
1220 "reserved_ipv6_prefix_length, "
1221 "reserved_ipv6_prefix_address_type, "
1226 "option_formatted_value, "
1228 "option_is_persistent, "
1229 "option_client_class, "
1230 "option_subnet_id, "
1231 "option_user_context, "
1234 "WHERE host_ipv6_subnet_id = ? "
1235 "AND TOKEN(key) > TOKEN(?) "
1240 {GET_HOST_BY_IPV6_SUBNET_ID_PAGE,
1241 {GET_HOST_BY_IPV6_SUBNET_ID_PAGE,
1246 "host_identifier_type, "
1247 "host_ipv4_subnet_id, "
1248 "host_ipv6_subnet_id, "
1249 "host_ipv4_address, "
1250 "host_ipv4_next_server, "
1251 "host_ipv4_server_hostname, "
1252 "host_ipv4_boot_file_name, "
1256 "host_ipv4_client_classes, "
1257 "host_ipv6_client_classes, "
1258 "reserved_ipv6_prefix_address, "
1259 "reserved_ipv6_prefix_length, "
1260 "reserved_ipv6_prefix_address_type, "
1265 "option_formatted_value, "
1267 "option_is_persistent, "
1268 "option_client_class, "
1269 "option_subnet_id, "
1270 "option_user_context, "
1273 "WHERE host_ipv6_subnet_id = ? "
1285 "host_identifier_type, "
1286 "host_ipv4_subnet_id, "
1287 "host_ipv6_subnet_id, "
1288 "host_ipv4_address, "
1289 "host_ipv4_next_server, "
1290 "host_ipv4_server_hostname, "
1291 "host_ipv4_boot_file_name, "
1295 "host_ipv4_client_classes, "
1296 "host_ipv6_client_classes, "
1297 "reserved_ipv6_prefix_address, "
1298 "reserved_ipv6_prefix_length, "
1299 "reserved_ipv6_prefix_address_type, "
1304 "option_formatted_value, "
1306 "option_is_persistent, "
1307 "option_client_class, "
1308 "option_subnet_id, "
1309 "option_user_context, "
1322 "host_identifier_type, "
1323 "host_ipv4_subnet_id, "
1324 "host_ipv6_subnet_id, "
1325 "host_ipv4_address, "
1326 "host_ipv4_next_server, "
1327 "host_ipv4_server_hostname, "
1328 "host_ipv4_boot_file_name, "
1332 "host_ipv4_client_classes, "
1333 "host_ipv6_client_classes, "
1334 "reserved_ipv6_prefix_address, "
1335 "reserved_ipv6_prefix_length, "
1336 "reserved_ipv6_prefix_address_type, "
1341 "option_formatted_value, "
1343 "option_is_persistent, "
1344 "option_client_class, "
1345 "option_subnet_id, "
1346 "option_user_context, "
1349 "WHERE TOKEN(key) > TOKEN(?) "
1360 "host_identifier_type, "
1361 "host_ipv4_subnet_id, "
1362 "host_ipv6_subnet_id, "
1363 "host_ipv4_address, "
1364 "host_ipv4_next_server, "
1365 "host_ipv4_server_hostname, "
1366 "host_ipv4_boot_file_name, "
1370 "host_ipv4_client_classes, "
1371 "host_ipv6_client_classes, "
1372 "reserved_ipv6_prefix_address, "
1373 "reserved_ipv6_prefix_length, "
1374 "reserved_ipv6_prefix_address_type, "
1379 "option_formatted_value, "
1381 "option_is_persistent, "
1382 "option_client_class, "
1383 "option_subnet_id, "
1384 "option_user_context, "
1397 "host_identifier_type, "
1398 "host_ipv4_subnet_id, "
1399 "host_ipv6_subnet_id, "
1400 "host_ipv4_address, "
1401 "host_ipv4_next_server, "
1402 "host_ipv4_server_hostname, "
1403 "host_ipv4_boot_file_name, "
1407 "host_ipv4_client_classes, "
1408 "host_ipv6_client_classes, "
1409 "reserved_ipv6_prefix_address, "
1410 "reserved_ipv6_prefix_length, "
1411 "reserved_ipv6_prefix_address_type, "
1416 "option_formatted_value, "
1418 "option_is_persistent, "
1419 "option_client_class, "
1420 "option_subnet_id, "
1421 "option_user_context, "
1431 "DELETE FROM hosts WHERE key = ? AND id = ? "
1436 CqlHostExchange::CqlHostExchange()
1437 : host_(NULL), id_(0), host_identifier_type_(0), host_ipv4_subnet_id_(0),
1438 host_ipv6_subnet_id_(0), host_ipv4_address_(0), host_ipv4_next_server_(0),
1439 host_ipv4_server_hostname_(NULL_DHCP4_SERVER_HOSTNAME),
1440 host_ipv4_boot_file_name_(NULL_DHCP4_BOOT_FILE_NAME),
1442 user_context_(NULL_USER_CONTEXT),
1443 reserved_ipv6_prefix_length_(NULL_RESERVED_IPV6_PREFIX_LENGTH),
1444 reserved_ipv6_prefix_address_type_(NULL_RESERVED_IPV6_PREFIX_ADDRESS_TYPE),
1445 iaid_(NULL_IAID), option_universe_(NULL_OPTION_UNIVERSE),
1446 option_code_(NULL_OPTION_CODE),
1447 option_is_persistent_(NULL_OPTION_IS_PERSISTENT),
1448 option_subnet_id_(NULL_OPTION_SUBNET_ID),
1449 option_user_context_(NULL_OPTION_USER_CONTEXT),
1450 option_scope_id_(NULL_OPTION_SCOPE_ID) {
1466 data.
add(&host_identifier_);
1468 data.
add(&host_identifier_type_);
1470 data.
add(&host_ipv4_subnet_id_);
1472 data.
add(&host_ipv6_subnet_id_);
1474 data.
add(&host_ipv4_address_);
1476 data.
add(&host_ipv4_next_server_);
1478 data.
add(&host_ipv4_server_hostname_);
1480 data.
add(&host_ipv4_boot_file_name_);
1482 data.
add(&auth_key_);
1484 data.
add(&hostname_);
1486 data.
add(&user_context_);
1488 data.
add(&host_ipv4_client_classes_);
1490 data.
add(&host_ipv6_client_classes_);
1494 data.
add(&reserved_ipv6_prefix_address_);
1496 data.
add(&reserved_ipv6_prefix_length_);
1498 data.
add(&reserved_ipv6_prefix_address_type_);
1505 data.
add(&option_universe_);
1507 data.
add(&option_code_);
1509 data.
add(&option_value_);
1511 data.
add(&option_formatted_value_);
1513 data.
add(&option_space_);
1515 data.
add(&option_is_persistent_);
1517 data.
add(&option_client_class_);
1519 data.
add(&option_subnet_id_);
1521 data.
add(&option_user_context_);
1523 data.
add(&option_scope_id_);
1531 const std::string& option_space,
1543 HostIdentifier host_identifier = host->getIdentifier();
1544 host_identifier_ =
CassBlob(host_identifier.begin(), host_identifier.end());
1547 << host_identifier_.data() <<
" of length " << host_identifier_.size()
1552 host_identifier_type_ =
static_cast<cass_int32_t
>(host->getIdentifierType());
1553 if (host_identifier_type_ > MAX_IDENTIFIER_TYPE) {
1555 "host identifier type returned: " << host_identifier_type_);
1559 host_ipv4_subnet_id_ =
static_cast<cass_int32_t
>(host->getIPv4SubnetID());
1562 host_ipv6_subnet_id_ =
static_cast<cass_int32_t
>(host->getIPv6SubnetID());
1565 host_ipv4_address_ =
static_cast<cass_int32_t
>(host->getIPv4Reservation().toUint32());
1568 host_ipv4_next_server_ =
static_cast<cass_int32_t
>(host->getNextServer().toUint32());
1571 host_ipv4_server_hostname_ = host->getServerHostname();
1574 host_ipv4_boot_file_name_ = host->getBootFileName();
1577 auth_key_ = host->getKey().toText();
1580 hostname_ = host->getHostname();
1581 if (hostname_.size() > HOSTNAME_MAX_LEN) {
1583 << hostname_ <<
" of length " << hostname_.size()
1584 <<
" is greater than allowed of " << HOSTNAME_MAX_LEN);
1588 lower_case_hostname_ = host->getLowerHostname();
1589 if (lower_case_hostname_.size() > HOSTNAME_MAX_LEN) {
1592 "case hostname " << lower_case_hostname_ <<
" of length "
1593 << lower_case_hostname_.size()
1594 <<
" is greater than allowed of " << HOSTNAME_MAX_LEN);
1600 user_context_ = ctx->str();
1602 user_context_ = NULL_USER_CONTEXT;
1606 host_ipv4_client_classes_ = host->getClientClasses4().toText(
",");
1609 "IPv4 client classes " << host_ipv4_client_classes_ <<
" of length "
1610 << host_ipv4_client_classes_.size() <<
" is greater than allowed of "
1615 host_ipv6_client_classes_ = host->getClientClasses6().toText(
",");
1618 "IPv6 client classes " << host_ipv6_client_classes_ <<
" of length "
1619 << host_ipv6_client_classes_.size() <<
" is greater than allowed of "
1623 if (reservation == NULL) {
1625 reserved_ipv6_prefix_address_ = NULL_RESERVED_IPV6_PREFIX_ADDRESS;
1627 reserved_ipv6_prefix_length_ = NULL_RESERVED_IPV6_PREFIX_LENGTH;
1629 reserved_ipv6_prefix_address_type_ = NULL_RESERVED_IPV6_PREFIX_ADDRESS_TYPE;
1636 reserved_ipv6_prefix_length_ =
static_cast<cass_int32_t
>(reservation->
getPrefixLen());
1639 reserved_ipv6_prefix_address_type_ =
1647 if (option_descriptor.
option_ == NULL) {
1648 option_universe_ = NULL_OPTION_UNIVERSE;
1649 option_code_ = NULL_OPTION_CODE;
1650 option_value_ = NULL_OPTION_VALUE;
1651 option_formatted_value_ = NULL_OPTION_FORMATTED_VALUE;
1652 option_space_ = NULL_OPTION_SPACE;
1653 option_is_persistent_ = NULL_OPTION_IS_PERSISTENT;
1654 option_client_class_ = NULL_OPTION_CLIENT_CLASS;
1655 option_subnet_id_ = NULL_OPTION_SUBNET_ID;
1656 option_user_context_ = NULL_OPTION_USER_CONTEXT;
1657 option_scope_id_ = NULL_OPTION_SCOPE_ID;
1660 option_universe_ = option_descriptor.
option_->getUniverse();
1663 option_code_ = option_descriptor.
option_->getType();
1668 if (option_descriptor.
option_->len() >
1669 option_descriptor.
option_->getHeaderLen()) {
1675 option_descriptor.
option_->pack(buffer);
1676 const char* buffer_ptr =
static_cast<const char*
>(buffer.getData());
1677 option_value_.assign(buffer_ptr + option_descriptor.
option_->getHeaderLen(),
1678 buffer_ptr + buffer.getLength());
1680 option_value_.clear();
1682 option_formatted_value_.clear();
1684 option_value_.clear();
1689 option_space_ = option_space;
1692 option_is_persistent_ = option_descriptor.
persistent_ ? cass_true : cass_false;
1696 option_client_class_.clear();
1700 option_subnet_id_ = subnet_id;
1702 option_subnet_id_ = 0;
1708 option_user_context_ = ctx->str();
1710 option_user_context_ = NULL_OPTION_USER_CONTEXT;
1715 option_scope_id_ = 3;
1719 id_ =
static_cast<cass_int64_t
>(
hashIntoId());
1725 "CqlHostExchange::prepareExchange(): "
1726 "could not copy data from host "
1727 << host->getHostname() <<
", reason: " << ex.
what());
1735 const std::string& option_space,
1738 prepareExchange(host, subnet_id, reservation, option_space, option_descriptor);
1744 if (statement_tag == CqlHostExchange::INSERT_HOST) {
1747 data.
add(&host_identifier_);
1748 data.
add(&host_identifier_type_);
1749 data.
add(&host_ipv4_subnet_id_);
1750 data.
add(&host_ipv6_subnet_id_);
1751 data.
add(&host_ipv4_address_);
1752 data.
add(&host_ipv4_next_server_);
1753 data.
add(&host_ipv4_server_hostname_);
1754 data.
add(&host_ipv4_boot_file_name_);
1755 data.
add(&auth_key_);
1756 data.
add(&hostname_);
1757 data.
add(&lower_case_hostname_);
1758 data.
add(&user_context_);
1759 data.
add(&host_ipv4_client_classes_);
1760 data.
add(&host_ipv6_client_classes_);
1764 data.
add(&reserved_ipv6_prefix_address_);
1765 data.
add(&reserved_ipv6_prefix_length_);
1766 data.
add(&reserved_ipv6_prefix_address_type_);
1770 data.
add(&option_universe_);
1771 data.
add(&option_code_);
1772 data.
add(&option_value_);
1773 data.
add(&option_formatted_value_);
1774 data.
add(&option_space_);
1775 data.
add(&option_is_persistent_);
1776 data.
add(&option_client_class_);
1777 data.
add(&option_subnet_id_);
1778 data.
add(&option_user_context_);
1779 data.
add(&option_scope_id_);
1783 "CqlHostExchange::createBindForMutation(): "
1784 "could not create bind array from host "
1785 << host->getHostname() <<
", reason: " << ex.
what());
1793 const std::string& option_space,
1796 prepareExchange(host, subnet_id, reservation, option_space, option_descriptor);
1802 if (statement_tag == CqlHostExchange::DELETE_HOST) {
1809 "CqlHostExchange::createBindForDelete(): "
1810 "could not create bind array from host "
1811 << host->getHostname() <<
", reason: " << ex.
what());
1821 std::stringstream key_stream;
1823 key_stream << std::setw(V6ADDRESS_TEXT_MAX_LEN) << std::setfill(
'-')
1824 << reserved_ipv6_prefix_address_;
1825 key_stream << std::setw(4) << std::setfill(
'-')
1826 << reserved_ipv6_prefix_length_;
1827 key_stream << std::setw(4) << std::setfill(
'-') << option_code_;
1830 const std::string key = key_stream.str();
1832 return (Hash64::hash(key));
1837 const std::string key =
hostKey();
1839 return (Hash64::hash(key));
1847 std::stringstream key_stream;
1848 if (host_ipv4_address_) {
1851 key_stream << std::setw(10) << std::setfill(
'-') <<
"-";
1855 key_stream << std::setw(10) << std::setfill(
'-') << host_identifier_type_;
1857 key_stream << std::setw(10) << std::setfill(
'-') << host_ipv4_subnet_id_;
1858 key_stream << std::setw(10) << std::setfill(
'-') << host_ipv6_subnet_id_;
1859 key_stream << std::setw(V4ADDRESS_TEXT_MAX_LEN) << std::setfill(
'-')
1860 << host_ipv4_address_;
1861 return key_stream.str();
1866 const uint64_t
id =
static_cast<uint64_t
>(id_);
1868 HostIdentifier host_identifier =
1869 HostIdentifier(host_identifier_.begin(), host_identifier_.end());
1886 Host* host =
new Host(host_identifier.data(), host_identifier.size(),
1887 host_identifier_type, ipv4_subnet_id, ipv6_subnet_id,
1888 ipv4_reservation, hostname_,
1889 host_ipv4_client_classes_, host_ipv6_client_classes_,
1890 static_cast<uint32_t
>(host_ipv4_next_server_),
1891 host_ipv4_server_hostname_, host_ipv4_boot_file_name_,
1895 if (!user_context_.empty()) {
1898 if (!ctx || (ctx->getType() != Element::map)) {
1900 <<
"' is not a JSON map");
1905 <<
"' is invalid JSON: " << ex.
what());
1912 if (reservation != NULL_IPV6_RESERVATION &&
1918 if (option_wrapper.option_descriptor_) {
1919 if (option_wrapper.option_descriptor_->option_->getUniverse() ==
Option::V4) {
1920 host->
getCfgOption4()->add(*option_wrapper.option_descriptor_,
1921 option_wrapper.option_space_);
1922 }
else if (option_wrapper.option_descriptor_->option_->getUniverse() ==
Option::V6) {
1923 host->
getCfgOption6()->add(*option_wrapper.option_descriptor_,
1924 option_wrapper.option_space_);
1935 switch (reserved_ipv6_prefix_address_type_) {
1942 case NULL_RESERVED_IPV6_PREFIX_ADDRESS_TYPE:
1943 return (NULL_IPV6_RESERVATION);
1946 "reservation type returned: " << reserved_ipv6_prefix_address_type_
1947 <<
". Only 0 (IA_NA) or 2 (IA_PD) are allowed.");
1951 reserved_ipv6_prefix_length_));
1965 if (option_space_.empty() || option_universe_ == NULL_OPTION_UNIVERSE) {
1977 if (vendor_id > 0) {
1979 static_cast<Option::Universe>(option_universe_), vendor_id,
1986 if (!option_definition_ptr) {
1987 option_definition_ptr =
1992 if (!option_definition_ptr) {
1994 OptionBuffer option_buffer(option_value_.begin(), option_value_.end());
1995 option = boost::make_shared<Option>(
static_cast<Option::Universe>(option_universe_),
1996 static_cast<uint16_t>(option_code_),
1997 option_buffer.begin(), option_buffer.end());
2005 if (option_formatted_value_.empty()) {
2007 option_value_.end());
2008 option = option_definition_ptr->optionFactory(
2009 static_cast<Option::Universe>(option_universe_),
2010 static_cast<uint16_t>(option_code_), option_buffer.begin(),
2011 option_buffer.end());
2015 std::vector<std::string> split_vector;
2016 boost::split(split_vector, option_formatted_value_,
2017 boost::is_any_of(
","));
2018 option = option_definition_ptr->optionFactory(
2019 static_cast<Option::Universe>(option_universe_),
2020 static_cast<uint16_t>(option_code_), split_vector);
2024 OptionWrapper result(boost::make_shared<OptionDescriptor>(option, option_is_persistent_,
2025 option_formatted_value_),
2028 if (!option_user_context_.empty()) {
2031 if (!ctx || (ctx->getType() != Element::map)) {
2033 <<
"' is no a JSON map");
2035 result.option_descriptor_->setContext(ctx);
2038 <<
"' is invalid JSON: " << ex.
what());
2087 const uint8_t* identifier_begin,
2088 const size_t identifier_len)
const;
2097 const uint8_t prefix_len)
const;
2109 const uint8_t* identifier_begin,
2110 const size_t identifier_len)
const;
2130 const uint8_t* identifier_begin,
2131 const size_t identifier_len)
const;
2183 uint64_t lower_host_id,
2196 uint64_t lower_host_id,
2236 virtual std::string
getName()
const;
2254 const IPv6Resrv*
const reservation = NULL,
2255 const std::list<std::string>& option_spaces = std::list<std::string>(),
2275 const std::list<std::string>& option_spaces4,
2277 const std::list<std::string>& option_spaces6,
2315 uint64_t lower_host_id,
2316 size_t count = 0)
const;
2327 uint64_t lower_host_id,
2328 size_t count = 0)
const;
2338 size_t count = 0)
const;
2348 size_t count = 0)
const;
2370 uint64_t lower_host_id,
2371 uint64_t& key)
const;
2386 uint64_t lower_host_id,
2387 uint64_t& key)
const;
2400 virtual bool getHostKey(uint64_t lower_host_id,
2401 uint64_t& key)
const;
2411 uint64_t& key)
const;
2421 uint64_t& key)
const;
2448 const IPv6Resrv*
const reservation = NULL,
2449 const std::string& option_space = NULL_OPTION_SPACE,
2482 std::stringstream key_stream;
2483 HostIdentifier host_identifier = std::get<HOST_IDENTIFIER>(key);
2484 key_stream <<
DUID(host_identifier).
toText() <<
"-";
2485 key_stream << std::get<HOST_IDENTIFIER_TYPE>(key) <<
"-";
2486 key_stream << std::get<IPv4_SUBNET_ID>(key) <<
"-";
2487 key_stream << std::get<IPv6_SUBNET_ID>(key) <<
"-";
2488 key_stream << std::get<IPv4_RESERVATION>(key);
2489 const std::string key_string = key_stream.str();
2491 const uint64_t hash = Hash64::hash(key_string);
2493 return (static_cast<std::size_t>(hash));
2504 return (std::get<HOST_IDENTIFIER>(key1) == std::get<HOST_IDENTIFIER>(key2) &&
2505 std::get<HOST_IDENTIFIER_TYPE>(key1) ==
2506 std::get<HOST_IDENTIFIER_TYPE>(key2) &&
2507 std::get<IPv4_SUBNET_ID>(key1) == std::get<IPv4_SUBNET_ID>(key2) &&
2508 std::get<IPv6_SUBNET_ID>(key1) == std::get<IPv6_SUBNET_ID>(key2) &&
2509 std::get<IPv4_RESERVATION>(key1) == std::get<IPv4_RESERVATION>(key2));
2513 : parameters_(parameters), dbconn_(parameters) {
2517 std::pair<uint32_t, uint32_t> db_version =
getVersion();
2518 if (code_version != db_version) {
2520 << code_version.first <<
"." << code_version.second
2521 <<
" found version: " << db_version.first <<
"."
2522 << db_version.second);
2549 std::list<std::string> option_spaces4 = cfg_option4->getOptionSpaceNames();
2550 std::list<std::string> vendor_spaces4 = cfg_option4->getVendorIdsSpaceNames();
2551 option_spaces4.insert(option_spaces4.end(), vendor_spaces4.begin(),
2552 vendor_spaces4.end());
2556 std::list<std::string> option_spaces6 = cfg_option6->getOptionSpaceNames();
2557 std::list<std::string> vendor_spaces6 = cfg_option6->getVendorIdsSpaceNames();
2558 option_spaces6.insert(option_spaces6.end(), vendor_spaces6.begin(),
2559 vendor_spaces6.end());
2566 if (std::distance(reservations.first, reservations.second) > 0) {
2567 for (
IPv6ResrvIterator it = reservations.first; result && it != reservations.second; ++it) {
2569 option_spaces6, cfg_option6);
2575 option_spaces6, cfg_option6);
2583 if (!address.
isV4()) {
2585 "address supplied is not an IPv4 address");
2589 cass_int32_t host_ipv4_subnet_id =
static_cast<cass_int32_t
>(subnet_id);
2590 cass_int32_t host_ipv4_address =
static_cast<cass_int32_t
>(address.
toUint32());
2594 where_values.
add(&host_ipv4_subnet_id);
2595 where_values.
add(&host_ipv4_address);
2607 const uint8_t* identifier_begin,
2608 const size_t identifier_len)
const {
2610 CassBlob host_identifier(identifier_begin, identifier_begin + identifier_len);
2611 cass_int32_t host_identifier_type =
static_cast<cass_int32_t
>(identifier_type);
2612 cass_int32_t host_ipv4_subnet_id =
static_cast<cass_int32_t
>(subnet_id);
2616 where_values.
add(&host_ipv4_subnet_id);
2617 where_values.
add(&host_identifier);
2618 where_values.
add(&host_identifier_type);
2629 const uint8_t prefix_len)
const {
2631 std::string reserved_ipv6_prefix_address = prefix.
toText();
2632 cass_int32_t reserved_ipv6_prefix_length = prefix_len;
2637 where_values.
add(&reserved_ipv6_prefix_address);
2638 where_values.
add(&reserved_ipv6_prefix_length);
2641 host =
getHost(CqlHostExchange::GET_HOST_BY_IPV6_PREFIX, where_values);
2648 HostIdentifier host_identifier = host->getIdentifier();
2651 host_identifier.size());
2653 if (collection.empty()) {
2657 if (collection.size() >= 2u) {
2659 "CqlHostDataSource::get6(2): multiple records were "
2661 "database where only one was expected for statement "
2662 << CqlHostExchange::GET_HOST_BY_IPV6_PREFIX);
2673 const uint8_t* identifier_begin,
2674 const size_t identifier_len)
const {
2676 cass_int32_t host_ipv6_subnet_id =
static_cast<cass_int32_t
>(subnet_id);
2677 CassBlob host_identifier(identifier_begin, identifier_begin + identifier_len);
2678 cass_int32_t host_identifier_type =
static_cast<cass_int32_t
>(identifier_type);
2682 where_values.
add(&host_ipv6_subnet_id);
2683 where_values.
add(&host_identifier);
2684 where_values.
add(&host_identifier_type);
2696 cass_int32_t host_ipv6_subnet_id =
static_cast<cass_int32_t
>(subnet_id);
2697 std::string reserved_ipv6_prefix_address = address.
toText();
2701 where_values.
add(&host_ipv6_subnet_id);
2702 where_values.
add(&reserved_ipv6_prefix_address);
2713 const uint8_t* identifier_begin,
2714 const size_t identifier_len)
const {
2716 CassBlob host_identifier(identifier_begin, identifier_begin + identifier_len);
2717 cass_int32_t host_identifier_type =
static_cast<cass_int32_t
>(identifier_type);
2721 where_values.
add(&host_identifier);
2722 where_values.
add(&host_identifier_type);
2734 cass_int32_t host_ipv4_subnet_id =
static_cast<cass_int32_t
>(subnet_id);
2738 where_values.
add(&host_ipv4_subnet_id);
2751 cass_int32_t host_ipv6_subnet_id =
static_cast<cass_int32_t
>(subnet_id);
2755 where_values.
add(&host_ipv6_subnet_id);
2768 std::string hostname_ = hostname;
2772 where_values.
add(&hostname_);
2786 std::string hostname_ = hostname;
2787 cass_int32_t host_ipv4_subnet_id =
static_cast<cass_int32_t
>(subnet_id);
2791 where_values.
add(&hostname_);
2792 where_values.
add(&host_ipv4_subnet_id);
2806 std::string hostname_ = hostname;
2807 cass_int32_t host_ipv6_subnet_id =
static_cast<cass_int32_t
>(subnet_id);
2811 where_values.
add(&hostname_);
2812 where_values.
add(&host_ipv6_subnet_id);
2831 uint64_t lower_host_id,
2842 uint64_t lower_host_id,
2874 cass_int32_t host_ipv4_address =
static_cast<cass_int32_t
>(address.
toUint32());
2878 where_values.
add(&host_ipv4_address);
2919 const std::list<std::string>& option_spaces,
2930 bool option_found =
false;
2931 for (
const std::string& space : option_spaces) {
2936 if (options && !options->empty()) {
2941 option_found =
true;
2948 if (result && !option_found) {
2960 const std::list<std::string>& option_spaces4,
2962 const std::list<std::string>& option_spaces6,
2973 if (result && cfg_option4 && !cfg_option4->empty()) {
2976 if (result && cfg_option6 && !cfg_option6->empty()) {
2980 (!cfg_option4 || cfg_option4->empty()) &&
2981 (!cfg_option6 || cfg_option6->empty())) {
2993 if (collection.empty()) {
2997 if (collection.size() >= 2u) {
2999 "found in the database where only one was expected for statement "
3003 return (*collection.begin());
3010 std::unique_ptr<CqlHostExchange> host_exchange(
new CqlHostExchange());
3012 statement_tag,
false);
3016 for (boost::any& host : collection) {
3017 host_collection.push_back(
HostPtr(boost::any_cast<Host*>(host)));
3022 for (
HostPtr& host : host_collection) {
3023 HostKey key = HostKey(host->getIdentifier(), host->getIdentifierType(),
3024 host->getIPv4SubnetID(), host->getIPv6SubnetID(),
3025 host->getIPv4Reservation());
3026 if (map.find(key) == map.end()) {
3035 for (
HostPtr& host : host_collection) {
3036 HostKey key = HostKey(host->getIdentifier(), host->getIdentifierType(),
3037 host->getIPv4SubnetID(), host->getIPv6SubnetID(),
3038 host->getIPv4Reservation());
3039 if (map.find(key) != map.end()) {
3040 result_collection.push_back(map[key]);
3044 return (result_collection);
3051 cass_int64_t key_data =
static_cast<cass_int64_t
>(key);
3052 where_values.
add(&key_data);
3059 if (collection.empty()) {
3063 if (collection.size() >= 2u) {
3065 "found in the database where only one was expected for statement "
3066 << CqlHostExchange::GET_HOST_KEY);
3069 return (*collection.begin());
3074 uint64_t lower_host_id,
3075 size_t count)
const {
3077 for (; count; count--) {
3079 bool valid_key =
getHostKey4(subnet_id, lower_host_id, key);
3086 result_collection.push_back(host);
3087 lower_host_id = host->getHostId();
3090 return (result_collection);
3095 uint64_t lower_host_id,
3096 size_t count)
const {
3098 for (; count; count--) {
3100 bool valid_key =
getHostKey6(subnet_id, lower_host_id, key);
3107 result_collection.push_back(host);
3108 lower_host_id = host->getHostId();
3111 return (result_collection);
3116 size_t count)
const {
3118 for (; count; count--) {
3120 bool valid_key =
getHostKey(lower_host_id, key);
3127 result_collection.push_back(host);
3128 lower_host_id = host->getHostId();
3131 return (result_collection);
3136 size_t count)
const {
3138 for (; count; count--) {
3140 bool valid_key =
getHostKey(lower_host_id, key);
3147 result_collection.push_back(host);
3148 lower_host_id = host->getHostId();
3151 return (result_collection);
3156 uint64_t lower_host_id,
3157 uint64_t& key)
const {
3159 cass_int32_t host_subnet_id =
static_cast<cass_int32_t
>(subnet_id);
3163 where_values.
add(&host_subnet_id);
3165 cass_int64_t host_data = 0;
3166 if (lower_host_id) {
3167 host_data =
static_cast<cass_int64_t
>(lower_host_id);
3168 where_values.
add(&host_data);
3174 std::unique_ptr<CqlHostExchange> host_exchange(
new CqlHostExchange());
3176 if (lower_host_id) {
3177 collection = host_exchange->
executeSelect(dbconn_, where_values,
3178 CqlHostExchange::GET_HOST_BY_IPV4_SUBNET_ID_PAGE,
false);
3180 collection = host_exchange->
executeSelect(dbconn_, where_values,
3181 CqlHostExchange::GET_HOST_BY_IPV4_SUBNET_ID_LIMIT,
false);
3186 for (boost::any& host : collection) {
3187 host_collection.push_back(
HostPtr(boost::any_cast<Host*>(host)));
3191 if (host_collection.empty()) {
3197 if (lower_host_id) {
3206 uint64_t lower_host_id,
3207 uint64_t& key)
const {
3209 cass_int32_t host_subnet_id =
static_cast<cass_int32_t
>(subnet_id);
3213 where_values.
add(&host_subnet_id);
3215 cass_int64_t host_data = 0;
3216 if (lower_host_id) {
3217 host_data =
static_cast<cass_int64_t
>(lower_host_id);
3218 where_values.
add(&host_data);
3224 std::unique_ptr<CqlHostExchange> host_exchange(
new CqlHostExchange());
3226 if (lower_host_id) {
3227 collection = host_exchange->
executeSelect(dbconn_, where_values,
3228 CqlHostExchange::GET_HOST_BY_IPV6_SUBNET_ID_PAGE,
false);
3230 collection = host_exchange->
executeSelect(dbconn_, where_values,
3231 CqlHostExchange::GET_HOST_BY_IPV6_SUBNET_ID_LIMIT,
false);
3236 for (boost::any& host : collection) {
3237 host_collection.push_back(
HostPtr(boost::any_cast<Host*>(host)));
3241 if (host_collection.empty()) {
3247 if (lower_host_id) {
3256 uint64_t& key)
const {
3259 cass_int64_t host_data = 0;
3260 if (lower_host_id) {
3261 host_data =
static_cast<cass_int64_t
>(lower_host_id);
3262 where_values.
add(&host_data);
3268 std::unique_ptr<CqlHostExchange> host_exchange(
new CqlHostExchange());
3270 if (lower_host_id) {
3271 collection = host_exchange->
executeSelect(dbconn_, where_values,
3272 CqlHostExchange::GET_HOST_PAGE,
false);
3274 collection = host_exchange->
executeSelect(dbconn_, where_values,
3275 CqlHostExchange::GET_HOST_LIMIT,
false);
3280 for (boost::any& host : collection) {
3281 host_collection.push_back(
HostPtr(boost::any_cast<Host*>(host)));
3285 if (host_collection.empty()) {
3291 if (lower_host_id) {
3300 uint64_t& key)
const {
3302 cass_int32_t host_subnet_id =
static_cast<cass_int32_t
>(subnet_id);
3303 cass_int64_t key_data =
static_cast<cass_int64_t
>(key);
3307 where_values.
add(&host_subnet_id);
3308 where_values.
add(&key_data);
3311 std::unique_ptr<CqlHostExchange> host_exchange(
new CqlHostExchange());
3313 CqlHostExchange::GET_HOST_BY_IPV4_SUBNET_ID_NEXT_KEY,
false);
3317 for (boost::any& host : collection) {
3318 host_collection.push_back(
HostPtr(boost::any_cast<Host*>(host)));
3321 if (host_collection.empty()) {
3331 uint64_t& key)
const {
3333 cass_int32_t host_subnet_id =
static_cast<cass_int32_t
>(subnet_id);
3334 cass_int64_t key_data =
static_cast<cass_int64_t
>(key);
3338 where_values.
add(&host_subnet_id);
3339 where_values.
add(&key_data);
3342 std::unique_ptr<CqlHostExchange> host_exchange(
new CqlHostExchange());
3344 CqlHostExchange::GET_HOST_BY_IPV6_SUBNET_ID_NEXT_KEY,
false);
3348 for (boost::any& host : collection) {
3349 host_collection.push_back(
HostPtr(boost::any_cast<Host*>(host)));
3352 if (host_collection.empty()) {
3363 cass_int64_t key_data =
static_cast<cass_int64_t
>(key);
3367 where_values.
add(&key_data);
3370 std::unique_ptr<CqlHostExchange> host_exchange(
new CqlHostExchange());
3372 CqlHostExchange::GET_HOST_NEXT_KEY,
false);
3376 for (boost::any& host : collection) {
3377 host_collection.push_back(
HostPtr(boost::any_cast<Host*>(host)));
3380 if (host_collection.empty()) {
3393 const std::string& option_space,
3402 std::unique_ptr<CqlHostExchange> host_exchange(
new CqlHostExchange());
3407 option_descriptor, CqlHostExchange::INSERT_HOST, assigned_values);
3409 host_exchange->
executeMutation(dbconn_, assigned_values, CqlHostExchange::INSERT_HOST);
3412 option_descriptor, CqlHostExchange::DELETE_HOST, assigned_values);
3414 host_exchange->
executeMutation(dbconn_, assigned_values, CqlHostExchange::DELETE_HOST);
3432 source_host->getIPv6Reservations();
3433 if (std::distance(reservations_range.first, reservations_range.second) > 0) {
3435 reservations_iterator != reservations_range.second;
3436 ++reservations_iterator) {
3437 if (!target_host->hasReservation(reservations_iterator->second)) {
3438 target_host->addReservation(reservations_iterator->second);
3444 source_host->getCfgOption4()->mergeTo(*target_host->getCfgOption4());
3447 source_host->getCfgOption6()->mergeTo(*target_host->getCfgOption6());
3467 HostPtr host = boost::const_pointer_cast<
Host>(impl_->
get4(subnet_id, address));
3474 const uint8_t* identifier_begin,
const size_t identifier_len) {
3475 HostPtr host = boost::const_pointer_cast<
Host>(impl_->
get4(subnet_id, identifier_type,
3476 identifier_begin, identifier_len));
3483 const uint8_t* identifier_begin,
const size_t identifier_len) {
3484 HostPtr host = boost::const_pointer_cast<
Host>(impl_->
get6(subnet_id, identifier_type,
3485 identifier_begin, identifier_len));
3492 const uint8_t* identifier_begin,
3493 const size_t identifier_len)
const {
3496 return (impl_->
getAll(identifier_type, identifier_begin, identifier_len));
3503 return (impl_->
getAll4(subnet_id));
3510 return (impl_->
getAll6(subnet_id));
3539 uint64_t lower_host_id,
3543 return (impl_->
getPage4(subnet_id, lower_host_id, page_size));
3549 uint64_t lower_host_id,
3553 return (impl_->
getPage6(subnet_id, lower_host_id, page_size));
3558 uint64_t lower_host_id,
3562 return (impl_->
getPage4(lower_host_id, page_size));
3567 uint64_t lower_host_id,
3571 return (impl_->
getPage6(lower_host_id, page_size));
3578 return (impl_->
getAll4(address));
3584 const uint8_t* identifier_begin,
3585 const size_t identifier_len)
const {
3588 return (impl_->
get4(subnet_id, identifier_type, identifier_begin,
3597 return (impl_->
get4(subnet_id, address));
3604 auto host =
get4(subnet_id, address);
3606 hosts.push_back(host);
3614 const uint8_t* identifier_begin,
3615 const size_t identifier_len)
const {
3618 return (impl_->
get6(subnet_id, identifier_type, identifier_begin, identifier_len));
3623 const uint8_t prefix_len)
const {
3626 return (impl_->
get6(prefix, prefix_len));
3634 return (impl_->
get6(subnet_id, address));
3641 auto host =
get6(subnet_id, address);
3643 hosts.push_back(host);
3655 return std::string(
"cql");
3665 return std::string(
"Host data source that stores host information in the CQL database");
Database statement not applied.
virtual bool del(const SubnetID &subnet_id, const asiolink::IOAddress &addr) override
Attempts to delete hosts by (subnet-id, address)
virtual ~CqlHostExchange()
Virtual destructor.
virtual bool del6(const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) override
Attempts to delete a host by (subnet-id6, identifier-type, identifier).
static OptionDefinitionPtr getRuntimeOptionDef(const std::string &space, const uint16_t code)
Returns runtime (non-standard) option definition by space and option code.
const isc::log::MessageID DHCPSRV_CQL_COMMIT
void unspecified(bool unspecified)
Modifies the flag that indicates whether the value is specified or unspecified.
void setContext(const data::ConstElementPtr &ctx)
Sets user context.
void executeMutation(const CqlConnection &connection, const AnyArray &assigned_values, StatementTag statement_tag)
Executes INSERT, UPDATE or DELETE statements.
uint32_t toUint32() const
Converts IPv4 address to uint32_t.
static std::pair< uint32_t, uint32_t > getVersion(const ParameterMap ¶meters)
Get the schema version.
virtual boost::any retrieve() override
Copy received data into Host object.
virtual ConstHostCollection getAll(const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const
Implementation of CqlHostDataSource::getAll()
Wraps value holding size of the page with host reservations.
virtual ConstHostCollection getAll6(const SubnetID &subnet_id) const
Implementation of CqlHostDataSource::getAll6()
virtual bool getNextHostKey4(const SubnetID &subnet_id, uint64_t &key) const
Retrieves next valid host key.
const size_t CLIENT_CLASSES_MAX_LEN
Maximum length of classes stored in a dhcp4/6_client_classes columns.
boost::shared_ptr< OptionDescriptor > OptionDescriptorPtr
A pointer to option descriptor.
Structure used to bind C++ input values to dynamic CQL parameters.
virtual ConstHostCollection getAllbyHostname(const std::string &hostname) const
Implementation of CqlHostDataSource::getAllbyHostname()
virtual std::string getName() const
Implementation of CqlHostDataSource::getName()
virtual bool insertOrDeleteHost(bool insert, const HostPtr &host, const Optional< SubnetID > &subnet_id=Optional< SubnetID >(), const IPv6Resrv *const reservation=NULL, const std::string &option_space=NULL_OPTION_SPACE, const OptionDescriptor &option_descriptor=OptionDescriptor(false))
Inserts or deletes a single host.
A standard Data module exception that is thrown if a parse error is encountered when constructing an ...
virtual ConstHostCollection getAll4(const SubnetID &subnet_id) const
Implementation of CqlHostDataSource::getAll4()
boost::shared_ptr< Host > HostPtr
Pointer to the Host object.
const IPv6Resrv retrieveReservation() const
Creates IPv6 reservation from the data contained in the currently processed row.
const asiolink::IOAddress & getPrefix() const
Returns prefix for the reservation.
boost::shared_ptr< const CfgOption > ConstCfgOptionPtr
Const pointer.
CqlHostDataSourceImpl(const DatabaseConnection::ParameterMap ¶meters)
Constructor.
virtual ConstHostPtr getHost(StatementTag statement_tag, AnyArray &where_values) const
Retrieves a single host.
const size_t page_size_
Holds page size.
boost::shared_ptr< Option > OptionPtr
virtual void createBindForSelect(AnyArray &data, StatementTag statement_tag=NULL) override
Binds member variables to data array to receive Host data.
void prepareStatements(StatementMap &statements)
Prepare statements.
Universe
defines option universe DHCPv4 or DHCPv6
virtual ConstHostCollection getAllbyHostname6(const std::string &hostname, const SubnetID &subnet_id) const
Implementation of CqlHostDataSource::getAllbyHostname6()
void openDatabase()
Open database.
virtual ConstHostCollection getAllbyHostname4(const std::string &hostname, const SubnetID &subnet_id) const override
Return all hosts with a hostname in a DHCPv4 subnet.
virtual ConstHostCollection getAll6(const SubnetID &subnet_id) const override
Return all hosts in a DHCPv6 subnet.
virtual ConstHostCollection getAllbyHostname4(const std::string &hostname, const SubnetID &subnet_id) const
Implementation of CqlHostDataSource::getAllbyHostname4()
std::vector< HostPtr > HostCollection
Collection of the Host objects.
const isc::log::MessageID DHCPSRV_CQL_HOST_GET6
virtual ConstHostPtr get4(const SubnetID &subnet_id, const asiolink::IOAddress &address) const
Implementation of CqlHostDataSource::get4()
static StatementMap tagged_statements_
Cassandra statements.
IPv6 reservation for a host.
const size_t OPTION_SPACE_MAX_LEN
Maximum length of option space name.
CfgOptionPtr getCfgOption6()
Returns pointer to the DHCPv6 option data configuration for this host.
const isc::log::MessageID DHCPSRV_CQL_HOST_GET_ALL
bool isV4() const
Convenience function to check for an IPv4 address.
virtual ConstHostCollection getPage4(const SubnetID &subnet_id, size_t &source_index, uint64_t lower_host_id, const HostPageSize &page_size) const override
Returns range of hosts in a DHCPv4 subnet.
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
Holds DUID (DHCPv6 Unique Identifier)
Exception thrown on failure to open database.
char const *const StatementTag
Statement index representing the statement name.
bool hasReservation(const IPv6Resrv &reservation) const
Checks if specified IPv6 reservation exists for the host.
virtual ConstHostCollection getPage6(const SubnetID &subnet_id, uint64_t lower_host_id, const HostPageSize &page_size) const
Implementation of CqlHostDataSource::getPage6()
uint64_t hashIntoKey() const
Create unique key for storage in table key.
Multiple lease records found where one expected.
virtual ConstHostCollection getPage6(const SubnetID &subnet_id, size_t &source_index, uint64_t lower_host_id, const HostPageSize &page_size) const override
Returns range of hosts in a DHCPv6 subnet.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
std::string formatted_value_
Option value in textual (CSV) format.
virtual VersionPair getVersion() const
Implementation of CqlHostDataSource::getVersion()
virtual void mergeHosts(const ConstHostPtr &source_host, HostPtr &target_host) const
Merge denormalized table entries that belong to the same host into a single host, one by one...
void setHostId(HostID id)
Sets Host ID (primary key in MySQL, PostgreSQL and Cassandra backends)
std::pair< IPv6ResrvIterator, IPv6ResrvIterator > IPv6ResrvRange
virtual ConstHostPtr getHostByKey(uint64_t key) const
Retrieves a host by key.
virtual bool setIPReservationsUnique(const bool unique) override
Controls whether IP reservations are unique or non-unique.
const isc::log::MessageID DHCPSRV_CQL_HOST_DB_GET_VERSION
void add(const boost::any &value)
Add a value at the end of the vector.
const int DHCPSRV_DBG_TRACE_DETAIL
Additional information.
std::vector< ConstHostPtr > ConstHostCollection
Collection of the const Host objects.
std::string hostKey() const
Create unique key string for a host.
virtual ConstHostCollection getAllHosts() const
Implementation of CqlHostDataSource::getAllHosts()
bool persistent_
Persistence flag.
std::vector< cass_byte_t > CassBlob
Host identifier converted to Cassandra data type.
Implementation of the CqlHostDataSource.
virtual bool insertOrDeleteHostWithOptions(bool insert, const HostPtr &host, const IPv6Resrv *const reservation=NULL, const std::list< std::string > &option_spaces=std::list< std::string >(), const ConstCfgOptionPtr cfg_option=ConstCfgOptionPtr())
Adds/deletes any options found in the Host object to/from a separate table entry. ...
virtual void commit() override
Commit Transactions.
virtual bool getNextHostKey(uint64_t &key) const
Retrieves next valid host key.
virtual ConstHostPtr get6(const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const override
Returns a Host connected to an IPv6 subnet.
virtual bool del4(const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) override
Attempts to delete a host by (subnet-id4, identifier-type, identifier).
virtual void rollback() override
Rollback Transactions.
boost::shared_ptr< const Element > ConstElementPtr
const isc::log::MessageID DHCPSRV_CQL_HOST_ADD
boost::shared_ptr< const Host > ConstHostPtr
Const pointer to the Host object.
Provides mechanisms for sending and retrieving data from the hosts table.
void createBindForDelete(const HostPtr &host, const Optional< SubnetID > &subnet_id, const IPv6Resrv *const reservation, const std::string &option_space, const OptionDescriptor &option_descriptor, StatementTag statement_tag, AnyArray &data)
Binds Host to data array to send data to the Cassandra database.
std::pair< uint32_t, uint32_t > VersionPair
Pair containing major and minor versions.
bool operator==(const HostKey &key1, const HostKey &key2)
equals operator for HostKey
data::ConstElementPtr getContext() const
Returns const pointer to the user context.
Represents a device with IPv4 and/or IPv6 reservations.
virtual bool getHostKey6(const SubnetID &subnet_id, uint64_t lower_host_id, uint64_t &key) const
Retrieves a valid host key.
Type
Type of the reservation.
CqlHostDataSource(const db::DatabaseConnection::ParameterMap ¶meters)
Constructor.
std::string toText() const
Returns textual representation of a DUID (e.g. 00:01:02:03:ff)
void createBindForMutation(const HostPtr &host, const Optional< SubnetID > &subnet_id, const IPv6Resrv *const reservation, const std::string &option_space, const OptionDescriptor &option_descriptor, StatementTag statement_tag, AnyArray &data)
Binds Host to data array to send data to the Cassandra database.
static OptionDefinitionPtr getOptionDef(const std::string &space, const uint16_t code)
Return the first option definition matching a particular option code.
IPv6ResrvCollection::const_iterator IPv6ResrvIterator
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
virtual bool insertOrDeleteHostWithReservations(bool insert, const HostPtr &host, const IPv6Resrv *const reservation, const std::list< std::string > &option_spaces4, const ConstCfgOptionPtr cfg_option4, const std::list< std::string > &option_spaces6, const ConstCfgOptionPtr cfg_option6)
Adds/deletes any reservations found in the Host object to/from a separate table entry.
OptionPtr option_
Option instance.
virtual void add(const HostPtr &host) override
Adds a new host to the collection.
const isc::log::MessageID DHCPSRV_CQL_ROLLBACK
virtual ConstHostCollection getPage4(const SubnetID &subnet_id, uint64_t lower_host_id, const HostPageSize &page_size) const
Implementation of CqlHostDataSource::getPage4()
uint64_t hashIntoId() const
Create unique hash for storage in table id.
This is a base class for exceptions thrown from the DNS library module.
virtual std::string getName() const
Returns the name of the database.
constexpr uint32_t CQL_SCHEMA_VERSION_MAJOR
Define CQL schema version: 5.0.
Defines the logger used by the top-level component of kea-dhcp-ddns.
virtual ConstHostCollection getAll(const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const override
Return all hosts connected to any subnet for which reservations have been made using a specified iden...
std::string getParameter(const std::string &name) const
Returns value of a connection parameter.
static const size_t MAX_DUID_LEN
maximum duid size As defined in RFC 8415, section 11.1
const isc::log::MessageID DHCPSRV_CQL_HOST_GET4
virtual bool getNextHostKey6(const SubnetID &subnet_id, uint64_t &key) const
Retrieves next valid host key.
virtual db::VersionPair getVersion() const
Retrieves schema version from the DB.
void addReservation(const IPv6Resrv &reservation)
Adds new IPv6 reservation.
Type getType() const
Returns reservation type.
#define DHCP6_OPTION_SPACE
std::unordered_map< StatementTag, CqlTaggedStatement, StatementTagHash, StatementTagEqual > StatementMap
A container for all statements.
virtual bool getHostKey(uint64_t lower_host_id, uint64_t &key) const
Retrieves a valid host key.
AnyArray executeSelect(const CqlConnection &connection, const AnyArray &where_values, StatementTag statement_tag, const bool &single=false)
Executes SELECT statements.
#define DHCP4_OPTION_SPACE
global std option spaces
constexpr uint32_t CQL_SCHEMA_VERSION_MINOR
virtual ~CqlHostDataSourceImpl()
Destructor.
boost::shared_ptr< OptionContainer > OptionContainerPtr
Pointer to the OptionContainer object.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
virtual std::string getDescription() const
Returns textual description of the backend.
std::string toText() const
Convert the address to a string.
virtual ConstHostCollection getHostCollectionPage6(const SubnetID &subnet_id, uint64_t lower_host_id, size_t count=0) const
Retrieves a page of hosts.
virtual ConstHostCollection getAllbyHostname6(const std::string &hostname, const SubnetID &subnet_id) const override
Return all hosts with a hostname in a DHCPv6 subnet.
virtual ConstHostCollection getHostCollection(StatementTag statement_tag, AnyArray &where_values) const
Retrieves a collection of hosts.
boost::shared_ptr< OptionDefinition > OptionDefinitionPtr
Pointer to option definition object.
virtual bool insertOrDelete(const HostPtr &host, bool insert)
Implementation of CqlHostDataSource::add() and del()
virtual bool getHostKey4(const SubnetID &subnet_id, uint64_t lower_host_id, uint64_t &key) const
Retrieves a valid host key.
isc::log::Logger dhcpsrv_logger("dhcpsrv")
DHCP server library Logger.
static uint32_t optionSpaceToVendorId(const std::string &option_space)
Converts option space name to vendor id.
IdentifierType
Type of the host identifier.
Common CQL connector pool.
std::map< std::string, std::string > ParameterMap
Database configuration parameter map.
uint8_t getPrefixLen() const
Returns prefix length.
HostKeyComponent
Identifies components of the host key.
The IOAddress class represents an IP addresses (version agnostic)
const OptionWrapper retrieveOption() const
Retrieves option from members.
virtual ConstHostCollection getHostCollectionPage4(const SubnetID &subnet_id, uint64_t lower_host_id, size_t count=0) const
Retrieves a page of hosts.
std::size_t hash_value(const HostKey &key)
hash function for HostMap
virtual ConstHostPtr get6(const asiolink::IOAddress &prefix, const uint8_t prefix_len) const
Retrieves a host by its reserved IPv6 address or prefix.
virtual ~CqlHostDataSource()
Virtual destructor.
A template representing an optional value.
virtual std::string getType() const override
Return backend type.
virtual ConstHostCollection getAllHosts() const
Returns a collection of all the hosts.
virtual ConstHostCollection getAllbyHostname(const std::string &hostname) const override
Return all hosts with a hostname.
Exception thrown on failure to execute a database function.
CfgOptionPtr getCfgOption4()
Returns pointer to the DHCPv4 option data configuration for this host.
Database duplicate entry error.
static OptionDefinitionPtr getVendorOptionDef(const Option::Universe u, const uint32_t vendor_id, const uint16_t code)
Returns vendor option definition for a given vendor-id and code.
uint32_t SubnetID
Unique identifier for a subnet (both v4 and v6)
virtual ConstHostCollection getAll4(const SubnetID &subnet_id) const override
Return all hosts in a DHCPv4 subnet.
void prepareExchange(const HostPtr &host, const Optional< SubnetID > &subnet_id, const IPv6Resrv *const reservation, const std::string &option_space, const OptionDescriptor &option_descriptor)
Sets the exchange members with data of Host.
virtual ConstHostPtr get4(const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const override
Retrieves a Host connected to an IPv4 subnet.