XU XUv0.13.1
中文

#embedded/wifi/ipv4

import: #embedded/wifi/ipv4

counts: 7 functions, 4 methods, 2 types, 5 constants, 0 method sets

IDs are network-order byte strings, independent of the target int width. Input LLC bytes must already have passed 802.11/CCMP authentication, replay checking and deaggregation. These functions do not establish a radio link.

const DHCP_READY

XuAPI
pub const DHCP_READY = 0

Purpose

Constant DHCP_READY, defining protocol or algorithm parameters.

const DHCP_SELECTING

XuAPI
pub const DHCP_SELECTING = 1

Purpose

Constant DHCP_SELECTING, defining protocol or algorithm parameters.

const DHCP_REQUESTING

XuAPI
pub const DHCP_REQUESTING = 2

Purpose

Constant DHCP_REQUESTING, defining protocol or algorithm parameters.

const DHCP_LEASED

XuAPI
pub const DHCP_LEASED = 3

Purpose

Constant DHCP_LEASED, defining protocol or algorithm parameters.

const DHCP_FAILED

XuAPI
pub const DHCP_FAILED = 4

Purpose

Constant DHCP_FAILED, defining protocol or algorithm parameters.

struct Client

XuAPI
pub struct Client {
    pub state int
    pub mac string
    pub xid string
    pub offered string
    pub server string
    pub address string // empty until a matching, valid DHCPACK
    pub mask string
    pub router string
    pub lease_seconds string // network-order uint32; not a host-width int
}

Purpose

Ipv4 Client session maintaining connection and operations.

Public fields

state int
field (int)
mac string
field (string)
xid string
field (string)
offered string
field (string)
server string
field (string)
address string // empty until a matching, valid DHCPACK
field (string // empty until a matching, valid DHCPACK)
mask string
field (string)
router string
field (string)
lease_seconds string // network-order uint32; not a host-width int
field (string // network-order uint32; not a host-width int)

create

XuAPI
pub fn create(mac string, xid string) Client

Purpose

The caller supplies an unpredictable four-byte XID for each new exchange. This is initial acquisition only. Retry clocks, lease expiration, renewal, duplicate-address detection and DHCPDECLINE belong to the caller.

Parameters

mac string
mac (string)
xid string
xid (string)

Returns

Client — a value of this type

($&Client) discover

XuAPI
pub fn (c $&Client) discover() string

Purpose

Execute discover on $&Client.

Parameters

c $&Client
The Client instance used by this call (exclusive borrow).

Returns

string — result string

($&Client) request

XuAPI
pub fn (c $&Client) request() string

Purpose

Execute request on $&Client.

Parameters

c $&Client
The Client instance used by this call (exclusive borrow).

Returns

string — result string

($&Client) receive_llc

XuAPI
pub fn (c $&Client) receive_llc(payload &string) bool

Purpose

True means one accepted state transition, including a matching DHCPNAK. The caller checks state == DHCP_LEASED before using address/mask/router.

Parameters

c $&Client
The Client instance used by this call (exclusive borrow).
payload &string
payload (read-only borrow; caller keeps the original; type &string)

Returns

bool — true or false

($&Client) receive_ethernet

XuAPI
pub fn (c $&Client) receive_ethernet(frame &string) bool

Purpose

Ethernet II without FCS or VLAN tags; intended for host packet fixtures or an independently authenticated bridge. 802.11 callers use receive_llc.

Parameters

c $&Client
The Client instance used by this call (exclusive borrow).
frame &string
frame (read-only borrow; caller keeps the original; type &string)

Returns

bool — true or false

arp_request

XuAPI
pub fn arp_request(mac &string, source_ip &string, target_ip &string) string

Purpose

The caller uses a successfully ACKed configuration and performs conflict detection before enabling application traffic. An ARP response alone is evidence of a neighbor, not proof of Internet reachability.

Parameters

mac &string
mac (read-only borrow; caller keeps the original; type &string)
source_ip &string
source_ip (read-only borrow; caller keeps the original; type &string)
target_ip &string
target_ip (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

arp_reply_mac

XuAPI
pub fn arp_reply_mac(payload &string, own_mac &string, own_ip &string, target_ip &string) string

Purpose

Return the matched responder's six-byte MAC, or empty on malformed, unsolicited, multicast/zero sender, or another target's reply.

Parameters

payload &string
payload (read-only borrow; caller keeps the original; type &string)
own_mac &string
own_mac (read-only borrow; caller keeps the original; type &string)
own_ip &string
own_ip (read-only borrow; caller keeps the original; type &string)
target_ip &string
target_ip (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

echo_request

XuAPI
pub fn echo_request(source_ip &string, target_ip &string, id int, sequence int, body &string) string

Purpose

Echo request.

Parameters

source_ip &string
source_ip (read-only borrow; caller keeps the original; type &string)
target_ip &string
target_ip (read-only borrow; caller keeps the original; type &string)
id int
id (int)
sequence int
sequence (int)
body &string
body (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

echo_reply_valid

XuAPI
pub fn echo_reply_valid(payload &string, source_ip &string, target_ip &string, id int, sequence int, body &string) bool

Purpose

source_ip is our local address and target_ip is the peer we queried. Validate the full returned body in addition to identifier and sequence.

Parameters

payload &string
payload (read-only borrow; caller keeps the original; type &string)
source_ip &string
source_ip (read-only borrow; caller keeps the original; type &string)
target_ip &string
target_ip (read-only borrow; caller keeps the original; type &string)
id int
id (int)
sequence int
sequence (int)
body &string
body (read-only borrow; caller keeps the original; type &string)

Returns

bool — true or false

struct ArpResponse

XuAPI
pub struct ArpResponse {
    pub valid bool
    pub destination string
    pub payload string
}

Purpose

Ipv4 Server response payload containing status, headers, and body.

Public fields

valid bool
field (bool)
destination string
field (string)
payload string
field (string)

arp_response

XuAPI
pub fn arp_response(payload &string, own_mac &string, own_ip &string) ArpResponse

Purpose

Answer an ordinary IPv4 peer's request for our acquired address. ARP probes (sender IP zero), conflicts and other targets need separate policy.

Parameters

payload &string
payload (read-only borrow; caller keeps the original; type &string)
own_mac &string
own_mac (read-only borrow; caller keeps the original; type &string)
own_ip &string
own_ip (read-only borrow; caller keeps the original; type &string)

Returns

ArpResponse — a value of this type

echo_response

XuAPI
pub fn echo_response(payload &string, own_ip &string) string

Purpose

Validate an Echo Request before constructing an exact-length reply. Link padding is excluded, and both checksums are recomputed after the changes.

Parameters

payload &string
payload (read-only borrow; caller keeps the original; type &string)
own_ip &string
own_ip (read-only borrow; caller keeps the original; type &string)

Returns

string — result string