📄 sockets.c
字号:
/* sockets.h * linqianghe@163.com * 2006-10-20 */#include <sys/socket.h>#include <stdio.h>#include <unistd.h>#include "config.h"#include "sockets.h"#include "util.h"#include "net-support.h"#include "dummy_ipv4.h"#include "log.h"int skfd = -1; /* generic raw socket desc. */int sockets_open( int family ){ struct aftype **aft; int sfd = -1; static int force = -1; if( force < 0 ){ force = 0; if( kernel_version() < KRELEASE(2, 1, 0) ) force = 1; if( access("/proc/net", R_OK) ) force = 1; } for( aft = aftypes; *aft; aft++ ){ struct aftype *af = *aft; int type = SOCK_DUMMY; if( af->af == AF_UNSPEC ) continue; if( family && family != af->af ) continue; if( af->fd != -1 ){ sfd = af->fd; continue; } if( !family && !force && af->flag_file ){ if (access(af->flag_file, R_OK)) continue; } af->fd = socket(af->af, type, IPPROTO_DUMMY ); if (af->fd >= 0) sfd = af->fd; } if( sfd < 0 ) PR_ERR( "No usable address families found.\n" ); return sfd;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -