Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2010 Lalith Suresh | 3 * Copyright (c) 2010 Lalith Suresh |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
446 } | 446 } |
447 | 447 |
448 // This method should never be called since Click handles | 448 // This method should never be called since Click handles |
449 // forwarding directly | 449 // forwarding directly |
450 bool | 450 bool |
451 Ipv4ClickRouting::RouteInput (Ptr<const Packet> p, const Ipv4Header &header, | 451 Ipv4ClickRouting::RouteInput (Ptr<const Packet> p, const Ipv4Header &header, |
452 Ptr<const NetDevice> idev, UnicastForwardCallback ucb, | 452 Ptr<const NetDevice> idev, UnicastForwardCallback ucb, |
453 MulticastForwardCallback mcb, LocalDeliverCallbac k lcb,· | 453 MulticastForwardCallback mcb, LocalDeliverCallbac k lcb,· |
454 ErrorCallback ecb) | 454 ErrorCallback ecb) |
455 { | 455 { |
456 NS_FATAL_ERROR ("Click router does not have a RouteInput() interface!"); | |
456 return false; | 457 return false; |
Tom Henderson
2011/02/18 02:06:37
should it be a fatal error if it is never intended
| |
457 } | 458 } |
458 | 459 |
459 void | 460 void |
460 Ipv4ClickRouting::PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const | 461 Ipv4ClickRouting::PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const |
461 { | 462 { |
462 } | 463 } |
463 | 464 |
464 void | 465 void |
465 Ipv4ClickRouting::NotifyInterfaceUp (uint32_t i) | 466 Ipv4ClickRouting::NotifyInterfaceUp (uint32_t i) |
466 {} | 467 {} |
467 | 468 |
468 void | 469 void |
469 Ipv4ClickRouting::NotifyInterfaceDown (uint32_t i) | 470 Ipv4ClickRouting::NotifyInterfaceDown (uint32_t i) |
470 {} | 471 {} |
471 | 472 |
472 void | 473 void |
473 Ipv4ClickRouting::NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress add ress) | 474 Ipv4ClickRouting::NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress add ress) |
474 {} | 475 {} |
475 | 476 |
476 void | 477 void |
477 Ipv4ClickRouting::NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address) | 478 Ipv4ClickRouting::NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address) |
478 {} | 479 {} |
479 | 480 |
480 | 481 |
481 } // namespace ns3 | 482 } // namespace ns3 |
482 | |
483 using namespace ns3; | |
Tom Henderson
2011/02/18 02:06:37
In general, we do not use namespace ns3 within the
| |
484 | 483 |
485 static int simstrlcpy(char *buf, int len, const std::string &s) | 484 static int simstrlcpy(char *buf, int len, const std::string &s) |
486 { | 485 { |
487 if (len) | 486 if (len) |
488 { | 487 { |
489 len--; | 488 len--; |
490 | 489 |
491 if ((unsigned) len > s.length()) | 490 if ((unsigned) len > s.length()) |
492 { | 491 { |
493 len = s.length(); | 492 len = s.length(); |
494 } | 493 } |
495 | 494 |
496 s.copy(buf, len); | 495 s.copy(buf, len); |
497 buf[len] = '\0'; | 496 buf[len] = '\0'; |
498 } | 497 } |
499 return 0; | 498 return 0; |
500 } | 499 } |
501 | 500 |
502 // Sends a Packet from Click to the Simulator: Defined in simclick.h. Click | 501 // Sends a Packet from Click to the Simulator: Defined in simclick.h. Click |
503 // calls these methods. | 502 // calls these methods. |
504 int simclick_sim_send(simclick_node_t *simnode, | 503 int simclick_sim_send(simclick_node_t *simnode, |
505 int ifid, int type, const unsigned char* data, int len, | 504 int ifid, int type, const unsigned char* data, int len, |
506 simclick_simpacketinfo *pinfo) | 505 simclick_simpacketinfo *pinfo) |
507 { | 506 { |
508 NS_LOG_DEBUG ("simclick_sim_send called at " <<Simulator::Now().GetSeconds()<< ": " << ifid << " " << type << " " << data << " "<< len); | 507 NS_LOG_DEBUG ("simclick_sim_send called at " << ns3::Simulator::Now().GetSecon ds()<<": " << ifid << " " << type << " " << data << " "<< len); |
509 | 508 |
510 if (simnode == NULL) | 509 if (simnode == NULL) |
511 { | 510 { |
512 return -1; | 511 return -1; |
513 } | 512 } |
514 | 513 |
515 Ptr<Ipv4ClickRouting> clickInstance = Ipv4ClickRouting::GetClickInstanceFromSi mNode (simnode); | 514 ns3::Ptr<ns3::Ipv4ClickRouting> clickInstance = ns3::Ipv4ClickRouting::GetClic kInstanceFromSimNode (simnode); |
516 | 515 |
517 clickInstance->HandlePacketFromClick (ifid, type, data, len); | 516 clickInstance->HandlePacketFromClick (ifid, type, data, len); |
518 | 517 |
519 return 0; | 518 return 0; |
520 } | 519 } |
521 | 520 |
522 // Click Service Methods: Defined in simclick.h | 521 // Click Service Methods: Defined in simclick.h |
523 int simclick_sim_command(simclick_node_t *simnode, int cmd, ...) | 522 int simclick_sim_command(simclick_node_t *simnode, int cmd, ...) |
524 { | 523 { |
525 va_list val; | 524 va_list val; |
526 va_start (val, cmd); | 525 va_start (val, cmd); |
527 | 526 |
528 int retval = 0; | 527 int retval = 0; |
529 | 528 |
530 Ptr<Ipv4ClickRouting> clickInstance = Ipv4ClickRouting::GetClickInstanceFromSi mNode (simnode); | 529 ns3::Ptr<ns3::Ipv4ClickRouting> clickInstance = ns3::Ipv4ClickRouting::GetClic kInstanceFromSimNode (simnode); |
531 switch (cmd)· | 530 switch (cmd)· |
532 { | 531 { |
533 case SIMCLICK_VERSION: | 532 case SIMCLICK_VERSION: |
534 { | 533 { |
535 retval = 0; | 534 retval = 0; |
536 break; | 535 break; |
537 } | 536 } |
538 | 537 |
539 case SIMCLICK_SUPPORTS: | 538 case SIMCLICK_SUPPORTS: |
540 { | 539 { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
616 break; | 615 break; |
617 } | 616 } |
618 | 617 |
619 case SIMCLICK_IF_READY: | 618 case SIMCLICK_IF_READY: |
620 { | 619 { |
621 int ifid = va_arg(val, int); // Commented out so that optimized build wo rks | 620 int ifid = va_arg(val, int); // Commented out so that optimized build wo rks |
622 | 621 |
623 // We're not using a ClickQueue, so we're always ready (for the timebein g) | 622 // We're not using a ClickQueue, so we're always ready (for the timebein g) |
624 retval = clickInstance->IsInterfaceReady (ifid); | 623 retval = clickInstance->IsInterfaceReady (ifid); |
625 | 624 |
626 NS_LOG_DEBUG (clickInstance->GetNodeName () << " SIMCLICK_IF_READY: " << ifid << " " << Simulator::Now ()); | 625 NS_LOG_DEBUG (clickInstance->GetNodeName () << " SIMCLICK_IF_READY: " << ifid << " " << ns3::Simulator::Now ()); |
627 break; | 626 break; |
628 } | 627 } |
629 | 628 |
630 case SIMCLICK_TRACE: | 629 case SIMCLICK_TRACE: |
631 { | 630 { |
632 // Used only for tracing | 631 // Used only for tracing |
633 NS_LOG_DEBUG (clickInstance->GetNodeName () << " Received a call for SIM CLICK_TRACE"); | 632 NS_LOG_DEBUG (clickInstance->GetNodeName () << " Received a call for SIM CLICK_TRACE"); |
634 break; | 633 break; |
635 } | 634 } |
636 | 635 |
637 case SIMCLICK_GET_NODE_ID: | 636 case SIMCLICK_GET_NODE_ID: |
638 { | 637 { |
639 // Used only for tracing | 638 // Used only for tracing |
640 NS_LOG_DEBUG (clickInstance->GetNodeName () << " Received a call for SIM CLICK_GET_NODE_ID"); | 639 NS_LOG_DEBUG (clickInstance->GetNodeName () << " Received a call for SIM CLICK_GET_NODE_ID"); |
641 break; | 640 break; |
642 } | 641 } |
643 } | 642 } |
644 return retval; | 643 return retval; |
645 } | 644 } |
646 | 645 |
647 #endif // NS3_CLICK | 646 #endif // NS3_CLICK |
LEFT | RIGHT |