C# Class Tsukikage.Net.UPnPWanService

UPnPを使って、いわゆる「ルータのポート穴あけ」をしてくれるクラス。
ファイルを表示 Open project: ttsuki/ttsuki Class Usage Examples

Public Methods

Method Description
AddPortMapping ( UPnPPortMapping portMapping ) : void

ポートマッピングを追加する。

AddPortMapping ( string remoteHost, ushort externalPort, string protocol, ushort internalPort, IPAddress internalClient, bool enabled, string description, uint leaseDuration ) : void

ポートマッピングを追加する。

DeletePortMapping ( UPnPPortMapping portMapping ) : void

ポートマッピングを削除する。

DeletePortMapping ( string remoteHost, ushort externalPort, string protocol ) : void

ポートマッピングを削除する。

FindUPnPWanService ( ) : UPnPWanService

ネットワーク内の UPnP Wan サービスを探す。ちょっと時間がかかる。 見つからなかったときはnullが返るので気をつける。

GetExternalIPAddress ( ) : IPAddress

グローバルIPアドレスを得る。

GetGenericPortMappingEntries ( ) : List

現在設定されているポートマッピング情報を得る。

GetLocalIPAddress ( ) : IPAddress

自分のIPアドレス(v4)を得る。

Test ( ) : void

テスト兼サンプル

Private Methods

Method Description
ThrowForHR ( string action, HRESULT_UPnP hr, object result ) : void
UPnPWanService ( ) : System

Method Details

AddPortMapping() public method

ポートマッピングを追加する。
public AddPortMapping ( UPnPPortMapping portMapping ) : void
portMapping UPnPPortMapping 追加するポートマッピング
return void

AddPortMapping() public method

ポートマッピングを追加する。
public AddPortMapping ( string remoteHost, ushort externalPort, string protocol, ushort internalPort, IPAddress internalClient, bool enabled, string description, uint leaseDuration ) : void
remoteHost string 通信相手。通信先を限定する場合に指定。
externalPort ushort グローバルポート番号。
protocol string プロトコル名。"TCP" or "UDP"を指定。
internalPort ushort 内部クライアントのポート番号。
internalClient System.Net.IPAddress 内部クライアントのIPアドレス。
enabled bool
description string 説明。任意。
leaseDuration uint リース期間(秒単位)。0を指定すると無期限
return void

DeletePortMapping() public method

ポートマッピングを削除する。
public DeletePortMapping ( UPnPPortMapping portMapping ) : void
portMapping UPnPPortMapping 削除するポートマッピング。RemoteHostとExternalPortとProtocolだけが使われる。
return void

DeletePortMapping() public method

ポートマッピングを削除する。
public DeletePortMapping ( string remoteHost, ushort externalPort, string protocol ) : void
remoteHost string 追加時に指定した通信相手。
externalPort ushort 追加時に指定した外部ポート番号。
protocol string 追加時に指定されたプロトコル。
return void

FindUPnPWanService() public static method

ネットワーク内の UPnP Wan サービスを探す。ちょっと時間がかかる。 見つからなかったときはnullが返るので気をつける。
public static FindUPnPWanService ( ) : UPnPWanService
return UPnPWanService

GetExternalIPAddress() public method

グローバルIPアドレスを得る。
public GetExternalIPAddress ( ) : IPAddress
return System.Net.IPAddress

GetGenericPortMappingEntries() public method

現在設定されているポートマッピング情報を得る。
public GetGenericPortMappingEntries ( ) : List
return List

GetLocalIPAddress() public method

自分のIPアドレス(v4)を得る。
public GetLocalIPAddress ( ) : IPAddress
return System.Net.IPAddress

Test() public static method

テスト兼サンプル
public static Test ( ) : void
return void