Skip to content

Commit

Permalink
minor lease table change and added entry in plist to prevent multitas…
Browse files Browse the repository at this point in the history
…king
  • Loading branch information
tlodge committed Oct 28, 2010
1 parent 8b747fb commit 8e57b9a
Show file tree
Hide file tree
Showing 42 changed files with 1,006 additions and 983 deletions.
2 changes: 1 addition & 1 deletion Classes/NameResolver.h
Expand Up @@ -9,7 +9,7 @@
#import <Foundation/Foundation.h>
#import "LeaseRecord.h"
#import "LeaseObject.h"

#include <netinet/ip.h>
@interface NameResolver : NSObject {

}
Expand Down
28 changes: 21 additions & 7 deletions Classes/NameResolver.m
Expand Up @@ -16,6 +16,7 @@ +(void) createMacLookupTable;
+(void) createIPLookupTable;
+(void) addObservers;
+(void) createLocalNetmask;
+(BOOL) isIP:(NSString *) string;
@end

NSMutableDictionary *iplookuptable;
Expand Down Expand Up @@ -81,9 +82,9 @@ +(void) createLocalNetmask{

+(void) createMacLookupTable{
/*
* No longer read on cahced copy from file. Assume that router will give us what we need.
* needed for remembering application names!
*/
/*

NSString *docsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *path = [docsDirectory stringByAppendingPathComponent:@"mactable.txt"];
NSFileManager *fileManager = [NSFileManager defaultManager];
Expand All @@ -94,9 +95,9 @@ +(void) createMacLookupTable{
maclookuptable = [[NSMutableDictionary dictionaryWithCapacity:10] retain];
}
[fileManager release];
*/

maclookuptable = [[NSMutableDictionary dictionaryWithCapacity:10] retain];

//maclookuptable = [[NSMutableDictionary dictionaryWithCapacity:10] retain];
}

+(void) addObservers{
Expand Down Expand Up @@ -219,6 +220,9 @@ +(void) newLease:(NSNotification *) n{

LeaseObject *lobj = (LeaseObject *) [n object];

if ([[lobj action] isEqualToString:@"del"]){
return;
}
if (![[lobj action] isEqualToString:@"upd"]){
[iplookuptable setObject:[lobj macaddr] forKey:[lobj ipaddr]];
}else{
Expand All @@ -230,12 +234,22 @@ +(void) newLease:(NSNotification *) n{

NSString* humanname = [maclookuptable objectForKey:[lobj macaddr]];


//if (humanname == NULL){
/*
* Only give the name of the machine as an IP address if our current name is an IP
* or if we don't yet have a name (i.e hwdb returns NULL for name)
*/
if (humanname == NULL || [self isIP:humanname]){
humanname = [[lobj name] isEqualToString:@"NULL"] ? [lobj ipaddr] : [lobj name];
[maclookuptable setObject:humanname forKey:[lobj macaddr]];
[self writeMacTable];
//}
}
}

+(BOOL) isIP:(NSString *) string{
struct in_addr pin;
int success = inet_aton([string UTF8String], &pin);
if (success == 1) return TRUE;
return FALSE;
}

+(void) writeMacTable{
Expand Down
4 changes: 4 additions & 0 deletions Classes/PortLookup.m
Expand Up @@ -83,6 +83,10 @@ +(void) dealloc{
if (tcplookup[i] != NULL)
[tcplookup[i] release];
}
for (int i =0; i < 143; i++){
if (protolookup[i] != NULL)
[protolookup[i] release];
}
[super dealloc];

}
Expand Down
2 changes: 2 additions & 0 deletions ContentionApp-Info.plist
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIApplicationExitsOnSuspend</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDisplayName</key>
Expand Down

0 comments on commit 8e57b9a

Please sign in to comment.