-
Notifications
You must be signed in to change notification settings - Fork 1
/
DistributedPacket.m
93 lines (72 loc) · 1.65 KB
/
DistributedPacket.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//
// DistributedPacket.m
// v002PacketCapture
//
// Created by vade on 5/7/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import "DistributedPacket.h"
#define v002_MAX_CAPTURED_PACKETS 50
@interface DistributedPacket ()
@property (atomic, readwrite, retain) NSMutableArray * mutablePacketArray;
@property (atomic, readwrite, retain) NSMutableSet * mutableIPSet;
@end
@implementation DistributedPacket
@synthesize mutablePacketArray;
- (NSString*) description
{
return @"distributed packet is a distributed piece of shit";
}
- (id) init
{
if((self = [super init]))
{
self.mutablePacketArray = [NSMutableArray array];
self.mutableIPSet = [NSMutableSet set];
}
return self;
}
- (void) dealloc
{
self.mutableIPSet = nil;
self.mutablePacketArray = nil;
[super dealloc];
}
- (out bycopy NSArray*) packetArray
{
return self.mutablePacketArray;
}
- (oneway void) addPacket:(in oneway NSDictionary*) packet
{
[self addIP:[packet valueForKey:@"Source"]];
[self addIP:[packet valueForKey:@"Destination"]];
if([self.mutablePacketArray count] > v002_MAX_CAPTURED_PACKETS)
{
[self.mutablePacketArray removeLastObject];
}
else
[self.mutablePacketArray insertObject:packet atIndex:0];
}
- (oneway void) addIP:(in oneway NSString*) ip
{
if(ip)
[self.mutableIPSet addObject:ip];
}
- (out bycopy NSArray*) ipArray
{
return [self.mutableIPSet allObjects];
}
- (oneway void) setInterface:(in oneway NSString*) device
{
// set the device to be monitored by pcap
NSLog(@"Set Device: %@", device);
}
- (oneway void) quitHelperTool
{
[[NSApplication sharedApplication] terminate:nil];
}
- (oneway void) debug
{
NSLog(@"Debugging");
}
@end