[Click] segmentation fault using cp_va_parse
Beyers Cronje
bcronje at gmail.com
Sun Aug 31 10:59:25 EDT 2008
Hi,
You can use cp_integer which parses a string to uint32_t, then just check
value if it fits in a uint16_t i.e. 'if (value <= 0xFFFF)'
Beyers
On Sun, Aug 31, 2008 at 4:31 PM, sendoa vaz <sendoav at gmail.com> wrote:
> Hi again, I have solved the error fortunately, but I have another question,
> anyone knows how to parse a string into one uint16_t???
> I want to capture one number from the handler and assign it to he VLAN tag
> which has 16 bits.
>
> Thanks
>
>
> 2008/8/31 sendoa vaz <sendoav at gmail.com>
>
> > Hi,
> >
> > I am trying to add the VLAN capability to the etherswitch element and I
> > have introduced a new write handler to introduce new records into the
> > etherswitch's table and whenever I try to run the configuration and use
> this
> > new write handler I get a segmentation fault. I execute the following
> > command : write switch2.tabla 11:1:11:00:12:12 10 13 100. I think the
> > problem could be originated when I capture the port and the vlan
> > arguments...Anyone has deal with cp_va_parse ??
> >
> > Thanks in advance!
> >
> > Sendoa
> >
> > int
> > EtherSwitch::writer(const String &arg, Element *e, void *, ErrorHandler
> > *errh)
> > {
> > EtherSwitch *sw = (EtherSwitch *) e;
> >
> > Vector<String> args;
> > EtherAddress eth;
> > cp_spacevec(arg,args);
> >
> > if (args.size() <4) {
> > return errh->error("Necesitas especificar 4 parametros");
> > }
> >
> > if (!cp_ethernet_address(args[0], ð))
> > {
> > return errh->error("Couldn't read EtherAddress out of eth");
> > }
> >
> > uint16_t _vlan=0;
> > int _port=0;
> >
> > cp_va_parse(cp_uncomment(args[1]),0,errh,cpUnsigned,"port",_port);
> > cp_va_parse(cp_uncomment(args[2]),0,errh,cpTCPPort,"vlan",_vlan);
> > cp_seconds_as(cp_uncomment(args[3]), 0, &sw->_timeout);
> > Timestamp stamp=sw->_timeout;
> >
> > int condition=0;
> >
> > for (Table::iterator iter = sw->_table.begin(); iter.live(); iter++)
> > {
> > if(eth==iter.key() && _vlan==iter.value().vlan)
> > condition=1;
> > }
> > if(condition==0)
> > sw->insert(eth,_port,_vlan,stamp);
> >
> > return 0;
> > }
> > int
> > EtherSwitch::insert(EtherAddress eth,int port,uint16_t vlan,Timestamp
> > &stamp)
> > {
> > _table.insert(eth, AddrInfo(port,stamp,vlan));
> > return 0;
> > }
> >
> _______________________________________________
> click mailing list
> click at amsterdam.lcs.mit.edu
> https://amsterdam.lcs.mit.edu/mailman/listinfo/click
>
More information about the click
mailing list