v / vlib / net
Raw file | 74 loc (65 sloc) | 1.14 KB | Latest commit hash de136f6ba
1module net
2
3const max_unix_path = 104
4
5pub struct C.addrinfo {
6mut:
7 ai_family int
8 ai_socktype int
9 ai_flags int
10 ai_protocol int
11 ai_addrlen int
12 ai_addr voidptr
13 ai_canonname voidptr
14 ai_next voidptr
15}
16
17pub struct C.sockaddr_in6 {
18mut:
19 // 1 + 1 + 2 + 4 + 16 + 4 = 28;
20 sin6_len u8 // 1
21 sin6_family u8 // 1
22 sin6_port u16 // 2
23 sin6_flowinfo u32 // 4
24 sin6_addr [16]u8 // 16
25 sin6_scope_id u32 // 4
26}
27
28pub struct C.sockaddr_in {
29mut:
30 sin_len u8
31 sin_family u8
32 sin_port u16
33 sin_addr u32
34 sin_zero [8]char
35}
36
37pub struct C.sockaddr_un {
38mut:
39 sun_len u8
40 sun_family u8
41 sun_path [max_unix_path]char
42}
43
44[_pack: '1']
45pub struct Ip6 {
46 port u16
47 flow_info u32
48 addr [16]u8
49 scope_id u32
50}
51
52[_pack: '1']
53pub struct Ip {
54 port u16
55 addr [4]u8
56 // Pad to size so that socket functions
57 // dont complain to us (see in.h and bind())
58 // TODO(emily): I would really like to use
59 // some constant calculations here
60 // so that this doesnt have to be hardcoded
61 sin_pad [8]u8
62}
63
64pub struct Unix {
65 path [max_unix_path]char
66}
67
68[_pack: '1']
69pub struct Addr {
70pub:
71 len u8
72 f u8
73 addr AddrData
74}