当前位置: 技术问答>linux和unix
(菜鸟飞飞)原始套接字ICMP包无法接收(谢谢回答,急着用哈)
来源: 互联网 发布时间:2016-11-24
本文导语: #include "stdio.h" #include #include #include #include #include #include #include #define BUFFER_MAX 2048 int main() { int sock, n_read, proto; char buffer[BUFFER_MAX]; char *ethhead, *iphead, *tcphead, ...
#include "stdio.h"
#include
#include
#include
#include
#include
#include
#include
#define BUFFER_MAX 2048
int main()
{
int sock, n_read, proto;
char buffer[BUFFER_MAX];
char *ethhead, *iphead, *tcphead,
*udphead, *icmphead, *p;
struct sockaddr_in recvAddr;
int nLen = sizeof(recvAddr);
bzero(&recvAddr,sizeof(recvAddr));
recvAddr.sin_family=AF_INET;
if((sock = socket(AF_INET, SOCK_RAW,IPPROTO_ICMP))