📄 readme
字号:
A SAMPLE LLRPC USER=================== There are two ways to communicate with a Click kernel module from userlevel. The first, handlers, uses a simple file-based model: you read andwrite files in /proc/click or /proc/click/ELEMENTNAME. Generally, thesefiles are ASCII. For example, to read the current count from a counternamed `c', you might read `/proc/click/c/count', then parse the result (asimple string like "2003") into an integer. To change the RED min_threshparameter, you might write a string like "10" to the file`/proc/click/red/min_thresh'. Handlers are a heavyweight mechanism -- all that file opening andclosing and data parsing and unparsing -- although relatively easy to use.The other communication method, LLRPCs (low-level remote procedure calls),is much faster, although less safe; it's suitable for heavy-dutykernel/user communication. A Click LLRPC is implemented by ioctl. A user-level program opens anyof the element's handler files -- for example, its`/proc/click/ELEMENT/name' handler -- then calls ioctl(), passing in thefile descriptor, one of the LLRPC IDs from <click/llrpc.h>, and therelevant data. For example, the CLICK_LLRPC_GET_COUNT LLRPC takes a pointerto an integer. On input, this integer identifies the counter of interest.On output, its value is set to the relevant count. This is much lessexpensive than using an ASCII `count' handler. Several of our elements provide LLRPC interfaces; for example, checkout the Counter element in elements/standard/counter.cc. These interfacesare generally documented in the element manual pages -- for example, `manCounter'. Sometimes, you may want to keep a file descriptor open for a long timefor making LLRPC calls. Remember that this file descriptor will becomeinvalid if someone installs another Click configuration! All LLRPC calls onthe old file descriptor will return EINVAL. One reasonable behavior is toclose and reopen the file descriptor on error, and only complain if theioctl fails both times.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -