以前一直用wine装的网通插件,就是装好后运行ishare_user.exe的那个。最近插件突然不能用了,重装老是在装winpcap那儿报错,没办法,就google了另一个方法。
(不知道怎么发附件,只好贴源代码了……)
1.copy下面的源代码,保存成drcom.c(名字其实无所谓)
#include <stdio.h>
#include <string.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
typedef struct _code2 {
char sign;
char type;
short len;
int id;
int code0;
int code1;
}code2;
typedef struct _code3 {
char sign;
char type;
short len;
int id;
int unk0;
int code1;
int unk1;
int code0;
int check;
int unk2;
char mac[6];
char dhcp;
char devtype;
int ipaddr;
int netmask;
char padding[48];
}code3;
int waitdata(int hsocket, int time)
{
fd_set fds;
struct timeval tv;
FD_ZERO(&fds);
FD_SET(hsocket,&fds);
tv.tv_usec = time;
tv.tv_sec = 0;
return select(hsocket+1,&fds,NULL,NULL,&tv);
}
main (int argc, char* argv[])
{
struct in_addr ip,netmask,ptp;
char mac[6];
int hsocket;
struct ifreq ifr;
struct sockaddr_in sin;
struct sockaddr *sa = (struct sockaddr *) &sin;
int fromlen;
struct sockaddr_in *sin_ptr;
u_char *ptr;
u_long *ptr_long;
int n;
int check;
char c1[] = {7,1,8,0,1,0,0,0};
code2 c2;
code3 c3;
char c4[512];
int sendlen, recvlen;
int errorcount,workwell,noticed=0;
printf("\nFree Dr.COM for Linux v0.3\n mengxp works,2009 @ xiyou\n \n\n");
init:
if ((hsocket = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
{
perror( "socket error!");
return 0;
}
errorcount = 0;
strcpy(ifr.ifr_name, "ppp0");
if (ioctl(hsocket, SIOCGIFADDR, &ifr) < 0)
{
// perror("ioctl SIOCGIFADDR error");
errorcount++;
}
sin_ptr = (struct sockaddr_in *)&ifr.ifr_addr;
ip = sin_ptr->sin_addr;
if (ioctl(hsocket, SIOCGIFNETMASK, &ifr) < 0)
{
// perror("ioctl SIOCGIFNETMASK error");
errorcount++;
}
sin_ptr = (struct sockaddr_in *)&ifr.ifr_addr;
netmask = sin_ptr->sin_addr;
if (ioctl(hsocket, SIOCGIFDSTADDR, &ifr) < 0)
{
// perror("ioctl SIOCGIFDSTADDR error");
errorcount++;
}
sin_ptr = (struct sockaddr_in *)&ifr.ifr_addr;
ptp = sin_ptr->sin_addr;
memset(&mac,0,6);
if(errorcount)
{
close(hsocket);
if(!noticed)
printf("couldn't get ppp0 interface!\nplease check your connection!\n\n");
noticed++;
sleep(3);
goto init;
}
else
noticed = 0;
printf("ppp0 interface:\n");
printf(" IP: %s\n", inet_ntoa(ip));
printf(" NetMask: %s\n", inet_ntoa(netmask));
printf(" Server: %s\n\n", inet_ntoa(ptp));