capset({version=_LINUX_CAPABILITY_VERSION_3, pid=0}, {effective=1<<CAP_NET_RAW, permitted=1<<CAP_NET_ADMIN|1<<CAP_NET_RAW, inheritable=0}) = 0 socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP) = -1 EACCES (Permission denied) socket(AF_INET, SOCK_RAW, IPPROTO_ICMP) = 3 socket(AF_INET...
sd = socket(PF_INET, SOCK_RAW, IPPROTO_UDP);if(sd <0) {perror("raw error");exit(2);} if(setsockopt(sd, IPPROTO_IP, IP_HDRINCL, val,sizeof(one)) <0) {perror("setsockopt error");exit(2);}sin.sin_family = AF_INET;sin.sin_port = htons(dst_port); sin.sin_addr.s_addr = ...
ip_fd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP); if(ip_fd < 0) { fprintf(stderr, “raw socket error.n”); exit(1); } /*改变进程的用户ID, 回收root权限,设置当前用户权限*/ setuid(getpid); ping(argv[1]); } @ping框架的建立ping.c用于初始化ping相关信息及端口信息 #include “commo...
capset({version=_LINUX_CAPABILITY_VERSION_3, pid=0}, {effective=1<<CAP_NET_RAW, permitted=1<<CAP_NET_ADMIN|1<<CAP_NET_RAW, inheritable=0}) = 0 socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP) = -1 EACCES (Permission denied) socket(AF_INET, SOCK_RAW, IPPROTO_ICMP) = 3 socket(AF_INET...
socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP) = 3 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 setsockopt(3, SOL_IPV6, IPV6_V6ONLY, [1], 4) = 0 bind(3, {sa_family=AF_INET6, sin6_port=htons(8888), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, "::", &sin6_...
<sys/socket.h> 创建一个套接字 domain: AF_INET:IPv4协议 AF_INET6:IPv6协议 AF_LOCAL:Unix域协议 AF_ROUTE:路由套接口 AF_KEY:密钥套接口 type: SOCKET_STREAM:双向可靠数据流,对应TCP SOCKET_DGRAM:双向不可靠数据报,对应UDP SOCKET_RAW:提供传输层以下的协议,可以访问内部网络接口,例如接收和发送ICMP报文...
socket(AF_INET, SOCK_RAW, IPPROTO_ICMP) = 3 socket(AF_INET6, SOCK_DGRAM, IPPROTO_ICMPV6) = -1 EACCES (Permission denied) socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6) = 4 capget({version=_LINUX_CAPABILITY_VERSION_3, pid=0}, NULL) = 0 ...
`AF_INET` 是 Linux 系统中的一个网络协议族常量,它代表 IPv4 网络协议。在 Linux 中,网络编程通常会涉及到套接字(socket)的使用,而套接字可以通过指定不同的协议族来进行...
数据报socket(SOCK_DGRAM ) 数据报套接字定义了一种无连接的服 ,数据通过相互独立的报文进行传输,是无序的,并且不保证是可靠、无差错的。它使用数据报协议UDP。 原始socket(SOCK_RAW) 原始套接字允许对底层协议如IP或ICMP进行直接访问,功能强大但使用较为不便,主要用于一些协议的开发。
sd = socket(PF_INET, SOCK_RAW, IPPROTO_UDP);if (sd < 0) {perror("raw error");exit(2);} if(setsockopt(sd, IPPROTO_IP, IP_HDRINCL, val, sizeof(one)) < 0) {perror("setsockopt() error");exit(2);}sin.sin_family = AF_INET;sin.sin_port = htons(dst_port); ...