[Click] assertion problem with port

iaaaguru at tce.edu iaaaguru at tce.edu
Wed Mar 2 09:26:25 EST 2011


i think the problem is with the line " output(h).push(p);". in the "push"
finction..if its commented the element works fine... can u pls help


########### time.cc ##########
#include <click/config.h>
#include "time.hh"
#include <click/confparse.hh>
#include <click/error.hh>
#include <click/glue.hh>
#include <click/router.hh>
CLICK_DECLS

Time::Time()
    : _interval(0, Timestamp::subsec_per_sec / 2),
      _count0(0),_count1(0), _active(true), _timer(this)
{
	click_chatter("constructor count0: %d count1: %d",_count0,_count1);
}

Time::~Time()
{
}

int
Time::configure(Vector<String> &conf, ErrorHandler *errh)
{
  if (cp_va_kparse(conf, this, errh,
		   "INTERVAL", cpkP, cpTimestamp, &_interval,
		   "ACTIVE", 0, cpBool, &_active,
		    cpEnd) < 0)
    return -1;

}

int
Time::initialize(ErrorHandler *)
{
  _timer.initialize(this);
  if (_active)
    _timer.schedule_after(_interval);
  return 0;
}

void
Time::run_timer(Timer *)
{


//@@@@@@@@@@@@@@@@@ get counters from pull element @@@@@@@@@@@@@@@

  click_chatter("Left count : %d Right count :%d",_count1,_count0);

  if ((_count0==0)&&(_count1)==0)
    click_chatter("No netowrk flow");

  if(_count0>_count1)
    {
      click_chatter("Right is hot");
      hot_int =0;
    }

  else if ((_count0==0)||(_count1)==0)
     {
       if(_count0=0)
         {
          if(_count1=0)
            click_chatter("No network flow");
          else
            click_chatter("No flow from left");
          }

     }

  if(_count1>_count0)
    {
      click_chatter("Left is hot");
      hot_int=1;
    }

//@@@@@@@@@@@@@@@@@@ reset all counters @@@@@@@@@@@@@@@@@@@@@@@@@@
  _count0=0;
  _count1=0;
   click_chatter("Timer reset");

//@@@@@@@@@@@@@@@@@@@@  UDP section  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@

  pudp=input(2).pull();
  if(pudp)
    {

     click_chatter("@@@@@@@@@@@@ Recieved UDP packet @@@@@@@@@@@@@@@@@");
     push(hot_int,pudp);

    }

  _timer.reschedule_after(_interval);
}

Packet*
Time::pull(int)
{

  p0=input(0).pull();

	if(p0)
	 {
	    _count0+=1;
            p0->kill();
	  }

  p1=input(1).pull();

	if(p1)
	{
	  _count1+=1;
          p1->kill();
	}


   return p0;

}

void
Time::push(int h, Packet *p)
{

   if(p)
    {
    // pudp_n = p->clone();

     click_chatter("Made packet");
     output(h).push(p);
     click_chatter("Pushed packet");
   }
 }

CLICK_ENDDECLS
ELEMENT_REQUIRES(userlevel)
EXPORT_ELEMENT(Time)
ELEMENT_MT_SAFE(Time)

########### time.hh ##########


#ifndef CLICK_TIME_HH
#define CLICK_TIME_HH
#include <click/element.hh>
#include <click/timer.hh>
CLICK_DECLS


class Time : public Element { public:

  Time();
  ~Time();

  const char *class_name() const		{ return "Time"; }
  const char *port_count() const		{ return "-/="; }
  const char *processing() const		{ return AGNOSTIC; }

  int configure(Vector<String> &, ErrorHandler *);
  int initialize(ErrorHandler *);

  void run_timer(Timer *);
  Packet* pull(int);
  void push(int, Packet *p);

 private:
  Packet *p0, *p1, *pudp,*pudp_n;
  Timestamp _interval;
  int _count0,_count1,hot_int;
  bool _active;
  Timer _timer;
  int counter;
  String _data;

};

CLICK_ENDDECLS
#endif




> Please include your code.
> - Ian
>
>
> On 03/02/2011 08:16 AM, iaaaguru at tce.edu wrote:
>> hi all...
>> i wrote an agnostic element. its pull ekement pull packet from 3 input
>> ports and push elements on having certain conditions based on pulled
>> packets  generates packet and pushes it to output port.. while doing
>> this
>> i get an error..
>>
>> "click: ../include/click/element.hh:559: void
>> Element::Port::push(Packet*)
>> const: Assertion `_e&&  p' failed."
>>
>> can u pls help...
>>
>>
>>
>> -----------------------------------------
>> This email was sent using TCEMail Service.
>> Thiagarajar College of Engineering
>> Madurai-625 015, India
>>
>> _______________________________________________
>> click mailing list
>> click at amsterdam.lcs.mit.edu
>> https://amsterdam.lcs.mit.edu/mailman/listinfo/click
> _______________________________________________
> click mailing list
> click at amsterdam.lcs.mit.edu
> https://amsterdam.lcs.mit.edu/mailman/listinfo/click
>



-----------------------------------------
This email was sent using TCEMail Service.
Thiagarajar College of Engineering
Madurai-625 015, India



-----------------------------------------
This email was sent using TCEMail Service.
Thiagarajar College of Engineering
Madurai-625 015, India



More information about the click mailing list