├── SharpPcap ├── .gitignore ├── App.ico ├── SharpPcap.dll.config ├── Readme.Mono ├── PacketArrivalEventHandler.cs ├── CaptureStoppedEventHandler.cs ├── WinPcap │ ├── StatisticsModeEventHandler.cs │ ├── AuthenticationTypes.cs │ ├── UnmanagedStructures.cs │ ├── SendQueueTransmitModes.cs │ ├── CaptureMode.cs │ ├── OpenFlags.cs │ ├── StatisticsModeEventArgs.cs │ ├── RemoteAuthentication.cs │ └── StatisticsModePacket.cs ├── AirPcap │ ├── AirPcapBands.cs │ ├── Win32SafeNativeMethods.cs │ ├── AirPcapMediumType.cs │ ├── AirPcapKeyType.cs │ ├── AirPcapDecryptionState.cs │ ├── AirPcapAdapterId.cs │ ├── AirPcapChannelInfoFlags.cs │ ├── AirPcapValidationType.cs │ ├── AirPcapAdapterBus.cs │ ├── AirPcapLinkTypes.cs │ ├── AirPcapMacFlags.cs │ ├── AirPcapDeviceDescription.cs │ ├── AirPcapVersion.cs │ ├── AirPcapDeviceTimestamp.cs │ └── AirPcapKey.cs ├── PcapException.cs ├── CaptureStoppedEventStatus.cs ├── DeviceNotReadyException.cs ├── StatisticsException.cs ├── NotSupportedOnCaptureFileException.cs ├── WinPcapRequiredException.cs ├── ICaptureStatistics.cs ├── InvalidOperationDuringBackgroundCaptureException.cs ├── DeviceMode.cs ├── Version.cs ├── CaptureEventArgs.cs └── AssemblyInfo.cs ├── cloudlist ├── .settings │ └── .gitignore └── .gitignore ├── PacketDotNet ├── .gitignore ├── Libraries │ └── log4net.dll ├── MiscUtil │ └── Conversion │ │ ├── Endianness.cs │ │ └── LittleEndianBitConverter.cs ├── DataLinkPacket.cs ├── AssemblyInfo.cs ├── SessionPacket.cs ├── IpVersion.cs ├── ApplicationPacket.cs ├── InternetPacket.cs ├── IGMPMessageType.cs ├── PPPProtocol.cs ├── LLDP │ ├── InterfaceNumbering.cs │ ├── AddressFamily.cs │ ├── ChassisSubTypes.cs │ ├── PortSubTypes.cs │ ├── CapabilityOptions.cs │ ├── SystemName.cs │ ├── EndOfLLDPDU.cs │ └── PortDescription.cs ├── PayloadType.cs ├── StringOutputType.cs ├── PPPFields.cs ├── Tcp │ ├── ChecksumAlgorighmType.cs │ ├── Echo.cs │ ├── SACKPermitted.cs │ ├── EchoReply.cs │ ├── EndOfOptions.cs │ ├── NoOperation.cs │ ├── MaximumSegmentSize.cs │ └── AlternateChecksumRequest.cs ├── LinuxSLLType.cs ├── ICMPv6Types.cs ├── Ieee8021QFields.cs ├── Ieee80211 │ ├── DurationField.cs │ ├── RadioTapChannelFlags.cs │ ├── RadioTapFlags.cs │ ├── MacFields.cs │ └── PpiFieldType.cs ├── IeeeP8021PPriorities.cs ├── ICMPv6Fields.cs ├── EthernetFields.cs ├── IpPort.cs ├── PPPoECode.cs ├── UdpFields.cs ├── ICMPv4Fields.cs ├── IGMPv2Fields.cs ├── PPPoEFields.cs └── Utils │ ├── HexPrinter.cs │ └── RandomUtils.cs ├── Mono.Nat ├── .gitignore ├── app.config ├── mono.nat.pc.in ├── ISearcher.cs ├── AssemblyInfo.cs ├── Enums │ ├── ProtocolType.cs │ └── MapState.cs ├── EventArgs │ └── DeviceEventArgs.cs ├── Upnp │ ├── Messages │ │ ├── Responses │ │ │ ├── DeletePortMappingResponseMessage.cs │ │ │ ├── CreatePortMappingResponseMessage.cs │ │ │ └── GetExternalIPAddressResponseMessage.cs │ │ ├── Requests │ │ │ ├── GetExternalIPAddressMessage.cs │ │ │ ├── GetGenericPortMappingEntry.cs │ │ │ ├── DeletePortMappingMessage.cs │ │ │ └── GetSpecificPortMappingEntryMessage.cs │ │ ├── DiscoverDeviceMessage.cs │ │ ├── ErrorMessage.cs │ │ └── GetServicesMessage.cs │ └── AsyncResults │ │ ├── GetAllMappingsAsyncResult.cs │ │ └── PortMapAsyncResult.cs ├── Pmp │ ├── AsyncResults │ │ └── PortMapAsyncResult.cs │ └── PmpConstants.cs ├── AsyncResults │ └── AsyncResult.cs └── INatDevice.cs ├── XBSlink ├── ok_16.png ├── XBSlink.ico ├── XBSlink.suo ├── error_16.png ├── error_50.png ├── icon_key.png ├── warning_16.png ├── sounds │ ├── new_node.wav │ ├── node_left.wav │ └── incoming_chat_msg.wav ├── .gitignore ├── SharpPcap.dll.config ├── XBSlink.csproj.user ├── Settings.cs ├── Program.cs └── Properties │ └── AssemblyInfo.cs ├── XBSlink Installer ├── .gitignore ├── WinPcap_4_1_3.exe ├── XBSlink_license.txt ├── xbslink_version_info.exe ├── create_linux_package.sh ├── get_xbs_version.nsi └── VersionCompare.nsh └── .gitignore /SharpPcap/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | /obj/ 3 | /SharpPcap.pidb 4 | -------------------------------------------------------------------------------- /cloudlist/.settings/.gitignore: -------------------------------------------------------------------------------- 1 | /org.eclipse.php.core.prefs 2 | -------------------------------------------------------------------------------- /PacketDotNet/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | /obj/ 3 | /PacketDotNet.pidb 4 | -------------------------------------------------------------------------------- /Mono.Nat/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | /obj/ 3 | /Mono.Nat.pidb 4 | /*.Nat.csproj.user 5 | -------------------------------------------------------------------------------- /SharpPcap/App.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seuffert/XBSlink/HEAD/SharpPcap/App.ico -------------------------------------------------------------------------------- /XBSlink/ok_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seuffert/XBSlink/HEAD/XBSlink/ok_16.png -------------------------------------------------------------------------------- /XBSlink/XBSlink.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seuffert/XBSlink/HEAD/XBSlink/XBSlink.ico -------------------------------------------------------------------------------- /XBSlink/XBSlink.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seuffert/XBSlink/HEAD/XBSlink/XBSlink.suo -------------------------------------------------------------------------------- /XBSlink/error_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seuffert/XBSlink/HEAD/XBSlink/error_16.png -------------------------------------------------------------------------------- /XBSlink/error_50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seuffert/XBSlink/HEAD/XBSlink/error_50.png -------------------------------------------------------------------------------- /XBSlink/icon_key.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seuffert/XBSlink/HEAD/XBSlink/icon_key.png -------------------------------------------------------------------------------- /XBSlink/warning_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seuffert/XBSlink/HEAD/XBSlink/warning_16.png -------------------------------------------------------------------------------- /XBSlink Installer/.gitignore: -------------------------------------------------------------------------------- 1 | /XBSlink_setup_*.exe 2 | /XBSlink_v*.tar.gz 3 | /XBSlink_version.txt 4 | -------------------------------------------------------------------------------- /XBSlink/sounds/new_node.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seuffert/XBSlink/HEAD/XBSlink/sounds/new_node.wav -------------------------------------------------------------------------------- /XBSlink/sounds/node_left.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seuffert/XBSlink/HEAD/XBSlink/sounds/node_left.wav -------------------------------------------------------------------------------- /PacketDotNet/Libraries/log4net.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seuffert/XBSlink/HEAD/PacketDotNet/Libraries/log4net.dll -------------------------------------------------------------------------------- /XBSlink Installer/WinPcap_4_1_3.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seuffert/XBSlink/HEAD/XBSlink Installer/WinPcap_4_1_3.exe -------------------------------------------------------------------------------- /XBSlink Installer/XBSlink_license.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seuffert/XBSlink/HEAD/XBSlink Installer/XBSlink_license.txt -------------------------------------------------------------------------------- /XBSlink/sounds/incoming_chat_msg.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seuffert/XBSlink/HEAD/XBSlink/sounds/incoming_chat_msg.wav -------------------------------------------------------------------------------- /cloudlist/.gitignore: -------------------------------------------------------------------------------- 1 | /.buildpath 2 | /.project 3 | /XBSlink_clouds.sqlite3 4 | /simple_XBSlink_cloudlist_server_v1.6.1.zip 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /XBSlink.suo 2 | /XBSlink.userprefs 3 | XBSlink/obj 4 | XBSlink/bin 5 | _ReSharper.XBSlink/ 6 | /*.suo 7 | /*.userprefs 8 | -------------------------------------------------------------------------------- /XBSlink Installer/xbslink_version_info.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seuffert/XBSlink/HEAD/XBSlink Installer/xbslink_version_info.exe -------------------------------------------------------------------------------- /Mono.Nat/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /XBSlink/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | /obj/ 3 | /XBSlink.pidb 4 | /DebugWindow.resources 5 | /ExceptionMessage.resources 6 | /Form1.resources 7 | /Properties/Resources.resources 8 | -------------------------------------------------------------------------------- /XBSlink Installer/create_linux_package.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd ../XBSlink/bin/Release 3 | tar -czf "../../../XBSlink Installer/XBSlink_release.tar.gz" * 4 | cd "../../../XBSlink Installer" 5 | -------------------------------------------------------------------------------- /Mono.Nat/mono.nat.pc.in: -------------------------------------------------------------------------------- 1 | Name: Mono.Nat 2 | Description: Mono.Nat 3 | Version: @VERSION@ 4 | 5 | Requires: 6 | Libs: -r:@expanded_libdir@/@PACKAGE@/Mono.Nat.dll 7 | Libraries=@expanded_libdir@/@PACKAGE@/Mono.Nat.dll 8 | -------------------------------------------------------------------------------- /XBSlink/SharpPcap.dll.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /PacketDotNet/MiscUtil/Conversion/Endianness.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace MiscUtil.Conversion 3 | { 4 | /// 5 | /// Endianness of a converter 6 | /// 7 | public enum Endianness 8 | { 9 | /// 10 | /// Little endian - least significant byte first 11 | /// 12 | LittleEndian, 13 | /// 14 | /// Big endian - most significant byte first 15 | /// 16 | BigEndian 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /SharpPcap/SharpPcap.dll.config: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Mono.Nat/ISearcher.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Net.Sockets; 5 | using System.Net; 6 | 7 | namespace Mono.Nat 8 | { 9 | public delegate void NatDeviceCallback(INatDevice device); 10 | 11 | internal interface ISearcher 12 | { 13 | event EventHandler DeviceFound; 14 | event EventHandler DeviceLost; 15 | 16 | void Search(); 17 | void Handle(IPAddress localAddress, byte[] response, IPEndPoint endpoint); 18 | DateTime NextSearch { get; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /XBSlink Installer/get_xbs_version.nsi: -------------------------------------------------------------------------------- 1 | !define File "..\XBSlink\bin\Release\XBSlink.exe" 2 | 3 | OutFile "xbslink_version_info.exe" 4 | SilentInstall silent 5 | RequestExecutionLevel user 6 | 7 | Section 8 | 9 | ## Get file version 10 | GetDllVersion "${File}" $R0 $R1 11 | IntOp $R2 $R0 / 0x00010000 12 | IntOp $R3 $R0 & 0x0000FFFF 13 | IntOp $R4 $R1 / 0x00010000 14 | IntOp $R5 $R1 & 0x0000FFFF 15 | StrCpy $R1 "$R2.$R3.$R4.$R5" 16 | 17 | ## Write it to a !define for use in main script 18 | FileOpen $R0 "$EXEDIR\XBSlink_version.txt" w 19 | FileWrite $R0 '!define Version "$R1"' 20 | FileClose $R0 21 | 22 | SectionEnd -------------------------------------------------------------------------------- /XBSlink/XBSlink.csproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | publish\ 5 | 6 | 7 | 8 | 9 | 10 | de-DE 11 | false 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /SharpPcap/Readme.Mono: -------------------------------------------------------------------------------- 1 | To use SharpPcap on Mono on Linux or Mac 2 | 3 | NOTE: Users of Mono on Windows don't need to be concerned about dll mapping as wpcap.dll is used on 4 | Windows, even if under the Mono runtime instead of the Microsoft one. 5 | 6 | 7 | - Build the solution with Monodevelop or get the precompiled assembly. 8 | 9 | - Place the assembly, SharpPcap.dll, and the dll map file, SharpPcap.dll.config, in the same directory. 10 | * This is the extra step required under non-Windows platforms. It is necessary because the assembly 11 | is currently being built assuming the pcap library name is wpcap.dll as it is under Windows. 12 | 13 | - Make sure you have libpcap installed. 14 | 15 | - Add the assembly to your project like any other assembly and enjoy. 16 | -------------------------------------------------------------------------------- /Mono.Nat/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | 6 | [assembly: AssemblyTitle("Mono.Nat")] 7 | [assembly: AssemblyDescription(".NET Library for automatic network address translation")] 8 | [assembly: AssemblyConfiguration("")] 9 | [assembly: AssemblyCompany("")] 10 | [assembly: AssemblyProduct("Mono.Nat")] 11 | [assembly: AssemblyCopyright("Copyright Alan McGovern, Ben Motmans © 2006-2007")] 12 | [assembly: AssemblyTrademark("")] 13 | [assembly: AssemblyCulture("")] 14 | [assembly: ComVisible(false)] 15 | [assembly: Guid("c8e81e95-9f15-4eb8-8982-3d2c9cd95dee")] 16 | [assembly: AssemblyVersion("1.1.0.0")] 17 | [assembly: AssemblyFileVersion("1.1.0.0")] 18 | 19 | [assembly: CLSCompliant(false)] 20 | -------------------------------------------------------------------------------- /SharpPcap/PacketArrivalEventHandler.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2005 Tamir Gal 19 | * Copyright 2008-2010 Chris Morgan 20 | */ 21 | 22 | using System; 23 | 24 | namespace SharpPcap 25 | { 26 | /// A delegate for Packet Arrival events 27 | public delegate void PacketArrivalEventHandler(object sender, CaptureEventArgs e); 28 | } 29 | -------------------------------------------------------------------------------- /SharpPcap/CaptureStoppedEventHandler.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2005 Tamir Gal 19 | * Copyright 2009-2010 Chris Morgan 20 | */ 21 | using System; 22 | 23 | namespace SharpPcap 24 | { 25 | /// 26 | /// A delegate for notifying of a capture stopped event 27 | /// 28 | public delegate void CaptureStoppedEventHandler(object sender, CaptureStoppedEventStatus status); 29 | } 30 | -------------------------------------------------------------------------------- /PacketDotNet/DataLinkPacket.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | using System; 18 | using PacketDotNet.Utils; 19 | 20 | namespace PacketDotNet 21 | { 22 | /// 23 | /// Represents a Layer 2 protocol. 24 | /// 25 | public abstract class DataLinkPacket : Packet 26 | { 27 | /// 28 | /// DataLinkPacket constructor 29 | /// 30 | public DataLinkPacket() 31 | {} 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /PacketDotNet/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // Information about this assembly is defined by the following attributes. 5 | // Change them to the values specific to your project. 6 | 7 | [assembly: AssemblyTitle("PacketDotNet")] 8 | [assembly: AssemblyDescription(".Net assembly for dissecting and constructing network packets")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("")] 12 | [assembly: AssemblyCopyright("Chris Morgan (chmorgan@gmail.com)")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". 17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision, 18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision. 19 | 20 | [assembly: AssemblyVersion("0.13.0")] 21 | 22 | // The following attributes are used to specify the signing key for the assembly, 23 | // if desired. See the Mono documentation for more information about signing. 24 | 25 | [assembly: AssemblyDelaySign(false)] 26 | [assembly: AssemblyKeyFile("")] 27 | -------------------------------------------------------------------------------- /PacketDotNet/SessionPacket.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2009 Chris Morgan 19 | */ 20 | 21 | using PacketDotNet.Utils; 22 | 23 | namespace PacketDotNet 24 | { 25 | /// 26 | /// Session layer packet 27 | /// 28 | public abstract class SessionPacket : Packet 29 | { 30 | /// 31 | /// Constructor 32 | /// 33 | public SessionPacket() 34 | {} 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /PacketDotNet/IpVersion.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2009 Chris Morgan 19 | */ 20 | using System; 21 | 22 | namespace PacketDotNet 23 | { 24 | /// Code constants for internet protocol versions. 25 | /// 26 | /// 27 | public enum IpVersion 28 | { 29 | /// Internet protocol version 4. 30 | IPv4 = 4, 31 | /// Internet protocol version 6. 32 | IPv6 = 6 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /PacketDotNet/ApplicationPacket.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | 18 | using PacketDotNet.Utils; 19 | 20 | namespace PacketDotNet 21 | { 22 | /// 23 | /// Represents an application layer packet as described at http://en.wikipedia.org/wiki/Application_Layer 24 | /// 25 | public abstract class ApplicationPacket : Packet 26 | { 27 | /// 28 | /// ApplicationPacket constructor 29 | /// 30 | public ApplicationPacket() 31 | {} 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /SharpPcap/WinPcap/StatisticsModeEventHandler.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2005 Tamir Gal 19 | * Copyright 2008-2010 Chris Morgan 20 | */ 21 | 22 | using System; 23 | 24 | namespace SharpPcap.WinPcap 25 | { 26 | /// 27 | /// A delegate for delivering network statistics when using winpcap in 28 | /// statistics mode 29 | /// 30 | public delegate void StatisticsModeEventHandler(object sender, StatisticsModeEventArgs e); 31 | } 32 | -------------------------------------------------------------------------------- /SharpPcap/AirPcap/AirPcapBands.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010-2011 Chris Morgan 19 | */ 20 | 21 | using System; 22 | using System.Collections.Generic; 23 | using System.Linq; 24 | using System.Text; 25 | 26 | namespace SharpPcap.AirPcap 27 | { 28 | /// 29 | /// Frequency bands 30 | /// 31 | [Flags] 32 | public enum AirPcapBands : int 33 | { 34 | /// 2.4 GHz band 35 | _2GHZ = 1, 36 | 37 | /// 5 GHz band 38 | _5GHZ = 2, 39 | }; 40 | } 41 | -------------------------------------------------------------------------------- /PacketDotNet/InternetPacket.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2009 Chris Morgan 19 | */ 20 | 21 | using System; 22 | using PacketDotNet.Utils; 23 | 24 | namespace PacketDotNet 25 | { 26 | /// 27 | /// Internet packets include IPv4, IPv6, IGMP etc, see 28 | /// http://en.wikipedia.org/wiki/Internet_Layer 29 | /// 30 | public class InternetPacket : Packet 31 | { 32 | /// 33 | /// Constructor 34 | /// 35 | public InternetPacket() 36 | { } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /SharpPcap/AirPcap/Win32SafeNativeMethods.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010-2011 Chris Morgan 19 | */ 20 | using System; 21 | using System.Runtime.InteropServices; 22 | using System.Security; 23 | 24 | namespace SharpPcap.AirPcap 25 | { 26 | [SuppressUnmanagedCodeSecurityAttribute] 27 | internal static class Win32SafeNativeMethods 28 | { 29 | [DllImport("kernel32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)] 30 | internal static extern int WaitForSingleObject(IntPtr hHandle, IntPtr dwMilliseconds); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SharpPcap/WinPcap/AuthenticationTypes.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010-2011 Chris Morgan 19 | */ 20 | 21 | using System; 22 | namespace SharpPcap.WinPcap 23 | { 24 | /// 25 | /// Types of authentication 26 | /// 27 | public enum AuthenticationTypes 28 | { 29 | /// 30 | /// Null authentication 31 | /// 32 | Null = 0, 33 | 34 | /// 35 | /// Username/password authentication 36 | /// 37 | Password = 1 38 | } 39 | } 40 | 41 | -------------------------------------------------------------------------------- /SharpPcap/PcapException.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2005 Tamir Gal 19 | * Copyright 2008-2009 Chris Morgan 20 | * Copyright 2008-2009 Phillip Lemon 21 | */ 22 | 23 | using System; 24 | 25 | namespace SharpPcap 26 | { 27 | /// 28 | /// General Pcap Exception. 29 | /// 30 | public class PcapException : Exception 31 | { 32 | internal PcapException() : base() 33 | { 34 | } 35 | 36 | internal PcapException(string msg):base(msg) 37 | { 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /SharpPcap/CaptureStoppedEventStatus.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2009-2010 Chris Morgan 19 | */ 20 | using System; 21 | 22 | namespace SharpPcap 23 | { 24 | /// 25 | /// Status types when capture is stopped 26 | /// 27 | public enum CaptureStoppedEventStatus 28 | { 29 | /// 30 | /// Capture completed without errors 31 | /// 32 | CompletedWithoutError, 33 | 34 | /// 35 | /// Error while capturing 36 | /// 37 | ErrorWhileCapturing 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /SharpPcap/DeviceNotReadyException.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2005 Tamir Gal 19 | * Copyright 2008-2010 Chris Morgan 20 | */ 21 | using System; 22 | 23 | namespace SharpPcap 24 | { 25 | /// 26 | /// A PcapDevice or dumpfile is not ready for capture operations. 27 | /// 28 | public class DeviceNotReadyException : PcapException 29 | { 30 | internal DeviceNotReadyException() : base() 31 | { 32 | } 33 | 34 | internal DeviceNotReadyException(string msg) : base(msg) 35 | { 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /PacketDotNet/IGMPMessageType.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2009 Chris Morgan 19 | */ 20 | namespace PacketDotNet 21 | { 22 | /// Code constants for IGMP message types. 23 | /// 24 | /// From RFC #2236. 25 | /// 26 | /// 27 | public enum IGMPMessageType : byte 28 | { 29 | #pragma warning disable 1591 30 | MembershipQuery = 0x11, 31 | MembershipReportIGMPv1 = 0x12, 32 | MembershipReportIGMPv2 = 0x16, 33 | MembershipReportIGMPv3 = 0x22, 34 | LeaveGroup = 0x17, 35 | #pragma warning restore 1591 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /PacketDotNet/PPPProtocol.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010 Chris Morgan 19 | */ 20 | using System; 21 | namespace PacketDotNet 22 | { 23 | /// 24 | /// Indicates the protocol encapsulated by the PPP packet 25 | /// See http://www.iana.org/assignments/ppp-numbers 26 | /// 27 | public enum PPPProtocol : ushort 28 | { 29 | /// Padding 30 | Padding = 0x1, 31 | 32 | /// IPv4 33 | IPv4 = 0x21, 34 | 35 | /// IPv6 36 | IPv6 = 0x57, 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /SharpPcap/StatisticsException.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2009-2010 Chris Morgan 19 | */ 20 | using System; 21 | 22 | namespace SharpPcap 23 | { 24 | /// 25 | /// thrown when pcap_stats() reports an error 26 | /// 27 | public class StatisticsException : PcapException 28 | { 29 | /// 30 | /// string constructor 31 | /// 32 | /// 33 | /// A 34 | /// 35 | public StatisticsException(string msg) : base(msg) 36 | { 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /PacketDotNet/LLDP/InterfaceNumbering.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010 Evan Plaice 19 | * Copyright 2010 Chris Morgan 20 | */ 21 | namespace PacketDotNet.LLDP 22 | { 23 | /// 24 | /// Interface Numbering Types 25 | /// 26 | /// Source IETF RFC 802.1AB 27 | public enum InterfaceNumbering 28 | { 29 | /// Unknown 30 | Unknown, 31 | /// Interface Index 32 | ifIndex, 33 | /// System Port Number 34 | SystemPortNumber 35 | }; 36 | } -------------------------------------------------------------------------------- /SharpPcap/AirPcap/AirPcapMediumType.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010-2011 Chris Morgan 19 | */ 20 | 21 | using System; 22 | 23 | namespace SharpPcap.AirPcap 24 | { 25 | /// 26 | /// Medium type 27 | /// 28 | [Flags] 29 | public enum AirPcapMediumType : int 30 | { 31 | /// 802.11a medium 32 | _802_11_A = 1, 33 | /// 802.11b medium 34 | _802_11_B = 2, 35 | /// 802.11g medium 36 | _802_11_G = 4, 37 | /// 802.11n medium 38 | _802_11_N = 8 39 | }; 40 | } 41 | -------------------------------------------------------------------------------- /SharpPcap/WinPcap/UnmanagedStructures.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace SharpPcap.WinPcap 5 | { 6 | /// 7 | /// WinPcap specific unmanaged structures 8 | /// 9 | public class UnmanagedStructures 10 | { 11 | #region Unmanaged Structs Implementation 12 | 13 | /// 14 | /// Struct to specifiy Remote Address using rpcapd.exe, Winpcaps Remote Packet Capture Daemon 15 | /// 16 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] //Note: Pack =1 cause problems with Win 7 64b 17 | public struct pcap_rmtauth 18 | { 19 | /// 20 | /// NOTE: IntPtr used to ensure that the correct data size is used depending on 21 | /// the platform being used, 32bits on a 32bit machine, 64bits on a 64bit machine 22 | /// 23 | /// Auth Type, 0=Null, 1= Password 24 | /// 25 | public IntPtr type; 26 | /// 27 | /// Username 28 | /// 29 | public string username; 30 | 31 | /// 32 | /// Password 33 | /// 34 | public string password; 35 | } 36 | 37 | #endregion 38 | } 39 | } 40 | 41 | -------------------------------------------------------------------------------- /SharpPcap/NotSupportedOnCaptureFileException.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2011 Chris Morgan 19 | */ 20 | using System; 21 | 22 | namespace SharpPcap 23 | { 24 | /// 25 | /// Thrown when a method not supported on a capture file 26 | /// 27 | public class NotSupportedOnCaptureFileException : PcapException 28 | { 29 | /// 30 | /// string constructor 31 | /// 32 | /// 33 | /// A 34 | /// 35 | public NotSupportedOnCaptureFileException(string msg) : base(msg) 36 | { 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Mono.Nat/Enums/ProtocolType.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Authors: 3 | // Alan McGovern alan.mcgovern@gmail.com 4 | // 5 | // Copyright (C) 2006 Alan McGovern 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining 8 | // a copy of this software and associated documentation files (the 9 | // "Software"), to deal in the Software without restriction, including 10 | // without limitation the rights to use, copy, modify, merge, publish, 11 | // distribute, sublicense, and/or sell copies of the Software, and to 12 | // permit persons to whom the Software is furnished to do so, subject to 13 | // the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be 16 | // included in all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | using System; 28 | 29 | namespace Mono.Nat 30 | { 31 | public enum Protocol 32 | { 33 | Tcp, 34 | Udp 35 | } 36 | } -------------------------------------------------------------------------------- /SharpPcap/WinPcapRequiredException.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010 Chris Morgan 19 | */ 20 | using System; 21 | 22 | namespace SharpPcap 23 | { 24 | /// 25 | /// Exception thrown when a WinPcap extension method is called from 26 | /// a non-Windows platform 27 | /// 28 | public class WinPcapRequiredException : PcapException 29 | { 30 | /// 31 | /// string constructor 32 | /// 33 | /// 34 | /// A 35 | /// 36 | public WinPcapRequiredException(string msg) : base(msg) 37 | { 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /PacketDotNet/PayloadType.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010 Chris Morgan 19 | */ 20 | 21 | using System; 22 | 23 | namespace PacketDotNet 24 | { 25 | /// 26 | /// Differentiates between a packet class payload, a byte[] payload 27 | /// or no payload 28 | /// 29 | public enum PayloadType 30 | { 31 | /// 32 | /// Constant packet. 33 | /// 34 | Packet, 35 | 36 | /// 37 | /// Constant bytes. 38 | /// 39 | Bytes, 40 | 41 | /// 42 | /// Constant none. 43 | /// 44 | None 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /SharpPcap/WinPcap/SendQueueTransmitModes.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010 Chris Morgan 19 | */ 20 | 21 | using System; 22 | 23 | namespace SharpPcap.WinPcap 24 | { 25 | /// 26 | /// The types of transmit modes allowed by the WinPcap specific send queue 27 | /// implementation 28 | /// 29 | public enum SendQueueTransmitModes 30 | { 31 | /// 32 | /// Packets are sent as fast as possible 33 | /// 34 | Normal, 35 | 36 | /// 37 | /// Packets are synchronized in the kernel with a high precision timestamp 38 | /// 39 | Synchronized 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Mono.Nat/Enums/MapState.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Authors: 3 | // Alan McGovern alan.mcgovern@gmail.com 4 | // 5 | // Copyright (C) 2006 Alan McGovern 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining 8 | // a copy of this software and associated documentation files (the 9 | // "Software"), to deal in the Software without restriction, including 10 | // without limitation the rights to use, copy, modify, merge, publish, 11 | // distribute, sublicense, and/or sell copies of the Software, and to 12 | // permit persons to whom the Software is furnished to do so, subject to 13 | // the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be 16 | // included in all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | using System; 28 | 29 | namespace Mono.Nat 30 | { 31 | public enum MapState 32 | { 33 | AlreadyMapped, 34 | Available 35 | } 36 | } -------------------------------------------------------------------------------- /SharpPcap/WinPcap/CaptureMode.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010 Chris Morgan 19 | */ 20 | 21 | using System; 22 | 23 | namespace SharpPcap.WinPcap 24 | { 25 | /// 26 | /// The working mode of a Pcap device 27 | /// 28 | public enum CaptureMode : int 29 | { 30 | /// 31 | /// Set a Pcap device to capture packets, Capture mode 32 | /// 33 | Packets = 0, 34 | 35 | /// 36 | /// Set a Pcap device to report statistics. 37 | ///
38 | /// Statistics mode is only supported in WinPcap 39 | ///
40 | Statistics = 1 41 | }; 42 | } 43 | -------------------------------------------------------------------------------- /SharpPcap/ICaptureStatistics.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2011 Chris Morgan 19 | */ 20 | 21 | using System; 22 | 23 | namespace SharpPcap 24 | { 25 | /// 26 | /// Adapter statistics, received, dropped packet counts etc 27 | /// 28 | public interface ICaptureStatistics 29 | { 30 | /// 31 | /// Number of packets received 32 | /// 33 | uint ReceivedPackets { get; set; } 34 | 35 | /// 36 | /// Number of packets dropped 37 | /// 38 | uint DroppedPackets { get; set; } 39 | 40 | /// 41 | /// Number of interface dropped packets 42 | /// 43 | uint InterfaceDroppedPackets { get; set; } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /SharpPcap/AirPcap/AirPcapKeyType.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010-2011 Chris Morgan 19 | */ 20 | 21 | using System; 22 | 23 | namespace SharpPcap.AirPcap 24 | { 25 | /// 26 | /// Type of keys in the adapter 27 | /// 28 | public enum AirPcapKeyType : uint 29 | { 30 | /// 31 | /// Key type: WEP. The key can have an arbitrary length smaller than 32 bytes. 32 | /// 33 | Wep = 0, 34 | 35 | /// 36 | /// Key type: TKIP (WPA). NOT SUPPORTED YET by AirPcap 37 | /// 38 | Tkip = 1, 39 | 40 | /// 41 | /// Key type: CCMP (WPA2). NOT SUPPORTED YET by AirPcap 42 | /// 43 | Ccmp = 2 44 | }; 45 | } 46 | -------------------------------------------------------------------------------- /SharpPcap/InvalidOperationDuringBackgroundCaptureException.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010 Chris Morgan 19 | */ 20 | using System; 21 | 22 | namespace SharpPcap 23 | { 24 | /// 25 | /// Thrown when an operation can't be performed because 26 | /// a background capture has been started via PcapDevice.StartCapture() 27 | /// 28 | public class InvalidOperationDuringBackgroundCaptureException : PcapException 29 | { 30 | /// 31 | /// string constructor 32 | /// 33 | /// 34 | /// A 35 | /// 36 | public InvalidOperationDuringBackgroundCaptureException(string msg) : base(msg) 37 | { 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /SharpPcap/AirPcap/AirPcapDecryptionState.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010-2011 Chris Morgan 19 | */ 20 | 21 | using System; 22 | using System.Collections.Generic; 23 | using System.Linq; 24 | using System.Text; 25 | 26 | namespace SharpPcap.AirPcap 27 | { 28 | /// 29 | /// Type of decryption the adapter performs. 30 | /// An adapter can be instructed to turn decryption (based on the device-configured keys configured 31 | /// with \ref AirpcapSetDeviceKeys()) on or off. 32 | /// 33 | public enum AirPcapDecryptionState : int 34 | { 35 | ///This adapter performs decryption 36 | DecryptionOn = 1, 37 | ///This adapter does not perform decryption 38 | DecryptionOff = 2 39 | }; 40 | } 41 | -------------------------------------------------------------------------------- /XBSlink/Settings.cs: -------------------------------------------------------------------------------- 1 | namespace XBSlink.Properties { 2 | 3 | 4 | // Diese Klasse ermöglicht die Behandlung bestimmter Ereignisse der Einstellungsklasse: 5 | // Das SettingChanging-Ereignis wird ausgelöst, bevor der Wert einer Einstellung geändert wird. 6 | // Das PropertyChanged-Ereignis wird ausgelöst, nachdem der Wert einer Einstellung geändert wurde. 7 | // Das SettingsLoaded-Ereignis wird ausgelöst, nachdem die Einstellungswerte geladen wurden. 8 | // Das SettingsSaving-Ereignis wird ausgelöst, bevor die Einstellungswerte gespeichert werden. 9 | internal sealed partial class Settings { 10 | 11 | public Settings() { 12 | // // Heben Sie die Auskommentierung der unten angezeigten Zeilen auf, um Ereignishandler zum Speichern und Ändern von Einstellungen hinzuzufügen: 13 | // 14 | // this.SettingChanging += this.SettingChangingEventHandler; 15 | // 16 | // this.SettingsSaving += this.SettingsSavingEventHandler; 17 | // 18 | } 19 | 20 | private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) { 21 | // Fügen Sie hier Code zum Behandeln des SettingChangingEvent-Ereignisses hinzu. 22 | } 23 | 24 | private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) { 25 | // Fügen Sie hier Code zum Behandeln des SettingsSaving-Ereignisses hinzu. 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /PacketDotNet/StringOutputType.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | using System; 18 | namespace PacketDotNet 19 | { 20 | /// 21 | /// The available types of strings that the ToString(StringOutputType) can handle. 22 | /// 23 | public enum StringOutputType 24 | { 25 | /// 26 | /// Outputs the packet info on a single line 27 | /// 28 | Normal, 29 | /// 30 | /// Outputs the packet info on a single line with coloring 31 | /// 32 | Colored, 33 | /// 34 | /// Outputs the detailed packet info 35 | /// 36 | Verbose, 37 | /// 38 | /// Outputs the detailed packet info with coloring 39 | /// 40 | VerboseColored 41 | } 42 | } -------------------------------------------------------------------------------- /SharpPcap/DeviceMode.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010 Chris Morgan 19 | */ 20 | 21 | using System; 22 | 23 | namespace SharpPcap 24 | { 25 | /// 26 | /// The mode used when opening a device 27 | /// 28 | public enum DeviceMode : short 29 | { 30 | /// 31 | /// Promiscuous mode. 32 | /// Instructs the OS that we want to receive all packets, even those not 33 | /// intended for the adapter. On non-switched networks this can result in 34 | /// a large amount of addtional traffic. 35 | /// NOTE: Devices in this mode CAN be detected via the network 36 | /// 37 | Promiscuous = 1, 38 | 39 | /// 40 | /// Not promiscuous mode 41 | /// 42 | Normal = 0 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /XBSlink Installer/VersionCompare.nsh: -------------------------------------------------------------------------------- 1 | Function VersionCompare 2 | !define VersionCompare `!insertmacro VersionCompareCall` 3 | 4 | !macro VersionCompareCall _VER1 _VER2 _RESULT 5 | Push `${_VER1}` 6 | Push `${_VER2}` 7 | Call VersionCompare 8 | Pop ${_RESULT} 9 | !macroend 10 | 11 | Exch $1 12 | Exch 13 | Exch $0 14 | Exch 15 | Push $2 16 | Push $3 17 | Push $4 18 | Push $5 19 | Push $6 20 | Push $7 21 | 22 | begin: 23 | StrCpy $2 -1 24 | IntOp $2 $2 + 1 25 | StrCpy $3 $0 1 $2 26 | StrCmp $3 '' +2 27 | StrCmp $3 '.' 0 -3 28 | StrCpy $4 $0 $2 29 | IntOp $2 $2 + 1 30 | StrCpy $0 $0 '' $2 31 | 32 | StrCpy $2 -1 33 | IntOp $2 $2 + 1 34 | StrCpy $3 $1 1 $2 35 | StrCmp $3 '' +2 36 | StrCmp $3 '.' 0 -3 37 | StrCpy $5 $1 $2 38 | IntOp $2 $2 + 1 39 | StrCpy $1 $1 '' $2 40 | 41 | StrCmp $4$5 '' equal 42 | 43 | StrCpy $6 -1 44 | IntOp $6 $6 + 1 45 | StrCpy $3 $4 1 $6 46 | StrCmp $3 '0' -2 47 | StrCmp $3 '' 0 +2 48 | StrCpy $4 0 49 | 50 | StrCpy $7 -1 51 | IntOp $7 $7 + 1 52 | StrCpy $3 $5 1 $7 53 | StrCmp $3 '0' -2 54 | StrCmp $3 '' 0 +2 55 | StrCpy $5 0 56 | 57 | StrCmp $4 0 0 +2 58 | StrCmp $5 0 begin newer2 59 | StrCmp $5 0 newer1 60 | IntCmp $6 $7 0 newer1 newer2 61 | 62 | StrCpy $4 '1$4' 63 | StrCpy $5 '1$5' 64 | IntCmp $4 $5 begin newer2 newer1 65 | 66 | equal: 67 | StrCpy $0 0 68 | goto end 69 | newer1: 70 | StrCpy $0 1 71 | goto end 72 | newer2: 73 | StrCpy $0 2 74 | 75 | end: 76 | Pop $7 77 | Pop $6 78 | Pop $5 79 | Pop $4 80 | Pop $3 81 | Pop $2 82 | Pop $1 83 | Exch $0 84 | FunctionEnd -------------------------------------------------------------------------------- /Mono.Nat/EventArgs/DeviceEventArgs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Authors: 3 | // Alan McGovern alan.mcgovern@gmail.com 4 | // 5 | // Copyright (C) 2006 Alan McGovern 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining 8 | // a copy of this software and associated documentation files (the 9 | // "Software"), to deal in the Software without restriction, including 10 | // without limitation the rights to use, copy, modify, merge, publish, 11 | // distribute, sublicense, and/or sell copies of the Software, and to 12 | // permit persons to whom the Software is furnished to do so, subject to 13 | // the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be 16 | // included in all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | using System; 28 | 29 | namespace Mono.Nat 30 | { 31 | public class DeviceEventArgs : EventArgs 32 | { 33 | private INatDevice device; 34 | 35 | public DeviceEventArgs(INatDevice device) 36 | { 37 | this.device = device; 38 | } 39 | 40 | public INatDevice Device 41 | { 42 | get { return this.device; } 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /SharpPcap/Version.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2005 Tamir Gal 19 | * Copyright 2008-2009 Phillip Lemon 20 | */ 21 | 22 | namespace SharpPcap 23 | { 24 | /// 25 | /// Helper class/method to retrieve the version of the SharpPcap assembly 26 | /// 27 | public sealed class Version 28 | { 29 | Version() { } 30 | 31 | /// 32 | /// Returns the current version string of the SharpPcap library 33 | /// 34 | /// the current version string of the SharpPcap library 35 | public static string VersionString 36 | { 37 | get 38 | { 39 | System.Reflection.Assembly asm 40 | = System.Reflection.Assembly.GetAssembly(typeof(SharpPcap.Version)); 41 | return asm.GetName().Version.ToString(); 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /PacketDotNet/PPPFields.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010 Chris Morgan 19 | */ 20 | using System; 21 | namespace PacketDotNet 22 | { 23 | /// 24 | /// The fields in a PPP packet 25 | /// See http://en.wikipedia.org/wiki/Point-to-Point_Protocol 26 | /// 27 | public class PPPFields 28 | { 29 | /// 30 | /// Length of the Protocol field in bytes, the field is of type 31 | /// PPPProtocol 32 | /// 33 | public static readonly int ProtocolLength = 2; 34 | 35 | /// 36 | /// Offset from the start of the PPP packet where the Protocol field is located 37 | /// 38 | public static readonly int ProtocolPosition = 0; 39 | 40 | /// 41 | /// The length of the header 42 | /// 43 | public static readonly int HeaderLength = ProtocolLength; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /SharpPcap/AirPcap/AirPcapAdapterId.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010-2011 Chris Morgan 19 | */ 20 | 21 | using System; 22 | 23 | namespace SharpPcap.AirPcap 24 | { 25 | /// 26 | /// Types of airpcap adapters 27 | /// 28 | public enum AirPcapAdapterId : int 29 | { 30 | /// 31 | /// Class 32 | /// 33 | Classic = 0, 34 | 35 | /// 36 | /// Class release 2 37 | /// 38 | ClassicRelease2, 39 | 40 | /// 41 | /// AirPcap TX 42 | /// 43 | Tx, 44 | 45 | /// 46 | /// AirPcap EX 47 | /// 48 | Ex, 49 | 50 | /// 51 | /// AirPcap N 52 | /// 53 | N, 54 | 55 | /// 56 | /// AirPcap Nx 57 | /// 58 | Nx 59 | }; 60 | } 61 | -------------------------------------------------------------------------------- /PacketDotNet/Tcp/ChecksumAlgorighmType.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010 Evan Plaice 19 | */ 20 | using System; 21 | 22 | namespace PacketDotNet.Tcp 23 | { 24 | /// 25 | /// Specifies the different types of algorithms that the 26 | /// Alternative Checksum option are allowed to use 27 | /// 28 | /// 29 | /// References: 30 | /// http://datatracker.ietf.org/doc/rfc1146/ 31 | /// 32 | public enum ChecksumAlgorighmType 33 | { 34 | /// Standard TCP Checksum Algorithm 35 | TCPChecksum = 0, 36 | 37 | /// 8-bit Fletchers Algorighm 38 | EightBitFletchersAlgorithm = 1, 39 | 40 | /// 16-bit Fletchers Algorithm 41 | SixteenBitFletchersAlgorithm = 2, 42 | 43 | /// Redundant Checksum Avoidance 44 | RedundantChecksumAvoidance = 3 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /Mono.Nat/Upnp/Messages/Responses/DeletePortMappingResponseMessage.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Authors: 3 | // Alan McGovern alan.mcgovern@gmail.com 4 | // 5 | // Copyright (C) 2006 Alan McGovern 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining 8 | // a copy of this software and associated documentation files (the 9 | // "Software"), to deal in the Software without restriction, including 10 | // without limitation the rights to use, copy, modify, merge, publish, 11 | // distribute, sublicense, and/or sell copies of the Software, and to 12 | // permit persons to whom the Software is furnished to do so, subject to 13 | // the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be 16 | // included in all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | 28 | 29 | using System; 30 | namespace Mono.Nat.Upnp 31 | { 32 | internal class DeletePortMapResponseMessage : MessageBase 33 | { 34 | public DeletePortMapResponseMessage() 35 | :base(null) 36 | { 37 | } 38 | 39 | public override System.Net.WebRequest Encode(out byte[] body) 40 | { 41 | throw new NotSupportedException(); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /SharpPcap/AirPcap/AirPcapChannelInfoFlags.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010-2011 Chris Morgan 19 | */ 20 | 21 | using System; 22 | using System.Collections.Generic; 23 | using System.Linq; 24 | using System.Text; 25 | 26 | namespace SharpPcap.AirPcap 27 | { 28 | /// 29 | /// Channel info flags 30 | /// 31 | [Flags] 32 | public enum AirPcapChannelInfoFlags : byte 33 | { 34 | /// 35 | /// No flags set 36 | /// 37 | None = 0x0, 38 | 39 | /// 40 | /// Channel info flag: the channel is enabled for transmission, too. 41 | /// 42 | /// To comply with the electomagnetic emission regulations of the different countries, the AirPcap hardware can be programmed 43 | /// to block transmission on specific channels. This flag is set by AirpcapGetDeviceSupportedChannels() to indicate that a 44 | /// channel in the list supports transmission. 45 | /// 46 | TxEnable = 0x1 47 | }; 48 | } 49 | -------------------------------------------------------------------------------- /SharpPcap/AirPcap/AirPcapValidationType.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010-2011 Chris Morgan 19 | */ 20 | 21 | using System; 22 | 23 | namespace SharpPcap.AirPcap 24 | { 25 | /// 26 | /// Type of frame validation the adapter performs. 27 | /// An adapter can be instructed to accept different kind of frames: correct frames only, frames with wrong Frame Check Sequence (FCS) only, all frames. 28 | /// 29 | public enum AirPcapValidationType : int 30 | { 31 | /// Accept all the frames the device captures 32 | ACCEPT_EVERYTHING = 1, 33 | /// Accept correct frames only, i.e. frames with correct Frame Check Sequence (FCS). 34 | ACCEPT_CORRECT_FRAMES = 2, 35 | /// Accept corrupt frames only, i.e. frames with worng Frame Check Sequence (FCS). 36 | ACCEPT_CORRUPT_FRAMES = 3, 37 | /// Unknown validation type. You should see it only in case of error. 38 | UNKNOWN = 4 39 | }; 40 | } 41 | -------------------------------------------------------------------------------- /SharpPcap/AirPcap/AirPcapAdapterBus.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010-2011 Chris Morgan 19 | */ 20 | 21 | using System; 22 | 23 | namespace SharpPcap.AirPcap 24 | { 25 | /// 26 | /// Adapter bus types 27 | /// 28 | public enum AirPcapAdapterBus : int 29 | { 30 | /// 31 | /// Usb 32 | /// 33 | Usb = 0, 34 | 35 | /// 36 | /// Pci 37 | /// 38 | Pci, 39 | 40 | /// 41 | /// PciExpress 42 | /// 43 | PciExpress, 44 | 45 | /// 46 | /// MiniPci 47 | /// 48 | MiniPci, 49 | 50 | /// 51 | /// MiniPciExpress 52 | /// 53 | MiniPciExpress, 54 | 55 | /// 56 | /// Cardbus 57 | /// 58 | Cardbus, 59 | 60 | /// 61 | /// Expresscard 62 | /// 63 | Expresscard 64 | }; 65 | 66 | } 67 | -------------------------------------------------------------------------------- /Mono.Nat/Upnp/Messages/Responses/CreatePortMappingResponseMessage.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Authors: 3 | // Alan McGovern alan.mcgovern@gmail.com 4 | // 5 | // Copyright (C) 2006 Alan McGovern 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining 8 | // a copy of this software and associated documentation files (the 9 | // "Software"), to deal in the Software without restriction, including 10 | // without limitation the rights to use, copy, modify, merge, publish, 11 | // distribute, sublicense, and/or sell copies of the Software, and to 12 | // permit persons to whom the Software is furnished to do so, subject to 13 | // the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be 16 | // included in all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | 28 | 29 | using System; 30 | namespace Mono.Nat.Upnp 31 | { 32 | internal class CreatePortMappingResponseMessage : MessageBase 33 | { 34 | #region Constructors 35 | public CreatePortMappingResponseMessage() 36 | :base(null) 37 | { 38 | } 39 | #endregion 40 | 41 | public override System.Net.WebRequest Encode(out byte[] body) 42 | { 43 | throw new NotImplementedException(); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /PacketDotNet/LLDP/AddressFamily.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010 Evan Plaice 19 | * Copyright 2010 Chris Morgan 20 | */ 21 | namespace PacketDotNet.LLDP 22 | { 23 | /// 24 | /// The IANA (Internet Assigned Numbers Authority) Address Family 25 | /// 26 | /// Source http://www.iana.org/assignments/address-family-numbers/ 27 | public enum AddressFamily 28 | { 29 | /// IP version 4 30 | IPv4 = 1, 31 | /// IP version 6 32 | IPv6 = 2, 33 | /// NSAP 34 | NSAP = 3, 35 | /// HDLC 36 | HDLC = 4, 37 | /// BBN 1822 38 | BBN1822 = 5, 39 | /// 802 (includes all 802 media plus Ethernet "canonical format") 40 | Eth802 = 6, 41 | /// E.163 42 | E163 = 7 43 | // Add more if necessary 44 | // See remarks for more info on where 45 | // to find more info 46 | } 47 | } -------------------------------------------------------------------------------- /PacketDotNet/Tcp/Echo.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010 Evan Plaice 19 | */ 20 | using System; 21 | 22 | namespace PacketDotNet.Tcp 23 | { 24 | /// 25 | /// An Echo Option 26 | /// throws an exception because Echo Options 27 | /// are obsolete as per their spec 28 | /// 29 | public class Echo : Option 30 | { 31 | #region Constructors 32 | 33 | /// 34 | /// Creates an Echo Option 35 | /// 36 | /// 37 | /// A 38 | /// 39 | /// 40 | /// A 41 | /// 42 | /// 43 | /// A 44 | /// 45 | public Echo(byte[] bytes, int offset, int length) : 46 | base(bytes, offset, length) 47 | { 48 | throw new NotSupportedException("Obsolete: The Echo Option has been deprecated."); 49 | } 50 | 51 | #endregion 52 | } 53 | } -------------------------------------------------------------------------------- /PacketDotNet/LinuxSLLType.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2009 Chris Morgan 19 | */ 20 | 21 | using System; 22 | 23 | namespace PacketDotNet 24 | { 25 | /// 26 | /// The types of cooked packets 27 | /// See http://github.com/mcr/libpcap/blob/master/pcap/sll.h 28 | /// 29 | public enum LinuxSLLType 30 | { 31 | /// 32 | /// Packet was sent to us by somebody else 33 | /// 34 | PacketSentToUs = 0x0, 35 | 36 | /// 37 | /// Packet was broadcast by somebody else 38 | /// 39 | PacketBroadCast = 0x1, 40 | 41 | /// 42 | /// Packet was multicast, but not broadcast 43 | /// 44 | PacketMulticast = 0x2, 45 | 46 | /// 47 | /// Packet was sent by somebody else to somebody else 48 | /// 49 | PacketSentToSomeoneElse = 0x3, 50 | 51 | /// 52 | /// Packet was sent by us 53 | /// 54 | PacketSentByUs = 0x4 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /PacketDotNet/ICMPv6Types.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet. 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010 Chris Morgan 19 | */ 20 | 21 | using System; 22 | 23 | namespace PacketDotNet 24 | { 25 | /// 26 | /// ICMPv6 types, see http://en.wikipedia.org/wiki/ICMPv6 and 27 | /// http://www.iana.org/assignments/icmpv6-parameters 28 | /// 29 | public enum ICMPv6Types : byte 30 | { 31 | #pragma warning disable 1591 32 | #region ICMPv6 Error Messages 33 | DestinationUnreachable = 1, 34 | PacketTooBig = 2, 35 | TimeExceeded = 3, 36 | ParameterProblem = 4, 37 | PrivateExperimentation1 = 100, 38 | PrivateExperimentation2 = 101, 39 | ReservedForExpansion1 = 127, 40 | #endregion 41 | #region ICMPv6 Informational Messages 42 | EchoRequest = 128, 43 | EchoReply = 129, 44 | RouterSolicitation = 133, 45 | NeighborSolicitation = 135, 46 | PrivateExperimentation3 = 200, 47 | PrivateExperimentation4 = 201, 48 | ReservedForExpansion2 = 255 49 | #endregion 50 | #pragma warning restore 1591 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /SharpPcap/AirPcap/AirPcapLinkTypes.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010-2011 Chris Morgan 19 | */ 20 | 21 | using System; 22 | 23 | namespace SharpPcap.AirPcap 24 | { 25 | /// 26 | /// Link type 27 | /// 28 | public enum AirPcapLinkTypes : int 29 | { 30 | /// 31 | /// plain 802.11 link type. Every packet in the buffer contains the raw 802.11 frame, including MAC FCS. 32 | /// 33 | _802_11 = 1, 34 | 35 | /// 36 | /// 802.11 plus radiotap link type. Every packet in the buffer contains a radiotap header followed by the 802.11 frame. MAC FCS is included. 37 | /// 38 | _802_11_PLUS_RADIO = 2, 39 | 40 | /// 41 | /// Unknown link type, should be seen only in error 42 | /// 43 | UNKNOWN = 3, 44 | 45 | /// 46 | /// 802.11 plus PPI header link type. Every packet in the buffer contains a PPI header followed by the 802.11 frame. MAC FCS is included. 47 | /// 48 | _802_11_PLUS_PPI = 4 49 | }; 50 | } 51 | -------------------------------------------------------------------------------- /PacketDotNet/Ieee8021QFields.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2013 Chris Morgan 19 | */ 20 | namespace PacketDotNet 21 | { 22 | /// 802.1Q fields 23 | public class Ieee8021QFields 24 | { 25 | /// Length of the ethertype value in bytes. 26 | public readonly static int TypeLength = 2; 27 | /// Length of the tag control information in bytes. 28 | public readonly static int TagControlInformationLength = 2; 29 | /// Position of the tag control information 30 | public readonly static int TagControlInformationPosition = 0; 31 | /// Position of the type field 32 | public readonly static int TypePosition; 33 | /// Length in bytes of a Ieee8021Q header. 34 | public readonly static int HeaderLength; // 4 35 | 36 | static Ieee8021QFields() 37 | { 38 | TypePosition = TagControlInformationPosition + TagControlInformationLength; 39 | HeaderLength = TypePosition + TypeLength; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /SharpPcap/WinPcap/OpenFlags.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010 Chris Morgan 19 | */ 20 | 21 | using System; 22 | 23 | namespace SharpPcap.WinPcap 24 | { 25 | /// 26 | /// The mode used when opening a device 27 | /// 28 | [Flags] 29 | public enum OpenFlags : short 30 | { 31 | /// 32 | /// Defines if the adapter has to go in promiscuous mode. 33 | /// 34 | Promiscuous = 1, 35 | 36 | /// 37 | /// Defines if the data trasfer (in case of a remote capture) 38 | /// has to be done with UDP protocol. 39 | /// 40 | DataTransferUdp = 2, 41 | 42 | /// 43 | /// Defines if the remote probe will capture its own generated traffic. 44 | /// 45 | NoCaptureRemote = 4, 46 | 47 | /// 48 | /// Defines if the local adapter will capture its own generated traffic. 49 | /// 50 | NoCaptureLocal = 8, 51 | 52 | /// 53 | /// This flag configures the adapter for maximum responsiveness. 54 | /// 55 | MaxResponsiveness = 16 56 | } 57 | } -------------------------------------------------------------------------------- /Mono.Nat/Upnp/Messages/Requests/GetExternalIPAddressMessage.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Authors: 3 | // Alan McGovern alan.mcgovern@gmail.com 4 | // 5 | // Copyright (C) 2006 Alan McGovern 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining 8 | // a copy of this software and associated documentation files (the 9 | // "Software"), to deal in the Software without restriction, including 10 | // without limitation the rights to use, copy, modify, merge, publish, 11 | // distribute, sublicense, and/or sell copies of the Software, and to 12 | // permit persons to whom the Software is furnished to do so, subject to 13 | // the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be 16 | // included in all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | using System; 28 | using System.Collections.Generic; 29 | using System.Text; 30 | using System.Net; 31 | using System.IO; 32 | 33 | namespace Mono.Nat.Upnp 34 | { 35 | internal class GetExternalIPAddressMessage : MessageBase 36 | { 37 | 38 | #region Constructors 39 | public GetExternalIPAddressMessage(UpnpNatDevice device) 40 | :base(device) 41 | { 42 | } 43 | #endregion 44 | 45 | 46 | public override WebRequest Encode(out byte[] body) 47 | { 48 | return CreateRequest("GetExternalIPAddress", string.Empty, out body); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /PacketDotNet/Tcp/SACKPermitted.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010 Evan Plaice 19 | */ 20 | using System; 21 | using MiscUtil.Conversion; 22 | using PacketDotNet.Utils; 23 | 24 | namespace PacketDotNet.Tcp 25 | { 26 | /// 27 | /// SACK (Selective Ack) Permitted Option 28 | /// Notifies the receiver that SACK is allowed. 29 | /// Must only be sent in a SYN segment 30 | /// 31 | /// 32 | /// References: 33 | /// http://datatracker.ietf.org/doc/rfc2018/ 34 | /// 35 | public class SACKPermitted : Option 36 | { 37 | #region Constructors 38 | 39 | /// 40 | /// Creates a Sack Permitted Option 41 | /// 42 | /// 43 | /// A 44 | /// 45 | /// 46 | /// A 47 | /// 48 | /// 49 | /// A 50 | /// 51 | public SACKPermitted(byte[] bytes, int offset, int length) : 52 | base(bytes, offset, length) 53 | { } 54 | 55 | #endregion 56 | } 57 | } -------------------------------------------------------------------------------- /PacketDotNet/Ieee80211/DurationField.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2012 Alan Rushforth 19 | */ 20 | 21 | using System; 22 | using System.Collections.Generic; 23 | using System.Linq; 24 | using System.Text; 25 | 26 | namespace PacketDotNet 27 | { 28 | namespace Ieee80211 29 | { 30 | /// 31 | /// Duration field. 32 | /// 33 | public class DurationField 34 | { 35 | /// 36 | /// This is the raw Duration field 37 | /// 38 | /// 39 | public UInt16 Field { get; set; } 40 | 41 | /// 42 | /// Initializes a new instance of the class. 43 | /// 44 | public DurationField() 45 | { 46 | } 47 | 48 | /// 49 | /// Constructor 50 | /// 51 | /// 52 | /// A 53 | /// 54 | public DurationField(UInt16 field) 55 | { 56 | this.Field = field; 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /SharpPcap/WinPcap/StatisticsModeEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2005 Tamir Gal 19 | * Copyright 2009-2010 Chris Morgan 20 | */ 21 | 22 | using System; 23 | using SharpPcap.LibPcap; 24 | 25 | namespace SharpPcap.WinPcap 26 | { 27 | /// 28 | /// Event that contains statistics mode data 29 | /// NOTE: WinPcap only 30 | /// 31 | public class StatisticsModeEventArgs : CaptureEventArgs 32 | { 33 | /// 34 | /// Constructor for a statistics mode event 35 | /// 36 | /// 37 | /// A 38 | /// 39 | /// 40 | /// A 41 | /// 42 | public StatisticsModeEventArgs(RawCapture packet, PcapDevice device) 43 | : base(packet, device) 44 | { 45 | } 46 | 47 | /// 48 | /// Statistics data for this event 49 | /// 50 | public StatisticsModePacket Statistics 51 | { 52 | get 53 | { 54 | return new StatisticsModePacket(base.Packet); 55 | } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Mono.Nat/Pmp/AsyncResults/PortMapAsyncResult.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Authors: 3 | // Ben Motmans 4 | // 5 | // Copyright (C) 2007 Ben Motmans 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining 8 | // a copy of this software and associated documentation files (the 9 | // "Software"), to deal in the Software without restriction, including 10 | // without limitation the rights to use, copy, modify, merge, publish, 11 | // distribute, sublicense, and/or sell copies of the Software, and to 12 | // permit persons to whom the Software is furnished to do so, subject to 13 | // the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be 16 | // included in all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | using System; 28 | 29 | namespace Mono.Nat.Pmp 30 | { 31 | internal class PortMapAsyncResult : AsyncResult 32 | { 33 | private Mapping mapping; 34 | 35 | internal PortMapAsyncResult (Mapping mapping, AsyncCallback callback, object asyncState) 36 | : base (callback, asyncState) 37 | { 38 | this.mapping = mapping; 39 | } 40 | 41 | internal PortMapAsyncResult (Protocol protocol, int port, int lifetime, AsyncCallback callback, object asyncState) 42 | : base (callback, asyncState) 43 | { 44 | this.mapping = new Mapping (protocol, port, port, lifetime); 45 | } 46 | 47 | internal Mapping Mapping 48 | { 49 | get { return mapping; } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /PacketDotNet/Ieee80211/RadioTapChannelFlags.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010 Chris Morgan 19 | */ 20 | 21 | using System; 22 | 23 | namespace PacketDotNet 24 | { 25 | namespace Ieee80211 26 | { 27 | /// 28 | /// Channel flags 29 | /// 30 | [Flags] 31 | public enum RadioTapChannelFlags : ushort 32 | { 33 | /// Turbo channel 34 | Turbo = 0x0010, 35 | ///CCK channel 36 | Cck = 0x0020, 37 | /// OFDM channel 38 | Ofdm = 0x0040, 39 | /// 2 GHz spectrum channel 40 | Channel2Ghz = 0x0080, 41 | /// 5 GHz spectrum channel 42 | Channel5Ghz = 0x0100, 43 | /// Only passive scan allowed 44 | Passive = 0x0200, 45 | /// Dynamic CCK-OFDM channel 46 | DynamicCckOfdm = 0x0400, 47 | /// GFSK channel (FHSS PHY) 48 | Gfsk = 0x0800, 49 | /// 11a static turbo channel only 50 | StaticTurbo = 0x2000 51 | }; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /PacketDotNet/Tcp/EchoReply.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010 Evan Plaice 19 | */ 20 | using System; 21 | 22 | namespace PacketDotNet.Tcp 23 | { 24 | /// 25 | /// Echo Reply Option 26 | /// Marked obsolete in the TCP spec Echo Reply Option has been 27 | /// replaced by the TSOPT (Timestamp Option) 28 | /// 29 | /// 30 | /// References: 31 | /// http://datatracker.ietf.org/doc/rfc1072/ 32 | /// 33 | public class EchoReply : Option 34 | { 35 | #region Constructors 36 | 37 | /// 38 | /// Creates an Echo Reply Option 39 | /// 40 | /// 41 | /// A 42 | /// 43 | /// 44 | /// A 45 | /// 46 | /// 47 | /// A 48 | /// 49 | public EchoReply(byte[] bytes, int offset, int length): 50 | base(bytes, offset, length) 51 | { 52 | throw new NotSupportedException("Obsolete: The Echo Option has been deprecated."); 53 | } 54 | 55 | #endregion 56 | } 57 | } -------------------------------------------------------------------------------- /Mono.Nat/Upnp/Messages/DiscoverDeviceMessage.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Authors: 3 | // Alan McGovern alan.mcgovern@gmail.com 4 | // 5 | // Copyright (C) 2006 Alan McGovern 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining 8 | // a copy of this software and associated documentation files (the 9 | // "Software"), to deal in the Software without restriction, including 10 | // without limitation the rights to use, copy, modify, merge, publish, 11 | // distribute, sublicense, and/or sell copies of the Software, and to 12 | // permit persons to whom the Software is furnished to do so, subject to 13 | // the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be 16 | // included in all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | using System.Text; 28 | 29 | namespace Mono.Nat.Upnp 30 | { 31 | internal static class DiscoverDeviceMessage 32 | { 33 | /// 34 | /// The message sent to discover all uPnP devices on the network 35 | /// 36 | /// 37 | public static byte[] Encode() 38 | { 39 | string s = "M-SEARCH * HTTP/1.1\r\n" 40 | + "HOST: 239.255.255.250:1900\r\n" 41 | + "MAN: \"ssdp:discover\"\r\n" 42 | + "MX: 3\r\n" 43 | + "ST: ssdp:all\r\n\r\n"; 44 | return UTF8Encoding.ASCII.GetBytes(s); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /SharpPcap/AirPcap/AirPcapMacFlags.cs: -------------------------------------------------------------------------------- 1 | /* This file is part of SharpPcap. SharpPcap is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SharpPcap is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SharpPcap. If not, see . */ /* * Copyright 2010-2011 Chris Morgan */ using System; namespace SharpPcap.AirPcap { /// /// Mac flags /// [Flags] public enum AirPcapMacFlags : int { /// /// If set, the device is configured to work in monitor mode. /// When monitor mode is on, the device captures all the frames transmitted on the channel. This includes: /// - unicast packets /// - multicast packets /// - broadcast packets /// - control and management packets /// /// When monitor mode is off, the device has a filter on unicast packets to capture only the packets whose MAC /// destination address equals the device's address. This means the following frames will be received: /// - unicast packets whose destination is the address of the device /// - multicast packets /// - broadcast packets /// - beacons and probe requests /// MonitorModeOn = 1, /// /// If set, the device will acknowledge the data frames sent to its address. This is useful when the device needs to interact with other devices on the /// 802.11 network, bacause handling the ACKs in software is normally too slow. /// AckFramesOn = 2, }; } -------------------------------------------------------------------------------- /SharpPcap/AirPcap/AirPcapDeviceDescription.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010-2011 Chris Morgan 19 | */ 20 | using System; 21 | using System.Collections.Generic; 22 | using System.Linq; 23 | using System.Text; 24 | 25 | namespace SharpPcap.AirPcap 26 | { 27 | /// 28 | /// Adapter description 29 | /// 30 | public class AirPcapDeviceDescription 31 | { 32 | /// 33 | /// Device name 34 | /// 35 | public string Name { get; set; } 36 | 37 | /// 38 | /// Device description 39 | /// 40 | public string Description { get; set; } 41 | 42 | internal AirPcapDeviceDescription(AirPcapUnmanagedStructures.AirpcapDeviceDescription desc) 43 | { 44 | this.Name = desc.Name; 45 | this.Description = desc.Description; 46 | } 47 | 48 | /// 49 | /// ToString() override 50 | /// 51 | /// 52 | /// A 53 | /// 54 | public override string ToString() 55 | { 56 | return string.Format("Name: {0}, Description: {1}", 57 | Name, Description); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Mono.Nat/AsyncResults/AsyncResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Threading; 5 | 6 | namespace Mono.Nat 7 | { 8 | internal class AsyncResult : IAsyncResult 9 | { 10 | private object asyncState; 11 | private AsyncCallback callback; 12 | private bool completedSynchronously; 13 | private bool isCompleted; 14 | private Exception storedException; 15 | private ManualResetEvent waitHandle; 16 | 17 | public AsyncResult(AsyncCallback callback, object asyncState) 18 | { 19 | this.callback = callback; 20 | this.asyncState = asyncState; 21 | waitHandle = new ManualResetEvent(false); 22 | } 23 | 24 | public object AsyncState 25 | { 26 | get { return asyncState; } 27 | } 28 | 29 | public ManualResetEvent AsyncWaitHandle 30 | { 31 | get { return waitHandle; } 32 | } 33 | 34 | WaitHandle IAsyncResult.AsyncWaitHandle 35 | { 36 | get { return waitHandle; } 37 | } 38 | 39 | public bool CompletedSynchronously 40 | { 41 | get { return completedSynchronously; } 42 | protected internal set { completedSynchronously = value; } 43 | } 44 | 45 | public bool IsCompleted 46 | { 47 | get { return isCompleted; } 48 | protected internal set { isCompleted = value; } 49 | } 50 | 51 | public Exception StoredException 52 | { 53 | get { return storedException; } 54 | } 55 | 56 | public void Complete() 57 | { 58 | Complete(storedException); 59 | } 60 | 61 | public void Complete(Exception ex) 62 | { 63 | storedException = ex; 64 | isCompleted = true; 65 | waitHandle.Set(); 66 | 67 | if (callback != null) 68 | callback(this); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Mono.Nat/Upnp/AsyncResults/GetAllMappingsAsyncResult.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Authors: 3 | // Alan McGovern alan.mcgovern@gmail.com 4 | // 5 | // Copyright (C) 2006 Alan McGovern 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining 8 | // a copy of this software and associated documentation files (the 9 | // "Software"), to deal in the Software without restriction, including 10 | // without limitation the rights to use, copy, modify, merge, publish, 11 | // distribute, sublicense, and/or sell copies of the Software, and to 12 | // permit persons to whom the Software is furnished to do so, subject to 13 | // the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be 16 | // included in all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | using System; 28 | using System.Collections.Generic; 29 | using System.Text; 30 | using System.Net; 31 | 32 | namespace Mono.Nat.Upnp 33 | { 34 | internal class GetAllMappingsAsyncResult : PortMapAsyncResult 35 | { 36 | private List mappings; 37 | private Mapping specificMapping; 38 | 39 | public GetAllMappingsAsyncResult(WebRequest request, AsyncCallback callback, object asyncState) 40 | : base(request, callback, asyncState) 41 | { 42 | mappings = new List(); 43 | } 44 | 45 | public List Mappings 46 | { 47 | get { return this.mappings; } 48 | } 49 | 50 | public Mapping SpecificMapping 51 | { 52 | get { return this.specificMapping; } 53 | set { this.specificMapping = value; } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /PacketDotNet/IeeeP8021PPriorities.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2013 Chris Morgan 19 | */ 20 | using System; 21 | 22 | namespace PacketDotNet 23 | { 24 | /// 25 | /// Ieee p8021 P priorities. 26 | /// http://en.wikipedia.org/wiki/IEEE_802.1p 27 | /// 28 | public enum IeeeP8021PPriorities : byte 29 | { 30 | /// 31 | /// Background 32 | /// 33 | Background_0 = 1, 34 | /// 35 | /// Best effort 36 | /// 37 | BestEffort_1 = 0, 38 | /// 39 | /// Excellent effort 40 | /// 41 | ExcellentEffort_2 = 2, 42 | /// 43 | /// Critical application 44 | /// 45 | CriticalApplications_3 = 3, 46 | /// 47 | /// Video, < 100ms latency and jitter 48 | /// 49 | Video_4 = 4, 50 | /// 51 | /// Voice, < 10ms latency and jitter 52 | /// 53 | Voice_5 = 5, 54 | /// 55 | /// Internetwork control 56 | /// 57 | InternetworkControl_6 = 6, 58 | /// 59 | /// Network control 60 | /// 61 | NetworkControl_7 = 7 62 | } 63 | } -------------------------------------------------------------------------------- /PacketDotNet/LLDP/ChassisSubTypes.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010 Evan Plaice 19 | * Copyright 2010 Chris Morgan 20 | */ 21 | namespace PacketDotNet.LLDP 22 | { 23 | /// 24 | /// The Chassis ID TLV subtypes 25 | /// 26 | public enum ChassisSubTypes 27 | { 28 | /// A Chassis Component identifier 29 | /// See IETF RFC 2737 30 | ChassisComponent = 1, 31 | /// An Interface Alias identifier 32 | /// See IETF RFC 2863 33 | InterfaceAlias = 2, 34 | /// A Port Component identifier 35 | /// See IETF RFC 2737 36 | PortComponent = 3, 37 | /// A MAC (Media Access Control) Address identifier 38 | /// See IEEE Std 802 39 | MACAddress = 4, 40 | /// A Network Address (IP Address) Identifier 41 | /// See IEEE Std 802 42 | NetworkAddress = 5, 43 | /// An Interface Name identifier 44 | /// See IEEE Std 802 45 | InterfaceName = 6, 46 | /// A Locally Assigned identifier 47 | LocallyAssigned = 7 48 | }; 49 | } -------------------------------------------------------------------------------- /Mono.Nat/Upnp/Messages/Responses/GetExternalIPAddressResponseMessage.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Authors: 3 | // Alan McGovern alan.mcgovern@gmail.com 4 | // 5 | // Copyright (C) 2006 Alan McGovern 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining 8 | // a copy of this software and associated documentation files (the 9 | // "Software"), to deal in the Software without restriction, including 10 | // without limitation the rights to use, copy, modify, merge, publish, 11 | // distribute, sublicense, and/or sell copies of the Software, and to 12 | // permit persons to whom the Software is furnished to do so, subject to 13 | // the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be 16 | // included in all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | using System; 28 | using System.Collections.Generic; 29 | using System.Text; 30 | using System.Net; 31 | 32 | namespace Mono.Nat.Upnp 33 | { 34 | internal class GetExternalIPAddressResponseMessage : MessageBase 35 | { 36 | public IPAddress ExternalIPAddress 37 | { 38 | get { return this.externalIPAddress; } 39 | } 40 | private IPAddress externalIPAddress; 41 | 42 | public GetExternalIPAddressResponseMessage(string ip) 43 | :base(null) 44 | { 45 | this.externalIPAddress = IPAddress.Parse(ip); 46 | } 47 | 48 | public override WebRequest Encode(out byte[] body) 49 | { 50 | throw new NotImplementedException(); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /PacketDotNet/LLDP/PortSubTypes.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010 Evan Plaice 19 | * Copyright 2010 Chris Morgan 20 | */ 21 | namespace PacketDotNet.LLDP 22 | { 23 | /// 24 | /// The Port ID TLV subtypes 25 | /// 26 | public enum PortSubTypes 27 | { 28 | /// An Interface Alias identifier 29 | /// See IETF RFC 2863 30 | InterfaceAlias = 1, 31 | /// A Port Component identifier 32 | /// See IETF RFC 2737 33 | PortComponent = 2, 34 | /// A MAC (Media Access Control) Address identifier 35 | /// See IEEE Std 802 36 | MACAddress = 3, 37 | /// A Network Address (IP Address) Identifier 38 | /// See IEEE Std 802 39 | NetworkAddress = 4, 40 | /// An Interface Name identifier 41 | /// See IEEE Std 802 42 | InterfaceName = 5, 43 | /// An Agent Circiut ID identifier 44 | /// See IETF RFC 3046 45 | AgentCircuitID = 6, 46 | /// A Locally Assigned identifier 47 | /// See IETF RFC 3046 48 | LocallyAssigned = 7 49 | }; 50 | } -------------------------------------------------------------------------------- /SharpPcap/CaptureEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2005 Tamir Gal 19 | * Copyright 2008-2009 Chris Morgan 20 | * Copyright 2008-2009 Phillip Lemon 21 | */ 22 | using System; 23 | 24 | namespace SharpPcap 25 | { 26 | /// 27 | /// Capture event arguments 28 | /// 29 | public class CaptureEventArgs : EventArgs 30 | { 31 | private RawCapture packet; 32 | 33 | /// 34 | /// Packet that was captured 35 | /// 36 | public RawCapture Packet 37 | { 38 | get { return packet; } 39 | } 40 | 41 | private ICaptureDevice device; 42 | 43 | /// 44 | /// Device this EventArgs was generated for 45 | /// 46 | public ICaptureDevice Device 47 | { 48 | get { return device; } 49 | } 50 | 51 | /// 52 | /// Constructor 53 | /// 54 | /// 55 | /// A 56 | /// 57 | /// 58 | /// A 59 | /// 60 | public CaptureEventArgs(RawCapture packet, ICaptureDevice device) 61 | { 62 | this.packet = packet; 63 | this.device = device; 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /XBSlink/Program.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Project: XBSlink: A XBox360 & PS3/2 System Link Proxy 3 | * File name: Program.cs 4 | * 5 | * @author Oliver Seuffert, Copyright (C) 2011. 6 | */ 7 | /* 8 | * XBSlink is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; If not, see 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using System.Windows.Forms; 25 | 26 | namespace XBSlink 27 | { 28 | static class Program 29 | { 30 | public static FormMain main_form = null; 31 | private static xbs_console_app console_app = null; 32 | 33 | /// 34 | /// Der Haupteinstiegspunkt für die Anwendung. 35 | /// 36 | [STAThread] 37 | static void Main(string[] args) 38 | { 39 | xbs_settings settings = new xbs_settings(); 40 | 41 | if (args.Length > 0) 42 | { 43 | console_app = new xbs_console_app(); 44 | console_app.run(settings, args); 45 | } 46 | else 47 | { 48 | Application.EnableVisualStyles(); 49 | Application.SetCompatibleTextRenderingDefault(false); 50 | 51 | try 52 | { 53 | main_form = new FormMain(); 54 | } 55 | catch (ApplicationException) 56 | { 57 | main_form = null; 58 | } 59 | 60 | if (main_form != null) 61 | Application.Run(main_form); 62 | } 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Mono.Nat/Upnp/Messages/Requests/GetGenericPortMappingEntry.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Authors: 3 | // Alan McGovern alan.mcgovern@gmail.com 4 | // 5 | // Copyright (C) 2006 Alan McGovern 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining 8 | // a copy of this software and associated documentation files (the 9 | // "Software"), to deal in the Software without restriction, including 10 | // without limitation the rights to use, copy, modify, merge, publish, 11 | // distribute, sublicense, and/or sell copies of the Software, and to 12 | // permit persons to whom the Software is furnished to do so, subject to 13 | // the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be 16 | // included in all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | using System; 28 | using System.Collections.Generic; 29 | using System.Text; 30 | using System.Xml; 31 | 32 | namespace Mono.Nat.Upnp 33 | { 34 | internal class GetGenericPortMappingEntry : MessageBase 35 | { 36 | private int index; 37 | 38 | public GetGenericPortMappingEntry(int index, UpnpNatDevice device) 39 | :base(device) 40 | { 41 | this.index = index; 42 | } 43 | 44 | public override System.Net.WebRequest Encode(out byte[] body) 45 | { 46 | StringBuilder sb = new StringBuilder(128); 47 | XmlWriter writer = CreateWriter(sb); 48 | 49 | WriteFullElement(writer, "NewPortMappingIndex", index.ToString()); 50 | 51 | writer.Flush(); 52 | return CreateRequest("GetGenericPortMappingEntry", sb.ToString(), out body); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /PacketDotNet/Ieee80211/RadioTapFlags.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010 Chris Morgan 19 | */ 20 | 21 | using System; 22 | 23 | namespace PacketDotNet 24 | { 25 | namespace Ieee80211 26 | { 27 | /// 28 | /// Radio tap flags 29 | /// 30 | [Flags] 31 | public enum RadioTapFlags 32 | { 33 | /// 34 | /// sent/received during cfp 35 | /// 36 | CFP = 0x01, 37 | /// 38 | /// sent/received with short preamble 39 | /// 40 | ShortPreamble = 0x02, 41 | /// 42 | /// sent/received with WEP encryption 43 | /// 44 | WepEncrypted = 0x04, 45 | /// 46 | /// sent/received with fragmentation 47 | /// 48 | Fragmentation = 0x08, 49 | /// 50 | /// frame includes FCS 51 | /// 52 | FcsIncludedInFrame = 0x10, 53 | /// 54 | /// frame includes padding to the 32 bit boundary between the 802.11 header and the payload 55 | /// 56 | PostFramePadding = 0x20, 57 | /// 58 | ///fFrame failed the fcs check 59 | /// 60 | FailedFcsCheck = 0x40 61 | }; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /PacketDotNet/LLDP/CapabilityOptions.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010 Evan Plaice 19 | * Copyright 2010 Chris Morgan 20 | */ 21 | using System; 22 | 23 | namespace PacketDotNet.LLDP 24 | { 25 | /// 26 | /// The System Capabilities options 27 | /// 28 | [Flags] 29 | public enum CapabilityOptions 30 | { 31 | /// 32 | /// An Other Type of System 33 | /// 34 | Other = 0x01, 35 | /// A Repeater 36 | /// See IETF RFC 2108 37 | Repeater = 0x02, 38 | /// A Bridge 39 | /// IETF RFC 2674 40 | Bridge = 0x04, 41 | /// A WLAN Access Point 42 | /// IEEE 802.11 MIB 43 | WLanAP = 0x08, 44 | /// A Router 45 | /// IETF RFC 1812 46 | Router = 0x10, 47 | /// A Telephone 48 | /// IETF RFC 2011 49 | Telephone = 0x20, 50 | /// A DOCSIS Cable Device 51 | /// 52 | /// See IETF RFC 2669 53 | /// See IETF RFC 2670 54 | /// 55 | DocsisCableDevice = 0x40, 56 | /// A Station with no other capabilities 57 | /// IETF RFC 2011 58 | StationOnly = 0x80, 59 | }; 60 | } -------------------------------------------------------------------------------- /PacketDotNet/ICMPv6Fields.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2009 Chris Morgan 19 | */ 20 | namespace PacketDotNet 21 | { 22 | /// 23 | /// ICMP protocol field encoding information. 24 | /// See http://en.wikipedia.org/wiki/ICMPv6 25 | /// 26 | public class ICMPv6Fields 27 | { 28 | /// Length of the ICMP message type code in bytes. 29 | public readonly static int TypeLength = 1; 30 | /// Length of the ICMP subcode in bytes. 31 | public readonly static int CodeLength = 1; 32 | /// Length of the ICMP header checksum in bytes. 33 | public readonly static int ChecksumLength = 2; 34 | /// Position of the ICMP message type. 35 | public readonly static int TypePosition = 0; 36 | /// Position of the ICMP message subcode. 37 | public readonly static int CodePosition; 38 | /// Position of the ICMP header checksum. 39 | public readonly static int ChecksumPosition; 40 | /// Length in bytes of an ICMP header. 41 | public readonly static int HeaderLength; // == 4 42 | 43 | static ICMPv6Fields() 44 | { 45 | CodePosition = TypePosition + TypeLength; 46 | ChecksumPosition = CodePosition + CodeLength; 47 | HeaderLength = ChecksumPosition + ChecksumLength; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /PacketDotNet/LLDP/SystemName.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010 Evan Plaice 19 | * Copyright 2010 Chris Morgan 20 | */ 21 | using System; 22 | using System.Text; 23 | 24 | namespace PacketDotNet.LLDP 25 | { 26 | /// 27 | /// A System Name TLV 28 | /// 29 | public class SystemName : StringTLV 30 | { 31 | #region Constructors 32 | 33 | /// 34 | /// Creates a System Name TLV 35 | /// 36 | /// 37 | /// 38 | /// 39 | /// The System Name TLV's offset from the 40 | /// origin of the LLDP 41 | /// 42 | public SystemName(byte[] bytes, int offset) : 43 | base(bytes, offset) 44 | {} 45 | 46 | /// 47 | /// Creates a System Name TLV and sets it value 48 | /// 49 | /// 50 | /// A textual Name of the system 51 | /// 52 | public SystemName(string name) : base(TLVTypes.SystemName, name) 53 | { 54 | } 55 | 56 | #endregion 57 | 58 | #region Properties 59 | 60 | /// 61 | /// A textual Name of the system 62 | /// 63 | public string Name 64 | { 65 | get { return StringValue; } 66 | set { StringValue = value; } 67 | } 68 | 69 | #endregion 70 | } 71 | } -------------------------------------------------------------------------------- /Mono.Nat/Upnp/Messages/ErrorMessage.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Authors: 3 | // Alan McGovern alan.mcgovern@gmail.com 4 | // 5 | // Copyright (C) 2006 Alan McGovern 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining 8 | // a copy of this software and associated documentation files (the 9 | // "Software"), to deal in the Software without restriction, including 10 | // without limitation the rights to use, copy, modify, merge, publish, 11 | // distribute, sublicense, and/or sell copies of the Software, and to 12 | // permit persons to whom the Software is furnished to do so, subject to 13 | // the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be 16 | // included in all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | using System; 28 | 29 | namespace Mono.Nat.Upnp 30 | { 31 | internal class ErrorMessage : MessageBase 32 | { 33 | #region Member Variables 34 | public string Description 35 | { 36 | get { return this.description; } 37 | } 38 | private string description; 39 | 40 | public int ErrorCode 41 | { 42 | get { return this.errorCode; } 43 | } 44 | private int errorCode; 45 | #endregion 46 | 47 | 48 | #region Constructors 49 | public ErrorMessage(int errorCode, string description) 50 | :base(null) 51 | { 52 | this.description = description; 53 | this.errorCode = errorCode; 54 | } 55 | #endregion 56 | 57 | 58 | public override System.Net.WebRequest Encode(out byte[] body) 59 | { 60 | throw new NotImplementedException(); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /XBSlink/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Project: XBSlink: A XBox360 & PS3/2 System Link Proxy 3 | * File name: AssemblyInfo.cs 4 | * 5 | * @author Oliver Seuffert, Copyright (C) 2011. 6 | */ 7 | /* 8 | * XBSlink is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | * for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; If not, see 20 | */ 21 | 22 | using System.Reflection; 23 | using System.Runtime.CompilerServices; 24 | using System.Runtime.InteropServices; 25 | 26 | // Allgemeine Informationen über eine Assembly werden über die folgenden 27 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, 28 | // die mit einer Assembly verknüpft sind. 29 | [assembly: AssemblyTitle("XBSlink")] 30 | [assembly: AssemblyDescription("XBSlink - Xbox System Link Proxy")] 31 | [assembly: AssemblyConfiguration("")] 32 | [assembly: AssemblyCompany("Oliver Seuffert")] 33 | [assembly: AssemblyProduct("XBSlink")] 34 | [assembly: AssemblyCopyright("Copyright Oliver Seuffert © 2013")] 35 | [assembly: AssemblyTrademark("xbslink@secudb.de | http://www.secudb.de/~seuffert/xbslink/")] 36 | [assembly: AssemblyCulture("")] 37 | 38 | // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar 39 | // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von 40 | // COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. 41 | [assembly: ComVisible(false)] 42 | 43 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird 44 | [assembly: Guid("cf940b99-b2ae-499e-a618-99810a5a994f")] 45 | 46 | [assembly: AssemblyVersion("0.9.6.0")] 47 | [assembly: AssemblyFileVersion("0.9.6.0")] 48 | -------------------------------------------------------------------------------- /Mono.Nat/Upnp/Messages/Requests/DeletePortMappingMessage.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Authors: 3 | // Alan McGovern alan.mcgovern@gmail.com 4 | // 5 | // Copyright (C) 2006 Alan McGovern 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining 8 | // a copy of this software and associated documentation files (the 9 | // "Software"), to deal in the Software without restriction, including 10 | // without limitation the rights to use, copy, modify, merge, publish, 11 | // distribute, sublicense, and/or sell copies of the Software, and to 12 | // permit persons to whom the Software is furnished to do so, subject to 13 | // the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be 16 | // included in all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | using System.Net; 28 | using System.IO; 29 | using System.Text; 30 | using System.Xml; 31 | 32 | namespace Mono.Nat.Upnp 33 | { 34 | internal class DeletePortMappingMessage : MessageBase 35 | { 36 | private Mapping mapping; 37 | 38 | public DeletePortMappingMessage(Mapping mapping, UpnpNatDevice device) 39 | : base(device) 40 | { 41 | this.mapping = mapping; 42 | } 43 | 44 | public override WebRequest Encode(out byte[] body) 45 | { 46 | StringBuilder builder = new StringBuilder(256); 47 | XmlWriter writer = CreateWriter(builder); 48 | 49 | WriteFullElement(writer, "NewRemoteHost", string.Empty); 50 | WriteFullElement(writer, "NewExternalPort", mapping.PublicPort.ToString(MessageBase.Culture)); 51 | WriteFullElement(writer, "NewProtocol", mapping.Protocol == Protocol.Tcp ? "TCP" : "UDP"); 52 | 53 | writer.Flush(); 54 | return CreateRequest("DeletePortMapping", builder.ToString(), out body); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /PacketDotNet/EthernetFields.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2009 Chris Morgan 19 | */ 20 | using System; 21 | 22 | namespace PacketDotNet 23 | { 24 | /// 25 | /// Ethernet protocol field encoding information. 26 | /// 27 | public class EthernetFields 28 | { 29 | /// Width of the ethernet type code in bytes. 30 | public readonly static int TypeLength = 2; 31 | 32 | /// Position of the destination MAC address within the ethernet header. 33 | public readonly static int DestinationMacPosition = 0; 34 | 35 | /// Position of the source MAC address within the ethernet header. 36 | public readonly static int SourceMacPosition; 37 | 38 | /// Position of the ethernet type field within the ethernet header. 39 | public readonly static int TypePosition; 40 | 41 | /// Total length of an ethernet header in bytes. 42 | public readonly static int HeaderLength; // == 14 43 | 44 | static EthernetFields() 45 | { 46 | SourceMacPosition = EthernetFields.MacAddressLength; 47 | TypePosition = EthernetFields.MacAddressLength * 2; 48 | HeaderLength = EthernetFields.TypePosition + EthernetFields.TypeLength; 49 | } 50 | 51 | /// 52 | /// size of an ethernet mac address in bytes 53 | /// 54 | public readonly static int MacAddressLength = 6; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Mono.Nat/Pmp/PmpConstants.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Authors: 3 | // Ben Motmans 4 | // 5 | // Copyright (C) 2007 Ben Motmans 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining 8 | // a copy of this software and associated documentation files (the 9 | // "Software"), to deal in the Software without restriction, including 10 | // without limitation the rights to use, copy, modify, merge, publish, 11 | // distribute, sublicense, and/or sell copies of the Software, and to 12 | // permit persons to whom the Software is furnished to do so, subject to 13 | // the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be 16 | // included in all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | using System; 28 | 29 | namespace Mono.Nat.Pmp 30 | { 31 | internal static class PmpConstants 32 | { 33 | public const byte Version = (byte)0; 34 | 35 | public const byte OperationCode = (byte)0; 36 | public const byte OperationCodeUdp = (byte)1; 37 | public const byte OperationCodeTcp = (byte)2; 38 | public const byte ServerNoop = (byte)128; 39 | 40 | public const int ClientPort = 5350; 41 | public const int ServerPort = 5351; 42 | 43 | public const int RetryDelay = 250; 44 | public const int RetryAttempts = 9; 45 | 46 | public const int RecommendedLeaseTime = 60 * 60; 47 | public const int DefaultLeaseTime = RecommendedLeaseTime; 48 | 49 | public const short ResultCodeSuccess = 0; 50 | public const short ResultCodeUnsupportedVersion = 1; 51 | public const short ResultCodeNotAuthorized = 2; 52 | public const short ResultCodeNetworkFailure = 3; 53 | public const short ResultCodeOutOfResources = 4; 54 | public const short ResultCodeUnsupportedOperationCode = 5; 55 | } 56 | } -------------------------------------------------------------------------------- /SharpPcap/WinPcap/RemoteAuthentication.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace SharpPcap.WinPcap 5 | { 6 | /// 7 | /// Remote authentication type and parameters 8 | /// 9 | public class RemoteAuthentication 10 | { 11 | /// 12 | /// Type of authentication 13 | /// 14 | public AuthenticationTypes Type { get; set; } 15 | 16 | /// 17 | /// Username 18 | /// 19 | public string Username { get; set; } 20 | 21 | /// 22 | /// Password 23 | /// 24 | public string Password { get; set; } 25 | 26 | /// 27 | /// Constructor 28 | /// 29 | /// 30 | /// A 31 | /// 32 | /// 33 | /// A 34 | /// 35 | /// 36 | /// A 37 | /// 38 | public RemoteAuthentication (AuthenticationTypes Type, 39 | string Username, 40 | string Password) 41 | { 42 | this.Type = Type; 43 | this.Username = Username; 44 | this.Password = Password; 45 | } 46 | 47 | /// 48 | /// Converts this structure to an unmanaged IntPtr. Should be 49 | /// freed with Marshal.FreeHGlobal(IntPtr); 50 | /// 51 | /// 52 | /// A 53 | /// 54 | internal IntPtr GetUnmanaged() 55 | { 56 | UnmanagedStructures.pcap_rmtauth rmauth; 57 | rmauth.type = (IntPtr)Type; 58 | rmauth.username = Username; 59 | rmauth.password = Password; 60 | 61 | // Initialize unmanged memory to hold the struct. 62 | IntPtr rmAuthPointer = Marshal.AllocHGlobal(Marshal.SizeOf(rmauth)); 63 | 64 | // marshal pcap_rmtauth 65 | Marshal.StructureToPtr(rmauth, rmAuthPointer, false); 66 | 67 | return rmAuthPointer; 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /PacketDotNet/IpPort.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2009 Chris Morgan 19 | */ 20 | 21 | namespace PacketDotNet 22 | { 23 | /// Code constants for ip ports. 24 | public enum IpPort : ushort 25 | { 26 | #pragma warning disable 1591 27 | Echo = 7, 28 | DayTime = 13, 29 | FtpData = 20, 30 | Ftp = 21, 31 | /// 32 | /// Secure shell 33 | /// 34 | Ssh = 22, 35 | /// 36 | /// Terminal protocol 37 | /// 38 | Telnet = 23, 39 | /// 40 | /// Simple mail transport protocol 41 | /// 42 | Smtp = 25, 43 | Time = 37, 44 | Whois = 63, 45 | Tftp = 69, 46 | Gopher = 70, 47 | Finger = 79, 48 | /// 49 | /// Hyper text transfer protocol 50 | /// 51 | Http = 80, 52 | /// 53 | /// Same as Http 54 | /// 55 | Www = 80, 56 | Kerberos = 88, 57 | Pop3 = 110, 58 | Ident = 113, 59 | Auth = 113, 60 | /// 61 | /// Secure ftp 62 | /// 63 | Sftp = 115, 64 | /// 65 | /// Network time protocol 66 | /// 67 | Ntp = 123, 68 | Imap = 143, 69 | /// 70 | /// Simple network management protocol 71 | /// 72 | Snmp = 161, 73 | PrivilegedPortLimit = 1024 74 | #pragma warning restore 1591 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /SharpPcap/WinPcap/StatisticsModePacket.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2005 Tamir Gal 19 | * Copyright 2008-2009 Chris Morgan 20 | */ 21 | 22 | using System; 23 | 24 | namespace SharpPcap.WinPcap 25 | { 26 | /// 27 | /// Holds network statistics entry from winpcap when in statistics mode 28 | /// See http://www.winpcap.org/docs/docs_41b5/html/group__wpcap__tut9.html 29 | /// 30 | public class StatisticsModePacket 31 | { 32 | /// 33 | /// This holds time value 34 | /// 35 | public PosixTimeval Timeval 36 | { 37 | get; 38 | set; 39 | } 40 | 41 | /// 42 | /// This holds byte received and packets received 43 | /// 44 | private byte[] m_pktData; 45 | 46 | internal StatisticsModePacket(RawCapture p) 47 | { 48 | this.Timeval = p.Timeval; 49 | this.m_pktData = p.Data; 50 | } 51 | 52 | /// 53 | /// Number of packets received since last sample 54 | /// 55 | public Int64 RecievedPackets 56 | { 57 | get 58 | { 59 | return BitConverter.ToInt64(m_pktData, 0); 60 | } 61 | } 62 | 63 | /// 64 | /// Number of bytes received since last sample 65 | /// 66 | public Int64 RecievedBytes 67 | { 68 | get 69 | { 70 | return BitConverter.ToInt64(m_pktData, 8); 71 | } 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /PacketDotNet/PPPoECode.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010 Chris Morgan 19 | */ 20 | 21 | using System; 22 | namespace PacketDotNet 23 | { 24 | /// 25 | /// Values for the Code field of a PPPoE packet 26 | /// See http://tools.ietf.org/html/rfc2516 27 | /// 28 | public enum PPPoECode : ushort 29 | { 30 | /// 31 | /// The PPPoe payload must contain a PPP packet 32 | /// 33 | SessionStage = 0x0, 34 | 35 | /// 36 | /// Active Discovery Offer (PADO) packet 37 | /// 38 | ActiveDiscoveryOffer = 0x07, 39 | 40 | /// 41 | /// From RFC2516: 42 | /// The Host sends the PADI packet with the DESTINATION_ADDR set to the 43 | /// broadcast address. The CODE field is set to 0x09 and the SESSION_ID 44 | /// MUST be set to 0x0000. 45 | /// 46 | /// The PADI packet MUST contain exactly one TAG of TAG_TYPE Service- 47 | /// Name, indicating the service the Host is requesting, and any number 48 | /// of other TAG types. An entire PADI packet (including the PPPoE 49 | /// header) MUST NOT exceed 1484 octets so as to leave sufficient room 50 | /// for a relay agent to add a Relay-Session-Id TAG. 51 | /// 52 | ActiveDiscoveryInitiation = 0x9, 53 | 54 | /// 55 | /// Indicate that the PPPoe session specified by the SessionId field of 56 | /// the PPPoe packet has been terminated 57 | /// 58 | ActiveDiscoveryTerminate = 0xa7, 59 | } 60 | } 61 | 62 | -------------------------------------------------------------------------------- /Mono.Nat/Upnp/Messages/Requests/GetSpecificPortMappingEntryMessage.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Authors: 3 | // Alan McGovern alan.mcgovern@gmail.com 4 | // 5 | // Copyright (C) 2006 Alan McGovern 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining 8 | // a copy of this software and associated documentation files (the 9 | // "Software"), to deal in the Software without restriction, including 10 | // without limitation the rights to use, copy, modify, merge, publish, 11 | // distribute, sublicense, and/or sell copies of the Software, and to 12 | // permit persons to whom the Software is furnished to do so, subject to 13 | // the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be 16 | // included in all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | using System; 28 | using System.Collections.Generic; 29 | using System.Text; 30 | using System.Xml; 31 | using System.Net; 32 | 33 | namespace Mono.Nat.Upnp 34 | { 35 | internal class GetSpecificPortMappingEntryMessage : MessageBase 36 | { 37 | internal Protocol protocol; 38 | internal int externalPort; 39 | 40 | public GetSpecificPortMappingEntryMessage(Protocol protocol, int externalPort, UpnpNatDevice device) 41 | : base(device) 42 | { 43 | this.protocol = protocol; 44 | this.externalPort = externalPort; 45 | } 46 | 47 | public override WebRequest Encode(out byte[] body) 48 | { 49 | StringBuilder sb = new StringBuilder(64); 50 | XmlWriter writer = CreateWriter(sb); 51 | 52 | WriteFullElement(writer, "NewRemoteHost", string.Empty); 53 | WriteFullElement(writer, "NewExternalPort", externalPort.ToString()); 54 | WriteFullElement(writer, "NewProtocol", protocol == Protocol.Tcp ? "TCP" : "UDP"); 55 | writer.Flush(); 56 | 57 | return CreateRequest("GetSpecificPortMappingEntry", sb.ToString(), out body); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /PacketDotNet/UdpFields.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2009 Chris Morgan 19 | */ 20 | namespace PacketDotNet 21 | { 22 | /// 23 | /// Defines the lengths and positions of the udp fields within 24 | /// a udp packet 25 | /// 26 | public struct UdpFields 27 | { 28 | /// Length of a UDP port in bytes. 29 | public readonly static int PortLength = 2; 30 | /// Length of the header length field in bytes. 31 | public readonly static int HeaderLengthLength = 2; 32 | /// Length of the checksum field in bytes. 33 | public readonly static int ChecksumLength = 2; 34 | /// Position of the source port. 35 | public readonly static int SourcePortPosition = 0; 36 | /// Position of the destination port. 37 | public readonly static int DestinationPortPosition; 38 | /// Position of the header length. 39 | public readonly static int HeaderLengthPosition; 40 | /// Position of the header checksum length. 41 | public readonly static int ChecksumPosition; 42 | /// Length of a UDP header in bytes. 43 | public readonly static int HeaderLength; // == 8 44 | 45 | static UdpFields() 46 | { 47 | DestinationPortPosition = PortLength; 48 | HeaderLengthPosition = DestinationPortPosition + PortLength; 49 | ChecksumPosition = HeaderLengthPosition + HeaderLengthLength; 50 | HeaderLength = ChecksumPosition + ChecksumLength; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /SharpPcap/AirPcap/AirPcapVersion.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010-2011 Chris Morgan 19 | */ 20 | 21 | using System; 22 | using System.Collections.Generic; 23 | using System.Linq; 24 | using System.Text; 25 | 26 | namespace SharpPcap.AirPcap 27 | { 28 | /// 29 | /// Version 30 | /// 31 | public class AirPcapVersion 32 | { 33 | /// 34 | /// Returns the version in separate fields 35 | /// 36 | /// 37 | /// 38 | /// 39 | /// 40 | /// 41 | public static void Version(out uint Major, out uint Minor, out uint Rev, out uint Build) 42 | { 43 | UInt32 major, minor, rev, build; 44 | 45 | AirPcapSafeNativeMethods.AirpcapGetVersion(out major, out minor, out rev, out build); 46 | 47 | Major = (uint)major; 48 | Minor = (uint)minor; 49 | Rev = (uint)rev; 50 | Build = (uint)build; 51 | } 52 | 53 | /// 54 | /// Returns the version in a.b.c.d format 55 | /// 56 | /// 57 | public static string VersionString() 58 | { 59 | uint Major, Minor, Rev, Build; 60 | Version(out Major, out Minor, out Rev, out Build); 61 | 62 | return string.Format("{0}.{1}.{2}.{3}", 63 | Major, 64 | Minor, 65 | Rev, 66 | Build); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /PacketDotNet/LLDP/EndOfLLDPDU.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010 Evan Plaice 19 | * Copyright 2010 Chris Morgan 20 | */ 21 | namespace PacketDotNet.LLDP 22 | { 23 | /// 24 | /// An End Of LLDPDU TLV 25 | /// 26 | public class EndOfLLDPDU : TLV 27 | { 28 | #region Constructors 29 | 30 | /// 31 | /// Parses bytes into an End Of LLDPDU TLV 32 | /// 33 | /// 34 | /// TLV bytes 35 | /// 36 | /// 37 | /// The End Of LLDPDU TLV's offset from the 38 | /// origin of the LLDP 39 | /// 40 | public EndOfLLDPDU(byte[] bytes, int offset) : 41 | base(bytes, offset) 42 | { 43 | Type = 0; 44 | Length = 0; 45 | } 46 | 47 | /// 48 | /// Creates an End Of LLDPDU TLV 49 | /// 50 | public EndOfLLDPDU() 51 | { 52 | var bytes = new byte[TLVTypeLength.TypeLengthLength]; 53 | var offset = 0; 54 | var length = bytes.Length; 55 | tlvData = new PacketDotNet.Utils.ByteArraySegment(bytes, offset, length); 56 | 57 | Type = 0; 58 | Length = 0; 59 | } 60 | 61 | /// 62 | /// Convert this TTL TLV to a string. 63 | /// 64 | /// 65 | /// A human readable string 66 | /// 67 | public override string ToString () 68 | { 69 | return string.Format("[EndOfLLDPDU]"); 70 | } 71 | 72 | #endregion 73 | } 74 | } -------------------------------------------------------------------------------- /SharpPcap/AirPcap/AirPcapDeviceTimestamp.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010-2011 Chris Morgan 19 | */ 20 | 21 | using System; 22 | 23 | namespace SharpPcap.AirPcap 24 | { 25 | /// 26 | /// Defines the internal AirPcap device timestamp 27 | /// 28 | public class AirPcapDeviceTimestamp 29 | { 30 | /// Current value of the device counter, in microseconds. 31 | public UInt64 DeviceTimestamp; 32 | 33 | /// Value of the software counter used to timestamp packets before reading the device counter, in microseconds. 34 | public UInt64 SoftwareTimestampBefore; 35 | 36 | /// Value of the software counter used to timestamp packets after reading the device counter, in microseconds. 37 | public UInt64 SoftwareTimestampAfter; 38 | 39 | internal AirPcapDeviceTimestamp(AirPcapUnmanagedStructures.AirpcapDeviceTimestamp timestamp) 40 | { 41 | DeviceTimestamp = timestamp.DeviceTimestamp; 42 | SoftwareTimestampBefore = timestamp.SoftwareTimestampBefore; 43 | SoftwareTimestampAfter = timestamp.SoftwareTimestampAfter; 44 | } 45 | 46 | /// 47 | /// ToString() override 48 | /// 49 | /// 50 | /// A 51 | /// 52 | public override string ToString() 53 | { 54 | return string.Format("[AirPcapDeviceTimestamp DeviceTimestamp {0}, SoftwareTimestampBefore {1}, SoftwareTimestampAfter {2}", 55 | DeviceTimestamp, SoftwareTimestampBefore, SoftwareTimestampAfter); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Mono.Nat/Upnp/Messages/GetServicesMessage.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Authors: 3 | // Alan McGovern alan.mcgovern@gmail.com 4 | // 5 | // Copyright (C) 2006 Alan McGovern 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining 8 | // a copy of this software and associated documentation files (the 9 | // "Software"), to deal in the Software without restriction, including 10 | // without limitation the rights to use, copy, modify, merge, publish, 11 | // distribute, sublicense, and/or sell copies of the Software, and to 12 | // permit persons to whom the Software is furnished to do so, subject to 13 | // the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be 16 | // included in all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | using System; 28 | using System.Diagnostics; 29 | using System.Net; 30 | 31 | namespace Mono.Nat.Upnp 32 | { 33 | internal class GetServicesMessage : MessageBase 34 | { 35 | private string servicesDescriptionUrl; 36 | private EndPoint hostAddress; 37 | 38 | public GetServicesMessage(string description, EndPoint hostAddress) 39 | :base(null) 40 | { 41 | if (string.IsNullOrEmpty(description)) 42 | Trace.WriteLine("Description is null"); 43 | 44 | if (hostAddress == null) 45 | Trace.WriteLine("hostaddress is null"); 46 | 47 | this.servicesDescriptionUrl = description; 48 | this.hostAddress = hostAddress; 49 | } 50 | 51 | 52 | public override WebRequest Encode(out byte[] body) 53 | { 54 | HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://" + this.hostAddress.ToString() + this.servicesDescriptionUrl); 55 | req.Headers.Add("ACCEPT-LANGUAGE", "en"); 56 | req.Method = "GET"; 57 | 58 | body = new byte[0]; 59 | return req; 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /PacketDotNet/Tcp/EndOfOptions.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010 Evan Plaice 19 | */ 20 | using System; 21 | 22 | namespace PacketDotNet.Tcp 23 | { 24 | /// 25 | /// End-of-Options Option 26 | /// Marks the end of the Options list 27 | /// 28 | /// 29 | /// References: 30 | /// http://datatracker.ietf.org/doc/rfc793/ 31 | /// 32 | public class EndOfOptions : Option 33 | { 34 | #region Constructors 35 | 36 | /// 37 | /// Creates an End Of Options Option 38 | /// 39 | /// 40 | /// A 41 | /// 42 | /// 43 | /// A 44 | /// 45 | /// 46 | /// A 47 | /// 48 | public EndOfOptions(byte[] bytes, int offset, int length) : 49 | base(bytes, offset, length) 50 | { } 51 | 52 | #endregion 53 | 54 | #region Properties 55 | 56 | /// 57 | /// The length of the EndOfOptions field 58 | /// Returns 1 as opposed to returning the length field because 59 | /// the EndOfOptions option is only 1 byte long and doesn't 60 | /// contain a length field 61 | /// 62 | public override byte Length 63 | { 64 | get { return EndOfOptions.OptionLength; } 65 | } 66 | 67 | #endregion 68 | 69 | #region Members 70 | 71 | /// 72 | /// The length (in bytes) of the EndOfOptions option 73 | /// 74 | internal const int OptionLength = 1; 75 | 76 | #endregion 77 | } 78 | } -------------------------------------------------------------------------------- /PacketDotNet/Tcp/NoOperation.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010 Evan Plaice 19 | */ 20 | using System; 21 | 22 | namespace PacketDotNet.Tcp 23 | { 24 | /// 25 | /// No Operation Option 26 | /// Used in the TCP Options field to pad the length to the next 32 byte boundary 27 | /// 28 | /// 29 | /// References: 30 | /// http://datatracker.ietf.org/doc/rfc793/ 31 | /// 32 | public class NoOperation : Option 33 | { 34 | #region Constructors 35 | 36 | /// 37 | /// Creates a No Operation Option 38 | /// 39 | /// 40 | /// A 41 | /// 42 | /// 43 | /// A 44 | /// 45 | /// 46 | /// A 47 | /// 48 | public NoOperation(byte[] bytes, int offset, int length) : 49 | base(bytes, offset, length) 50 | { } 51 | 52 | #endregion 53 | 54 | #region Properties 55 | 56 | /// 57 | /// The length of the NoOperation field 58 | /// Returns 1 as opposed to returning the length field because 59 | /// the NoOperation option is only 1 byte long and doesn't 60 | /// contain a length field 61 | /// 62 | public override byte Length 63 | { 64 | get { return NoOperation.OptionLength; } 65 | } 66 | 67 | #endregion 68 | 69 | #region Members 70 | 71 | /// 72 | /// The length (in bytes) of the NoOperation option 73 | /// 74 | internal const int OptionLength = 1; 75 | 76 | #endregion 77 | } 78 | } -------------------------------------------------------------------------------- /PacketDotNet/Ieee80211/MacFields.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010 Chris Morgan 19 | */ 20 | using System; 21 | 22 | namespace PacketDotNet 23 | { 24 | namespace Ieee80211 25 | { 26 | /// 27 | /// 28 | /// NOTE: All positions are not defined here because the frame type changes 29 | /// whether some address fields are present or not, causing the sequence control 30 | /// field to move. In addition the payload size determines where the frame control 31 | /// sequence value is as it is after the payload bytes, if any payload is present 32 | /// 33 | class MacFields 34 | { 35 | public readonly static int FrameControlLength = 2; 36 | public readonly static int DurationIDLength = 2; 37 | public readonly static int AddressLength = EthernetFields.MacAddressLength; 38 | public readonly static int SequenceControlLength = 2; 39 | public readonly static int FrameCheckSequenceLength = 4; 40 | 41 | public readonly static int FrameControlPosition = 0; 42 | public readonly static int DurationIDPosition; 43 | /// 44 | /// Not all MAC Frames contain a sequence control field. The value of this field is only meaningful when they do. 45 | /// 46 | public readonly static int SequenceControlPosition; 47 | public readonly static int Address1Position; 48 | 49 | static MacFields() 50 | { 51 | DurationIDPosition = FrameControlPosition + FrameControlLength; 52 | Address1Position = DurationIDPosition + DurationIDLength; 53 | SequenceControlPosition = MacFields.Address1Position + (MacFields.AddressLength * 3); 54 | } 55 | } 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /PacketDotNet/ICMPv4Fields.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2009 Chris Morgan 19 | */ 20 | namespace PacketDotNet 21 | { 22 | /// 23 | /// ICMP protocol field encoding information. 24 | /// See http://en.wikipedia.org/wiki/ICMPv6 25 | /// 26 | public class ICMPv4Fields 27 | { 28 | /// Length of the ICMP message type code in bytes. 29 | public readonly static int TypeCodeLength = 2; 30 | /// Length of the ICMP header checksum in bytes. 31 | public readonly static int ChecksumLength = 2; 32 | /// Length of the ICMP ID field in bytes. 33 | public readonly static int IDLength = 2; 34 | /// Length of the ICMP Sequence field in bytes 35 | public readonly static int SequenceLength = 2; 36 | 37 | /// Position of the ICMP message type/code. 38 | public readonly static int TypeCodePosition = 0; 39 | /// Position of the ICMP header checksum. 40 | public readonly static int ChecksumPosition; 41 | /// Position of the ICMP ID field 42 | public readonly static int IDPosition; 43 | /// Position of the Sequence field 44 | public readonly static int SequencePosition; 45 | /// Length in bytes of an ICMP header. 46 | public readonly static int HeaderLength; 47 | 48 | static ICMPv4Fields() 49 | { 50 | TypeCodePosition = 0; 51 | ChecksumPosition = TypeCodePosition + TypeCodeLength; 52 | IDPosition = ChecksumPosition + ChecksumLength; 53 | SequencePosition = IDPosition + IDLength; 54 | HeaderLength = SequencePosition + SequenceLength; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Mono.Nat/INatDevice.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Authors: 3 | // Alan McGovern alan.mcgovern@gmail.com 4 | // Ben Motmans 5 | // 6 | // Copyright (C) 2006 Alan McGovern 7 | // Copyright (C) 2007 Ben Motmans 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | using System.Collections.Generic; 31 | using System.Text; 32 | using System.Net; 33 | 34 | namespace Mono.Nat 35 | { 36 | public interface INatDevice 37 | { 38 | void CreatePortMap (Mapping mapping); 39 | void DeletePortMap (Mapping mapping); 40 | 41 | Mapping[] GetAllMappings (); 42 | IPAddress GetExternalIP (); 43 | Mapping GetSpecificMapping (Protocol protocol, int port); 44 | 45 | IAsyncResult BeginCreatePortMap (Mapping mapping, AsyncCallback callback, object asyncState); 46 | IAsyncResult BeginDeletePortMap (Mapping mapping, AsyncCallback callback, object asyncState); 47 | 48 | IAsyncResult BeginGetAllMappings (AsyncCallback callback, object asyncState); 49 | IAsyncResult BeginGetExternalIP (AsyncCallback callback, object asyncState); 50 | IAsyncResult BeginGetSpecificMapping (Protocol protocol, int externalPort, AsyncCallback callback, object asyncState); 51 | 52 | void EndCreatePortMap (IAsyncResult result); 53 | void EndDeletePortMap (IAsyncResult result); 54 | 55 | Mapping[] EndGetAllMappings (IAsyncResult result); 56 | IPAddress EndGetExternalIP (IAsyncResult result); 57 | Mapping EndGetSpecificMapping (IAsyncResult result); 58 | 59 | DateTime LastSeen { get; set; } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /PacketDotNet/IGMPv2Fields.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2009 Chris Morgan 19 | */ 20 | namespace PacketDotNet 21 | { 22 | /// IGMP protocol field encoding information. 23 | public class IGMPv2Fields 24 | { 25 | /// Length of the IGMP message type code in bytes. 26 | public readonly static int TypeLength = 1; 27 | /// Length of the IGMP max response code in bytes. 28 | public readonly static int MaxResponseTimeLength = 1; 29 | /// Length of the IGMP header checksum in bytes. 30 | public readonly static int ChecksumLength = 2; 31 | /// Length of group address in bytes. 32 | public readonly static int GroupAddressLength; 33 | /// Position of the IGMP message type. 34 | public readonly static int TypePosition = 0; 35 | /// Position of the IGMP max response code. 36 | public readonly static int MaxResponseTimePosition; 37 | /// Position of the IGMP header checksum. 38 | public readonly static int ChecksumPosition; 39 | /// Position of the IGMP group address. 40 | public readonly static int GroupAddressPosition; 41 | /// Length in bytes of an IGMP header. 42 | public readonly static int HeaderLength; // 8 43 | 44 | static IGMPv2Fields() 45 | { 46 | GroupAddressLength = IPv4Fields.AddressLength; 47 | MaxResponseTimePosition = TypePosition + TypeLength; 48 | ChecksumPosition = MaxResponseTimePosition + MaxResponseTimeLength; 49 | GroupAddressPosition = ChecksumPosition + ChecksumLength; 50 | HeaderLength = GroupAddressPosition + GroupAddressLength; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /SharpPcap/AirPcap/AirPcapKey.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of SharpPcap. 3 | 4 | SharpPcap is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | SharpPcap is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with SharpPcap. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010-2011 Chris Morgan 19 | */ 20 | 21 | using System; 22 | using System.Collections.Generic; 23 | using System.Linq; 24 | using System.Text; 25 | 26 | namespace SharpPcap.AirPcap 27 | { 28 | /// 29 | /// WEB key container 30 | /// 31 | public class AirPcapKey 32 | { 33 | /// 34 | /// Number of bytes in a wep key 35 | /// 36 | public const int WepKeyMaxSize = 32; 37 | 38 | /// 39 | /// Type of key, can be on of: \ref AIRPCAP_KEYTYPE_WEP, \ref AIRPCAP_KEYTYPE_TKIP, \ref AIRPCAP_KEYTYPE_CCMP. Only AIRPCAP_KEYTYPE_WEP is supported by the driver at the moment. 40 | /// 41 | public AirPcapKeyType Type; 42 | 43 | /// 44 | /// Key data 45 | /// 46 | public byte[] Data; 47 | 48 | /// 49 | /// Constructor 50 | /// 51 | /// 52 | /// 53 | public AirPcapKey(AirPcapKeyType Type, byte[] Data) 54 | { 55 | this.Type = Type; 56 | this.Data = Data; 57 | } 58 | 59 | internal AirPcapKey(AirPcapUnmanagedStructures.AirpcapKey key) 60 | { 61 | Type = key.KeyType; 62 | 63 | Data = new byte[key.KeyData.Length]; 64 | Array.Copy(key.KeyData, Data, Data.Length); 65 | } 66 | 67 | /// 68 | /// 69 | /// 70 | /// 71 | /// A 72 | /// 73 | public override string ToString() 74 | { 75 | return string.Format("[AirPcapKey Type: {0}, Data.Length: {1}]", 76 | Type, Data.Length); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /SharpPcap/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | // 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | // 8 | [assembly: AssemblyTitle("SharpPcap")] 9 | [assembly: AssemblyDescription("A packet capture framework for .NET")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("http://sharppcap.sf.net")] 12 | [assembly: AssemblyProduct("SharpPcap")] 13 | [assembly: AssemblyCopyright("Tamir Gal, Chris Morgan and others")] 14 | [assembly: AssemblyTrademark("SharpPcap")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 18 | // Version information for an assembly consists of the following four values: 19 | // 20 | // Major Version 21 | // Minor Version 22 | // Build Number 23 | // Revision 24 | // 25 | // You can specify all the values or you can default the Revision and Build Numbers 26 | // by using the '*' as shown below: 27 | 28 | [assembly: AssemblyVersion("4.2.0")] 29 | 30 | // 31 | // In order to sign your assembly you must specify a key to use. Refer to the 32 | // Microsoft .NET Framework documentation for more information on assembly signing. 33 | // 34 | // Use the attributes below to control which key is used for signing. 35 | // 36 | // Notes: 37 | // (*) If no key is specified, the assembly is not signed. 38 | // (*) KeyName refers to a key that has been installed in the Crypto Service 39 | // Provider (CSP) on your machine. KeyFile refers to a file which contains 40 | // a key. 41 | // (*) If the KeyFile and the KeyName values are both specified, the 42 | // following processing occurs: 43 | // (1) If the KeyName can be found in the CSP, that key is used. 44 | // (2) If the KeyName does not exist and the KeyFile does exist, the key 45 | // in the KeyFile is installed into the CSP and used. 46 | // (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. 47 | // When specifying the KeyFile, the location of the KeyFile should be 48 | // relative to the project output directory which is 49 | // %Project Directory%\obj\. For example, if your KeyFile is 50 | // located in the project directory, you would specify the AssemblyKeyFile 51 | // attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] 52 | // (*) Delay Signing is an advanced option - see the Microsoft .NET Framework 53 | // documentation for more information on this. 54 | // 55 | [assembly: AssemblyDelaySign(false)] 56 | [assembly: AssemblyKeyFile("")] 57 | [assembly: AssemblyKeyName("")] 58 | -------------------------------------------------------------------------------- /PacketDotNet/Ieee80211/PpiFieldType.cs: -------------------------------------------------------------------------------- 1 | #region Header 2 | 3 | /* 4 | This file is part of PacketDotNet 5 | 6 | PacketDotNet is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | PacketDotNet is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with PacketDotNet. If not, see . 18 | */ 19 | /* 20 | * Copyright 2011 David Thedens 21 | */ 22 | 23 | #endregion Header 24 | using System; 25 | 26 | namespace PacketDotNet 27 | { 28 | namespace Ieee80211 29 | { 30 | 31 | #region Enumerations 32 | 33 | /// 34 | /// from PPI v 1.0.10 35 | /// 36 | [Flags] 37 | public enum PpiFieldType : int 38 | { 39 | /// 40 | /// PpiReserved0 41 | /// 42 | PpiReserved0 = 0, 43 | 44 | /// 45 | /// PpiReserved1 46 | /// 47 | PpiReserved1 = 1, 48 | 49 | /// 50 | /// PpiCommon 51 | /// 52 | PpiCommon = 2, 53 | 54 | /// 55 | /// PpiMacExtensions 56 | /// 57 | PpiMacExtensions = 3, 58 | 59 | /// 60 | /// PpiMacPhy 61 | /// 62 | PpiMacPhy = 4, 63 | 64 | /// 65 | /// PpiSpectrum 66 | /// 67 | PpiSpectrum = 5, 68 | 69 | /// 70 | /// PpiProcessInfo 71 | /// 72 | PpiProcessInfo = 6, 73 | 74 | /// 75 | /// PpiCaptureInfo 76 | /// 77 | PpiCaptureInfo = 7, 78 | 79 | /// 80 | /// PpiAggregation 81 | /// 82 | PpiAggregation = 8, 83 | 84 | /// 85 | /// Ppi802_3 86 | /// 87 | Ppi802_3 = 9, 88 | 89 | /// 90 | /// PpiReservedAll 91 | /// 92 | PpiReservedAll = 10, 93 | } 94 | 95 | #endregion Enumerations 96 | } 97 | } -------------------------------------------------------------------------------- /PacketDotNet/PPPoEFields.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010 Chris Morgan 19 | */ 20 | using System; 21 | 22 | namespace PacketDotNet 23 | { 24 | /// 25 | /// Point to Point Protocol 26 | /// See http://tools.ietf.org/html/rfc2516 27 | /// 28 | public class PPPoEFields 29 | { 30 | /// Size in bytes of the version/type field 31 | public readonly static int VersionTypeLength = 1; 32 | 33 | /// Size in bytes of the code field 34 | public readonly static int CodeLength = 1; 35 | 36 | /// Size in bytes of the SessionId field 37 | public readonly static int SessionIdLength = 2; 38 | 39 | /// Size in bytes of the Length field 40 | public readonly static int LengthLength = 2; 41 | 42 | /// Offset from the start of the header to the version/type field 43 | public readonly static int VersionTypePosition = 0; 44 | 45 | /// Offset from the start of the header to the Code field 46 | public readonly static int CodePosition; 47 | 48 | /// Offset from the start of the header to the SessionId field 49 | public readonly static int SessionIdPosition; 50 | 51 | /// Offset from the start of the header to the Length field 52 | public readonly static int LengthPosition; 53 | 54 | /// 55 | /// Length of the overall PPPoe header 56 | /// 57 | public readonly static int HeaderLength; 58 | 59 | static PPPoEFields() 60 | { 61 | CodePosition = VersionTypePosition + VersionTypeLength; 62 | SessionIdPosition = CodePosition + CodeLength; 63 | LengthPosition = SessionIdPosition + SessionIdLength; 64 | 65 | HeaderLength = LengthPosition + LengthLength; 66 | } 67 | } 68 | } 69 | 70 | -------------------------------------------------------------------------------- /Mono.Nat/Upnp/AsyncResults/PortMapAsyncResult.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Authors: 3 | // Alan McGovern alan.mcgovern@gmail.com 4 | // 5 | // Copyright (C) 2006 Alan McGovern 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining 8 | // a copy of this software and associated documentation files (the 9 | // "Software"), to deal in the Software without restriction, including 10 | // without limitation the rights to use, copy, modify, merge, publish, 11 | // distribute, sublicense, and/or sell copies of the Software, and to 12 | // permit persons to whom the Software is furnished to do so, subject to 13 | // the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be 16 | // included in all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | 28 | 29 | using System; 30 | using System.Net; 31 | using System.Threading; 32 | 33 | namespace Mono.Nat.Upnp 34 | { 35 | internal class PortMapAsyncResult : AsyncResult 36 | { 37 | private WebRequest request; 38 | private MessageBase savedMessage; 39 | 40 | protected PortMapAsyncResult(WebRequest request, AsyncCallback callback, object asyncState) 41 | : base (callback, asyncState) 42 | { 43 | this.request = request; 44 | } 45 | 46 | internal WebRequest Request 47 | { 48 | get { return this.request; } 49 | set { this.request = value; } 50 | } 51 | 52 | internal MessageBase SavedMessage 53 | { 54 | get { return this.savedMessage; } 55 | set { this.savedMessage = value; } 56 | } 57 | 58 | internal static PortMapAsyncResult Create (MessageBase message, WebRequest request, AsyncCallback storedCallback, object asyncState) 59 | { 60 | if (message is GetGenericPortMappingEntry) 61 | return new GetAllMappingsAsyncResult(request, storedCallback, asyncState); 62 | 63 | if (message is GetSpecificPortMappingEntryMessage) 64 | { 65 | GetSpecificPortMappingEntryMessage mapMessage = (GetSpecificPortMappingEntryMessage)message; 66 | GetAllMappingsAsyncResult result = new GetAllMappingsAsyncResult(request, storedCallback, asyncState); 67 | 68 | result.SpecificMapping = new Mapping(mapMessage.protocol, 0, mapMessage.externalPort, 0); 69 | return result; 70 | } 71 | 72 | return new PortMapAsyncResult(request, storedCallback, asyncState); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /PacketDotNet/Utils/HexPrinter.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | 18 | using System; 19 | using System.Net.NetworkInformation; 20 | using System.Text; 21 | 22 | namespace PacketDotNet.Utils 23 | { 24 | /// 25 | /// Helper class that prints out an array of hex values 26 | /// 27 | public class HexPrinter 28 | { 29 | /// 30 | /// Create a string that contains the hex values of byte[] Byte in 31 | /// text form 32 | /// 33 | /// 34 | /// A 35 | /// 36 | /// 37 | /// A 38 | /// 39 | /// 40 | /// A 41 | /// 42 | /// 43 | /// A 44 | /// 45 | public static string GetString(byte[] Byte, 46 | int Offset, 47 | int Length) 48 | { 49 | StringBuilder sb = new StringBuilder(); 50 | 51 | for(int i = Offset; i < Offset + Length; i++) 52 | { 53 | sb.AppendFormat("[{0:x2}]", Byte[i]); 54 | } 55 | 56 | return sb.ToString(); 57 | } 58 | 59 | /// 60 | /// Creates a string from a Physical address in the format "xx:xx:xx:xx:xx:xx" 61 | /// 62 | /// 63 | /// A 64 | /// 65 | /// 66 | /// A 67 | /// 68 | public static string PrintMACAddress(PhysicalAddress address) 69 | { 70 | byte[] bytes = address.GetAddressBytes(); 71 | string output = ""; 72 | 73 | for(int i = 0; i < bytes.Length; i++) 74 | { 75 | output += bytes[i].ToString("x").PadLeft(2, '0') + ":"; 76 | } 77 | return output.TrimEnd(':'); 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /PacketDotNet/Tcp/MaximumSegmentSize.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010 Evan Plaice 19 | */ 20 | using System; 21 | using MiscUtil.Conversion; 22 | using PacketDotNet.Utils; 23 | 24 | namespace PacketDotNet.Tcp 25 | { 26 | /// 27 | /// Maximum Segment Size Option 28 | /// An extension to the DataOffset/HeaderLength field to 29 | /// allow sizes greater than 65,535 30 | /// 31 | /// 32 | /// References: 33 | /// http://datatracker.ietf.org/doc/rfc793/ 34 | /// 35 | public class MaximumSegmentSize : Option 36 | { 37 | #region Constructors 38 | 39 | /// 40 | /// Creates a Maximum Segment Size Option 41 | /// 42 | /// 43 | /// A 44 | /// 45 | /// 46 | /// A 47 | /// 48 | /// 49 | /// A 50 | /// 51 | public MaximumSegmentSize(byte[] bytes, int offset, int length) : 52 | base(bytes, offset, length) 53 | { } 54 | 55 | #endregion 56 | 57 | #region Properties 58 | 59 | /// 60 | /// The Maximum Segment Size 61 | /// 62 | public ushort Value 63 | { 64 | get { return EndianBitConverter.Big.ToUInt16(Bytes, ValueFieldOffset); } 65 | } 66 | 67 | #endregion 68 | 69 | #region Methods 70 | 71 | /// 72 | /// Returns the Option info as a string 73 | /// 74 | /// 75 | /// A 76 | /// 77 | public override string ToString() 78 | { 79 | return "[" + Kind.ToString() + ": Value=" + Value.ToString() + " bytes]"; 80 | } 81 | 82 | #endregion 83 | 84 | #region Members 85 | 86 | // the offset (in bytes) of the Value Field 87 | const int ValueFieldOffset = 2; 88 | 89 | #endregion 90 | } 91 | } -------------------------------------------------------------------------------- /PacketDotNet/LLDP/PortDescription.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010 Evan Plaice 19 | * Copyright 2010 Chris Morgan 20 | */ 21 | using System; 22 | using System.Text; 23 | using PacketDotNet.Utils; 24 | 25 | namespace PacketDotNet.LLDP 26 | { 27 | /// 28 | /// A Port Description TLV 29 | /// 30 | public class PortDescription : StringTLV 31 | { 32 | #if DEBUG 33 | private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 34 | #else 35 | // NOTE: No need to warn about lack of use, the compiler won't 36 | // put any calls to 'log' here but we need 'log' to exist to compile 37 | #pragma warning disable 0169, 0649 38 | private static readonly ILogInactive log; 39 | #pragma warning restore 0169, 0649 40 | #endif 41 | 42 | #region Constructors 43 | 44 | /// 45 | /// Creates a Port Description TLV 46 | /// 47 | /// 48 | /// 49 | /// 50 | /// The Port Description TLV's offset from the 51 | /// origin of the LLDP 52 | /// 53 | public PortDescription(byte[] bytes, int offset) : 54 | base(bytes, offset) 55 | { 56 | log.Debug(""); 57 | } 58 | 59 | /// 60 | /// Creates a Port Description TLV and sets it value 61 | /// 62 | /// 63 | /// A textual description of the port 64 | /// 65 | public PortDescription(string description) : base(TLVTypes.PortDescription, description) 66 | { 67 | log.Debug(""); 68 | } 69 | 70 | #endregion 71 | 72 | #region Properties 73 | 74 | /// 75 | /// A textual Description of the port 76 | /// 77 | public string Description 78 | { 79 | get { return StringValue; } 80 | set { StringValue = value; } 81 | } 82 | 83 | #endregion 84 | } 85 | } -------------------------------------------------------------------------------- /PacketDotNet/Utils/RandomUtils.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | 18 | using System; 19 | using System.Collections.Generic; 20 | using System.Net; 21 | 22 | namespace PacketDotNet.Utils 23 | { 24 | /// 25 | /// Random utility methods 26 | /// 27 | public class RandomUtils 28 | { 29 | /// 30 | /// Generate a random ip address 31 | /// 32 | /// 33 | /// A 34 | /// 35 | /// 36 | /// A 37 | /// 38 | public static System.Net.IPAddress GetIPAddress(IpVersion version) 39 | { 40 | var rnd = new Random(); 41 | byte[] randomAddressBytes; 42 | 43 | if(version == IpVersion.IPv4) 44 | { 45 | randomAddressBytes = new byte[IPv4Fields.AddressLength]; 46 | rnd.NextBytes(randomAddressBytes); 47 | } else if(version == IpVersion.IPv6) 48 | { 49 | randomAddressBytes = new byte[IPv6Fields.AddressLength]; 50 | rnd.NextBytes(randomAddressBytes); 51 | } else 52 | { 53 | throw new System.InvalidOperationException("Unknown version of " + version); 54 | } 55 | 56 | return new System.Net.IPAddress(randomAddressBytes); 57 | } 58 | 59 | /// 60 | /// Get the length of the longest string in a list of strings 61 | /// 62 | /// 63 | /// A 64 | /// 65 | /// 66 | /// A 67 | /// 68 | public static int LongestStringLength(List stringsList) 69 | { 70 | string longest=""; 71 | 72 | foreach(string L in stringsList) 73 | { 74 | if (L.Length > longest.Length) 75 | { 76 | longest = L; 77 | } 78 | } 79 | return longest.Length; 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /PacketDotNet/MiscUtil/Conversion/LittleEndianBitConverter.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace MiscUtil.Conversion 3 | { 4 | /// 5 | /// Implementation of EndianBitConverter which converts to/from little-endian 6 | /// byte arrays. 7 | /// 8 | public sealed class LittleEndianBitConverter : EndianBitConverter 9 | { 10 | /// 11 | /// Indicates the byte order ("endianess") in which data is converted using this class. 12 | /// 13 | /// 14 | /// Different computer architectures store data using different byte orders. "Big-endian" 15 | /// means the most significant byte is on the left end of a word. "Little-endian" means the 16 | /// most significant byte is on the right end of a word. 17 | /// 18 | /// true if this converter is little-endian, false otherwise. 19 | public sealed override bool IsLittleEndian() 20 | { 21 | return true; 22 | } 23 | 24 | /// 25 | /// Indicates the byte order ("endianess") in which data is converted using this class. 26 | /// 27 | public sealed override Endianness Endianness 28 | { 29 | get { return Endianness.LittleEndian; } 30 | } 31 | 32 | /// 33 | /// Copies the specified number of bytes from value to buffer, starting at index. 34 | /// 35 | /// The value to copy 36 | /// The number of bytes to copy 37 | /// The buffer to copy the bytes into 38 | /// The index to start at 39 | protected override void CopyBytesImpl(long value, int bytes, byte[] buffer, int index) 40 | { 41 | for (int i=0; i < bytes; i++) 42 | { 43 | buffer[i+index] = unchecked((byte)(value&0xff)); 44 | value = value >> 8; 45 | } 46 | } 47 | 48 | /// 49 | /// Returns a value built from the specified number of bytes from the given buffer, 50 | /// starting at index. 51 | /// 52 | /// The data in byte array format 53 | /// The first index to use 54 | /// The number of bytes to use 55 | /// The value built from the given bytes 56 | protected override long FromBytes(byte[] buffer, int startIndex, int bytesToConvert) 57 | { 58 | long ret = 0; 59 | for (int i=0; i < bytesToConvert; i++) 60 | { 61 | ret = unchecked((ret << 8) | buffer[startIndex+bytesToConvert-1-i]); 62 | } 63 | return ret; 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /PacketDotNet/Tcp/AlternateChecksumRequest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of PacketDotNet 3 | 4 | PacketDotNet is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | PacketDotNet is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with PacketDotNet. If not, see . 16 | */ 17 | /* 18 | * Copyright 2010 Evan Plaice 19 | */ 20 | using System; 21 | using MiscUtil.Conversion; 22 | using PacketDotNet.Utils; 23 | 24 | namespace PacketDotNet.Tcp 25 | { 26 | /// 27 | /// AlternateChecksumRequest Option 28 | /// 29 | public class AlternateChecksumRequest : Option 30 | { 31 | #region Constructors 32 | 33 | /// 34 | /// Creates an Alternate Checksum Request Option 35 | /// Used to negotiate an alternative checksum algorithm in a connection 36 | /// 37 | /// 38 | /// A 39 | /// 40 | /// 41 | /// A 42 | /// 43 | /// 44 | /// A 45 | /// 46 | /// 47 | /// References: 48 | /// http://datatracker.ietf.org/doc/rfc1146/ 49 | /// 50 | public AlternateChecksumRequest(byte[] bytes, int offset, int length) : 51 | base(bytes, offset, length) 52 | { } 53 | 54 | #endregion 55 | 56 | #region Properties 57 | 58 | /// 59 | /// The Checksum 60 | /// 61 | public ChecksumAlgorighmType Checksum 62 | { 63 | get { return (ChecksumAlgorighmType)Bytes[ChecksumFieldOffset]; } 64 | } 65 | 66 | #endregion 67 | 68 | #region Methods 69 | 70 | /// 71 | /// Returns the Option info as a string 72 | /// 73 | /// 74 | /// A 75 | /// 76 | public override string ToString() 77 | { 78 | return "[" + Kind.ToString() + ": ChecksumType=" + Checksum.ToString() + "]"; 79 | } 80 | 81 | #endregion 82 | 83 | #region Members 84 | 85 | // the offset (in bytes) of the Checksum field 86 | const int ChecksumFieldOffset = 2; 87 | 88 | #endregion 89 | } 90 | } --------------------------------------------------------------------------------