欢迎光临
我们一直在努力

dnsmasq是什么意思,dnsmasq ipset

DNSmasq 代码分析 代码流程分析 遇到的知识点 od shell命令/dev/urandom实现引导时启动setjump & longjump jump_bufSLAACgetopt & getopt_long 函数DHCP服务器如何知道 DNS server and route 6.4节ACD技术PXE(Preboot Execution Enviroment)预启动执行环境strtok 函数uname函数实现read write时的注意关闭文件描述符的注意判断linux版本 (ipset.c line 88 ipset_init 函数)[AF_NETLINK & IPPROTO_RAW 选项](# 15-> AF_NETLINK & IPPROTO_RAW 选项)readv & writev(聚合读、散布写)[SO_BINDTODEVICE socket选项](# 17-> SO_BINDTODEVICE 选项)inotify 函数[if_nametodeix 函数](# 19-> if_nametoindex & if_indextoname)[getpwnam 函数](# 20-> getpwnam函数)[设置文件描述符 NONBLOCK](# 21-> 设置文件描述符 NONBLOCK)safe_pip & safe_malloc & wine_malloc Code(详细见dnsmasq源码)[chown & fchown & lchown 函数](# 23-> chown & fchown & lchown 函数)difftime 函数 遇到知识点解答 15-> AF_NETLINK & IPPROTO_RAW 选项 IPPROTO_RAW

对于socket(AF_INET, SOCK_RAW, IPPROTO_IP),其原型为
int socket (int domain, int type, int protocol);
1 参数protocol用来指明所要接收的协议包,如果是象IPPROTO_TCP(6)这种非0、非255的协议,当操作系统内核碰到ip头中protocol域和创建socket所使用参数protocol相同的IP包,就会交给这个raw socket来处理,因此,一般来说,要想接收什么样的数据包,就应该在参数protocol里来指定相应的协议。当内核向此raw socket交付数据包的时候,是包括整个IP头的,并且已经是重组好的IP包。
2 如果protocol是IPPROTO_RAW(255),这时候,这个socket只能用来发送IP包,而不能接收任何的数据。发送的数据需要自己填充IP包头,并且自己计算校验和。
3 对于protocol为0(IPPROTO_IP)的raw socket。用于接收任何的IP数据包。其中的校验和和协议分析由程序自己完成。

AF_NETLINK

netlink 凭借其标准的 socket API、模块化实现、异步通信机制、多播机制等等多种优势,成为了内核与越来越多应用程序之间交互的主要方式。在 Linux 的内核中,已经为我们封装了使用 netlink 对特定网络状态变化进行消息通知的功能,这就是著名的 rtnetlink。详细介绍参考IBM学习。

17-> SO_BINDTODEVICE 选项

指定套接字数据收发从哪一个设备。

SO_BINDTODEVICE
Bind this socket to a particular device like “eth0”, as specified in the passed interface name. If the
name is an empty string or the option length is zero, the socket device binding is removed.
———— In man 7 socket

19-> if_nametoindex & if_indextoname

The if_nametoindex() function returns the index of the network interface corresponding to the name ifname.
The if_indextoname() function returns the name of the network interface corresponding to the interface index ifindex. The name is placed in the buffer pointed to by ifname. The buffer must allow for the storage of at least IF_NAMESIZE bytes.

? ———— In man page

20-> getpwnam函数

The getpwnam() function returns a pointer to a structure containing the broken-out fields of the record in the password database (e.g., the local password file /etc/passwd, NIS, and LDAP) that matches the username name.

The getpwuid() function returns a pointer to a structure containing the broken-out fields of the record in the password database that matches the user ID uid.

? ————[nam page]

21-> 设置文件描述符 NONBLOCK /* set NONBLOCK bit on fd: See Stevens 16.6 */int fix_fd(int fd){ int flags; if ((flags = fcntl(fd, F_GETFL)) == -1 || fcntl(fd, 香港vps F_SETFL, flags | O_NONBLOCK) == -1) return 0; return 1;} 23-> chown & fchown & lchown 函数 chown() changes the ownership of the file specified by pathname, which is dereferenced if it is a symbolic link.fchown() changes the ownership of the file referred to by the open file descriptor fd.lchown() is like chown(), but does not dereference symbolic links 35526180

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。