-
Notifications
You must be signed in to change notification settings - Fork 11
/
socks_util.h
52 lines (46 loc) · 1.04 KB
/
socks_util.h
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
#ifndef SOCKS_UTIL_H
#define SOCKS_UTIL_H
#include <stddef.h>
#include <stdint.h>
#include "socks.h"
static inline size_t socks5_get_request_size (enum socks_addr_types type,
uint8_t dns)
{
switch (type)
{
case SOCKS5_ADDR_IPV4: return 10;
case SOCKS5_ADDR_IPV6: return 22;
case SOCKS5_ADDR_DNS: return 7+dns;
default: return 0;
}
}
static inline size_t socks5_get_reply_size (enum socks_addr_types type,
uint8_t dns)
{
switch (type)
{
case SOCKS5_ADDR_IPV4: return 10;
case SOCKS5_ADDR_IPV6: return 22;
case SOCKS5_ADDR_DNS: return 7+dns;
default: return 0;
}
}
static inline int is_supported_socks5_addr_type (uint8_t type)
{
switch (type)
{
case SOCKS5_ADDR_IPV4: return 1;
case SOCKS5_ADDR_DNS: return 1;
case SOCKS5_ADDR_IPV6: return 1;
default: return 0;
}
}
static inline int is_supported_socks5_err_type (uint8_t type)
{
return (type <= SOCKS5_ADDR_UNSUP);
}
static inline int is_supported_socks_cmd_type (uint8_t type)
{
return (type >= SOCKS_CMD_CONNECT && type <= SOCKS_CMD_UDP);
}
#endif