当前位置: 技术问答>linux和unix
linux下如何抓取发给非本机的ip数据包
来源: 互联网 发布时间:2015-12-31
本文导语: int main(int argc,char **argv) { int sockfd; struct sockaddr_in addr; char RecvBuf[MAX_PACK_LEN]; int bind_rc; int len; bzero(&addr,sizeof(struct sockaddr_in)); addr.sin_family=AF_INET; addr.sin_port=htons(port1); addr.sin_addr.s_addr = INAD...
int main(int argc,char **argv)
{
int sockfd;
struct sockaddr_in addr;
char RecvBuf[MAX_PACK_LEN];
int bind_rc;
int len;
bzero(&addr,sizeof(struct sockaddr_in));
addr.sin_family=AF_INET;
addr.sin_port=htons(port1);
addr.sin_addr.s_addr = INADDR_ANY;
sockfd=socket(AF_INET,SOCK_RAW,IPPROTO_UDP);
if(sockfd
{
int sockfd;
struct sockaddr_in addr;
char RecvBuf[MAX_PACK_LEN];
int bind_rc;
int len;
bzero(&addr,sizeof(struct sockaddr_in));
addr.sin_family=AF_INET;
addr.sin_port=htons(port1);
addr.sin_addr.s_addr = INADDR_ANY;
sockfd=socket(AF_INET,SOCK_RAW,IPPROTO_UDP);
if(sockfd