[Xorp-hackers] xorp callback construction

Pavlin Radoslavov pavlin@icir.org
Thu, 23 Mar 2006 15:49:12 -0800


> I'm running into a compile error that I am unable to circumvent. I
> written a xorp module that sends commands to the fea, but in
> constructing the callback to be dispatched to
> XrlIfmgrV0p1Client::send_start_transaction(), I have the following
> line, which should instantiate the start transaction callback:
> 
> uint32_t tid;
> XrlIfmgrV0p1Client::StartTransactionCB cb2 =
> XrlIfmgrV0p1Client::StartTransactionCB(this,
> &XrlRLInterfacesNode::send_start_transaction_cb, &tid);

Try something like this (off the top of my head):

    bool success;
    XrlIfmgrV0p1Client client(&xrl_router);

    success = client.send_start_transaction(fea_target_name.c_str(),
	callback(this,  &XrlRLInterfacesNode::send_start_transaction_cb));
    if (success != true) {
       // Handle XRL transmission error
       ...
    }
    ...

where the callback method must be like:

void
XrlRLInterfacesNode::send_start_transaction_cb(const XrlError& xrl_error,
                                               const uint32_t* tid)
{
    switch (xrl_error.error_code()) {
    case OKAY:
	// Use the value of *tid
	break;
    ....
    // Switch cases to handle all other XRL errors
    }
}


Pavlin


> 
> The "this" object is a child class that derives from
>  class XrlRLInterfacesNode :     public XrlStdRouter, /* used for
> dispatch of xrl messages */
>                             public XrlRlInterfacesTargetBase { /* used
> for defined interface */
> 
> However, the compilier is unhappy with the instantiation of the
> StartTransactionCB object though:
> 
> xrl_rl_interfaces_node.cc:943: error: no matching function for call to
> `ref_ptr<XorpCallback2<void, const XrlError&, const uint32_t*>
> >::ref_ptr(XrlRLInterfacesNode* const, void
> (XrlRLInterfacesNode::*)(const XrlError&, const uint32_t*), uint32_t*)'
> ../libxorp/ref_ptr.hh:247: note: candidates are:
> ref_ptr<_Tp>::ref_ptr(_Tp*, int32_t) [with _Tp = XorpCallback2<void,
> const XrlError&, const uint32_t*>]
> ../libxorp/ref_ptr.hh:149: note:                
> ref_ptr<_Tp>::ref_ptr(const ref_ptr<_Tp>&) [with _Tp =
> XorpCallback2<void, const XrlError&, const uint32_t*>]
> ../libxorp/ref_ptr.hh:136: note:                
> ref_ptr<_Tp>::ref_ptr(_Tp*) [with _Tp = XorpCallback2<void, const
> XrlError&, const uint32_t*>]
> 
> The callback method is defined as:
> 
> void send_start_transaction_cb(const XrlError &xrl_error, const uint32_t
> *tid);
> 
> So, it looks as if my callback method isn't defined correctly, but in
> searching through the xorp source--but it looks correct to me (but I'm
> probably missing something obvious). 
> 
> Thanks for any help!
> 
> 
> Mike Larson
> 
> _______________________________________________
> Xorp-hackers mailing list
> Xorp-hackers@icir.org
> http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/xorp-hackers