调用winpcap发送路由器公告
#include <stdlib.h>
#include <stdio.h> #include <pcap.h> #pragma comment(lib, "packet.lib")
#pragma comment(lib, "wpcap.lib") int main(int argc, char **argv)
{
pcap_t *fp;
char errbuf[PCAP_ERRBUF_SIZE];
u_char packet[];
int i; /* Check the validity of the command line */
if (argc != )
{
printf("usage: %s interface", argv[]);
return ;
} /* Open the adapter */
if ((fp = pcap_open_live(argv[], // name of the device
, // portion of the packet to capture. It doesn't matter in this case
, // promiscuous mode (nonzero means promiscuous)
, // read timeout
errbuf // error buffer
)) == NULL)
{
fprintf(stderr,"\nUnable to open the adapter. %s is not supported by WinPcap\n", argv[]);
return ;
} /* Supposing to be on ethernet, set mac destination to 1:1:1:1:1:1 */
packet[]= 0xbd;
packet[]= 0xbd;
packet[]= 0xbd;
packet[]= 0xbd;
packet[]= 0xbd;
packet[]= 0xbd; /* set mac source to 2:2:2:2:2:2 */
packet[]= 0x00;
packet[]= 0x0e;
packet[]= 0xc6;
packet[]= 0xd6;
packet[]= 0x80;
packet[]= 0x6c; // Eth type
packet[] = 0x86;
packet[] = 0xdd; //IPv6 header
packet[] = 0x60;
packet[] = 0x00;
packet[] = 0x00;
packet[] = 0x00; packet[] = 0x00;
packet[] = 0x24;
packet[] = 0x3a; //next header
packet[] = 0x08; packet[] = 0xfe; // source addr
packet[] = 0x80;
packet[] = 0x00;
packet[] = 0x00; packet[] = 0x00;
packet[] = 0x00;
packet[] = 0x00;
packet[] = 0x00; packet[] = 0x8c;
packet[] = 0x79;
packet[] = 0xe4;
packet[] = 0xf9; packet[] = 0xf5;
packet[] = 0xa3;
packet[] = 0xe5;
packet[] = 0xeb; packet[] = 0xff; // dest addr
packet[] = 0x02;
packet[] = 0x00;
packet[] = 0x00; packet[] = 0x00;
packet[] = 0x00;
packet[] = 0x00;
packet[] = 0x00; packet[] = 0x00;
packet[] = 0x00;
packet[] = 0x00;
packet[] = 0x00; packet[] = 0x00;
packet[] = 0x00;
packet[] = 0x00;
packet[] = 0x01; packet[] = 0x86; // icmp v6 header type
packet[] = 0x00; // code
packet[] = 0xe6; // check sum
packet[] = 0x43; packet[] = 0x08;
packet[] = 0x00;
packet[] = 0x01; // router lifetime
packet[] = 0x10; packet[] = 0x00; // reachable time
packet[] = 0x00;
packet[] = 0x00;
packet[] = 0x00; packet[] = 0x00; // retrans timer
packet[] = 0x00;
packet[] = 0x00;
packet[] = 0x00; packet[] = 0x03; // Option-type
packet[] = 0x04; // Option-length
packet[] = 0x40; // Option-prefix length
packet[] = 0xc0; // Option-L A packet[] = 0xff; // Option-valid lifetime
packet[] = 0xff; // Option-valid lifetime
packet[] = 0xff; // Option-valid lifetime
packet[] = 0xff; // Option-valid lifetime packet[] = 0xff; // Option-prefered lifetime
packet[] = 0xff; // Option-prefered lifetime
packet[] = 0xff; // Option-prefered lifetime
packet[] = 0xff; // Option-prefered lifetime packet[] = 0x00; // Option-reserved
packet[] = 0x00; // Option-reserved
packet[] = 0x00; // Option-reserved
packet[] = 0x00; // Option-reserved packet[] = 0xfc; // Option-prefix
packet[] = 0x00; // Option-prefix
packet[] = 0x00; // Option-prefix
packet[] = 0x00; // Option-prefix packet[] = 0x00; // Option-prefix
packet[] = 0x00; // Option-prefix
packet[] = 0xf8; // Option-prefix
packet[] = 0x02; // Option-prefix packet[] = 0x00; // Option-prefix
packet[] = 0x00; // Option-prefix
packet[] = 0x00; // Option-prefix
packet[] = 0x00; // Option-prefix packet[] = 0x00; // Option-prefix
packet[] = 0x00; // Option-prefix
packet[] = 0x00; // Option-prefix
packet[] = 0x00; // Option-prefix packet[] = 0x2c; // crc
packet[] = 0x6a; // crc
packet[] = 0x46; // crc
packet[] = 0xb5; // crc ///* Fill the rest of the packet */
//for(i=102;i<200;i++)
//{
// packet[i]= (u_char)i;
//} /* Send down the packet */
if (pcap_sendpacket(fp, // Adapter
packet, // buffer with the packet
// size
) != )
{
fprintf(stderr,"\nError sending the packet: %s\n", pcap_geterr(fp));
return ;
} pcap_close(fp);
return ;
}
调用winpcap发送路由器公告的更多相关文章
- sqlserver能否调用webservice发送短信呢?
上班的时候突然有一个想法,sqlserver能否调用webservice发送短信呢? 经过查找资料,终于找到了解决办法,现将步骤贴到下面: (1)开启sqlserver组件功能,如果不开启这个组件功能 ...
- android 中调用接口发送短信
android中可以通过两种方式发送短信 第一:调用系统短信接口直接发送短信:主要代码如下: //直接调用短信接口发短信 SmsManager smsManager = SmsManager.getD ...
- 使用nodejs调用微信发送红包
前置条件:申请微信发送红包的账户及其权限 依赖 blueimg-md5和 xmlreader 库 /common/weixin.js 源码 /** * Created by chent696 on 2 ...
- C#调用Mail发送QQ邮件
需要用到: 1.System.Net.Mail; 2.QQ邮箱的POP3/SMTP服务码 QQ邮箱的POP3/SMTP服务码获取方法: 1.打开qq邮箱: 2.进入设置页面-->账户:(往下翻) ...
- php调用微信发送自定义模版接口
function sendWechatmodel($openid,$data,$go_url)//接受消息的用户openid,发送的消息,点击详情跳转的url { ...
- winpcap 发送接收速率
总体情况: 在不修改winpcap源码的情况下,发包.收包最大速率3包/ms. 收包几个api的速率: 1. m_fp = pcap_open_live(adapter->name, 65536 ...
- iOS调用系统发送短信和邮件分享
//发送邮件 -(void)sendMail:(NSString*)subject content:(NSString*)content{ MFMailComposeViewController*co ...
- Android调用Webservice发送文件
一服务器端C#这里有三个上传方法1.uploadFile( byte []bs, String fileName); PC机操作是没有问题2. uploadImage(String filename, ...
- 一次ajax调用,发送了两次请求(一次为请求方法为option,一次为正常请求)
在项目了开发时遇见一个奇怪的现象,就是我在js里面发送一次ajax请求,在浏览器network那边查询到的却是发送了两次请求,第一次的Request Method参数为OPTIONS,第二次的Requ ...
随机推荐
- 理解 SQL 开窗函数
一次面试被问到开窗函数,懵逼了,赶紧补补总结一下.... 开窗函数也是函数,所以 比如在原来的查询上添加一个总数列 create table ztest( id int identity, c1 in ...
- python中方法调用和函数调用的区别
函数调用: 传几个参数,就会有几个实参方法调用: 默认传递一个参数self,至少要定义一个形参
- Java 添加、修改、读取、复制、删除Excel批注
本文介绍通过Java程序来操作Excel批注的方法.操作内容包括批注添加(添加批注文本.背景色.字体.自适应等).修改.读取(文本.图片).复制.删除等. 工具:Free Spire.XLS for ...
- 数学基础系列(六)----特征值分解和奇异值分解(SVD)
一.介绍 特征值和奇异值在大部分人的印象中,往往是停留在纯粹的数学计算中.而且线性代数或者矩阵论里面,也很少讲任何跟特征值与奇异值有关的应用背景. 奇异值分解是一个有着很明显的物理意义的一种方法,它可 ...
- Identity 4 -1创建一个登录中心
准备知识 官网地址:https://identityserver4.readthedocs.io/ 通过nuget安装 Identity Server4
- JAVA中值传递,引用传递
刚在写一个用例,需要在方法中改变传递的参数的值,可是java中只有传值调用,没有传址调用.所以在java方法中改变参数的值是行不通的.但是可以改变引用变量的属性值. 可以仔细理解一下下面几句话: 1. ...
- 使用LD_PRELOAD注入程序
LD_PRELOAD是Linux系统的一个环境变量,它可以影响程序的运行时的链接(Runtime linker),它允许你定义在程序运行前优先加载的动态链接库.这个功能主要就是用来有选择性的载入不同动 ...
- JDK源码之Byte类分析
一 简介 byte,即字节,由8位的二进制组成.在Java中,byte类型的数据是8位带符号的二进制数,以二进制补码表示的整数 取值范围:默认值为0,最小值为-128(-2^7);最大值是127(2^ ...
- 1240: 函数strcmp的设计
#include <string.h>#include <stdio.h>int mycmp(char*s1,char*s2);int main(){ int sum; cha ...
- 计算机网络基础:TCP和UDP
UDP(用户数据报协议) 应用场景:一个数据包就能完成数据通信:不需要建立会话和流量控制:多播.广播:是一种不可靠传输.(例如QQ聊天,屏幕广播) UDP协议特点: UDP是无连接的,即发送数据之前不 ...