forked from nospaceships/node-raw-socket
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.d.ts
102 lines (82 loc) · 1.88 KB
/
index.d.ts
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
94
95
96
97
98
99
100
101
102
import {EventEmitter} from 'events';
export interface Options {
bufferSize?: number;
protocol?: number;
addressFamily?: number;
}
export interface Socket extends EventEmitter {
new(options?: Options): this;
setOption(
level: number,
option: number,
value: number,
length?: number
): void;
getOption(
level: number,
option: number,
value: number,
length?: number
): number;
send(
buffer: Buffer,
offset: number,
length: number,
address: string,
beforeCallback?: () => void,
afterCallback?: (error: Error | null, bytes: number) => void
): this;
send(
buffer: Buffer,
offset: number,
length: number,
address: string,
afterCallback?: (error: Error | null, bytes: number) => void
): this;
recv(
buffer: Buffer,
callback?: (buffer: Buffer, bytes: number, source: string) => void
): this;
pause(recvPaused: boolean, sendPaused: boolean): this;
close(): this;
}
export function createSocket(options?: Options): Socket;
export function writeChecksum(
buffer: Buffer,
offset: number,
checksum: number
): Buffer;
export function createChecksum(...args: Buffer[]): number;
export interface TAddressFamily {
IPv4: number;
IPv6: number;
}
export const AddressFamily: TAddressFamily;
export interface TProtocol {
ICMP: number;
TCP: number;
UDP: number;
ICMPv6: number;
}
export const Protocol: TProtocol;
export interface TSocketLevel {
IPPROTO_IP: number;
IPPROTO_IPV6: number;
SOL_SOCKET: number;
}
export const SocketLevel: TSocketLevel;
export interface TSocketOption {
SO_BROADCAST: number;
SO_RCVBUF: number;
SO_RCVTIMEO: number;
SO_SNDBUF: number;
SO_SNDTIMEO: number;
IP_HDRINCL: number;
IP_OPTIONS: number;
IP_TOS: number;
IP_TTL: number;
IPV6_TTL: number;
IPV6_UNICAST_HOPS: number;
IPV6_V6ONLY: number;
}
export const SocketOption: TSocketOption;