易截截图软件、单文件、免安装、纯绿色、仅160KB

Linux下几例抓包程序代码

抓包程序1 grub_allpacket.c
#include <stdio.h>
#include <string.h>
#include <errno.h> 
#include <unistd.h>
#include <sys/socket.h>
#include <sys/types.h> 
#include <linux/in.h>
#include <linux/if_ether.h>
#include <net/if.h>
#include <sys/ioctl.h>
#include <stdlib.h>
int main(int argc, char **argv) {
   int sock, n,i;
   char buffer[2048];
   unsigned char *iphead, *ethhead;
   struct ifreq ethreq;
 
   if ( (sock=socket(PF_PACKET, SOCK_RAW,
                     htons(ETH_P_IP)))<0) {
     perror("socket");
     exit(1);
   }
   /* Set the network card in promiscuos mode */
   strncpy(ethreq.ifr_name,"eth0",IFNAMSIZ);
   if (ioctl(sock,SIOCGIFFLAGS,&ethreq)==-1) {
     perror("ioctl");
     close(sock);
     exit(1);
}
   ethreq.ifr_flags|=IFF_PROMISC;
   if (ioctl(sock,SIOCSIFFLAGS,&ethreq)==-1) {
     perror("ioctl");
     close(sock);
     exit(1);
   }
 
   while (1) {
     printf("----------\n");
     n = recvfrom(sock,buffer,2048,0,NULL,NULL);
     printf("%d bytes read\n",n);
     printf("the frame content is :\n");
     for(i=0;i<n;)
 {
 printf("%02x",(unsigned char)buffer[i]);
 fflush(stdout);
 i=i+1;
 if(i%8==0)
  printf("\n");
 else
  printf(":");
 }
     printf("\n");
     /* Check to see if the packet contains at least
&nbs


相关文档:

实战Linux Bluetooth编程 (七) SDP协议

Service Discovery Protocol(SDP)提供一种能力,让应用程序有方法发现哪种服务可用以及这种服务的特性。
服务发现协议(SDP或Bluetooth SDP)在蓝牙协议栈中对蓝牙环境中的应用程序有特殊的含意,发现哪个服务是可用的和确定这些可用服务的特征。SDP定义了bluetooth client发现可用bluetooth server服务和它们的特征的方法。 ......

Linux设备模型之input子系统详解

一:前言
最近在研究android的sensor driver,主要是E-compass,其中用到了Linux input子系统.在网上也看了很多这方面的资料,感觉还是这篇分析的比较细致透彻,因此转载一下以便自己学习,同时和大家分享!
(这篇博客主要是以键盘驱动为例的,不过讲解的是Linux Input Subsystem,可以仔细的研究一下!)
键盘驱动将检 ......

Linux下无法mount本机IP的解决方法:

设置dsn后虽然虚拟机可以上网了,但是用户名变成了bogon,而不是之前的localhost,去掉DNS后重启虚拟机就又变成了localhost
然后就可以mount本机了
还有一种方法:
hostname 显示当前主机名
hostname localhost 设置当前主机名为localhost
估计也可以解决上述不能mount的问题。 ......

RHCE——RH033之linux下的打印机

 
system-config-printer        图形界面设置打印机
 
 
BSD(FreeBSD)/System V
 
lpr/lp  打印文件名           打印
lpr  -P打印机名  打印文件名 
lp &nb ......

Linux之路为何如此艰难?






<!--
@page { margin: 2cm }
P { margin-bottom: 0.21cm }
-->
       在本文中,所谓“
Linux
之路”是指通向完美
Linux
桌面的道路。谈起
Linux
桌面,有人不屑一顾,嗤之以鼻。实际情况如何?
 
     11

......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号