1// Copyright 2018 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5library fuchsia.net;
6
7// Legacy interface to create a socket
8enum SocketDomain {
9    inet = 2;
10    inet6 = 10;
11};
12
13enum SocketType {
14    stream = 1;
15    dgram = 2;
16};
17
18enum SocketProtocol {
19    ip = 0;
20    icmp = 1;
21    tcp = 6;
22    udp = 17;
23    ipv6 = 41;
24    icmpv6 = 58;
25};
26
27struct String {
28    array<uint8>:256 val;
29    uint32 len;
30};
31
32enum AddrInfoStatus {
33    ok = 0;
34    // invalid flags
35    bad_flags = 1;
36    // missing node name or service name
37    no_name = 2;
38    // temporary failure
39    again = 3;
40    // non-recoverable failure
41    fail = 4;
42    // no address found for node name
43    no_data = 5;
44    // argument buffer overflow
45    buffer_overflow = 6;
46    // system error
47    system_error = 7;
48};
49
50struct AddrInfoHints {
51    int32 flags;
52    int32 family;
53    int32 sock_type;
54    int32 protocol;
55};
56
57struct AddrStorage {
58    array<uint8>:16 val;
59    uint32 len;
60    int32 unused; // TODO: remove this once the field alignment issue is fixed.
61};
62
63struct AddrInfo {
64    int32 flags;
65    int32 family;
66    int32 sock_type;
67    int32 protocol;
68    AddrStorage addr;
69    uint16 port;
70};
71
72[Discoverable, Layout = "Simple"]
73interface LegacySocketProvider {
74    1: OpenSocket(SocketDomain domain, SocketType type, SocketProtocol protocol)
75           -> (handle<socket>? s, int32 status);
76    2: GetAddrInfo(String? node, String? service, AddrInfoHints? hints)
77           -> (AddrInfoStatus status, int32 nres, AddrInfo? ai0, AddrInfo? ai1, AddrInfo? ai2, AddrInfo? ai3);
78    // TODO: change (nres, ai0, ai1, ai2, ai3) to a vector once we can.
79};
80