[Click] To/From Click devices

rchertov@purdue.edu rchertov at purdue.edu
Tue Nov 28 10:43:55 EST 2006


Hello,
   There was a request to take a look at my char device drivers I made for
user-Click interaction.

Build the new elements.
Create the devices
mknod /dev/toclick0 c 240 0
mknod /dev/toclick1 c 240 1
mknod /dev/toclick1 c 240 1
mknod /dev/touser0 c 241 0
mknod /dev/touser1 c 241 1
mknod /dev/touser2 c 241 2
(you can make as few or as many as you want (255 is max))

In the Click config file you use the elements as follows:

FromUser(MINORNUMBER, [SIZE, BURST])-> CheckIPHeader -> Discard;

MINORNUMBER is instance of the device you want to use (0 for /dev/toclick0)
SIZE is the size ring buffer inside of the device.
BURST how many packets to move from the ring buffer into click at once

In a user app you just do this
fd = open("/dev/toclick0", O_WRONLY);
// You write a single pkt at a time.  buff contains a pkt of size buff_size
// you can't write pkts larger than (1536+16)
write(fd, buff, buff_size);
close(fd);



PollDevice(eth0) -> ToUser(MINORNUMBER, [SIZE]);

MINORNUMBER is instance of the device you want to use (0 for /dev/touser0)
SIZE is the size ring buffer inside of the device.


In user level land you just do 
fd = open("/dev/touser0", O_RDONLY);
// you read pkts and not bytes.  The returned value will be in bytes
// Each pkt is a slot of (1536+16). so make buff size a multiple of this number
read(fd, buff, 2);  
close(fd);


If you have any questions please let me know.

Roman
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clicktouser.cc
Type: text/x-c++src
Size: 12249 bytes
Desc: not available
Url : https://amsterdam.lcs.mit.edu/pipermail/click/attachments/20061128/b406bc07/clicktouser-0001.cc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clicktouser.hh
Type: text/x-c++hdr
Size: 2297 bytes
Desc: not available
Url : https://amsterdam.lcs.mit.edu/pipermail/click/attachments/20061128/b406bc07/clicktouser-0001.hh
-------------- next part --------------
A non-text attachment was scrubbed...
Name: usertoclick.hh
Type: text/x-c++hdr
Size: 2120 bytes
Desc: not available
Url : https://amsterdam.lcs.mit.edu/pipermail/click/attachments/20061128/b406bc07/usertoclick-0001.hh
-------------- next part --------------
A non-text attachment was scrubbed...
Name: usertoclick.cc
Type: text/x-c++src
Size: 12246 bytes
Desc: not available
Url : https://amsterdam.lcs.mit.edu/pipermail/click/attachments/20061128/b406bc07/usertoclick-0001.cc


More information about the click mailing list