[Click] segmentation fault using cp_va_parse

sendoa vaz sendoav at gmail.com
Sat Aug 30 23:16:39 EDT 2008


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], &eth))
    {
      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;
}


More information about the click mailing list