1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. #include <pcap.h>
  5.  
  6. #pragma comment(lib, "packet.lib")
  7. #pragma comment(lib, "wpcap.lib")
  8.  
  9. int main(int argc, char **argv)
  10. {
  11. pcap_t *fp;
  12. char errbuf[PCAP_ERRBUF_SIZE];
  13. u_char packet[];
  14. int i;
  15.  
  16. /* Check the validity of the command line */
  17. if (argc != )
  18. {
  19. printf("usage: %s interface", argv[]);
  20. return ;
  21. }
  22.  
  23. /* Open the adapter */
  24. if ((fp = pcap_open_live(argv[], // name of the device
  25. , // portion of the packet to capture. It doesn't matter in this case
  26. , // promiscuous mode (nonzero means promiscuous)
  27. , // read timeout
  28. errbuf // error buffer
  29. )) == NULL)
  30. {
  31. fprintf(stderr,"\nUnable to open the adapter. %s is not supported by WinPcap\n", argv[]);
  32. return ;
  33. }
  34.  
  35. /* Supposing to be on ethernet, set mac destination to 1:1:1:1:1:1 */
  36. packet[]= 0xbd;
  37. packet[]= 0xbd;
  38. packet[]= 0xbd;
  39. packet[]= 0xbd;
  40. packet[]= 0xbd;
  41. packet[]= 0xbd;
  42.  
  43. /* set mac source to 2:2:2:2:2:2 */
  44. packet[]= 0x00;
  45. packet[]= 0x0e;
  46. packet[]= 0xc6;
  47. packet[]= 0xd6;
  48. packet[]= 0x80;
  49. packet[]= 0x6c;
  50.  
  51. // Eth type
  52. packet[] = 0x86;
  53. packet[] = 0xdd;
  54.  
  55. //IPv6 header
  56. packet[] = 0x60;
  57. packet[] = 0x00;
  58. packet[] = 0x00;
  59. packet[] = 0x00;
  60.  
  61. packet[] = 0x00;
  62. packet[] = 0x24;
  63. packet[] = 0x3a; //next header
  64. packet[] = 0x08;
  65.  
  66. packet[] = 0xfe; // source addr
  67. packet[] = 0x80;
  68. packet[] = 0x00;
  69. packet[] = 0x00;
  70.  
  71. packet[] = 0x00;
  72. packet[] = 0x00;
  73. packet[] = 0x00;
  74. packet[] = 0x00;
  75.  
  76. packet[] = 0x8c;
  77. packet[] = 0x79;
  78. packet[] = 0xe4;
  79. packet[] = 0xf9;
  80.  
  81. packet[] = 0xf5;
  82. packet[] = 0xa3;
  83. packet[] = 0xe5;
  84. packet[] = 0xeb;
  85.  
  86. packet[] = 0xff; // dest addr
  87. packet[] = 0x02;
  88. packet[] = 0x00;
  89. packet[] = 0x00;
  90.  
  91. packet[] = 0x00;
  92. packet[] = 0x00;
  93. packet[] = 0x00;
  94. packet[] = 0x00;
  95.  
  96. packet[] = 0x00;
  97. packet[] = 0x00;
  98. packet[] = 0x00;
  99. packet[] = 0x00;
  100.  
  101. packet[] = 0x00;
  102. packet[] = 0x00;
  103. packet[] = 0x00;
  104. packet[] = 0x01;
  105.  
  106. packet[] = 0x86; // icmp v6 header type
  107. packet[] = 0x00; // code
  108. packet[] = 0xe6; // check sum
  109. packet[] = 0x43;
  110.  
  111. packet[] = 0x08;
  112. packet[] = 0x00;
  113. packet[] = 0x01; // router lifetime
  114. packet[] = 0x10;
  115.  
  116. packet[] = 0x00; // reachable time
  117. packet[] = 0x00;
  118. packet[] = 0x00;
  119. packet[] = 0x00;
  120.  
  121. packet[] = 0x00; // retrans timer
  122. packet[] = 0x00;
  123. packet[] = 0x00;
  124. packet[] = 0x00;
  125.  
  126. packet[] = 0x03; // Option-type
  127. packet[] = 0x04; // Option-length
  128. packet[] = 0x40; // Option-prefix length
  129. packet[] = 0xc0; // Option-L A
  130.  
  131. packet[] = 0xff; // Option-valid lifetime
  132. packet[] = 0xff; // Option-valid lifetime
  133. packet[] = 0xff; // Option-valid lifetime
  134. packet[] = 0xff; // Option-valid lifetime
  135.  
  136. packet[] = 0xff; // Option-prefered lifetime
  137. packet[] = 0xff; // Option-prefered lifetime
  138. packet[] = 0xff; // Option-prefered lifetime
  139. packet[] = 0xff; // Option-prefered lifetime
  140.  
  141. packet[] = 0x00; // Option-reserved
  142. packet[] = 0x00; // Option-reserved
  143. packet[] = 0x00; // Option-reserved
  144. packet[] = 0x00; // Option-reserved
  145.  
  146. packet[] = 0xfc; // Option-prefix
  147. packet[] = 0x00; // Option-prefix
  148. packet[] = 0x00; // Option-prefix
  149. packet[] = 0x00; // Option-prefix
  150.  
  151. packet[] = 0x00; // Option-prefix
  152. packet[] = 0x00; // Option-prefix
  153. packet[] = 0xf8; // Option-prefix
  154. packet[] = 0x02; // Option-prefix
  155.  
  156. packet[] = 0x00; // Option-prefix
  157. packet[] = 0x00; // Option-prefix
  158. packet[] = 0x00; // Option-prefix
  159. packet[] = 0x00; // Option-prefix
  160.  
  161. packet[] = 0x00; // Option-prefix
  162. packet[] = 0x00; // Option-prefix
  163. packet[] = 0x00; // Option-prefix
  164. packet[] = 0x00; // Option-prefix
  165.  
  166. packet[] = 0x2c; // crc
  167. packet[] = 0x6a; // crc
  168. packet[] = 0x46; // crc
  169. packet[] = 0xb5; // crc
  170.  
  171. ///* Fill the rest of the packet */
  172. //for(i=102;i<200;i++)
  173. //{
  174. // packet[i]= (u_char)i;
  175. //}
  176.  
  177. /* Send down the packet */
  178. if (pcap_sendpacket(fp, // Adapter
  179. packet, // buffer with the packet
  180. // size
  181. ) != )
  182. {
  183. fprintf(stderr,"\nError sending the packet: %s\n", pcap_geterr(fp));
  184. return ;
  185. }
  186.  
  187. pcap_close(fp);
  188. return ;
  189. }

调用winpcap发送路由器公告的更多相关文章

  1. sqlserver能否调用webservice发送短信呢?

    上班的时候突然有一个想法,sqlserver能否调用webservice发送短信呢? 经过查找资料,终于找到了解决办法,现将步骤贴到下面: (1)开启sqlserver组件功能,如果不开启这个组件功能 ...

  2. android 中调用接口发送短信

    android中可以通过两种方式发送短信 第一:调用系统短信接口直接发送短信:主要代码如下: //直接调用短信接口发短信 SmsManager smsManager = SmsManager.getD ...

  3. 使用nodejs调用微信发送红包

    前置条件:申请微信发送红包的账户及其权限 依赖 blueimg-md5和 xmlreader 库 /common/weixin.js 源码 /** * Created by chent696 on 2 ...

  4. C#调用Mail发送QQ邮件

    需要用到: 1.System.Net.Mail; 2.QQ邮箱的POP3/SMTP服务码 QQ邮箱的POP3/SMTP服务码获取方法: 1.打开qq邮箱: 2.进入设置页面-->账户:(往下翻) ...

  5. php调用微信发送自定义模版接口

     function sendWechatmodel($openid,$data,$go_url)//接受消息的用户openid,发送的消息,点击详情跳转的url        {           ...

  6. winpcap 发送接收速率

    总体情况: 在不修改winpcap源码的情况下,发包.收包最大速率3包/ms. 收包几个api的速率: 1. m_fp = pcap_open_live(adapter->name, 65536 ...

  7. iOS调用系统发送短信和邮件分享

    //发送邮件 -(void)sendMail:(NSString*)subject content:(NSString*)content{ MFMailComposeViewController*co ...

  8. Android调用Webservice发送文件

    一服务器端C#这里有三个上传方法1.uploadFile( byte []bs, String fileName); PC机操作是没有问题2. uploadImage(String filename, ...

  9. 一次ajax调用,发送了两次请求(一次为请求方法为option,一次为正常请求)

    在项目了开发时遇见一个奇怪的现象,就是我在js里面发送一次ajax请求,在浏览器network那边查询到的却是发送了两次请求,第一次的Request Method参数为OPTIONS,第二次的Requ ...

随机推荐

  1. 1、使用 as 而不要用 is

    public class ShouldAsNotIs { public void ShouldAs() { object a = new ShouldAsNotIs(); var b = a as S ...

  2. dp-划分数 (递推)

    问题描述 : 有 n 个无区别的物品 , 将他们分成 不超过 m 堆, 问有多少种分法 ? 例如 : n = 4 , m = 3 , 则总共有的分法是 1 + 2 +1 , 0 + 1 + 3 , 0 ...

  3. 理解Stream(一)——串行与终止操作

    Java 8 stream特性是一个能快速降低开发人员工作量的语法糖,用起来很简单,用好了很难.这里就通过一系列的博客对几个常见的错误进行解释说明,并给出替代方法.这里先说明串行和终止操作. 首先,给 ...

  4. 深入理解Java虚拟机-类加载连接和初始化解析

    不管学习什么,我一直追求的是知其然,还要知其所以然,对真理的追求可以体现在方方面面.人生短短数十载,匆匆一世似烟云,我认为,既然来了,就应该留下一些有意义的东西.本系列文章是结合张龙老师的<深入 ...

  5. git 其它补充(版本)

    1.给源码贡献力量(当自己比较牛逼时) pull request 2..gitignore文件 在创建仓库的时候可以进行设置 3.版本 git tag -a v1.0 -m '版本介绍' 本地创建Ta ...

  6. python 安装虚拟环境virtualenv

    1.sudo apt install virtualenv 安装失败 2.sudo apt-get update 更新失败 提示: E: 仓库 “http://mirrors.aliyun.com/u ...

  7. Idea破解至2089年

    我是用的版本是2018.3.6,别的朋友使用的是2019的某个版本,不过关都不影响破解 下载jar包:链接:https://pan.***baidu.***com/s/1aRR0***2YNI9jew ...

  8. 对于kvm配置ssh

    首先我们要让自己的机器开启ssh服务 首先更新源 sudo apt-get update 安装ssh服务 sudo apt-get install openssh-server 检测是否已启动 ps ...

  9. linux C++类中成员变量和函数的使用

    1.undefined reference to XXX 问题原因 1)XXX所在的so库等未指定 2)XXX在类中实现的时候没有加上类::函数的格式 2. was not declared in t ...

  10. 爬虫之协程,selenium

    1.什么是代理?代理和爬虫之间的关联是什么? 2.在requests的get和post方法常用的参数有哪些?分别有什么作用?(四个参数) - url headers parmas/data proxi ...