aboutsummaryrefslogtreecommitdiff
path: root/lib/std/os/uefi/protocols/ip6_protocol.zig
blob: db419630d00940fcbb83f294f858f29cbef48885 (plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
const uefi = @import("std").os.uefi;
const Guid = uefi.Guid;
const Event = uefi.Event;
const Status = uefi.Status;
const MacAddress = uefi.protocols.MacAddress;
const ManagedNetworkConfigData = uefi.protocols.ManagedNetworkConfigData;
const SimpleNetworkMode = uefi.protocols.SimpleNetworkMode;

pub const Ip6Protocol = extern struct {
    _get_mode_data: fn (*const Ip6Protocol, ?*Ip6ModeData, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) callconv(.C) Status,
    _configure: fn (*const Ip6Protocol, ?*const Ip6ConfigData) callconv(.C) Status,
    _groups: fn (*const Ip6Protocol, bool, ?*const Ip6Address) callconv(.C) Status,
    _routes: fn (*const Ip6Protocol, bool, ?*const Ip6Address, u8, ?*const Ip6Address) callconv(.C) Status,
    _neighbors: fn (*const Ip6Protocol, bool, *const Ip6Address, ?*const MacAddress, u32, bool) callconv(.C) Status,
    _transmit: fn (*const Ip6Protocol, *Ip6CompletionToken) callconv(.C) Status,
    _receive: fn (*const Ip6Protocol, *Ip6CompletionToken) callconv(.C) Status,
    _cancel: fn (*const Ip6Protocol, ?*Ip6CompletionToken) callconv(.C) Status,
    _poll: fn (*const Ip6Protocol) callconv(.C) Status,

    /// Gets the current operational settings for this instance of the EFI IPv6 Protocol driver.
    pub fn getModeData(self: *const Ip6Protocol, ip6_mode_data: ?*Ip6ModeData, mnp_config_data: ?*ManagedNetworkConfigData, snp_mode_data: ?*SimpleNetworkMode) Status {
        return self._get_mode_data(self, ip6_mode_data, mnp_config_data, snp_mode_data);
    }

    /// Assign IPv6 address and other configuration parameter to this EFI IPv6 Protocol driver instance.
    pub fn configure(self: *const Ip6Protocol, ip6_config_data: ?*const Ip6ConfigData) Status {
        return self._configure(self, ip6_config_data);
    }

    /// Joins and leaves multicast groups.
    pub fn groups(self: *const Ip6Protocol, join_flag: bool, group_address: ?*const Ip6Address) Status {
        return self._groups(self, join_flag, group_address);
    }

    /// Adds and deletes routing table entries.
    pub fn routes(self: *const Ip6Protocol, delete_route: bool, destination: ?*const Ip6Address, prefix_length: u8, gateway_address: ?*const Ip6Address) Status {
        return self._routes(self, delete_route, destination, prefix_length, gateway_address);
    }

    /// Add or delete Neighbor cache entries.
    pub fn neighbors(self: *const Ip6Protocol, delete_flag: bool, target_ip6_address: *const Ip6Address, target_link_address: ?*const MacAddress, timeout: u32, override: bool) Status {
        return self._neighbors(self, delete_flag, target_ip6_address, target_link_address, timeout, override);
    }

    /// Places outgoing data packets into the transmit queue.
    pub fn transmit(self: *const Ip6Protocol, token: *Ip6CompletionToken) Status {
        return self._transmit(self, token);
    }

    /// Places a receiving request into the receiving queue.
    pub fn receive(self: *const Ip6Protocol, token: *Ip6CompletionToken) Status {
        return self._receive(self, token);
    }

    /// Abort an asynchronous transmits or receive request.
    pub fn cancel(self: *const Ip6Protocol, token: ?*Ip6CompletionToken) Status {
        return self._cancel(self, token);
    }

    /// Polls for incoming data packets and processes outgoing data packets.
    pub fn poll(self: *const Ip6Protocol) Status {
        return self._poll(self);
    }

    pub const guid align(8) = Guid{
        .time_low = 0x2c8759d5,
        .time_mid = 0x5c2d,
        .time_high_and_version = 0x66ef,
        .clock_seq_high_and_reserved = 0x92,
        .clock_seq_low = 0x5f,
        .node = [_]u8{ 0xb6, 0x6c, 0x10, 0x19, 0x57, 0xe2 },
    };
};

pub const Ip6ModeData = extern struct {
    is_started: bool,
    max_packet_size: u32,
    config_data: Ip6ConfigData,
    is_configured: bool,
    address_count: u32,
    address_list: [*]Ip6AddressInfo,
    group_count: u32,
    group_table: [*]Ip6Address,
    route_count: u32,
    route_table: [*]Ip6RouteTable,
    neighbor_count: u32,
    neighbor_cache: [*]Ip6NeighborCache,
    prefix_count: u32,
    prefix_table: [*]Ip6AddressInfo,
    icmp_type_count: u32,
    icmp_type_list: [*]Ip6IcmpType,
};

pub const Ip6ConfigData = extern struct {
    default_protocol: u8,
    accept_any_protocol: bool,
    accept_icmp_errors: bool,
    accept_promiscuous: bool,
    destination_address: Ip6Address,
    station_address: Ip6Address,
    traffic_class: u8,
    hop_limit: u8,
    flow_label: u32,
    receive_timeout: u32,
    transmit_timeout: u32,
};

pub const Ip6Address = [16]u8;

pub const Ip6AddressInfo = extern struct {
    address: Ip6Address,
    prefix_length: u8,
};

pub const Ip6RouteTable = extern struct {
    gateway: Ip6Address,
    destination: Ip6Address,
    prefix_length: u8,
};

pub const Ip6NeighborState = enum(u32) {
    Incomplete,
    Reachable,
    Stale,
    Delay,
    Probe,
};

pub const Ip6NeighborCache = extern struct {
    neighbor: Ip6Address,
    link_address: MacAddress,
    state: Ip6NeighborState,
};

pub const Ip6IcmpType = extern struct {
    type: u8,
    code: u8,
};

pub const Ip6CompletionToken = extern struct {
    event: Event,
    status: Status,
    packet: *anyopaque, // union TODO
};