常常有些朋友在Linux论坛问一些问题,不过,其中大多数的问题都是很基的。
icintget_dest_addr(constchar*hostid,structether_addr*eaddr)
{
structether_addr*eap;</P>eap=ether_aton(hostid);
if(eap){
*eaddr=*eap;
if(debug)
fprintf(stderr,"Thetargetstationaddressis%s.\n",
ether_ntoa(eaddr));
}elseif(ether_hostton(hostid,eaddr)==0){
if(debug)
fprintf(stderr,"Stationaddressforhostname%sis%s.\n",
hostid,ether_ntoa(eaddr));
}else{
(void)fprintf(stderr,
"ether-wake:TheMagicPackethostaddressmustbe"
"specifiedas\n"
"-astationaddress,00:11:22:33:44:55,or\n"
"-ahostnamewithaknownethersentry.\n");
return-1;
}
return0;
}
staticintget_fill(unsignedchar*pkt,structether_addr*eaddr)
{
intoffset,i;
unsignedchar*station_addr=eaddr->ether_addr_octet;
if(opt_broadcast)
memset(pkt+0,0xff,6);
else
memcpy(pkt,station_addr,6);
memcpy(pkt+6,station_addr,6);
pkt[12]=0x08;/*Or0x0806forARP,0x8035forRARP*/
pkt[13]=0x42;
offset=14;
memset(pkt+offset,0xff,6);
offset+=6;
for(i=0;i<16;i++){
memcpy(pkt+offset,station_addr,6);
offset+=6;
}
if(debug){
fprintf(stderr,"Packetis");
for(i=0;i<offset;i++)
fprintf(stderr,"%2.2x",pkt);
fprintf(stderr,".\n");
}
returnoffset;
}
staticintget_wol_pw(constchar*optarg)
{
intpasswd[6];
intbyte_cnt;
inti;
byte_cnt=sscanf(optarg,"%2x:%2x:%2x:%2x:%2x:%2x",
&passwd[0],&passwd[1],&passwd[2],
&passwd[3],&passwd[4],&passwd[5]);
if(byte_cnt<4)
byte_cnt=sscanf(optarg,"%d.%d.%d.%d",
&passwd[0],&passwd[1],&passwd[2],&passwd[3]);
if(byte_cnt<4){
fprintf(stderr,"UnabletoreadtheWake-On-LANpassword.\n");
return0;
}
printf("TheMagicpacketpasswordis%2.2x%2.2x%2.2x%2.2x(%d).\n",
passwd[0],passwd[1],passwd[2],passwd[3],byte_cnt);
for(i=0;i<byte_cnt;i++)
wol_passwd=passwd;
returnwol_passwd_sz=byte_cnt;
}
#if0
{
to=(structsockaddr_in*)&whereto;
to->sin_family=AF_INET;
if(inet_aton(target,&to->sin_addr)){
上一页12345下一页
给你装的系统里为ubuntu12.04,它已经封装的很臃肿了,但是考虑到你没有很多时间投入其中,所以给你装了它,但是怎么用它提高开发效率,需要你在学习的过程中不断总结; |