-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNSData+ProxyPacket.h
More file actions
54 lines (47 loc) · 1.39 KB
/
NSData+ProxyPacket.h
File metadata and controls
54 lines (47 loc) · 1.39 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
54
//
// NSData+ProxyPacket.h
// Slink
//
// Created by Tim Wu on 7/18/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import <arpa/inet.h>
typedef NSData ProxyPacket;
typedef NSMutableData MutableProxyPacket;
#import "ProxyInfo.h"
#import "NSString+MacAddress.h"
#import "NSArray+ProxyList.h"
#define CONTROL_PACKET_MAGIC 0x12345678
// Magic number and the type
#define PACKET_HEADER_SZ (sizeof(uint32_t) * 2)
#define ETHERNET_HEADER_SZ 14
#define IP_HEADER_SZ 20
#define UDP_HEADER_SZ 8
typedef enum {
INJECT,
INTRODUCE,
INTRODUCE_ACK,
PROXY_LIST,
LIST_PROXY_REQ,
INVALID
} PACKET_TYPE;
@interface NSData (ProxyPacket)
+ (ProxyPacket *) introducePacketToHost:(NSString *) host port:(UInt16) port;
+ (ProxyPacket *) introduceAckPacketToHost:(NSString *) host port:(UInt16) port;
+ (ProxyPacket *) introducePacket:(ProxyInfo *) receieverInfo;
+ (ProxyPacket *) introduceAckPacket:(ProxyInfo *) receieverInfo;
+ (ProxyPacket *) listProxyReqPacket;
- (PACKET_TYPE) packetType;
- (PACKET_TYPE) filterInject;
- (const void *) packetData;
- (NSUInteger) packetLength;
- (MacAddress *) srcMacAddress;
- (MacAddress *) dstMacAddress;
- (ProxyList *) proxyList;
- (ProxyInfo *) receiverProxyInfo;
@end
@interface NSMutableData (MutableProxyPacket)
+ (MutableProxyPacket *) proxyPacketWithType:(uint32_t) type andLength:(uint32_t) length;
- (void *) mutablePacketData;
@end