仿真平台内核初版 -tlib库 包含<sparc arm riscv powerPC>
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.21022</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{7CA1E07C-DB49-40B6-820A-5A8F1370127B}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AssemblyName>ConstructingPackets</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
|
||||
<RootNamespace>ConstructingPackets</RootNamespace>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<UpgradeBackupLocation />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Main.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\PacketDotNet\PacketDotNet.csproj">
|
||||
<Project>{55ABBA4C-AAF9-4726-A592-0C92436CEC92}</Project>
|
||||
<Name>PacketDotNet</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
41
lib/Packet.Net/Examples/ConstructingPackets/Main.cs
Normal file
41
lib/Packet.Net/Examples/ConstructingPackets/Main.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using PacketDotNet;
|
||||
|
||||
namespace ConstructingPackets
|
||||
{
|
||||
/// <summary>
|
||||
/// Example that shows how to construct a packet using packet constructors
|
||||
/// to build a tcp/ip ipv4 packet
|
||||
/// </summary>
|
||||
class MainClass
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
ushort tcpSourcePort = 123;
|
||||
ushort tcpDestinationPort = 321;
|
||||
var tcpPacket = new TcpPacket(tcpSourcePort, tcpDestinationPort);
|
||||
|
||||
var ipSourceAddress = System.Net.IPAddress.Parse("192.168.1.1");
|
||||
var ipDestinationAddress = System.Net.IPAddress.Parse("192.168.1.2");
|
||||
var ipPacket = new IPv4Packet(ipSourceAddress, ipDestinationAddress);
|
||||
|
||||
var sourceHwAddress = "90-90-90-90-90-90";
|
||||
var ethernetSourceHwAddress = System.Net.NetworkInformation.PhysicalAddress.Parse(sourceHwAddress);
|
||||
var destinationHwAddress = "80-80-80-80-80-80";
|
||||
var ethernetDestinationHwAddress = System.Net.NetworkInformation.PhysicalAddress.Parse(destinationHwAddress);
|
||||
// NOTE: using EthernetPacketType.None to illustrate that the ethernet
|
||||
// protocol type is updated based on the packet payload that is
|
||||
// assigned to that particular ethernet packet
|
||||
var ethernetPacket = new EthernetPacket(ethernetSourceHwAddress,
|
||||
ethernetDestinationHwAddress,
|
||||
EthernetPacketType.None);
|
||||
|
||||
// Now stitch all of the packets together
|
||||
ipPacket.PayloadPacket = tcpPacket;
|
||||
ethernetPacket.PayloadPacket = ipPacket;
|
||||
|
||||
// and print out the packet to see that it looks just like we wanted it to
|
||||
Console.WriteLine(ethernetPacket.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user