91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 2KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2021-06-09
  • 語(yǔ)言: 其他
  • 標(biāo)簽: winpcap??tcp??

資源簡(jiǎn)介

winpcap開源包,實(shí)現(xiàn)數(shù)據(jù)鏈路層,網(wǎng)絡(luò)層,傳輸層,的封包技術(shù)!并發(fā)送出去!

資源截圖

代碼片段和文件信息


#include?“stdio.h“
#include?“pcap.h“
#pragma?comment(lib“wpcap.lib“)?
#pragma?comment(lib“WS2_32.lib“)??

struct?EthernetHeader
{
????u_char?DestMAC[6];
????u_char?SourMAC[6];
????u_short?EthType;
};
struct?IpHeader
{
????unsigned?char?Version_HLen;
????unsigned?char?TOS;
????short?Length;
????short?Ident;
????short?Flags_Offset;
????unsigned?char?TTL;
????unsigned?char?Protocol;
????short?Checksum;
????unsigned?int?SourceAddr;
????unsigned?int?DestinationAddr;
};
struct?PsdTcpHeader
{
????unsigned?long?SourceAddr;
????unsigned?long?DestinationAddr;
????char?Zero;
????char?Protcol;
????unsigned?short?TcpLen;
};
struct?TcpHeader
{
????unsigned?short?SrcPort;
????unsigned?short?DstPort;
????unsigned?int?SequenceNum;
????unsigned?int?Acknowledgment;
????unsigned?char?HdrLen;
????unsigned?char?Flags;
????unsigned?short?AdvertisedWindow;
????unsigned?short?Checksum;
????unsigned?short?UrgPtr;
};
unsigned?short?checksum(unsigned?short?*data?int?length)
{
????unsigned?long?temp?=?0;
????while?(length?>?1)
????{
????????temp?+=??*data++;
????????length?-=?sizeof(unsigned?short);
????}
????if?(length)
????{
????????temp?+=?*(unsigned?short*)data;
????}
????temp?=?(temp?>>?16)?+?(temp?&0xffff);
????temp?+=?(temp?>>?16);
????return?(unsigned?short)(~temp);
}

int?main(int?argc?char?**argv)
{
????struct?EthernetHeader?ethernet;
????struct?IpHeader?ip;
????struct?TcpHeader?tcp;
????struct?PsdTcpHeader?ptcp;
????int?Result;
????unsigned?char?SendBuffer[200];
????char?TcpData[]?=?“Tcp?Data?Test.“;
????pcap_if_t?*NetwokDevice;
????pcap_t?*WinpcapHandle;
????pcap_if_t?*Device;
????char?WinpcapError[PCAP_ERRBUF_SIZE];
????int?DeviceIndex?=?0;
????char?DeviceName[100][1000];
????int?i;
????Result?=?pcap_findalldevs(&NetwokDevice?WinpcapError);
????if?(Result?==??-?1)
????{
????????printf(“pcap_findalldevs?Error“);
????????return?0;
????}?for?(Device?=?NetwokDevice?i?=?0;?Device?&&?i?next?i++)
????{
????????printf(“Number?%d:“?i);
????????printf(“%s:“?Device->name);
????????printf(“%s\n“?Device->description);
????????sprintf(DeviceName[i]?“%s“?Device->name);
????}
????for?(;;)
????{
????????printf(“Please?Choose?the?Device?Number:(0-%d)“?i?-?1);
????????scanf(“%d“?&DeviceIndex);
????????if?(DeviceIndex?>?i?-?1?||?DeviceIndex?????????{
????????????printf(“Device?Number?Error\n“);
????????????continue;
????????}
????????else
????????????break;
????}
????WinpcapHandle?=?pcap_open_live(LPCTSTR(DeviceName[DeviceIndex])?65535?1?1000?WinpcapError);
????if?(WinpcapHandle?==?NULL)
????{
????????printf(“pcap_open_live?error“);
????????pcap_freealldevs(NetwokDevice);
????????return?0;
????}
????memset(ðernet?0?sizeof(ethernet));
????BYTE?destmac[8];
????destmac[0]?=?0x00;
????destmac[1]?=?0x11;
????destmac[2]?=?0x22;
????destmac[3]?=?0x33;
????destmac[4]?=?0x44;
????destmac[5]?=?0x55;
????memcpy(ethernet.DestMA

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----

?????文件???????6118??2011-12-05?17:05??maketcppacket.cpp

-----------?---------??----------?-----??----

?????????????????6118????????????????????1


評(píng)論

共有 條評(píng)論