MirrorLink(三 UPNP)-- 使用

news/2024/11/28 11:33:37/

1、使用libupnp,首先发现设备:

可以获取到一些信息:

ApplicationServer相关信息:

serviceType : urn:schemas-upnp-org:service:TmApplicationServer:1
serviceId : urn:upnp-org:serviceId:TmApplicationServer1

SCPDURL : http://192.168.42.129:4004/tmapplicationserver.xml
controlURL : http://192.168.42.129:4004/TmApplicationServer-control
eventSubURL : http://192.168.42.129:4004/TmApplicationServer-eventing

2、ClientProfile相关信息

serviceType : urn:schemas-upnp-org:service:TmClientProfile:1...
Subscribing to serviceId : urn:upnp-org:serviceId:TmClientProfile1

Subscribing to serviceId : urn:upnp-org:serviceId:TmClientProfile1...
Subscribing to SCPDURL : http://192.168.42.129:4004/tmclientprofile.xml...
Subscribing to controlURL : http://192.168.42.129:4004/TmClientProfile1-control...
Subscribing to eventSubURL : http://192.168.42.129:4004/TmClientProfile1-eventing

二、然后通过这些url去获取其他的详细信息:

1、GetMaxNumProfiles,获取最大支持的profile数量,一般为1,那么说明profileID为0

<u:GetMaxNumProfilesResponse xmlns:u="urn:schemas-upnp-org:service:TmClientProfile:1">
<NumProfilesAllowed>1</NumProfilesAllowed>^M
</u:GetMaxNumProfilesResponse>

2、使用profileID=0调用SetClientProfile

3、之后就可以调用GetApplicationList获取所有application列表

<?xml version="1.0"?>
<u:GetApplicationListResponse xmlns:u="urn:schemas-upnp-org:service:TmApplicationServer:1">
<AppListing><appList><app><appID>0x4</appID><name>Bluetooth HFP</name><description>Bluetooth HFP Audio</description><allowedProfileIDs>0</allowedProfileIDs><remotingInfo><protocolID>BTHFP</protocolID><direction>bi</direction></remotingInfo><audioInfo><audioType>phone</audioType><contentCategory>0x1</contentCategory><contentRules>0x0</contentRules><trustLevel>0x80</trustLevel></audioInfo><resourceStatus>free</resourceStatus></app><app><appID>0x3</appID><name>Bluetooth A2DP</name><description>Bluetooth A2DP Audio Server</description><allowedProfileIDs>0</allowedProfileIDs><remotingInfo><protocolID>BTA2DP</protocolID><direction>out</direction></remotingInfo><audioInfo><audioType>application</audioType><contentCategory>0x2</contentCategory><contentRules>0x0</contentRules><trustLevel>0x80</trustLevel></audioInfo><resourceStatus>free</resourceStatus></app><app><appID>0x5</appID><name>RTP Server 99</name><description>RTP Audio Server</description><allowedProfileIDs>0</allowedProfileIDs><remotingInfo><protocolID>RTP</protocolID><format>99</format><direction>out</direction><audioIPL>4800</audioIPL><audioMPL>9600</audioMPL></remotingInfo><appInfo><appCategory>0xf0000001</appCategory><trustLevel>0x80</trustLevel></appInfo><audioInfo><audioType>application</audioType><contentCategory>0x2</contentCategory><contentRules>0x0</contentRules><trustLevel>0x80</trustLevel></audioInfo><resourceStatus>free</resourceStatus></app><app><appID>0x6</appID><name>RTP Server 98</name><description>RTP Audio Server</description><allowedProfileIDs>0</allowedProfileIDs><remotingInfo><protocolID>RTP</protocolID><format>98</format><direction>out</direction><audioIPL>4800</audioIPL><audioMPL>9600</audioMPL></remotingInfo><appInfo><appCategory>0xf0000001</appCategory><trustLevel>0x80</trustLevel></appInfo><audioInfo><audioType>application</audioType><contentCategory>0x2</contentCategory><contentRules>0x0</contentRules><trustLevel>0x80</trustLevel></audioInfo><resourceStatus>free</resourceStatus></app><app><appID>0x7</appID><name>RTP Client 99</name><description>RTP Audio Client</description><allowedProfileIDs>0</allowedProfileIDs><remotingInfo><protocolID>RTP</protocolID><format>99</format><direction>in</direction><audioIPL>4800</audioIPL><audioMPL>9600</audioMPL></remotingInfo><appInfo><appCategory>0xf0000002</appCategory><trustLevel>0x80</trustLevel></appInfo><audioInfo><audioType>phone</audioType><contentCategory>0x10</contentCategory><contentRules>0x0</contentRules><trustLevel>0x80</trustLevel></audioInfo><resourceStatus>free</resourceStatus></app><app><appID>0x8</appID><name>RTP Client 98</name><description>RTP Audio Client</description><allowedProfileIDs>0</allowedProfileIDs><remotingInfo><protocolID>RTP</protocolID><format>98</format><direction>in</direction><audioIPL>4800</audioIPL><audioMPL>9600</audioMPL></remotingInfo><appInfo><appCategory>0xf0000002</appCategory><trustLevel>0x80</trustLevel></appInfo><audioInfo><audioType>phone</audioType><contentCategory>0x10</contentCategory><contentRules>0x0</contentRules><trustLevel>0x80</trustLevel></audioInfo><resourceStatus>free</resourceStatus></app><app><appID>0x9</appID><name>Device Attestation</name><allowedProfileIDs>0</allowedProfileIDs><remotingInfo><protocolID>DAP</protocolID></remotingInfo><appInfo><appCategory>0xf0000001</appCategory><trustLevel>0x0</trustLevel></appInfo><resourceStatus>free</resourceStatus></app><app><appID>0xa</appID><name>Common Data Bus</name><description>CDB Server Endpoint</description><allowedProfileIDs>0</allowedProfileIDs><remotingInfo><protocolID>CDB</protocolID><format>1.1</format></remotingInfo><appInfo><appCategory>0xf0000000</appCategory><trustLevel>0x80</trustLevel></appInfo><resourceStatus>free</resourceStatus></app>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></ds:CanonicalizationMethod>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"></ds:SignatureMethod>
<ds:Reference URI="">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"></ds:Transform>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></ds:Transform>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></ds:DigestMethod>
<ds:DigestValue>pAijzscQ7RO3w/PwNyDLvYgLKps=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>
ydcWz3u/32wDEVbG7D/hB8/P0TG0KL2Plt3y8zMIg95LRsKNcafX/nR40/JLH/bfCtg4lmrgoHCq
3OJvtrhZUhm6cRS/WnyX0WX8mZR9d0clt4q7SYKDVbO8kLX9yL4/HspvACAZtMYd6y6ODKP6s/DM
niJwsDgfpEoR1u8JBDEA6GtzElTgdZdIws3QlM/IzEQm0K4BVVlkUxF4QmBVIQiLymp+6rNWWtd8
U2K3mRtaEwUhHVG8on0xNCyx+7+WgrbQHp5eLBirVEw4gXxMXp5UEIH17CPbHw5le1tRsPz9es1K
ip8JDw0EChmxEmdLn/Om3s34vibLWpyBWBPH9g==
</ds:SignatureValue>
</ds:Signature></appList>
</AppListing>
</u:GetApplicationListResponse>

4、然后可以根据app相关信息调用函数GetCertifiedApplicationsList、GetApplicationCertificateInfo、GetApplicationStatus、LaunchApplication和TerminateApplication

<?xml version="1.0"?>
<u:GetCertifiedApplicationsList xmlns:u="urn:schemas-upnp-org:service:TmApplicationServer:1">
<AppCertFilter>*</AppCertFilter>
<ProfileID>0</ProfileID>
</u:GetCertifiedApplicationsList><?xml version="1.0"?>
<u:GetCertifiedApplicationsListResponse xmlns:u="urn:schemas-upnp-org:service:TmApplicationServer:1">
<CertifiedAppList>0x2,0xb</CertifiedAppList>
</u:GetCertifiedApplicationsListResponse><?xml version="1.0"?>
<u:LaunchApplication xmlns:u="urn:schemas-upnp-org:service:TmApplicationServer:1">
<AppID>0x2</AppID>
<ProfileID>0</ProfileID>
</u:LaunchApplication><?xml version="1.0"?>
<u:TerminateApplication xmlns:u="urn:schemas-upnp-org:service:TmApplicationServer:1">
<AppID>0x2</AppID>
<ProfileID>0</ProfileID>
</u:TerminateApplication><?xml version="1.0"?>
<u:GetApplicationCertificateInfo xmlns:u="urn:schemas-upnp-org:service:TmApplicationServer:1">
<AppID>0x6</AppID>
</u:GetApplicationCertificateInfo><?xml version="1.0"?>
<u:GetApplicationCertificateInfoResponse xmlns:u="urn:schemas-upnp-org:service:TmApplicationServer:1">
<AppCertification></AppCertification>
</u:GetApplicationCertificateInfoResponse><?xml version="1.0"?>
<u:GetApplicationStatus xmlns:u="urn:schemas-upnp-org:service:TmApplicationServer:1">
<AppID>0x6</AppID>
</u:GetApplicationStatus><?xml version="1.0"?>
<u:GetApplicationStatusResponse xmlns:u="urn:schemas-upnp-org:service:TmApplicationServer:1">
<AppStatus>&lt;appStatusList&gt;&lt;appStatus&gt;&lt;appID&gt;0x6&lt;/appID&gt;&lt;status&gt;&lt;profileID&gt;0&lt;/profileID&gt;&lt;statusType&gt;Notrunning&lt;/statusType&gt;&lt;/status&gt;&lt;/appStatus&gt;
&lt;/appStatusList&gt;
</AppStatus>
</u:GetApplicationStatusResponse>解析以后:
<?xml version="1.0"?>
<u:GetApplicationStatusResponse xmlns:u="urn:schemas-upnp-org:service:TmApplicationServer:1">
<AppStatus><appStatusList><appStatus><appID>0x6</appID><status><profileID>0</profileID><statusType>Notrunning</statusType></status></appStatus>
</appStatusList>
</AppStatus>
</u:GetApplicationStatusResponse>

三、libupnp的编译

libupnp 来源于http://pupnp.sourceforge.net/,其有多个版本可以下载;

如libupnp版本1.8.4下载后为libupnp-1.8.4.tar.bz2,需要将其放置到Ubuntu中进行解压,libupnp的文档也在此压缩档中;

解压方式是:

.tar.gz     格式解压为  tar   -zxvf   xx.tar.gz

.tar.bz2   格式解压为   tar   -jxvf    xx.tar.bz2

编译

系统要求

            libpthread程序包 --由于threadutil使用了pthread线程,所以这个包要提前安装

编译

        核心库的编译

            $ cd $(LIBUPNP) 进入libupnp根目录

            $ ./configure   #默认配置下,会将include文件安在/usr/local/include/upnp目录

                    #将lib文件安装在/usr/local/lib目录下

            $ make    #编译核心库    

            $ sudo make install

四、libupnp库的修改

由于usb断开时,upnp发送断开太慢,所以需要进行修改:

1、\libupnp-1.8.4\upnp\src\inc\upnpapi.h(socket读写超时设置成2s)

2、libupnp-1.8.4\upnp\src\inc\httpreadwrite.h(http超时设置成2s)

3、libupnp-1.8.4\upnp\src\genlib\net\http\httpreadwrite.c(connect非阻塞模式timeout由5s修改成2s)

4、libupnp-1.8.4\configure(connect修改成非阻塞模式)


http://www.ppmy.cn/news/350487.html

相关文章

UPNP编程要点

UPNP编程 安装SDK相对比较简单&#xff0c;参考阅读SDK目录下的README 我使用命令如下&#xff1a; tar jxvf libupnp-1.6.17.tar.bz2 cd libupnp-1.6.17/ ./configure --prefix/home/momo/DLNA --enable-sample make make install 这样在/home/momo/DLNA目录下就可以…

CTF Crypto --- orz!

文章目录 题目解题过程 题目 from Crypto.Util.number import * from gmpy2 import *flag bxxx t len(flag)//3 part1 bytes_to_long(flag[:t]) part2 bytes_to_long(flag[t:2*t]) part3 bytes_to_long(flag[2*t:]) q getPrime(1024) p next_prime(q) n p * qo getPr…

UPnP实现中的常见脆弱性与风险分析

UPnP 协议栈的脆弱性 与风险分析 由于 UPnP 协议栈包含的协议较多&#xff0c;在实现过程中&#xff0c;容易存在脆弱性。而在 UPnP 工作流程的六个 阶段中&#xff0c;发现、描述、控制三个阶段出现过比较严重的脆弱性问题。这些脆弱性广泛存在于支持 UPnP 技术的物联网 设备…

UPNP自动端口映射的实现与路由器UPNP相关资料

UPNP的全称是 Universal plug-and-play( 通用即插即用).UPnP 是针对智能家电、无线设备以及各种外观尺寸的个人电脑的普遍对等&#xff08;peer-to-peer&#xff09;网络连接而设计的一种架构。它旨在为家庭、小型企业、公共场 所中或连接到互联网的ad-hoc 网或未管理网络提供易…

显示upnp服务器 sonos,四步解决UPNP功能被阻塞的问题

6. ESET NOD32 安全套装/EAV的下载杀毒参数(如迅雷的下载后扫描,虽然感觉没必要,但还是写出来啦) ESET NOD32安全套装、EAV是用“ecls.exe”来进行下载后杀毒的,在迅雷下载软件中添加“ecls.exe” 例如: ESET NOD32安全套装:“C:\Program Files\ESET\ESET Smart Security\…

UPNP编程

零、SDK的安装 upnp的概念就不理会了&#xff0c;网上很多&#xff0c;这里偏向于具体编程。 SDK使用upnp1.6.17版本&#xff0c;这是一个linux下的开源版本&#xff0c;目前仍然在维护&#xff0c;下载地址&#xff1a; http://pupnp.sourceforge.net/ 安装SDK相对比较简单&am…

QQ相册加密?!

从今 年很黄很暴力的艳照门不难看出 对照片的隐私的保存是多么重要 QQ相册是很多朋友存放照片的地方,不想给陌生人看的照片加个密,或者干脆在空间里设置个密码,但是这真的安全么? 在没有密码的情况下 我们很难进入对方的QQ空间,虽然TX的漏洞不断,但是总是能及时补上 可是...…

直流充电桩产品主控模块软硬件源码资料/支持以太网

直流充电桩产品主控模块软硬件源码资料/支持以太网/刷卡等功能 直流充电桩产品硬件控制源码/支持以太网&#xff0c; 重要提醒 &#xff1a;原理 图和源码不对应&#xff0c;原理图PCB为单枪&#xff0c;源码为双枪&#xff0c;使用STM32主控&#xff0c;只有充电控制器不包含整…