2
0

upnpcommands.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. /* $Id: upnpcommands.c,v 1.24 2009/04/17 21:21:19 nanard Exp $ */
  2. /* Project : miniupnp
  3. * Author : Thomas Bernard
  4. * Copyright (c) 2005-2009 Thomas Bernard
  5. * This software is subject to the conditions detailed in the
  6. * LICENCE file provided in this distribution.
  7. * */
  8. #include <stdlib.h>
  9. #include <stdio.h>
  10. #include <string.h>
  11. #include "upnpcommands.h"
  12. #include "miniupnpc.h"
  13. static UNSIGNED_INTEGER
  14. my_atoui(const char * s)
  15. {
  16. return s ? ((UNSIGNED_INTEGER)STRTOUI(s, NULL, 0)) : 0;
  17. }
  18. /*
  19. * */
  20. UNSIGNED_INTEGER
  21. UPNP_GetTotalBytesSent(const char * controlURL,
  22. const char * servicetype)
  23. {
  24. struct NameValueParserData pdata;
  25. char buffer[4096];
  26. int bufsize = 4096;
  27. unsigned int r = 0;
  28. char * p;
  29. simpleUPnPcommand(-1, controlURL, servicetype, "GetTotalBytesSent", 0, buffer, &bufsize);
  30. ParseNameValue(buffer, bufsize, &pdata);
  31. /*DisplayNameValueList(buffer, bufsize);*/
  32. p = GetValueFromNameValueList(&pdata, "NewTotalBytesSent");
  33. r = my_atoui(p);
  34. ClearNameValueList(&pdata);
  35. return r;
  36. }
  37. /*
  38. * */
  39. UNSIGNED_INTEGER
  40. UPNP_GetTotalBytesReceived(const char * controlURL,
  41. const char * servicetype)
  42. {
  43. struct NameValueParserData pdata;
  44. char buffer[4096];
  45. int bufsize = 4096;
  46. unsigned int r = 0;
  47. char * p;
  48. simpleUPnPcommand(-1, controlURL, servicetype, "GetTotalBytesReceived", 0, buffer, &bufsize);
  49. ParseNameValue(buffer, bufsize, &pdata);
  50. /*DisplayNameValueList(buffer, bufsize);*/
  51. p = GetValueFromNameValueList(&pdata, "NewTotalBytesReceived");
  52. r = my_atoui(p);
  53. ClearNameValueList(&pdata);
  54. return r;
  55. }
  56. /*
  57. * */
  58. UNSIGNED_INTEGER
  59. UPNP_GetTotalPacketsSent(const char * controlURL,
  60. const char * servicetype)
  61. {
  62. struct NameValueParserData pdata;
  63. char buffer[4096];
  64. int bufsize = 4096;
  65. unsigned int r = 0;
  66. char * p;
  67. simpleUPnPcommand(-1, controlURL, servicetype, "GetTotalPacketsSent", 0, buffer, &bufsize);
  68. ParseNameValue(buffer, bufsize, &pdata);
  69. /*DisplayNameValueList(buffer, bufsize);*/
  70. p = GetValueFromNameValueList(&pdata, "NewTotalPacketsSent");
  71. r = my_atoui(p);
  72. ClearNameValueList(&pdata);
  73. return r;
  74. }
  75. /*
  76. * */
  77. UNSIGNED_INTEGER
  78. UPNP_GetTotalPacketsReceived(const char * controlURL,
  79. const char * servicetype)
  80. {
  81. struct NameValueParserData pdata;
  82. char buffer[4096];
  83. int bufsize = 4096;
  84. unsigned int r = 0;
  85. char * p;
  86. simpleUPnPcommand(-1, controlURL, servicetype, "GetTotalPacketsReceived", 0, buffer, &bufsize);
  87. ParseNameValue(buffer, bufsize, &pdata);
  88. /*DisplayNameValueList(buffer, bufsize);*/
  89. p = GetValueFromNameValueList(&pdata, "NewTotalPacketsReceived");
  90. r = my_atoui(p);
  91. ClearNameValueList(&pdata);
  92. return r;
  93. }
  94. /* UPNP_GetStatusInfo() call the corresponding UPNP method
  95. * returns the current status and uptime */
  96. int UPNP_GetStatusInfo(const char * controlURL,
  97. const char * servicetype,
  98. char * status,
  99. unsigned int * uptime,
  100. char * lastconnerror)
  101. {
  102. struct NameValueParserData pdata;
  103. char buffer[4096];
  104. int bufsize = 4096;
  105. char * p;
  106. char * up;
  107. char * err;
  108. int ret = UPNPCOMMAND_UNKNOWN_ERROR;
  109. if(!status && !uptime)
  110. return UPNPCOMMAND_INVALID_ARGS;
  111. simpleUPnPcommand(-1, controlURL, servicetype, "GetStatusInfo", 0, buffer, &bufsize);
  112. ParseNameValue(buffer, bufsize, &pdata);
  113. /*DisplayNameValueList(buffer, bufsize);*/
  114. up = GetValueFromNameValueList(&pdata, "NewUptime");
  115. p = GetValueFromNameValueList(&pdata, "NewConnectionStatus");
  116. err = GetValueFromNameValueList(&pdata, "NewLastConnectionError");
  117. if(p && up)
  118. ret = UPNPCOMMAND_SUCCESS;
  119. if(status) {
  120. if(p){
  121. strncpy(status, p, 64 );
  122. status[63] = '\0';
  123. }else
  124. status[0]= '\0';
  125. }
  126. if(uptime) {
  127. if(up)
  128. sscanf(up,"%u",uptime);
  129. else
  130. uptime = 0;
  131. }
  132. if(lastconnerror) {
  133. if(err) {
  134. strncpy(lastconnerror, err, 64 );
  135. lastconnerror[63] = '\0';
  136. } else
  137. lastconnerror[0] = '\0';
  138. }
  139. p = GetValueFromNameValueList(&pdata, "errorCode");
  140. if(p) {
  141. ret = UPNPCOMMAND_UNKNOWN_ERROR;
  142. sscanf(p, "%d", &ret);
  143. }
  144. ClearNameValueList(&pdata);
  145. return ret;
  146. }
  147. /* UPNP_GetConnectionTypeInfo() call the corresponding UPNP method
  148. * returns the connection type */
  149. int UPNP_GetConnectionTypeInfo(const char * controlURL,
  150. const char * servicetype,
  151. char * connectionType)
  152. {
  153. struct NameValueParserData pdata;
  154. char buffer[4096];
  155. int bufsize = 4096;
  156. char * p;
  157. int ret = UPNPCOMMAND_UNKNOWN_ERROR;
  158. if(!connectionType)
  159. return UPNPCOMMAND_INVALID_ARGS;
  160. simpleUPnPcommand(-1, controlURL, servicetype,
  161. "GetConnectionTypeInfo", 0, buffer, &bufsize);
  162. ParseNameValue(buffer, bufsize, &pdata);
  163. p = GetValueFromNameValueList(&pdata, "NewConnectionType");
  164. /*p = GetValueFromNameValueList(&pdata, "NewPossibleConnectionTypes");*/
  165. /* PossibleConnectionTypes will have several values.... */
  166. if(p) {
  167. strncpy(connectionType, p, 64 );
  168. connectionType[63] = '\0';
  169. ret = UPNPCOMMAND_SUCCESS;
  170. } else
  171. connectionType[0] = '\0';
  172. p = GetValueFromNameValueList(&pdata, "errorCode");
  173. if(p) {
  174. ret = UPNPCOMMAND_UNKNOWN_ERROR;
  175. sscanf(p, "%d", &ret);
  176. }
  177. ClearNameValueList(&pdata);
  178. return ret;
  179. }
  180. /* UPNP_GetLinkLayerMaxBitRate() call the corresponding UPNP method.
  181. * Returns 2 values: Downloadlink bandwidth and Uplink bandwidth.
  182. * One of the values can be null
  183. * Note : GetLinkLayerMaxBitRates belongs to WANPPPConnection:1 only
  184. * We can use the GetCommonLinkProperties from WANCommonInterfaceConfig:1 */
  185. int UPNP_GetLinkLayerMaxBitRates(const char * controlURL, const char * servicetype, unsigned int * bitrateDown, unsigned int* bitrateUp)
  186. {
  187. struct NameValueParserData pdata;
  188. char buffer[4096];
  189. int bufsize = 4096;
  190. int ret = UPNPCOMMAND_UNKNOWN_ERROR;
  191. char * down;
  192. char * up;
  193. char * p;
  194. if(!bitrateDown && !bitrateUp)
  195. return UPNPCOMMAND_INVALID_ARGS;
  196. /* shouldn't we use GetCommonLinkProperties ? */
  197. simpleUPnPcommand(-1, controlURL, servicetype,
  198. "GetCommonLinkProperties", 0, buffer, &bufsize);
  199. /*"GetLinkLayerMaxBitRates", 0, buffer, &bufsize);*/
  200. /*DisplayNameValueList(buffer, bufsize);*/
  201. ParseNameValue(buffer, bufsize, &pdata);
  202. /*down = GetValueFromNameValueList(&pdata, "NewDownstreamMaxBitRate");*/
  203. /*up = GetValueFromNameValueList(&pdata, "NewUpstreamMaxBitRate");*/
  204. down = GetValueFromNameValueList(&pdata, "NewLayer1DownstreamMaxBitRate");
  205. up = GetValueFromNameValueList(&pdata, "NewLayer1UpstreamMaxBitRate");
  206. /*GetValueFromNameValueList(&pdata, "NewWANAccessType");*/
  207. /*GetValueFromNameValueList(&pdata, "NewPhysicalLinkSatus");*/
  208. if(down && up)
  209. ret = UPNPCOMMAND_SUCCESS;
  210. if(bitrateDown)
  211. {
  212. if(down)
  213. sscanf(down,"%u",bitrateDown);
  214. else
  215. *bitrateDown = 0;
  216. }
  217. if(bitrateUp)
  218. {
  219. if(up)
  220. sscanf(up,"%u",bitrateUp);
  221. else
  222. *bitrateUp = 0;
  223. }
  224. p = GetValueFromNameValueList(&pdata, "errorCode");
  225. if(p) {
  226. ret = UPNPCOMMAND_UNKNOWN_ERROR;
  227. sscanf(p, "%d", &ret);
  228. }
  229. ClearNameValueList(&pdata);
  230. return ret;
  231. }
  232. /* UPNP_GetExternalIPAddress() call the corresponding UPNP method.
  233. * if the third arg is not null the value is copied to it.
  234. * at least 16 bytes must be available
  235. *
  236. * Return values :
  237. * 0 : SUCCESS
  238. * NON ZERO : ERROR Either an UPnP error code or an unknown error.
  239. *
  240. * 402 Invalid Args - See UPnP Device Architecture section on Control.
  241. * 501 Action Failed - See UPnP Device Architecture section on Control.
  242. */
  243. int UPNP_GetExternalIPAddress(const char * controlURL,
  244. const char * servicetype,
  245. char * extIpAdd)
  246. {
  247. struct NameValueParserData pdata;
  248. char buffer[4096];
  249. int bufsize = 4096;
  250. char * p;
  251. int ret = UPNPCOMMAND_UNKNOWN_ERROR;
  252. if(!extIpAdd || !controlURL || !servicetype)
  253. return UPNPCOMMAND_INVALID_ARGS;
  254. simpleUPnPcommand(-1, controlURL, servicetype, "GetExternalIPAddress", 0, buffer, &bufsize);
  255. /*DisplayNameValueList(buffer, bufsize);*/
  256. ParseNameValue(buffer, bufsize, &pdata);
  257. /*printf("external ip = %s\n", GetValueFromNameValueList(&pdata, "NewExternalIPAddress") );*/
  258. p = GetValueFromNameValueList(&pdata, "NewExternalIPAddress");
  259. if(p) {
  260. strncpy(extIpAdd, p, 16 );
  261. extIpAdd[15] = '\0';
  262. ret = UPNPCOMMAND_SUCCESS;
  263. } else
  264. extIpAdd[0] = '\0';
  265. p = GetValueFromNameValueList(&pdata, "errorCode");
  266. if(p) {
  267. ret = UPNPCOMMAND_UNKNOWN_ERROR;
  268. sscanf(p, "%d", &ret);
  269. }
  270. ClearNameValueList(&pdata);
  271. return ret;
  272. }
  273. int
  274. UPNP_AddPortMapping(const char * controlURL, const char * servicetype,
  275. const char * extPort,
  276. const char * inPort,
  277. const char * inClient,
  278. const char * desc,
  279. const char * proto,
  280. const char * remoteHost)
  281. {
  282. struct UPNParg * AddPortMappingArgs;
  283. char buffer[4096];
  284. int bufsize = 4096;
  285. struct NameValueParserData pdata;
  286. const char * resVal;
  287. int ret;
  288. if(!inPort || !inClient || !proto || !extPort)
  289. return UPNPCOMMAND_INVALID_ARGS;
  290. AddPortMappingArgs = calloc(9, sizeof(struct UPNParg));
  291. AddPortMappingArgs[0].elt = "NewRemoteHost";
  292. AddPortMappingArgs[0].val = remoteHost;
  293. AddPortMappingArgs[1].elt = "NewExternalPort";
  294. AddPortMappingArgs[1].val = extPort;
  295. AddPortMappingArgs[2].elt = "NewProtocol";
  296. AddPortMappingArgs[2].val = proto;
  297. AddPortMappingArgs[3].elt = "NewInternalPort";
  298. AddPortMappingArgs[3].val = inPort;
  299. AddPortMappingArgs[4].elt = "NewInternalClient";
  300. AddPortMappingArgs[4].val = inClient;
  301. AddPortMappingArgs[5].elt = "NewEnabled";
  302. AddPortMappingArgs[5].val = "1";
  303. AddPortMappingArgs[6].elt = "NewPortMappingDescription";
  304. AddPortMappingArgs[6].val = desc?desc:"libminiupnpc";
  305. AddPortMappingArgs[7].elt = "NewLeaseDuration";
  306. AddPortMappingArgs[7].val = "0";
  307. simpleUPnPcommand(-1, controlURL, servicetype, "AddPortMapping", AddPortMappingArgs, buffer, &bufsize);
  308. /*DisplayNameValueList(buffer, bufsize);*/
  309. /*buffer[bufsize] = '\0';*/
  310. /*puts(buffer);*/
  311. ParseNameValue(buffer, bufsize, &pdata);
  312. resVal = GetValueFromNameValueList(&pdata, "errorCode");
  313. if(resVal) {
  314. /*printf("AddPortMapping errorCode = '%s'\n", resVal); */
  315. ret = UPNPCOMMAND_UNKNOWN_ERROR;
  316. sscanf(resVal, "%d", &ret);
  317. } else {
  318. ret = UPNPCOMMAND_SUCCESS;
  319. }
  320. ClearNameValueList(&pdata);
  321. free(AddPortMappingArgs);
  322. return ret;
  323. }
  324. int
  325. UPNP_DeletePortMapping(const char * controlURL, const char * servicetype,
  326. const char * extPort, const char * proto,
  327. const char * remoteHost)
  328. {
  329. /*struct NameValueParserData pdata;*/
  330. struct UPNParg * DeletePortMappingArgs;
  331. char buffer[4096];
  332. int bufsize = 4096;
  333. struct NameValueParserData pdata;
  334. const char * resVal;
  335. int ret;
  336. if(!extPort || !proto)
  337. return UPNPCOMMAND_INVALID_ARGS;
  338. DeletePortMappingArgs = calloc(4, sizeof(struct UPNParg));
  339. DeletePortMappingArgs[0].elt = "NewRemoteHost";
  340. DeletePortMappingArgs[0].val = remoteHost;
  341. DeletePortMappingArgs[1].elt = "NewExternalPort";
  342. DeletePortMappingArgs[1].val = extPort;
  343. DeletePortMappingArgs[2].elt = "NewProtocol";
  344. DeletePortMappingArgs[2].val = proto;
  345. simpleUPnPcommand(-1, controlURL, servicetype,
  346. "DeletePortMapping",
  347. DeletePortMappingArgs, buffer, &bufsize);
  348. /*DisplayNameValueList(buffer, bufsize);*/
  349. ParseNameValue(buffer, bufsize, &pdata);
  350. resVal = GetValueFromNameValueList(&pdata, "errorCode");
  351. if(resVal) {
  352. ret = UPNPCOMMAND_UNKNOWN_ERROR;
  353. sscanf(resVal, "%d", &ret);
  354. } else {
  355. ret = UPNPCOMMAND_SUCCESS;
  356. }
  357. ClearNameValueList(&pdata);
  358. free(DeletePortMappingArgs);
  359. return ret;
  360. }
  361. int UPNP_GetGenericPortMappingEntry(const char * controlURL,
  362. const char * servicetype,
  363. const char * index,
  364. char * extPort,
  365. char * intClient,
  366. char * intPort,
  367. char * protocol,
  368. char * desc,
  369. char * enabled,
  370. char * rHost,
  371. char * duration)
  372. {
  373. struct NameValueParserData pdata;
  374. struct UPNParg * GetPortMappingArgs;
  375. char buffer[4096];
  376. int bufsize = 4096;
  377. char * p;
  378. int r = UPNPCOMMAND_UNKNOWN_ERROR;
  379. if(!index)
  380. return UPNPCOMMAND_INVALID_ARGS;
  381. intClient[0] = '\0';
  382. intPort[0] = '\0';
  383. GetPortMappingArgs = calloc(2, sizeof(struct UPNParg));
  384. GetPortMappingArgs[0].elt = "NewPortMappingIndex";
  385. GetPortMappingArgs[0].val = index;
  386. simpleUPnPcommand(-1, controlURL, servicetype,
  387. "GetGenericPortMappingEntry",
  388. GetPortMappingArgs, buffer, &bufsize);
  389. ParseNameValue(buffer, bufsize, &pdata);
  390. p = GetValueFromNameValueList(&pdata, "NewRemoteHost");
  391. if(p && rHost)
  392. {
  393. strncpy(rHost, p, 64);
  394. rHost[63] = '\0';
  395. }
  396. p = GetValueFromNameValueList(&pdata, "NewExternalPort");
  397. if(p && extPort)
  398. {
  399. strncpy(extPort, p, 6);
  400. extPort[5] = '\0';
  401. r = UPNPCOMMAND_SUCCESS;
  402. }
  403. p = GetValueFromNameValueList(&pdata, "NewProtocol");
  404. if(p && protocol)
  405. {
  406. strncpy(protocol, p, 4);
  407. protocol[3] = '\0';
  408. }
  409. p = GetValueFromNameValueList(&pdata, "NewInternalClient");
  410. if(p && intClient)
  411. {
  412. strncpy(intClient, p, 16);
  413. intClient[15] = '\0';
  414. r = 0;
  415. }
  416. p = GetValueFromNameValueList(&pdata, "NewInternalPort");
  417. if(p && intPort)
  418. {
  419. strncpy(intPort, p, 6);
  420. intPort[5] = '\0';
  421. }
  422. p = GetValueFromNameValueList(&pdata, "NewEnabled");
  423. if(p && enabled)
  424. {
  425. strncpy(enabled, p, 4);
  426. enabled[3] = '\0';
  427. }
  428. p = GetValueFromNameValueList(&pdata, "NewPortMappingDescription");
  429. if(p && desc)
  430. {
  431. strncpy(desc, p, 80);
  432. desc[79] = '\0';
  433. }
  434. p = GetValueFromNameValueList(&pdata, "NewLeaseDuration");
  435. if(p && duration)
  436. {
  437. strncpy(duration, p, 16);
  438. duration[15] = '\0';
  439. }
  440. p = GetValueFromNameValueList(&pdata, "errorCode");
  441. if(p) {
  442. r = UPNPCOMMAND_UNKNOWN_ERROR;
  443. sscanf(p, "%d", &r);
  444. }
  445. ClearNameValueList(&pdata);
  446. free(GetPortMappingArgs);
  447. return r;
  448. }
  449. int UPNP_GetPortMappingNumberOfEntries(const char * controlURL, const char * servicetype, unsigned int * numEntries)
  450. {
  451. struct NameValueParserData pdata;
  452. char buffer[4096];
  453. int bufsize = 4096;
  454. char* p;
  455. int ret = UPNPCOMMAND_UNKNOWN_ERROR;
  456. simpleUPnPcommand(-1, controlURL, servicetype, "GetPortMappingNumberOfEntries", 0, buffer, &bufsize);
  457. #ifdef DEBUG
  458. DisplayNameValueList(buffer, bufsize);
  459. #endif
  460. ParseNameValue(buffer, bufsize, &pdata);
  461. p = GetValueFromNameValueList(&pdata, "NewPortMappingNumberOfEntries");
  462. if(numEntries && p) {
  463. *numEntries = 0;
  464. sscanf(p, "%u", numEntries);
  465. ret = UPNPCOMMAND_SUCCESS;
  466. }
  467. p = GetValueFromNameValueList(&pdata, "errorCode");
  468. if(p) {
  469. ret = UPNPCOMMAND_UNKNOWN_ERROR;
  470. sscanf(p, "%d", &ret);
  471. }
  472. ClearNameValueList(&pdata);
  473. return ret;
  474. }
  475. /* UPNP_GetSpecificPortMappingEntry retrieves an existing port mapping
  476. * the result is returned in the intClient and intPort strings
  477. * please provide 16 and 6 bytes of data */
  478. int
  479. UPNP_GetSpecificPortMappingEntry(const char * controlURL,
  480. const char * servicetype,
  481. const char * extPort,
  482. const char * proto,
  483. char * intClient,
  484. char * intPort)
  485. {
  486. struct NameValueParserData pdata;
  487. struct UPNParg * GetPortMappingArgs;
  488. char buffer[4096];
  489. int bufsize = 4096;
  490. char * p;
  491. int ret = UPNPCOMMAND_UNKNOWN_ERROR;
  492. if(!intPort || !intClient || !extPort || !proto)
  493. return UPNPCOMMAND_INVALID_ARGS;
  494. GetPortMappingArgs = calloc(4, sizeof(struct UPNParg));
  495. GetPortMappingArgs[0].elt = "NewRemoteHost";
  496. GetPortMappingArgs[1].elt = "NewExternalPort";
  497. GetPortMappingArgs[1].val = extPort;
  498. GetPortMappingArgs[2].elt = "NewProtocol";
  499. GetPortMappingArgs[2].val = proto;
  500. simpleUPnPcommand(-1, controlURL, servicetype,
  501. "GetSpecificPortMappingEntry",
  502. GetPortMappingArgs, buffer, &bufsize);
  503. /*fd = simpleUPnPcommand(fd, controlURL, data.servicetype, "GetSpecificPortMappingEntry", AddPortMappingArgs, buffer, &bufsize); */
  504. /*DisplayNameValueList(buffer, bufsize);*/
  505. ParseNameValue(buffer, bufsize, &pdata);
  506. p = GetValueFromNameValueList(&pdata, "NewInternalClient");
  507. if(p) {
  508. strncpy(intClient, p, 16);
  509. intClient[15] = '\0';
  510. ret = UPNPCOMMAND_SUCCESS;
  511. } else
  512. intClient[0] = '\0';
  513. p = GetValueFromNameValueList(&pdata, "NewInternalPort");
  514. if(p) {
  515. strncpy(intPort, p, 6);
  516. intPort[5] = '\0';
  517. } else
  518. intPort[0] = '\0';
  519. p = GetValueFromNameValueList(&pdata, "errorCode");
  520. if(p) {
  521. ret = UPNPCOMMAND_UNKNOWN_ERROR;
  522. sscanf(p, "%d", &ret);
  523. }
  524. ClearNameValueList(&pdata);
  525. free(GetPortMappingArgs);
  526. return ret;
  527. }