Ubuntu10.04 campus Netcom plug-in solution (Western Mail)

Source: Internet
Author: User
Tags socket error
Install ishare_user.exe with the network plug-in directly installed in wine. Recently, the plug-in suddenly became unavailable. the reinstallation always reports an error when installing winpcap. If there is no way, google has another method. (I don't know how to send attachments, just paste the source code ......) 1. copy the following

Install ishare_user.exe with the network plug-in directly installed in wine. Recently, the plug-in suddenly became unavailable. the reinstallation always reports an error when installing winpcap. If there is no way, google has another method.
(I don't know how to send attachments, just paste the source code ......)
1. copy the source code below and save it as drcom. c (the name doesn't matter)
# Include
# Include
# Include
# Include
# Include
# Include
 
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 [] = };
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 http://www.deadc0de.com/?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 ");
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", inet_ntoa (ptp ));


Sin. sin_addr = ip;
Sin. sin_port = htons (61440 );
Sin. sin_family = AF_INET;
If (bind (hsocket, sa, sizeof (sin) <0)
{
Printf ("can't bind udp port 61440! \ N ");
Return 0;
}


Sin. sin_addr = ptp;
Printf ("Activating connection... \ n ");


Workwell = 0;
Keepalive:
Errorcount = 0;
While (1)
{
Sendlen = sendto (hsocket, & c1, 8, MSG_NOSIGNAL, sa, sizeof (sin ));
If (sendlen <0 | errorcount> = 5)
{
Printf ("socket error! Reinit... \ n ");
Close (hsocket );
Goto init;
}
If (waitdata (hsocket, 1000*1000 ))
{
Fromlen = sizeof (sin );
Recvlen = recvfrom (hsocket, & c2, sizeof (c2), 0, sa, & fromlen );
Ip = sin. sin_addr;
Break;
}
Else
{
Errorcount ++;
Printf ("recv2 timed out \ n ");
}
}

Memset (& c3, 0, 96 );
C3.sign = 7;
C3.len = 96;
C3.id = 3;
C3.code1 = c2.code1;
C3.unk1 = 0x2000200;
C3.code0 = c2.code0;
C3.check = 0x1312fc7;
C3.unk2 = 0x7e;
Memcpy (& c3.mac, & mac, 6 );
C3.devtype = 0x17;
Memcpy (& c3.ipaddr, & ip, 4 );
Memcpy (& c3.netmask, & netmask, 4 );

Ptr_long = (u_long *) & c3;
For (n = 0, check = 0; n <96/4; n ++)
Check ^ = * (ptr_long + n );
C3.check = check * 0x12C4B7E;
C3.unk2 = 0;

Ptr = (u_char *) & c3.mac;
For (n = 0; n <64; n ++)
* (Ptr + n) = (* (ptr + n)> 8-(n & 7) + (* (ptr + n) <(n & 7 ));

Sendlen = sendto (hsocket, & c3, 96, MSG_NOSIGNAL, sa, sizeof (sin ));
If (sendlen <0 | errorcount> = 5)
{
Printf ("socket error! Reinit... \ n ");
Close (hsocket );
Goto init;
}
If (waitdata (hsocket, 1000*1000 ))
{
Fromlen = sizeof (sin );
Recvlen = recvfrom (hsocket, & c2, sizeof (c2), 0, sa, & fromlen );
If (! Workwell)
{
Printf ("Keeping connection active... \ n ");
Workwell ++;
}
}
Else
{
Printf ("recv4 timed out \ n ");
Sleep (1 );
Goto keepalive;
}


Sleep (15 );
Goto keepalive;
Return 0;
}


2. Go to the drcom. c directory on the terminal and run gcc drcom. c-o drcom. (If gcc is not installed, run sudo apt-get install gcc first)
3. Run drcom.
If it is difficult to run at startup, you can add it to startup:
System-> preference-> Start application-> Add, and then add drcom.
China West mail's Netcom can do this, but not necessarily in other places.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.