-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPcapListener.h
More file actions
53 lines (43 loc) · 1.04 KB
/
PcapListener.h
File metadata and controls
53 lines (43 loc) · 1.04 KB
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
//
// PcapListener.h
// objcPlayground
//
// Created by Tim Wu on 7/11/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import <pcap.h>
#define READ_TIMEOUT_MS 10
#define SNAPLEN 64 * 1024
#define TASK_PACKETS 1
@interface NSObject (HandlePcapPacket)
- (void) handleSniffedPacket:(NSData *) packet;
@end
@interface PcapListenerException : NSException
{
}
@end
/*!
@class
@abstract Simple class to listen on an interface for packets.
*/
@interface PcapListener : NSObject {
pcap_t * pcap;
bpf_u_int32 net, mask;
NSString * listenInterface;
NSString * filter;
NSThread * pollThread;
id delegate;
}
+ (NSArray *) getAvailableInterfaces;
@property (assign) NSString * filter;
// Initializers
- (id) initWithInterface:(NSString *) _interface withDelegate:(id) _delegate;
- (id) initWithInterface:(NSString *) _interface withDelegate:(id) _delegate
AndFilter:(NSString *) _filter;
- (int) inject: (NSData *) packet;
// Lifecyle methods
- (void) close;
// Internal methods
- (void) packetLoop;
@end