summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/bp_sim.cpp83
-rwxr-xr-xsrc/tuple_gen.cpp90
2 files changed, 85 insertions, 88 deletions
diff --git a/src/bp_sim.cpp b/src/bp_sim.cpp
index fcefa50c..a51c20c3 100755
--- a/src/bp_sim.cpp
+++ b/src/bp_sim.cpp
@@ -2350,21 +2350,18 @@ void operator >> (const YAML::Node& node, CFlowYamlDpPkt & fi) {
void operator >> (const YAML::Node& node, CVlanYamlInfo & fi) {
uint32_t tmp;
- try {
+ if (node.FindValue("enable")) {
node["enable"] >> tmp ;
fi.m_enable=tmp;
- }catch ( const std::exception& e ) {
-
- }
+ }
- try {
+ if (node.FindValue("vlan0")) {
node["vlan0"] >> tmp;
fi.m_vlan_per_port[0] = tmp;
+ }
+ if (node.FindValue("vlan1")) {
node["vlan1"] >> tmp;
fi.m_vlan_per_port[1] = tmp;
- }catch ( const std::exception& e ) {
- // there is a default
-
}
}
@@ -2373,14 +2370,15 @@ void operator >> (const YAML::Node& node, CVlanYamlInfo & fi) {
void operator >> (const YAML::Node& node, CFlowYamlInfo & fi) {
node["name"] >> fi.m_name;
- try {
+ if (node.FindValue("client_pool")) {
node["client_pool"] >> fi.m_client_pool_name;
- } catch ( const std::exception& e ) {
+ } else {
fi.m_client_pool_name = "default";
}
- try {
+
+ if (node.FindValue("server_pool")) {
node["server_pool"] >> fi.m_server_pool_name;
- } catch ( const std::exception& e ) {
+ } else {
fi.m_server_pool_name = "default";
}
@@ -2392,35 +2390,35 @@ void operator >> (const YAML::Node& node, CFlowYamlInfo & fi) {
node["rtt"] >> t;
fi.m_rtt_sec = t/1000000.0;
node["w"] >> fi.m_w;
-
- try {
+
+ if (node.FindValue("cap_ipg")) {
node["cap_ipg"] >> fi.m_cap_mode;
fi.m_cap_mode_was_set =true;
- } catch ( const std::exception& e ) {
+ } else {
fi.m_cap_mode_was_set =false;
}
- try {
+ if (node.FindValue("wlength")) {
node["wlength"] >> fi.m_wlength;
fi.m_wlength_set=true;
- } catch ( const std::exception& e ) {
+ } else {
fi.m_wlength_set=false;
fi.m_wlength =500;
}
- try {
+ if (node.FindValue("limit")) {
node["limit"] >> fi.m_limit;
fi.m_limit_was_set = true;
- } catch ( const std::exception& e ) {
+ } else {
fi.m_limit_was_set = false;
fi.m_limit = 0;
}
- try {
+ if (node.FindValue("plugin_id")) {
uint32_t plugin_val;
node["plugin_id"] >> plugin_val;
fi.m_plugin_id=plugin_val;
- } catch ( const std::exception& e ) {
+ } else {
fi.m_plugin_id=0;
}
@@ -2429,10 +2427,10 @@ void operator >> (const YAML::Node& node, CFlowYamlInfo & fi) {
if ( utl_yaml_read_ip_addr(node,
"server_addr",
fi.m_server_addr) ){
- try {
+ if (node.FindValue("one_app_server")) {
node["one_app_server"] >> fi.m_one_app_server;
fi.m_one_app_server_was_set=true;
- } catch ( const std::exception& e ) {
+ } else {
fi.m_one_app_server_was_set = false;
fi.m_one_app_server = false;
}
@@ -2478,10 +2476,10 @@ void operator >> (const YAML::Node& node, CFlowsYamlInfo & flows_info) {
node["duration"] >> flows_info.m_duration_sec;
- try {
+ if (node.FindValue("generator")) {
node["generator"] >> flows_info.m_tuple_gen;
flows_info.m_tuple_gen_was_set =true;
- } catch ( const std::exception& e ) {
+ } else {
flows_info.m_tuple_gen_was_set =false;
}
@@ -2500,7 +2498,7 @@ void operator >> (const YAML::Node& node, CFlowsYamlInfo & flows_info) {
// formed by providing src_ipv6,dst_ipv6 and specifying
// {0,0,0,0,0,0xffff}
flows_info.m_ipv6_set=true;
- try {
+ if (node.FindValue("src_ipv6")) {
const YAML::Node& src_ipv6_info = node["src_ipv6"];
if (src_ipv6_info.size() == 6 ){
for(unsigned i=0;i<src_ipv6_info.size();i++) {
@@ -2512,11 +2510,11 @@ void operator >> (const YAML::Node& node, CFlowsYamlInfo & flows_info) {
}else{
flows_info.m_ipv6_set=false;
}
- } catch ( const std::exception& e ) {
+ } else {
flows_info.m_ipv6_set=false;
}
- try {
+ if (node.FindValue("dst_ipv6")) {
const YAML::Node& dst_ipv6_info = node["dst_ipv6"];
if (dst_ipv6_info.size() == 6 ){
for(unsigned i=0;i<dst_ipv6_info.size();i++) {
@@ -2528,61 +2526,60 @@ void operator >> (const YAML::Node& node, CFlowsYamlInfo & flows_info) {
}else{
flows_info.m_ipv6_set=false;
}
- } catch ( const std::exception& e ) {
+ } else {
flows_info.m_ipv6_set=false;
}
- try {
+ if (node.FindValue("cap_ipg")) {
node["cap_ipg"] >> flows_info.m_cap_mode;
flows_info.m_cap_mode_set=true;
- } catch ( const std::exception& e ) {
+ } else {
flows_info.m_cap_mode=false;
flows_info.m_cap_mode_set=false;
}
double t;
- try {
+ if (node.FindValue("cap_ipg_min")) {
node["cap_ipg_min"] >> t ;
flows_info.m_cap_ipg_min = t/1000000.0;
flows_info.m_cap_ipg_min_set=true;
- } catch ( const std::exception& e ) {
+ } else {
flows_info.m_cap_ipg_min_set=false;
flows_info.m_cap_ipg_min = 20;
}
- try {
+ if (node.FindValue("cap_override_ipg")) {
node["cap_override_ipg"] >> t;
flows_info.m_cap_overide_ipg = t/1000000.0;
flows_info.m_cap_overide_ipg_set = true;
- } catch ( const std::exception& e ) {
+ } else {
flows_info.m_cap_overide_ipg_set = false;
flows_info.m_cap_overide_ipg = 0;
}
- try {
+ if (node.FindValue("wlength")) {
node["wlength"] >> flows_info.m_wlength;
flows_info.m_wlength_set=true;
- } catch ( const std::exception& e ) {
+ } else {
flows_info.m_wlength_set=false;
flows_info.m_wlength =100;
}
- try {
+ if (node.FindValue("one_app_server")) {
node["one_app_server"] >> flows_info.m_one_app_server;
flows_info.m_one_app_server_was_set=true;
- } catch ( const std::exception& e ) {
+ } else {
flows_info.m_one_app_server =false;
flows_info.m_one_app_server_was_set=false;
}
- try {
+ if (node.FindValue("vlan")) {
node["vlan"] >> flows_info.m_vlan_info;
- } catch ( const std::exception& e ) {
}
- try {
+ if (node.FindValue("mac_override_by_ip")) {
node["mac_override_by_ip"] >> flows_info.m_mac_replace_by_ip;
- } catch ( const std::exception& e ) {
+ } else {
flows_info.m_mac_replace_by_ip =false;
}
diff --git a/src/tuple_gen.cpp b/src/tuple_gen.cpp
index 3a477338..80a25f1a 100755
--- a/src/tuple_gen.cpp
+++ b/src/tuple_gen.cpp
@@ -223,12 +223,22 @@ bool CTupleGenPoolYaml::is_valid(uint32_t num_threads,bool is_plugins){
+#define UTL_YAML_READ(type, field, target) if (node.FindValue(#field)) { \
+ utl_yaml_read_ ## type (node, #field , target); \
+ } else { printf("error in generator definition -- " #field "\n"); }
void operator >> (const YAML::Node& node, CTupleGenPoolYaml & fi) {
std::string tmp;
- node["name"] >> fi.m_name;
- node["distribution"] >> tmp ;
+ if (node.FindValue("name")) {
+ node["name"] >> fi.m_name;
+ } else {
+ printf("error in generator definition, name missing\n");
+ assert(0);
+ }
+ if (node.FindValue("distribution")) {
+ node["distribution"] >> tmp ;
+ }
if (tmp == "random") {
fi.m_dist=cdRANDOM_DIST;
}else if (tmp == "normal") {
@@ -236,39 +246,24 @@ void operator >> (const YAML::Node& node, CTupleGenPoolYaml & fi) {
} else {
fi.m_dist=cdSEQ_DIST;
}
- utl_yaml_read_ip_addr(node,"ip_start",fi.m_ip_start);
- utl_yaml_read_ip_addr(node,"ip_end",fi.m_ip_end);
- fi.m_number_of_clients_per_gb = 0;
+ UTL_YAML_READ(ip_addr, ip_start, fi.m_ip_start);
+ UTL_YAML_READ(ip_addr, ip_end, fi.m_ip_end);
+ fi.m_number_of_clients_per_gb = 0;
fi.m_min_clients = 0;
fi.m_is_bundling = false;
fi.m_tcp_aging_sec = 0;
fi.m_udp_aging_sec = 0;
fi.m_dual_interface_mask = 0;
- try {
- utl_yaml_read_uint32(node,"clients_per_gb",fi.m_number_of_clients_per_gb);
- } catch ( const std::exception& e ) {
- ;}
- try {
- utl_yaml_read_uint32(node,"min_clients",fi.m_min_clients);
- } catch ( const std::exception& e ) {
- ;}
- try {
- utl_yaml_read_ip_addr(node,"dual_port_mask",fi.m_dual_interface_mask);
- } catch ( const std::exception& e ) {
- ;}
- try {
- utl_yaml_read_uint16(node,"tcp_aging",fi.m_tcp_aging_sec);
- } catch ( const std::exception& e ) {
- ;}
- try {
- utl_yaml_read_uint16(node,"udp_aging",fi.m_udp_aging_sec);
- } catch ( const std::exception& e ) {
- ;}
- try {
+
+ UTL_YAML_READ(uint32, clients_per_gb, fi.m_number_of_clients_per_gb);
+ UTL_YAML_READ(uint32, min_clients, fi.m_min_clients);
+ UTL_YAML_READ(ip_addr, dual_port_mask, fi.m_dual_interface_mask);
+ UTL_YAML_READ(uint16, tcp_aging, fi.m_tcp_aging_sec);
+ UTL_YAML_READ(uint16, udp_aging, fi.m_udp_aging_sec);
+ if (node.FindValue("track_ports")) {
node["track_ports"] >> fi.m_is_bundling;
- } catch ( const std::exception& e ) {
- ;}
+ }
}
void copy_global_pool_para(CTupleGenPoolYaml & src, CTupleGenPoolYaml & dst) {
if (src.m_number_of_clients_per_gb == 0)
@@ -282,12 +277,15 @@ void copy_global_pool_para(CTupleGenPoolYaml & src, CTupleGenPoolYaml & dst) {
if (src.m_udp_aging_sec == 0)
src.m_udp_aging_sec = dst.m_udp_aging_sec;
}
+
+
void operator >> (const YAML::Node& node, CTupleGenYamlInfo & fi) {
std::string tmp;
- try {
- CTupleGenPoolYaml c_pool;
- CTupleGenPoolYaml s_pool;
+ CTupleGenPoolYaml c_pool;
+ CTupleGenPoolYaml s_pool;
+
+ if (node.FindValue("distribution")) {
node["distribution"] >> tmp ;
if (tmp == "random") {
c_pool.m_dist=cdRANDOM_DIST;
@@ -297,23 +295,24 @@ void operator >> (const YAML::Node& node, CTupleGenYamlInfo & fi) {
c_pool.m_dist=cdSEQ_DIST;
}
s_pool.m_dist = c_pool.m_dist;
- utl_yaml_read_ip_addr(node,"clients_start",c_pool.m_ip_start);
- utl_yaml_read_ip_addr(node,"clients_end",c_pool.m_ip_end);
- utl_yaml_read_ip_addr(node,"servers_start",s_pool.m_ip_start);
- utl_yaml_read_ip_addr(node,"servers_end",s_pool.m_ip_end);
- utl_yaml_read_uint32(node,"clients_per_gb",c_pool.m_number_of_clients_per_gb);
- utl_yaml_read_uint32(node,"min_clients",c_pool.m_min_clients);
- utl_yaml_read_ip_addr(node,"dual_port_mask",c_pool.m_dual_interface_mask);
- utl_yaml_read_uint16(node,"tcp_aging",c_pool.m_tcp_aging_sec);
- utl_yaml_read_uint16(node,"udp_aging",c_pool.m_udp_aging_sec);
+ UTL_YAML_READ(ip_addr, clients_start, c_pool.m_ip_start);
+ UTL_YAML_READ(ip_addr, clients_end, c_pool.m_ip_end);
+ UTL_YAML_READ(ip_addr, servers_start, s_pool.m_ip_start);
+ UTL_YAML_READ(ip_addr, servers_end, s_pool.m_ip_end);
+ UTL_YAML_READ(uint32, clients_per_gb, c_pool.m_number_of_clients_per_gb);
+ UTL_YAML_READ(uint32, min_clients, c_pool.m_min_clients);
+ UTL_YAML_READ(ip_addr, dual_port_mask, c_pool.m_dual_interface_mask);
+ UTL_YAML_READ(uint16, tcp_aging, c_pool.m_tcp_aging_sec);
+ UTL_YAML_READ(uint16, udp_aging, c_pool.m_udp_aging_sec);
s_pool.m_dual_interface_mask = c_pool.m_dual_interface_mask;
s_pool.m_is_bundling = false;
fi.m_client_pool.push_back(c_pool);
fi.m_server_pool.push_back(s_pool);
- }catch ( const std::exception& e ) {
+ } else {
printf("No default generator defined.\n");
}
- try{
+
+ if (node.FindValue("generator_clients")) {
const YAML::Node& c_pool_info = node["generator_clients"];
for (uint16_t idx=0;idx<c_pool_info.size();idx++) {
CTupleGenPoolYaml pool;
@@ -327,10 +326,11 @@ void operator >> (const YAML::Node& node, CTupleGenYamlInfo & fi) {
printf("client pool in YAML is wrong\n");
}
}
- }catch ( const std::exception& e ) {
+ } else {
printf("no client generator pool configured, using default pool\n");
}
- try {
+
+ if (node.FindValue("generator_servers")) {
const YAML::Node& s_pool_info = node["generator_servers"];
for (uint16_t idx=0;idx<s_pool_info.size();idx++) {
CTupleGenPoolYaml pool;
@@ -344,7 +344,7 @@ void operator >> (const YAML::Node& node, CTupleGenYamlInfo & fi) {
}
fi.m_server_pool.push_back(pool);
}
- }catch ( const std::exception& e ) {
+ } else {
printf("no server generator pool configured, using default pool\n");
}
}