[Click] Accessing element handlers from within a click script
Eddie Kohler
kohler at cs.ucla.edu
Mon Aug 10 18:47:31 EDT 2009
Hi David,
Bart, Beyers, and Peter had good feedback for you, but I wanted to point
specifically at some elements that already pass handlers around. Most of our
current elements use HandlerCall objects for write handlers, not read
handlers. But you can find a couple that use read handlers.
* elements/analysis/aggregateipflows.* : The _filepos_h HandlerCall object is
called to fetch the current packet's file position...
HandlerCall *_filepos_h; ...
String s = _filepos_h->call_read();
Also check out elements/standard/script.* and elements/userlevel/progressbar.*
for examples of using Handler objects directly. But probably the best thing
is to look at the HandlerCall documentation Peter mentioned.
Eddie
david johnson wrote:
> Hi
>
> I've got the following example code in which I'm continuously scanning
> for beacons and storing the results in bs.scan. I then want to send the
> results of the scan to other nodes in the network when I get a certain
> request message.
>
> To do this I need to access the BeaconScanner handler "scan". I'm new to
> click and maybe I'm breaking some fundamental rule in a click config
> script but is it possible to pass an element handler as a parameter to
> another element.
>
> I need to do it at this point in the code:
> 25 -> send_scan_results(### pass bs.scan handler to element ###)
>
> Thanks
> David
>
> =========================================
>
> 1 control :: ControlSocket("TCP", 7777);
> 2
> 3 rates :: AvailableRates(DEFAULT 2 4 11 22);
> 4
> 5 FromDevice(ath0, PROMISC true)
> 6 -> RadiotapDecap()
> 7 -> c1 :: Counter
> 8 -> wifi_cl :: Classifier(0/00%0c, /mgt
> 9 0/08%0c, /data);
> 10
> 11 wifi_cl [0] -> Classifier(0/80%f0)
> 12 -> c2 :: Counter
> 13 -> bs :: BeaconScanner()
> 14 -> Discard;
> 15
> 16 wifi_cl [1]
> 17 -> WifiDecap()
> 18 -> cognitive :: -> Classifier(//some String 1,
> 19 // Some String 2,
> 20 // Some String 3,
> 21 );
> 22
> 23 // Respond to Get beacons stored in node
> 24 cognitive [0]
> 25 -> send_scan_results(### pass bs.scan handler to element ###)
> 26 -> q;
> 27
> 28
> 29 q :: Queue(10)
> 30 -> wep_encap :: WepEncap(ACTIVE false)
> 31 -> set_rate :: SetTXRate(2)
> 32 -> rate :: ProbeTXRate(OFFSET 4,
> 33 THRESHOLD 0,
> 34 WINDOW 10000,
> 35 RT rates)
> 36 -> SetTXPower(63)
> 37 -> extra_encap :: ExtraEncap()
> 38 -> to_dev :: ToDevice (ath0);
>
>
> _______________________________________________
> click mailing list
> click at amsterdam.lcs.mit.edu
> https://amsterdam.lcs.mit.edu/mailman/listinfo/click
More information about the click
mailing list