├── .gitignore ├── Configs └── BaseTeam.xcconfig ├── LICENSE.txt ├── Port Map.entitlements ├── Port Map.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcshareddata │ └── xcschemes │ ├── NATEcho.xcscheme │ ├── Port Map.xcscheme │ ├── TCMPortMapper.xcscheme │ └── UPnP Command Line Debug Tool.xcscheme ├── README.md ├── RSVerticallyCenteredTextFieldCell ├── MIT-License.rtf ├── RSVerticallyCenteredTextFieldCell.h └── RSVerticallyCenteredTextFieldCell.m ├── createZip.sh ├── framework ├── NSNotificationCenterThreadingAdditions.h ├── NSNotificationCenterThreadingAdditions.m ├── OUI-Preprocessing │ ├── Ethernet-OUI.txt │ ├── OUItoCompany2Level_pretty.json │ ├── OUItoCompanyShort_pretty.json │ ├── OUItoCompany_pretty.json │ ├── nmap-mac-prefixes-sorted.txt │ ├── nmap-mac-prefixes.txt │ └── preparejson.rb ├── OUItoCompany2Level.json.gz ├── TCMNATPMPPortMapper.h ├── TCMNATPMPPortMapper.m ├── TCMPortMapper-Info.plist ├── TCMPortMapper.h ├── TCMPortMapper.m ├── TCMPortMapper_prefix.pch ├── TCMSystemConfiguration.h ├── TCMSystemConfiguration.m ├── TCMUPNPPortMapper.h ├── TCMUPNPPortMapper.m ├── libnatpmp │ ├── Changelog.txt │ ├── JavaTest.java │ ├── LICENSE │ ├── Makefile │ ├── README │ ├── build.bat │ ├── declspec.h │ ├── fr │ │ └── free │ │ │ └── miniupnp │ │ │ └── libnatpmp │ │ │ ├── LibraryExtractor.java │ │ │ ├── NatPmp.java │ │ │ ├── NatPmpResponse.java │ │ │ └── URLUtils.java │ ├── getgateway.c │ ├── getgateway.h │ ├── libnatpmpmodule.c │ ├── msvc │ │ ├── libnatpmp.sln │ │ ├── libnatpmp.vcproj │ │ └── natpmpc-static.vcproj │ ├── natpmp-jni.c │ ├── natpmp.c │ ├── natpmp.def │ ├── natpmp.h │ ├── natpmpc.1 │ ├── natpmpc.c │ ├── setup.py │ ├── setupmingw32.py │ ├── testgetgateway.c │ ├── wingettimeofday.c │ └── wingettimeofday.h ├── miniupnp_modeldescription.patch └── miniupnpc │ ├── CMakeLists.txt │ ├── Changelog.txt │ ├── LICENSE │ ├── MANIFEST.in │ ├── Makefile │ ├── Makefile.mingw │ ├── README │ ├── VERSION │ ├── apiversions.txt │ ├── codelength.h │ ├── connecthostport.c │ ├── connecthostport.h │ ├── external-ip.sh │ ├── igd_desc_parse.c │ ├── igd_desc_parse.h │ ├── java │ ├── JavaBridgeTest.java │ ├── testjava.bat │ └── testjava.sh │ ├── listdevices.c │ ├── man3 │ └── miniupnpc.3 │ ├── mingw32make.bat │ ├── minihttptestserver.c │ ├── minisoap.c │ ├── minisoap.h │ ├── minissdpc.c │ ├── minissdpc.h │ ├── miniupnpc.c │ ├── miniupnpc.def │ ├── miniupnpc.h │ ├── miniupnpc_declspec.h │ ├── miniupnpc_socketdef.h │ ├── miniupnpcmodule.c │ ├── miniupnpcstrings.h │ ├── miniupnpcstrings.h.cmake │ ├── miniupnpcstrings.h.in │ ├── miniupnpctypes.h │ ├── miniwget.c │ ├── miniwget.h │ ├── miniwget_private.h │ ├── minixml.c │ ├── minixml.h │ ├── minixmlvalid.c │ ├── msvc │ ├── genminiupnpcstrings.vbs │ ├── miniupnpc.sln │ ├── miniupnpc.vcproj │ ├── miniupnpc.vcxproj │ ├── miniupnpc.vcxproj.filters │ ├── miniupnpc_vs2010.sln │ ├── miniupnpc_vs2010.vcxproj │ ├── miniupnpc_vs2010.vcxproj.filters │ ├── miniupnpc_vs2015.sln │ ├── upnpc-static.vcproj │ ├── upnpc-static.vcxproj │ ├── upnpc-static.vcxproj.filters │ └── upnpc-static_vs2010.vcxproj │ ├── portlistingparse.c │ ├── portlistingparse.h │ ├── pymoduletest.py │ ├── receivedata.c │ ├── receivedata.h │ ├── setup.py │ ├── setupmingw32.py │ ├── testdesc │ ├── linksys_WAG200G_desc.values │ ├── linksys_WAG200G_desc.xml │ ├── new_LiveBox_desc.values │ └── new_LiveBox_desc.xml │ ├── testigddescparse.c │ ├── testminiwget.c │ ├── testminiwget.sh │ ├── testminixml.c │ ├── testportlistingparse.c │ ├── testreplyparse │ ├── DeletePortMapping.namevalue │ ├── DeletePortMapping.xml │ ├── GetExternalIPAddress.namevalue │ ├── GetExternalIPAddress.xml │ ├── GetSpecificPortMappingEntryReq.namevalue │ ├── GetSpecificPortMappingEntryReq.xml │ ├── GetSpecificPortMappingEntryResp.namevalue │ ├── GetSpecificPortMappingEntryResp.xml │ ├── SetDefaultConnectionService.namevalue │ ├── SetDefaultConnectionService.xml │ └── readme.txt │ ├── testupnpigd.py │ ├── testupnpreplyparse.c │ ├── testupnpreplyparse.sh │ ├── updateminiupnpcstrings.sh │ ├── upnpc.c │ ├── upnpcommands.c │ ├── upnpcommands.h │ ├── upnpdev.c │ ├── upnpdev.h │ ├── upnperrors.c │ ├── upnperrors.h │ ├── upnpreplyparse.c │ ├── upnpreplyparse.h │ └── wingenminiupnpcstrings.c ├── general_artwork ├── ImageIcons.afdesign └── PortMapIcon.acorn ├── natecho ├── AppController.h ├── AppController.m ├── Base.lproj │ └── MainMenu.nib │ │ ├── designable.nib │ │ └── keyedobjects.nib ├── NATEcho-Info.plist ├── TCPServer.h ├── TCPServer.m └── main.m ├── portmap ├── AppController.h ├── AppController.m ├── Base.lproj │ └── MainMenu.nib │ │ ├── designable.nib │ │ └── keyedobjects.nib ├── English.lproj │ ├── InfoPlist.strings │ └── Localizable.strings ├── Info.plist ├── Presets.plist ├── TCMPortMappingAdditions.h ├── TCMPortMappingAdditions.m ├── TCMPortStringFromPublicPortValueTransformer.h ├── TCMPortStringFromPublicPortValueTransformer.m ├── TCMStatusImageFromMappingStatusValueTransformer.h ├── TCMStatusImageFromMappingStatusValueTransformer.m ├── artwork │ ├── Assets.xcassets │ │ ├── Contents.json │ │ └── PortMap.appiconset │ │ │ ├── 1024.png │ │ │ ├── 128.png │ │ │ ├── 16.png │ │ │ ├── 256.png │ │ │ ├── 32.png │ │ │ ├── 512.png │ │ │ ├── 64.png │ │ │ └── Contents.json │ └── Icons.xcassets │ │ ├── Contents.json │ │ ├── DotGreen.imageset │ │ ├── Contents.json │ │ ├── DotGreen.png │ │ └── DotGreen@2x.png │ │ ├── DotRed.imageset │ │ ├── Contents.json │ │ ├── DotRed.png │ │ └── DotRed@2x.png │ │ └── DotYellow.imageset │ │ ├── Contents.json │ │ ├── DotYellow.png │ │ └── DotYellow@2x.png ├── htdocs │ ├── appcast.rss │ ├── portmap_releasenotes.css │ ├── portmap_releasenotes.html │ ├── version_1_1.html │ ├── version_1_2.html │ ├── version_1_3.html │ ├── version_1_3_1.html │ └── version_2_0.html ├── main.m └── miniupnpc-LICENSE.txt ├── ruby ├── mdnskiller.rb ├── nat-pmp-ip-broadcaster.rb └── nat-pmp-listener.rb └── set_build_number.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | build/ 3 | *.pbxuser 4 | !default.pbxuser 5 | *.mode1v3 6 | !default.mode1v3 7 | *.mode2v3 8 | !default.mode2v3 9 | *.perspectivev3 10 | !default.perspectivev3 11 | xcuserdata 12 | *.xccheckout 13 | *.moved-aside 14 | DerivedData 15 | *.hmap 16 | *.ipa 17 | *.xcuserstate 18 | 19 | #OS X Stuff 20 | .localized 21 | .DS_Store 22 | *.zip 23 | 24 | # Pods 25 | Pods/ 26 | 27 | # Editors 28 | .idea 29 | *.swp 30 | 31 | # Fastlane 32 | fastlane/report.xml 33 | *.mobileprovision 34 | *.certSigningRequest 35 | *.cer 36 | 37 | # Keys 38 | *.pem 39 | *.pkey 40 | *.p12 41 | 42 | # Rbenv 43 | .ruby-version 44 | 45 | # built stuff 46 | *.o 47 | *.a -------------------------------------------------------------------------------- /Configs/BaseTeam.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // BaseTeam.xcconfig 3 | // Port Map 4 | // 5 | // Created by dom on 25.09.18. 6 | // 7 | 8 | // Configuration settings file format documentation can be found at: 9 | // https://help.apple.com/xcode/#/dev745c5c974 10 | 11 | DEVELOPMENT_TEAM = 12 | // CODE_SIGN_IDENTITY = Developer ID Application 13 | // PROVISIONING_PROFILE_SPECIFIER = PortMapDeveloperID 14 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2008-2018 Dominik Wagner - @monkeydom 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /Port Map.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.network.client 8 | 9 | com.apple.security.network.server 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Port Map.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Port Map.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Port Map.xcodeproj/xcshareddata/xcschemes/NATEcho.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /Port Map.xcodeproj/xcshareddata/xcschemes/Port Map.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /Port Map.xcodeproj/xcshareddata/xcschemes/TCMPortMapper.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /Port Map.xcodeproj/xcshareddata/xcschemes/UPnP Command Line Debug Tool.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /RSVerticallyCenteredTextFieldCell/MIT-License.rtf: -------------------------------------------------------------------------------- 1 | {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf380 2 | {\fonttbl\f0\fswiss\fcharset77 Helvetica;} 3 | {\colortbl;\red255\green255\blue255;} 4 | {\info 5 | {\*\company Test}}\margl1440\margr1440\vieww9000\viewh8400\viewkind0 6 | \deftab720 7 | \pard\pardeftab720\sl380\ql\qnatural 8 | 9 | \f0\fs25\fsmilli12700 \cf0 This source code is provided to you compliments of Red Sweater Software under the license as described below. NOTE: This is the MIT License.\ 10 | \ 11 | Copyright (c) 2006 Red Sweater Software\ 12 | \ 13 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\ 14 | \ 15 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\ 16 | \ 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\ 18 | } -------------------------------------------------------------------------------- /RSVerticallyCenteredTextFieldCell/RSVerticallyCenteredTextFieldCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // RSVerticallyCenteredTextFieldCell.h 3 | // RSCommon 4 | // 5 | // Created by Daniel Jalkut on 6/17/06. 6 | // Copyright 2006 Red Sweater Software. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface RSVerticallyCenteredTextFieldCell : NSTextFieldCell 13 | { 14 | BOOL mIsEditingOrSelecting; 15 | } 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /RSVerticallyCenteredTextFieldCell/RSVerticallyCenteredTextFieldCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // RSVerticallyCenteredTextField.m 3 | // RSCommon 4 | // 5 | // Created by Daniel Jalkut on 6/17/06. 6 | // Copyright 2006 Red Sweater Software. All rights reserved. 7 | // 8 | 9 | #import "RSVerticallyCenteredTextFieldCell.h" 10 | 11 | @implementation RSVerticallyCenteredTextFieldCell 12 | 13 | - (NSRect)drawingRectForBounds:(NSRect)theRect 14 | { 15 | // Get the parent's idea of where we should draw 16 | NSRect newRect = [super drawingRectForBounds:theRect]; 17 | 18 | // When the text field is being 19 | // edited or selected, we have to turn off the magic because it screws up 20 | // the configuration of the field editor. We sneak around this by 21 | // intercepting selectWithFrame and editWithFrame and sneaking a 22 | // reduced, centered rect in at the last minute. 23 | if (mIsEditingOrSelecting == NO) 24 | { 25 | // Get our ideal size for current text 26 | NSSize textSize = [self cellSizeForBounds:theRect]; 27 | 28 | // Center that in the proposed rect 29 | float heightDelta = newRect.size.height - textSize.height; 30 | if (heightDelta > 0) 31 | { 32 | newRect.size.height -= heightDelta; 33 | newRect.origin.y += (heightDelta / 2); 34 | } 35 | } 36 | 37 | return newRect; 38 | } 39 | 40 | - (void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject start:(NSInteger)selStart length:(NSInteger)selLength 41 | { 42 | aRect = [self drawingRectForBounds:aRect]; 43 | mIsEditingOrSelecting = YES; 44 | [super selectWithFrame:aRect inView:controlView editor:textObj delegate:anObject start:selStart length:selLength]; 45 | mIsEditingOrSelecting = NO; 46 | } 47 | 48 | - (void)editWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject event:(NSEvent *)theEvent 49 | { 50 | aRect = [self drawingRectForBounds:aRect]; 51 | mIsEditingOrSelecting = YES; 52 | [super editWithFrame:aRect inView:controlView editor:textObj delegate:anObject event:theEvent]; 53 | mIsEditingOrSelecting = NO; 54 | } 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /createZip.sh: -------------------------------------------------------------------------------- 1 | zipBasePath="{TARGET_BUILD_DIR}/${ZipName}" 2 | git=$(sh /etc/profile; which git) 3 | 4 | echo "Removing zip file ${zipBasePath}.zip" 5 | rm -f "${zipBasePath}.zip" 6 | if [ x${ACTION} = xclean ]; then 7 | exit 0 8 | fi 9 | 10 | echo "Setting ownership..." 11 | chgrp -R admin "${BUILT_PRODUCTS_DIR}/${ZipProduct}" 12 | echo "...done" 13 | 14 | echo "Setting permissions..." 15 | chmod -R g+w "${BUILT_PRODUCTS_DIR}/${ZipProduct}" 16 | echo "...done" 17 | 18 | echo "Creating Zip file ${zipBasePath}.zip ..." 19 | cd "${BUILT_PRODUCTS_DIR}" 20 | zip -9 -r -y "${ZipName}.zip" "${ZipProduct}" 21 | echo "...done" 22 | 23 | echo "Adding Revision Number to Zip file ${zipBasePath}.zip ..." 24 | cd "${SRCROOT}" 25 | REV=$("$git" rev-list --first-parent --count HEAD) 26 | # REV=$("$git" describe --tag --always) 27 | cd "${BUILT_PRODUCTS_DIR}" 28 | cp "${ZipName}.zip" "${ZipName}-${REV}.zip" 29 | echo "...done" 30 | -------------------------------------------------------------------------------- /framework/NSNotificationCenterThreadingAdditions.h: -------------------------------------------------------------------------------- 1 | // NSNotificationCenterThreadingAdditions 2 | // Enable NSNotification being sent from threads 3 | // 4 | 5 | @import Cocoa; 6 | 7 | @interface NSNotificationCenter (NSNotificationCenterThreadingAdditions) 8 | - (void)postNotificationOnMainThread:(NSNotification *)aNotification; 9 | - (void)postNotificationOnMainThreadWithName:(NSString *)aName object:(id)anObject; 10 | @end 11 | -------------------------------------------------------------------------------- /framework/NSNotificationCenterThreadingAdditions.m: -------------------------------------------------------------------------------- 1 | #import "NSNotificationCenterThreadingAdditions.h" 2 | #import 3 | 4 | @implementation NSNotificationCenter (NSNotificationCenterThreadingAdditions) 5 | 6 | - (void)postNotificationOnMainThread:(NSNotification *)notification { 7 | if (pthread_main_np()) { 8 | return [self postNotification:notification]; 9 | } else { 10 | dispatch_async(dispatch_get_main_queue(), ^{ 11 | [self postNotification:notification]; 12 | }); 13 | } 14 | } 15 | 16 | - (void)postNotificationOnMainThreadWithName:(NSString *)name object:(id)object { 17 | [self postNotificationOnMainThread:[NSNotification notificationWithName:name object:object]]; 18 | } 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /framework/OUItoCompany2Level.json.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monkeydom/TCMPortMapper/914d064d4e8d37c20be3e91260881bb5bcf8c455/framework/OUItoCompany2Level.json.gz -------------------------------------------------------------------------------- /framework/TCMNATPMPPortMapper.h: -------------------------------------------------------------------------------- 1 | // TCMNATPMPPortMapper.h 2 | // Encapsulates libnatpmp, listens for router changes 3 | // 4 | 5 | #import "TCMPortMapper.h" 6 | 7 | #import "natpmp.h" 8 | 9 | extern NSString * const TCMNATPMPPortMapperDidFailNotification; 10 | extern NSString * const TCMNATPMPPortMapperDidGetExternalIPAddressNotification; 11 | extern NSString * const TCMNATPMPPortMapperDidBeginWorkingNotification; 12 | extern NSString * const TCMNATPMPPortMapperDidEndWorkingNotification ; 13 | extern NSString * const TCMNATPMPPortMapperDidReceiveBroadcastedExternalIPChangeNotification; 14 | 15 | typedef enum { 16 | TCMExternalIPThreadID = 0, 17 | TCMUpdatingMappingThreadID = 1, 18 | } TCMPortMappingThreadID; 19 | 20 | @interface TCMNATPMPPortMapper : NSObject { 21 | NSLock *natPMPThreadIsRunningLock; 22 | int IPAddressThreadShouldQuitAndRestart; 23 | BOOL UpdatePortMappingsThreadShouldQuit; 24 | BOOL UpdatePortMappingsThreadShouldRestart; 25 | TCMPortMappingThreadID runningThreadID; 26 | NSTimer *_updateTimer; 27 | NSTimeInterval _updateInterval; 28 | NSString *_lastExternalIPSenderAddress; 29 | NSString *_lastBroadcastedExternalIP; 30 | CFSocketRef _externalAddressChangeListeningSocket; 31 | } 32 | 33 | - (void)refresh; 34 | - (void)stop; 35 | - (void)updatePortMappings; 36 | - (void)stopBlocking; 37 | 38 | - (void)ensureListeningToExternalIPAddressChanges; 39 | - (void)stopListeningToExternalIPAddressChanges; 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /framework/TCMPortMapper-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildRevision 6 | 1 7 | CFBundleDevelopmentRegion 8 | English 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1.4.0 21 | 22 | 23 | -------------------------------------------------------------------------------- /framework/TCMPortMapper.h: -------------------------------------------------------------------------------- 1 | // TCMPortMapper.h 2 | // Establishes port mapping via upnp or natpmp 3 | // 4 | // Some rights reserved: 5 | 6 | @import Foundation; 7 | #import 8 | #import 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | extern NSString * const TCMPortMapperExternalIPAddressDidChange; 14 | 15 | extern NSString * const TCMPortMapperWillStartSearchForRouterNotification; 16 | extern NSString * const TCMPortMapperDidFinishSearchForRouterNotification; 17 | 18 | extern NSString * const TCMPortMapperDidStartWorkNotification; 19 | extern NSString * const TCMPortMapperDidFinishWorkNotification; 20 | 21 | extern NSString * const TCMPortMapperDidReceiveUPNPMappingTableNotification; 22 | 23 | extern NSString * const TCMPortMappingDidChangeMappingStatusNotification; 24 | 25 | 26 | extern NSString * const TCMNATPMPPortMapProtocol; 27 | extern NSString * const TCMUPNPPortMapProtocol; 28 | extern NSString * const TCMNoPortMapProtocol; 29 | 30 | typedef NS_ENUM(uint8_t, TCMPortMappingStatus) { 31 | TCMPortMappingStatusUnmapped = 0, 32 | TCMPortMappingStatusTrying = 1, 33 | TCMPortMappingStatusMapped = 2 34 | }; 35 | 36 | typedef NS_ENUM(uint8_t, TCMPortMappingTransportProtocol) { 37 | TCMPortMappingTransportProtocolUDP = 1, 38 | TCMPortMappingTransportProtocolTCP = 2, 39 | TCMPortMappingTransportProtocolBoth = 3 40 | }; 41 | 42 | @interface TCMPortMapping : NSObject 43 | + (instancetype)portMappingWithLocalPort:(uint16_t)privatePort desiredExternalPort:(uint16_t)publicPort transportProtocol:(TCMPortMappingTransportProtocol)transportProtocol userInfo:(nullable id)userInfo; 44 | - (instancetype)initWithLocalPort:(uint16_t)privatePort desiredExternalPort:(uint16_t)publicPort transportProtocol:(TCMPortMappingTransportProtocol)transportProtocol userInfo:(nullable id)userInfo; 45 | 46 | @property (nonatomic) uint16_t desiredExternalPort; 47 | @property (nonatomic) uint16_t localPort; 48 | @property (nonatomic) uint16_t externalPort; 49 | @property (nonatomic) TCMPortMappingTransportProtocol transportProtocol; 50 | @property (nonatomic) TCMPortMappingStatus mappingStatus; 51 | 52 | @property (nullable, nonatomic, strong) id userInfo; 53 | @end 54 | 55 | @interface NSString (TCMPortMapper_IPAdditions) 56 | /** 57 | @return YES if the string is representing an IPv4 Address. 58 | */ 59 | - (BOOL)isIPv4Address; 60 | /** 61 | @return YES if the String represents an IPv4 Address and it is in one of the private or self assigned subnetranges. NO otherwise. 62 | */ 63 | - (BOOL)IPv4AddressIsInPrivateSubnet; 64 | @end 65 | 66 | @interface TCMPortMapper : NSObject 67 | + (instancetype)sharedInstance; 68 | + (nullable NSString *)manufacturerForHardwareAddress:(NSString *)aMACAddress; 69 | + (NSString *)sizereducableHashOfString:(NSString *)inString; 70 | 71 | - (NSSet *)portMappings; 72 | - (NSMutableSet *)removeMappingQueue; 73 | - (void)addPortMapping:(TCMPortMapping *)aMapping; 74 | - (void)removePortMapping:(TCMPortMapping *)aMapping; 75 | - (void)refresh; 76 | 77 | - (BOOL)isAtWork; 78 | - (BOOL)isRunning; 79 | - (void)start; 80 | - (void)stop; 81 | - (void)stopBlocking; 82 | 83 | // will request the complete UPNPMappingTable and deliver it using a TCMPortMapperDidReceiveUPNPMappingTableNotification with "mappingTable" in the userInfo Dictionary (if current router is a UPNP router) 84 | - (void)requestUPNPMappingTable; 85 | // this is mainly for Port Map.app and can remove any mappings that can be removed using UPNP (including mappings from other hosts). aMappingList is an Array of Dictionaries with the key @"protocol" and @"publicPort". 86 | - (void)removeUPNPMappings:(NSArray *)aMappingList; 87 | 88 | // needed for generating a UPNP port mapping description that differs for each user 89 | @property (nonatomic, strong) NSString *userID; 90 | // we provide a half length md5 has for convenience 91 | // we could use full length but the description field of the routers might be limited 92 | - (void)hashUserID:(NSString *)aUserIDToHash; 93 | 94 | @property (nonatomic, readonly, nullable) NSString *externalIPAddress; 95 | @property (nonatomic, readonly) NSString *localIPAddress; 96 | @property (nonatomic, readonly, nullable) NSString *localBonjourHostName; 97 | 98 | @property (nonatomic, strong, nullable) NSString *mappingProtocol; 99 | @property (nonatomic, copy, nullable) NSString *routerName; 100 | @property (nonatomic, readonly, nullable) NSString *routerIPAddress; 101 | @property (nonatomic, readonly, nullable) NSString *routerHardwareAddress; 102 | @end 103 | 104 | NS_ASSUME_NONNULL_END 105 | -------------------------------------------------------------------------------- /framework/TCMPortMapper_prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'PortMapper' target in the 'PortMapper' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /framework/TCMSystemConfiguration.h: -------------------------------------------------------------------------------- 1 | // TCMSystemConfiguration.h 2 | // TCMPortMapper 3 | // 4 | 5 | @import Foundation; 6 | 7 | @class TCMSystemConfiguration; 8 | typedef void (^TCMSystemConfigurationDidChangeCallback)(TCMSystemConfiguration *config, NSArray *changedKeys); 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | @interface TCMSystemConfiguration : NSObject 12 | + (instancetype)sharedConfiguration; 13 | 14 | - (id)observeConfigurationKeys:(NSArray *)keys observationBlock:(TCMSystemConfigurationDidChangeCallback)callbackBlock; 15 | - (void)removeConfigurationKeyObservation:(id)observation; 16 | 17 | @end 18 | 19 | NS_ASSUME_NONNULL_END 20 | -------------------------------------------------------------------------------- /framework/TCMUPNPPortMapper.h: -------------------------------------------------------------------------------- 1 | // TCMUPNPPortMapper.h 2 | // Encapsulates miniupnp framework 3 | // 4 | 5 | #import "TCMPortMapper.h" 6 | #import "TCMNATPMPPortMapper.h" 7 | #include "miniwget.h" 8 | #include "miniupnpc.h" 9 | #include "upnpcommands.h" 10 | #include "upnperrors.h" 11 | 12 | extern NSString * const TCMUPNPPortMapperDidFailNotification; 13 | extern NSString * const TCMUPNPPortMapperDidGetExternalIPAddressNotification; 14 | extern NSString * const TCMUPNPPortMapperDidBeginWorkingNotification; 15 | extern NSString * const TCMUPNPPortMapperDidEndWorkingNotification; 16 | 17 | @interface TCMUPNPPortMapper : NSObject { 18 | NSLock *_threadIsRunningLock; 19 | BOOL refreshThreadShouldQuit; 20 | BOOL UpdatePortMappingsThreadShouldQuit; 21 | BOOL UpdatePortMappingsThreadShouldRestart; 22 | TCMPortMappingThreadID runningThreadID; 23 | struct UPNPUrls _urls; 24 | struct IGDdatas _igddata; 25 | } 26 | 27 | @property (atomic, strong) NSArray *latestUPNPPortMappingsList; 28 | 29 | - (void)refresh; 30 | - (void)updatePortMappings; 31 | - (void)stop; 32 | - (void)stopBlocking; 33 | - (NSArray *)latestUPNPPortMappingsList; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /framework/libnatpmp/Changelog.txt: -------------------------------------------------------------------------------- 1 | $Id: Changelog.txt,v 1.33 2013/11/26 08:47:36 nanard Exp $ 2 | 3 | 2013/11/26: 4 | enforce strict aliasing rules. 5 | 6 | 2013/09/10: 7 | small patch for MSVC >= 16 8 | rename win32 implementation of gettimeofday() to natpmp_gettimeofday() 9 | 10 | 2012/08/21: 11 | Little change in Makefile 12 | removed warnings in testgetgateway.c 13 | Fixed bugs in command line argumentparsing in natpmpc.c 14 | 15 | 2011/08/07: 16 | Patch to build on debian/kFreeBSD. 17 | 18 | 2011/07/15: 19 | Put 3 clauses BSD licence at the top of source files. 20 | 21 | 2011/06/18: 22 | --no-undefined => -Wl,--no-undefined 23 | adding a natpmpc.1 man page 24 | 25 | 2011/05/19: 26 | Small fix in libnatpmpmodule.c thanks to Manuel Mausz 27 | 28 | 2011/01/03: 29 | Added an argument to initnatpmp() in order to force the gateway to be used 30 | 31 | 2011/01/01: 32 | fix in make install 33 | 34 | 2010/05/21: 35 | make install now working under MacOSX (and BSD) 36 | 37 | 2010/04/12: 38 | cplusplus stuff in natpmp.h 39 | 40 | 2010/02/02: 41 | Fixed compilation under Mac OS X 42 | 43 | 2009/12/19: 44 | improve and fix building under Windows. 45 | Project files for MS Visual Studio 2008 46 | More simple (and working) code for Win32. 47 | More checks in the /proc/net/route parsing. Add some comments. 48 | 49 | 2009/08/04: 50 | improving getgateway.c for windows 51 | 52 | 2009/07/13: 53 | Adding Haiku code in getgateway.c 54 | 55 | 2009/06/04: 56 | Adding Python module thanks to David Wu 57 | 58 | 2009/03/10: 59 | Trying to have windows get gateway working if not using DHCP 60 | 61 | 2009/02/27: 62 | dont include declspec.h if not under WIN32. 63 | 64 | 2009/01/23: 65 | Prefixed the libraries name with lib 66 | 67 | 2008/10/06: 68 | Fixed a memory leak in getdefaultgateway() (USE_SYSCTL_NET_ROUTE) 69 | 70 | 2008/07/03: 71 | Adding WIN32 code from Robbie Hanson 72 | 73 | 2008/06/30: 74 | added a Solaris implementation for getgateway(). 75 | added a LICENCE file to the distribution 76 | 77 | 2008/05/29: 78 | Anonymous unions are forbidden in ANSI C. That was causing problems with 79 | non-GCC compilers. 80 | 81 | 2008/04/28: 82 | introduced strnatpmperr() 83 | improved natpmpc.c sample 84 | make install now install the binary 85 | 86 | 2007/12/13: 87 | Fixed getgateway.c for working under OS X ;) 88 | Fixed values for NATPMP_PROTOCOL_TCP and NATPMP_PROTOCOL_UDP 89 | 90 | 2007/12/11: 91 | Fixed getgateway.c for compilation under Mac OS X 92 | 93 | 2007/12/01: 94 | added some comments in .h 95 | 96 | 2007/11/30: 97 | implemented almost everything 98 | 99 | -------------------------------------------------------------------------------- /framework/libnatpmp/JavaTest.java: -------------------------------------------------------------------------------- 1 | import java.net.InetAddress; 2 | import java.net.UnknownHostException; 3 | import java.nio.ByteBuffer; 4 | 5 | import fr.free.miniupnp.libnatpmp.NatPmp; 6 | import fr.free.miniupnp.libnatpmp.NatPmpResponse; 7 | 8 | class JavaTest { 9 | public static void main(String[] args) { 10 | NatPmp natpmp = new NatPmp(); 11 | 12 | natpmp.sendPublicAddressRequest(); 13 | NatPmpResponse response = new NatPmpResponse(); 14 | 15 | int result = -1; 16 | do{ 17 | result = natpmp.readNatPmpResponseOrRetry(response); 18 | try { 19 | Thread.sleep(4000); 20 | } catch (InterruptedException e) { 21 | //fallthrough 22 | } 23 | } while (result != 0); 24 | 25 | byte[] bytes = intToByteArray(response.addr); 26 | 27 | try { 28 | InetAddress inetAddress = InetAddress.getByAddress(bytes); 29 | System.out.println("Public address is " + inetAddress); 30 | } catch (UnknownHostException e) { 31 | throw new RuntimeException(e); 32 | } 33 | } 34 | 35 | public static final byte[] intToByteArray(int value) { 36 | return new byte[] { 37 | (byte)value, 38 | (byte)(value >>> 8), 39 | (byte)(value >>> 16), 40 | (byte)(value >>> 24)}; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /framework/libnatpmp/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2007-2011, Thomas BERNARD 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | * The name of the author may not be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | 27 | -------------------------------------------------------------------------------- /framework/libnatpmp/README: -------------------------------------------------------------------------------- 1 | libnatpmp (c) 2007-2009 Thomas Bernard 2 | contact : miniupnp@free.fr 3 | 4 | see http://miniupnp.free.fr/libnatpmp.html 5 | or http://miniupnp.tuxfamily.org/libnatpmp.html 6 | for some documentation and code samples. 7 | 8 | -------------------------------------------------------------------------------- /framework/libnatpmp/build.bat: -------------------------------------------------------------------------------- 1 | @echo Compiling with MinGW 2 | @SET LIBS=-lws2_32 -liphlpapi 3 | 4 | @echo Compile getgateway 5 | gcc -c -Wall -Os -DWIN32 -DSTATICLIB -DENABLE_STRNATPMPERR getgateway.c 6 | gcc -c -Wall -Os -DWIN32 -DSTATICLIB -DENABLE_STRNATPMPERR testgetgateway.c 7 | gcc -o testgetgateway getgateway.o testgetgateway.o %LIBS% 8 | del testgetgateway.o 9 | 10 | @echo Compile natpmp-static: 11 | gcc -c -Wall -Os -DWIN32 -DSTATICLIB -DENABLE_STRNATPMPERR getgateway.c 12 | gcc -c -Wall -Os -DWIN32 -DSTATICLIB -DENABLE_STRNATPMPERR natpmp.c 13 | gcc -c -Wall -Os -DWIN32 wingettimeofday.c 14 | ar cr natpmp.a getgateway.o natpmp.o wingettimeofday.o 15 | del getgateway.o natpmp.o 16 | gcc -c -Wall -Os -DWIN32 -DSTATICLIB -DENABLE_STRNATPMPERR natpmpc.c 17 | gcc -o natpmpc-static natpmpc.o natpmp.a %LIBS% 18 | upx --best natpmpc-static.exe 19 | del natpmpc.o 20 | 21 | @echo Create natpmp.dll: 22 | gcc -c -Wall -Os -DWIN32 -DENABLE_STRNATPMPERR -DNATPMP_EXPORTS getgateway.c 23 | gcc -c -Wall -Os -DWIN32 -DENABLE_STRNATPMPERR -DNATPMP_EXPORTS natpmp.c 24 | dllwrap -k --driver-name gcc --def natpmp.def --output-def natpmp.dll.def --implib natpmp.lib -o natpmp.dll getgateway.o natpmp.o wingettimeofday.o %LIBS% 25 | 26 | @echo Compile natpmp-shared: 27 | gcc -c -Wall -Os -DWIN32 -DENABLE_STRNATPMPERR -DNATPMP_EXPORTS natpmpc.c 28 | gcc -o natpmpc-shared natpmpc.o natpmp.lib -lws2_32 29 | upx --best natpmpc-shared.exe 30 | del *.o 31 | -------------------------------------------------------------------------------- /framework/libnatpmp/declspec.h: -------------------------------------------------------------------------------- 1 | #ifndef DECLSPEC_H_INCLUDED 2 | #define DECLSPEC_H_INCLUDED 3 | 4 | #if defined(WIN32) && !defined(STATICLIB) 5 | /* for windows dll */ 6 | #ifdef NATPMP_EXPORTS 7 | #define LIBSPEC __declspec(dllexport) 8 | #else 9 | #define LIBSPEC __declspec(dllimport) 10 | #endif 11 | #else 12 | #if defined(__GNUC__) && __GNUC__ >= 4 13 | /* fix dynlib for OS X 10.9.2 and Apple LLVM version 5.0 */ 14 | #define LIBSPEC __attribute__ ((visibility ("default"))) 15 | #else 16 | #define LIBSPEC 17 | #endif 18 | #endif 19 | 20 | #endif 21 | 22 | -------------------------------------------------------------------------------- /framework/libnatpmp/fr/free/miniupnp/libnatpmp/NatPmp.java: -------------------------------------------------------------------------------- 1 | package fr.free.miniupnp.libnatpmp; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | 6 | public class NatPmp { 7 | private static final String JNA_LIBRARY_NAME = LibraryExtractor.getLibraryPath("jninatpmp", true, NatPmp.class); 8 | 9 | static { 10 | String s = JNA_LIBRARY_NAME; 11 | startup(); 12 | } 13 | 14 | public ByteBuffer natpmp; 15 | 16 | public NatPmp() { 17 | init(0, 0); 18 | } 19 | 20 | public NatPmp(int forcedgw) { 21 | init(1, forcedgw); 22 | } 23 | 24 | /** Cleans up the native resources used by this object. 25 | Attempting to use the object after this has been called 26 | will lead to crashes.*/ 27 | public void dispose() { 28 | free(); 29 | } 30 | 31 | 32 | protected void finalize() { 33 | if (natpmp != null) 34 | free(); 35 | } 36 | 37 | private native void init(int forcegw, int forcedgw); 38 | private native void free(); 39 | 40 | private static native void startup(); 41 | 42 | public native int sendPublicAddressRequest(); 43 | public native int sendNewPortMappingRequest(int protocol, int privateport, int publicport, int lifetime); 44 | 45 | //returns a number of milliseconds, in accordance with Java convention 46 | public native long getNatPmpRequestTimeout(); 47 | 48 | public native int readNatPmpResponseOrRetry(NatPmpResponse response); 49 | 50 | } 51 | -------------------------------------------------------------------------------- /framework/libnatpmp/fr/free/miniupnp/libnatpmp/NatPmpResponse.java: -------------------------------------------------------------------------------- 1 | package fr.free.miniupnp.libnatpmp; 2 | 3 | public class NatPmpResponse { 4 | 5 | public static final int TYPE_PUBLICADDRESS=0; 6 | public static final int TYPE_UDPPORTMAPPING=1; 7 | public static final int TYPE_TCPPORTMAPPING=2; 8 | 9 | /** see TYPE_* constants */ 10 | public short type; 11 | /** NAT-PMP response code */ 12 | public short resultcode; 13 | /** milliseconds since start of epoch */ 14 | public long epoch; 15 | 16 | /** only defined if type == 0*/ 17 | public int addr; 18 | 19 | /** only defined if type != 0 */ 20 | public int privateport; 21 | 22 | /** only defined if type != 0 */ 23 | public int mappedpublicport; 24 | 25 | /** only defined if type != 0 */ 26 | public long lifetime; //milliseconds 27 | 28 | } -------------------------------------------------------------------------------- /framework/libnatpmp/fr/free/miniupnp/libnatpmp/URLUtils.java: -------------------------------------------------------------------------------- 1 | package fr.free.miniupnp.libnatpmp; 2 | 3 | /** I (Leah X Schmidt) copied this code from jnaerator, because 4 | JNAerator's extractor requires you to buy into the whole JNA 5 | concept. 6 | 7 | JNAErator is 8 | Copyright (c) 2009 Olivier Chafik, All Rights Reserved 9 | 10 | JNAerator is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | JNAerator is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License 21 | along with JNAerator. If not, see . 22 | 23 | */ 24 | 25 | import java.io.File; 26 | import java.io.IOException; 27 | import java.io.InputStream; 28 | import java.net.URL; 29 | import java.util.ArrayList; 30 | import java.util.List; 31 | import java.util.jar.JarEntry; 32 | import java.util.jar.JarInputStream; 33 | 34 | public class URLUtils { 35 | 36 | public static URL getResource(Class cl, String path) throws IOException { 37 | String clp = cl.getName().replace('.', '/') + ".class"; 38 | URL clu = cl.getClassLoader().getResource(clp); 39 | String s = clu.toString(); 40 | if (s.endsWith(clp)) 41 | return new URL(s.substring(0, s.length() - clp.length()) + path); 42 | 43 | if (s.startsWith("jar:")) { 44 | String[] ss = s.split("!"); 45 | return new URL(ss[1] + "!/" + path); 46 | } 47 | return null; 48 | } 49 | 50 | public static List listFiles(URL directory) throws IOException { 51 | List ret = new ArrayList(); 52 | String s = directory.toString(); 53 | if (s.startsWith("jar:")) { 54 | String[] ss = s.substring("jar:".length()).split("!"); 55 | String path = ss[1]; 56 | URL target = new URL(ss[0]); 57 | InputStream tin = target.openStream(); 58 | try { 59 | JarInputStream jin = new JarInputStream(tin); 60 | JarEntry je; 61 | while ((je = jin.getNextJarEntry()) != null) { 62 | String p = "/" + je.getName(); 63 | if (p.startsWith(path) && p.indexOf('/', path.length() + 1) < 0) 64 | 65 | ret.add(new URL("jar:" + target + "!" + p)); 66 | } 67 | } finally { 68 | tin.close(); 69 | } 70 | } else if (s.startsWith("file:")) { 71 | File f = new File(directory.getFile()); 72 | File[] ffs = f.listFiles(); 73 | if (ffs != null) 74 | for (File ff : ffs) 75 | ret.add(ff.toURI().toURL()); 76 | } else 77 | throw new IOException("Cannot list contents of " + directory); 78 | 79 | return ret; 80 | } 81 | } -------------------------------------------------------------------------------- /framework/libnatpmp/getgateway.h: -------------------------------------------------------------------------------- 1 | /* $Id: getgateway.h,v 1.8 2014/04/22 09:15:40 nanard Exp $ */ 2 | /* libnatpmp 3 | Copyright (c) 2007-2014, Thomas BERNARD 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, 10 | this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | * The name of the author may not be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | #ifndef __GETGATEWAY_H__ 30 | #define __GETGATEWAY_H__ 31 | 32 | #ifdef WIN32 33 | #if !defined(_MSC_VER) || _MSC_VER >= 1600 34 | #include 35 | #else 36 | typedef unsigned long uint32_t; 37 | typedef unsigned short uint16_t; 38 | #endif 39 | #define in_addr_t uint32_t 40 | #endif 41 | /* #include "declspec.h" */ 42 | 43 | /* getdefaultgateway() : 44 | * return value : 45 | * 0 : success 46 | * -1 : failure */ 47 | /* LIBSPEC */int getdefaultgateway(in_addr_t * addr); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /framework/libnatpmp/msvc/libnatpmp.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual C++ Express 2008 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libnatpmp", "libnatpmp.vcproj", "{D59B6527-F3DE-4D26-A08D-52F1EE989301}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "natpmpc-static", "natpmpc-static.vcproj", "{A0B49FA9-98AB-4A74-8B4C-8AB7FA36089B}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {D59B6527-F3DE-4D26-A08D-52F1EE989301} = {D59B6527-F3DE-4D26-A08D-52F1EE989301} 9 | EndProjectSection 10 | EndProject 11 | Global 12 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 13 | Debug|Win32 = Debug|Win32 14 | Release|Win32 = Release|Win32 15 | EndGlobalSection 16 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 17 | {D59B6527-F3DE-4D26-A08D-52F1EE989301}.Debug|Win32.ActiveCfg = Debug|Win32 18 | {D59B6527-F3DE-4D26-A08D-52F1EE989301}.Debug|Win32.Build.0 = Debug|Win32 19 | {D59B6527-F3DE-4D26-A08D-52F1EE989301}.Release|Win32.ActiveCfg = Release|Win32 20 | {D59B6527-F3DE-4D26-A08D-52F1EE989301}.Release|Win32.Build.0 = Release|Win32 21 | {A0B49FA9-98AB-4A74-8B4C-8AB7FA36089B}.Debug|Win32.ActiveCfg = Debug|Win32 22 | {A0B49FA9-98AB-4A74-8B4C-8AB7FA36089B}.Debug|Win32.Build.0 = Debug|Win32 23 | {A0B49FA9-98AB-4A74-8B4C-8AB7FA36089B}.Release|Win32.ActiveCfg = Release|Win32 24 | {A0B49FA9-98AB-4A74-8B4C-8AB7FA36089B}.Release|Win32.Build.0 = Release|Win32 25 | EndGlobalSection 26 | GlobalSection(SolutionProperties) = preSolution 27 | HideSolutionNode = FALSE 28 | EndGlobalSection 29 | EndGlobal 30 | -------------------------------------------------------------------------------- /framework/libnatpmp/msvc/libnatpmp.vcproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monkeydom/TCMPortMapper/914d064d4e8d37c20be3e91260881bb5bcf8c455/framework/libnatpmp/msvc/libnatpmp.vcproj -------------------------------------------------------------------------------- /framework/libnatpmp/msvc/natpmpc-static.vcproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monkeydom/TCMPortMapper/914d064d4e8d37c20be3e91260881bb5bcf8c455/framework/libnatpmp/msvc/natpmpc-static.vcproj -------------------------------------------------------------------------------- /framework/libnatpmp/natpmp.def: -------------------------------------------------------------------------------- 1 | LIBRARY 2 | ; libnatpmp library 3 | 4 | EXPORTS 5 | initnatpmp 6 | closenatpmp 7 | sendpublicaddressrequest 8 | sendnewportmappingrequest 9 | getnatpmprequesttimeout 10 | readnatpmpresponseorretry 11 | strnatpmperr 12 | -------------------------------------------------------------------------------- /framework/libnatpmp/natpmpc.1: -------------------------------------------------------------------------------- 1 | .TH natpmpc 1 2 | 3 | .SH NAME 4 | natpmpc \- NAT\-PMP library test client and mapping setter. 5 | 6 | .SH "SYNOPSIS" 7 | Display the public IP address: 8 | .br 9 | \fBnatpmpc\fP 10 | 11 | Add a port mapping: 12 | .br 13 | \fBnatpmpc\fP \-a [lifetime] 14 | 15 | .SH DESCRIPTION 16 | 17 | In order to remove a mapping, set it with a lifetime of 0 seconds. 18 | To remove all mappings for your machine, use 0 as private port and 19 | lifetime. 20 | -------------------------------------------------------------------------------- /framework/libnatpmp/setup.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/python 2 | # $Id: setup.py,v 1.3 2012/03/05 04:54:01 nanard Exp $ 3 | # 4 | # python script to build the libnatpmp module under unix 5 | # 6 | # replace libnatpmp.a by libnatpmp.so for shared library usage 7 | from distutils.core import setup, Extension 8 | from distutils import sysconfig 9 | sysconfig.get_config_vars()["OPT"] = '' 10 | sysconfig.get_config_vars()["CFLAGS"] = '' 11 | setup(name="libnatpmp", version="1.0", 12 | ext_modules=[ 13 | Extension(name="libnatpmp", sources=["libnatpmpmodule.c"], 14 | extra_objects=["libnatpmp.a"], 15 | define_macros=[('ENABLE_STRNATPMPERR', None)] 16 | )] 17 | ) 18 | 19 | -------------------------------------------------------------------------------- /framework/libnatpmp/setupmingw32.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/python 2 | # $Id: setupmingw32.py,v 1.3 2012/03/05 04:54:01 nanard Exp $ 3 | # python script to build the miniupnpc module under windows 4 | # 5 | from distutils.core import setup, Extension 6 | from distutils import sysconfig 7 | sysconfig.get_config_vars()["OPT"] = '' 8 | sysconfig.get_config_vars()["CFLAGS"] = '' 9 | setup(name="libnatpmp", version="1.0", 10 | ext_modules=[ 11 | Extension(name="libnatpmp", sources=["libnatpmpmodule.c"], 12 | libraries=["ws2_32"], 13 | extra_objects=["libnatpmp.a"], 14 | define_macros=[('ENABLE_STRNATPMPERR', None)] 15 | )] 16 | ) 17 | 18 | -------------------------------------------------------------------------------- /framework/libnatpmp/testgetgateway.c: -------------------------------------------------------------------------------- 1 | /* $Id: testgetgateway.c,v 1.7 2012/08/21 17:13:31 nanard Exp $ */ 2 | /* libnatpmp 3 | Copyright (c) 2007-2011, Thomas BERNARD 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, 10 | this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | * The name of the author may not be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | #include 30 | #ifdef WIN32 31 | #include 32 | #else 33 | #include 34 | #include 35 | #endif 36 | #include "getgateway.h" 37 | 38 | int main(int argc, char * * argv) 39 | { 40 | (void)argc; 41 | (void)argv; 42 | struct in_addr gatewayaddr; 43 | int r; 44 | #ifdef WIN32 45 | uint32_t temp = 0; 46 | r = getdefaultgateway(&temp); 47 | gatewayaddr.S_un.S_addr = temp; 48 | #else 49 | r = getdefaultgateway(&(gatewayaddr.s_addr)); 50 | #endif 51 | if(r>=0) 52 | printf("default gateway : %s\n", inet_ntoa(gatewayaddr)); 53 | else 54 | fprintf(stderr, "getdefaultgateway() failed\n"); 55 | return 0; 56 | } 57 | 58 | -------------------------------------------------------------------------------- /framework/libnatpmp/wingettimeofday.c: -------------------------------------------------------------------------------- 1 | /* $Id: wingettimeofday.c,v 1.6 2013/09/10 20:13:26 nanard Exp $ */ 2 | /* libnatpmp 3 | Copyright (c) 2007-2013, Thomas BERNARD 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, 10 | this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | * The name of the author may not be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | #ifdef WIN32 30 | #if defined(_MSC_VER) 31 | struct timeval { 32 | long tv_sec; 33 | long tv_usec; 34 | }; 35 | #else 36 | #include 37 | #endif 38 | 39 | typedef struct _FILETIME { 40 | unsigned long dwLowDateTime; 41 | unsigned long dwHighDateTime; 42 | } FILETIME; 43 | 44 | void __stdcall GetSystemTimeAsFileTime(FILETIME*); 45 | 46 | int natpmp_gettimeofday(struct timeval* p, void* tz /* IGNORED */) { 47 | union { 48 | long long ns100; /*time since 1 Jan 1601 in 100ns units */ 49 | FILETIME ft; 50 | } _now; 51 | 52 | if(!p) 53 | return -1; 54 | GetSystemTimeAsFileTime( &(_now.ft) ); 55 | p->tv_usec =(long)((_now.ns100 / 10LL) % 1000000LL ); 56 | p->tv_sec = (long)((_now.ns100-(116444736000000000LL))/10000000LL); 57 | return 0; 58 | } 59 | #endif 60 | 61 | -------------------------------------------------------------------------------- /framework/libnatpmp/wingettimeofday.h: -------------------------------------------------------------------------------- 1 | /* $Id: wingettimeofday.h,v 1.5 2013/09/11 07:22:25 nanard Exp $ */ 2 | /* libnatpmp 3 | Copyright (c) 2007-2013, Thomas BERNARD 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, 10 | this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | * The name of the author may not be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | #ifndef __WINGETTIMEOFDAY_H__ 30 | #define __WINGETTIMEOFDAY_H__ 31 | #ifdef WIN32 32 | #if defined(_MSC_VER) 33 | #include 34 | #else 35 | #include 36 | #endif 37 | int natpmp_gettimeofday(struct timeval* p, void* tz /* IGNORED */); 38 | #endif 39 | #endif 40 | -------------------------------------------------------------------------------- /framework/miniupnp_modeldescription.patch: -------------------------------------------------------------------------------- 1 | diff -Naur miniupnpc-20080217/igd_desc_parse.c miniupnpcpatched/igd_desc_parse.c 2 | --- miniupnpc-20080217/igd_desc_parse.c 2006-11-19 23:32:55.000000000 +0100 3 | +++ miniupnpcpatched/igd_desc_parse.c 2008-02-17 13:17:43.000000000 +0100 4 | @@ -17,6 +17,7 @@ 5 | struct IGDdatas * datas = (struct IGDdatas *)d; 6 | memcpy( datas->cureltname, name, l); 7 | datas->cureltname[l] = '\0'; 8 | + //printf("element:%s\n",datas->cureltname); 9 | datas->level++; 10 | } 11 | 12 | @@ -60,6 +61,8 @@ 13 | datas->level, datas->cureltname, l, data); */ 14 | if( !strcmp(datas->cureltname, "URLBase") ) 15 | dstmember = datas->urlbase; 16 | + if (!strcmp(datas->cureltname, "modelDescription") && datas->level <= 3) 17 | + dstmember = datas->modeldescription; 18 | else if(datas->state<=1) 19 | { 20 | if( !strcmp(datas->cureltname, "serviceType") ) 21 | @@ -88,6 +91,9 @@ 22 | } 23 | if(dstmember) 24 | { 25 | +// printf("----->dstmember: %2d %s : %.*s\n", 26 | +// datas->level, datas->cureltname, l, data); 27 | + 28 | if(l>=MINIUPNPC_URL_MAXSIZE) 29 | l = MINIUPNPC_URL_MAXSIZE-1; 30 | memcpy(dstmember, data, l); 31 | diff -Naur miniupnpc-20080217/igd_desc_parse.h miniupnpcpatched/igd_desc_parse.h 32 | --- miniupnpc-20080217/igd_desc_parse.h 2007-04-11 17:21:09.000000000 +0200 33 | +++ miniupnpcpatched/igd_desc_parse.h 2008-02-17 13:17:43.000000000 +0100 34 | @@ -27,6 +27,7 @@ 35 | char scpdurl[MINIUPNPC_URL_MAXSIZE]; 36 | char servicetype[MINIUPNPC_URL_MAXSIZE]; 37 | char devicetype[MINIUPNPC_URL_MAXSIZE]; 38 | + char modeldescription[MINIUPNPC_URL_MAXSIZE]; 39 | }; 40 | 41 | void IGDstartelt(void *, const char *, int); 42 | -------------------------------------------------------------------------------- /framework/miniupnpc/LICENSE: -------------------------------------------------------------------------------- 1 | MiniUPnPc 2 | Copyright (c) 2005-2016, Thomas BERNARD 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | * The name of the author may not be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | POSSIBILITY OF SUCH DAMAGE. 27 | 28 | -------------------------------------------------------------------------------- /framework/miniupnpc/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README 2 | include VERSION 3 | include LICENSE 4 | include miniupnpcmodule.c 5 | include setup.py 6 | include Makefile 7 | include *.[ch] 8 | include *.h.in 9 | include *.sh 10 | -------------------------------------------------------------------------------- /framework/miniupnpc/Makefile.mingw: -------------------------------------------------------------------------------- 1 | # $Id: Makefile.mingw,v 1.24 2018/05/03 08:17:29 nanard Exp $ 2 | # Miniupnp project. 3 | # http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/ 4 | # (c) 2005-2018 Thomas Bernard 5 | # This Makefile is made for MinGW 6 | # 7 | # To cross compile on a *nix machine : 8 | # make -f Makefile.mingw DLLWRAP=mingw32-dllwrap CC=mingw32-gcc AR=mingw32-ar 9 | # 10 | CC ?= gcc 11 | DLLWRAP = dllwrap 12 | SH = /bin/sh 13 | ifeq ($(OS),Windows_NT) 14 | RM = del 15 | else 16 | RM = rm -f 17 | endif 18 | #CFLAGS = -Wall -g -DDEBUG -D_WIN32_WINNT=0X501 19 | CFLAGS = -Wall -Os -DNDEBUG -D_WIN32_WINNT=0X501 20 | LDLIBS = -lws2_32 -liphlpapi 21 | # -lwsock32 22 | # -liphlpapi is needed for GetBestRoute() and GetIpAddrTable() 23 | PYTHON=\utils\python25\python 24 | OBJS=miniwget.o minixml.o igd_desc_parse.o minisoap.o \ 25 | minissdpc.o \ 26 | miniupnpc.o upnpreplyparse.o upnpcommands.o upnperrors.o \ 27 | connecthostport.o portlistingparse.o receivedata.o \ 28 | upnpdev.o 29 | OBJSDLL=$(addprefix dll/, $(OBJS)) 30 | 31 | all: init upnpc-static upnpc-shared testminixml libminiupnpc.a \ 32 | miniupnpc.dll listdevices 33 | 34 | init: 35 | mkdir dll 36 | echo init > init 37 | 38 | clean: 39 | $(RM) upnpc testminixml *.o 40 | $(RM) dll\*.o 41 | $(RM) *.exe 42 | $(RM) miniupnpc.dll 43 | $(RM) libminiupnpc.a 44 | 45 | libminiupnpc.a: $(OBJS) 46 | $(AR) cr $@ $? 47 | 48 | pythonmodule: libminiupnpc.a 49 | $(PYTHON) setupmingw32.py build --compiler=mingw32 50 | $(PYTHON) setupmingw32.py install --skip-build 51 | 52 | miniupnpc.dll: libminiupnpc.a $(OBJSDLL) 53 | $(DLLWRAP) -k --driver-name $(CC) \ 54 | --def miniupnpc.def \ 55 | --output-def miniupnpc.dll.def \ 56 | --implib miniupnpc.lib -o $@ \ 57 | $(OBJSDLL) $(LDLIBS) 58 | 59 | miniupnpc.lib: miniupnpc.dll 60 | # echo $@ generated with $< 61 | 62 | dll/upnpc.o: upnpc.o 63 | # echo $@ generated with $< 64 | 65 | .c.o: 66 | $(CC) $(CFLAGS) -DMINIUPNP_STATICLIB -c -o $@ $< 67 | $(CC) $(CFLAGS) -DMINIUPNP_EXPORTS -c -o dll/$@ $< 68 | 69 | upnpc.o: upnpc.c 70 | $(CC) $(CFLAGS) -DMINIUPNP_STATICLIB -c -o $@ $< 71 | $(CC) $(CFLAGS) -c -o dll/$@ $< 72 | 73 | # --enable-stdcall-fixup 74 | upnpc-static: upnpc.o libminiupnpc.a 75 | $(CC) -o $@ $^ $(LDLIBS) 76 | 77 | upnpc-shared: dll/upnpc.o miniupnpc.lib 78 | $(CC) -o $@ $^ $(LDLIBS) 79 | 80 | listdevices: listdevices.o libminiupnpc.a 81 | $(CC) -o $@ $^ $(LDLIBS) 82 | 83 | wingenminiupnpcstrings: wingenminiupnpcstrings.o 84 | 85 | wingenminiupnpcstrings.o: wingenminiupnpcstrings.c 86 | 87 | # To make miniupnpcstrings.h from miniupnpcstrings.h.in we either 88 | # use a custom executable (if running make under windows) or use 89 | # sed (if cross compiling from another platform). 90 | ifeq ($(OS),Windows_NT) 91 | miniupnpcstrings.h: miniupnpcstrings.h.in wingenminiupnpcstrings 92 | wingenminiupnpcstrings $< $@ 93 | else 94 | miniupnpcstrings.h: miniupnpcstrings.h.in VERSION 95 | sed 's|OS_STRING ".*"|OS_STRING "Windows/Mingw32"|' $< | \ 96 | sed 's|MINIUPNPC_VERSION_STRING ".*"|MINIUPNPC_VERSION_STRING "$(shell cat VERSION)"|' > $@ 97 | endif 98 | 99 | minixml.o: minixml.c minixml.h 100 | 101 | upnpc.o: miniwget.h minisoap.h miniupnpc.h igd_desc_parse.h 102 | upnpc.o: upnpreplyparse.h upnpcommands.h upnperrors.h miniupnpcstrings.h 103 | 104 | miniwget.o: miniwget.c miniwget.h miniupnpcstrings.h connecthostport.h 105 | 106 | minisoap.o: minisoap.c minisoap.h miniupnpcstrings.h 107 | 108 | miniupnpc.o: miniupnpc.c miniupnpc.h minisoap.h miniwget.h minixml.h 109 | 110 | igd_desc_parse.o: igd_desc_parse.c igd_desc_parse.h 111 | 112 | testminixml: minixml.o igd_desc_parse.o testminixml.c 113 | 114 | upnpreplyparse.o: upnpreplyparse.c upnpreplyparse.h minixml.h 115 | 116 | upnpcommands.o: upnpcommands.c upnpcommands.h upnpreplyparse.h miniupnpc.h portlistingparse.h 117 | 118 | minissdpc.o: minissdpc.c minissdpc.h receivedata.h 119 | 120 | upnpdev.o: upnpdev.c upnpdev.h 121 | 122 | -------------------------------------------------------------------------------- /framework/miniupnpc/README: -------------------------------------------------------------------------------- 1 | Project: miniupnp 2 | Project web page: http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/ 3 | github: https://github.com/miniupnp/miniupnp 4 | Author: Thomas Bernard 5 | Copyright (c) 2005-2017 Thomas Bernard 6 | This software is subject to the conditions detailed in the 7 | LICENSE file provided within this distribution. 8 | 9 | 10 | * miniUPnP Client - miniUPnPc * 11 | 12 | To compile, simply run 'gmake' (could be 'make' on your system). 13 | Under win32, to compile with MinGW, type "mingw32make.bat". 14 | MS Visual C solution and project files are supplied in the msvc/ subdirectory. 15 | 16 | The compilation is known to work under linux, FreeBSD, 17 | OpenBSD, MacOS X, AmigaOS and cygwin. 18 | The official AmigaOS4.1 SDK was used for AmigaOS4 and GeekGadgets for AmigaOS3. 19 | upx (http://upx.sourceforge.net) is used to compress the win32 .exe files. 20 | 21 | To install the library and headers on the system use : 22 | > su 23 | > make install 24 | > exit 25 | 26 | alternatively, to install into a specific location, use : 27 | > INSTALLPREFIX=/usr/local make install 28 | 29 | upnpc.c is a sample client using the libminiupnpc. 30 | To use the libminiupnpc in your application, link it with 31 | libminiupnpc.a (or .so) and use the following functions found in miniupnpc.h, 32 | upnpcommands.h and miniwget.h : 33 | - upnpDiscover() 34 | - UPNP_GetValidIGD() 35 | - miniwget() 36 | - parserootdesc() 37 | - GetUPNPUrls() 38 | - UPNP_* (calling UPNP methods) 39 | 40 | Note : use #include etc... for the includes 41 | and -lminiupnpc for the link 42 | 43 | Discovery process is speeded up when MiniSSDPd is running on the machine. 44 | 45 | 46 | * Python module * 47 | 48 | you can build a python module with 'make pythonmodule' 49 | and install it with 'make installpythonmodule'. 50 | setup.py (and setupmingw32.py) are included in the distribution. 51 | 52 | 53 | Feel free to contact me if you have any problem : 54 | e-mail : miniupnp@free.fr 55 | 56 | If you are using libminiupnpc in your application, please 57 | send me an email ! 58 | 59 | For any question, you can use the web forum : 60 | https://miniupnp.tuxfamily.org/forum/ 61 | 62 | Bugs should be reported on github : 63 | https://github.com/miniupnp/miniupnp/issues 64 | -------------------------------------------------------------------------------- /framework/miniupnpc/VERSION: -------------------------------------------------------------------------------- 1 | 2.1 2 | -------------------------------------------------------------------------------- /framework/miniupnpc/codelength.h: -------------------------------------------------------------------------------- 1 | /* $Id: codelength.h,v 1.5 2015/07/09 12:40:18 nanard Exp $ */ 2 | /* Project : miniupnp 3 | * Author : Thomas BERNARD 4 | * copyright (c) 2005-2015 Thomas Bernard 5 | * This software is subjet to the conditions detailed in the 6 | * provided LICENCE file. */ 7 | #ifndef CODELENGTH_H_INCLUDED 8 | #define CODELENGTH_H_INCLUDED 9 | 10 | /* Encode length by using 7bit per Byte : 11 | * Most significant bit of each byte specifies that the 12 | * following byte is part of the code */ 13 | 14 | /* n : unsigned 15 | * p : unsigned char * 16 | */ 17 | #define DECODELENGTH(n, p) n = 0; \ 18 | do { n = (n << 7) | (*p & 0x7f); } \ 19 | while((*(p++)&0x80) && (n<(1<<25))); 20 | 21 | /* n : unsigned 22 | * READ : function/macro to read one byte (unsigned char) 23 | */ 24 | #define DECODELENGTH_READ(n, READ) \ 25 | n = 0; \ 26 | do { \ 27 | unsigned char c; \ 28 | READ(c); \ 29 | n = (n << 7) | (c & 0x07f); \ 30 | if(!(c&0x80)) break; \ 31 | } while(n<(1<<25)); 32 | 33 | /* n : unsigned 34 | * p : unsigned char * 35 | * p_limit : unsigned char * 36 | */ 37 | #define DECODELENGTH_CHECKLIMIT(n, p, p_limit) \ 38 | n = 0; \ 39 | do { \ 40 | if((p) >= (p_limit)) break; \ 41 | n = (n << 7) | (*(p) & 0x7f); \ 42 | } while((*((p)++)&0x80) && (n<(1<<25))); 43 | 44 | 45 | /* n : unsigned 46 | * p : unsigned char * 47 | */ 48 | #define CODELENGTH(n, p) if(n>=268435456) *(p++) = (n >> 28) | 0x80; \ 49 | if(n>=2097152) *(p++) = (n >> 21) | 0x80; \ 50 | if(n>=16384) *(p++) = (n >> 14) | 0x80; \ 51 | if(n>=128) *(p++) = (n >> 7) | 0x80; \ 52 | *(p++) = n & 0x7f; 53 | 54 | #endif /* CODELENGTH_H_INCLUDED */ 55 | -------------------------------------------------------------------------------- /framework/miniupnpc/connecthostport.h: -------------------------------------------------------------------------------- 1 | /* $Id: connecthostport.h,v 1.4 2018/04/06 10:53:13 nanard Exp $ */ 2 | /* Project: miniupnp 3 | * http://miniupnp.free.fr/ 4 | * Author: Thomas Bernard 5 | * Copyright (c) 2010-2018 Thomas Bernard 6 | * This software is subjects to the conditions detailed 7 | * in the LICENCE file provided within this distribution */ 8 | #ifndef CONNECTHOSTPORT_H_INCLUDED 9 | #define CONNECTHOSTPORT_H_INCLUDED 10 | 11 | #include "miniupnpc_socketdef.h" 12 | 13 | /* connecthostport() 14 | * return a socket connected (TCP) to the host and port 15 | * or INVALID_SOCKET in case of error */ 16 | SOCKET connecthostport(const char * host, unsigned short port, 17 | unsigned int scope_id); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /framework/miniupnpc/external-ip.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # $Id: external-ip.sh,v 1.2 2017/11/02 15:33:09 nanard Exp $ 3 | # (c) 2010 Reuben Hawkins 4 | upnpc -s | sed -n -e 's/^ExternalIPAddress = \([0-9.]*\)$/\1/p' 5 | -------------------------------------------------------------------------------- /framework/miniupnpc/igd_desc_parse.h: -------------------------------------------------------------------------------- 1 | /* $Id: igd_desc_parse.h,v 1.12 2014/11/17 17:19:13 nanard Exp $ */ 2 | /* Project : miniupnp 3 | * http://miniupnp.free.fr/ 4 | * Author : Thomas Bernard 5 | * Copyright (c) 2005-2014 Thomas Bernard 6 | * This software is subject to the conditions detailed in the 7 | * LICENCE file provided in this distribution. 8 | * */ 9 | #ifndef IGD_DESC_PARSE_H_INCLUDED 10 | #define IGD_DESC_PARSE_H_INCLUDED 11 | 12 | /* Structure to store the result of the parsing of UPnP 13 | * descriptions of Internet Gateway Devices */ 14 | #define MINIUPNPC_URL_MAXSIZE (128) 15 | struct IGDdatas_service { 16 | char controlurl[MINIUPNPC_URL_MAXSIZE]; 17 | char eventsuburl[MINIUPNPC_URL_MAXSIZE]; 18 | char scpdurl[MINIUPNPC_URL_MAXSIZE]; 19 | char servicetype[MINIUPNPC_URL_MAXSIZE]; 20 | char devicetype[MINIUPNPC_URL_MAXSIZE]; 21 | char modeldescription[MINIUPNPC_URL_MAXSIZE]; 22 | }; 23 | 24 | struct IGDdatas { 25 | char cureltname[MINIUPNPC_URL_MAXSIZE]; 26 | char urlbase[MINIUPNPC_URL_MAXSIZE]; 27 | char presentationurl[MINIUPNPC_URL_MAXSIZE]; 28 | int level; 29 | /*int state;*/ 30 | /* "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1" */ 31 | struct IGDdatas_service CIF; 32 | /* "urn:schemas-upnp-org:service:WANIPConnection:1" 33 | * "urn:schemas-upnp-org:service:WANPPPConnection:1" */ 34 | struct IGDdatas_service first; 35 | /* if both WANIPConnection and WANPPPConnection are present */ 36 | struct IGDdatas_service second; 37 | /* "urn:schemas-upnp-org:service:WANIPv6FirewallControl:1" */ 38 | struct IGDdatas_service IPv6FC; 39 | /* tmp */ 40 | struct IGDdatas_service tmp; 41 | }; 42 | 43 | void IGDstartelt(void *, const char *, int); 44 | void IGDendelt(void *, const char *, int); 45 | void IGDdata(void *, const char *, int); 46 | #ifdef DEBUG 47 | void printIGD(struct IGDdatas *); 48 | #endif /* DEBUG */ 49 | 50 | #endif /* IGD_DESC_PARSE_H_INCLUDED */ 51 | -------------------------------------------------------------------------------- /framework/miniupnpc/java/testjava.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set JAVA=java 3 | set JAVAC=javac 4 | REM notice the semicolon for Windows. Write once, run ... oh nevermind 5 | set CP=miniupnpc_win32.jar;. 6 | 7 | %JAVAC% -cp "%CP%" JavaBridgeTest.java || exit 1 8 | %JAVA% -cp "%CP%" JavaBridgeTest 12345 UDP || exit 1 9 | -------------------------------------------------------------------------------- /framework/miniupnpc/java/testjava.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | JAVA=java 4 | JAVAC=javac 5 | CP=$(for i in *.jar; do echo -n $i:; done). 6 | 7 | $JAVAC -cp $CP JavaBridgeTest.java || exit 1 8 | $JAVA -cp $CP JavaBridgeTest 12345 UDP || exit 1 9 | -------------------------------------------------------------------------------- /framework/miniupnpc/man3/miniupnpc.3: -------------------------------------------------------------------------------- 1 | .TH MINIUPNPC 3 2 | .SH NAME 3 | miniupnpc \- UPnP client library 4 | .SH SYNOPSIS 5 | .SH DESCRIPTION 6 | The miniupnpc library implement the UPnP protocol defined 7 | to dialog with Internet Gateway Devices. It also has 8 | the ability to use data gathered by minissdpd(1) about 9 | UPnP devices up on the network in order to skip the 10 | long UPnP device discovery process. 11 | .PP 12 | At first, upnpDiscover(3) has to be used to discover UPnP IGD present 13 | on the network. Then UPNP_GetValidIGD(3) to select the right one. 14 | Alternatively, UPNP_GetIGDFromUrl(3) could be used to bypass discovery 15 | process if the root description url of the device to use is known. 16 | Then all the UPNP_* functions can be used, such as 17 | UPNP_GetConnectionTypeInfo(3), UPNP_AddPortMapping(3), etc... 18 | .SH "HEADER FILES" 19 | .IP miniupnpc.h 20 | That's the main header file for the miniupnpc library API. 21 | It contains all the functions and structures related to device discovery. 22 | .IP upnpcommands.h 23 | This header file contain the UPnP IGD methods that are accessible 24 | through the miniupnpc API. The name of the C functions are matching 25 | the UPnP methods names. ie: GetGenericPortMappingEntry is 26 | UPNP_GetGenericPortMappingEntry. 27 | .SH "API FUNCTIONS" 28 | .IP "struct UPNPDev * upnpDiscover(int delay, const char * multicastif, const char * minissdpdsock, int localport, int ipv6, int * error);" 29 | execute the discovery process. 30 | delay (in millisecond) is the maximum time for waiting any device response. 31 | If available, device list will be obtained from MiniSSDPd. 32 | Default path for minissdpd socket will be used if minissdpdsock argument is NULL. 33 | If multicastif is not NULL, it will be used instead of the default multicast interface for sending SSDP discover packets. 34 | If localport is set to UPNP_LOCAL_PORT_SAME(1) SSDP packets will be sent 35 | from the source port 1900 (same as destination port), if set to 36 | UPNP_LOCAL_PORT_ANY(0) system assign a source port, any other value will 37 | be attempted as the source port. 38 | If ipv6 is not 0, IPv6 is used instead of IPv4 for the discovery process. 39 | .IP "void freeUPNPDevlist(struct UPNPDev * devlist);" 40 | free the list returned by upnpDiscover(). 41 | .IP "int UPNP_GetValidIGD(struct UPNPDev * devlist, struct UPNPUrls * urls, struct IGDdatas * data, char * lanaddr, int lanaddrlen);" 42 | browse the list of device returned by upnpDiscover(), find 43 | a live UPnP internet gateway device and fill structures passed as arguments 44 | with data used for UPNP methods invocation. 45 | .IP "int UPNP_GetIGDFromUrl(const char * rootdescurl, struct UPNPUrls * urls, struct IGDdatas * data, char * lanaddr, int lanaddrlen);" 46 | permit one to bypass the upnpDiscover() call if the xml root description 47 | URL of the UPnP IGD is known. 48 | Fill structures passed as arguments 49 | with data used for UPNP methods invocation. 50 | .IP "void GetUPNPUrls(struct UPNPUrls *, struct IGDdatas *, const char *);" 51 | .IP "void FreeUPNPUrls(struct UPNPUrls *);" 52 | 53 | .SH "SEE ALSO" 54 | minissdpd(1) 55 | .SH BUGS 56 | -------------------------------------------------------------------------------- /framework/miniupnpc/mingw32make.bat: -------------------------------------------------------------------------------- 1 | @mingw32-make -f Makefile.mingw %1 2 | @if errorlevel 1 goto end 3 | @if not exist upnpc-static.exe goto end 4 | @strip upnpc-static.exe 5 | @upx --best upnpc-static.exe 6 | @strip upnpc-shared.exe 7 | @upx --best upnpc-shared.exe 8 | :end 9 | -------------------------------------------------------------------------------- /framework/miniupnpc/minisoap.c: -------------------------------------------------------------------------------- 1 | /* $Id: minisoap.c,v 1.27 2018/04/06 10:53:13 nanard Exp $ */ 2 | /* vim: tabstop=4 shiftwidth=4 noexpandtab 3 | * Project : miniupnp 4 | * Author : Thomas Bernard 5 | * Copyright (c) 2005-2018 Thomas Bernard 6 | * This software is subject to the conditions detailed in the 7 | * LICENCE file provided in this distribution. 8 | * 9 | * Minimal SOAP implementation for UPnP protocol. 10 | */ 11 | #include 12 | #include 13 | #ifdef _WIN32 14 | #include 15 | #include 16 | #define snprintf _snprintf 17 | #else 18 | #include 19 | #include 20 | #include 21 | #endif 22 | #include "minisoap.h" 23 | #include "miniupnpcstrings.h" 24 | 25 | /* only for malloc */ 26 | #include 27 | 28 | #ifdef _WIN32 29 | #define PRINT_SOCKET_ERROR(x) fprintf(stderr, "Socket error: %s, %d\n", x, WSAGetLastError()); 30 | #else 31 | #define PRINT_SOCKET_ERROR(x) perror(x) 32 | #endif 33 | 34 | /* httpWrite sends the headers and the body to the socket 35 | * and returns the number of bytes sent */ 36 | static int 37 | httpWrite(SOCKET fd, const char * body, int bodysize, 38 | const char * headers, int headerssize) 39 | { 40 | int n = 0; 41 | /*n = write(fd, headers, headerssize);*/ 42 | /*if(bodysize>0) 43 | n += write(fd, body, bodysize);*/ 44 | /* Note : my old linksys router only took into account 45 | * soap request that are sent into only one packet */ 46 | char * p; 47 | /* TODO: AVOID MALLOC, we could use writev() for that */ 48 | p = malloc(headerssize+bodysize); 49 | if(!p) 50 | return -1; 51 | memcpy(p, headers, headerssize); 52 | memcpy(p+headerssize, body, bodysize); 53 | /*n = write(fd, p, headerssize+bodysize);*/ 54 | n = send(fd, p, headerssize+bodysize, 0); 55 | if(n<0) { 56 | PRINT_SOCKET_ERROR("send"); 57 | } 58 | /* disable send on the socket */ 59 | /* draytek routers don't seem to like that... */ 60 | #if 0 61 | #ifdef _WIN32 62 | if(shutdown(fd, SD_SEND)<0) { 63 | #else 64 | if(shutdown(fd, SHUT_WR)<0) { /*SD_SEND*/ 65 | #endif 66 | PRINT_SOCKET_ERROR("shutdown"); 67 | } 68 | #endif 69 | free(p); 70 | return n; 71 | } 72 | 73 | /* self explanatory */ 74 | int soapPostSubmit(SOCKET fd, 75 | const char * url, 76 | const char * host, 77 | unsigned short port, 78 | const char * action, 79 | const char * body, 80 | const char * httpversion) 81 | { 82 | int bodysize; 83 | char headerbuf[512]; 84 | int headerssize; 85 | char portstr[8]; 86 | bodysize = (int)strlen(body); 87 | /* We are not using keep-alive HTTP connections. 88 | * HTTP/1.1 needs the header Connection: close to do that. 89 | * This is the default with HTTP/1.0 90 | * Using HTTP/1.1 means we need to support chunked transfer-encoding : 91 | * When using HTTP/1.1, the router "BiPAC 7404VNOX" always use chunked 92 | * transfer encoding. */ 93 | /* Connection: Close is normally there only in HTTP/1.1 but who knows */ 94 | portstr[0] = '\0'; 95 | if(port != 80) 96 | snprintf(portstr, sizeof(portstr), ":%hu", port); 97 | headerssize = snprintf(headerbuf, sizeof(headerbuf), 98 | "POST %s HTTP/%s\r\n" 99 | "Host: %s%s\r\n" 100 | "User-Agent: " OS_STRING ", " UPNP_VERSION_STRING ", MiniUPnPc/" MINIUPNPC_VERSION_STRING "\r\n" 101 | "Content-Length: %d\r\n" 102 | "Content-Type: text/xml\r\n" 103 | "SOAPAction: \"%s\"\r\n" 104 | "Connection: Close\r\n" 105 | "Cache-Control: no-cache\r\n" /* ??? */ 106 | "Pragma: no-cache\r\n" 107 | "\r\n", 108 | url, httpversion, host, portstr, bodysize, action); 109 | if ((unsigned int)headerssize >= sizeof(headerbuf)) 110 | return -1; 111 | #ifdef DEBUG 112 | /*printf("SOAP request : headersize=%d bodysize=%d\n", 113 | headerssize, bodysize); 114 | */ 115 | printf("SOAP request : POST %s HTTP/%s - Host: %s%s\n", 116 | url, httpversion, host, portstr); 117 | printf("SOAPAction: \"%s\" - Content-Length: %d\n", action, bodysize); 118 | printf("Headers :\n%s", headerbuf); 119 | printf("Body :\n%s\n", body); 120 | #endif 121 | return httpWrite(fd, body, bodysize, headerbuf, headerssize); 122 | } 123 | 124 | 125 | -------------------------------------------------------------------------------- /framework/miniupnpc/minisoap.h: -------------------------------------------------------------------------------- 1 | /* $Id: minisoap.h,v 1.6 2018/04/06 10:53:13 nanard Exp $ */ 2 | /* Project : miniupnp 3 | * Author : Thomas Bernard 4 | * Copyright (c) 2005-2018 Thomas Bernard 5 | * This software is subject to the conditions detailed in the 6 | * LICENCE file provided in this distribution. */ 7 | #ifndef MINISOAP_H_INCLUDED 8 | #define MINISOAP_H_INCLUDED 9 | 10 | #include "miniupnpc_socketdef.h" 11 | 12 | /*int httpWrite(int, const char *, int, const char *);*/ 13 | int soapPostSubmit(SOCKET, const char *, const char *, unsigned short, 14 | const char *, const char *, const char *); 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /framework/miniupnpc/minissdpc.h: -------------------------------------------------------------------------------- 1 | /* $Id: minissdpc.h,v 1.7 2015/10/08 16:15:47 nanard Exp $ */ 2 | /* Project: miniupnp 3 | * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ 4 | * Author: Thomas Bernard 5 | * Copyright (c) 2005-2015 Thomas Bernard 6 | * This software is subjects to the conditions detailed 7 | * in the LICENCE file provided within this distribution */ 8 | #ifndef MINISSDPC_H_INCLUDED 9 | #define MINISSDPC_H_INCLUDED 10 | 11 | #include "miniupnpc_declspec.h" 12 | #include "upnpdev.h" 13 | 14 | /* error codes : */ 15 | #define MINISSDPC_SUCCESS (0) 16 | #define MINISSDPC_UNKNOWN_ERROR (-1) 17 | #define MINISSDPC_SOCKET_ERROR (-101) 18 | #define MINISSDPC_MEMORY_ERROR (-102) 19 | #define MINISSDPC_INVALID_INPUT (-103) 20 | #define MINISSDPC_INVALID_SERVER_REPLY (-104) 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | #if !(defined(_WIN32) || defined(__amigaos__) || defined(__amigaos4__)) 27 | 28 | MINIUPNP_LIBSPEC struct UPNPDev * 29 | getDevicesFromMiniSSDPD(const char * devtype, const char * socketpath, int * error); 30 | 31 | MINIUPNP_LIBSPEC int 32 | connectToMiniSSDPD(const char * socketpath); 33 | 34 | MINIUPNP_LIBSPEC int 35 | disconnectFromMiniSSDPD(int fd); 36 | 37 | MINIUPNP_LIBSPEC int 38 | requestDevicesFromMiniSSDPD(int fd, const char * devtype); 39 | 40 | MINIUPNP_LIBSPEC struct UPNPDev * 41 | receiveDevicesFromMiniSSDPD(int fd, int * error); 42 | 43 | #endif /* !(defined(_WIN32) || defined(__amigaos__) || defined(__amigaos4__)) */ 44 | 45 | MINIUPNP_LIBSPEC struct UPNPDev * 46 | ssdpDiscoverDevices(const char * const deviceTypes[], 47 | int delay, const char * multicastif, 48 | int localport, 49 | int ipv6, unsigned char ttl, 50 | int * error, 51 | int searchalltypes); 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | 57 | #endif 58 | 59 | -------------------------------------------------------------------------------- /framework/miniupnpc/miniupnpc.def: -------------------------------------------------------------------------------- 1 | LIBRARY 2 | ; miniupnpc library 3 | miniupnpc 4 | 5 | EXPORTS 6 | ; miniupnpc 7 | upnpDiscover 8 | freeUPNPDevlist 9 | parserootdesc 10 | UPNP_GetValidIGD 11 | UPNP_GetIGDFromUrl 12 | GetUPNPUrls 13 | FreeUPNPUrls 14 | ; miniwget 15 | miniwget 16 | miniwget_getaddr 17 | ; upnpcommands 18 | UPNP_GetTotalBytesSent 19 | UPNP_GetTotalBytesReceived 20 | UPNP_GetTotalPacketsSent 21 | UPNP_GetTotalPacketsReceived 22 | UPNP_GetStatusInfo 23 | UPNP_GetConnectionTypeInfo 24 | UPNP_GetExternalIPAddress 25 | UPNP_GetLinkLayerMaxBitRates 26 | UPNP_AddPortMapping 27 | UPNP_AddAnyPortMapping 28 | UPNP_DeletePortMapping 29 | UPNP_DeletePortMappingRange 30 | UPNP_GetPortMappingNumberOfEntries 31 | UPNP_GetSpecificPortMappingEntry 32 | UPNP_GetGenericPortMappingEntry 33 | UPNP_GetListOfPortMappings 34 | UPNP_AddPinhole 35 | UPNP_CheckPinholeWorking 36 | UPNP_UpdatePinhole 37 | UPNP_GetPinholePackets 38 | UPNP_DeletePinhole 39 | UPNP_GetFirewallStatus 40 | UPNP_GetOutboundPinholeTimeout 41 | ; upnperrors 42 | strupnperror 43 | ; portlistingparse 44 | ParsePortListing 45 | FreePortListing 46 | -------------------------------------------------------------------------------- /framework/miniupnpc/miniupnpc_declspec.h: -------------------------------------------------------------------------------- 1 | #ifndef MINIUPNPC_DECLSPEC_H_INCLUDED 2 | #define MINIUPNPC_DECLSPEC_H_INCLUDED 3 | 4 | #if defined(_WIN32) && !defined(MINIUPNP_STATICLIB) 5 | /* for windows dll */ 6 | #ifdef MINIUPNP_EXPORTS 7 | #define MINIUPNP_LIBSPEC __declspec(dllexport) 8 | #else 9 | #define MINIUPNP_LIBSPEC __declspec(dllimport) 10 | #endif 11 | #else 12 | #if defined(__GNUC__) && __GNUC__ >= 4 13 | /* fix dynlib for OS X 10.9.2 and Apple LLVM version 5.0 */ 14 | #define MINIUPNP_LIBSPEC __attribute__ ((visibility ("default"))) 15 | #else 16 | #define MINIUPNP_LIBSPEC 17 | #endif 18 | #endif 19 | 20 | #endif /* MINIUPNPC_DECLSPEC_H_INCLUDED */ 21 | 22 | -------------------------------------------------------------------------------- /framework/miniupnpc/miniupnpc_socketdef.h: -------------------------------------------------------------------------------- 1 | /* $Id: miniupnpc_socketdef.h,v 1.2 2018/04/06 10:53:14 nanard Exp $ */ 2 | /* Miniupnp project : http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/ 3 | * Author : Thomas Bernard 4 | * Copyright (c) 2018 Thomas Bernard 5 | * This software is subject to the conditions detailed in the 6 | * LICENCE file provided within this distribution */ 7 | #ifndef MINIUPNPC_SOCKETDEF_H_INCLUDED 8 | #define MINIUPNPC_SOCKETDEF_H_INCLUDED 9 | 10 | #ifdef _MSC_VER 11 | 12 | #define ISINVALID(s) (INVALID_SOCKET==(s)) 13 | 14 | #else 15 | 16 | #ifndef SOCKET 17 | #define SOCKET int 18 | #endif 19 | #ifndef SSIZE_T 20 | #define SSIZE_T ssize_t 21 | #endif 22 | #ifndef INVALID_SOCKET 23 | #define INVALID_SOCKET (-1) 24 | #endif 25 | #ifndef ISINVALID 26 | #define ISINVALID(s) ((s)<0) 27 | #endif 28 | 29 | #endif 30 | 31 | #ifdef _WIN32 32 | #define PRINT_SOCKET_ERROR(x) fprintf(stderr, "Socket error: %s, %d\n", x, WSAGetLastError()); 33 | #else 34 | #define PRINT_SOCKET_ERROR(x) perror(x) 35 | #endif 36 | 37 | #endif /* MINIUPNPC_SOCKETDEF_H_INCLUDED */ 38 | -------------------------------------------------------------------------------- /framework/miniupnpc/miniupnpcstrings.h: -------------------------------------------------------------------------------- 1 | /* $Id: miniupnpcstrings.h.in,v 1.6 2014/11/04 22:31:55 nanard Exp $ */ 2 | /* Project: miniupnp 3 | * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ 4 | * Author: Thomas Bernard 5 | * Copyright (c) 2005-2014 Thomas Bernard 6 | * This software is subjects to the conditions detailed 7 | * in the LICENCE file provided within this distribution */ 8 | #ifndef MINIUPNPCSTRINGS_H_INCLUDED 9 | #define MINIUPNPCSTRINGS_H_INCLUDED 10 | 11 | #define OS_STRING "Darwin/17.7.0" 12 | #define MINIUPNPC_VERSION_STRING "2.1" 13 | 14 | #if 0 15 | /* according to "UPnP Device Architecture 1.0" */ 16 | #define UPNP_VERSION_STRING "UPnP/1.0" 17 | #else 18 | /* according to "UPnP Device Architecture 1.1" */ 19 | #define UPNP_VERSION_STRING "UPnP/1.1" 20 | #endif 21 | 22 | #endif 23 | 24 | -------------------------------------------------------------------------------- /framework/miniupnpc/miniupnpcstrings.h.cmake: -------------------------------------------------------------------------------- 1 | #ifndef MINIUPNPCSTRINGS_H_INCLUDED 2 | #define MINIUPNPCSTRINGS_H_INCLUDED 3 | 4 | #define OS_STRING "${CMAKE_SYSTEM_NAME}" 5 | #define MINIUPNPC_VERSION_STRING "${MINIUPNPC_VERSION}" 6 | 7 | #if 0 8 | /* according to "UPnP Device Architecture 1.0" */ 9 | #define UPNP_VERSION_STRING "UPnP/1.0" 10 | #else 11 | /* according to "UPnP Device Architecture 1.1" */ 12 | #define UPNP_VERSION_STRING "UPnP/1.1" 13 | #endif 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /framework/miniupnpc/miniupnpcstrings.h.in: -------------------------------------------------------------------------------- 1 | /* $Id: miniupnpcstrings.h.in,v 1.6 2014/11/04 22:31:55 nanard Exp $ */ 2 | /* Project: miniupnp 3 | * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ 4 | * Author: Thomas Bernard 5 | * Copyright (c) 2005-2014 Thomas Bernard 6 | * This software is subjects to the conditions detailed 7 | * in the LICENCE file provided within this distribution */ 8 | #ifndef MINIUPNPCSTRINGS_H_INCLUDED 9 | #define MINIUPNPCSTRINGS_H_INCLUDED 10 | 11 | #define OS_STRING "OS/version" 12 | #define MINIUPNPC_VERSION_STRING "version" 13 | 14 | #if 0 15 | /* according to "UPnP Device Architecture 1.0" */ 16 | #define UPNP_VERSION_STRING "UPnP/1.0" 17 | #else 18 | /* according to "UPnP Device Architecture 1.1" */ 19 | #define UPNP_VERSION_STRING "UPnP/1.1" 20 | #endif 21 | 22 | #endif 23 | 24 | -------------------------------------------------------------------------------- /framework/miniupnpc/miniupnpctypes.h: -------------------------------------------------------------------------------- 1 | /* $Id: miniupnpctypes.h,v 1.2 2012/09/27 15:42:10 nanard Exp $ */ 2 | /* Miniupnp project : http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org 3 | * Author : Thomas Bernard 4 | * Copyright (c) 2011 Thomas Bernard 5 | * This software is subject to the conditions detailed in the 6 | * LICENCE file provided within this distribution */ 7 | #ifndef MINIUPNPCTYPES_H_INCLUDED 8 | #define MINIUPNPCTYPES_H_INCLUDED 9 | 10 | #if (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) 11 | #define UNSIGNED_INTEGER unsigned long long 12 | #define STRTOUI strtoull 13 | #else 14 | #define UNSIGNED_INTEGER unsigned int 15 | #define STRTOUI strtoul 16 | #endif 17 | 18 | #endif 19 | 20 | -------------------------------------------------------------------------------- /framework/miniupnpc/miniwget.h: -------------------------------------------------------------------------------- 1 | /* $Id: miniwget.h,v 1.13 2018/04/06 10:53:15 nanard Exp $ */ 2 | /* Project : miniupnp 3 | * Author : Thomas Bernard 4 | * Copyright (c) 2005-2016 Thomas Bernard 5 | * This software is subject to the conditions detailed in the 6 | * LICENCE file provided in this distribution. 7 | * */ 8 | #ifndef MINIWGET_H_INCLUDED 9 | #define MINIWGET_H_INCLUDED 10 | 11 | #include "miniupnpc_declspec.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | MINIUPNP_LIBSPEC void * miniwget(const char *, int *, unsigned int, int *); 18 | 19 | MINIUPNP_LIBSPEC void * miniwget_getaddr(const char *, int *, char *, int, unsigned int, int *); 20 | 21 | int parseURL(const char *, char *, unsigned short *, char * *, unsigned int *); 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /framework/miniupnpc/miniwget_private.h: -------------------------------------------------------------------------------- 1 | /* $Id: miniwget_private.h,v 1.1 2018/04/06 10:17:58 nanard Exp $ */ 2 | /* Project : miniupnp 3 | * Author : Thomas Bernard 4 | * Copyright (c) 2018 Thomas Bernard 5 | * This software is subject to the conditions detailed in the 6 | * LICENCE file provided in this distribution. 7 | * */ 8 | #ifndef MINIWGET_INTERNAL_H_INCLUDED 9 | #define MINIWGET_INTERNAL_H_INCLUDED 10 | 11 | #include "miniupnpc_socketdef.h" 12 | 13 | void * getHTTPResponse(SOCKET s, int * size, int * status_code); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /framework/miniupnpc/minixml.h: -------------------------------------------------------------------------------- 1 | /* $Id: minixml.h,v 1.7 2012/09/27 15:42:10 nanard Exp $ */ 2 | /* minimal xml parser 3 | * 4 | * Project : miniupnp 5 | * Website : http://miniupnp.free.fr/ 6 | * Author : Thomas Bernard 7 | * Copyright (c) 2005 Thomas Bernard 8 | * This software is subject to the conditions detailed in the 9 | * LICENCE file provided in this distribution. 10 | * */ 11 | #ifndef MINIXML_H_INCLUDED 12 | #define MINIXML_H_INCLUDED 13 | #define IS_WHITE_SPACE(c) ((c==' ') || (c=='\t') || (c=='\r') || (c=='\n')) 14 | 15 | /* if a callback function pointer is set to NULL, 16 | * the function is not called */ 17 | struct xmlparser { 18 | const char *xmlstart; 19 | const char *xmlend; 20 | const char *xml; /* pointer to current character */ 21 | int xmlsize; 22 | void * data; 23 | void (*starteltfunc) (void *, const char *, int); 24 | void (*endeltfunc) (void *, const char *, int); 25 | void (*datafunc) (void *, const char *, int); 26 | void (*attfunc) (void *, const char *, int, const char *, int); 27 | }; 28 | 29 | /* parsexml() 30 | * the xmlparser structure must be initialized before the call 31 | * the following structure members have to be initialized : 32 | * xmlstart, xmlsize, data, *func 33 | * xml is for internal usage, xmlend is computed automatically */ 34 | void parsexml(struct xmlparser *); 35 | 36 | #endif 37 | 38 | -------------------------------------------------------------------------------- /framework/miniupnpc/minixmlvalid.c: -------------------------------------------------------------------------------- 1 | /* $Id: minixmlvalid.c,v 1.7 2015/07/15 12:41:15 nanard Exp $ */ 2 | /* MiniUPnP Project 3 | * http://miniupnp.tuxfamily.org/ or http://miniupnp.free.fr/ 4 | * minixmlvalid.c : 5 | * validation program for the minixml parser 6 | * 7 | * (c) 2006-2011 Thomas Bernard */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include "minixml.h" 13 | 14 | /* xml event structure */ 15 | struct event { 16 | enum { ELTSTART, ELTEND, ATT, CHARDATA } type; 17 | const char * data; 18 | int len; 19 | }; 20 | 21 | struct eventlist { 22 | int n; 23 | struct event * events; 24 | }; 25 | 26 | /* compare 2 xml event lists 27 | * return 0 if the two lists are equals */ 28 | int evtlistcmp(struct eventlist * a, struct eventlist * b) 29 | { 30 | int i; 31 | struct event * ae, * be; 32 | if(a->n != b->n) 33 | { 34 | printf("event number not matching : %d != %d\n", a->n, b->n); 35 | /*return 1;*/ 36 | } 37 | for(i=0; in; i++) 38 | { 39 | ae = a->events + i; 40 | be = b->events + i; 41 | if( (ae->type != be->type) 42 | ||(ae->len != be->len) 43 | ||memcmp(ae->data, be->data, ae->len)) 44 | { 45 | printf("Found a difference : %d '%.*s' != %d '%.*s'\n", 46 | ae->type, ae->len, ae->data, 47 | be->type, be->len, be->data); 48 | return 1; 49 | } 50 | } 51 | return 0; 52 | } 53 | 54 | /* Test data */ 55 | static const char xmldata[] = 56 | "\n" 57 | " " 58 | "character data" 59 | " \n \t" 60 | "" 61 | "\nstuff !\n ]]> \n\n" 62 | " \tchardata1 chardata2 " 63 | ""; 64 | 65 | static const struct event evtref[] = 66 | { 67 | {ELTSTART, "xmlroot", 7}, 68 | {ELTSTART, "elt1", 4}, 69 | /* attributes */ 70 | {CHARDATA, "character data", 14}, 71 | {ELTEND, "elt1", 4}, 72 | {ELTSTART, "elt1b", 5}, 73 | {ELTSTART, "elt1", 4}, 74 | {CHARDATA, " stuff !\n ", 16}, 75 | {ELTEND, "elt1", 4}, 76 | {ELTSTART, "elt2a", 5}, 77 | {ELTSTART, "elt2b", 5}, 78 | {CHARDATA, "chardata1", 9}, 79 | {ELTEND, "elt2b", 5}, 80 | {ELTSTART, "elt2b", 5}, 81 | {CHARDATA, " chardata2 ", 11}, 82 | {ELTEND, "elt2b", 5}, 83 | {ELTEND, "elt2a", 5}, 84 | {ELTEND, "xmlroot", 7} 85 | }; 86 | 87 | void startelt(void * data, const char * p, int l) 88 | { 89 | struct eventlist * evtlist = data; 90 | struct event * evt; 91 | evt = evtlist->events + evtlist->n; 92 | /*printf("startelt : %.*s\n", l, p);*/ 93 | evt->type = ELTSTART; 94 | evt->data = p; 95 | evt->len = l; 96 | evtlist->n++; 97 | } 98 | 99 | void endelt(void * data, const char * p, int l) 100 | { 101 | struct eventlist * evtlist = data; 102 | struct event * evt; 103 | evt = evtlist->events + evtlist->n; 104 | /*printf("endelt : %.*s\n", l, p);*/ 105 | evt->type = ELTEND; 106 | evt->data = p; 107 | evt->len = l; 108 | evtlist->n++; 109 | } 110 | 111 | void chardata(void * data, const char * p, int l) 112 | { 113 | struct eventlist * evtlist = data; 114 | struct event * evt; 115 | evt = evtlist->events + evtlist->n; 116 | /*printf("chardata : '%.*s'\n", l, p);*/ 117 | evt->type = CHARDATA; 118 | evt->data = p; 119 | evt->len = l; 120 | evtlist->n++; 121 | } 122 | 123 | int testxmlparser(const char * xml, int size) 124 | { 125 | int r; 126 | struct eventlist evtlist; 127 | struct eventlist evtlistref; 128 | struct xmlparser parser; 129 | evtlist.n = 0; 130 | evtlist.events = malloc(sizeof(struct event)*100); 131 | if(evtlist.events == NULL) 132 | { 133 | fprintf(stderr, "Memory allocation error.\n"); 134 | return -1; 135 | } 136 | memset(&parser, 0, sizeof(parser)); 137 | parser.xmlstart = xml; 138 | parser.xmlsize = size; 139 | parser.data = &evtlist; 140 | parser.starteltfunc = startelt; 141 | parser.endeltfunc = endelt; 142 | parser.datafunc = chardata; 143 | parsexml(&parser); 144 | printf("%d events\n", evtlist.n); 145 | /* compare */ 146 | evtlistref.n = sizeof(evtref)/sizeof(struct event); 147 | evtlistref.events = (struct event *)evtref; 148 | r = evtlistcmp(&evtlistref, &evtlist); 149 | free(evtlist.events); 150 | return r; 151 | } 152 | 153 | int main(int argc, char * * argv) 154 | { 155 | int r; 156 | (void)argc; (void)argv; 157 | 158 | r = testxmlparser(xmldata, sizeof(xmldata)-1); 159 | if(r) 160 | printf("minixml validation test failed\n"); 161 | return r; 162 | } 163 | 164 | -------------------------------------------------------------------------------- /framework/miniupnpc/msvc/genminiupnpcstrings.vbs: -------------------------------------------------------------------------------- 1 | ' VBScript to generate miniupnpcstrings.h 2 | ' Copyright 2018 Thomas Bernard 3 | 'Set WshShell = CreateObject("WScript.Shell") 4 | Set FSO = CreateObject("Scripting.FileSystemObject") 5 | versionfile = "..\version" 6 | infile = "..\miniupnpcstrings.h.in" 7 | outfile = "..\miniupnpcstrings.h" 8 | 9 | On Error Resume Next 10 | 11 | 'Wscript.Echo revision 12 | 13 | Err.Clear 14 | Set f = FSO.OpenTextFile(versionfile, 1, False) ' 1 = Read 15 | If Err.Number = 0 Then 16 | version = f.ReadLine 17 | f.Close 18 | Else 19 | ' Exit error 20 | WScript.Quit 1 21 | End If 22 | 23 | os_version = "0.0.0" 24 | strComputer = "." 25 | Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 26 | Set colOperatingSystems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem") 27 | For Each objOperatingSystem in colOperatingSystems 28 | 'Wscript.Echo objOperatingSystem.Caption & " -- " 29 | os_version = objOperatingSystem.Version 30 | Next 31 | 32 | Dim array 33 | 34 | Set f_in = FSO.OpenTextFile(infile, 1, False) 35 | If Err.Number = 0 Then 36 | Set f_out = FSO.OpenTextFile(outfile, 2, True) ' 2 = Write 37 | Do Until f_in.AtEndOfStream 38 | line = f_in.ReadLine 39 | If Len(line) > 0 Then 40 | array = Split(line, " ") 41 | If UBound(array) >= 2 And array(0) = "#define" Then 42 | If array(1) = "OS_STRING" Then 43 | line = "#define OS_STRING " & Chr(34) & "MSWindows/" & os_version & Chr(34) 44 | ElseIf array(1) = "MINIUPNPC_VERSION_STRING" Then 45 | line = "#define MINIUPNPC_VERSION_STRING " & Chr(34) & version & Chr(34) 46 | End if 47 | End if 48 | End If 49 | f_out.WriteLine line 50 | Loop 51 | f_in.Close 52 | f_out.Close 53 | End If 54 | -------------------------------------------------------------------------------- /framework/miniupnpc/msvc/miniupnpc.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual C++ Express 2008 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniupnpc", "miniupnpc.vcproj", "{D28CE435-CB33-4BAE-8A52-C6EF915956F5}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "upnpc-static", "upnpc-static.vcproj", "{469E1CF6-08A2-4B7B-A2AA-5BDB089857C1}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {D28CE435-CB33-4BAE-8A52-C6EF915956F5} = {D28CE435-CB33-4BAE-8A52-C6EF915956F5} 9 | EndProjectSection 10 | EndProject 11 | Global 12 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 13 | Debug|Win32 = Debug|Win32 14 | Release|Win32 = Release|Win32 15 | EndGlobalSection 16 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 17 | {D28CE435-CB33-4BAE-8A52-C6EF915956F5}.Debug|Win32.ActiveCfg = Debug|Win32 18 | {D28CE435-CB33-4BAE-8A52-C6EF915956F5}.Debug|Win32.Build.0 = Debug|Win32 19 | {D28CE435-CB33-4BAE-8A52-C6EF915956F5}.Release|Win32.ActiveCfg = Release|Win32 20 | {D28CE435-CB33-4BAE-8A52-C6EF915956F5}.Release|Win32.Build.0 = Release|Win32 21 | {469E1CF6-08A2-4B7B-A2AA-5BDB089857C1}.Debug|Win32.ActiveCfg = Debug|Win32 22 | {469E1CF6-08A2-4B7B-A2AA-5BDB089857C1}.Debug|Win32.Build.0 = Debug|Win32 23 | {469E1CF6-08A2-4B7B-A2AA-5BDB089857C1}.Release|Win32.ActiveCfg = Release|Win32 24 | {469E1CF6-08A2-4B7B-A2AA-5BDB089857C1}.Release|Win32.Build.0 = Release|Win32 25 | EndGlobalSection 26 | GlobalSection(SolutionProperties) = preSolution 27 | HideSolutionNode = FALSE 28 | EndGlobalSection 29 | EndGlobal 30 | -------------------------------------------------------------------------------- /framework/miniupnpc/msvc/miniupnpc.vcproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monkeydom/TCMPortMapper/914d064d4e8d37c20be3e91260881bb5bcf8c455/framework/miniupnpc/msvc/miniupnpc.vcproj -------------------------------------------------------------------------------- /framework/miniupnpc/msvc/miniupnpc.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Fichiers sources 20 | 21 | 22 | Fichiers sources 23 | 24 | 25 | Fichiers sources 26 | 27 | 28 | Fichiers sources 29 | 30 | 31 | Fichiers sources 32 | 33 | 34 | Fichiers sources 35 | 36 | 37 | Fichiers sources 38 | 39 | 40 | Fichiers sources 41 | 42 | 43 | Fichiers sources 44 | 45 | 46 | Fichiers sources 47 | 48 | 49 | Fichiers sources 50 | 51 | 52 | Fichiers sources 53 | 54 | 55 | Fichiers sources 56 | 57 | 58 | 59 | 60 | Fichiers d%27en-tête 61 | 62 | 63 | Fichiers d%27en-tête 64 | 65 | 66 | Fichiers d%27en-tête 67 | 68 | 69 | Fichiers d%27en-tête 70 | 71 | 72 | Fichiers d%27en-tête 73 | 74 | 75 | Fichiers d%27en-tête 76 | 77 | 78 | Fichiers d%27en-tête 79 | 80 | 81 | Fichiers d%27en-tête 82 | 83 | 84 | Fichiers d%27en-tête 85 | 86 | 87 | Fichiers d%27en-tête 88 | 89 | 90 | Fichiers d%27en-tête 91 | 92 | 93 | Fichiers d%27en-tête 94 | 95 | 96 | Fichiers d%27en-tête 97 | 98 | 99 | Fichiers d%27en-tête 100 | 101 | 102 | Fichiers d%27en-tête 103 | 104 | 105 | Fichiers d%27en-tête 106 | 107 | 108 | -------------------------------------------------------------------------------- /framework/miniupnpc/msvc/miniupnpc_vs2010.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual C++ Express 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniupnpc", "miniupnpc_vs2010.vcxproj", "{D28CE435-CB33-4BAE-8A52-C6EF915956F5}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "upnpc-static", "upnpc-static_vs2010.vcxproj", "{469E1CF6-08A2-4B7B-A2AA-5BDB089857C1}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {D28CE435-CB33-4BAE-8A52-C6EF915956F5}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {D28CE435-CB33-4BAE-8A52-C6EF915956F5}.Debug|Win32.Build.0 = Debug|Win32 16 | {D28CE435-CB33-4BAE-8A52-C6EF915956F5}.Release|Win32.ActiveCfg = Release|Win32 17 | {D28CE435-CB33-4BAE-8A52-C6EF915956F5}.Release|Win32.Build.0 = Release|Win32 18 | {469E1CF6-08A2-4B7B-A2AA-5BDB089857C1}.Debug|Win32.ActiveCfg = Debug|Win32 19 | {469E1CF6-08A2-4B7B-A2AA-5BDB089857C1}.Debug|Win32.Build.0 = Debug|Win32 20 | {469E1CF6-08A2-4B7B-A2AA-5BDB089857C1}.Release|Win32.ActiveCfg = Release|Win32 21 | {469E1CF6-08A2-4B7B-A2AA-5BDB089857C1}.Release|Win32.Build.0 = Release|Win32 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /framework/miniupnpc/msvc/miniupnpc_vs2010.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | sources 6 | 7 | 8 | sources 9 | 10 | 11 | sources 12 | 13 | 14 | sources 15 | 16 | 17 | sources 18 | 19 | 20 | sources 21 | 22 | 23 | sources 24 | 25 | 26 | sources 27 | 28 | 29 | sources 30 | 31 | 32 | sources 33 | 34 | 35 | sources 36 | 37 | 38 | sources 39 | 40 | 41 | sources 42 | 43 | 44 | 45 | 46 | headers 47 | 48 | 49 | headers 50 | 51 | 52 | headers 53 | 54 | 55 | headers 56 | 57 | 58 | headers 59 | 60 | 61 | headers 62 | 63 | 64 | headers 65 | 66 | 67 | headers 68 | 69 | 70 | headers 71 | 72 | 73 | headers 74 | 75 | 76 | headers 77 | 78 | 79 | headers 80 | 81 | 82 | headers 83 | 84 | 85 | headers 86 | 87 | 88 | headers 89 | 90 | 91 | headers 92 | 93 | 94 | headers 95 | 96 | 97 | headers 98 | 99 | 100 | headers 101 | 102 | 103 | 104 | 105 | {f2cbd46b-f63f-412e-80e5-b7c9048a1add} 106 | 107 | 108 | {2b3996de-1bc4-418b-8a83-a5f34fdf0df5} 109 | 110 | 111 | -------------------------------------------------------------------------------- /framework/miniupnpc/msvc/miniupnpc_vs2015.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25123.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniupnpc", "miniupnpc.vcxproj", "{D28CE435-CB33-4BAE-8A52-C6EF915956F5}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "upnpc-static", "upnpc-static.vcxproj", "{469E1CF6-08A2-4B7B-A2AA-5BDB089857C1}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Win32 = Debug|Win32 13 | Release|Win32 = Release|Win32 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {D28CE435-CB33-4BAE-8A52-C6EF915956F5}.Debug|Win32.ActiveCfg = Debug|Win32 17 | {D28CE435-CB33-4BAE-8A52-C6EF915956F5}.Debug|Win32.Build.0 = Debug|Win32 18 | {D28CE435-CB33-4BAE-8A52-C6EF915956F5}.Release|Win32.ActiveCfg = Release|Win32 19 | {D28CE435-CB33-4BAE-8A52-C6EF915956F5}.Release|Win32.Build.0 = Release|Win32 20 | {469E1CF6-08A2-4B7B-A2AA-5BDB089857C1}.Debug|Win32.ActiveCfg = Debug|Win32 21 | {469E1CF6-08A2-4B7B-A2AA-5BDB089857C1}.Debug|Win32.Build.0 = Debug|Win32 22 | {469E1CF6-08A2-4B7B-A2AA-5BDB089857C1}.Release|Win32.ActiveCfg = Release|Win32 23 | {469E1CF6-08A2-4B7B-A2AA-5BDB089857C1}.Release|Win32.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /framework/miniupnpc/msvc/upnpc-static.vcproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monkeydom/TCMPortMapper/914d064d4e8d37c20be3e91260881bb5bcf8c455/framework/miniupnpc/msvc/upnpc-static.vcproj -------------------------------------------------------------------------------- /framework/miniupnpc/msvc/upnpc-static.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Fichiers sources 20 | 21 | 22 | -------------------------------------------------------------------------------- /framework/miniupnpc/portlistingparse.c: -------------------------------------------------------------------------------- 1 | /* $Id: portlistingparse.c,v 1.10 2016/12/16 08:53:21 nanard Exp $ */ 2 | /* MiniUPnP project 3 | * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ 4 | * (c) 2011-2016 Thomas Bernard 5 | * This software is subject to the conditions detailed 6 | * in the LICENCE file provided within the distribution */ 7 | #include 8 | #include 9 | #ifdef DEBUG 10 | #include 11 | #endif /* DEBUG */ 12 | #include "portlistingparse.h" 13 | #include "minixml.h" 14 | 15 | /* list of the elements */ 16 | static const struct { 17 | const portMappingElt code; 18 | const char * const str; 19 | } elements[] = { 20 | { PortMappingEntry, "PortMappingEntry"}, 21 | { NewRemoteHost, "NewRemoteHost"}, 22 | { NewExternalPort, "NewExternalPort"}, 23 | { NewProtocol, "NewProtocol"}, 24 | { NewInternalPort, "NewInternalPort"}, 25 | { NewInternalClient, "NewInternalClient"}, 26 | { NewEnabled, "NewEnabled"}, 27 | { NewDescription, "NewDescription"}, 28 | { NewLeaseTime, "NewLeaseTime"}, 29 | { PortMappingEltNone, NULL} 30 | }; 31 | 32 | /* Helper function */ 33 | static UNSIGNED_INTEGER 34 | atoui(const char * p, int l) 35 | { 36 | UNSIGNED_INTEGER r = 0; 37 | while(l > 0 && *p) 38 | { 39 | if(*p >= '0' && *p <= '9') 40 | r = r*10 + (*p - '0'); 41 | else 42 | break; 43 | p++; 44 | l--; 45 | } 46 | return r; 47 | } 48 | 49 | /* Start element handler */ 50 | static void 51 | startelt(void * d, const char * name, int l) 52 | { 53 | int i; 54 | struct PortMappingParserData * pdata = (struct PortMappingParserData *)d; 55 | pdata->curelt = PortMappingEltNone; 56 | for(i = 0; elements[i].str; i++) 57 | { 58 | if(strlen(elements[i].str) == (size_t)l && memcmp(name, elements[i].str, l) == 0) 59 | { 60 | pdata->curelt = elements[i].code; 61 | break; 62 | } 63 | } 64 | if(pdata->curelt == PortMappingEntry) 65 | { 66 | struct PortMapping * pm; 67 | pm = calloc(1, sizeof(struct PortMapping)); 68 | if(pm == NULL) 69 | { 70 | /* malloc error */ 71 | #ifdef DEBUG 72 | fprintf(stderr, "%s: error allocating memory", 73 | "startelt"); 74 | #endif /* DEBUG */ 75 | return; 76 | } 77 | pm->l_next = pdata->l_head; /* insert in list */ 78 | pdata->l_head = pm; 79 | } 80 | } 81 | 82 | /* End element handler */ 83 | static void 84 | endelt(void * d, const char * name, int l) 85 | { 86 | struct PortMappingParserData * pdata = (struct PortMappingParserData *)d; 87 | (void)name; 88 | (void)l; 89 | pdata->curelt = PortMappingEltNone; 90 | } 91 | 92 | /* Data handler */ 93 | static void 94 | data(void * d, const char * data, int l) 95 | { 96 | struct PortMapping * pm; 97 | struct PortMappingParserData * pdata = (struct PortMappingParserData *)d; 98 | pm = pdata->l_head; 99 | if(!pm) 100 | return; 101 | if(l > 63) 102 | l = 63; 103 | switch(pdata->curelt) 104 | { 105 | case NewRemoteHost: 106 | memcpy(pm->remoteHost, data, l); 107 | pm->remoteHost[l] = '\0'; 108 | break; 109 | case NewExternalPort: 110 | pm->externalPort = (unsigned short)atoui(data, l); 111 | break; 112 | case NewProtocol: 113 | if(l > 3) 114 | l = 3; 115 | memcpy(pm->protocol, data, l); 116 | pm->protocol[l] = '\0'; 117 | break; 118 | case NewInternalPort: 119 | pm->internalPort = (unsigned short)atoui(data, l); 120 | break; 121 | case NewInternalClient: 122 | memcpy(pm->internalClient, data, l); 123 | pm->internalClient[l] = '\0'; 124 | break; 125 | case NewEnabled: 126 | pm->enabled = (unsigned char)atoui(data, l); 127 | break; 128 | case NewDescription: 129 | memcpy(pm->description, data, l); 130 | pm->description[l] = '\0'; 131 | break; 132 | case NewLeaseTime: 133 | pm->leaseTime = atoui(data, l); 134 | break; 135 | default: 136 | break; 137 | } 138 | } 139 | 140 | 141 | /* Parse the PortMappingList XML document for IGD version 2 142 | */ 143 | void 144 | ParsePortListing(const char * buffer, int bufsize, 145 | struct PortMappingParserData * pdata) 146 | { 147 | struct xmlparser parser; 148 | 149 | memset(pdata, 0, sizeof(struct PortMappingParserData)); 150 | /* init xmlparser */ 151 | parser.xmlstart = buffer; 152 | parser.xmlsize = bufsize; 153 | parser.data = pdata; 154 | parser.starteltfunc = startelt; 155 | parser.endeltfunc = endelt; 156 | parser.datafunc = data; 157 | parser.attfunc = 0; 158 | parsexml(&parser); 159 | } 160 | 161 | void 162 | FreePortListing(struct PortMappingParserData * pdata) 163 | { 164 | struct PortMapping * pm; 165 | while((pm = pdata->l_head) != NULL) 166 | { 167 | /* remove from list */ 168 | pdata->l_head = pm->l_next; 169 | free(pm); 170 | } 171 | } 172 | 173 | -------------------------------------------------------------------------------- /framework/miniupnpc/portlistingparse.h: -------------------------------------------------------------------------------- 1 | /* $Id: portlistingparse.h,v 1.11 2015/07/21 13:16:55 nanard Exp $ */ 2 | /* MiniUPnP project 3 | * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ 4 | * (c) 2011-2015 Thomas Bernard 5 | * This software is subject to the conditions detailed 6 | * in the LICENCE file provided within the distribution */ 7 | #ifndef PORTLISTINGPARSE_H_INCLUDED 8 | #define PORTLISTINGPARSE_H_INCLUDED 9 | 10 | #include "miniupnpc_declspec.h" 11 | /* for the definition of UNSIGNED_INTEGER */ 12 | #include "miniupnpctypes.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | /* sample of PortMappingEntry : 19 | 20 | 202.233.2.1 21 | 2345 22 | TCP 23 | 2345 24 | 192.168.1.137 25 | 1 26 | dooom 27 | 345 28 | 29 | */ 30 | typedef enum { PortMappingEltNone, 31 | PortMappingEntry, NewRemoteHost, 32 | NewExternalPort, NewProtocol, 33 | NewInternalPort, NewInternalClient, 34 | NewEnabled, NewDescription, 35 | NewLeaseTime } portMappingElt; 36 | 37 | struct PortMapping { 38 | struct PortMapping * l_next; /* list next element */ 39 | UNSIGNED_INTEGER leaseTime; 40 | unsigned short externalPort; 41 | unsigned short internalPort; 42 | char remoteHost[64]; 43 | char internalClient[64]; 44 | char description[64]; 45 | char protocol[4]; 46 | unsigned char enabled; 47 | }; 48 | 49 | struct PortMappingParserData { 50 | struct PortMapping * l_head; /* list head */ 51 | portMappingElt curelt; 52 | }; 53 | 54 | MINIUPNP_LIBSPEC void 55 | ParsePortListing(const char * buffer, int bufsize, 56 | struct PortMappingParserData * pdata); 57 | 58 | MINIUPNP_LIBSPEC void 59 | FreePortListing(struct PortMappingParserData * pdata); 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /framework/miniupnpc/pymoduletest.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/python 2 | # vim: tabstop=2 shiftwidth=2 expandtab 3 | # MiniUPnP project 4 | # Author : Thomas Bernard 5 | # This Sample code is public domain. 6 | # website : https://miniupnp.tuxfamily.org/ 7 | 8 | # import the python miniupnpc module 9 | import miniupnpc 10 | import sys 11 | 12 | try: 13 | import argparse 14 | parser = argparse.ArgumentParser() 15 | parser.add_argument('-m', '--multicastif') 16 | parser.add_argument('-p', '--minissdpdsocket') 17 | parser.add_argument('-d', '--discoverdelay', type=int, default=200) 18 | parser.add_argument('-z', '--localport', type=int, default=0) 19 | # create the object 20 | u = miniupnpc.UPnP(**vars(parser.parse_args())) 21 | except: 22 | print 'argparse not available' 23 | i = 1 24 | multicastif = None 25 | minissdpdsocket = None 26 | discoverdelay = 200 27 | localport = 0 28 | while i < len(sys.argv): 29 | print sys.argv[i] 30 | if sys.argv[i] == '-m' or sys.argv[i] == '--multicastif': 31 | multicastif = sys.argv[i+1] 32 | elif sys.argv[i] == '-p' or sys.argv[i] == '--minissdpdsocket': 33 | minissdpdsocket = sys.argv[i+1] 34 | elif sys.argv[i] == '-d' or sys.argv[i] == '--discoverdelay': 35 | discoverdelay = int(sys.argv[i+1]) 36 | elif sys.argv[i] == '-z' or sys.argv[i] == '--localport': 37 | localport = int(sys.argv[i+1]) 38 | else: 39 | raise Exception('invalid argument %s' % sys.argv[i]) 40 | i += 2 41 | # create the object 42 | u = miniupnpc.UPnP(multicastif, minissdpdsocket, discoverdelay, localport) 43 | 44 | print 'inital(default) values :' 45 | print ' discoverdelay', u.discoverdelay 46 | print ' lanaddr', u.lanaddr 47 | print ' multicastif', u.multicastif 48 | print ' minissdpdsocket', u.minissdpdsocket 49 | #u.minissdpdsocket = '../minissdpd/minissdpd.sock' 50 | # discovery process, it usually takes several seconds (2 seconds or more) 51 | print 'Discovering... delay=%ums' % u.discoverdelay 52 | print u.discover(), 'device(s) detected' 53 | # select an igd 54 | try: 55 | u.selectigd() 56 | except Exception, e: 57 | print 'Exception :', e 58 | sys.exit(1) 59 | # display information about the IGD and the internet connection 60 | print 'local ip address :', u.lanaddr 61 | print 'external ip address :', u.externalipaddress() 62 | print u.statusinfo(), u.connectiontype() 63 | print 'total bytes : sent', u.totalbytesent(), 'received', u.totalbytereceived() 64 | print 'total packets : sent', u.totalpacketsent(), 'received', u.totalpacketreceived() 65 | 66 | #print u.addportmapping(64000, 'TCP', 67 | # '192.168.1.166', 63000, 'port mapping test', '') 68 | #print u.deleteportmapping(64000, 'TCP') 69 | 70 | port = 0 71 | proto = 'UDP' 72 | # list the redirections : 73 | i = 0 74 | while True: 75 | p = u.getgenericportmapping(i) 76 | if p==None: 77 | break 78 | print i, p 79 | (port, proto, (ihost,iport), desc, c, d, e) = p 80 | #print port, desc 81 | i = i + 1 82 | 83 | print u.getspecificportmapping(port, proto) 84 | try: 85 | print u.getportmappingnumberofentries() 86 | except Exception, e: 87 | print 'GetPortMappingNumberOfEntries() is not supported :', e 88 | 89 | -------------------------------------------------------------------------------- /framework/miniupnpc/receivedata.c: -------------------------------------------------------------------------------- 1 | /* $Id: receivedata.c,v 1.9 2018/04/06 10:53:15 nanard Exp $ */ 2 | /* Project : miniupnp 3 | * Website : http://miniupnp.free.fr/ 4 | * Author : Thomas Bernard 5 | * Copyright (c) 2011-2014 Thomas Bernard 6 | * This software is subject to the conditions detailed in the 7 | * LICENCE file provided in this distribution. */ 8 | 9 | #include 10 | #include 11 | #ifdef _WIN32 12 | #include 13 | #include 14 | #else /* _WIN32 */ 15 | #include 16 | #if defined(__amigaos__) && !defined(__amigaos4__) 17 | #define socklen_t int 18 | #else /* #if defined(__amigaos__) && !defined(__amigaos4__) */ 19 | #include 20 | #endif /* #else defined(__amigaos__) && !defined(__amigaos4__) */ 21 | #include 22 | #include 23 | #if !defined(__amigaos__) && !defined(__amigaos4__) 24 | #include 25 | #endif /* !defined(__amigaos__) && !defined(__amigaos4__) */ 26 | #include 27 | #define MINIUPNPC_IGNORE_EINTR 28 | #endif /* _WIN32 */ 29 | 30 | #include "receivedata.h" 31 | 32 | int 33 | receivedata(SOCKET socket, 34 | char * data, int length, 35 | int timeout, unsigned int * scope_id) 36 | { 37 | #ifdef MINIUPNPC_GET_SRC_ADDR 38 | struct sockaddr_storage src_addr; 39 | socklen_t src_addr_len = sizeof(src_addr); 40 | #endif /* MINIUPNPC_GET_SRC_ADDR */ 41 | int n; 42 | #if !defined(_WIN32) && !defined(__amigaos__) && !defined(__amigaos4__) 43 | /* using poll */ 44 | struct pollfd fds[1]; /* for the poll */ 45 | #ifdef MINIUPNPC_IGNORE_EINTR 46 | do { 47 | #endif /* MINIUPNPC_IGNORE_EINTR */ 48 | fds[0].fd = socket; 49 | fds[0].events = POLLIN; 50 | n = poll(fds, 1, timeout); 51 | #ifdef MINIUPNPC_IGNORE_EINTR 52 | } while(n < 0 && errno == EINTR); 53 | #endif /* MINIUPNPC_IGNORE_EINTR */ 54 | if(n < 0) { 55 | PRINT_SOCKET_ERROR("poll"); 56 | return -1; 57 | } else if(n == 0) { 58 | /* timeout */ 59 | return 0; 60 | } 61 | #else /* !defined(_WIN32) && !defined(__amigaos__) && !defined(__amigaos4__) */ 62 | /* using select under _WIN32 and amigaos */ 63 | fd_set socketSet; 64 | TIMEVAL timeval; 65 | FD_ZERO(&socketSet); 66 | FD_SET(socket, &socketSet); 67 | timeval.tv_sec = timeout / 1000; 68 | timeval.tv_usec = (timeout % 1000) * 1000; 69 | n = select(FD_SETSIZE, &socketSet, NULL, NULL, &timeval); 70 | if(n < 0) { 71 | PRINT_SOCKET_ERROR("select"); 72 | return -1; 73 | } else if(n == 0) { 74 | return 0; 75 | } 76 | #endif /* !defined(_WIN32) && !defined(__amigaos__) && !defined(__amigaos4__) */ 77 | #ifdef MINIUPNPC_GET_SRC_ADDR 78 | memset(&src_addr, 0, sizeof(src_addr)); 79 | n = recvfrom(socket, data, length, 0, 80 | (struct sockaddr *)&src_addr, &src_addr_len); 81 | #else /* MINIUPNPC_GET_SRC_ADDR */ 82 | n = recv(socket, data, length, 0); 83 | #endif /* MINIUPNPC_GET_SRC_ADDR */ 84 | if(n<0) { 85 | PRINT_SOCKET_ERROR("recv"); 86 | } 87 | #ifdef MINIUPNPC_GET_SRC_ADDR 88 | if (src_addr.ss_family == AF_INET6) { 89 | const struct sockaddr_in6 * src_addr6 = (struct sockaddr_in6 *)&src_addr; 90 | #ifdef DEBUG 91 | printf("scope_id=%u\n", src_addr6->sin6_scope_id); 92 | #endif /* DEBUG */ 93 | if(scope_id) 94 | *scope_id = src_addr6->sin6_scope_id; 95 | } 96 | #endif /* MINIUPNPC_GET_SRC_ADDR */ 97 | return n; 98 | } 99 | 100 | -------------------------------------------------------------------------------- /framework/miniupnpc/receivedata.h: -------------------------------------------------------------------------------- 1 | /* $Id: receivedata.h,v 1.5 2018/04/06 10:53:15 nanard Exp $ */ 2 | /* Project: miniupnp 3 | * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ 4 | * Author: Thomas Bernard 5 | * Copyright (c) 2011-2018 Thomas Bernard 6 | * This software is subjects to the conditions detailed 7 | * in the LICENCE file provided within this distribution */ 8 | #ifndef RECEIVEDATA_H_INCLUDED 9 | #define RECEIVEDATA_H_INCLUDED 10 | 11 | #include "miniupnpc_socketdef.h" 12 | 13 | /* Reads data from the specified socket. 14 | * Returns the number of bytes read if successful, zero if no bytes were 15 | * read or if we timed out. Returns negative if there was an error. */ 16 | int receivedata(SOCKET socket, 17 | char * data, int length, 18 | int timeout, unsigned int * scope_id); 19 | 20 | #endif 21 | 22 | -------------------------------------------------------------------------------- /framework/miniupnpc/setup.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/python 2 | # vim: tabstop=8 shiftwidth=8 expandtab 3 | # $Id: setup.py,v 1.13 2017/11/02 15:36:12 nanard Exp $ 4 | # the MiniUPnP Project (c) 2007-2017 Thomas Bernard 5 | # http://miniupnp.tuxfamily.org/ or http://miniupnp.free.fr/ 6 | # 7 | # python script to build the miniupnpc module under unix 8 | # 9 | # Uses MAKE environment variable (defaulting to 'make') 10 | 11 | from setuptools import setup, Extension 12 | from setuptools.command import build_ext 13 | import subprocess 14 | import os 15 | 16 | EXT = ['libminiupnpc.a'] 17 | 18 | class make_then_build_ext(build_ext.build_ext): 19 | def run(self): 20 | subprocess.check_call([os.environ.get('MAKE', 'make')] + EXT) 21 | build_ext.build_ext.run(self) 22 | 23 | setup(name="miniupnpc", 24 | version=open('VERSION').read().strip(), 25 | author='Thomas BERNARD', 26 | author_email='miniupnp@free.fr', 27 | license=open('LICENSE').read(), 28 | url='http://miniupnp.free.fr/', 29 | description='miniUPnP client', 30 | cmdclass={'build_ext': make_then_build_ext}, 31 | ext_modules=[ 32 | Extension(name="miniupnpc", sources=["miniupnpcmodule.c"], 33 | extra_objects=EXT) 34 | ]) 35 | 36 | -------------------------------------------------------------------------------- /framework/miniupnpc/setupmingw32.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/python 2 | # vim: tabstop=8 shiftwidth=8 expandtab 3 | # $Id: setupmingw32.py,v 1.10 2015/10/26 17:03:17 nanard Exp $ 4 | # the MiniUPnP Project (c) 2007-2014 Thomas Bernard 5 | # http://miniupnp.tuxfamily.org/ or http://miniupnp.free.fr/ 6 | # 7 | # python script to build the miniupnpc module under windows (using mingw32) 8 | # 9 | try: 10 | from setuptools import setup, Extension 11 | except ImportError: 12 | from distutils.core import setup, Extension 13 | from distutils import sysconfig 14 | sysconfig.get_config_vars()["OPT"] = '' 15 | sysconfig.get_config_vars()["CFLAGS"] = '' 16 | setup(name="miniupnpc", 17 | version=open('VERSION').read().strip(), 18 | author='Thomas BERNARD', 19 | author_email='miniupnp@free.fr', 20 | license=open('LICENSE').read(), 21 | url='http://miniupnp.free.fr/', 22 | description='miniUPnP client', 23 | ext_modules=[ 24 | Extension(name="miniupnpc", sources=["miniupnpcmodule.c"], 25 | libraries=["ws2_32", "iphlpapi"], 26 | extra_objects=["libminiupnpc.a"]) 27 | ]) 28 | 29 | -------------------------------------------------------------------------------- /framework/miniupnpc/testdesc/linksys_WAG200G_desc.values: -------------------------------------------------------------------------------- 1 | # values for linksys_WAG200G_desc.xml 2 | 3 | CIF: 4 | servicetype = urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1 5 | controlurl = /upnp/control/WANCommonIFC1 6 | eventsuburl = /upnp/event/WANCommonIFC1 7 | scpdurl = /cmnicfg.xml 8 | 9 | first: 10 | servicetype = urn:schemas-upnp-org:service:WANPPPConnection:1 11 | controlurl = /upnp/control/WANPPPConn1 12 | eventsuburl = /upnp/event/WANPPPConn1 13 | scpdurl = /pppcfg.xml 14 | 15 | -------------------------------------------------------------------------------- /framework/miniupnpc/testdesc/linksys_WAG200G_desc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1 5 | 0 6 | 7 | http://192.168.1.1:49152 8 | 9 | urn:schemas-upnp-org:device:InternetGatewayDevice:1 10 | LINKSYS WAG200G Gateway 11 | LINKSYS 12 | http://www.linksys.com 13 | LINKSYS WAG200G Gateway 14 | Wireless-G ADSL Home Gateway 15 | WAG200G 16 | http://www.linksys.com 17 | 123456789 18 | uuid:8ca2eb37-1dd2-11b2-86f1-001a709b5aa8 19 | WAG200G 20 | 21 | 22 | urn:schemas-upnp-org:service:Layer3Forwarding:1 23 | urn:upnp-org:serviceId:L3Forwarding1 24 | /upnp/control/L3Forwarding1 25 | /upnp/event/L3Forwarding1 26 | /l3frwd.xml 27 | 28 | 29 | 30 | 31 | urn:schemas-upnp-org:device:WANDevice:1 32 | WANDevice 33 | LINKSYS 34 | http://www.linksys.com/ 35 | Residential Gateway 36 | Internet Connection Sharing 37 | 1 38 | http://www.linksys.com/ 39 | 0000001 40 | uuid:8ca2eb36-1dd2-11b2-86f1-001a709b5aa8 41 | WAG200G 42 | 43 | 44 | urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1 45 | urn:upnp-org:serviceId:WANCommonIFC1 46 | /upnp/control/WANCommonIFC1 47 | /upnp/event/WANCommonIFC1 48 | /cmnicfg.xml 49 | 50 | 51 | 52 | 53 | urn:schemas-upnp-org:device:WANConnectionDevice:1 54 | WANConnectionDevice 55 | LINKSYS 56 | http://www.linksys.com/ 57 | Residential Gateway 58 | Internet Connection Sharing 59 | 1 60 | http://www.linksys.com/ 61 | 0000001 62 | uuid:8ca2eb37-1dd2-11b2-86f0-001a709b5aa8 63 | WAG200G 64 | 65 | 66 | urn:schemas-upnp-org:service:WANEthernetLinkConfig:1 67 | urn:upnp-org:serviceId:WANEthLinkC1 68 | /upnp/control/WANEthLinkC1 69 | /upnp/event/WANEthLinkC1 70 | /wanelcfg.xml 71 | 72 | 73 | urn:schemas-upnp-org:service:WANPPPConnection:1 74 | urn:upnp-org:serviceId:WANPPPConn1 75 | /upnp/control/WANPPPConn1 76 | /upnp/event/WANPPPConn1 77 | /pppcfg.xml 78 | 79 | 80 | 81 | 82 | 83 | 84 | urn:schemas-upnp-org:device:LANDevice:1 85 | LANDevice 86 | LINKSYS 87 | http://www.linksys.com/ 88 | Residential Gateway 89 | Residential Gateway 90 | 1 91 | http://www.linksys.com/ 92 | 0000001 93 | uuid:8ca2eb36-1dd2-11b2-86f0-001a709b5aa 94 | 8 95 | WAG200G 96 | 97 | 98 | urn:schemas-upnp-org:service:LANHostConfigManagement:1 99 | urn:upnp-org:serviceId:LANHostCfg1 100 | /upnp/control/LANHostCfg1 101 | /upnp/event/LANHostCfg1 102 | /lanhostc.xml 103 | 104 | 105 | 106 | 107 | http://192.168.1.1/index.htm 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /framework/miniupnpc/testdesc/new_LiveBox_desc.values: -------------------------------------------------------------------------------- 1 | # values for new_LiveBox_desc.xml 2 | 3 | CIF: 4 | servicetype = urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1 5 | controlurl = /87895a19/upnp/control/WANCommonIFC1 6 | eventsuburl = /87895a19/upnp/control/WANCommonIFC1 7 | scpdurl = /87895a19/gateicfgSCPD.xml 8 | 9 | first: 10 | servicetype = urn:schemas-upnp-org:service:WANPPPConnection:2 11 | controlurl = /87895a19/upnp/control/WANIPConn1 12 | eventsuburl = /87895a19/upnp/control/WANIPConn1 13 | scpdurl = /87895a19/gateconnSCPD_PPP.xml 14 | 15 | IPv6FC: 16 | servicetype = urn:schemas-upnp-org:service:WANIPv6FirewallControl:1 17 | controlurl = /87895a19/upnp/control/WANIPv6FwCtrl1 18 | eventsuburl = /87895a19/upnp/control/WANIPv6FwCtrl1 19 | scpdurl = /87895a19/wanipv6fwctrlSCPD.xml 20 | 21 | -------------------------------------------------------------------------------- /framework/miniupnpc/testdesc/new_LiveBox_desc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1 5 | 0 6 | 7 | 8 | VEN_0129&DEV_0000&SUBSYS_03&REV_250417 9 | GenericUmPass 10 | NetworkInfrastructure.Gateway 11 | Network.Gateway 12 | urn:schemas-upnp-org:device:InternetGatewayDevice:2 13 | Orange Livebox 14 | Sagemcom 15 | http://www.sagemcom.com/ 16 | Residential Livebox,(DSL,WAN Ethernet) 17 | uuid:87895a19-50f9-3736-a87f-115c230155f8 18 | Sagemcom,fr,SG30_sip-fr-4.28.35.1 19 | 3 20 | LK14129DP441489 21 | http://192.168.1.1 22 | 23 | 24 | 25 | image/png 26 | 16 27 | 16 28 | 8 29 | /87895a19/ligd.png 30 | 31 | 32 | 33 | 34 | urn:schemas-upnp-org:device:WANDevice:2 35 | WANDevice 36 | Sagemcom 37 | http://www.sagemcom.com/ 38 | WAN Device on Sagemcom,fr,SG30_sip-fr-4.28.35.1 39 | Residential Livebox,(DSL,WAN Ethernet) 40 | 3 41 | http://www.sagemcom.com/ 42 | LK14129DP441489 43 | http://192.168.1.1 44 | uuid:e2397374-53d8-3fc6-8306-593ba1a34625 45 | 46 | 47 | 48 | urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1 49 | urn:upnp-org:serviceId:WANCommonIFC1 50 | /87895a19/upnp/control/WANCommonIFC1 51 | /87895a19/upnp/control/WANCommonIFC1 52 | /87895a19/gateicfgSCPD.xml 53 | 54 | 55 | 56 | 57 | urn:schemas-upnp-org:device:WANConnectionDevice:2 58 | WANConnectionDevice 59 | Sagemcom 60 | http://www.sagemcom.com/ 61 | WanConnectionDevice on Sagemcom,fr,SG30_sip-fr-4.28.35.1 62 | Residential Livebox,(DSL,WAN Ethernet) 63 | 3 64 | http://www.sagemcom.com/ 65 | LK14129DP441489 66 | http://192.168.1.1 67 | uuid:44598a08-288e-32c9-8a4d-d3c008ede331 68 | 69 | 70 | 71 | urn:schemas-upnp-org:service:WANPPPConnection:2 72 | urn:upnp-org:serviceId:WANIPConn1 73 | /87895a19/upnp/control/WANIPConn1 74 | /87895a19/upnp/control/WANIPConn1 75 | /87895a19/gateconnSCPD_PPP.xml 76 | 77 | 78 | urn:schemas-upnp-org:service:WANIPv6FirewallControl:1 79 | urn:upnp-org:serviceId:WANIPv6FwCtrl1 80 | /87895a19/upnp/control/WANIPv6FwCtrl1 81 | /87895a19/upnp/control/WANIPv6FwCtrl1 82 | /87895a19/wanipv6fwctrlSCPD.xml 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /framework/miniupnpc/testminiwget.c: -------------------------------------------------------------------------------- 1 | /* $Id: testminiwget.c,v 1.7 2018/01/16 01:01:05 nanard Exp $ */ 2 | /* vim: tabstop=4 shiftwidth=4 noexpandtab 3 | * Project : miniupnp 4 | * Author : Thomas Bernard 5 | * Copyright (c) 2005-2018 Thomas Bernard 6 | * This software is subject to the conditions detailed in the 7 | * LICENCE file provided in this distribution. 8 | * */ 9 | #include 10 | #include 11 | #include "miniwget.h" 12 | 13 | /** 14 | * This program uses the miniwget / miniwget_getaddr function 15 | * from miniwget.c in order to retrieve a web ressource using 16 | * a GET HTTP method, and store it in a file. 17 | */ 18 | int main(int argc, char * * argv) 19 | { 20 | void * data; 21 | int size, writtensize; 22 | FILE *f; 23 | char addr[64]; 24 | int status_code = -1; 25 | 26 | if(argc < 3) { 27 | fprintf(stderr, "Usage:\t%s url file\n", argv[0]); 28 | fprintf(stderr, "Example:\t%s http://www.google.com/ out.html\n", argv[0]); 29 | return 1; 30 | } 31 | data = miniwget_getaddr(argv[1], &size, addr, sizeof(addr), 0, &status_code); 32 | if(!data || (status_code != 200)) { 33 | if(data) free(data); 34 | fprintf(stderr, "Error %d fetching %s\n", status_code, argv[1]); 35 | return 1; 36 | } 37 | printf("local address : %s\n", addr); 38 | printf("got %d bytes\n", size); 39 | f = fopen(argv[2], "wb"); 40 | if(!f) { 41 | fprintf(stderr, "Cannot open file %s for writing\n", argv[2]); 42 | free(data); 43 | return 1; 44 | } 45 | writtensize = fwrite(data, 1, size, f); 46 | if(writtensize != size) { 47 | fprintf(stderr, "Could only write %d bytes out of %d to %s\n", 48 | writtensize, size, argv[2]); 49 | } else { 50 | printf("%d bytes written to %s\n", writtensize, argv[2]); 51 | } 52 | fclose(f); 53 | free(data); 54 | return 0; 55 | } 56 | 57 | -------------------------------------------------------------------------------- /framework/miniupnpc/testminiwget.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # $Id: testminiwget.sh,v 1.16 2018/01/16 01:01:05 nanard Exp $ 3 | # vim: tabstop=4 shiftwidth=4 noexpandtab 4 | # project miniupnp : http://miniupnp.free.fr/ 5 | # (c) 2011-2018 Thomas Bernard 6 | # 7 | # test program for miniwget.c 8 | # is usually invoked by "make check" 9 | # 10 | # This test program : 11 | # 1 - launches a local HTTP server (minihttptestserver) 12 | # 2 - uses testminiwget to retrieve data from this server 13 | # 3 - compares served and received data 14 | # 4 - kills the local HTTP server and exits 15 | # 16 | # The script was tested and works with ksh, bash 17 | # it should now also run with dash 18 | 19 | TMPD=`mktemp -d -t miniwgetXXXXXXXXXX` 20 | HTTPSERVEROUT="${TMPD}/httpserverout" 21 | EXPECTEDFILE="${TMPD}/expectedfile" 22 | DOWNLOADEDFILE="${TMPD}/downloadedfile" 23 | PORT= 24 | RET=0 25 | IPCONFIG=$(which ifconfig) 26 | if [ -z "$IPCONFIG" ] ; then 27 | IPCONFIG="/sbin/ifconfig" 28 | fi 29 | 30 | if ! $IPCONFIG -a | grep inet6 ; then 31 | HAVE_IPV6=no 32 | fi 33 | 34 | case "$HAVE_IPV6" in 35 | n|no|0) 36 | ADDR=localhost 37 | SERVERARGS="" 38 | ;; 39 | *) 40 | ADDR="[::1]" 41 | SERVERARGS="-6" 42 | ;; 43 | 44 | esac 45 | 46 | #make minihttptestserver 47 | #make testminiwget 48 | 49 | # launching the test HTTP server 50 | ./minihttptestserver $SERVERARGS -e $EXPECTEDFILE > $HTTPSERVEROUT & 51 | SERVERPID=$! 52 | while [ -z "$PORT" ]; do 53 | sleep 1 54 | PORT=`cat $HTTPSERVEROUT | sed 's/Listening on port \([0-9]*\)/\1/' ` 55 | done 56 | if [ "$PORT" = "*** ERROR ***" ]; then 57 | echo "HTTP test server error" 58 | echo "Network config :" 59 | $IPCONFIG -a 60 | exit 2 61 | fi 62 | echo "Test HTTP server is listening on $PORT" 63 | 64 | URL1="http://$ADDR:$PORT/index.html" 65 | URL2="http://$ADDR:$PORT/chunked" 66 | URL3="http://$ADDR:$PORT/addcrap" 67 | 68 | echo "standard test ..." 69 | ./testminiwget $URL1 "${DOWNLOADEDFILE}.1" 70 | if cmp $EXPECTEDFILE "${DOWNLOADEDFILE}.1" ; then 71 | echo "ok" 72 | else 73 | echo "standard test FAILED" 74 | RET=1 75 | fi 76 | 77 | echo "chunked transfert encoding test ..." 78 | ./testminiwget $URL2 "${DOWNLOADEDFILE}.2" 79 | if cmp $EXPECTEDFILE "${DOWNLOADEDFILE}.2" ; then 80 | echo "ok" 81 | else 82 | echo "chunked transfert encoding test FAILED" 83 | RET=1 84 | fi 85 | 86 | echo "response too long test ..." 87 | ./testminiwget $URL3 "${DOWNLOADEDFILE}.3" 88 | if cmp $EXPECTEDFILE "${DOWNLOADEDFILE}.3" ; then 89 | echo "ok" 90 | else 91 | echo "response too long test FAILED" 92 | RET=1 93 | fi 94 | 95 | # kill the test HTTP server 96 | kill $SERVERPID 97 | wait $SERVERPID 98 | 99 | # remove temporary files (for success cases) 100 | if [ $RET -eq 0 ]; then 101 | rm -f "${DOWNLOADEDFILE}.1" 102 | rm -f "${DOWNLOADEDFILE}.2" 103 | rm -f "${DOWNLOADEDFILE}.3" 104 | rm -f $EXPECTEDFILE $HTTPSERVEROUT 105 | rmdir ${TMPD} 106 | else 107 | echo "at least one of the test FAILED" 108 | echo "directory ${TMPD} is left intact" 109 | fi 110 | exit $RET 111 | 112 | -------------------------------------------------------------------------------- /framework/miniupnpc/testminixml.c: -------------------------------------------------------------------------------- 1 | /* $Id: testminixml.c,v 1.10 2014/11/17 17:19:13 nanard Exp $ 2 | * MiniUPnP project 3 | * Website : http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ 4 | * Author : Thomas Bernard. 5 | * Copyright (c) 2005-2014 Thomas Bernard 6 | * 7 | * testminixml.c 8 | * test program for the "minixml" functions. 9 | */ 10 | #include 11 | #include 12 | #include 13 | #include "minixml.h" 14 | #include "igd_desc_parse.h" 15 | 16 | /* ---------------------------------------------------------------------- */ 17 | void printeltname1(void * d, const char * name, int l) 18 | { 19 | int i; 20 | (void)d; 21 | printf("element "); 22 | for(i=0;i 2 | 123 3 | TCP 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /framework/miniupnpc/testreplyparse/GetExternalIPAddress.namevalue: -------------------------------------------------------------------------------- 1 | NewExternalIPAddress=1.2.3.4 2 | 3 | -------------------------------------------------------------------------------- /framework/miniupnpc/testreplyparse/GetExternalIPAddress.xml: -------------------------------------------------------------------------------- 1 | 1.2.3.4 2 | 3 | -------------------------------------------------------------------------------- /framework/miniupnpc/testreplyparse/GetSpecificPortMappingEntryReq.namevalue: -------------------------------------------------------------------------------- 1 | NewProtocol=UDP 2 | NewExternalPort=12345 3 | NewRemoteHost= 4 | -------------------------------------------------------------------------------- /framework/miniupnpc/testreplyparse/GetSpecificPortMappingEntryReq.xml: -------------------------------------------------------------------------------- 1 | 2 | 12345UDP 3 | 4 | -------------------------------------------------------------------------------- /framework/miniupnpc/testreplyparse/GetSpecificPortMappingEntryResp.namevalue: -------------------------------------------------------------------------------- 1 | NewInternalPort=12345 2 | NewInternalClient=192.168.10.110 3 | NewEnabled=1 4 | NewPortMappingDescription=libminiupnpc 5 | NewLeaseDuration=0 6 | -------------------------------------------------------------------------------- /framework/miniupnpc/testreplyparse/GetSpecificPortMappingEntryResp.xml: -------------------------------------------------------------------------------- 1 | 12345192.168.10.1101libminiupnpc0 2 | 3 | -------------------------------------------------------------------------------- /framework/miniupnpc/testreplyparse/SetDefaultConnectionService.namevalue: -------------------------------------------------------------------------------- 1 | NewDefaultConnectionService=uuid:c6c05a33-f704-48df-9910-e099b3471d81:WANConnectionDevice:1,INVALID_SERVICE_ID 2 | -------------------------------------------------------------------------------- /framework/miniupnpc/testreplyparse/SetDefaultConnectionService.xml: -------------------------------------------------------------------------------- 1 | uuid:c6c05a33-f704-48df-9910-e099b3471d81:WANConnectionDevice:1,INVALID_SERVICE_ID 2 | -------------------------------------------------------------------------------- /framework/miniupnpc/testreplyparse/readme.txt: -------------------------------------------------------------------------------- 1 | This directory contains files used for validation of upnpreplyparse.c code. 2 | 3 | Each .xml file to parse should give the results which are in the .namevalue 4 | file. 5 | 6 | A .namevalue file contain name=value lines. 7 | 8 | -------------------------------------------------------------------------------- /framework/miniupnpc/testupnpigd.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/python 2 | # $Id: testupnpigd.py,v 1.5 2016/12/16 08:50:55 nanard Exp $ 3 | # MiniUPnP project 4 | # Author : Thomas Bernard 5 | # This Sample code is public domain. 6 | # website : http://miniupnp.tuxfamily.org/ 7 | 8 | # import the python miniupnpc module 9 | import miniupnpc 10 | import socket 11 | 12 | try: 13 | from http.server import BaseHTTPRequestHandler, HTTPServer 14 | except ImportError: 15 | from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer 16 | 17 | # function definition 18 | def list_redirections(): 19 | i = 0 20 | while True: 21 | p = u.getgenericportmapping(i) 22 | if p==None: 23 | break 24 | print(i, p) 25 | i = i + 1 26 | 27 | #define the handler class for HTTP connections 28 | class handler_class(BaseHTTPRequestHandler): 29 | def do_GET(self): 30 | self.send_response(200) 31 | self.end_headers() 32 | self.wfile.write("OK MON GARS") 33 | 34 | # create the object 35 | u = miniupnpc.UPnP() 36 | #print 'inital(default) values :' 37 | #print ' discoverdelay', u.discoverdelay 38 | #print ' lanaddr', u.lanaddr 39 | #print ' multicastif', u.multicastif 40 | #print ' minissdpdsocket', u.minissdpdsocket 41 | u.discoverdelay = 200; 42 | 43 | try: 44 | print('Discovering... delay=%ums' % u.discoverdelay) 45 | ndevices = u.discover() 46 | print(ndevices, 'device(s) detected') 47 | 48 | # select an igd 49 | u.selectigd() 50 | # display information about the IGD and the internet connection 51 | print('local ip address :', u.lanaddr) 52 | externalipaddress = u.externalipaddress() 53 | print('external ip address :', externalipaddress) 54 | print(u.statusinfo(), u.connectiontype()) 55 | 56 | #instanciate a HTTPd object. The port is assigned by the system. 57 | httpd = HTTPServer((u.lanaddr, 0), handler_class) 58 | eport = httpd.server_port 59 | 60 | # find a free port for the redirection 61 | r = u.getspecificportmapping(eport, 'TCP') 62 | while r != None and eport < 65536: 63 | eport = eport + 1 64 | r = u.getspecificportmapping(eport, 'TCP') 65 | 66 | print('trying to redirect %s port %u TCP => %s port %u TCP' % (externalipaddress, eport, u.lanaddr, httpd.server_port)) 67 | 68 | b = u.addportmapping(eport, 'TCP', u.lanaddr, httpd.server_port, 69 | 'UPnP IGD Tester port %u' % eport, '') 70 | if b: 71 | print('Success. Now waiting for some HTTP request on http://%s:%u' % (externalipaddress ,eport)) 72 | try: 73 | httpd.handle_request() 74 | httpd.server_close() 75 | except KeyboardInterrupt as details: 76 | print("CTRL-C exception!", details) 77 | b = u.deleteportmapping(eport, 'TCP') 78 | if b: 79 | print('Successfully deleted port mapping') 80 | else: 81 | print('Failed to remove port mapping') 82 | else: 83 | print('Failed') 84 | 85 | httpd.server_close() 86 | 87 | except Exception as e: 88 | print('Exception :', e) 89 | -------------------------------------------------------------------------------- /framework/miniupnpc/testupnpreplyparse.c: -------------------------------------------------------------------------------- 1 | /* $Id: testupnpreplyparse.c,v 1.5 2017/12/12 11:18:46 nanard Exp $ */ 2 | /* MiniUPnP project 3 | * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ 4 | * (c) 2006-2017 Thomas Bernard 5 | * This software is subject to the conditions detailed 6 | * in the LICENCE file provided within the distribution */ 7 | #include 8 | #include 9 | #include 10 | #include "upnpreplyparse.h" 11 | 12 | int 13 | test_parsing(const char * buf, int len, FILE * f) 14 | { 15 | char line[1024]; 16 | struct NameValueParserData pdata; 17 | int ok = 1; 18 | ParseNameValue(buf, len, &pdata); 19 | /* check result */ 20 | if(f != NULL) 21 | { 22 | while(fgets(line, sizeof(line), f)) 23 | { 24 | char * value; 25 | char * equal; 26 | char * parsedvalue; 27 | int l; 28 | l = strlen(line); 29 | while((l > 0) && ((line[l-1] == '\r') || (line[l-1] == '\n'))) 30 | line[--l] = '\0'; 31 | /* skip empty lines */ 32 | if(l == 0) 33 | continue; 34 | equal = strchr(line, '='); 35 | if(equal == NULL) 36 | { 37 | fprintf(stderr, "Warning, line does not contain '=' : %s\n", line); 38 | continue; 39 | } 40 | *equal = '\0'; 41 | value = equal + 1; 42 | parsedvalue = GetValueFromNameValueList(&pdata, line); 43 | if((parsedvalue == NULL) || (strcmp(parsedvalue, value) != 0)) 44 | { 45 | fprintf(stderr, "Element <%s> : expecting value '%s', got '%s'\n", 46 | line, value, parsedvalue ? parsedvalue : ""); 47 | ok = 0; 48 | } 49 | } 50 | } 51 | ClearNameValueList(&pdata); 52 | return ok; 53 | } 54 | 55 | int main(int argc, char * * argv) 56 | { 57 | FILE * f; 58 | char * buffer; 59 | long l; 60 | int ok; 61 | 62 | if(argc<2) 63 | { 64 | fprintf(stderr, "Usage: %s file.xml [file.namevalues]\n", argv[0]); 65 | return 1; 66 | } 67 | f = fopen(argv[1], "r"); 68 | if(!f) 69 | { 70 | fprintf(stderr, "Error : can not open file %s\n", argv[1]); 71 | return 2; 72 | } 73 | if(fseek(f, 0, SEEK_END) < 0) { 74 | perror("fseek"); 75 | return 1; 76 | } 77 | l = (int)ftell(f); 78 | if(l < 0) { 79 | perror("ftell"); 80 | return 1; 81 | } 82 | if(fseek(f, 0, SEEK_SET) < 0) { 83 | perror("fseek"); 84 | return 1; 85 | } 86 | buffer = malloc(l + 1); 87 | if(buffer == NULL) { 88 | fprintf(stderr, "Error: failed to allocate %ld bytes\n", l+1); 89 | return 1; 90 | } 91 | l = fread(buffer, 1, l, f); 92 | fclose(f); 93 | f = NULL; 94 | buffer[l] = '\0'; 95 | if(argc > 2) 96 | { 97 | f = fopen(argv[2], "r"); 98 | if(!f) 99 | { 100 | fprintf(stderr, "Error : can not open file %s\n", argv[2]); 101 | return 2; 102 | } 103 | } 104 | #ifdef DEBUG 105 | DisplayNameValueList(buffer, l); 106 | #endif 107 | ok = test_parsing(buffer, l, f); 108 | if(f) 109 | { 110 | fclose(f); 111 | } 112 | free(buffer); 113 | return ok ? 0 : 3; 114 | } 115 | 116 | -------------------------------------------------------------------------------- /framework/miniupnpc/testupnpreplyparse.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for f in testreplyparse/*.xml ; do 4 | bf="`dirname $f`/`basename $f .xml`" 5 | if ./testupnpreplyparse $f $bf.namevalue ; then 6 | echo "$f : passed" 7 | else 8 | echo "$f : FAILED" 9 | exit 1 10 | fi 11 | done 12 | 13 | exit 0 14 | 15 | -------------------------------------------------------------------------------- /framework/miniupnpc/updateminiupnpcstrings.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # $Id: updateminiupnpcstrings.sh,v 1.7 2011/01/04 11:41:53 nanard Exp $ 3 | # project miniupnp : http://miniupnp.free.fr/ 4 | # (c) 2009 Thomas Bernard 5 | 6 | FILE=miniupnpcstrings.h 7 | TMPFILE=miniupnpcstrings.h.tmp 8 | TEMPLATE_FILE=${FILE}.in 9 | 10 | # detecting the OS name and version 11 | OS_NAME=`uname -s` 12 | OS_VERSION=`uname -r` 13 | if [ -f /etc/debian_version ]; then 14 | OS_NAME=Debian 15 | OS_VERSION=`cat /etc/debian_version` 16 | fi 17 | # use lsb_release (Linux Standard Base) when available 18 | LSB_RELEASE=`which lsb_release` 19 | if [ 0 -eq $? -a -x "${LSB_RELEASE}" ]; then 20 | OS_NAME=`${LSB_RELEASE} -i -s` 21 | OS_VERSION=`${LSB_RELEASE} -r -s` 22 | case $OS_NAME in 23 | Debian) 24 | #OS_VERSION=`${LSB_RELEASE} -c -s` 25 | ;; 26 | Ubuntu) 27 | #OS_VERSION=`${LSB_RELEASE} -c -s` 28 | ;; 29 | esac 30 | fi 31 | 32 | # on AmigaOS 3, uname -r returns "unknown", so we use uname -v 33 | if [ "$OS_NAME" = "AmigaOS" ]; then 34 | if [ "$OS_VERSION" = "unknown" ]; then 35 | OS_VERSION=`uname -v` 36 | fi 37 | fi 38 | 39 | echo "Detected OS [$OS_NAME] version [$OS_VERSION]" 40 | MINIUPNPC_VERSION=`cat VERSION` 41 | echo "MiniUPnPc version [${MINIUPNPC_VERSION}]" 42 | 43 | EXPR="s|OS_STRING \".*\"|OS_STRING \"${OS_NAME}/${OS_VERSION}\"|" 44 | #echo $EXPR 45 | test -f ${FILE}.in 46 | echo "setting OS_STRING macro value to ${OS_NAME}/${OS_VERSION} in $FILE." 47 | sed -e "$EXPR" < $TEMPLATE_FILE > $TMPFILE 48 | 49 | EXPR="s|MINIUPNPC_VERSION_STRING \".*\"|MINIUPNPC_VERSION_STRING \"${MINIUPNPC_VERSION}\"|" 50 | echo "setting MINIUPNPC_VERSION_STRING macro value to ${MINIUPNPC_VERSION} in $FILE." 51 | sed -e "$EXPR" < $TMPFILE > $FILE 52 | rm $TMPFILE 53 | 54 | -------------------------------------------------------------------------------- /framework/miniupnpc/upnpdev.c: -------------------------------------------------------------------------------- 1 | /* $Id: upnpdev.c,v 1.1 2015/08/28 12:14:19 nanard Exp $ */ 2 | /* Project : miniupnp 3 | * Web : http://miniupnp.free.fr/ 4 | * Author : Thomas BERNARD 5 | * copyright (c) 2005-2015 Thomas Bernard 6 | * This software is subjet to the conditions detailed in the 7 | * provided LICENSE file. */ 8 | #include 9 | #include "upnpdev.h" 10 | 11 | /* freeUPNPDevlist() should be used to 12 | * free the chained list returned by upnpDiscover() */ 13 | void freeUPNPDevlist(struct UPNPDev * devlist) 14 | { 15 | struct UPNPDev * next; 16 | while(devlist) 17 | { 18 | next = devlist->pNext; 19 | free(devlist); 20 | devlist = next; 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /framework/miniupnpc/upnpdev.h: -------------------------------------------------------------------------------- 1 | /* $Id: upnpdev.h,v 1.2 2018/04/06 10:53:15 nanard Exp $ */ 2 | /* Project : miniupnp 3 | * Web : http://miniupnp.free.fr/ 4 | * Author : Thomas BERNARD 5 | * copyright (c) 2005-2018 Thomas Bernard 6 | * This software is subjet to the conditions detailed in the 7 | * provided LICENSE file. */ 8 | #ifndef UPNPDEV_H_INCLUDED 9 | #define UPNPDEV_H_INCLUDED 10 | 11 | #include "miniupnpc_declspec.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | struct UPNPDev { 18 | struct UPNPDev * pNext; 19 | char * descURL; 20 | char * st; 21 | char * usn; 22 | unsigned int scope_id; 23 | char buffer[3]; 24 | }; 25 | 26 | /* freeUPNPDevlist() 27 | * free list returned by upnpDiscover() */ 28 | MINIUPNP_LIBSPEC void freeUPNPDevlist(struct UPNPDev * devlist); 29 | 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | 36 | #endif /* UPNPDEV_H_INCLUDED */ 37 | -------------------------------------------------------------------------------- /framework/miniupnpc/upnperrors.c: -------------------------------------------------------------------------------- 1 | /* $Id: upnperrors.c,v 1.8 2014/06/10 09:41:48 nanard Exp $ */ 2 | /* Project : miniupnp 3 | * Author : Thomas BERNARD 4 | * copyright (c) 2007 Thomas Bernard 5 | * All Right reserved. 6 | * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ 7 | * This software is subjet to the conditions detailed in the 8 | * provided LICENCE file. */ 9 | #include 10 | #include "upnperrors.h" 11 | #include "upnpcommands.h" 12 | #include "miniupnpc.h" 13 | 14 | const char * strupnperror(int err) 15 | { 16 | const char * s = NULL; 17 | switch(err) { 18 | case UPNPCOMMAND_SUCCESS: 19 | s = "Success"; 20 | break; 21 | case UPNPCOMMAND_UNKNOWN_ERROR: 22 | s = "Miniupnpc Unknown Error"; 23 | break; 24 | case UPNPCOMMAND_INVALID_ARGS: 25 | s = "Miniupnpc Invalid Arguments"; 26 | break; 27 | case UPNPCOMMAND_INVALID_RESPONSE: 28 | s = "Miniupnpc Invalid response"; 29 | break; 30 | case UPNPDISCOVER_SOCKET_ERROR: 31 | s = "Miniupnpc Socket error"; 32 | break; 33 | case UPNPDISCOVER_MEMORY_ERROR: 34 | s = "Miniupnpc Memory allocation error"; 35 | break; 36 | case 401: 37 | s = "Invalid Action"; 38 | break; 39 | case 402: 40 | s = "Invalid Args"; 41 | break; 42 | case 501: 43 | s = "Action Failed"; 44 | break; 45 | case 606: 46 | s = "Action not authorized"; 47 | break; 48 | case 701: 49 | s = "PinholeSpaceExhausted"; 50 | break; 51 | case 702: 52 | s = "FirewallDisabled"; 53 | break; 54 | case 703: 55 | s = "InboundPinholeNotAllowed"; 56 | break; 57 | case 704: 58 | s = "NoSuchEntry"; 59 | break; 60 | case 705: 61 | s = "ProtocolNotSupported"; 62 | break; 63 | case 706: 64 | s = "InternalPortWildcardingNotAllowed"; 65 | break; 66 | case 707: 67 | s = "ProtocolWildcardingNotAllowed"; 68 | break; 69 | case 708: 70 | s = "WildcardNotPermittedInSrcIP"; 71 | break; 72 | case 709: 73 | s = "NoPacketSent"; 74 | break; 75 | case 713: 76 | s = "SpecifiedArrayIndexInvalid"; 77 | break; 78 | case 714: 79 | s = "NoSuchEntryInArray"; 80 | break; 81 | case 715: 82 | s = "WildCardNotPermittedInSrcIP"; 83 | break; 84 | case 716: 85 | s = "WildCardNotPermittedInExtPort"; 86 | break; 87 | case 718: 88 | s = "ConflictInMappingEntry"; 89 | break; 90 | case 724: 91 | s = "SamePortValuesRequired"; 92 | break; 93 | case 725: 94 | s = "OnlyPermanentLeasesSupported"; 95 | break; 96 | case 726: 97 | s = "RemoteHostOnlySupportsWildcard"; 98 | break; 99 | case 727: 100 | s = "ExternalPortOnlySupportsWildcard"; 101 | break; 102 | default: 103 | s = "UnknownError"; 104 | break; 105 | } 106 | return s; 107 | } 108 | -------------------------------------------------------------------------------- /framework/miniupnpc/upnperrors.h: -------------------------------------------------------------------------------- 1 | /* $Id: upnperrors.h,v 1.6 2015/07/21 13:16:55 nanard Exp $ */ 2 | /* (c) 2007-2015 Thomas Bernard 3 | * All rights reserved. 4 | * MiniUPnP Project. 5 | * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ 6 | * This software is subjet to the conditions detailed in the 7 | * provided LICENCE file. */ 8 | #ifndef UPNPERRORS_H_INCLUDED 9 | #define UPNPERRORS_H_INCLUDED 10 | 11 | #include "miniupnpc_declspec.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | /* strupnperror() 18 | * Return a string description of the UPnP error code 19 | * or NULL for undefinded errors */ 20 | MINIUPNP_LIBSPEC const char * strupnperror(int err); 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /framework/miniupnpc/upnpreplyparse.h: -------------------------------------------------------------------------------- 1 | /* $Id: upnpreplyparse.h,v 1.19 2014/10/27 16:33:19 nanard Exp $ */ 2 | /* MiniUPnP project 3 | * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ 4 | * (c) 2006-2013 Thomas Bernard 5 | * This software is subject to the conditions detailed 6 | * in the LICENCE file provided within the distribution */ 7 | 8 | #ifndef UPNPREPLYPARSE_H_INCLUDED 9 | #define UPNPREPLYPARSE_H_INCLUDED 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | struct NameValue { 16 | struct NameValue * l_next; 17 | char name[64]; 18 | char value[128]; 19 | }; 20 | 21 | struct NameValueParserData { 22 | struct NameValue * l_head; 23 | char curelt[64]; 24 | char * portListing; 25 | int portListingLength; 26 | int topelt; 27 | const char * cdata; 28 | int cdatalen; 29 | }; 30 | 31 | /* ParseNameValue() */ 32 | void 33 | ParseNameValue(const char * buffer, int bufsize, 34 | struct NameValueParserData * data); 35 | 36 | /* ClearNameValueList() */ 37 | void 38 | ClearNameValueList(struct NameValueParserData * pdata); 39 | 40 | /* GetValueFromNameValueList() */ 41 | char * 42 | GetValueFromNameValueList(struct NameValueParserData * pdata, 43 | const char * Name); 44 | 45 | #if 0 46 | /* GetValueFromNameValueListIgnoreNS() */ 47 | char * 48 | GetValueFromNameValueListIgnoreNS(struct NameValueParserData * pdata, 49 | const char * Name); 50 | #endif 51 | 52 | /* DisplayNameValueList() */ 53 | #ifdef DEBUG 54 | void 55 | DisplayNameValueList(char * buffer, int bufsize); 56 | #endif 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | 62 | #endif 63 | 64 | -------------------------------------------------------------------------------- /framework/miniupnpc/wingenminiupnpcstrings.c: -------------------------------------------------------------------------------- 1 | /* $Id: wingenminiupnpcstrings.c,v 1.4 2015/02/08 08:46:06 nanard Exp $ */ 2 | /* Project: miniupnp 3 | * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ 4 | * Author: Thomas Bernard 5 | * Copyright (c) 2005-2015 Thomas Bernard 6 | * This software is subjects to the conditions detailed 7 | * in the LICENSE file provided within this distribution */ 8 | #include 9 | #include 10 | 11 | /* This program display the Windows version and is used to 12 | * generate the miniupnpcstrings.h 13 | * wingenminiupnpcstrings miniupnpcstrings.h.in miniupnpcstrings.h 14 | */ 15 | int main(int argc, char * * argv) { 16 | char buffer[256]; 17 | OSVERSIONINFO osvi; 18 | FILE * fin; 19 | FILE * fout; 20 | int n; 21 | char miniupnpcVersion[32]; 22 | /* dwMajorVersion : 23 | The major version number of the operating system. For more information, see Remarks. 24 | dwMinorVersion : 25 | The minor version number of the operating system. For more information, see Remarks. 26 | dwBuildNumber : 27 | The build number of the operating system. 28 | dwPlatformId 29 | The operating system platform. This member can be the following value. 30 | szCSDVersion 31 | A null-terminated string, such as "Service Pack 3", that indicates the 32 | latest Service Pack installed on the system. If no Service Pack has 33 | been installed, the string is empty. 34 | */ 35 | ZeroMemory(&osvi, sizeof(OSVERSIONINFO)); 36 | osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 37 | 38 | GetVersionEx(&osvi); 39 | 40 | printf("Windows %lu.%lu Build %lu %s\n", 41 | osvi.dwMajorVersion, osvi.dwMinorVersion, 42 | osvi.dwBuildNumber, (const char *)&(osvi.szCSDVersion)); 43 | 44 | fin = fopen("VERSION", "r"); 45 | fgets(miniupnpcVersion, sizeof(miniupnpcVersion), fin); 46 | fclose(fin); 47 | for(n = 0; n < sizeof(miniupnpcVersion); n++) { 48 | if(miniupnpcVersion[n] < ' ') 49 | miniupnpcVersion[n] = '\0'; 50 | } 51 | printf("MiniUPnPc version %s\n", miniupnpcVersion); 52 | 53 | if(argc >= 3) { 54 | fin = fopen(argv[1], "r"); 55 | if(!fin) { 56 | fprintf(stderr, "Cannot open %s for reading.\n", argv[1]); 57 | return 1; 58 | } 59 | fout = fopen(argv[2], "w"); 60 | if(!fout) { 61 | fprintf(stderr, "Cannot open %s for writing.\n", argv[2]); 62 | fclose(fin); 63 | return 1; 64 | } 65 | n = 0; 66 | while(fgets(buffer, sizeof(buffer), fin)) { 67 | if(0 == memcmp(buffer, "#define OS_STRING \"OS/version\"", 30)) { 68 | sprintf(buffer, "#define OS_STRING \"MSWindows/%ld.%ld.%ld\"\n", 69 | osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber); 70 | } else if(0 == memcmp(buffer, "#define MINIUPNPC_VERSION_STRING \"version\"", 42)) { 71 | sprintf(buffer, "#define MINIUPNPC_VERSION_STRING \"%s\"\n", 72 | miniupnpcVersion); 73 | } 74 | /*fputs(buffer, stdout);*/ 75 | fputs(buffer, fout); 76 | n++; 77 | } 78 | fclose(fin); 79 | fclose(fout); 80 | printf("%d lines written to %s.\n", n, argv[2]); 81 | } 82 | return 0; 83 | } 84 | -------------------------------------------------------------------------------- /general_artwork/ImageIcons.afdesign: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monkeydom/TCMPortMapper/914d064d4e8d37c20be3e91260881bb5bcf8c455/general_artwork/ImageIcons.afdesign -------------------------------------------------------------------------------- /general_artwork/PortMapIcon.acorn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monkeydom/TCMPortMapper/914d064d4e8d37c20be3e91260881bb5bcf8c455/general_artwork/PortMapIcon.acorn -------------------------------------------------------------------------------- /natecho/AppController.h: -------------------------------------------------------------------------------- 1 | // AppController.h 2 | // 3 | 4 | @import Cocoa; 5 | #import "TCPServer.h" 6 | 7 | @interface AppController : NSObject { 8 | IBOutlet NSTextField *O_portTextField; 9 | IBOutlet NSButton *O_startStopButton; 10 | IBOutlet NSImageView *O_serverStatusImageView; 11 | IBOutlet NSTextField *O_serverStatusTextField; 12 | IBOutlet NSTextField *O_serverReachabilityTextField; 13 | 14 | IBOutlet NSProgressIndicator *O_publicIndicator; 15 | IBOutlet NSImageView *O_publicStatusImageView; 16 | IBOutlet NSTextField *O_publicStatusTextField; 17 | 18 | NSMutableArray *I_streamsArray; 19 | TCPServer *I_server; 20 | } 21 | 22 | - (IBAction)startStop:(id)aSender; 23 | - (void)start; 24 | - (void)stop; 25 | @end 26 | -------------------------------------------------------------------------------- /natecho/Base.lproj/MainMenu.nib/keyedobjects.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monkeydom/TCMPortMapper/914d064d4e8d37c20be3e91260881bb5bcf8c455/natecho/Base.lproj/MainMenu.nib/keyedobjects.nib -------------------------------------------------------------------------------- /natecho/NATEcho-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | NSMainNibFile 20 | MainMenu 21 | NSPrincipalClass 22 | NSApplication 23 | 24 | 25 | -------------------------------------------------------------------------------- /natecho/TCPServer.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: TCPServer.h 3 | 4 | Abstract: Interface description for a basic TCP/IP server Foundation class 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Computer, Inc. ("Apple") in consideration of your agreement to the 8 | following terms, and your use, installation, modification or 9 | redistribution of this Apple software constitutes acceptance of these 10 | terms. If you do not agree with these terms, please do not use, 11 | install, modify or redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Computer, 22 | Inc. may be used to endorse or promote products derived from the Apple 23 | Software without specific prior written permission from Apple. Except 24 | as expressly stated in this notice, no other rights or licenses, express 25 | or implied, are granted by Apple herein, including but not limited to 26 | any patent rights that may be infringed by your derivative works or by 27 | other works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (c) 2005 Apple Computer, Inc., All Rights Reserved 45 | */ 46 | 47 | #import 48 | #import 49 | 50 | NSString * const TCPServerErrorDomain; 51 | 52 | typedef enum { 53 | kTCPServerCouldNotBindToIPv4Address = 1, 54 | kTCPServerCouldNotBindToIPv6Address = 2, 55 | kTCPServerNoSocketsAvailable = 3, 56 | } TCPServerErrorCode; 57 | 58 | @interface TCPServer : NSObject { 59 | @private 60 | id delegate; 61 | NSString *domain; 62 | NSString *name; 63 | NSString *type; 64 | uint16_t port; 65 | CFSocketRef ipv4socket; 66 | CFSocketRef ipv6socket; 67 | NSNetService *netService; 68 | } 69 | 70 | - (id)delegate; 71 | - (void)setDelegate:(id)value; 72 | 73 | - (NSString *)domain; 74 | - (void)setDomain:(NSString *)value; 75 | 76 | - (NSString *)name; 77 | - (void)setName:(NSString *)value; 78 | 79 | - (NSString *)type; 80 | - (void)setType:(NSString *)value; 81 | 82 | - (uint16_t)port; 83 | - (void)setPort:(uint16_t)value; 84 | 85 | - (BOOL)start:(NSError **)error; 86 | - (BOOL)stop; 87 | 88 | - (void)handleNewConnectionFromAddress:(NSData *)addr inputStream:(NSInputStream *)istr outputStream:(NSOutputStream *)ostr; 89 | // called when a new connection comes in; by default, informs the delegate 90 | 91 | @end 92 | 93 | @interface TCPServer (TCPServerDelegateMethods) 94 | - (void)TCPServer:(TCPServer *)server didReceiveConnectionFromAddress:(NSData *)addr inputStream:(NSInputStream *)istr outputStream:(NSOutputStream *)ostr; 95 | // if the delegate implements this method, it is called when a new 96 | // connection comes in; a subclass may, of course, change that behavior 97 | @end 98 | 99 | -------------------------------------------------------------------------------- /natecho/main.m: -------------------------------------------------------------------------------- 1 | // main.m 2 | // 3 | 4 | #import 5 | 6 | int main(int argc, const char * argv[]) { 7 | return NSApplicationMain(argc, argv); 8 | } 9 | -------------------------------------------------------------------------------- /portmap/AppController.h: -------------------------------------------------------------------------------- 1 | // AppController.h 2 | // Port Map.app 3 | 4 | @import Cocoa; 5 | 6 | @interface AppController : NSObject { 7 | } 8 | 9 | - (IBAction)togglePortMapper:(id)aSender; 10 | 11 | - (IBAction)refresh:(id)aSender; 12 | - (IBAction)addMapping:(id)aSender; 13 | - (IBAction)removeMapping:(id)aSender; 14 | - (IBAction)addMappingEndSheet:(id)aSender; 15 | - (IBAction)addMappingCancelSheet:(id)aSender; 16 | - (IBAction)choosePreset:(id)aSender; 17 | - (IBAction)showInstructionalPanel:(id)aSender; 18 | - (IBAction)endInstructionalSheet:(id)aSender; 19 | 20 | - (IBAction)gotoTCMPortMapperSources:(id)aSender; 21 | - (IBAction)reportABug:(id)aSender; 22 | - (IBAction)showReleaseNotes:(id)aSender; 23 | 24 | - (IBAction)showAbout:(id)aSender; 25 | 26 | - (IBAction)requestUPNPMappingTable:(id)aSender; 27 | - (IBAction)requestUPNPMappingTableRemoveMappings:(id)aSender; 28 | - (IBAction)requestUPNPMappingTableOKSheet:(id)aSender; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /portmap/Base.lproj/MainMenu.nib/keyedobjects.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monkeydom/TCMPortMapper/914d064d4e8d37c20be3e91260881bb5bcf8c455/portmap/Base.lproj/MainMenu.nib/keyedobjects.nib -------------------------------------------------------------------------------- /portmap/English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monkeydom/TCMPortMapper/914d064d4e8d37c20be3e91260881bb5bcf8c455/portmap/English.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /portmap/English.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | /* port map window title */ 2 | "Port Map" = "Port Map"; 3 | "Port Map on %@" = "Port Map on %@"; 4 | 5 | "NAT-PMP Howto URL" = "http://support.apple.com/kb/HT1552"; 6 | "Port Map URL" = "https://github.com/monkeydom/TCMPortMapper"; 7 | "TCMPortMapper URL" = "https://github.com/monkeydom/TCMPortMapper"; 8 | "Bugtracker URL" = "https://github.com/monkeydom/TCMPortMapper/issues"; 9 | 10 | /* status messages */ 11 | "Router incompatible." = "Router incompatible."; 12 | "Can't find router." = "Can't find router."; 13 | "Searching..." = "Searching…"; 14 | "Stopped" = "Stopped"; 15 | "No Router" = "No Router"; 16 | "No external Address." = "No external Address."; 17 | -------------------------------------------------------------------------------- /portmap/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | PortMap 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 2.0.1 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSApplicationCategoryType 26 | public.app-category.utilities 27 | LSMinimumSystemVersion 28 | 10.10 29 | NSMainNibFile 30 | MainMenu 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /portmap/Presets.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | mappingTitle 7 | SubEtha Engine 8 | desiredPort 9 | 6942 10 | localPort 11 | 6942 12 | referenceString 13 | see://[IP]:[PORT] 14 | transportProtocol 15 | 2 16 | 17 | 18 | mappingTitle 19 | VNC 20 | desiredPort 21 | 5900 22 | localPort 23 | 5900 24 | referenceString 25 | vnc://[IP]:[PORT] 26 | transportProtocol 27 | 2 28 | 29 | 30 | mappingTitle 31 | Web Server 32 | desiredPort 33 | 80 34 | localPort 35 | 80 36 | referenceString 37 | http://[IP]:[PORT] 38 | transportProtocol 39 | 2 40 | 41 | 42 | mappingTitle 43 | Secure Shell 44 | desiredPort 45 | 22 46 | localPort 47 | 22 48 | referenceString 49 | ssh://[IP]:[PORT] 50 | transportProtocol 51 | 2 52 | 53 | 54 | mappingTitle 55 | Rails Demo App 56 | desiredPort 57 | 3000 58 | localPort 59 | 3000 60 | referenceString 61 | http://[IP]:[PORT] 62 | transportProtocol 63 | 2 64 | 65 | 66 | mappingTitle 67 | IRC Auth/Ident 68 | desiredPort 69 | 113 70 | localPort 71 | 113 72 | referenceString 73 | auth://[IP]:[PORT] 74 | transportProtocol 75 | 2 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /portmap/TCMPortMappingAdditions.h: -------------------------------------------------------------------------------- 1 | // TCMPortMappingAdditions.h 2 | // 3 | 4 | @import Cocoa; 5 | #import 6 | 7 | @interface TCMPortMapping (TCMPortMappingAdditions) 8 | + (TCMPortMapping *)portMappingWithDictionaryRepresentation:(NSDictionary *)aDictionary; 9 | @property (nonatomic, readonly) NSDictionary *dictionaryRepresentation; 10 | @end 11 | -------------------------------------------------------------------------------- /portmap/TCMPortMappingAdditions.m: -------------------------------------------------------------------------------- 1 | #import "TCMPortMappingAdditions.h" 2 | 3 | @implementation TCMPortMapping (TCMPortMappingAdditions) 4 | 5 | + (TCMPortMapping *)portMappingWithDictionaryRepresentation:(NSDictionary *)aDictionary { 6 | TCMPortMapping *mapping = [TCMPortMapping portMappingWithLocalPort:[[aDictionary objectForKey:@"privatePort"] intValue] desiredExternalPort:[[aDictionary objectForKey:@"desiredPublicPort"] intValue] transportProtocol:TCMPortMappingTransportProtocolTCP userInfo:[(NSDictionary *)[aDictionary objectForKey:@"userInfo"] mutableCopy]]; 7 | [mapping setTransportProtocol:[[aDictionary objectForKey:@"transportProtocol"] intValue]]; 8 | return mapping; 9 | } 10 | 11 | - (NSDictionary *)dictionaryRepresentation { 12 | return @{ 13 | @"userInfo": [self userInfo], 14 | @"privatePort" : @(self.localPort) , 15 | @"desiredPublicPort" : @(self.desiredExternalPort), 16 | @"transportProtocol" : @(self.transportProtocol), 17 | }; 18 | } 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /portmap/TCMPortStringFromPublicPortValueTransformer.h: -------------------------------------------------------------------------------- 1 | // TCMPortStringFromPublicPortValueTransformer.h 2 | // 3 | 4 | @import Cocoa; 5 | 6 | @interface TCMPortStringFromPublicPortValueTransformer : NSValueTransformer 7 | @end 8 | 9 | @interface TCMReplacedStringFromPortMappingReferenceStringValueTransformer : NSValueTransformer 10 | @end 11 | -------------------------------------------------------------------------------- /portmap/TCMPortStringFromPublicPortValueTransformer.m: -------------------------------------------------------------------------------- 1 | #import "TCMPortStringFromPublicPortValueTransformer.h" 2 | #import 3 | 4 | @implementation TCMPortStringFromPublicPortValueTransformer 5 | 6 | + (Class)transformedValueClass { 7 | return [NSString class]; 8 | } 9 | 10 | - (id)transformedValue:(id)value { 11 | if ([value isKindOfClass:[NSNumber class]]) { 12 | switch([value intValue]) { 13 | case 0: 14 | return NSLocalizedString(@"unmapped",@""); 15 | default: 16 | return [NSString stringWithFormat:@"%d",[value intValue]]; 17 | } 18 | } else { 19 | return @"NaN"; 20 | } 21 | } 22 | 23 | @end 24 | 25 | @implementation TCMReplacedStringFromPortMappingReferenceStringValueTransformer 26 | 27 | + (Class)transformedValueClass { 28 | return [NSString class]; 29 | } 30 | 31 | - (id)transformedValue:(id)value { 32 | if ([value respondsToSelector:@selector(lastObject)]) { 33 | value = [value lastObject]; 34 | } 35 | if ([value respondsToSelector:@selector(mappingStatus)] && 36 | [value mappingStatus]==TCMPortMappingStatusMapped && 37 | [[TCMPortMapper sharedInstance] externalIPAddress]) { 38 | NSMutableString *string = [[[value userInfo] objectForKey:@"referenceString"] mutableCopy]; 39 | if (string) { 40 | if ([string rangeOfString:@"[IP]"].location!=NSNotFound) 41 | [string replaceCharactersInRange:[string rangeOfString:@"[IP]"] withString:[[TCMPortMapper sharedInstance] externalIPAddress]]; 42 | if ([string rangeOfString:@"[PORT]"].location!=NSNotFound) 43 | [string replaceCharactersInRange:[string rangeOfString:@"[PORT]"] withString:[NSString stringWithFormat:@"%d",[value externalPort]]]; 44 | } 45 | return string; 46 | } else { 47 | return @""; 48 | } 49 | } 50 | 51 | @end 52 | 53 | -------------------------------------------------------------------------------- /portmap/TCMStatusImageFromMappingStatusValueTransformer.h: -------------------------------------------------------------------------------- 1 | // TCMStatusImageFromMappingStatusValueTransformer.h 2 | // 3 | 4 | @import Cocoa; 5 | 6 | @interface TCMStatusImageFromMappingStatusValueTransformer : NSValueTransformer 7 | @end 8 | -------------------------------------------------------------------------------- /portmap/TCMStatusImageFromMappingStatusValueTransformer.m: -------------------------------------------------------------------------------- 1 | #import "TCMStatusImageFromMappingStatusValueTransformer.h" 2 | 3 | @implementation TCMStatusImageFromMappingStatusValueTransformer 4 | 5 | + (Class)transformedValueClass { 6 | return [NSImage class]; 7 | } 8 | 9 | - (id)transformedValue:(id)value { 10 | if ([value isKindOfClass:[NSNumber class]]) { 11 | switch ([value intValue]) { 12 | case 2: 13 | return [NSImage imageNamed:@"DotGreen"]; 14 | case 1: 15 | return [NSImage imageNamed:@"DotYellow"]; 16 | default: 17 | return [NSImage imageNamed:@"DotRed"]; 18 | } 19 | } else { 20 | return [NSImage imageNamed:NSImageNameStatusNone]; 21 | } 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /portmap/artwork/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /portmap/artwork/Assets.xcassets/PortMap.appiconset/1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monkeydom/TCMPortMapper/914d064d4e8d37c20be3e91260881bb5bcf8c455/portmap/artwork/Assets.xcassets/PortMap.appiconset/1024.png -------------------------------------------------------------------------------- /portmap/artwork/Assets.xcassets/PortMap.appiconset/128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monkeydom/TCMPortMapper/914d064d4e8d37c20be3e91260881bb5bcf8c455/portmap/artwork/Assets.xcassets/PortMap.appiconset/128.png -------------------------------------------------------------------------------- /portmap/artwork/Assets.xcassets/PortMap.appiconset/16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monkeydom/TCMPortMapper/914d064d4e8d37c20be3e91260881bb5bcf8c455/portmap/artwork/Assets.xcassets/PortMap.appiconset/16.png -------------------------------------------------------------------------------- /portmap/artwork/Assets.xcassets/PortMap.appiconset/256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monkeydom/TCMPortMapper/914d064d4e8d37c20be3e91260881bb5bcf8c455/portmap/artwork/Assets.xcassets/PortMap.appiconset/256.png -------------------------------------------------------------------------------- /portmap/artwork/Assets.xcassets/PortMap.appiconset/32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monkeydom/TCMPortMapper/914d064d4e8d37c20be3e91260881bb5bcf8c455/portmap/artwork/Assets.xcassets/PortMap.appiconset/32.png -------------------------------------------------------------------------------- /portmap/artwork/Assets.xcassets/PortMap.appiconset/512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monkeydom/TCMPortMapper/914d064d4e8d37c20be3e91260881bb5bcf8c455/portmap/artwork/Assets.xcassets/PortMap.appiconset/512.png -------------------------------------------------------------------------------- /portmap/artwork/Assets.xcassets/PortMap.appiconset/64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monkeydom/TCMPortMapper/914d064d4e8d37c20be3e91260881bb5bcf8c455/portmap/artwork/Assets.xcassets/PortMap.appiconset/64.png -------------------------------------------------------------------------------- /portmap/artwork/Assets.xcassets/PortMap.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "32.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "256.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "512.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "1024.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /portmap/artwork/Icons.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /portmap/artwork/Icons.xcassets/DotGreen.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "DotGreen.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "DotGreen@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /portmap/artwork/Icons.xcassets/DotGreen.imageset/DotGreen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monkeydom/TCMPortMapper/914d064d4e8d37c20be3e91260881bb5bcf8c455/portmap/artwork/Icons.xcassets/DotGreen.imageset/DotGreen.png -------------------------------------------------------------------------------- /portmap/artwork/Icons.xcassets/DotGreen.imageset/DotGreen@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monkeydom/TCMPortMapper/914d064d4e8d37c20be3e91260881bb5bcf8c455/portmap/artwork/Icons.xcassets/DotGreen.imageset/DotGreen@2x.png -------------------------------------------------------------------------------- /portmap/artwork/Icons.xcassets/DotRed.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "DotRed.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "DotRed@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /portmap/artwork/Icons.xcassets/DotRed.imageset/DotRed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monkeydom/TCMPortMapper/914d064d4e8d37c20be3e91260881bb5bcf8c455/portmap/artwork/Icons.xcassets/DotRed.imageset/DotRed.png -------------------------------------------------------------------------------- /portmap/artwork/Icons.xcassets/DotRed.imageset/DotRed@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monkeydom/TCMPortMapper/914d064d4e8d37c20be3e91260881bb5bcf8c455/portmap/artwork/Icons.xcassets/DotRed.imageset/DotRed@2x.png -------------------------------------------------------------------------------- /portmap/artwork/Icons.xcassets/DotYellow.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "DotYellow.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "DotYellow@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /portmap/artwork/Icons.xcassets/DotYellow.imageset/DotYellow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monkeydom/TCMPortMapper/914d064d4e8d37c20be3e91260881bb5bcf8c455/portmap/artwork/Icons.xcassets/DotYellow.imageset/DotYellow.png -------------------------------------------------------------------------------- /portmap/artwork/Icons.xcassets/DotYellow.imageset/DotYellow@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monkeydom/TCMPortMapper/914d064d4e8d37c20be3e91260881bb5bcf8c455/portmap/artwork/Icons.xcassets/DotYellow.imageset/DotYellow@2x.png -------------------------------------------------------------------------------- /portmap/htdocs/appcast.rss: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Port Map Changelog 5 | http://www.codingmonkeys.de/portmap/appcast.rss 6 | Most recent changes with links to updates. 7 | en 8 | 9 | Version 1.2: Small bugfixes 10 | 11 | http://www.codingmonkeys.de/portmap/version_1_2.html 12 | 13 | Fri, 12 Dec 19:20:11 +0000 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /portmap/htdocs/portmap_releasenotes.css: -------------------------------------------------------------------------------- 1 | /* Tiger Mac Help task_style.css v2.0f*/ 2 | /* */ 3 | 4 | body { 5 | margin: 2px 12px 12px 6 | } 7 | 8 | h1 { 9 | font-size: 11pt; 10 | font-family: "Lucida Grande", Arial, sans-serif; 11 | margin-bottom: 0 12 | } 13 | 14 | 15 | h2 { 16 | font-size: 9pt; 17 | font-family: "Lucida Grande", Arial, sans-serif; 18 | margin-top: 0; 19 | margin-bottom: -10px 20 | } 21 | 22 | h3 { 23 | font-size: 9pt; 24 | font-family: "Lucida Grande", Arial, sans-serif; 25 | font-weight: bold; 26 | margin-top: -4px; 27 | margin-bottom: -4px 28 | } 29 | 30 | p { 31 | font-size: 9pt; 32 | font-family: "Lucida Grande", Arial, sans-serif; 33 | line-height: 12pt; 34 | text-decoration: none 35 | } 36 | 37 | 38 | ol { 39 | font-size: 9pt; 40 | font-family: "Lucida Grande", Arial, sans-serif; 41 | line-height: 12pt; 42 | list-style-position: outside; 43 | margin-top: 12px; 44 | margin-bottom: 12px; 45 | margin-left: -18px; 46 | padding-left: 40px 47 | } 48 | 49 | 50 | ol li { 51 | margin-top: 6px; 52 | margin-bottom: 6px 53 | } 54 | 55 | 56 | ol p { 57 | margin-top: 6px; 58 | margin-bottom: 6px 59 | } 60 | 61 | 62 | ul { 63 | font-size: 9pt; 64 | font-family: "Lucida Grande", Arial, sans-serif; 65 | line-height: 12pt; 66 | list-style-type: square; 67 | list-style-position: outside; 68 | margin-top: 12px; 69 | margin-bottom: 12px; 70 | margin-left: -24px; 71 | padding-left: 40px 72 | } 73 | 74 | 75 | ul li { 76 | margin-top: 6px; 77 | margin-bottom: 6px 78 | } 79 | 80 | 81 | ul p { 82 | margin-top: 6px; 83 | margin-bottom: 6px 84 | } 85 | 86 | 87 | a { 88 | color: #00f; 89 | font-size: 9pt; 90 | font-family: "Lucida Grande", Arial, sans-serif; 91 | line-height: 12pt; 92 | text-decoration: none 93 | } 94 | 95 | 96 | a:hover { 97 | color: #00f; 98 | font-family: "Lucida Grande", Arial, sans-serif; 99 | text-decoration: underline 100 | } 101 | 102 | hr { 103 | text-decoration: none; 104 | border: solid 1px #bfbfbf 105 | } 106 | 107 | td { 108 | padding: 6px 109 | } 110 | 111 | #banner { background-color: #f2f2f2; background-repeat: no-repeat; padding: -2px 6px 0; position: fixed; top: 0; left: 0; width: 100%; height: 1.2em; float: left; border: solid 1px #bfbfbf } 112 | 113 | #caticon { 114 | margin-top: 3px; 115 | margin-bottom: -3px; 116 | margin-right: 5px; 117 | float: left; 118 | } 119 | 120 | #pagetitle { 121 | margin-top: 12px; 122 | margin-bottom: 0px; 123 | margin-left: 40px; 124 | width: 88%; 125 | border: solid 1px #fff 126 | } 127 | 128 | 129 | #mainbox { 130 | margin-top: 2349px; 131 | padding-right: 6px 132 | } 133 | 134 | #taskbox { 135 | background-color: #e6edff; 136 | list-style-type: decimal; 137 | list-style-position: outside; 138 | margin: 12px 0; 139 | padding: 2px 12px; 140 | border: solid 1px #bfbfbf 141 | } 142 | 143 | 144 | #taskbox h2 { 145 | margin-top: 8; 146 | margin-bottom: -4px 147 | } 148 | 149 | #machelp { position: absolute; top: 2px; left: 10px } 150 | 151 | #index { background-color: #f2f2f2; padding-right: 25px; top: 2px; right: 12px; width: auto; float: right } 152 | 153 | #next { 154 | position: absolute; 155 | top: 49px; 156 | left: 88% 157 | } 158 | 159 | #asindent { 160 | margin-left: 22px; 161 | font-size: 9pt; 162 | font-family: Verdana, Courier, sans-serif; 163 | } 164 | 165 | .bread { 166 | color: #00f; 167 | font-size: 8pt; 168 | margin: -9px 0 -6px 169 | } 170 | 171 | .leftborder { 172 | color: #00f; 173 | font-size: 8pt; 174 | margin: -9px 0 -6px; 175 | padding-top: 2px; 176 | padding-bottom: 3px; 177 | padding-left: 8px; 178 | border-left: 1px solid #bfbfbf 179 | } 180 | 181 | .mult { 182 | margin-top: -8px 183 | } 184 | 185 | .blue { 186 | background-color: #e6edff; 187 | margin-top: -3px; 188 | margin-bottom: -3px; 189 | padding-top: -3px; 190 | padding-bottom: -3px 191 | } 192 | 193 | .rightfloater 194 | { 195 | float: right; 196 | margin-left: 15px; 197 | } 198 | 199 | .rules { 200 | border-bottom: 1px dotted #ccc 201 | } 202 | 203 | .dots { 204 | border: dotted 1px #ccc 205 | } 206 | 207 | .seealso { 208 | margin-top: 4px; 209 | margin-bottom: 4px 210 | } 211 | code { 212 | color: black; 213 | font-size: 9pt; 214 | font-family: Verdana, Courier, sans-serif; 215 | } 216 | -------------------------------------------------------------------------------- /portmap/htdocs/version_1_1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Port Map Changelog 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 17 | 18 | 19 | 34 | 35 |
15 |

Version 1.1: Update of underlying libraries and bugfixes

16 |
20 |
    21 |
  • updated of miniupnpc library to version 1.2 - should increase compatibility with more router/gateways, e.g. the Arcor EasyBox A300.
  • 22 |
  • update of libnatpmp to libnatpmp-20081006
  • 23 |
  • fixed an issue with AVM routers that caused generation of too many and stale UPNP mappings
  • 24 |
  • fixed an issue with NAT-PMP and the current Airport Extreme Base stations that caused external IP changes not to be noticed
  • 25 |
  • fixed an issue that caused TCMPortMapper to not recognize global network changes if it was started while no network was connected
  • 26 |
  • fixed a crashing issue appearing with certain setups where UPNP devices have been discovered that inevitably lead to miniwget crashes due to missing content
  • 27 |
  • fixed too eager error reporting in case of system wake up by increasing the interval of the refresh after wake up from 1.0 to 2.0 seconds
  • 28 |
  • fixed reporting of "Router incompatible." in the case of an Apple Airport and not DSL or other network connection. Now correctly "No external Address." is displayed but mappings still can be setup to be active when the device goes online again.
  • 29 |
  • fixed an issue where quickly turning NAT-PMP port mappings on and off raised an exception instead of updating the mapping.
  • 30 |
  • fixed an issue where choosing multiple UPNP port mappings for deletion did sometimes disable the remove button.
  • 31 |
  • improved long time running UPNP setups by decreasing the regular refresh interval
  • 32 |
33 |
36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /portmap/htdocs/version_1_2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Port Map Changelog 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 17 | 18 | 19 | 27 | 28 |
15 |

Version 1.2: small bugfixes

16 |
20 |
    21 |
  • fixed an issue with TCMPortMappingTransportProtocolBoth and UPNP where port mappings would increase their public port on refresh
  • 22 |
  • fixed an issue with TCMPortMappingTransportProtocolBoth and UPNP where port mapping would leave their UDP part mapped
  • 23 |
  • fixed a small memory leak with UPNP (32 bytes per refresh complete refresh)
  • 24 |
  • improved compatibility with a bug in mDNSResponder by not continuously listening to 5350 - but only if we discovered a NAT-PMP compatible gateway. If you encounter a massive logging of mDNSResponder you now can switch Port Map off and on again to resolve this issue, until mDNSResponder is fixed by Apple.
  • 25 |
26 |
29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /portmap/htdocs/version_1_3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Port Map Changelog 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 17 | 18 | 19 | 26 | 27 |
15 |

Version 1.3: Airport Extreme Base Station and mDNSResponder havoc relief

16 |
20 |
    21 |
  • fixed an issue where Port Map would trigger a bug in the mDNSResponder after machine wake if the computer is in a Network that supports NAT-PMP (e.g. Apple Airport Extreme Base Stations) and Back to My Mac is enabled.
  • 22 |
  • fixed an issue where Port Map would trigger a bug in the mDNSResponder after network change to a Network which supports NAT-PMP (e.g. Apple Airport Extreme Base Stations) and Back to My Mac is enabled.
  • 23 |
  • if you still encounter a massive logging of mDNSResponder you now can switch Port Map off and on again to resolve this issue, until mDNSResponder is fixed by Apple.
  • 24 |
25 |
28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /portmap/htdocs/version_1_3_1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Port Map Changelog 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 17 | 18 | 19 | 24 | 25 |
15 |

Version 1.3.1: fixed a threading related crash

16 |
20 |
    21 |
  • fixed a crash in stopListeningToExternalIPAddressChanges (see Issue #31 for a crashlog)
  • 22 |
23 |
26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /portmap/htdocs/version_2_0.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Port Map Changelog 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 17 | 18 | 19 | 24 | 25 |
15 |

Version 2.0: Library update, IPv6 support, Port Map app redesign

16 |
20 | 23 |
26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /portmap/main.m: -------------------------------------------------------------------------------- 1 | // main.m 2 | 3 | @import Cocoa; 4 | 5 | int main(int argc, const char * argv[]) { 6 | return NSApplicationMain(argc, argv); 7 | } 8 | -------------------------------------------------------------------------------- /portmap/miniupnpc-LICENSE.txt: -------------------------------------------------------------------------------- 1 | MiniUPnPc 2 | Copyright (c) 2005-2016, Thomas BERNARD 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | * The name of the author may not be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | POSSIBILITY OF SUCH DAMAGE. 27 | 28 | -------------------------------------------------------------------------------- /ruby/mdnskiller.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'socket' 3 | require 'ipaddr' 4 | 5 | port = 5350 6 | 7 | print "Listening for NAT-PMP public IP changes:\n" 8 | 9 | socket = UDPSocket.new 10 | while true do 11 | begin 12 | # socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, true) 13 | # socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEPORT, true) 14 | socket.bind("224.0.0.1",port) 15 | addr = '0.0.0.0' 16 | host = Socket.gethostname 17 | # socket.setsockopt(Socket::IPPROTO_IP, Socket::IP_ADD_MEMBERSHIP, mreq) 18 | loop do 19 | data, sender = socket.recvfrom(100) 20 | host = sender[3] 21 | received = data.unpack('CCnNN') 22 | # A compatible NAT gateway MUST generate a response with the following 23 | # format: 24 | # 25 | # 0 1 2 3 26 | # 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 27 | # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 28 | # | Vers = 0 | OP = 128 + 0 | Result Code | 29 | # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 30 | # | Seconds Since Start of Epoch | 31 | # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 32 | # | Public IP Address (a.b.c.d) | 33 | # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 34 | print "#{Time.now} #{host}: Received new Public Address packet: IP #{IPAddr.ntop(data[8..12])} - Vers= #{received[0]}, OP = #{received[1]}, ResultCode = #{received[2]}, Epoch Seconds = #{received[3]}\n" 35 | end 36 | rescue Exception 37 | end 38 | end -------------------------------------------------------------------------------- /ruby/nat-pmp-ip-broadcaster.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'socket' 3 | require 'ipaddr' 4 | 5 | port = 5350 6 | # A compatible NAT gateway MUST generate a response with the following 7 | # format: 8 | # 9 | # 0 1 2 3 10 | # 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 11 | # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 12 | # | Vers = 0 | OP = 128 + 0 | Result Code | 13 | # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 14 | # | Seconds Since Start of Epoch | 15 | # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 16 | # | Public IP Address (a.b.c.d) | 17 | # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 18 | 19 | 20 | uni_socket = UDPSocket.new 21 | uni_socket.connect("224.0.0.1",port) 22 | secondsSinceStart = 123 23 | publicIPAddress = IPAddr.new("222.66.55.55").to_i 24 | 25 | loopCount = 0 26 | 27 | while true do 28 | uni_socket.send([0,128,0,secondsSinceStart+loopCount,publicIPAddress+loopCount].pack('CCnNN'),0) 29 | sleep 10 30 | # loopCount += 1 31 | end 32 | -------------------------------------------------------------------------------- /ruby/nat-pmp-listener.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'socket' 3 | require 'ipaddr' 4 | 5 | port = 5350 6 | 7 | print "Listening for NAT-PMP public IP changes:\n" 8 | 9 | socket = UDPSocket.new 10 | socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, true) 11 | socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEPORT, true) 12 | socket.bind("224.0.0.1",port) 13 | addr = '0.0.0.0' 14 | host = Socket.gethostname 15 | # socket.setsockopt(Socket::IPPROTO_IP, Socket::IP_ADD_MEMBERSHIP, mreq) 16 | loop do 17 | data, sender = socket.recvfrom(100) 18 | host = sender[3] 19 | received = data.unpack('CCnNN') 20 | # A compatible NAT gateway MUST generate a response with the following 21 | # format: 22 | # 23 | # 0 1 2 3 24 | # 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 25 | # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 26 | # | Vers = 0 | OP = 128 + 0 | Result Code | 27 | # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 28 | # | Seconds Since Start of Epoch | 29 | # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 30 | # | Public IP Address (a.b.c.d) | 31 | # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 32 | print "#{Time.now} #{host}: Received new Public Address packet: IP #{IPAddr.ntop(data[8..12])} - Vers= #{received[0]}, OP = #{received[1]}, ResultCode = #{received[2]}, Epoch Seconds = #{received[3]}\n" 33 | end -------------------------------------------------------------------------------- /set_build_number.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | git=$(sh /etc/profile; which git) 4 | number_of_commits=$("$git" rev-list --first-parent --count HEAD) 5 | git_release_version=$("$git" describe --tags --always) 6 | 7 | target_plist="$TARGET_BUILD_DIR/$INFOPLIST_PATH" 8 | dsym_plist="$DWARF_DSYM_FOLDER_PATH/$DWARF_DSYM_FILE_NAME/Contents/Info.plist" 9 | 10 | 11 | 12 | private_revision_key="CFBundleVersion" 13 | 14 | if [ "$1" != "" ]; then 15 | private_revision_key=$1 16 | # hack to not try to write a custom key to a plist that doesn't have it 17 | dsym_plist=target_plist 18 | fi 19 | 20 | for plist in "$target_plist" "$dsym_plist"; do 21 | if [ -f "$plist" ]; then 22 | echo "/usr/libexec/PlistBuddy -c \"Set :$private_revision_key $number_of_commits\"" "$plist" 23 | /usr/libexec/PlistBuddy -c "Set :$private_revision_key $number_of_commits" "$plist" 24 | fi 25 | done --------------------------------------------------------------------------------