[Click] How does AddressInfo work?

Eddie Kohler kohler at cs.ucla.edu
Thu Dec 9 11:54:34 EST 2004


Hi Dagang,

> I am now trying to create a new element that doesn't stand in the packet 
> flows. Its mere function is to mentain a state and manipulate some other 
> elements accordingly via handlers. I guess this element can work in a 
> similiar way as AddressInfo, since this AddressInfo is not involved in 
> the flows either.

Yep!  There are many other examples in Click: ScheduleInfo, 
PerfCounterInfo, ControlSocket, ChatterSocket, ProgressBar, Error, 
DriverManager, AlignmentInfo, IPRewriterPatterns, RoundRobinIPMapper.

> I found AddressInfo is used (only?) in the parse functions. Its class 
> methods are called only when CLICK_TOOL is not defined. I have no idea 
> what this CLICK_TOOL is. Is it just a flag for the makefile? And what is 
> the purpose of it? Is there a kind of guideline to follow for these 
> elements that don't participate packets manipulation? I also want to 
> know if I want to check whether a certain element exists in the router 
> configuration, what shall I do?

CLICK_TOOL is defined when Click is compiling things in the tools/ 
directory.  You should not need to use it.  Check out one of the 
elements above for a more salient example.

For checking whether an element exists, you can either use 
Router::find() [to find an element by name], or use the Router 
'attachment' system.  The DriverManager and ScheduleInfo elemnets use 
the attachment system;

     if (router()->attachment("DriverManager"))
	return errh->error("router has more than one DriverManager element");
     router()->set_attachment("DriverManager", this);

Then later elements can say

     DriverManager* dm = (DriverManager*) 
router()->attachment("DriverManager");

to get the single DriverManager element, or a nul pointer if none exists.

Eddie


> 
> Any help will be highly appreciated!
> 
> Best regards,
> Dagang
> 
> 
> _______________________________________________
> click mailing list
> click at amsterdam.lcs.mit.edu
> https://amsterdam.lcs.mit.edu/mailman/listinfo/click


More information about the click mailing list