Build并运行上述程序,从Memo1里可以看到整个工作过程,可以看出,搜索设备、取控制页URL、增加端口映射项、查看映射项参数、删除映射项等关键步骤均符合我们预期的设想。因此,完全可以在您的应用中把本程序的有关内容集成进去。
--------------------------------------------------------------------------
(1)、以下是“搜索设备”的工作过程信息:
--------------------------------------------------------------------------
发出了如下命令:
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
MAN: "ssdp:discover"
MX: 3
ST: upnp:rootdevice
从192.168.0.1:1900收到289个字节的数据!
收到的信息如下:
HTTP/1.1 200 OK
Cache-Control: max-age=1800
Date: Thu, 01 Jan 1970 00:37:12 GMT
Ext:
Location: http://192.168.0.1:1780/InternetGatewayDevice.xml
Server: os/ver 2.0 UPnP/1.0 router/(5+20).1.2.99
ST: upnp:rootdevice
USN: uuid:7fff6211-b0fa-4075-a15c-0b624d01bfb4::upnp:rootdevice
*******************************************
Location=http://192.168.0.1:1780/InternetGatewayDevice.xml
Device IP=192.168.0.1
Device Port=1780
Server=os/ver 2.0 UPnP/1.0 router/(5+20).1.2.99
USN=uuid:7fff6211-b0fa-4075-a15c-0b624d01bfb4::upnp:rootdevice
*******************************************
--------------------------------------------------------------------------
(2)、以下是“获取控制页URL”的工作过程信息:
--------------------------------------------------------------------------
向192.168.0.1:1780设备发起连接...
与192.168.0.1:1780设备成功连接
向192.168.0.1:1780提交如下查询请求:
GET /InternetGatewayDevice.xml HTTP/1.1
Host: 192.168.0.1:1780
从192.168.0.1:1780收到如下应答数据:
HTTP/1.1 200 OK
Content-Type: text/xml
Content-Length: 3778
Connection: close
Pragma: no-cache
<?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<URLBase></URLBase>
<device>
<deviceType>urn:schemas-upnp-org:device:InternetGatewayDevice:1</deviceType>
<friendlyName>DI-504</friendlyName>
<manufacturer>D-Link Sytems, Inc.</manufacturer>
<manufacturerURL>http://www.dlink.com</manufacturerURL>
<modelDeion>Internet Access Router</modelDeion>
<modelName>DI-504</modelName>
<modelURL>http://www.dlink.com</modelURL>
<UDN>uuid:7fff6211-b0fa-4075-a15c-0b624d01bfb4</UDN>
<serviceList>
<service>
<serviceType>urn:schemas-upnp-org:service:Layer3Forwarding:1</serviceType>
<serviceId>urn:upnp-org:serviceId:L3Forwarding1</serviceId>
<SCPDURL>/x_layer3forwarding.xml</SCPDURL>
<controlURL>/control?Layer3Forwarding</controlURL>
<eventSubURL>/event?Layer3Forwarding</eventSubURL>
</service>
</serviceList>
<deviceList>
<device>
<deviceType>urn:schemas-upnp-org:device:WANDevice:1</deviceType>
<friendlyName>WANDevice</friendlyName>
<manufacturer>D-Link Sytems, Inc.</manufacturer>
<manufacturerURL>http://www.dlink.com</manufacturerURL>
<modelDeion>Internet Access Router</modelDeion>
<modelName>DI-504</modelName&