|
Revision 54, 1.0 KB
(checked in by tyler, 4 years ago)
|
- Finish implementing the little GUI app
|
| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | #import "XzibitController.h" |
|---|
| 10 | #include "pmpmapper.h" |
|---|
| 11 | |
|---|
| 12 | @implementation XzibitController |
|---|
| 13 | |
|---|
| 14 | - (IBAction)createMapping:(id)sender |
|---|
| 15 | { |
|---|
| 16 | int privateport = [localCreatePort intValue]; |
|---|
| 17 | int publicport = [natCreatePort intValue]; |
|---|
| 18 | int duration = [mappingDuration intValue]; |
|---|
| 19 | |
|---|
| 20 | if (pmp_create_map(PMP_MAP_TCP,privateport,publicport,(duration * 60)) != NULL) |
|---|
| 21 | { |
|---|
| 22 | [statusField setStringValue:[NSString stringWithFormat:@"Mapping for port %d created with external port %d", privateport, publicport]]; |
|---|
| 23 | } |
|---|
| 24 | else |
|---|
| 25 | { |
|---|
| 26 | [statusField setStringValue:@"Failed to properly create the mapping"]; |
|---|
| 27 | } |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | - (IBAction)destroyMapping:(id)sender |
|---|
| 31 | { |
|---|
| 32 | int privateport = [localDestroyPort intValue]; |
|---|
| 33 | |
|---|
| 34 | if (pmp_destroy_map(PMP_MAP_TCP,privateport) != NULL) |
|---|
| 35 | { |
|---|
| 36 | [statusField setStringValue:[NSString stringWithFormat:@"Mapping for port %d destroyed", privateport]]; |
|---|
| 37 | } |
|---|
| 38 | else |
|---|
| 39 | { |
|---|
| 40 | [statusField setStringValue:@"Failed to properly destroy the mapping"]; |
|---|
| 41 | } |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | @end |
|---|