1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- #include <hooks/hooks.h>
- #include <map>
- #include <boost/foreach.hpp>
- #include "logger.h"
- #include "common.h"
- using namespace isc::hooks;
- using namespace isc::data;
- std::map<std::string, std::string> cm_map;
- std::map<std::string, std::string> option122_map;
- extern "C" {
- int loadMappging(std::string base_map_config, LibraryHandle& handle, std::map<std::string, std::string>& map){
- ConstElementPtr curr_map = handle.getParameter(base_map_config);
- if (Element::map != curr_map->getType()){
- LOG_ERROR(runscript_logger, RUNSCRIPT_MISTYPED_PARAM).arg(base_map_config);
- return 1;
- }
- std::map<std::string, ConstElementPtr> map_config = curr_map->mapValue();;
- std::pair<std::string, ConstElementPtr> me;
- BOOST_FOREACH(me, map_config) {
- std::string class_to_map = me.first;
- std::cout << me.first << "\n";
- ConstElementPtr table = me.second;
- if(table->getType() != Element::list){
- LOG_ERROR(runscript_logger, RUNSCRIPT_MISTYPED_PARAM).arg(base_map_config + "." + me.first);
- return 1;
- }
- const std::vector<ElementPtr> mac_list = table->listValue();
- for(int i = 0; i < mac_list.size(); i++) {
- ElementPtr it = mac_list[i];
- if(it->getType() != Element::string){
- LOG_ERROR(runscript_logger, RUNSCRIPT_MISTYPED_PARAM).arg(base_map_config + "." + me.first + "[" + std::to_string(i) + "]");
- return 1;
- }
- std::cout << mac_list[i]->stringValue() << "\n";
- std::string mac = mac_list[i]->stringValue();
- std::transform(mac.begin(), mac.end(),mac.begin(), ::toupper);
- map[mac] = class_to_map;
- }
- }
- return 0;
- }
- int load(LibraryHandle& handle)
- {
-
- return 0;
- }
- } // end extern "C"
|