Skip to content

Commit

Permalink
updated Packet.NET 0.11.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
seuffert committed Nov 17, 2011
1 parent b01ac95 commit 71ae210
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 11 deletions.
14 changes: 11 additions & 3 deletions PacketDotNet/ARPPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ You should have received a copy of the GNU Lesser General Public License
along with PacketDotNet. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Copyright 2009 Chris Morgan <chmorgan@gmail.com>
* Copyright 2011 Chris Morgan <chmorgan@gmail.com>
*/
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -137,7 +137,7 @@ virtual public ARPOperation Operation
}

/// <value>
/// Upper layer protocol address of the sender, typically an IPv4 or IPv6 address
/// Upper layer protocol address of the sender, arp is used for IPv4, IPv6 uses NDP
/// </value>
virtual public System.Net.IPAddress SenderProtocolAddress
{
Expand All @@ -150,6 +150,10 @@ virtual public System.Net.IPAddress SenderProtocolAddress

set
{
// check that the address family is ipv4
if (value.AddressFamily != System.Net.Sockets.AddressFamily.InterNetwork)
throw new System.InvalidOperationException("Family != IPv4, ARP is used for IPv4, NDP for IPv6");

byte[] address = value.GetAddressBytes();
Array.Copy(address, 0,
header.Bytes, header.Offset + ARPFields.SenderProtocolAddressPosition,
Expand All @@ -158,7 +162,7 @@ virtual public System.Net.IPAddress SenderProtocolAddress
}

/// <value>
/// Upper layer protocol address of the target, typically an IPv4 or IPv6 address
/// Upper layer protocol address of the target, arp is used for IPv4, IPv6 uses NDP
/// </value>
virtual public System.Net.IPAddress TargetProtocolAddress
{
Expand All @@ -171,6 +175,10 @@ virtual public System.Net.IPAddress TargetProtocolAddress

set
{
// check that the address family is ipv4
if (value.AddressFamily != System.Net.Sockets.AddressFamily.InterNetwork)
throw new System.InvalidOperationException("Family != IPv4, ARP is used for IPv4, NDP for IPv6");

byte[] address = value.GetAddressBytes();
Array.Copy(address, 0,
header.Bytes, header.Offset + ARPFields.TargetProtocolAddressPosition,
Expand Down
2 changes: 1 addition & 1 deletion PacketDotNet/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.

[assembly: AssemblyVersion("0.9.0")]
[assembly: AssemblyVersion("0.11.0")]

// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
Expand Down
8 changes: 7 additions & 1 deletion PacketDotNet/ICMPv4TypeCodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ public enum ICMPv4TypeCodes : ushort
Unreachable_PrecedenceCutoffInEffect = 0x030F,

SourceQuench = 0x0400,
AlternateHostAddress = 0x0500,

AlternateHostAddress = 0x0500, // preserved for backwards compatibility
Redirect_Network = 0x0500,
Redirect_Host = 0x0501,
Redirect_TypeOfServiceAndNetwork = 0x0502,
Redirect_TypeOfServiceAndHost = 0x0503,

Unassigned3 = 0x0700,
EchoRequest = 0x0800,
RouterAdvertisement = 0x0900,
Expand Down
3 changes: 1 addition & 2 deletions PacketDotNet/PacketDotNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
<GenerateDocumentation>true</GenerateDocumentation>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=a5715cc6d5c3540b, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<Reference Include="log4net">
<HintPath>Libraries\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
Expand Down
23 changes: 19 additions & 4 deletions PacketDotNet/TcpPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@ virtual public bool ValidTCPChecksum
}
}

private int AllFlags
/// <summary>
/// Flags, 9 bits
/// TODO: Handle the NS bit
/// </summary>
public byte AllFlags
{
get
{
Expand Down Expand Up @@ -292,9 +296,9 @@ virtual public bool CWR
private void setFlag(bool on, int MASK)
{
if (on)
AllFlags = AllFlags | MASK;
AllFlags = (byte)(AllFlags | MASK);
else
AllFlags = AllFlags & ~MASK;
AllFlags = (byte)(AllFlags & ~MASK);
}

/// <summary> Fetch ascii escape sequence of the color associated with this packet type.</summary>
Expand Down Expand Up @@ -482,7 +486,18 @@ private List<Option> ParseOptions(byte[] optionBytes)
while(offset < optionBytes.Length)
{
type = (OptionTypes)optionBytes[offset + Option.KindFieldOffset];
length = optionBytes[offset + Option.LengthFieldOffset];

// some options have no length field, we cannot read
// the length field if it isn't present or we risk
// out-of-bounds issues
if((type == OptionTypes.EndOfOptionList) ||
(type == OptionTypes.NoOperation))
{
length = 1;
} else
{
length = optionBytes[offset + Option.LengthFieldOffset];
}

switch(type)
{
Expand Down

0 comments on commit 71ae210

Please sign in to comment.