| 1 | module net |
| 2 | |
| 3 | const max_unix_path = 108 |
| 4 | |
| 5 | pub struct C.addrinfo { |
| 6 | mut: |
| 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 | |
| 17 | pub struct C.sockaddr_in { |
| 18 | mut: |
| 19 | sin_family u16 |
| 20 | sin_port u16 |
| 21 | sin_addr u32 |
| 22 | } |
| 23 | |
| 24 | pub struct C.sockaddr_in6 { |
| 25 | mut: |
| 26 | sin6_family u16 |
| 27 | sin6_port u16 |
| 28 | sin6_addr [4]u32 |
| 29 | } |
| 30 | |
| 31 | pub struct C.sockaddr_un { |
| 32 | mut: |
| 33 | sun_family u16 |
| 34 | sun_path [max_unix_path]char |
| 35 | } |
| 36 | |
| 37 | @[_pack: '1'] |
| 38 | pub struct Ip6 { |
| 39 | port u16 |
| 40 | flow_info u32 |
| 41 | addr [16]u8 |
| 42 | scope_id u32 |
| 43 | } |
| 44 | |
| 45 | @[_pack: '1'] |
| 46 | pub 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 | |
| 57 | pub struct Unix { |
| 58 | path [max_unix_path]u8 |
| 59 | } |
| 60 | |
| 61 | @[_pack: '1'] |
| 62 | pub struct Addr { |
| 63 | pub: |
| 64 | f u16 |
| 65 | addr AddrData |
| 66 | } |
| 67 | |