⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filter.txt

📁 ARM 嵌入式 系统 设计与实例开发 实验教材 二源码
💻 TXT
字号:
filter.txt: Linux Socket FilteringWritten by: Jay Schulist <jschlst@samba.org>Introduction============	Linux Socket Filtering is derived from the BerkeleyPacket Filter. There are some distinct differences betweenthe BSD and Linux Kernel Filtering.Linux Socket Filtering (LSF) allows a user-space program toattach a filter onto any socket and allow or disallow certaintypes of data to come through the socket. LSF follows exactlythe same filter code structure as the BSD Berkeley Packet Filter(BPF), so referring to the BSD bpf.4 manpage is very helpful increating filters.LSF is much simpler than BPF. One does not have to worry aboutdevices or anything like that. You simply create your filtercode, send it to the kernel via the SO_ATTACH_FILTER ioctl andif your filter code passes the kernel check on it, you thenimmediately begin filtering data on that socket.You can also detach filters from your socket via theSO_DETACH_FILTER ioctl. This will probably not be used muchsince when you close a socket that has a filter on it thefilter is automagically removed. The other less common casemay be adding a different filter on the same socket where you had anotherfilter that is still running: the kernel takes care of removingthe old one and placing your new one in its place, assuming yourfilter has passed the checks, otherwise if it fails the old filterwill remain on that socket.Examples========Ioctls-setsockopt(sockfd, SOL_SOCKET, SO_ATTACH_FILTER, &Filter, sizeof(Filter));setsockopt(sockfd, SOL_SOCKET, SO_DETACH_FILTER, &value, sizeof(value));See the BSD bpf.4 manpage and the BSD Packet Filter paper written bySteven McCanne and Van Jacobson of Lawrence Berkeley Laboratory.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -