v / vlib / net
Raw file | 66 loc (57 sloc) | 969 bytes | Latest commit hash de136f6ba
1module net
2
3const max_unix_path = 108
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_in {
18mut:
19 sin_family u16
20 sin_port u16
21 sin_addr u32
22}
23
24pub struct C.sockaddr_in6 {
25mut:
26 sin6_family u16
27 sin6_port u16
28 sin6_addr [4]u32
29}
30
31pub struct C.sockaddr_un {
32mut:
33 sun_family u16
34 sun_path [max_unix_path]char
35}
36
37[_pack: '1']
38pub struct Ip6 {
39 port u16
40 flow_info u32
41 addr [16]u8
42 scope_id u32
43}
44
45[_pack: '1']
46pub struct Ip {
47 port u16
48 addr [4]u8
49 // Pad to size so that socket functions
50 // dont complain to us (see in.h and bind())
51 // TODO(emily): I would really like to use
52 // some constant calculations here
53 // so that this doesnt have to be hardcoded
54 sin_pad [8]u8
55}
56
57pub struct Unix {
58 path [max_unix_path]u8
59}
60
61[_pack: '1']
62pub struct Addr {
63pub:
64 f u16
65 addr AddrData
66}