Changeset 1587
- Timestamp:
- 01/14/06 15:00:17 (3 years ago)
- Files:
-
- mrd6/trunk/include/mrd/node.h (modified) (1 diff)
- mrd6/trunk/include/mrdpriv/mld/router.h (modified) (3 diffs)
- mrd6/trunk/include/mrdpriv/pim/interface.h (modified) (1 diff)
- mrd6/trunk/src/mld/mld_router.cpp (modified) (16 diffs)
- mrd6/trunk/src/mrd.cpp (modified) (1 diff)
- mrd6/trunk/src/node.cpp (modified) (1 diff)
- mrd6/trunk/src/parser.cpp (modified) (1 diff)
- mrd6/trunk/src/pim/pim_interface.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
mrd6/trunk/include/mrd/node.h
r1586 r1587 464 464 }; 465 465 466 class statistics_node : public node { 467 public: 468 typedef uint64_t counter_type; 469 470 statistics_node(node *parent, int count, const char **descriptions); 471 ~statistics_node(); 472 473 bool check_startup(); 474 475 /* calls check_startup and adds itself to parent */ 476 bool setup(); 477 478 counter_type &counter(int index) const; 479 480 bool output_info(base_stream &, const std::vector<std::string> &) const; 481 482 private: 483 int m_count; 484 counter_type *m_counters; 485 const char **m_descriptions; 486 }; 487 466 488 struct propval_integer : propval { 467 489 propval_integer(const int32_t *); mrd6/trunk/include/mrdpriv/mld/router.h
r1586 r1587 134 134 bool send_mldv2_query(const in6_addr &); 135 135 136 void message_available(const in6_addr &, const in6_addr &, icmp6_hdr *, int); 136 137 void icmp_message_available(const in6_addr &, const in6_addr &, icmp6_hdr *, int); 137 138 138 void handle_mldv1_membership_report(const in6_addr *, mldv1 *);139 void handle_mldv2_membership_report(const in6_addr *, mldv2_report *, int);140 void handle_mldv1_membership_reduction(const in6_addr *, mldv1 *);141 void handle_membership_query(const in6_addr *);139 void handle_mldv1_membership_report(const in6_addr &, mldv1 *); 140 void handle_mldv2_membership_report(const in6_addr &, mldv2_report *, int); 141 void handle_mldv1_membership_reduction(const in6_addr &, mldv1 *); 142 void handle_membership_query(const in6_addr &); 142 143 143 144 void handle_mode_change_for_group(int ver, const inet6_addr &reqsrc, … … 161 162 intf_timer mif_query_timer_id, mif_other_querier_present_timer_id; 162 163 163 uint64_t mif_stat_icmp_received; 164 uint64_t mif_stat_icmp_sent; 164 statistics_node m_stats; 165 165 166 166 void address_added_or_removed(bool, const inet6_addr &); 167 168 void added_or_removed_address(bool, const inet6_addr &);169 167 }; 170 168 … … 303 301 bool call_method(int, base_stream &, const std::vector<std::string> &); 304 302 303 statistics_node &stats() { return m_stats; } 304 305 305 private: 306 306 virtual mld_group *allocate_group(); 307 308 statistics_node m_stats; 307 309 }; 308 310 mrd6/trunk/include/mrdpriv/pim/interface.h
r1586 r1587 170 170 void address_added_or_removed(bool, const inet6_addr &); 171 171 172 void added_or_removed_address(bool, const inet6_addr &);173 174 172 friend class pim_neighbour; 175 173 }; mrd6/trunk/src/mld/mld_router.cpp
r1586 r1587 57 57 }; 58 58 59 enum { 60 SentQueryCount = 0, 61 FailedSendQueryCount, 62 ReceivedMembershipQueryCount, 63 ReceivedMembershipReductionCount, 64 ReceivedMembershipReportCount, 65 ReceivedMembershipReportV2Count, 66 BadMembershipReportV2Count, 67 MLDStatsCount 68 }; 69 70 const char *stats_descriptions[] = { 71 "Sent Queries", 72 "Failed Sent Queries", 73 "Received Queries", 74 "Received Membership Reductions", 75 "Received Membership Reports", 76 "Received Membership Reports (V2)", 77 "Bad Membership Reports (V2)", 78 }; 79 59 80 mld_interface::mld_interface() 60 81 : interface_node(mld), … … 62 83 std::mem_fun(&mld_interface::handle_send_query_timeout)), 63 84 mif_other_querier_present_timer_id("other mld querier present", this, 64 std::mem_fun(&mld_interface::handle_other_querier_present_timeout)) { 85 std::mem_fun(&mld_interface::handle_other_querier_present_timeout)), 86 m_stats(this, MLDStatsCount, stats_descriptions) { 65 87 66 88 mif_isquerier = true; … … 101 123 102 124 bool mld_interface::check_startup() { 125 if (!m_stats.setup()) 126 return false; 103 127 return interface_node::check_startup(); 104 128 } … … 131 155 132 156 void mld_interface::address_added_or_removed(bool added, const inet6_addr &addr) { 133 added_or_removed_address(added, addr);134 }135 136 void mld_interface::added_or_removed_address(bool added, const inet6_addr &addr) {137 157 if (added) { 138 158 if (addr.is_linklocal()) { … … 205 225 } 206 226 227 void mld_interface::message_available(const in6_addr &from, const in6_addr &to, 228 icmp6_hdr *icmphdr, int len) { 229 loginfo(MESSAGE_SIG) << "Received a " 230 << _mld_message_name(icmphdr->icmp6_type) 231 << " from " << from << " to " << to << endl; 232 233 switch (icmphdr->icmp6_type) { 234 case ICMP6_MEMBERSHIP_REPORT: 235 handle_mldv1_membership_report(from, (mldv1 *)icmphdr); 236 break; 237 case ICMP6_MEMBERSHIP_REDUCTION: 238 handle_mldv1_membership_reduction(from, (mldv1 *)icmphdr); 239 break; 240 case ICMP6_MEMBERSHIP_QUERY: 241 handle_membership_query(from); 242 break; 243 case ICMP6_V2_MEMBERSHIP_REPORT: 244 case ICMP6_V2_MEMBERSHIP_REPORT_206: 245 handle_mldv2_membership_report(from, (mldv2_report *)icmphdr, len); 246 break; 247 } 248 } 249 207 250 void mld_interface::icmp_message_available(const in6_addr &from, const in6_addr &to, 208 icmp6_hdr *icmphdr, int len) { 251 icmp6_hdr *icmphdr, int len) { 252 if (!_is_mld_message(icmphdr->icmp6_type)) { 253 return; 254 } 255 209 256 if (conf()->has_property("proxy_to")) { 210 257 const char *newintfname = conf()->get_property_string("proxy_to"); … … 222 269 fatal = false; 223 270 } else { 224 newmldintf-> icmp_message_available(from, to, icmphdr, len);271 newmldintf->message_available(from, to, icmphdr, len); 225 272 return; 226 273 } … … 236 283 } 237 284 238 if (_is_mld_message(icmphdr->icmp6_type)) { 239 loginfo(MESSAGE_SIG) << "Received a " 240 << _mld_message_name(icmphdr->icmp6_type) 241 << " from " << from << " to " << to << endl; 242 } 243 244 switch (icmphdr->icmp6_type) { 245 case ICMP6_MEMBERSHIP_REPORT: 246 handle_mldv1_membership_report(&from, (mldv1 *)icmphdr); 247 break; 248 case ICMP6_MEMBERSHIP_REDUCTION: 249 handle_mldv1_membership_reduction(&from, (mldv1 *)icmphdr); 250 break; 251 case ICMP6_MEMBERSHIP_QUERY: 252 handle_membership_query(&from); 253 break; 254 case ICMP6_V2_MEMBERSHIP_REPORT: 255 case ICMP6_V2_MEMBERSHIP_REPORT_206: 256 handle_mldv2_membership_report(&from, (mldv2_report *)icmphdr, len); 257 break; 258 } 285 message_available(from, to, icmphdr, len); 259 286 } 260 287 … … 267 294 } 268 295 296 bool res; 297 269 298 if (mif_mld_version >= 2) { 270 re turnsend_mldv2_query(addr);299 res = send_mldv2_query(addr); 271 300 } else { 272 return send_mldv1_query(addr); 273 } 301 res = send_mldv1_query(addr); 302 } 303 304 if (res) { 305 m_stats.counter(SentQueryCount)++; 306 mld->stats().counter(SentQueryCount)++; 307 } else { 308 m_stats.counter(FailedSendQueryCount)++; 309 mld->stats().counter(FailedSendQueryCount)++; 310 } 311 312 return res; 274 313 } 275 314 … … 304 343 } 305 344 306 mif_stat_icmp_sent++; 307 308 return mld->send_icmp(owner(), in6addr_linkscope_allnodes, 309 query, query->length()); 345 if (mld->send_icmp(owner(), in6addr_linkscope_allnodes, 346 query, query->length())) { 347 m_stats.counter(SentQueryCount)++; 348 mld->stats().counter(SentQueryCount)++; 349 return true; 350 } else { 351 m_stats.counter(FailedSendQueryCount)++; 352 mld->stats().counter(FailedSendQueryCount)++; 353 return false; 354 } 310 355 } 311 356 … … 386 431 } 387 432 388 void mld_interface::handle_mldv1_membership_report(const in6_addr *src, 389 mldv1 *mldhdr) { 433 void mld_interface::handle_mldv1_membership_report(const in6_addr &src, 434 mldv1 *mldhdr) { 435 m_stats.counter(ReceivedMembershipReportCount)++; 436 mld->stats().counter(ReceivedMembershipReportCount)++; 437 390 438 if (!IN6_IS_ADDR_MULTICAST(&mldhdr->mcaddr) 391 439 || IN6_IS_ADDR_MC_NODELOCAL(&mldhdr->mcaddr) … … 393 441 return; 394 442 395 handle_mode_change_for_group(1, *src, mldhdr->mcaddr, 396 MLD_SSM_MODE_EXCLUDE, address_set()); 397 } 398 399 void mld_interface::handle_mldv2_membership_report(const in6_addr *src, 400 mldv2_report *mldhdr, int len) { 443 handle_mode_change_for_group(1, src, mldhdr->mcaddr, 444 MLD_SSM_MODE_EXCLUDE, address_set()); 445 } 446 447 void mld_interface::handle_mldv2_membership_report(const in6_addr &src, 448 mldv2_report *mldhdr, 449 int len) { 450 m_stats.counter(ReceivedMembershipReportV2Count)++; 451 mld->stats().counter(ReceivedMembershipReportV2Count)++; 452 401 453 mldv2_mrec *mrec = mldhdr->mrecs(); 402 454 int clen = 0; … … 414 466 if (clen > len) { 415 467 loginfo(MESSAGE_ERR) << "dropped badly formed MLDv2 Membership" 416 << " report packet from " << *src << " (" << clen468 << " report packet from " << src << " (" << clen 417 469 << " > " << len << ")" << endl; 470 471 m_stats.counter(BadMembershipReportV2Count)++; 472 mld->stats().counter(BadMembershipReportV2Count)++; 418 473 return; 419 474 } … … 433 488 } 434 489 435 handle_mode_change_for_group(2, *src, mrec->mca, mrec->type, sources); 436 } 437 } 438 439 void mld_interface::handle_mldv1_membership_reduction(const in6_addr *src, 440 mldv1 *mldhdr) { 490 handle_mode_change_for_group(2, src, mrec->mca, mrec->type, sources); 491 } 492 } 493 494 void mld_interface::handle_mldv1_membership_reduction(const in6_addr &src, 495 mldv1 *mldhdr) { 496 m_stats.counter(ReceivedMembershipReductionCount)++; 497 mld->stats().counter(ReceivedMembershipReductionCount)++; 498 441 499 if (!IN6_IS_ADDR_MULTICAST(&mldhdr->mcaddr) 442 500 || IN6_IS_ADDR_MC_NODELOCAL(&mldhdr->mcaddr) … … 444 502 return; 445 503 446 handle_mode_change_for_group(1, *src, mldhdr->mcaddr, 447 MLD_SSM_CHANGE_TO_INCLUDE, address_set()); 448 } 449 450 void mld_interface::handle_membership_query(const in6_addr *src) { 504 handle_mode_change_for_group(1, src, mldhdr->mcaddr, 505 MLD_SSM_CHANGE_TO_INCLUDE, address_set()); 506 } 507 508 void mld_interface::handle_membership_query(const in6_addr &src) { 509 m_stats.counter(ReceivedMembershipQueryCount)++; 510 mld->stats().counter(ReceivedMembershipQueryCount)++; 511 451 512 // there should only be a MLD querier in a subnet network 452 513 // so, if we are currently a querier, let's check if we have priority 453 514 if (mif_isquerier) { 454 if ( *src < *owner()->linklocal()) {515 if (src < *owner()->linklocal()) { 455 516 change_is_querier(false); 456 517 457 mif_querier_addr = *src;518 mif_querier_addr = src; 458 519 loginfo(NORMAL) << "No longer the MLD querier in this interface." 459 << " Querier is at " << mif_querier_addr << endl;520 << " Querier is at " << mif_querier_addr << endl; 460 521 } 461 522 } else { 462 if (mif_querier_addr.is_any() || *src < mif_querier_addr) {463 mif_querier_addr = *src;523 if (mif_querier_addr.is_any() || src < mif_querier_addr) { 524 mif_querier_addr = src; 464 525 loginfo(NORMAL) << "Querier is now at " << mif_querier_addr << endl; 465 526 } … … 1082 1143 1083 1144 mld_router::mld_router() 1084 : router("mld") { 1145 : router("mld"), 1146 m_stats(this, MLDStatsCount, stats_descriptions) { 1147 1085 1148 in6addr_linkscope_allnodes = inet6_addr("ff02::1").address(); 1086 1149 } … … 1094 1157 1095 1158 bool mld_router::check_startup() { 1159 if (!m_stats.setup()) 1160 return false; 1161 1096 1162 if (!router::check_startup()) 1097 1163 return false; mrd6/trunk/src/mrd.cpp
r1586 r1587 1625 1625 accept && i != m_create_group_acl.end(); ++i) { 1626 1626 accept = i->second->request_group(0, ctx->requester, 1627 ctx->groupaddr, owner);1627 ctx->groupaddr, owner); 1628 1628 } 1629 1629 mrd6/trunk/src/node.cpp
r1586 r1587 1127 1127 } 1128 1128 1129 statistics_node::statistics_node(node *parent, int count, 1130 const char **descriptions) 1131 : node(parent, "stats"), m_count(count), m_descriptions(descriptions) { 1132 m_counters = new counter_type[count]; 1133 } 1134 1135 statistics_node::~statistics_node() { 1136 delete [] m_counters; 1137 m_counters = 0; 1138 } 1139 1140 bool statistics_node::check_startup() { 1141 if (m_counters) { 1142 for (int i = 0; i < m_count; i++) { 1143 m_counters[i] = 0; 1144 } 1145 } else { 1146 return false; 1147 } 1148 1149 return true; 1150 } 1151 1152 bool statistics_node::setup() { 1153 if (!check_startup()) 1154 return false; 1155 return m_parent->add_child(this) == this; 1156 } 1157 1158 statistics_node::counter_type &statistics_node::counter(int index) const { 1159 return m_counters[index]; 1160 } 1161 1162 bool statistics_node::output_info(base_stream &out, 1163 const std::vector<std::string> &args) const { 1164 if (!args.empty()) 1165 return false; 1166 1167 for (int i = 0; i < m_count; i++) { 1168 out << m_descriptions[i] << ": " << m_counters[i] << endl; 1169 } 1170 1171 return true; 1172 } 1173 mrd6/trunk/src/parser.cpp
r1586 r1587 256 256 257 257 static inline bool is_token_char(char c) { 258 return isalnum(c) || c == ':' || c == '/' || c == '-' || c == '_' ;258 return isalnum(c) || c == ':' || c == '/' || c == '-' || c == '_' || c == '.'; 259 259 } 260 260 mrd6/trunk/src/pim/pim_interface.cpp
r1586 r1587 147 147 148 148 void pim_interface::address_added_or_removed(bool added, const inet6_addr &addr) { 149 added_or_removed_address(added, addr);150 }151 152 void pim_interface::added_or_removed_address(bool added, const inet6_addr &addr) {153 149 if (added) { 154 150 if (addr.is_linklocal()) {
