diff --git a/English.lproj/MainMenu.nib/classes.nib b/English.lproj/MainMenu.nib/classes.nib index b9b4b09..f949b9b 100644 --- a/English.lproj/MainMenu.nib/classes.nib +++ b/English.lproj/MainMenu.nib/classes.nib @@ -1,4 +1,19 @@ { - IBClasses = ({CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }); + IBClasses = ( + {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, + { + ACTIONS = {createMapping = id; destroyMapping = id; }; + CLASS = XzibitController; + LANGUAGE = ObjC; + OUTLETS = { + localCreatePort = NSTextField; + localDestroyPort = NSTextField; + mappingDuration = NSTextField; + natCreatePort = NSTextField; + statusField = NSTextField; + }; + SUPERCLASS = NSObject; + } + ); IBVersion = 1; } \ No newline at end of file diff --git a/English.lproj/MainMenu.nib/keyedobjects.nib b/English.lproj/MainMenu.nib/keyedobjects.nib index 28d30f2..f2369ab 100644 Binary files a/English.lproj/MainMenu.nib/keyedobjects.nib and b/English.lproj/MainMenu.nib/keyedobjects.nib differ diff --git a/PmpMyApp.xcodeproj/project.pbxproj b/PmpMyApp.xcodeproj/project.pbxproj index b214e3a..28306df 100644 --- a/PmpMyApp.xcodeproj/project.pbxproj +++ b/PmpMyApp.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 2F18D6740B7C6AF400149D44 /* XzibitController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2F18D6730B7C6AF400149D44 /* XzibitController.m */; }; 2F5A48720B75598F0052B0C1 /* pmpmapper.c in Sources */ = {isa = PBXBuildFile; fileRef = 2F5A48710B75598F0052B0C1 /* pmpmapper.c */; }; 2F5A48900B75658F0052B0C1 /* pmpmapper.c in Sources */ = {isa = PBXBuildFile; fileRef = 2F5A48710B75598F0052B0C1 /* pmpmapper.c */; }; 2F901ED00B7AEDB5004FF42C /* route.c in Sources */ = {isa = PBXBuildFile; fileRef = 2F901ECF0B7AEDB5004FF42C /* route.c */; }; @@ -27,6 +28,8 @@ 29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; 2F18D56B0B7C516D00149D44 /* draft-cheshire-nat-pmp.rtf */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = "draft-cheshire-nat-pmp.rtf"; path = "doc/draft-cheshire-nat-pmp.rtf"; sourceTree = ""; }; 2F18D56C0B7C516D00149D44 /* draft-cheshire-nat-pmp.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = "draft-cheshire-nat-pmp.txt"; path = "doc/draft-cheshire-nat-pmp.txt"; sourceTree = ""; }; + 2F18D6720B7C6AF400149D44 /* XzibitController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XzibitController.h; path = source/XzibitController.h; sourceTree = ""; }; + 2F18D6730B7C6AF400149D44 /* XzibitController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XzibitController.m; path = source/XzibitController.m; sourceTree = ""; }; 2F5A48700B75598F0052B0C1 /* pmpmapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pmpmapper.h; path = source/pmpmapper.h; sourceTree = ""; }; 2F5A48710B75598F0052B0C1 /* pmpmapper.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = pmpmapper.c; path = source/pmpmapper.c; sourceTree = ""; }; 2F5A488A0B7565810052B0C1 /* PMPMapper */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = PMPMapper; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -60,6 +63,8 @@ isa = PBXGroup; children = ( 2F5A486C0B7559600052B0C1 /* NAT-PMP */, + 2F18D6720B7C6AF400149D44 /* XzibitController.h */, + 2F18D6730B7C6AF400149D44 /* XzibitController.m */, ); name = Classes; sourceTree = ""; @@ -234,6 +239,7 @@ 8D11072D0486CEB800E47090 /* main.m in Sources */, 2F5A48720B75598F0052B0C1 /* pmpmapper.c in Sources */, 2F901ED00B7AEDB5004FF42C /* route.c in Sources */, + 2F18D6740B7C6AF400149D44 /* XzibitController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -269,6 +275,7 @@ GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 0; INSTALL_PATH = "$(HOME)/bin"; + OTHER_CFLAGS = "-DPMP_DEBUG"; PREBINDING = NO; PRODUCT_NAME = PMPMapper; ZERO_LINK = YES; @@ -287,6 +294,7 @@ GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_MODEL_TUNING = G5; INSTALL_PATH = "$(HOME)/bin"; + OTHER_CFLAGS = "-DPMP_DEBUG"; PREBINDING = NO; PRODUCT_NAME = PMPMapper; ZERO_LINK = NO; diff --git a/PmpMyApp.xcodeproj/tyler.mode1 b/PmpMyApp.xcodeproj/tyler.mode1 index b5c9b02..6b03099 100644 --- a/PmpMyApp.xcodeproj/tyler.mode1 +++ b/PmpMyApp.xcodeproj/tyler.mode1 @@ -265,8 +265,7 @@ PBXSmartGroupTreeModuleOutlineStateSelectionKey - 6 - 2 + 8 1 0 @@ -309,7 +308,7 @@ PBXProjectModuleGUID 1CE0B20306471E060097A5F4 PBXProjectModuleLabel - pmpmapper.c + XzibitController.m PBXSplitModuleInNavigatorKey Split0 @@ -317,11 +316,11 @@ PBXProjectModuleGUID 1CE0B20406471E060097A5F4 PBXProjectModuleLabel - pmpmapper.c + XzibitController.m _historyCapacity 0 bookmark - 2F18D65A0B7C688B00149D44 + 2F18D69D0B7C6D9900149D44 history 2F5A489C0B7565AE0052B0C1 @@ -330,8 +329,10 @@ 2F901EF70B7AEED5004FF42C 2F9021510B7BE0FB004FF42C 2F18D5750B7C51B000149D44 - 2F18D62D0B7C661600149D44 - 2F18D62E0B7C661600149D44 + 2F18D6800B7C6CA900149D44 + 2F18D6950B7C6D8000149D44 + 2F18D6960B7C6D8000149D44 + 2F18D6970B7C6D8000149D44 prevStack @@ -343,8 +344,13 @@ 2F901ED80B7AEDBC004FF42C 2F901EE10B7AEE09004FF42C 2F18D5770B7C51B000149D44 - 2F18D60F0B7C60BE00149D44 - 2F18D62F0B7C661600149D44 + 2F18D66A0B7C68EB00149D44 + 2F18D6840B7C6CA900149D44 + 2F18D6850B7C6CA900149D44 + 2F18D6860B7C6CA900149D44 + 2F18D6870B7C6CA900149D44 + 2F18D6980B7C6D8000149D44 + 2F18D6990B7C6D8000149D44 SplitCount @@ -376,7 +382,7 @@ GeometryConfiguration Frame - {{0, 883}, {951, 0}} + {{0, 884}, {951, 0}} RubberWindowFrame 1 104 1159 924 0 0 1680 1028 @@ -402,9 +408,9 @@ TableOfContents - 2F18D5540B7C4C1900149D44 + 2F18D66C0B7C68EB00149D44 1CE0B1FE06471DED0097A5F4 - 2F18D5550B7C4C1900149D44 + 2F18D66D0B7C68EB00149D44 1CE0B20306471E060097A5F4 1CE0B20506471E060097A5F4 @@ -538,11 +544,6 @@ 5 WindowOrderList - 2F18D5FC0B7C5F9400149D44 - 2F18D5FD0B7C5F9400149D44 - 2F5A48CE0B756D650052B0C1 - 1CD10A99069EF8BA00B06720 - 2F18D5FA0B7C5F9400149D44 2F5A48970B7565A60052B0C1 1C0AD2B3069F1EA900FABCE6 /Software/Subversion/trunk/PmpMyApp/PmpMyApp.xcodeproj @@ -591,7 +592,7 @@ ContentConfiguration PBXBuildLogShowsTranscriptDefaultKey - {{0, 209}, {620, 261}} + {{0, 149}, {620, 321}} PBXProjectModuleGUID XCMainBuildResultsModuleGUID PBXProjectModuleLabel @@ -629,7 +630,7 @@ TableOfContents 2F5A48970B7565A60052B0C1 - 2F18D55F0B7C4E5500149D44 + 2F18D66E0B7C68EB00149D44 1CD0528F0623707200166675 XCMainBuildResultsModuleGUID @@ -999,9 +1000,9 @@ TableOfContents 1C0AD2B3069F1EA900FABCE6 - 2F18D5560B7C4C1900149D44 + 2F18D66F0B7C68EB00149D44 1CD0528B0623707200166675 - 2F18D5570B7C4C1900149D44 + 2F18D6700B7C68EB00149D44 ToolbarConfiguration xcode.toolbar.config.run diff --git a/PmpMyApp.xcodeproj/tyler.pbxuser b/PmpMyApp.xcodeproj/tyler.pbxuser index 82a8099..935aabc 100644 --- a/PmpMyApp.xcodeproj/tyler.pbxuser +++ b/PmpMyApp.xcodeproj/tyler.pbxuser @@ -9,8 +9,8 @@ }; 29B97313FDCFA39411CA2CEA /* Project object */ = { activeBuildConfigurationName = Debug; - activeExecutable = 2F5A488B0B7565810052B0C1 /* PMPMapper */; - activeTarget = 2F5A48890B7565810052B0C1 /* PMPMapper */; + activeExecutable = 2F5A484B0B7558670052B0C1 /* PmpMyApp */; + activeTarget = 8D1107260486CEB800E47090 /* PmpMyApp */; addToTargets = ( 8D1107260486CEB800E47090 /* PmpMyApp */, ); @@ -67,17 +67,24 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 192695317; - PBXWorkspaceStateSaveDate = 192695317; + PBXPerProjectTemplateStateSaveDate = 192702654; + PBXWorkspaceStateSaveDate = 192702654; }; perUserProjectItems = { 2F18D5750B7C51B000149D44 /* PBXTextBookmark */ = 2F18D5750B7C51B000149D44 /* PBXTextBookmark */; 2F18D5770B7C51B000149D44 /* PBXTextBookmark */ = 2F18D5770B7C51B000149D44 /* PBXTextBookmark */; - 2F18D60F0B7C60BE00149D44 /* PBXTextBookmark */ = 2F18D60F0B7C60BE00149D44 /* PBXTextBookmark */; - 2F18D62D0B7C661600149D44 /* PBXTextBookmark */ = 2F18D62D0B7C661600149D44 /* PBXTextBookmark */; - 2F18D62E0B7C661600149D44 /* PBXTextBookmark */ = 2F18D62E0B7C661600149D44 /* PBXTextBookmark */; - 2F18D62F0B7C661600149D44 /* PBXTextBookmark */ = 2F18D62F0B7C661600149D44 /* PBXTextBookmark */; - 2F18D65A0B7C688B00149D44 /* PBXTextBookmark */ = 2F18D65A0B7C688B00149D44 /* PBXTextBookmark */; + 2F18D66A0B7C68EB00149D44 /* PBXTextBookmark */ = 2F18D66A0B7C68EB00149D44 /* PBXTextBookmark */; + 2F18D6800B7C6CA900149D44 /* PBXTextBookmark */ = 2F18D6800B7C6CA900149D44 /* PBXTextBookmark */; + 2F18D6840B7C6CA900149D44 /* PBXTextBookmark */ = 2F18D6840B7C6CA900149D44 /* PBXTextBookmark */; + 2F18D6850B7C6CA900149D44 /* PBXTextBookmark */ = 2F18D6850B7C6CA900149D44 /* PBXTextBookmark */; + 2F18D6860B7C6CA900149D44 /* PBXTextBookmark */ = 2F18D6860B7C6CA900149D44 /* PBXTextBookmark */; + 2F18D6870B7C6CA900149D44 /* PBXTextBookmark */ = 2F18D6870B7C6CA900149D44 /* PBXTextBookmark */; + 2F18D6950B7C6D8000149D44 /* PBXTextBookmark */ = 2F18D6950B7C6D8000149D44 /* PBXTextBookmark */; + 2F18D6960B7C6D8000149D44 /* PBXTextBookmark */ = 2F18D6960B7C6D8000149D44 /* PBXTextBookmark */; + 2F18D6970B7C6D8000149D44 /* PBXTextBookmark */ = 2F18D6970B7C6D8000149D44 /* PBXTextBookmark */; + 2F18D6980B7C6D8000149D44 /* PBXTextBookmark */ = 2F18D6980B7C6D8000149D44 /* PBXTextBookmark */; + 2F18D6990B7C6D8000149D44 /* PBXTextBookmark */ = 2F18D6990B7C6D8000149D44 /* PBXTextBookmark */; + 2F18D69D0B7C6D9900149D44 /* PBXTextBookmark */ = 2F18D69D0B7C6D9900149D44 /* PBXTextBookmark */; 2F5A489C0B7565AE0052B0C1 /* PBXTextBookmark */ = 2F5A489C0B7565AE0052B0C1 /* PBXTextBookmark */; 2F5A489D0B7565AE0052B0C1 /* PBXTextBookmark */ = 2F5A489D0B7565AE0052B0C1 /* PBXTextBookmark */; 2F5A48A00B7565AE0052B0C1 /* PBXTextBookmark */ = 2F5A48A00B7565AE0052B0C1 /* PBXTextBookmark */; @@ -122,56 +129,140 @@ vrLen = 1930; vrLoc = 0; }; - 2F18D60F0B7C60BE00149D44 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 2F5A48710B75598F0052B0C1 /* pmpmapper.c */; - name = "pmpmapper.c: 151"; - rLen = 0; - rLoc = 4269; - rType = 0; - vrLen = 754; - vrLoc = 3859; - }; - 2F18D62D0B7C661600149D44 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 2F5A48700B75598F0052B0C1 /* pmpmapper.h */; - name = "pmpmapper.h: "; - rLen = 0; - rLoc = 1128; - rType = 0; - vrLen = 1117; - vrLoc = 201; - }; - 2F18D62E0B7C661600149D44 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 2F5A48710B75598F0052B0C1 /* pmpmapper.c */; - name = "pmpmapper.c: 151"; - rLen = 0; - rLoc = 4269; - rType = 0; - vrLen = 1951; - vrLoc = 3397; - }; - 2F18D62F0B7C661600149D44 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 2F5A48700B75598F0052B0C1 /* pmpmapper.h */; - name = "pmpmapper.h: "; - rLen = 0; - rLoc = 1128; - rType = 0; - vrLen = 1117; - vrLoc = 201; - }; - 2F18D65A0B7C688B00149D44 /* PBXTextBookmark */ = { + 2F18D66A0B7C68EB00149D44 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 2F5A48710B75598F0052B0C1 /* pmpmapper.c */; name = "pmpmapper.c: 279"; rLen = 0; - rLoc = 8097; + rLoc = 8035; rType = 0; vrLen = 1588; vrLoc = 0; }; + 2F18D6720B7C6AF400149D44 /* XzibitController.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {904, 847}}"; + sepNavSelRange = "{406, 77}"; + sepNavVisRect = "{{0, 0}, {904, 847}}"; + }; + }; + 2F18D6730B7C6AF400149D44 /* XzibitController.m */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {904, 847}}"; + sepNavSelRange = "{824, 0}"; + sepNavVisRect = "{{0, 0}, {904, 847}}"; + }; + }; + 2F18D6800B7C6CA900149D44 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 2F18D6720B7C6AF400149D44 /* XzibitController.h */; + name = "XzibitController.h: 19"; + rLen = 77; + rLoc = 406; + rType = 0; + vrLen = 490; + vrLoc = 0; + }; + 2F18D6840B7C6CA900149D44 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 2F5A48700B75598F0052B0C1 /* pmpmapper.h */; + name = "pmpmapper.h: 26"; + rLen = 0; + rLoc = 439; + rType = 0; + vrLen = 808; + vrLoc = 35; + }; + 2F18D6850B7C6CA900149D44 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 2F18D6720B7C6AF400149D44 /* XzibitController.h */; + name = "XzibitController.h: 19"; + rLen = 77; + rLoc = 406; + rType = 0; + vrLen = 490; + vrLoc = 0; + }; + 2F18D6860B7C6CA900149D44 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 2F18D6730B7C6AF400149D44 /* XzibitController.m */; + name = "XzibitController.m: 19"; + rLen = 0; + rLoc = 714; + rType = 0; + vrLen = 456; + vrLoc = 0; + }; + 2F18D6870B7C6CA900149D44 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 2F5A48710B75598F0052B0C1 /* pmpmapper.c */; + name = "pmpmapper.c: 237"; + rLen = 0; + rLoc = 6828; + rType = 0; + vrLen = 1486; + vrLoc = 6002; + }; + 2F18D6950B7C6D8000149D44 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 2F5A48700B75598F0052B0C1 /* pmpmapper.h */; + name = "pmpmapper.h: pmp_destroy_map"; + rLen = 0; + rLoc = 1499; + rType = 0; + vrLen = 1260; + vrLoc = 284; + }; + 2F18D6960B7C6D8000149D44 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 2F5A48710B75598F0052B0C1 /* pmpmapper.c */; + name = "pmpmapper.c: 244"; + rLen = 0; + rLoc = 7071; + rType = 0; + vrLen = 1533; + vrLoc = 6038; + }; + 2F18D6970B7C6D8000149D44 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 2F18D6730B7C6AF400149D44 /* XzibitController.m */; + name = "XzibitController.m: 19"; + rLen = 0; + rLoc = 714; + rType = 0; + vrLen = 456; + vrLoc = 0; + }; + 2F18D6980B7C6D8000149D44 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 2F5A48700B75598F0052B0C1 /* pmpmapper.h */; + name = "pmpmapper.h: pmp_destroy_map"; + rLen = 0; + rLoc = 1499; + rType = 0; + vrLen = 1260; + vrLoc = 284; + }; + 2F18D6990B7C6D8000149D44 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 2F5A48710B75598F0052B0C1 /* pmpmapper.c */; + name = "pmpmapper.c: 244"; + rLen = 0; + rLoc = 7071; + rType = 0; + vrLen = 1533; + vrLoc = 6038; + }; + 2F18D69D0B7C6D9900149D44 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 2F18D6730B7C6AF400149D44 /* XzibitController.m */; + name = "XzibitController.m: 34"; + rLen = 0; + rLoc = 824; + rType = 0; + vrLen = 1069; + vrLoc = 0; + }; 2F5A484B0B7558670052B0C1 /* PmpMyApp */ = { isa = PBXExecutable; activeArgIndex = 2147483647; @@ -185,6 +276,7 @@ customDataFormattersEnabled = 1; debuggerPlugin = GDBDebugging; disassemblyDisplayState = 0; + dylibVariantSuffix = ""; enableDebugStr = 1; environmentEntries = ( ); @@ -209,17 +301,17 @@ }; 2F5A48700B75598F0052B0C1 /* pmpmapper.h */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {904, 1036}}"; - sepNavSelRange = "{1128, 0}"; - sepNavVisRect = "{{0, 190}, {904, 846}}"; + sepNavIntBoundsRect = "{{0, 0}, {904, 1092}}"; + sepNavSelRange = "{1499, 0}"; + sepNavVisRect = "{{0, 245}, {904, 847}}"; sepNavWindowFrame = "{{1954, -14}, {939, 979}}"; }; }; 2F5A48710B75598F0052B0C1 /* pmpmapper.c */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {904, 4102}}"; - sepNavSelRange = "{8097, 0}"; - sepNavVisRect = "{{0, 0}, {904, 847}}"; + sepNavIntBoundsRect = "{{0, 0}, {904, 4158}}"; + sepNavSelRange = "{7071, 0}"; + sepNavVisRect = "{{0, 2888}, {904, 847}}"; }; }; 2F5A48890B7565810052B0C1 /* PMPMapper */ = { @@ -317,7 +409,7 @@ fRef = 2F5A48710B75598F0052B0C1 /* pmpmapper.c */; name = "PMPMapper.c: 29"; rLen = 0; - rLoc = 7302; + rLoc = 7240; rType = 0; vrLen = 951; vrLoc = 0; diff --git a/source/XzibitController.h b/source/XzibitController.h new file mode 100644 index 0000000..0112d1a --- /dev/null +++ b/source/XzibitController.h @@ -0,0 +1,23 @@ +// +// XzibitController.h +// PmpMyApp +// +// Created by R. Tyler Ballance on 2/9/07. +// Copyright 2007 bleep. LLC. All rights reserved. +// + +#import + + +@interface XzibitController : NSObject { + IBOutlet NSTextField *localCreatePort; + IBOutlet NSTextField *natCreatePort; + IBOutlet NSTextField *mappingDuration; + IBOutlet NSTextField *localDestroyPort; + IBOutlet NSTextField *statusField; +} + +- (IBAction)createMapping:(id)sender; +- (IBAction)destroyMapping:(id)sender; + +@end diff --git a/source/XzibitController.m b/source/XzibitController.m new file mode 100644 index 0000000..d8f917e --- /dev/null +++ b/source/XzibitController.m @@ -0,0 +1,44 @@ +// +// XzibitController.m +// PmpMyApp +// +// Created by R. Tyler Ballance on 2/9/07. +// Copyright 2007 bleep. LLC. All rights reserved. +// + +#import "XzibitController.h" +#include "pmpmapper.h" + +@implementation XzibitController + +- (IBAction)createMapping:(id)sender +{ + int privateport = [localCreatePort intValue]; + int publicport = [natCreatePort intValue]; + int duration = [mappingDuration intValue]; + + if (pmp_create_map(PMP_MAP_TCP,privateport,publicport,(duration * 60)) != NULL) + { + [statusField setStringValue:[NSString stringWithFormat:@"Mapping for port %d created with external port %d", privateport, publicport]]; + } + else + { + [statusField setStringValue:@"Failed to properly create the mapping"]; + } +} + +- (IBAction)destroyMapping:(id)sender +{ + int privateport = [localDestroyPort intValue]; + + if (pmp_destroy_map(PMP_MAP_TCP,privateport) != NULL) + { + [statusField setStringValue:[NSString stringWithFormat:@"Mapping for port %d destroyed", privateport]]; + } + else + { + [statusField setStringValue:@"Failed to properly destroy the mapping"]; + } +} + +@end diff --git a/source/pmpmapper.c b/source/pmpmapper.c index 4cf57e3..cedd60b 100644 --- a/source/pmpmapper.c +++ b/source/pmpmapper.c @@ -27,14 +27,16 @@ static void double_timeout(struct timeval *to) } /*! - * pmp_get_public(struct sockaddr_in *) will return a sockaddr_in + * pmp_get_public() will return a sockaddr_in * structure representing the publicly facing IP address of the * default NAT gateway. The function will return NULL if: * - The gateway doesn't support NAT-PMP * - The gateway errors in some other spectacular fashion */ -struct sockaddr_in *pmp_get_public(struct sockaddr_in *gateway) +struct sockaddr_in *pmp_get_public() { + struct sockaddr_in *gateway = default_gw(); + if (gateway == NULL) { fprintf(stderr, "Cannot request public IP from a NULL gateway!\n"); @@ -134,11 +136,13 @@ iterate: } /*! - * pmp_create_map(struct sockaddr_in *,uint8_t,uint16_t,uint16_t,uint32_t) + * pmp_create_map(uint8_t,uint16_t,uint16_t,uint32_t) * will return NULL on error, or a pointer to the pmp_map_response_t type */ -pmp_map_response_t *pmp_create_map(struct sockaddr_in *gateway, uint8_t type, uint16_t privateport, uint16_t publicport, uint32_t lifetime) +pmp_map_response_t *pmp_create_map(uint8_t type, uint16_t privateport, uint16_t publicport, uint32_t lifetime) { + struct sockaddr_in *gateway = default_gw(); + if (gateway == NULL) { fprintf(stderr, "Cannot create mapping on a NULL gateway!\n"); @@ -230,14 +234,14 @@ iterate: } /*! - * pmp_destroy_map(struct sockaddr_in *,uint8_t,uint16_t) + * pmp_destroy_map(uint8_t,uint16_t) * will return NULL on error, or a pointer to the pmp_map_response_t type */ -pmp_map_response_t *pmp_destroy_map(struct sockaddr_in *gateway, uint8_t type, uint16_t privateport) +pmp_map_response_t *pmp_destroy_map(uint8_t type, uint16_t privateport) { pmp_map_response_t *response = NULL; - if ((response = pmp_create_map(gateway, type, privateport, 0, 0)) == NULL) + if ((response = pmp_create_map(type, privateport, 0, 0)) == NULL) { fprintf(stderr, "Failed to properly destroy mapping for %d!\n", privateport); return NULL; diff --git a/source/pmpmapper.h b/source/pmpmapper.h index 7eb79f6..47adf68 100644 --- a/source/pmpmapper.h +++ b/source/pmpmapper.h @@ -23,7 +23,7 @@ #include "route.h" // Comment out to disable building main() -#define PMP_DEBUG +//#define PMP_DEBUG #define PMP_VERSION 0 #define PMP_PORT 5351 @@ -71,8 +71,8 @@ typedef struct { uint32_t lifetime; } pmp_map_response_t; -struct sockaddr_in *pmp_get_public(struct sockaddr_in *gateway); -pmp_map_response_t *pmp_create_map(struct sockaddr_in *gateway, uint8_t type, uint16_t privateport, uint16_t publicport, uint32_t lifetime); -pmp_map_response_t *pmp_destroy_map(struct sockaddr_in *gateway, uint8_t type, uint16_t privateport); +struct sockaddr_in *pmp_get_public(); +pmp_map_response_t *pmp_create_map(uint8_t type, uint16_t privateport, uint16_t publicport, uint32_t lifetime); +pmp_map_response_t *pmp_destroy_map(uint8_t type, uint16_t privateport); #endif \ No newline at end of file