是不是出现很多undefined的错误?这个程序里面有些函数是unix系统提供的API.在Windows下没有这样的函数。你要找出这些函数,分析它们的功能,用相似的Windows Api来代替,或者自己写这些函数。
解决方案 »
- 关于从MFC中添加ActiveX控件没有属性的问题
- 这段OPENGL纹理贴图代码蕴藏什么奥妙
- 程序建立一种文件(比如后缀为.PAT),双击该文件就打开程序,而如何在WINDOWS中设置该文件的显示图标?
- 控件尺寸定制的问题?
- 透明控件问题,请指教。
- 一个为VB写的DLL,其中有一个LPSTR&参数输出结果信息,在VC里怎么做?
- 急,在线等!!!!!!!!!!!
- 有关对话框的问题?
- 有关文件读取的问题!
- 关于COleVariant和CString之间的一个怪问题,谨以此贴献给曾经奇怪,正在奇怪,和将来不想奇怪的各位兄弟!!!
- 大家放松一下,进来就有分,答上来的另外开贴,送300分
- 如何判断一个Edit控件具有ES_PASSWORD属性?请帮忙!
//把网卡置于混杂模式
我查了一下以为在 "afxsock.h"中现在再看看好象不是它(同名不同功能)。
我不知道在vc中是什么。来达到同样的功能。
#include "winsock2.h"
#include "stdio.h"
#include "header.h"
#include "string.h"
#pragma comment (lib , "ws2_32.lib")//1. 把网卡置于混杂模式
//2. 捕获数据包
//3. 分析数据包
#define INTERFACE "eth0"
int Open_Raw_Socker();
int Set_Promisc(char *my_interface,int sock);int main()
{
int sock, bytes_recieved, fromlen;
char buffer[65535];
struct sockaddr_in from;
struct ip *ip;
struct tcp *tcp;
sock =Open_Raw_Socker();
Set_Promisc(INTERFACE, sock);
while(1)
{
fromlen = sizeof from;
bytes_recieved = recvfrom(sock, buffer, sizeof buffer, 0, (struct sockaddr *)&from, &fromlen);
printf("\nBytes received ::: %5d\n",bytes_recieved);
printf("Source address ::: %s\n",inet_ntoa(from.sin_addr));
ip = (struct ip *)buffer;
/*See if this is a TCP packet*/
if(ip->ip_protocol == 6)
{
printf("IP header length ::: %d\n",ip->ip_length);
printf("Protocol ::: %d\n",ip->ip_protocol);
tcp = (struct tcp *)(buffer + (4*ip->ip_length));
printf("Source port ::: %d\n",ntohs(tcp->tcp_source_port));
printf("Dest port ::: %d\n",ntohs(tcp->tcp_dest_port));
}
}
return 1;
}int Open_Raw_Socket()
{
int sock;
if((sock = socket(AF_INET, SOCK_RAW, IPPROTO_TCP)) < 0)
{
/*Then the socket was not created properly and must die*/
perror("The raw socket was not created");
exit(0);
};
return(sock);
}int Set_Promisc(char *my_interface, int sock )
{
struct ifreq ifr;
strncpy(ifr.ifr_name,my_interface,strlen(my_interface)+1);
if((ioctl(sock, SIOCGIFFLAGS, &ifr) == -1))
{
/*Could not retrieve flags for the interface*/
perror("Could not retrive flags for the interface");
exit(0);
}
printf("THE interface is ::: %s \n",my_interface);
perror("Retrieved flags from interface successfully");
ifr.ifr_flags |= IFF_PROMISC;
if (ioctl(sock, SIOCSIFFLAGS, &ifr) == -1 ) //ioctl我不知道怎么改
{
/*Could not set the flags on the interface */
perror("Could not set the PROMISC flag:");
exit(0);
}
printf(" Setting interface :::%s ::: to promisc",my_interface);
return(0);
}
我在编com的服务端。加以下语句,他编译不通过。(exectuable)
#include"winsock2.h"
char FAR *hname=NULL;
int h=gethostname((char FAR *)hname,sizeof(hname));
使用DeviceIOControl代替ioctl。
祝你好运。
我在网上找了NT 下的SNIFF ,同样谢谢你等会儿给你分。
我还想问 我是照CSDN上的开发文挡中的 实战COM(04)----创建一个DCOM应用.htm
1.
我在编com的服务端。加以下语句,他编译不通过。(exectuable)不加可以。
#include"winsock2.h"
char FAR *hname=NULL;
int h=gethostname((char FAR *)hname,sizeof(hname));
2.我编的com在自己的机子上能连到服务端返回我想要的(原来),
但是当我把服务端拷到其他的机子上, 我自己机子上的服务端也配置(dcomcnfg)好了,
执行时create com failed。我这里是(NT 4。0)
然后,我自己机子上的服务端恢复成默认,连原来可以的现在也不行了。