using System;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
/// Items from the P2P.dll
public static partial class P2P
{
///
public const int PNRP_MAX_ENDPOINT_ADDRESSES = 10;
///
public const int PNRP_MAX_EXTENDED_PAYLOAD_BYTES = 0x1000;
///
public const string WSZ_SCOPE_GLOBAL = "GLOBAL";
///
public const string WSZ_SCOPE_LINKLOCAL = "LINKLOCAL";
///
public const string WSZ_SCOPE_SITELOCAL = "SITELOCAL";
/// The PNRP_CLOUD_FLAGS enumeration specifies the validity of a cloud name.
// https://docs.microsoft.com/en-us/windows/win32/api/pnrpdef/ne-pnrpdef-pnrp_cloud_flags typedef enum _PNRP_CLOUD_FLAGS {
// PNRP_CLOUD_NO_FLAGS, PNRP_CLOUD_NAME_LOCAL, PNRP_CLOUD_RESOLVE_ONLY, PNRP_CLOUD_FULL_PARTICIPANT } PNRP_CLOUD_FLAGS;
[PInvokeData("pnrpdef.h", MSDNShortId = "NE:pnrpdef._PNRP_CLOUD_FLAGS")]
[Flags]
public enum PNRP_CLOUD_FLAGS
{
/// The cloud name is valid on the network.
PNRP_CLOUD_NO_FLAGS = 0x0,
/// The cloud name is not valid on other computers.
PNRP_CLOUD_NAME_LOCAL = 0x1,
/// The cloud is configured to be resolve only. Names cannot be published to the cloud from this computer.
PNRP_CLOUD_RESOLVE_ONLY = 0x2,
/// This machine is a full participant in the cloud, and can publish and resolve names.
PNRP_CLOUD_FULL_PARTICIPANT = 0x4,
}
/// The PNRP_CLOUD_STATE enumeration specifies the different states a PNRP cloud can be in.
// https://docs.microsoft.com/en-us/windows/win32/api/pnrpdef/ne-pnrpdef-pnrp_cloud_state typedef enum _PNRP_CLOUD_STATE {
// PNRP_CLOUD_STATE_VIRTUAL, PNRP_CLOUD_STATE_SYNCHRONISING, PNRP_CLOUD_STATE_ACTIVE, PNRP_CLOUD_STATE_DEAD,
// PNRP_CLOUD_STATE_DISABLED, PNRP_CLOUD_STATE_NO_NET, PNRP_CLOUD_STATE_ALONE } PNRP_CLOUD_STATE;
[PInvokeData("pnrpdef.h", MSDNShortId = "NE:pnrpdef._PNRP_CLOUD_STATE")]
public enum PNRP_CLOUD_STATE
{
/// The cloud is not yet initialized.
PNRP_CLOUD_STATE_VIRTUAL = 0,
/// The cloud is in the process of being initialized.
PNRP_CLOUD_STATE_SYNCHRONISING,
/// The cloud is active.
PNRP_CLOUD_STATE_ACTIVE,
/// The cloud is initialized, but has lost its connection to the network.
PNRP_CLOUD_STATE_DEAD,
/// The cloud is disabled in the registry.
PNRP_CLOUD_STATE_DISABLED,
///
/// The cloud was active, but has lost access to the network. In this state the cloud can still be used for registration but it
/// is not capable of resolving addresses.
///
PNRP_CLOUD_STATE_NO_NET,
///
/// The local node bootstrapped, but found no other nodes in the cloud. This can also be the result of a network issue, like a
/// firewall, preventing the local node from locating other nodes within the cloud. It is also important to note that a cloud in
/// the PNRP_CLOUD_STATE_ALONE state may not have registered IP addresses.
///
PNRP_CLOUD_STATE_ALONE,
}
///
[PInvokeData("pnrpdef.h")]
public enum PNRP_EXTENDED_PAYLOAD_TYPE
{
///
PNRP_EXTENDED_PAYLOAD_TYPE_NONE = 0,
///
PNRP_EXTENDED_PAYLOAD_TYPE_BINARY,
///
PNRP_EXTENDED_PAYLOAD_TYPE_STRING,
}
/// Registered name state.
[PInvokeData("pnrpdef.h")]
public enum PNRP_REGISTERED_ID_STATE
{
/// Id is active in cloud
PNRP_REGISTERED_ID_STATE_OK = 1,
/// Id is no longer registered in cloud
PNRP_REGISTERED_ID_STATE_PROBLEM = 2
}
/// The PNRP_RESOLVE_CRITERIA enumeration specifies the criteria that PNRP uses to resolve searches.
// https://docs.microsoft.com/en-us/windows/win32/api/pnrpdef/ne-pnrpdef-pnrp_resolve_criteria typedef enum _PNRP_RESOLVE_CRITERIA {
// PNRP_RESOLVE_CRITERIA_DEFAULT, PNRP_RESOLVE_CRITERIA_REMOTE_PEER_NAME, PNRP_RESOLVE_CRITERIA_NEAREST_REMOTE_PEER_NAME,
// PNRP_RESOLVE_CRITERIA_NON_CURRENT_PROCESS_PEER_NAME, PNRP_RESOLVE_CRITERIA_NEAREST_NON_CURRENT_PROCESS_PEER_NAME,
// PNRP_RESOLVE_CRITERIA_ANY_PEER_NAME, PNRP_RESOLVE_CRITERIA_NEAREST_PEER_NAME } PNRP_RESOLVE_CRITERIA;
[PInvokeData("pnrpdef.h", MSDNShortId = "NE:pnrpdef._PNRP_RESOLVE_CRITERIA")]
public enum PNRP_RESOLVE_CRITERIA
{
///
/// Use the PNRP_RESOLVE_CRITERIA_NON_CURRENT_PROCESS_PEER_NAME criteria. This is also the default behavior if PNRPINFO is not specified.
///
PNRP_RESOLVE_CRITERIA_DEFAULT = 0,
/// Match a peer name. The resolve request excludes any peer name registered locally on this computer.
PNRP_RESOLVE_CRITERIA_REMOTE_PEER_NAME,
///
/// Match a peer name by finding the name with a service location closest to the supplied hint, or if no hint is supplied,
/// closest to the local IP address. The resolve request excludes any peer name registered locally on this computer.
///
PNRP_RESOLVE_CRITERIA_NEAREST_REMOTE_PEER_NAME,
///
/// Match a peer name. The matching peer name can be registered locally or remotely, but the resolve request excludes any peer
/// name registered by the process making the resolve request.
///
PNRP_RESOLVE_CRITERIA_NON_CURRENT_PROCESS_PEER_NAME,
///
/// Match a peer name by finding the name with a service location closest to the supplied hint, or if no hint is supplied,
/// closest to the local IP address. The matching peer name can be registered locally or remotely, but the resolve request
/// excludes any peer name registered by the process making the resolve request.
///
PNRP_RESOLVE_CRITERIA_NEAREST_NON_CURRENT_PROCESS_PEER_NAME,
/// Match a peer name. The matching peer name can be registered locally or remotely.
PNRP_RESOLVE_CRITERIA_ANY_PEER_NAME,
///
/// Match a peer name by finding the name with a service location closest to the supplied hint, or if no hint is supplied,
/// closest to the local IP address. The matching peer name can be registered locally or remotely.
///
PNRP_RESOLVE_CRITERIA_NEAREST_PEER_NAME,
}
/// Specifies the scope under which the peer group was registered.
[PInvokeData("pnrpdef.h")]
public enum PNRP_SCOPE
{
/// Any scope.
PNRP_SCOPE_ANY = 0, // Any
/// Global scope, including the Internet.
PNRP_GLOBAL_SCOPE = 1, // global
/// Local scope.
PNRP_SITE_LOCAL_SCOPE = 2, // site local
/// Link-local scope.
PNRP_LINK_LOCAL_SCOPE = 3 // link local
}
/// The PNRP_CLOUD_ID structure contains the values that define a network cloud.
// https://docs.microsoft.com/en-us/windows/win32/api/pnrpdef/ns-pnrpdef-pnrp_cloud_id typedef struct _PNRP_CLOUD_ID { INT
// AddressFamily; PNRP_SCOPE Scope; ULONG ScopeId; } PNRP_CLOUD_ID, *PPNRP_CLOUD_ID;
[PInvokeData("pnrpdef.h", MSDNShortId = "NS:pnrpdef._PNRP_CLOUD_ID")]
[StructLayout(LayoutKind.Sequential)]
public struct PNRP_CLOUD_ID
{
/// Must be AF_INET6.
public System.Net.Sockets.AddressFamily AddressFamily;
///
/// Specifies the scope of the cloud. Use one of the following values:
///
///
/// Value
/// Description
///
/// -
/// PNRP_SCOPE_ANY
/// The cloud can be in any scope.
///
/// -
/// PNRP_GLOBAL_SCOPE
/// The cloud must be a global scope.
///
/// -
/// PNRP_SITE_LOCAL_SCOPE
/// The cloud must be a site-local scope.
///
/// -
/// PNRP_LINK_LOCAL_SCOPE
/// The cloud must be a link-local scope.
///
///
///
public PNRP_SCOPE Scope;
/// Specifies the ID for this scope.
public uint ScopeId;
}
}
}